ローカル目次の深さをメイン目次の深さより小さく設定するか、ローカル目次の範囲を制限する

ローカル目次の深さをメイン目次の深さより小さく設定するか、ローカル目次の範囲を制限する

大きな文書にメイン\tableofcontentsといくつかの項目を設定しようとしています\localtableofcontents。文書は、序論、いくつかの部分、結論、参考文献で構成されています。

目次について:

  • はじめに、結論、参考文献は、本文の章として設定する必要があります\tableofcontents。最後の 2 つには番号を付けないでください。
  • 各パーツの表紙には、\localtableofcontents該当パーツの

私はパッケージを利用してこれを実現しようとしました{etoc}。次の MWE は、希望どおりにメインの toc を生成します。

\documentclass{report}
\usepackage{titlesec}
\usepackage{etoc}

% to be able to show localtoc on part-page
\titleclass{\part}{top}
\titleformat{\part}[display]{\normalfont\huge\filcenter\bfseries}{\partname\ \thepart}{0pt}{}

\begin{document}

\tableofcontents

\chapter{Introduction}

\part{A Part}
\etocsettocstyle{}{}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{A Chapter}
\section{A section}

\part{Another Part}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{Another Chapter}
\section{Another Section}

% (1) change local toc's depth
%\etocsettocdepth{part}
%\etocignoretoctocdepth

% (2) limit scope of last local toc
%\etocsetnexttocdepth{part}
%\invisiblelocaltableofcontents

\chapter*{Conclusion}
% to add unnumbered conclusion to toc:
\addcontentsline{toc}{chapter}{Conclusion}

\bibliographystyle{plainnat}
% to add unnumbered bibliography to toc:
\addcontentsline{toc}{chapter}{\bibname}
\bibliography{\jobname}
\end{document}

しかし、最後の結論と参考文献を除外することはできません\localtableofcontents

ここに画像の説明を入力してください

私の考えは次のいずれかでした:

  1. \etocsettocdepth最後は\localtableofcontents結論の直前に章がなくなる
  2. \localtableofcontents結論に到達しないように最後の範囲を制限する

私の試みは、上記の MWE でコメントアウトされています。しかし、どうせ効果がないようなので、実行しても問題ないかもしれません...

最後の結論と参考文献を除外するにはどうすればよいですか\localtableofcontents?

答え1

このような場合、etocコマンド があります\etocsetlocaltop。これは少し変わった構文で、ファイルpartに区切りを挿入するにはtoc次のように記述します。

\etocsetlocaltop.toc{part}

tocこれにより、新しいものが開始されたかのように動作するマーカーが追加されますpart。詳細については、etoc ドキュメント

完全な文書は次のようになります

\documentclass{report}
\usepackage{titlesec}
\usepackage{etoc}

% to be able to show localtoc on part-page
\titleclass{\part}{top}
\titleformat{\part}[display]{\normalfont\huge\filcenter\bfseries}{\partname\ \thepart}{0pt}{}

\begin{document}

\tableofcontents

\chapter{Introduction}

\part{A Part}
\etocsettocstyle{}{}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{A Chapter}
\section{A section}

\part{Another Part}
\etocsetnexttocdepth{section}
\localtableofcontents
\chapter{Another Chapter}
\section{Another Section}

% limit scope of last local toc
\etocsetlocaltop.toc{part}

\chapter*{Conclusion}
% to add unnumbered conclusion to toc:
\addcontentsline{toc}{chapter}{Conclusion}

\bibliographystyle{plainnat}
% to add unnumbered bibliography to toc:
\addcontentsline{toc}{chapter}{\bibname}
\bibliography{\jobname}
\end{document}

ここに画像の説明を入力してください

関連情報