
질문
여러 목차가 포함된 문서가 있는 경우 목차 섹션이 추가되는 범위를 제한하고 목차를 재설정할 수 있습니까?
상황
10개 언어로 구성된 문서가 있습니다. (사용 \input{en}, \input{de}, \input{da}
등) 목차는 11개입니다.
- 언어 디렉토리(각각으로 구성됨
\input
(아마도 각각에 대한 후크를 포함하는 사용자 정의 테이블이어야 할 것임)\input
. 아직 이것을 어떻게 구현할지 모르겠습니다. - 각 특정 언어에 대한 로컬 목차(10개 언어)
예제 코드
Main .tex의 예
\documentclass{article}
\usepackage{fontspec}
\begin{document}
\maketableofcontents % language directory (list of inputs with language names)
\input{en}
\input{de}
\input{da}
\end{document}
en.tex의 예
\maketableofcontents % local toc
\section{apple}
%\somecommand % TOC scope limit
de.tex의 예
\maketableofcontents % local toc
\section{apfel}
%\somecommand % TOC scope limit
da.tex의 예
\maketableofcontents % local toc
\section{æble}
%\somecommand % TOC scope limit
답변1
를 사용한 솔루션은 다음과 같습니다 etoc
.기본 filecontents 환경의 제한 사항에 유의하세요.
\begin{filecontents}{en.tex}
\localtableofcontents
\section{apple}
\end{filecontents}
\documentclass{article}
\usepackage{bookmark}
\usepackage{etoc}
% Use this version \newlang{<name>}{<file>}
% to use external files
\newcommand\newlangfile[2]{%
\newlang{#1}%
\input{#2}%
}
\newcommand\newlang[1]{%
\newpage\pdfbookmark{#1}{bkm#1}%
\renewcommand\contentsname{#1 Contents}%
\etoctoccontentsline{part}{#1}%
}
\begin{document}
\setcounter{tocdepth}{0}
\renewcommand\contentsname{Language directory}
\tableofcontents
\setcounter{tocdepth}{3}
%\newlang{english}
%\localtableofcontents
%\section{Apple}
% Or use
\newlangfile{english}{en.tex}
% if you prefer the second macro
\newlang{german}
\localtableofcontents
\section{Apfel}
\newlang{danish}
\localtableofcontents
\section{able}
\end{document}