6

Using the tocloft package, I defined a "List of Footnotes" which is displayed as a simple list, while I would like to display the chapters, too, in the following way:

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

Here is what I tried. (The strings of code I commented out and described as "1st try" and "2nd try" are what I tried, but they do not work.)

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

Additional Info: I am working with the scrreprt class, but I would be very glad if it could work also with the standard LaTeX classes.

Werner
  • 603,163
Pier Paolo
  • 2,790
  • This is similar to a question, I answered recently: http://tex.stackexchange.com/questions/200360/list-of-tables-or-figures-by-section-latex/200385#200385, although not with tocloft then. –  Sep 17 '14 at 16:02

1 Answers1

4

Below I've patched \@@makechapterhead which sets the actual chapter heading in KOMA-script. The final heading-related "construction" is to insert a vertical skip called \chapterheadendvskip. So, we add to that macro an \addcontentsline submission:

enter image description here

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

Note that the above patch will insert a chapter-style heading in the List of Footnotes even if the chapter has no footnotes. Also, I've updated you definition of \listofFootnoteQuote to avoid problems when it spans more than one page.

Werner
  • 603,163
  • Thanks! I have a question: will this work also if I use titlesec to change the appearance of the chapter-head? (I know this question might be too generic, but I have already tried to modify \@makechapterhead and the solution you propose doesn't work anymore.) – Pier Paolo Sep 17 '14 at 18:55
  • 1
    @PierPaolo: No, since titlesec uses a different set of macros to construct the titles. While the patch may work, \@@makechapterhead is never executed. One would possibly follow the same procedure as I did to identify the macro executed around the end of the \chapter setting (which might be intricate when dealing with titlesec) and patch that. – Werner Sep 17 '14 at 18:57