I'm making all my diagrams in SVG format using Inkscape and then I export them to some other format (e.g. PDF, EPS or PNG). I wrote a short script that does this for me automatically, but I'd like to avoid this step, if possible — sometimes the conversion from SVG converts the text labels into vectors, and that's annoying. Hence the question:
Is there a way to include SVG diagrams directly without conversion to an intermediate format?
Package suggestions, or instructions for specific LaTeX distribution are welcome. Tips and personal experience on which tools you have found to be working reliably would be also appreciated.
Best Answer
There is now (at time of writing for about a month) a package
svg
on CTAN and also included into the big TeX distributions.This package makes use of pdfTeX primitives. Not all of these are defined in LuaTeX, so you would get errors on compiling. See answer of Heiko Oberdiek for a solution.
Every SVG file given by the command
\includesvg
will under the hood be converted with the help of some additional programs, which at least on Windows are not installed by default (the package claims, it wouldn’t run in Windows, but see below):convert
)pdftops
)Notes:
For compilation
pdflatex
needs the command line switch--shell-escape
.All executables/binaries must be located in the search path. In Windows only the “ImageMagick” installer does this by default. For
inkscape
andpstopdf
one needs to add the paths oneself, or I would recommend for each a batch file in the binary path of your local texmf tree (which anyway should be itself in the search path). Additonal hint for MiKTeX users: Create a local texmf tree in MiKTeX.inkscape.cmd
(it must get this name!):pdftops.cmd
(it also must be named this way!), not needed for Users of TeX Live:Of course, adjust the paths to your local settings.
The package uses the *nix specific commands
mv
andrm
. In Windows we can emulate them once more with batch scripts, which again must get the names given here and should be put into the bin folder of the local texmf tree:mv.cmd
:The switch
/Y
overwrites existing files without any question! I introduced it here for the use with TeX editors.rm.cmd
:The switch
/Q
also suppresses any question!