我想知道如何隐藏目录中的某个部分,但又不会丢失文档正文中的部分编号。例如,在这个 tex 文件中,我丢失了 hide
的编号,并且所有序列都被损坏:
\documentclass{article}
\begin{document}
\tableofcontents
\section{uno}
\section{dos}
\section*{hide}
\section{tres}
\end{document}
最佳答案
我认为您正在寻找
\section*{hide}
\addtocounter{section}{1}
或者将其变成命令:
\newcommand{\toclesssection}[1]{\section*{#1}\addtocounter{section}{1}}
编辑:
好吧,我想我明白现在想要什么了(这比我给出的答案更有意义)。下面是一个命令,您可以使用它来禁止向目录中添加节、小节等。这个想法是暂时禁用 \addcontentsline
。
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
...
\tocless\section{hide}
\tocless\subsection{subhide}
关于latex - 在 Latex 中隐藏 Toc 的条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2785260/