tocloft:如何在用 \newlistof 定义的新列表中添加章节?

tocloft:如何在用 \newlistof 定义的新列表中添加章节?

使用该tocloft包,我定义了一个“脚注列表”,它显示为一个简单的列表,而我也想以以下方式显示章节:

List of Figures
                        (page)% not to be displayed
1 Chapter Title           1   % to be displayed like a chapter in the ToC of standard classes
  1 Text of footnote      2
2 Chapter Title           3
  1 Text of footnote      4
  2 Text of footnote      5

这是我尝试过的。(我注释掉并描述为“第一次尝试”和“第二次尝试”的代码串是我尝试过的,但它们不起作用。)

\documentclass[a4paper]{scrreprt}

\usepackage{letltxmacro}
\usepackage[titles]{tocloft}
\newcommand\footnotesname{List of Footnotes}
\newlistof[chapter]{FootnoteQuote}{loq}{\footnotesname}% FootnoteQuote is a new counter for the footnotes
\LetLtxMacro{\oldfootnote}{\footnote}
\renewcommand{\footnote}[1]{%
  \oldfootnote{#1}%
  \refstepcounter{FootnoteQuote}%
  \addcontentsline{loq}{section}{\protect\numberline{\theFootnoteQuote}#1}% formatted as sections
}
\renewcommand\theFootnoteQuote{\arabic{FootnoteQuote}}
\renewcommand{\cftdot}{}% No dotted leader lines
\let\oldlistofFootnoteQuote\listofFootnoteQuote% To add an entry in the ToC
\renewcommand\listofFootnoteQuote{%
  \oldlistofFootnoteQuote%
  \addcontentsline{toc}{chapter}{\footnotesname}\par%
}
% \LetLtxMacro{\oldchapter}{\chapter}% 1st try
% \renewcommand{\chapter}[1]{%
%   \oldchapter{#1}%
%   \addcontentsline{loq}{chapter}{\protect\numberline{\thechapter}#1}% taken from report.cls
% }
%
% \usepackage{etoolbox}% 2nd try
% \preto\chapter{\addtocontents{loq}{\protect\numberline{\thechapter}#1}}

\begin{document}

% \addtocontents{toc}{~\hfill\textbf{Page}\par}
\tableofcontents

\chapter{One}
Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

\chapter{Two}
Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

\listofFootnoteQuote

\end{document}

附加信息:我正在使用该scrreprt课程,但如果它也可以与标准 LaTeX 课程一起使用,我会非常高兴。

答案1

下面我已修补\@@makechapterhead,设置实际章节标题KOMA 脚本。最后一个与标题相关的“构造”是插入一个名为的垂直跳过\chapterheadendvskip。因此,我们向该宏添加一个\addcontentsline提交:

在此处输入图片描述

\documentclass[a4paper]{scrreprt}

\usepackage{letltxmacro,etoolbox}
\usepackage[titles]{tocloft}
\newcommand\footnotesname{List of Footnotes}
\newlistof[chapter]{FootnoteQuote}{loq}{\footnotesname}% FootnoteQuote is a new counter for the footnotes
\LetLtxMacro{\oldfootnote}{\footnote}
\renewcommand{\footnote}[1]{%
  \oldfootnote{#1}%
  \refstepcounter{FootnoteQuote}%
  \addcontentsline{loq}{section}{\protect\numberline{\theFootnoteQuote}#1}% formatted as sections
}
\renewcommand\theFootnoteQuote{\arabic{FootnoteQuote}}
\renewcommand{\cftdot}{}% No dotted leader lines
\let\oldlistofFootnoteQuote\listofFootnoteQuote% To add an entry in the ToC
\renewcommand\listofFootnoteQuote{%
  \cleardoublepage%
  \addcontentsline{toc}{chapter}{\footnotesname}\par%
  \oldlistofFootnoteQuote%
}
\makeatletter
\patchcmd{\@@makechapterhead}% <cmd>
  {\chapterheadendvskip}% <search>
  {\chapterheadendvskip%
   \addcontentsline{loq}{chapter}{\protect\numberline{\thechapter}#1}}% Replace
  {}{}% <successs><failure>
\makeatother

\begin{document}

% \addtocontents{toc}{~\hfill\textbf{Page}\par}
\tableofcontents

\chapter{One}
Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

\chapter{Two}
Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

Some words Some words Some words Some words\footnote{A footnote.} Some words Some words

\listofFootnoteQuote

\end{document}

请注意,即使章节没有脚注,上述补丁也会在脚注列表中插入章节样式的标题。此外,我已更新您的定义,以\listofFootnoteQuote避免跨越多页时出现问题。

相关内容