【问题标题】:Hide sections from ToC in Latex在 Latex 中隐藏 ToC 中的部分
【发布时间】:2020-05-16 02:05:23
【问题描述】:

我想从目录中隐藏附录的部分,而不会丢失文档正文中的部分编号,并且部分应该可以参考。

我找到了解决办法:hide an entry from Toc in latex

\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.

而且不能使用\label

有没有办法在不丢失编号的情况下隐藏一个部分并且仍然可以引用?

我也试过这个Remove specific subsection from TOC in LaTeX [duplicate]

最小可重现示例:https://latexbase.com/d/498aec5c-d490-47d5-a469-9c6df79a2962

谢谢

【问题讨论】:

标签: latex


【解决方案1】:

使用 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}}

【讨论】:

    猜你喜欢
    • 2017-04-17
    • 1970-01-01
    • 1970-01-01
    • 2015-05-29
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 2011-02-17
    相关资源
    最近更新 更多