因此,似乎这个问题已经被问过很多次了,但是,我发现现有的解决方案都不能特别令人满意,因为它们要么强制其他不需要的功能,要么破坏我的 TeX 文档的现有方面。
我正在使用报告类,我只想添加一个单独的页面(即从其自己的页面开始)来列出附录。我希望该页面有一个左对齐的标题“附录列表”,后面跟着每个附录项,每个附录项都带有指向页码的点(与表格列表和图表列表的外观和感觉相同)。此外,我还希望目录中只列出目录项“附录”,而不是每个实际的附录子项。
这是我目前创建附录并试图隐藏目录中子项的方法。我真的需要一些关于如何创建的指导\listofappendices
。我还注意到,呈现的 PDF 中的附录页码不是按字母顺序排列的,就像软件包文档建议的那样;请参阅这里。
\documentclass{report}
\usepackage{appendix}
\usepackage{hyperref}
\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}
\begin{document}
\maketitle
\tableofcontents
\listoftables
\listoffigures
% what I want \listofappendices
\chapter{Introduction}
Here is some content...
\appendix
\addappheadtotoc
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\chapter{First Appendix}
Here is my appendix content...
\chapter{Second Appendix}
Here is my appendix content...
\end{document}
我对 LaTeX 并不是很专业,因此非常感谢大家提供的任何帮助。
答案1
以下是使用包的建议scrwfile
:
\documentclass{report}
\usepackage{blindtext}% only for dummy text
\usepackage{scrwfile}
\usepackage{hyperref}
\TOCclone[List of Appendices]{toc}{atoc}
\addtocontents{atoc}{\protect\value{tocdepth}=-1}
\newcommand\listofappendices{\listofatoc}
\newcommand*\savedtocdepth{}
\AtBeginDocument{%
\edef\savedtocdepth{\the\value{tocdepth}}%
}
\let\originalappendix\appendix
\renewcommand\appendix{%
\originalappendix
\cleardoublepage
\addcontentsline{toc}{chapter}{\appendixname}%
\addtocontents{toc}{\protect\value{tocdepth}=-1}%
\addtocontents{atoc}{\protect\value{tocdepth}=\savedtocdepth}%
}
\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}
\begin{document}
\maketitle
\tableofcontents
\listoftables
\listoffigures
\listofappendices
\blinddocument
\appendix
\chapter{First Appendix}
Here is my appendix content
\chapter{Second Appendix}
Here is my appendix content
\blinddocument
\end{document}
结果:
答案2
这是一个最小的解决方案。它lop
为附录列表创建一个新文件。(注意,loa
由算法列表使用。)
\documentclass{report}
\usepackage{appendix}
\usepackage{hyperref}
\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}
\makeatletter
\newcommand*{\lopname}{List of Appendices}
\newcommand{\listofappendices}{% I removed all the \twocolumn stuff
\chapter*{\lopname\@mkboth{%
\MakeUppercase\lopname}{\MakeUppercase\lopname}}%
\@starttoc{lop}%
}
\makeatother
\begin{document}
\maketitle
\tableofcontents
\setcounter{tocdepth}{2}% restore default
\listoftables
\listoffigures
\listofappendices
\chapter{Introduction}
Here is some content...
\section{Test}
\appendix
\addappheadtotoc
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\chapter{First Appendix}
\addcontentsline{lop}{chapter}{\numberline{\thechapter}First Appendix}
Here is my appendix content...
\chapter{Second Appendix}
\addcontentsline{lop}{chapter}{\numberline{\thechapter}Second Appendix}
Here is my appendix content...
\end{document}
答案3
您可以\@chapter
在附录开始时修补以写入不同的文件。 相应的更改由 完成\appendix
,我们向其中添加了一些代码。
文档中不需要明确的标记。
\documentclass{report}
\usepackage{etoolbox}
\usepackage{hyperref}
\title{Here is my title}
\author{Name Name}
\date{October 1, 2019}
\makeatletter
\ifdefined\Hy@org@chapter
\patchcmd{\Hy@org@chapter}{toc}{\TocOrToa}{}{}
\patchcmd{\Hy@org@chapter}{toc}{\TocOrToa}{}{} % twice is necessary
\else
\patchcmd{\@chapter}{toc}{\TocOrToa}{}{}
\patchcmd{\@chapter}{toc}{\TocOrToa}{}{} % twice is necessary
\fi
\newcommand{\TocOrToa}{toc} % initial value
\apptocmd{\appendix}
{%
\addcontentsline{toc}{chapter}{\appendixname}%
\renewcommand{\TocOrToa}{toa}% now we want to write the list of appendices
\addtocontents{toc}{\protect\setcounter{tocdepth}{-2}}% sections won't appear in toc
\AtEndDocument{\addtocontents{toc}{\protect\setcounter{tocdepth}{3}}}% get back to normal
\addtocontents{toa}{\protect\setcounter{tocdepth}{0}}% only chapters
}
{}{}
\newcommand*{\toaname}{List of Appendices}
\newcommand{\listofappendices}{% I removed all the \twocolumn stuff
\chapter*{\toaname\@mkboth{\MakeUppercase\toaname}{\MakeUppercase\toaname}}%
\@starttoc{toa}%
}
\makeatother
\begin{document}
\pagenumbering{Alph} % to avoid hyperref complaints
\maketitle
\clearpage
\pagenumbering{arabic}
\tableofcontents
%\listoftables
%\listoffigures
\listofappendices
\chapter{Introduction}
Here is some content...
\appendix
\chapter{First Appendix}
Here is my appendix content...
\chapter{Second Appendix}
Here is my appendix content...
\end{document}
tocdepth
需要进行一些处理。