我想将 \lstlistoflistings 拆分为两个列表(一个在文档的主要内容中,一个在附录中)。Titletoc
仅适用于图形/表格:有解决方法吗?
我的结构目前如下所示:
\documentclass{report}
\usepackage{listings}
\usepackage[toc,page]{appendix}
\usepackage{titletoc}
% Start partial lists
\startlist[main]{lol}% starts main list of listings
% ... Some contents + printlist somewhere here
% Stop partial lists
\stoplist[main]{lol}% stops main list of listings
% Start partial lists
\startlist[appendices]{lol}% starts appendices list of listings
\begin{appendices}
% ... some listings here + printlist somewhere here
\end{appendices}
% Stop partial lists
\stoplist[appendices]{lol}% stops appendices list of listings
谢谢您的帮助
答案1
最后,我找到了一个不使用其他软件包的丑陋解决方案
\makeatletter
\providecommand{\phantomsection}{}
% Pour modifier plus facilement le nom - Ici, je recycles ceux de base
\newcommand\appendixlistingname{\lstlistlistingname}
\newcommand{\listofappendixlistings}{%
% Applying the same trick as listings does with \lstlistoflistings: Modifying \@starttoc such that it can load only .apl files
\begingroup
\let\@starttoc@orig\@starttoc%
\renewcommand{\contentsname}{\appendixlistingname}
\renewcommand{\@starttoc}[1]{%
\@starttoc@orig{apl}%
}%
\phantomsection
\addcontentsline{toc}{section}{\appendixlistingname}
\tableofcontents% Calling \tableofcontents with the `.apl` file instead of `.toc`
\endgroup
}
\newcommand{\appendixFix}{%
\setcounter{lstlisting}{0}%
\@ifundefined{theHlstlisting}{%
}{%
\renewcommand{\theHlstlisting}{appendix}
}%
\write\@auxout{%
\string\let\string\latex@tf@lol\string\tf@lol% Store the original `\tf@lol` file handle
\string\let\string\tf@lol\string\tf@apl%
}%
}{}{}
\makeatother
可以用作
\appendixFix
\begin{appendices}
\listofappendixlistings
\input{sections/appendixes/index} % File containing some listings code
\end{appendices}