
假設一本書只有 4 章。假設每章都有大量的章節,例如 100。
對於這樣一本書,最好有兩個連續的目錄:第一個目錄只涉及章節,第二個目錄將章節分為幾節。
我怎麼能這樣做呢?
在以下範例中,第二個目錄變為空白。
\documentclass{book}
\begin{document}
\setcounter{tocdepth}{0}
\tableofcontents
\setcounter{tocdepth}{1}
\tableofcontents
\chapter{One}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Two}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Three}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Four}
\section{a} \section{b} \section{c} \section{d} \section{e}
\end{document}
答案1
包裹shorttoc
\documentclass{book}
\usepackage{shorttoc}
\begin{document}
\shorttableofcontents{\contentsname}{0}
\setcounter{tocdepth}{1}
\tableofcontents
\chapter{One}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Two}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Three}
\section{a} \section{b} \section{c} \section{d} \section{e}
\chapter{Four}
\section{a} \section{b} \section{c} \section{d} \section{e}
\end{document}
您可以使用\shorttoc{\contentsname}{0}