
다음과 같은 문제가 있습니다. 여러 장으로 구성된 대규모 라텍스 프로젝트 project.tex. 각 장마다 tikz_pdf 폴더에 외부화하려는 여러 개의 tikz 그림이 있습니다. 파일 구조는 그에 따라
home/chapter/chapter1/img/example_1.tikz
home/chapter/chapter1/img/example_2.tikz
home/project.tex
home/tikz_pdf
대규모 프로젝트이므로 매크로를 사용하여 외부화를 자동화하고 싶습니다.
\includetikz{chapter/chapter1/img/example_1.tikz}
대신에
\input{chapter/chapter1/img/example_1.tikz}
/tikz_pdf에 생성된 PDF에서 동일한 tikz 파일 이름을 얻으려면 따라서 "chapter/chapter1/img/example1.tikz"의 외부화된 pdf는 "home/tikz_pdf/example1.pdf"가 됩니다. 이 목적을 위해 다음과 같이 적용할 수 있는 매크로를 사용하고 싶습니다.
\documentclass[12pt,lot, lof]{puthesis}
\usepackage{filemod}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pgfplotsset{plot coordinates/math parser=false}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]
% THIS IS THE MACRO
\makeatletter
\DeclareRobustCommand{\includetikz}[1]{%
\begingroup
\def\textendash{-}%
\includetikz@parse{#1}%
\edef\includetikz@base{\detokenize\expandafter{\includetikz@base}}%
\tikzsetnextfilename{\filename@base}%
\input{#1}%
\endgroup
}
\makeatother
\begin{document}
\begin{figure}
\includetikz{chapter/chapter1/img/example_1.tikz}
\end{figure}
\begin{figure}
\includetikz{chapter/chapter1/img/example_2.tikz}
\end{figure}
\end{document}
그러나 지금까지의 문제는 파일 이름의 밑줄로 인해 \input{#1}이 $ 누락 오류만 발생시킨다는 것입니다. 나는 이미 더 나은 결과 없이 \input{\detokanize{#1}}를 사용하려고 시도했습니다. 이 문제를 해결하는 방법을 알고 있습니까? 정말 감사합니다