Sjtuthesis: 修改目录中部分章节的tocdepth的问题

Created on 17 Jan 2019  ·  2Comments  ·  Source: sjtug/SJTUThesis

问题描述:
希望能将附录部分tocdepth设置成0

系统信息:

  • OS版本(带版本号): macOS 10.14.2
  • TeX 发行版(带版本号): MacTeX-2018

日志信息:

  1. 参考stackexchange,尝试在附录.tex文件中的\chapter前添加:
    \addtocontents{toc}{\setcounter{tocdepth}{1}}
    \tableofcontents
    但是编译失败。
    信息如下:
    [1] [2]) [3] [4] (./thesis.toc
    ! Missing number, treated as zero.

    \begingroup
    l.20 ...up \aftergroup \calc@B \calc@A \begingroup
    \aftergroup \calc@B \calc...

?

  1. 还是参考stackenchange的另一个问题,在thesis.tex文件中\appendix后添加一行
    \addtocontents{toc}{\setcounter{tocdepth}{0}},仍然失败,提示信息还是和第一个方法一样,如下:
    [1] [2]) [3] [4] (./thesis.toc
    ! Missing number, treated as zero.

    \begingroup
    l.20 ...up \aftergroup \calc@B \calc@A \begingroup
    \aftergroup \calc@B \calc...

?

强行按enter编译后的目录长成这样
screen shot 2019-01-16 at 19 02 40

作为小白 我的猜测
是不是由于cls文件已经定义了tocdepth,所以在thesis.tex或者其他.tex文件中再定义也会被override?所以要从源头cls解决这个问题?
先行谢过啦!

omacOS typquestion

Most helpful comment

模版使用了 calc 宏包,所以要给 \setcounter 加一个保护:

\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}

另外 \addtocontents 命令是在它后面一章的末尾起作用,所以你要把这一行放到附录之前的那一章的前面:

\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\include{tex/summary}

\appendix % 使用英文字母对附录编号

% 附录内容,本科学位论文可以用翻译的文献替代。
\include{tex/app_setup}

All 2 comments

模版使用了 calc 宏包,所以要给 \setcounter 加一个保护:

\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}

另外 \addtocontents 命令是在它后面一章的末尾起作用,所以你要把这一行放到附录之前的那一章的前面:

\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\include{tex/summary}

\appendix % 使用英文字母对附录编号

% 附录内容,本科学位论文可以用翻译的文献替代。
\include{tex/app_setup}

@AlexaraWu

非常感谢!

刚刚尝试了,完美解决!

Was this page helpful?
0 / 5 - 0 ratings