在使用 tocbasic 制作的自定义列表中复制 \listoffigures 的垂直间距

在使用 tocbasic 制作的自定义列表中复制 \listoffigures 的垂直间距

我曾经tocbasic创建过自定义环境。但是,此环境列表的外观与默认列表(即\listoffigures\listoftables)不同。

水平格式(缩进、宽度)的差异可以通过使用tocentryindenttocentrynumwidth 设置。但是,垂直间距的差异仍然是一个问题(项目之间以及标题和第一个项目之间)。

是否\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}

在此处输入图片描述

相关内容