by
271 12
0
5
6,707
18
Top 1% !
Popular
Famous
Pearl of Wisdom
Tagged
Popularity: 965th place
Created
Modified Jun 26, 2013
This snippet is Public
LicenseMIT_X11

Include SVG image in LaTeX

Best (and fastest) way to include images in LaTeX (Yes.. no Tikz!)
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1253/Include-SVG-image-in-LaTeX?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
First way: ------------------------------------------------------------------------ Export from inkscape an image as PDF, checking "PDF+LaTeX: .." and "Export Area is drawing". In LaTeX then include the resulting pdf_tex file: \begin{figure} \begin{center} \def\svgwidth{\columnwidth} \input{imgs/myimage.pdf_tex} \end{center} \caption{caption} \label{fig:label} \end{figure} If the image is in a subdirectory (like in this case), we must add the following in the preamble: \graphicspath{{imgs/}} ------------------------------------------------------------------------ Second (smart) way: (Note: inkscape must be in the system (command line) path). Add this to the preamble: \newcommand{\executeiffilenewer}[3]{% \ifnum\pdfstrcmp{\pdffilemoddate{#1}}% {\pdffilemoddate{#2}}>0% {\immediate\write18{#3}}\fi% } \newcommand{\includesvg}[1]{% \executeiffilenewer{#1.svg}{#1.pdf}% {inkscape -z -D --file=#1.svg % --export-pdf=#1.pdf --export-latex}% \input{#1.pdf_tex}% } Now simply use the command \includesvg linking the original .svg file instead of using input and exporting the svg to pdf from Inkscape.
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus