
그만큼subfiles
문서기본 파일과 하위 파일이 서로 다른 디렉터리에 있고 하위 파일에 패키지를 사용하는 자체 디렉터리에 대한 상대 경로가 포함되어 있는 경우 경로 문제를 처리한다고 설명합니다 \import
.나타난다이는 에 전달된 파일의 내용을 추가할 때 subfiles
사용됨을 의미합니다 . 예를 들어 는 를 호출하는 프리앰블을 수정하는 것과 대략 동일합니다 . 명확하지 않은 것은 올바른 방법입니다.\import
\subfile
\subfile{ch/ch1.tex}
ch1.tex
\import{ch/ch1.tex}
둥지 수입, 즉 가져온 하위 파일 내에서 가져옵니다.
아래에는 main.tex가 ch1.tex를 가져와야 하고 ch1.tex가 fig.png와 text.txt를 가져와야 한다고 가정하는 예제 프로젝트/디렉토리 구조와 두 개의 예제 파일이 제공됩니다.
+-- main.tex
+-- chapters
|
+-- ch1.tex
+-- content
|
+-- text1.txt
+-- fig1.png
%% main.tex
\documentclass{book}
\usepackage{graphicx}
\usepackage{subfiles}
\begin{document}
\subfile{chapters/ch1.tex} % \imports ch1.tex
\end{document}
%% ch1.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
\import{content}{text.txt} % adds some text - note use of \import
\includegraphics{content/fig.png} % adds a figure
\end{document}
위의 파일을 컴파일하면 원하는 출력이 생성됩니다. 그러나 main.tex 호출 \import
에서 사용된 것과 같이\subfile{chapters/ch1.tex}
또한사용된이내에통화 중 ch1.tex \import{content}{text.txt}
. 그만큼import
문서\subimport
후자에 사용해야 함을 나타냅니다 . \subimport requires a path relative to the currently imported file, the call should be
\subimport{content/}{text1.txt}`로.
하위 파일 내에서 가져오기는 항상 사용해야 합니까 subimport
? 그렇다면 문서 의 예제에서와 같이 다른 디렉토리를 가리켜야 할 때 왜 교환 \import
하면 동일한 결과가 생성되는지 혼란스럽습니다 .\subimport
import
답변1
직접 사용할 수 있습니다 \input
.
│ main.tex
│
└─chapters
│ ch1.tex
│
└─content
fig1.png
text1.txt
main.tex
\documentclass{book}
\usepackage{graphicx}
\graphicspath{{chapters/content/}}
\makeatletter
\newcommand{\input@path}{{chapters/}{chapters/content/}}
\makeatother
\begin{document}
aaa
\input{ch1.tex}
bbb
\end{document}
ch1.tex
ccc
\input{text1.txt}
\includegraphics[width=3cm]{fig1.png}
ddd
text1.txt
eee