附录中的部分内容应如下所示
A.1 Name of the first section
A.2 Name of the second section
而在 ToC 中应该只显示
A name of appendix A
使用\section*{Name of the first section}
不起作用,因为它会影响附录内的编号。
\documentclass[a4paper,12pt,titlepage,oneside,final]{book}
\usepackage[english]{babel}
\begin{document}
\tableofcontents
\appendix
\chapter{Name of appendix A}
\section*{Name of the first section}
\section{Name of the second section}
\end{document}
答案1
无需任何附加包,只需在命令后添加以下行即可完成此操作\appendix
:
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
梅威瑟:
\documentclass[a4paper,12pt,titlepage,oneside,final]{book}
\usepackage[english]{babel}
\begin{document}
\tableofcontents
\appendix
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
\chapter{Name of appendix A}
\section{Name of the first section}
\section{Name of the second section}
\end{document}
输出
答案2
您可以使用tocvsec2
包来更改所需位置的 ToC 深度:
\documentclass[a4paper,12pt,titlepage,oneside,final]{book}
\usepackage[english]{babel}
\usepackage{tocvsec2}
\begin{document}
\tableofcontents
\appendix
\chapter{Name of appendix A}
\settocdepth{chapter}
\section{Name of the first section}
\section{Name of the second section}
\chapter{Name of appendix B}
\section{Name of the first section}
\section{Name of the second section}
\end{document}