我有两个附录。第一个只包含表格,而第二个包含表格、图表和方案。我希望在每个附录的开头显示表格/图表的列表。如果整个附录只有一个表格/图表列表,我知道如何做到这一点。我遵循Markus Kohm 的指导方针为此。这对于单个列表来说很好,但对于多个列表来说却不行。此外,对于第二个附录,我希望将列出的表格、图表和方案合并到一个“附录 B 列表”中。
所以,我希望它看起来像这样:
附录 A
内容
表 A.1 附录 A 中的表格
表 A.2 附录 A 中的表格
附录 B
内容
表 B.1 附录 B 中的表格
图 B.1 附录 B 中的图
方案B.1 附录B中的方案
表 B.2 附录 B 中的表格
我认为这应该有效,但它并没有提供预期的输出:
\documentclass[listof=totoc]{scrbook}
\usepackage{tocbasic}
\newcommand{\entrynumberwithprefix}[2]{%
\csname listof#1entryname\endcsname\ #2%
}%
\newlength{\loftnumwidth}
\setlength{\loftnumwidth}{5em}
\DeclareTOCStyleEntry[%
entrynumberformat=\entrynumberwithprefix{lot},
numwidth=\loftnumwidth,%
indent=0pt,
]{tocline}{table}
\DeclareTOCStyleEntry[%
entrynumberformat=\entrynumberwithprefix{lof},
numwidth=\loftnumwidth,%
indent=0pt,
]{tocline}{figure}
\DeclareNewTOC[%
type=scheme,%
types=schemes,%
float,%
floattype=4,%
name=Scheme,%
tocentrynumberformat=\entrynumberwithprefix{los},
tocentrynumwidth=\loftnumwidth,%
tocentryindent=0pt,
]{los}
% new lists for appendices
\DeclareNewTOC[%
listname={Content of Appendix A},%
]{lotA}
\DeclareNewTOC[%
listname={Tables in Appendix B},%
]{lotB}
\DeclareNewTOC[%
listname={Content of Appendix B},%
]{lofB}
\DeclareNewTOC[%
listname={Schemes in Appendix B},%
]{losB}
\makeatletter
\newcommand*{\useappendixtocs}{%
\setcounter{figure}{0}%
\setcounter{table}{0}%
\KOMAoptions{listof=leveldown}
\renewcommand*{\ext@table}{lotA}%
\renewcommand*{\ext@figure}{lotB}%
\renewcommand*{\ext@figure}{lofB}%
\renewcommand*{\ext@figure}{losB}%
}
\g@addto@macro\appendix{
\useappendixtocs
}
\makeatother
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listofschemes
\chapter{Main Document}
\begin{table}
\caption{Table in main document.}
\end{table}
\begin{figure}
\caption{Figure in main document.}
\end{figure}
\begin{scheme}
\caption{Scheme in main document.}
\end{scheme}
\appendix
\chapter{First appendix with tables only}
\listoftoc{lotA}
\begin{table}
\caption{Table in appendix A.}
\end{table}
\chapter{Second appendix with figures, tables and schemes}
\listoftoc{lofB}%
\begin{table}
\caption{Table in appendix B.}
\end{table}
\begin{figure}
\caption{Figure in appendix B.}
\end{figure}
\begin{scheme}
\caption{Scheme in appendix B.}
\end{scheme}
\begin{table}
\caption{Table in appendix B.}
\end{table}
\end{document}
答案1
以下是一个建议:
\documentclass[
listof=totoc,
listof=flat% <- added
]{scrbook}
\newcommand{\entrynumberwithprefix}[2]{%
\csname listof#1entryname\endcsname\ #2%
}%
\DeclareTOCStyleEntry[
entrynumberformat=\entrynumberwithprefix{lof}
]{tocline}{figure}
\DeclareTOCStyleEntry[
entrynumberformat=\entrynumberwithprefix{lot}
]{tocline}{table}
\DeclareNewTOC[%
type=scheme,%
types=schemes,
float,%
floattype=4,%
name=Scheme,%
tocentryentrynumberformat=\entrynumberwithprefix{los},% <- option name changed
counterwithin=chapter,% <- added
]{los}
\makeatletter
\newcommand\listofapp{%
\DeclareNewTOC[%
listname={Content of Appendix \thechapter},%
setup=leveldown% <- needs KOMA-Script version 3.25
]{app\thechapter}%
\unsettoc{app\thechapter}{totoc}%
\renewcommand{\ext@figure}{app\thechapter}%
\renewcommand{\ext@table}{app\thechapter}%
\renewcommand{\ext@scheme}{app\thechapter}%
\listoftoc{app\thechapter}%
}
\makeatother
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\listofschemes
\chapter{Main Document}
\begin{table}
\caption{Table in main document.}
\end{table}
\begin{figure}
\caption{Figure in main document.}
\end{figure}
\begin{scheme}
\caption{Scheme in main document.}
\end{scheme}
\appendix
\chapter{First appendix with tables only}
\listofapp
\begin{table}
\caption{Table in appendix A.}
\end{table}
\chapter{Second appendix with figures, tables and schemes}
\listofapp
\begin{table}
\caption{Table in appendix B.}
\end{table}
\begin{figure}
\caption{Figure in appendix B.}
\end{figure}
\begin{scheme}
\caption{Scheme in appendix B.}
\end{scheme}
\begin{table}
\caption{Table in appendix B.}
\end{table}
\end{document}
运行三次得到:
请注意,选项setup
是\DeclareNewTOC
在 KOMA-Script 版本 3.25 中引入的。使用以前的 KOMA-Script 版本,您必须将其删除并添加\setuptoc{app\thechapter}{leveldown}
。