当 \listoffigures 和 \listoftables 由 tocbasic 控制时,保留 \tableofcontents 中的 \listoffigures 和 \listoftables

当 \listoffigures 和 \listoftables 由 tocbasic 控制时,保留 \tableofcontents 中的 \listoffigures 和 \listoftables

当图片列表和表格列表已置于包的控制之下时,如何将它们包含在目录中?通常,可以使用不带选项和 的tocbasic包来包含这些列表。tocbibindnotlofnotlot

梅威瑟:

\documentclass{report}
\usepackage[nottoc]{tocbibind}% load before tocbasic
\usepackage{tocbasic}

% reset vertical spacing of LoF and LoT
\renewcommand{\listoffigures}{\listoftoc[\listfigurename]{lof}}
\renewcommand{\listoftables}{\listoftoc[\listtablename]{lot}}

% place LoF and LoT under control of tocbasic
\DeclareTOCStyleEntries{tocline}{figure,table}

% define custom listing
\DeclareNewTOC[%
    type=thing,
    float,
    name=Thing,
    listname={List of Things},
    counterwithin=chapter,
    setup=totoc,%                add this list to the Table of Contents
    tocentryindent:=figure,
    tocentrynumwidth:=figure
]{lop}

% match vertical spacing of LoF and LoT
\usepackage{xpatch}
\makeatletter
\xapptocmd{\@chapter}
  {\addtocontents{lop}{\protect\addvspace{10\p@}}}
  {}{\PatchFailed}
\makeatother

\begin{document}
    \tableofcontents
    \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}

目录页,缺少 LoF 和 LoT:

在此处输入图片描述

答案1

您可以在序言中使用\setuptoc{lof}{totoc}\setuptoc{lot}{totoc}将两者添加到目录中:

\documentclass{report}
\usepackage[nottoc]{tocbibind}% load before tocbasic
\usepackage{tocbasic}


% reset vertical spacing of LoF and LoT
\renewcommand{\listoffigures}{\listoftoc[\listfigurename]{lof}}
\renewcommand{\listoftables}{\listoftoc[\listtablename]{lot}}

% place LoF and LoT under control of tocbasic
\DeclareTOCStyleEntries{tocline}{figure,table}

% define custom listing
\DeclareNewTOC[%
    type=thing,
    float,
    name=Thing,
    listname={List of Things},
    counterwithin=chapter,
    setup=totoc,%                add this list to the Table of Contents
    tocentryindent:=figure,
    tocentrynumwidth:=figure
]{lop}

\setuptoc{lof}{totoc}
\setuptoc{lot}{totoc}

% match vertical spacing of LoF and LoT
\usepackage{xpatch}
\makeatletter
\xapptocmd{\@chapter}
  {\addtocontents{lop}{\protect\addvspace{10\p@}}}
  {}{\PatchFailed}
\makeatother

\begin{document}
    \tableofcontents
    \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}

在此处输入图片描述

相关内容