I'm trying to use the svg package, for some svg files I have in a graphics/ subdirectory. My includegraphics command used to be:


Now, if I write:


I get this issue: The package needs you not to specify the file extension. But if I write


I get:

! LaTeX Error: File `./graphics/foo' not found.

and even if I set the path and write:


I still get:

! LaTeX Error: File `./graphics/foo' not found.

Finally, the svg package documentation says:

The path to the svg can be specified using the svgpath option, where the path must terminate in a /.

So that last attempt should have gotten me there. But just to be on the safe side, I tried:


and still got

! LaTeX Error: File `./graphics/.foo' not found.

What should I do then?


This works, provided you launch pdflatex with the -shell-escape option and you have inkscape on your system. This will call the (slow) conversion from SVG to PDF, with an accompanying TeX file. Later runs don't need the conversion, so they also work without the -shell-escape option.

So, if the file is test.tex you need

pdflatex -shell-escape test

(adjust for the method you run LaTeX on your system).





The SVG file has been taken from https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/

enter image description here

  • Can I get latexmk to use -shell-escape? – einpoklum Mar 23 '16 at 11:25
  • 2
    @einpoklum The manual of latexmk describes how to do it – egreg Mar 23 '16 at 11:31
  • Did you get this to work with latexmk? I'm using the command latexmk -shell-escape mydocument, and getting the same errors as you were getting (! LaTeX Error: File <filename> not found). – Filip S. Oct 21 '16 at 6:52
  • @FilipS.: Sorry for missing your question... as you can tell from my answer below, I went a different way. I'll assume this works. – einpoklum Jun 12 '17 at 22:15

Well, since svg needs inkscape anyway, you can just circumvent the issue altogether and perform the conversion yourself:

inkscape -z --export-pdf=foo.pdf foo.svg

to convert the file once and for all (assuming it doesn't change repeatedly). To automate that over all files in the current directory, try:

ls *.svg | while read f; do inkscape -z --export-pdf="${f/\.svg/.pdf}" "$f"; done

(but make sure your filenames don't contain .svg twice, otherwise you'd need something more involved.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.