我想创建一个附录列表,如下所示:
我知道我可以使用 listof* 宏打印不同的列表,但我不知道如何将词汇表的独立条目和作者声明添加到列表中。
基本上,我想要实现的是使用创建一个新列表
\newlistof{appendices}{apx}{\TitleOfAppendicesList}
并使用类似的调用
\addcontentsfromlist{apx}{\listoffigures}
\addcontentsfromlist{apx}{\listoftables}
\addcontentsfromlist{apx}{\lstlistoflistings}
\addcontentsline{apx}{chapter}{\TitleOfGlossary}
\addcontentsline{apx}{chapter}{\TitleOfStatementOfAuthorship}
我目前的做法可以看出这里。
\documentclass[a4paper,english]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{scrhack}
\usepackage{babel}
\usepackage{blindtext}
\usepackage{tocbibind}
\usepackage{appendix}
\usepackage{listings}
\usepackage[numberedsection]{glossaries}
\AtBeginDocument{%
\renewcommand{\listoffigures}{\begingroup%
\let\clearpage\relax
\tocsection
\tocfile{\listfigurename}{lof}
\endgroup}
\renewcommand{\listoftables}{\begingroup%
\let\clearpage\relax
\tocsection
\tocfile{\listtablename}{lot}
\endgroup}
\renewcommand{\lstlistoflistings}{\begingroup%
\let\clearpage\relax
\tocsection
\tocfile{\lstlistlistingname}{lol}
\endgroup}
}
\newglossaryentry{Application Programming Interface (API)}{
name=Application Programming Interface (API),
description={is an interface exposed by some piece of software so that other software can use this particular piece of software.}
}
\makeglossaries
\begin{document}
\tableofcontents % adds to itself (first entry called "Contents") - not wanted
\clearpage
\blindtext
\begin{figure}[t]
\centering
Some figure content.
\caption{Figure description.}
\end{figure}
\blindtext
\begin{table}[t]
\centering
\begin{tabular}{|l|l|l|}
\hline \\
\textbf{A} & \textbf{B} & \textbf{C} \\ \hline
some & tabular & data \\ \hline
\end{tabular}
\caption{Table description.}
\label{tables:table1}
\end{table}
\clearpage
\begin{appendices}
\renewcommand{\appendixtocname}{List of appendices}
\renewcommand{\lstlistlistingname}{List of source code listings}
\providecommand\StatementOfAuthorshipTitle{Statement of authorship}
\chapter*{\appendixtocname}
\addcontentsline{toc}{chapter}{\appendixtocname}
\listoffigures % adds to the table of content - not wanted
\listoftables % same
\lstlistoflistings % same
% how to add glossary & other artefacts here?
% actual contents follow the list of appendices
% each content group shall get its own heading, followed by their contents
% those headings must not appear in the table of contents, but have to appear in the list of appendices
\clearpage
\chapter*{\lstlistlistingname}
\begin{lstlisting}[language=c++,caption={The Hello-World-Example, in C++},captionpos=b,frame=single]
#include <iostream>
int main(int argc, char *argv[])
{
std::cout << "Hello World!" << std::endl;
return 0;
}
\end{lstlisting}
\glsaddall
\printglossaries
\clearpage
\chapter*{\StatementOfAuthorshipTitle}
inclusion of the statement document (PDF file)
%\includepdf[pages=-]{artefacts/statement.pdf}
\end{appendices}
\end{document}
答案1
使用tocbibind
和appendix
和的包glossaries
,listings
这并不是什么问题。
只需重新定义相关命令并结合\listof...
使用命令即可。\tocsection
\tocfile{\listofsomethingname}{ext}
对于glossaries
,numberedsection
包选项就足够了。
\documentclass{article}
\usepackage{blindtext}
\usepackage{listings}
\usepackage{tocbibind}
\usepackage[page]{appendix}
\usepackage[numberedsection]{glossaries}
\AtBeginDocument{%
\renewcommand{\listoffigures}{\begingroup%
\tocsection
\tocfile{\listfigurename}{lof}
\endgroup}
\renewcommand{\listoftables}{\begingroup%
\tocsection
\tocfile{\listtablename}{lot}
\endgroup}
\renewcommand{\lstlistoflistings}{\begingroup%
\tocsection
\tocfile{\lstlistlistingname}{lol}
\endgroup}
}
\newglossaryentry{foo}{%
name={Foo},
description={A foobar}
}
\makeglossaries
\setglossarysection{section}
\begin{document}
\glsaddall
\section{My first section}
\begin{figure}
\caption{Dummy figure}
\end{figure}
\blindtext[5]
\begin{table}
\caption{Dummy table}
\end{table}
\section{Another section}
\begin{lstlisting}[language=C,caption={The Hello-World-Example}]
#include<stdio.h>
int main(int argc,char **argv)
{
printf("Hello World!\n");
return(0);
}
\end{lstlisting}
\clearpage
\begin{appendices}
\listoffigures
\listoftables
\lstlistoflistings
\printglossaries
\end{appendices}
\end{document}