如何将使用 KOMA 脚本创建的自定义环境列表\DeclareNewTOC
包含在目录中?在下面的示例中,“照片列表”未出现在目录中。
此外,是否有一个选项可用于确保自定义列表(例如\listofphotos
)的格式与默认列表(例如\listoffigures
)的格式相匹配?(该tocentrystyle
选项似乎相关,但不清楚如何将其与样式关联listoffigures
,并且 KOMA-script 手册 [第 388-391 页] 中列出的条目样式没有提供所需的外观。)
梅威瑟:
\documentclass{report}
\usepackage{tocbasic}
\usepackage{tocbibind}
\DeclareNewTOC[%
type=photo,
float,
name=Photo,
listname={List of Photos},
counterwithin=chapter,
]{lop}
\begin{document}
\tableofcontents
\listoffigures
\listofphotos
\chapter{First}
\begin{figure}[ht] \centering\fbox{Figure}\caption{A figure} \end{figure}
\begin{photo}[ht] \centering\fbox{Photo} \caption{A photo} \end{photo}
\chapter{Second}
\begin{figure}[ht] \centering\fbox{Figure}\caption{A figure} \end{figure}
\begin{photo}[ht] \centering\fbox{Photo} \caption{A photo} \end{photo}
\end{document}
答案1
您可以使用
\setuptoc{lop}{totoc}
或者将选项添加setup=totoc
到的可选参数中\DeclareNewTOC
。
补充说明:\DeclareNewTOC
默认情况下使用tocentryindent=1em
和,tocentrynumwidth=1.5em
而 LoF 中的图形条目的缩进为1.5em
和数字宽度为2.3em
。因此,我建议将tocentryindent
和的值更改tocentrynumwidth
为与图形的值相同。
例子:
\documentclass{report}
\usepackage{tocbibind}% before tocbasic
\usepackage{tocbasic}
\DeclareTOCStyleEntries{tocline}{figure,table}% now controlled by tocbasic
\DeclareNewTOC[%
type=photo,
float,
name=Photo,
listname={List of Photos},
counterwithin=chapter,
setup=totoc,% entry in ToC
tocentryindent:=figure,% same indentation as for figure
tocentrynumwidth:=figure% same numwidth as for figure
]{lop}
\begin{document}
\tableofcontents
\listoffigures
\listofphotos
\chapter{First}
\begin{figure}[ht] \centering\fbox{Figure}\caption{A figure} \end{figure}
\begin{photo}[ht] \centering\fbox{Photo} \caption{A photo} \end{photo}
\chapter{Second}
\begin{figure}[ht] \centering\fbox{Figure}\caption{A figure} \end{figure}
\begin{photo}[ht] \centering\fbox{Photo} \caption{A photo} \end{photo}
\end{document}
或者
\documentclass{report}
\usepackage{tocbibind}% before tocbasic
\usepackage{tocbasic}
\DeclareNewTOC[%
type=photo,
float,
name=Photo,
listname={List of Photos},
counterwithin=chapter,
tocentryindent=1.5em,% same indentation as for figure
tocentrynumwidth=2.3em% same numwidth as for figure
]{lop}
\setuptoc{lop}{totoc}% entry in ToC
\begin{document}
\tableofcontents
\listoffigures
\listofphotos
\chapter{First}
\begin{figure}[ht] \centering\fbox{Figure}\caption{A figure} \end{figure}
\begin{photo}[ht] \centering\fbox{Photo} \caption{A photo} \end{photo}
\chapter{Second}
\begin{figure}[ht] \centering\fbox{Figure}\caption{A figure} \end{figure}
\begin{photo}[ht] \centering\fbox{Photo} \caption{A photo} \end{photo}
\end{document}
第二个建议也适用于旧版本的 KOMA-Script。