如何使用導入包在子文件中保留相對路徑引用並同時使用svg?

如何使用導入包在子文件中保留相對路徑引用並同時使用svg?

我有以下目錄結構:

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

這是以下內容main.tex

\documentclass{report}
\usepackage{svg}

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

這是chapter/chapter1.tex

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

如何使用導入包在子文件中保留相對路徑引用,同時使用svg檔?

如果我在主文件而不是子文件中使用 svg,它就會正確生成。

答案1

添加

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

到工程開始chapter1.tex

相關內容