質問

質問

質問

複数の目次があるドキュメントがある場合、目次セクションの範囲を制限して目次をリセットできますか?

状況

10 の言語で構成された文書があります。(使用\input{en}, \input{de}, \input{da}言語など) 目次は 11 個あります。

  • 言語ディレクトリ (それぞれで構成) \input(おそらく、それぞれに対するフックを含むカスタム テーブルにする必要があるでしょう\input。これをどのように実装するかはまだわかりません。
  • 各言語ごとのローカル目次(10 言語)

サンプルコード

メイン .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デフォルトのファイルコンテンツ環境の制限に注意してください

\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}

関連情報