Graphics, Figures & TablesIncluding SVG images in LaTeX using Inkscape

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Including SVG images in LaTeX using Inkscape

Post by meho_r »

Just in case someone missed it: Inkscape (version 0.48) now has a neat trick for using SVG images in LaTeX documents (actually, there's still conversion to PDF, but the process is now much easier). But, the best thing is: the text is now rendered by LaTeX, not Inkscape, which I personally consider a great thing.

For more infos, please check Inkscape's Release Notes and svg-inkscape "package" on CTAN.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

raman_raja
Posts: 1
Joined: Wed Jan 26, 2011 1:29 pm

Re: Including SVG images in LaTeX using Inkscape

Post by raman_raja »

I creaed a vector figure in Inkscape and saved it as a PDF file. But when I compiled it with Pdflatex I got the infamous 'bounding box not defined' error message. No forum could satisfactorily address this. Finally I found the answer by trial and error. This is my tex file :

% Embedding vector graphics in Latex
% Create the vector graphics in InkScape
% Save it as PDF file, say myfigure.pdf
% Choose the option Export Area is Drawing at the second step of saving
% usepackage[pdftex]{graphicx} is important
% includegraphics{myfigure} without the .pdf extension is important

\documentclass{article}
\usepackage[pdftex]{graphicx}
\begin{document}
Hello world!
\begin{figure*}[t]
\centering
\includegraphics{myfigure}
\caption{Test}
\end{figure*}
\end{document}
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Including SVG images in LaTeX using Inkscape

Post by meho_r »

But if you include a picture this way, you miss the whole point of this feature.

It's better that you do the following:

1. Create a drawing in Inkscape (put some math in it, just for testing purposes, e.g. $E=mc^2$)

2. Save the drawing as a PDF file, but don't forget to select PDF+LaTeX: Omit text in PDF and create LaTeX file and Export area is drawing options, as noted in the documentation

3. In your .tex document include the drawing using \input command, not \includegraphics:

Code: Select all

\documentclass{article}

\usepackage{graphicx}
\usepackage{xcolor}

\begin{document}

\begin{figure}
\centering
\input{mydrawing.pdf_tex}
\end{figure}

\end{document}
The whole procedure as well as known problems (including bounding box issue) are explained in svg-inkscape package documentation, so make sure you take a look at it.
Attachments
Test.zip
An example file for testing purposes
(1.74 KiB) Downloaded 463 times
Post Reply