## LaTeX forum ⇒ Page Layout ⇒ Nested footnotes

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
user001
Posts: 2
Joined: Mon Dec 19, 2011 10:21 am

### Nested footnotes

Hallo. I had an issue with correct numbering of nested footnotes in LaTeX, such as shown below:
footnote_misnumbering.png (13.79 KiB) Viewed 1683 times

This issue was resolved, but only in a manner which conflicted with the hyperref package. This conflict is shown in the below examples.

First is the desired pdflatex output:
MWE_Comment.png (12.12 KiB) Viewed 1683 times

And second is the actual output:
MWE_noComment.png (12.39 KiB) Viewed 1683 times

These outputs were generated from the following code without (top output) or with (bottom output) inclusion of the hyperref package.


Could someone please help me to generate the desired output in a manner that is compatible with the hyperref package? Thank you very much.

kaiserkarl13
Posts: 626
Joined: Tue Mar 25, 2008 5:02 pm
The "solution" you posted seems unnecessary. I get your example to work just fine without the extra packages and redefinitions. Observe:
\documentclass[10pt]{article} % comment the below line to resolve the footnote numbering problem\usepackage[colorlinks=true,urlcolor=red,hyperfootnotes=false]{hyperref} \begin{document}This text has a footnote\footnote%{Which contains a sub-footnote\protect\footnotemark}\footnotetext{This footnote should be labeled 2'}\end{document}

On my machine, it works fine. You might be having issues with minipages: the minipage environment redefines \thefootnote inside so it uses a, b, c, and uses mpfootnote instead of footnote for numbering. This means \footnotemark (which is not similarly redefined) won't have the correct default numbering. You can specify the number like this: \footnotemark[2] ... \footnotetext[2]{Text.}.

Incidentally, your original code doesn't process either unless you ignore the errors. Once the .aux file has been generated, it seems fine, but until then it looks for a non-existent number. So perhaps the moral of this post should be, "don't ignore errors!"

user001
Posts: 2
Joined: Mon Dec 19, 2011 10:21 am
Sorry, in the interest of posting a succinct MWE, I realize now that I made it too simple.

If you add a second footnote mark as below, the numbering won't work without the posted solution:

\begin{document}This text has a footnote\footnote%{Which contains two sub-footnote\footnotemark\footnotemark}\footnotetext{This footnote should be labeled 2'}\footnotetext{This footnote should be labeled 3'}\end{document}

kaiserkarl13
Posts: 626
Joined: Tue Mar 25, 2008 5:02 pm
You have to give LaTeX some help---you give it two \footnotetext commands in a row, so it uses the current value of the footnote counter when generating numbers. This will work for your example:
\documentclass[12pt]{article} % comment the below line to resolve the footnote numbering problem\usepackage[colorlinks=true,urlcolor=red,hyperfootnotes=true]{hyperref} \begin{document}This text has a footnote\footnote%{Here is a footnote within the footnote\footnotemark.  And here is anotherone.\footnotemark}\footnotetext[2]{This footnote should be labeled 2'}\footnotetext{This footnote should be labeled 3'}\end{document}

A slightly more robust way is like this:
\documentclass[12pt]{article} % comment the below line to resolve the footnote numbering problem\usepackage[colorlinks=true,urlcolor=red,hyperfootnotes=true]{hyperref}\newcounter{prevfn} \begin{document}This text has a footnote\footnote%{Here is a footnote within the footnote\footnotemark.  And here is anotherone.\footnotemark}\setcounter{prevfn}{\value{footnote}}\addtocounter{prevfn}{-1}\footnotetext[\value{prevfn}]{This footnote should be labeled 2'}\footnotetext{This footnote should be labeled 3'}\end{document}

I say "slightly" because it still requires you to know how many nested footnotes you have. It does not, however, require you to know the value off-hand.