
大きな文書にメイン\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
。
私の考えは次のいずれかでした:
\etocsettocdepth
最後は\localtableofcontents
結論の直前に章がなくなる\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}