我想把附录的章节从目录中隐藏起来,同时不丢失文档正文中的章节号,而且章节应该可以参考。
我找到了一个解决方案。用乳胶隐藏Toc中的一个条目
\newcommand{\toclesslab}[3].
{\bgroup\let\addcontentsline=\nocontentsline#1{#2\label{#3}}\egroup}
用法: \toclesslab/section{Motivation}{s:motivation}。
但它显示了两个错误,第一个在命令之后。
Argument of \label has an extra }.
Missing $ inserted.
第二个错误在行后
LaTeX Error: Not in outer par mode.
Undefined control sequence.
Missing number, treated as zero.
而且不可能使用 "标签"。
有没有一种方法可以隐藏一个章节,而不丢失编号,同时还可以引用?
我也试过这个方法 从LaTeX格式的TOC中删除具体分节[重复]
最小的可复制的例子。https:/latexbase.comd498aec5c-d490-47d5-a469-9c6df79a2962。
谢谢你了
可以通过使用toc depth来实现,但必须将深度重置回之前的值,否则会破坏其他列表。
\appendix
\section*{Appendix}
\addcontentsline{toc}{section}{Appendix}
%Here's the place to hide section from ToC
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\section{Appendix section}
\label{appendixSection}
Text
%At the end of the appendix it has to be set to the previous value
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}