Install inkscape2tikz. The following example is taken from inkscape2tikz home page.
Using inkscape2tikz we export this in to tikz code:
\documentclass{article}
\usepackage{tikz}
\usepackage{charter} %%%% Added for demo of fonts
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\definecolor{cff8080}{RGB}{255,128,128}
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1]
\begin{scope}[draw=black,line join=round,miter limit=4.00,line width=3.200pt]
\path[draw=black,fill=cff8080,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (91.0455,165.7194) rectangle
(250.7252,347.8104);
\path[draw=black,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (168.0839,258.1656) .. controls
(169.6992,260.2725) and (166.0408,261.3824) .. (164.5822,260.8503) .. controls
(160.6293,259.4083) and (160.6636,254.1057) .. (162.7146,251.1621) .. controls
(166.3833,245.8967) and (174.0594,246.2369) .. (178.5892,250.1116) .. controls
(185.2369,255.7979) and (184.5602,266.1224) .. (178.8226,272.1726) .. controls
(171.1753,280.2366) and (158.1221,279.2067) .. (150.5752,271.5890) .. controls
(141.0782,262.0028) and (142.4690,246.1872) .. (151.9759,237.1551) .. controls
(163.4900,226.2161) and (182.0854,227.9716) .. (192.5962,239.3729) .. controls
(204.9828,252.8090) and (202.8604,274.1941) .. (189.5613,286.1796) .. controls
(174.2071,300.0173) and (150.0257,297.5267) .. (136.5682,282.3277) .. controls
(121.2770,265.0577) and (124.1368,238.0757) .. (141.2372,223.1481) .. controls
(160.4213,206.4017) and (190.2069,209.6312) .. (206.6032,228.6342) .. controls
(224.8061,249.7311) and (221.2064,282.3227) .. (200.3000,300.1866);
\end{scope}
\end{tikzpicture}
\end{document}
Call this file as image.tex
(say). Following is your main.tex
file. Put image.tex
and main.tex
in the same folder. For this example, I have added image.tex
by filecontents
.
\documentclass{article}
\usepackage{graphicx}
\usepackage{charter} %%%% Added for demo of fonts Keep this in image.tex also to have same fonts
\usepackage{filecontents}
\begin{filecontents*}{image.tex}
\documentclass{article} %%% tex file for image begins
\usepackage{tikz}
\usepackage{charter} %%%% Added for demo of fonts
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\begin{document}
\definecolor{cff8080}{RGB}{255,128,128}
\begin{tikzpicture}[y=0.80pt,x=0.80pt,yscale=-1]
\begin{scope}[draw=black,line join=round,miter limit=4.00,line width=3.200pt]
\path[draw=black,fill=cff8080,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (91.0455,165.7194) rectangle
(250.7252,347.8104);
\path[draw=black,line join=round,even odd rule,line cap=butt,miter
limit=4.00,line width=3.200pt] (168.0839,258.1656) .. controls
(169.6992,260.2725) and (166.0408,261.3824) .. (164.5822,260.8503) .. controls
(160.6293,259.4083) and (160.6636,254.1057) .. (162.7146,251.1621) .. controls
(166.3833,245.8967) and (174.0594,246.2369) .. (178.5892,250.1116) .. controls
(185.2369,255.7979) and (184.5602,266.1224) .. (178.8226,272.1726) .. controls
(171.1753,280.2366) and (158.1221,279.2067) .. (150.5752,271.5890) .. controls
(141.0782,262.0028) and (142.4690,246.1872) .. (151.9759,237.1551) .. controls
(163.4900,226.2161) and (182.0854,227.9716) .. (192.5962,239.3729) .. controls
(204.9828,252.8090) and (202.8604,274.1941) .. (189.5613,286.1796) .. controls
(174.2071,300.0173) and (150.0257,297.5267) .. (136.5682,282.3277) .. controls
(121.2770,265.0577) and (124.1368,238.0757) .. (141.2372,223.1481) .. controls
(160.4213,206.4017) and (190.2069,209.6312) .. (206.6032,228.6342) .. controls
(224.8061,249.7311) and (221.2064,282.3227) .. (200.3000,300.1866);
\end{scope}
\end{tikzpicture}
\end{document}
\end{filecontents*} %%% tex file for image ends
% compile with pdflatex
\immediate\write18{pdflatex image}
% convert to PNG
\makeatletter
\immediate\write18{convert -density 500 -alpha on image.pdf image.png}
\makeatother
%
\begin{document}
\includegraphics[width=5cm]{image} %%% insert .png file
\end{document}
This assumes that you have imagemagick installed.
Best Answer
You could use the
svg
package, which does exactly what thesvg-inkscape
documentation describes.Now all you need to do is save your images as svg files and
pdflatex
does the rest for you.Important: Compile this with the
--shell-escape
flag, e.g.pdflatex --shell-escape my-book.tex
. Have a look at this answer which may help you add this option. (TeXstudio is/was a Texmaker fork.)A couple of points:
inkscape=inkscape -z -D
makes inkscape export the the svg drawing, not the whole page. Change it toinkscape=inkscape -z -C
if you want to export the whole page (or just remove it - it's the default behaviour).svgpath=fig/
is the directory containing your figures. Change this as appropriate, but do not remove the trailing/
.