4

I have the following directory structure:

main.tex
chapter/
    chapter1.tex
    img/
        image.svg

This is the content of main.tex:

\documentclass{report}
\usepackage{svg}

\begin{document}
\import{chapter/}{chapter1}
\end{document}

This is chapter/chapter1.tex:

\begin{figure}
    \centering
    \includesvg[width=0.7\textwidth, svgpath = img/]{image}
    \caption{Caption}
\end{figure}

How to use import package to keep relative path references in subfiles and at the same time use svg files?

If I use the svg in a main file and not in a subfile, it's generated correctly.

  • Does svg work normally on your system? Did you ever try it without \import or svgpath? Consider egreg's comment – Symbol 1 Mar 1 '15 at 6:53
  • Yes, as I said at the end, this works properly without import. Without svgpath attribute it won't work. – bryant1410 Mar 2 '15 at 6:34
  • Oops, missed that. It looks like svg package does know the correct path and did try it. You can prove/disprove it by testing any other extensions (.png/.jpg/etc). Turns out this package reports poor error messages so I cannot tell where things go wrong. A stupid fix may be adding the current directory in \Ginput@path to svgpath by hand. – Symbol 1 Mar 2 '15 at 7:06
  • How can I add \Ginput@path to svgpath? Can you give an example? I've tried, but failed. – bryant1410 Mar 2 '15 at 9:01
0

Adding

\makeatletter
  \svgpath{{\input@path/img/}}
\makeatother

to the start of chapter1.tex works.

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.