
我有一個很深的標題結構(直到 subsubsubsection),並且想僅顯示整個文件的部分和小節 - 到目前為止這很容易。但僅對於一個部分,我希望在目錄中也出現子小節和子子小節 - 有機會這樣做嗎?
答案1
這是一個簡化的範例,僅擴展到小節層級。
這個想法是重置文件本身的報告層級.toc
。這是透過在\addtocontents
適當的點插入適當的命令來完成的。
\documentclass{article}
\setcounter{tocdepth}{1}
\begin{document}
\tableofcontents
\section{First}
\subsection{One-first}
text
\subsection{One-second}
text
\section{Second}
\addtocontents{toc}{\setcounter{tocdepth}{2}}
\subsection{Two-first}
text
\subsection{Two-second}
text
\addtocontents{toc}{\setcounter{tocdepth}{1}}
\section{Third}
\subsection{Three-first}
text
\subsection{Three-second}
text
\end{document}