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.

The footception post (Footception: Footnote within a footnote within a footnote) describes how to recursively footnote. I am trying to make a nested footnote that is placed in the same footnote apparatus as the calling footnote, but the numbering goes awry. Here is a MWE that demonstrates the problem:

    \documentclass{article}
    \begin{document}
    This is a footnote\footnote{Here is a footnote within the footnote\footnotemark{}. And here is another one\footnotemark{}.}
    \footnotetext{This footnote should be labeled `2'}
    \footnotetext{This footnote should be labeled `3'}
    \end{document}

Here is the output:

footnotemark_fail

Note the errant footnote numbering. How can this be rectified? I would like to use automatic footnote enumeration, therefore temporary solutions like \footnotemark[2]{} and \footnotetext[2]{} should be avoided.

Major Edit #1: The package bigfoot was suggested by jon as offering a solution to this problem; however, while bigfoot permits construction of multiple footnote apparatus and allows commenting from a superior apparatus to an inferior one, the below MWE shows that bigfoot fails to permit intra-apparatus footnoting (as well as footnoting from an inferior to a superior apparatus):

    \documentclass{article}
    \usepackage{fullpage}
    \usepackage{bigfoot}
    \DeclareNewFootnote{default}
    \DeclareNewFootnote{B}[alph]
    \MakeSortedPerPage{B}
    \begin{document}
    This text has a footnote in the default apparatus%
    \footnote{Here.}%
    as well as an alphabetical apparatus%
    \footnoteB{Here.}.
    \verb+bigfoot+ allows subordinate footnotes from a superior apparatus to an inferior apparatus%
    \footnote{Like this\footnoteB{See.}.}, but not from an inferior apparatus to a superior apparatus%
    \footnoteB{Like this\footnote{Error.}.}. %
    Likewise, \verb+bigfoot+ forbids making a nested footnote from one apparatus to the same apparatus%
    \footnote{Like this\footnote{Error}.}\footnoteB{And like this\footnoteB{Error}.}. %
    A quick look at \verb+bigfoot.sty+ shows this to be true: \textit{``Higher-placed footnotes can't be anchored %
    in inferior ones.''} This means one cannot call a footnote from an inferior to superior apparatus or even from %
    one apparatus to the same apparatus. I am particularly interested in footnoting from one apparatus to the same %
    apparatus. I do not want multiple apparatus \footnote{Yes this is the correct plural\footnote{Fail.}.}.
    \end{document}

For convenience, I have posted the output as a .tif image: bigfoot_fail

share|improve this question
2  
bigfoot allows for nested footnotes. –  jon Dec 18 '11 at 1:05
    
Actually, this is not a duplicate. The footception post describes how to make subordinate footnotes. I am trying to make a nested footnote that is placed in the same footnote apparatus as the calling footnote. –  user001 Dec 18 '11 at 1:45
2  
Sorry for closing your question prematurely. I voted for reopening. –  lockstep Dec 18 '11 at 2:08
    
Thank you very much @lockstep. I will post a more detailed latex input file and output to explain further. –  user001 Dec 18 '11 at 2:15
1  
I'll admit I upvoted this for two reasons: 1) having multiple clear MWE (Though it looks like that was added after based on the comments, but anyway, it is good now) and 2) Using the term footception. –  Canageek Dec 18 '11 at 6:48

1 Answer 1

up vote 14 down vote accepted

It would be possible to redefine the way \footnotemark and \footnotetext operate. Here is one such a possibility:

enter image description here

\documentclass{article}
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\newcounter{fnmarkcntr}\newcounter{fntextcntr}
\makeatletter
\renewcommand{\footnotemark}{% Taken from article.cls
   \@ifnextchar[\@xfootnotemark
     {\stepcounter{fnmarkcntr}% added 
      \refstepcounter{footnote}\label{footnotemark\thefnmarkcntr}% modified
      \protected@xdef\@thefnmark{\thefootnote}%
      \@footnotemark}}
\makeatother
\LetLtxMacro{\oldfootnotetext}{\footnotetext}% store \footnotetext in \oldfootnotetext
\renewcommand{\footnotetext}[1]{%
  \stepcounter{fntextcntr}% step to next "footnotemark"
  \oldfootnotetext[\ref{footnotemark\thefntextcntr}]{#1}%
}
\begin{document}
This is a footnote\footnote{Here is a footnote within the footnote\footnotemark. And here is another one\footnotemark.}
\footnotetext{This footnote should be labeled '2'.}
\footnotetext{This footnote should be labeled '3'.}
\end{document}

The idea is to redefine \footnotemark to use \refstepcounter instead of \stepcounter and apply a label for each use of \footnotemark via some counter (fnmarkcntr in the above case). Then, for every successive use of \footnotetext{<text>} the appropriate label is pulled an placed in the optional argument \oldfootnotetex[..]{<text>}. This requires two compiles for the references to be correct.

It would also have been possible to patch \footnotemark with etoolbox rather than copying the original definition from article.cls.

Caveat: This approach is not compatible with hyperref.

share|improve this answer
    
Thank you @Werner. That is a very clever solution. I must ask what \the means. I compiled your document and it worked fine, however, when I copied the same definitions to another input file, I received the following error: "! Missing number, treated as zero. <to be read again> \protect." In the output file, numbering for normal \footnote{} commands and \footnotemark commands are unaffected, but \footnotetext commands produce a footnote number of 0. I am concerned that fnmarkcntr and fntextcntr may have become dissociated from one another. –  user001 Dec 18 '11 at 4:43
2  
When preceding a counter fnmarkcntr with \the (as in \thefnmarkcntr) it typesets the counter in its currently defined form (say \arabic or \alph or \Roman...). Try and see if you can incorporate my definition(s) with yours into an MWE to clearly shows the problem you are experiencing. There may be many things influencing my proposed solution, including your \documentclass as well as other packages. Edit your question and include this MWE as part of it. –  Werner Dec 18 '11 at 4:47
3  
@Werner Hyperref can produce some nasty errors... as it is beyond the scope to use \footnotemark and \footnotetext... (from the manual). I recommend hyperfootnotes=false. This is what probably is causing the errors. –  Yiannis Lazarides Dec 18 '11 at 6:54
2  
@YiannisLazarides: That's true. The original question didn't mention anything about hyperref. As such, I'll see if there's anything that can be done to save this answer. Otherwise, I'll suggest opening a new one (as a follow-up) that should rectify any incompatibilities with hyperref. –  Werner Dec 18 '11 at 7:01
    
@YiannisLazarides: Thank you for your comment. @Werner: Thank you for posting a helpful solution. Please let me know if you find any solution to the hyperref-induced error. –  user001 Dec 18 '11 at 7:12

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.