我正在上课report
。我希望目录如下所示。
1 Chapter 1 ............................ 2
Appendices ............................. 3
Appendix A: Appendix Chapter 1 ...... 4
Bibliography ........................... 5
但是,我现在的代码使它看起来像这样。
1 Chapter 1 ................... 2
Appendices .................... 3
A Appendix Chapter 1 ....... 4
2 Bibliography ............. 5
代码如下
\documentclass[12pt]{report}
\usepackage[toc,page]{appendix}
\usepackage[nottoc,numbib]{tocbibind}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
Lorem ipsum.... \cite{Hello}
\begin{appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\makeatletter
\addtocontents{toc}{%
\let\protect\l@chapter\protect\l@section
\let\protect\l@section\protect\l@subsection
\let\protect\l@subsection\protect\l@subsubsection
}
\makeatother
\chapter{Appendix Chapter 1}
Appendix here.
\end{appendices}
\bibliographystyle{plain}
\bibliography{refs}
\end{document}
如果我在参考书目之前添加一行\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
来重置目录深度,则参考书目条目将从目录中消失。
所以有两个问题:
- 如何使参考书目与章节列在同一级别?
- 如何在目录中以“附录A:”,“附录B:”等形式列出附录章节?
谢谢!
答案1
您问了两个问题,而我们更喜欢问单个问题。
这是针对您将参考书目像章节一样列出的问题的答案。
% apptocprob.tex SE 625775
\documentclass[12pt]{report}
\usepackage[toc,page]{appendix}
\usepackage[nottoc
%,numbib % do not number the bibliography
]{tocbibind}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
Lorem ipsum.... \cite{Hello}
\begin{appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\makeatletter
\addtocontents{toc}{%
\let\protect\savel@chapter\protect\l@chapter
\let\protect\l@chapter\protect\l@section
\let\protect\l@section\protect\l@subsection
\let\protect\l@subsection\protect\l@subsubsection
}
\makeatother
\chapter{Appendix Chapter 1}
Appendix here.
% make chapters look like chapters, not sections
\makeatletter
\addtocontents{toc}{%
\let\protect\l@chapter\protect\savel@chapter
}
\makeatother
\end{appendices}
\nocite{*}
\bibliographystyle{plain}
% \bibliography{refs} % you have not provided this
\bibliography{jobname} % I have not provided it, but for me it does result in a bibliography
\end{document}
当您在目录中开始附录时,您会使章节显示为节,但由于您希望将参考书目(相当于章节)设置为章节,因此您必须反转章节到节的规范。
关于您的其他问题,请阅读tocloft
包装手册。