Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Footnoting a footnote can be performed by placing a \footnotemark within a footnote, followed later by the accompanying \footnotetext. However, only a single footnote can be placed within a footnote because of footnote counter desynchronization. This problem was solved, but the solution turned out to be incompatible with the \hyperref package (despite disabling hyperfootnotes in the \usepackage{hyperref} declaration).

The below MWE demonstrates this incompatibility.

    \documentclass[10pt]{article}

    % comment the below line to resolve the footnote numbering problem
    \usepackage[colorlinks=true,urlcolor=red,hyperfootnotes=false]{hyperref}

    % solution proposed by Werner (begin)
    \usepackage{letltxmacro}
    \newcounter{fnmarkcntr}\newcounter{fntextcntr}
    \makeatletter
    \renewcommand{\footnotemark}{%
       \@ifnextchar[\@xfootnotemark
         {\stepcounter{fnmarkcntr}%
          \refstepcounter{footnote}\label{footnotemark\thefnmarkcntr}%
          \protected@xdef\@thefnmark{\thefootnote}%
          \@footnotemark}}
    \makeatother
    \LetLtxMacro{\oldfootnotetext}{\footnotetext}
    \renewcommand{\footnotetext}[1]{%
      \stepcounter{fntextcntr}%
      \oldfootnotetext[\ref{footnotemark\thefntextcntr}]{#1}
    }
    % solution proposed by Werner (end)

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

Shown below is the output of the above code with the \usepackage{hyperref} command removed.

enter image description here

Shown below is the erroneous output of the above code with the \usepackage{hyperref} command included.

enter image description here

Note that inclusion of the hyperref package results in incorrect numbering of the nested footnote (0 instead of 2) and placement of an undesired (albeit correctly numbered) footnotemark in the body of the text (it should be placed in the footnote). This undesired footnotemark has been erroneously hyperlinked.

share|improve this question
3  
As you chose to accept Werner's answer to the original question and to ask a follow-up question with regard to the hyperref incompatibility, it seems appropriate that you move the respective MWE ("Edit 2") to this new question. –  lockstep Dec 19 '11 at 0:06
2  
Perhaps also remove the "new" MWE from the original question. –  lockstep Dec 19 '11 at 0:20
    
BTW, your MWE results in an error even if I comment out hyperref. –  lockstep Dec 19 '11 at 0:22
    
Yes, that error is because I included a hyperlink (www.google.com), which is no longer recognized if the hyperref package is omitted. For simplicity, I will remove that -- it does not add anything substantive to the example. –  user001 Dec 19 '11 at 0:24
1  
@user001: I removed the automated CW from the question again. –  Martin Scharrer Dec 20 '11 at 14:21

1 Answer 1

You might want to (ab)use the tablefootnote package:

\documentclass{article}
\usepackage{tablefootnote}[2011/11/26]% v1.0e

\makeatletter
\newcommand{\spewnotes}{%
\tfn@tablefootnoteprintout%
\global\let\tfn@tablefootnoteprintout\relax%
\gdef\tfn@fnt{0}%
}
\makeatother

\usepackage{hyperref}

\begin{document}
This is a footnote\footnote{Here is a footnote within the footnote%
\tablefootnote{This footnote should be labeled `2'}. %
And here is another one\tablefootnote{This footnote should be labelled `3'}.}%
\spewnotes{}. Text\footnote{Another footnote%
\tablefootnote{This footnote should be labelled `5'}. %
And here is another one\tablefootnote{This footnote should be labelled `6'}}\spewnotes{}.

\newpage

Some text (which is necessary to get two pages,
thus one can choose continuous view of the pdf-file and then check
that the hyperreferences indeed aim to the correct point.

\end{document}

You just need to make sure that there is no page break between '\footnote{...}' and \spewnotes, otherwise the spewed footnotes end at the second page. (And I did not test what happens when you use a table with tablefootnote at the same page as your footnotes to footnotes, but one can deal with that problem in the unlikely case that it does really occur.)

share|improve this answer
3  
Posting the exact answer twice is discouraged here and will cause the answer to be automatically flagged. Simply adding a comment to the original answer would be better. –  Martin Scharrer Dec 20 '11 at 14:22
    
@MartinScharrer: Sorry, had done that at the time when this was CW and the questions both ask for a solution to the same problem, just this question additionally asks for hyperref, thus the one answer answers both questions. I'll include a comment at the other version of the question linking to this answer. (A bit of a complicated situation.) –  Stephen Dec 20 '11 at 18:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.