include svg images with the svg package

The problem is that you have given a file extension: you should not do this (indeed this seems clear in the svg manual. For me, the short demo

\documentclass{article}
\usepackage{svg}
\usepackage{amsmath} % you need amsmath as the demo includes a use of \eqref
\begin{document}

\begin{figure}[htbp]
  \centering
  \includesvg{image}
  \caption{svg image}
\end{figure}

\end{document}

using the demonstration file used by the package works fine.

Note that for this to work:

  • You need Inkscape on your path (why?) (schtandard pointed to this step-by-step of the setup)
  • You need to compile your .tex file to PDF with the --shell-escape option enabled

I had the same problem.

I found a simple way to deal with it.

  • Just open the svg file by Inkscape.

  • Save as the .pdf format

  • On the next pop up window:

    • Embed Fonts

    • Use exported object's size

    • Margin 0.1

  • click ok

Next the generated pdf file will be imported by latex easily as same as png or eps.


But some times inkscape does not read the svg file properly and some mistakes are occurred. In this case the solution which works for me is:

  • generate a pdf version of figure by your used designer software

  • include the pdf file in latex

  • use trim for cropping the figure in latex

for example:

\includegraphics[width=0.8\textwidth, trim={1cm 3cm 1cm 8cm},clip]{Fig.pdf}

While this may not be a valuable option for some users, it may be worth it for some:

Online SVG to PDF converters.

Here you may find Google search results.

After this one may follow the usual strategies for embedding PDF files into LaTeX,
(as described for example in the answer above).

Hope this helps some users. ;)

Tags:

Graphics

Svg