# Special nested footnotes

I’ve had a hard time finding an adequately robust footnote system. In the interest of sparing you my bankrupt descriptions of typography, I’ve provided a (crude) Photoshop mockup of the basic idea:

I’ve read at least a dozen questions on this site and tried them all; this question is similar to what I need, but the result is not what I'm looking for; the footnotes are segregated into different sections by level. The indentation and numerical consistency of the top-level footnotes is important, too.

Is there any kind of package (or whatever) that can do this, without requiring advanced knowledge of TeX (which I lack)? I’d prefer something that permits for source files looking a little like this:

Start of main text\footnote%
{Some sort of note here, clever witticisms, et cetera\footnote%
{Second, fourth-wall-breaking commentary\footnote%
{Snide suggestion that more-or-less repairs the fourth wall.} %
on the above commentary.} %
.}%
, which is constantly interrupted by the author’s scrambled, incoherent, and vagariously composed thought processes.


This is grotesque enough, and scarcely manageable, but I'm willing to compromise. Cleaner would be better.

There should, ideally, be support for splitting the outrageously overlong footnotes over two (or more) pages, preferably at a point I define, and with something like “[9], continued” at the start of the second page. I’m willing to give up on this, though; I may have to convert such footnotes to endnotes.

The exact TeX system is irrelevant; I’m fine using LaTeX or ConTeXt or plain TeX, or any other available flavors.

I don’t ask this kind of question (which seems so simple) lightly, but it’s been twelve hours and seven shots and I’m no closer to figuring this out than when I started. I’m starting to think it can’t be done.

• No, there is no package that does this out of the box. And there shouldn't be: nesting footnotes within (as it were) footnotes runs contrary to the (standard) method of separate footnote levels. (However, I think this could be mimicked if need be.) Certainly TeX should not have to detect that a footnote is in a footnote and then "next-level" it automatically. Also: for you to define where to break footnotes in a page (presumably while TeX figures out where to break the main text) is quite contrary to one main thing that TeX is designed to do: namely, decide when to ship out pages of text. – jon Jul 4 '15 at 6:11
• You can have a look to the bigfoot package. – egreg Jul 4 '15 at 7:00
• I lack the (t)expertise to implement this, but here's an idea. Top level footnotes act almost normal. Second level footnotes simply store the text for later processing. At the end of a top level footnote, typeset all the second level notes inside an enumerate environment. Of course, all this would have to work recursively. I don't know enough magic to do this, at least not without several hours of trial and error, but there be many wizards here. Mayhap one shall offer to help. – Mark Jul 9 '15 at 1:02
• Bigfoot looks like it can do what I need it to do, now it’s just a matter of getting it to do that. @Mark — I tried that idea and it produces an effect quite similar to what I’m going for and I like it, so I may do that if I can figure out a way to make it all match, if nobody comes forward with the magic fix. – t m Jul 13 '15 at 20:35
• Ok, let us know how it goes! – Mark Jul 14 '15 at 4:31

In terms of markup the nesting is quite easy to setup:

\def\footnote#1{%
\@ld@footnote{\let\footnote\footnoteA\indentfn#1}%
}
\def\footnoteA#1{%
\@ld@footnoteA{\let\footnote\footnoteB\indentfn#1}%
}


where \footnote, \footnoteA, \footnoteB are three indipendent footnote macros and \@ld@footnote and \@ld@footnoteA are copies of those (respectively). This interace would be built with the bigfoot package:

\DeclareNewFootnote{default}
\DeclareNewFootnote{A}[alph]
\MakeSortedPerPage{footnoteA}
\DeclareNewFootnote{B}[roman]
\MakeSortedPerPage{footnoteB}


The \indentfn is a helper macro defined as

\def\indentfn{\addtolength\footnotemargin{10pt}}


The length \footnotemargin is provided by the footmisc package.

Then you can type something like:

\footnote{%
Some sort of note here, clever witticisms, et cetera.%
\footnote{%
Second, fourth-wall-breaking commentary%
\footnote{%
Snide suggestion that more-or-less repairs the fourth wall.%
}%
on the above commentary.%
}%
}


to get the follwing output:

However, this won't give you the sorting as in your example pic. In my opinion this is worth an own follow-up question.

### Complete code

\documentclass{article}
\usepackage{bigfoot}
\DeclareNewFootnote{default}
\DeclareNewFootnote{A}[alph]
\MakeSortedPerPage{footnoteA}
\DeclareNewFootnote{B}[roman]
\MakeSortedPerPage{footnoteB}
\usepackage{footmisc}

\makeatletter
\let\@ld@footnote \footnote
\let\@ld@footnoteA\footnoteA
\def\footnote{%
\refstepcounter{footnote}%
\kernel@ifnextchar[{\footnot@}{\footnot@[\c@footnote]}%
}
\def\footnot@[#1]#2{%
\@ld@footnote[#1]{\let\footnote\footnoteA\indentfn#2}%
}
\def\footnoteA{%
\refstepcounter{footnoteA}%
\kernel@ifnextchar[{\footnot@A}{\footnot@A[\c@footnoteA]}%
}
\def\footnot@A[#1]#2{%
\@ld@footnoteA[#1]{\let\footnote\footnoteB\indentfn#2}%
}
\makeatother

\begin{document}
Start of main text,%
\footnote{%
Some sort of note here, clever witticisms, et cetera.%
\footnote{%
Second, fourth-wall-breaking commentary%
\footnote{%
Snide suggestion that more-or-less repairs the fourth wall.%
}%
on the above commentary.%
}%
}
which is constantly interrupted by the author’s scrambled, incoherent, and vagariously composed thought processes.
\end{document}