1

I am trying to display two figures, which both contain two SVG images in separate minipages each:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{graphicx}
\usepackage{svg}

\begin{document}

\begin{figure}
    \centering
    \begin{minipage}{0.5\textwidth}
        \centering
        \includesvg[width=1.0\textwidth]{plots/PrisonersDilemma/Lattice2D/initial_moral_mean_stability}
    \end{minipage}\hfill
    \begin{minipage}{0.5\textwidth}
        \centering
        \includesvg[width=1.0\textwidth]{plots/PrisonersDilemma/Lattice2D/initial_moral_mean_morality}
    \end{minipage}\hfill
    \caption{Figure 1}
    \label{fig:label1}
\end{figure}

\begin{figure}
    \centering
    \begin{minipage}{0.5\textwidth}
        \centering
        \includesvg[width=1.0\textwidth]{plots/StagHunt/Lattice2D/initial_moral_mean_stability}
    \end{minipage}\hfill
    \begin{minipage}{0.5\textwidth}
        \centering
        \includesvg[width=1.0\textwidth]{plots/StagHunt/Lattice2D/initial_moral_mean_morality}
    \end{minipage}\hfill
    \caption{Figure 2}
    \label{fig:label2}
\end{figure}

\end{document}

In the output, the latter two images are rendered as the first two. That is, the two SVGs in the second figure are supposed to be different:

enter image description here

The SVG files are at the exact locations specified, and I made sure that all four are different. It seems like LaTeX is using the files specified in the first figure for the second figure, too. What am I doing wrong here?

Download archive containing both .tex file and the SVG files for reproducing

1
  • It may be erroneous caching because the filenames are the same (although on different paths). You could try to give the files different names and see if that makes a difference.
    – Marijn
    Jan 28 at 11:31
2

In fact, this is due to the identical file names. By default, all generated files are stored in the current working folder under .\svg-inkscape by their simple file name, which is why these files are overwritten (there are only two pdf files under .\svg-inkscape). This issue (https://github.com/mrpiggi/svg/issues/11) is already known, I am going to fix it in the next main release. For now, \svgsetup{inkscapepath=svgsubdir} could be used as a workaround. This will place the generated files in the respective subfolder of the svg file.

1
  • \svgsetup{inkscapepath=svgsubdir} does indeed solve the problem. Thank you! Jan 28 at 12:32

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.