4

I am trying a very simple example of trying to import a svg image, I am following the manual on http://mirrors.acm.jhu.edu/ctan/graphics/svg/doc/svg.pdf but this doesn't work at all:

\documentclass{article}
\usepackage{svg}
\begin{document}
\includesvg{p.svg}
\end{document}

but I get an error:

! LaTeX Error: Unknown graphics extension: .svg

which shouldn't happen. I don't want to have to keep converting between SVG and EPS (which I can import) because this complicates the image-making process and clutters my directories. I'm trying to use includesvg the same way I would use includegraphics, just like the manual said. The manual isn't giving working examples, and this error doesn't even show up on google searches.

How can I import an SVG image?

  • 2
    Do you have tried to use \includesvg{p} only, i.e. without .svg extension? – user31729 Apr 5 '17 at 13:29
  • @ChristianHupfer yes, this gives the error ! LaTeX Error: File ./p' not found` – con Apr 5 '17 at 13:31
  • The introduction of the manual mentions the fact that typesetting should be done with the --shell-espace flag and Inkscape must be accessible fromt he terminal (by setting the PATH variable on Windows for example). Are you sure these requirements are satisfied in your case? – epR8GaYuh Apr 5 '17 at 13:44
  • @epR8GaYuh running pdflatex with --shell-escape and that inkscape is accessible from the terminal make no difference, the same error is produced – con Apr 5 '17 at 13:53
3

How to include an SVG file, with the minimal working example, with the file "p.svg":

\documentclass{article}
\usepackage{svg}
\begin{document}
\includesvg[width=\textwidth]{p}
\end{document}

but.... the package svg-extract (or inkscape) may or may not be installed on your system, which you can install on Ubuntu with

con@e:~/Scripts$ sudo tlmgr install svg-extract
[sudo] password for con: 
(running on Debian, switching to user mode!)
cannot setup TLPDB in /home/con/texmf at /usr/bin/tlmgr line 5604

ignore the last line, it works without this.

The latex script can be compiled to PDF with this:

pdflatex --shell-escape svg_graphic.tex
  • Can you please include your p.svg in this MWE? – Adam Kurkiewicz Sep 25 '17 at 12:53

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.