mjs*_*jsr 37 latex tableofcontents
我想知道如何隐藏目录中的一个部分,但不会丢失文档正文中的部分编号.例如,在这个tex文件中,我丢失了数字hide,并且所有序列都被损坏了:
\documentclass{article}
\begin{document}
\tableofcontents
\section{uno}
\section{dos}
\section*{hide}
\section{tres}
\end{document}
Run Code Online (Sandbox Code Playgroud)
Iva*_*rus 56
我想你在找
\section*{hide}
\addtocounter{section}{1}
Run Code Online (Sandbox Code Playgroud)
或者把它变成一个命令:
\newcommand{\toclesssection}[1]{\section*{#1}\addtocounter{section}{1}}
Run Code Online (Sandbox Code Playgroud)
编辑:
好吧,我想我现在明白了什么(而且我给出的答案更有意义).这是一个命令,您可以使用该命令来禁止向TOC添加节,子节等.想法是暂时禁用\addcontentsline.
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
...
\tocless\section{hide}
\tocless\subsection{subhide}
Run Code Online (Sandbox Code Playgroud)
小智 5
只是想对伊万的提示表示感谢!(我只是在为我的自定义 (Sub)Appendix{} 命令搜索类似的东西:
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
\newcommand{\Appendix}[1]{
\refstepcounter{section}
\section*{Appendix \thesection:\hspace*{1.5ex} #1}
\addcontentsline{toc}{section}{Appendix \thesection}
}
\newcommand{\SubAppendix}[1]{\tocless\subsection{#1}}
Run Code Online (Sandbox Code Playgroud)
也许这对其他人也有用......)