![在使用 tocbasic 制作的自定义列表中复制 \listoffigures 的垂直间距](https://linux22.com/image/442564/%E5%9C%A8%E4%BD%BF%E7%94%A8%20tocbasic%20%E5%88%B6%E4%BD%9C%E7%9A%84%E8%87%AA%E5%AE%9A%E4%B9%89%E5%88%97%E8%A1%A8%E4%B8%AD%E5%A4%8D%E5%88%B6%20%5Clistoffigures%20%E7%9A%84%E5%9E%82%E7%9B%B4%E9%97%B4%E8%B7%9D.png)
我曾经tocbasic
创建过自定义环境。但是,此环境列表的外观与默认列表(即\listoffigures
和\listoftables
)不同。
水平格式(缩进、宽度)的差异可以通过使用tocentryindent
和tocentrynumwidth
设置。但是,垂直间距的差异仍然是一个问题(项目之间以及标题和第一个项目之间)。
是否\DeclareNewToc
接受允许复制默认列表的垂直间距的选项?我未能在 KOMA-script 手册的表 15.1(TOC 条目样式属性)中找到合适的选项。
梅威瑟:
\documentclass{report}
\usepackage{tocbasic}
\usepackage{tocbibind}
\DeclareTOCStyleEntries{tocline}{figure,table}
\DeclareNewTOC[%
type=thing,
float,
name=Thing,
listname={List of Things},
counterwithin=chapter,
tocentryindent:=figure,
tocentrynumwidth:=figure
]{lop}
\begin{document}
% no page breaks (tex.stackexchange.com/a/30750)
\begingroup
\let\cleardoublepage\relax
\let\clearpage\relax
\listoffigures
\listoftables
\listofthings
\endgroup
\chapter{First}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 1} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 1} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 1} \end{thing}
\chapter{Second}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 2} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 2} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 2} \end{thing}
\end{document}
编辑:下图使用xpatch
答案中的示例,拼接了三个列表,显示了标题和第一个元素之间的不同垂直间距。
答案1
如果包tocbasic
应该控制列表标题的输出和标题后的空格,请使用
\renewcommand{\listoffigures}{\listoftoc[\listfigurename]{lof}}
\renewcommand{\listoftables}{\listoftoc[\listtablename]{lot}}
每个都会为 LoF 和 LoT\chapter
添加10pt
垂直空间。要对新定义的列表执行相同操作,您必须修补\@chapter
:
\makeatletter
\AddToHook{cmd/@chapter/after}{\addtocontents{lop}{\protect\addvspace{10\p@}}}
\makeatother
例子:
\documentclass{report}
\usepackage{tocbibind}% load before tocbasic
\usepackage{tocbasic}
\renewcommand{\listoffigures}{\listoftoc[\listfigurename]{lof}}
\renewcommand{\listoftables}{\listoftoc[\listtablename]{lot}}
\DeclareTOCStyleEntries{tocline}{figure,table}
\DeclareNewTOC[%
type=thing,
float,
name=Thing,
listname={List of Things},
counterwithin=chapter,
tocentryindent:=figure,
tocentrynumwidth:=figure
]{lop}
\makeatletter
\AddToHook{cmd/@chapter/after}{\addtocontents{lop}{\protect\addvspace{10\p@}}}
\makeatother
\begin{document}
% no page breaks (tex.stackexchange.com/a/30750)
\begingroup
\let\cleardoublepage\relax
\let\clearpage\relax
\listoffigures
\listoftables
\listofthings
\endgroup
\chapter{First}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 1} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 1} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 1} \end{thing}
\chapter{Second}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 2} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 2} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 2} \end{thing}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 3} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 3} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 3} \end{thing}
\end{document}
或者你可以使用
\usepackage{xpatch}
\makeatletter
\xapptocmd{\@chapter}
{\addtocontents{lop}{\protect\addvspace{10\p@}}}
{}{\PatchFailed}
\makeatother
例子:
\documentclass{report}
\usepackage{tocbibind}% load before tocbasic
\usepackage{tocbasic}
\renewcommand{\listoffigures}{\listoftoc[\listfigurename]{lof}}
\renewcommand{\listoftables}{\listoftoc[\listtablename]{lot}}
\DeclareTOCStyleEntries{tocline}{figure,table}
\DeclareNewTOC[%
type=thing,
float,
name=Thing,
listname={List of Things},
counterwithin=chapter,
tocentryindent:=figure,
tocentrynumwidth:=figure
]{lop}
\usepackage{xpatch}
\makeatletter
\xapptocmd{\@chapter}
{\addtocontents{lop}{\protect\addvspace{10\p@}}}
{}{\PatchFailed}
\makeatother
\begin{document}
% no page breaks (tex.stackexchange.com/a/30750)
\begingroup
\let\cleardoublepage\relax
\let\clearpage\relax
\listoffigures
\listoftables
\listofthings
\endgroup
\chapter{First}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 1} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 1} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 1} \end{thing}
\chapter{Second}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 2} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 2} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 2} \end{thing}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 3} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 3} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 3} \end{thing}
\end{document}
结果和上面一样。
如果您可以切换到 KOMA-Script 类(自动加载),那会更容易tocbasic
:
\documentclass[
listof=totoc,
index=totoc,
bibliography=totoc,
sfdefaults=false,% needs version 3.39 or newer
listof=leveldown
]{scrreprt}
\setuptoc{toc}{totoc}% if there should really be an entry for ToC in ToC
\DeclareNewTOC[%
type=thing,
float,
name=Thing,
listname={List of Things},
counterwithin=chapter,
tocentryindent:=figure,
tocentrynumwidth:=figure
]{lop}
\begin{document}
\tableofcontents
\addchap{Lists}
\listoffigures
\listoftables
\listofthings
\chapter{First}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 1} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 1} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 1} \end{thing}
\chapter{Second}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 2} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 2} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 2} \end{thing}
\begin{figure}[ht] \centering\fbox{Figure}\caption{Figure 3} \end{figure}
\begin{table}[ht] \centering\fbox{Table} \caption{Table 3} \end{table}
\begin{thing}[ht] \centering\fbox{Thing} \caption{Thing 3} \end{thing}
\end{document}