31

There is a question about nested footnotes with commas, which has some answers. Nested footnotes can be properly numbered, and they can be properly hyperlinked. Remaining problem: Hyperlinked footnotes are not separated by commas, although the footmisc package with option multiple is used. Minimal not-working example:

\documentclass{article}
\usepackage[multiple]{footmisc}
\usepackage{hyperref}
\begin{document}
Text\footnote{Here is a footnote.}\footnote{Here is another footnote.}.
\end{document}

While \textsuperscript{,\,} between the footnote(mark)s would be possible, I am looking for some automatic solution. (The better, if it would also work for nested footnotes.)

2
  • Section 2 of the footmisc manual states very clearly that footmisc is incompatible with hyperrefs hyperfootnotes option.
    – lockstep
    Commented Jan 4, 2012 at 20:37
  • 2
    @lockstep: Yes, thus: How to solve this?
    – Stephen
    Commented Jan 4, 2012 at 20:45

4 Answers 4

41

I see that I come some months to late but I want to present my approach to maybe solve the problem or at least to provide a workaround. The problem at my side is, the approach is so simple so that I can't imagine that there is no other people who had the same idea before. So my question is: Where is the catch in this approach?

To explain the code: I redefine the footnote-command and have a look to the following command using \futurelet. If the next command is also a footnote-command a , is included. What do you think about it?

\documentclass{article}
\usepackage{hyperref}

\let\oldFootnote\footnote
\newcommand\nextToken\relax

\renewcommand\footnote[1]{%
    \oldFootnote{#1}\futurelet\nextToken\isFootnote}

\newcommand\isFootnote{%
    \ifx\footnote\nextToken\textsuperscript{,}\fi}

\textheight=3cm
\begin{document}

Text\footnote{First footnote}\footnote{Second footnote}\footnote{Third footnote} Text\footnote{Fourth footnote} Text

\end{document} 

And this is the output of the given example: multiple footnotes

4
  • 1
    The \ifx\footnote\nextToken could use a \else\ifx\footnotemark\nextToken\textsuperscript{,}\fi% (and \footnoetmark would be needed to be redefined similar to the redefinition of \footnote), but otherwise your solution indeed seems to be the obvious one. (Optional argument for footnotes would be needed, too.) Hyperref could do something like "if package footmisc has been loaded with option multiple, then redefine footnote as done by Holle". +1 for this!
    – Stephen
    Commented Oct 5, 2012 at 17:13
  • 1
    This is also a Steven but from the future. ;) There apparently were some fixes in the meantime and the behavior now is better. If one loads footmisc before hyperref the MWE and my own use case work fine. However, when you load them the other way around there is a benign(?) warning LaTeX Warning: Command \@footnotemark has changed. If you additionally use a footnote in a minipage you would get another warning however: Package hyperref Warning: Ignoring empty anchor on input line…. Not sure if it's actually a problem but it was not reported yet and kept me looking for a while.
    – stefanct
    Commented Feb 19, 2020 at 1:36
  • @stefanct What do you mean by “If one loads footmisc before hyperref the MWE and my own use case work fine.”? Because, with footmisc 2022/03/08 v6.0d and hyperref 2022-05-17 v7.00q, the OP's MWE compiles certainly but there's no superscript comma between the footnote marks. Commented May 23, 2022 at 7:43
  • I was referring to the additional footmisc package, the order of the respective \usepackage commands and some warnings. I had no problems with the functionality whatsoever IIRC though. If it does not work with 2022's versions anymore then something has changed again, which I cannot test or comment on further, sorry.
    – stefanct
    Commented May 24, 2022 at 9:02
15

As @lockstep notes in the comments section above, the incompatibility between the footmisc and hyperref packages -- which somehow ends up suppressing the automatic insertion of a raised comma between consecutive footnote marks -- is sadly a fairly well-known phenomenon.

As a workaround, you could set up a macro named, say, \fnsep (short for "footnote mark separator") in the preamble:

\newcommand\fnsep{\textsuperscript{,}}

and then insert this little macro every time you have two consecutive footnotes -- which doesn't happen very often, right? -- as in

Text.\footnote{Here is a footnote.}\fnsep\footnote{Here is another footnote.}
10
  • 3
    To quote the OP: "I am looking for some automatic solution." ;-)
    – lockstep
    Commented Jan 4, 2012 at 22:32
  • 2
    Don't be so pessimistic. It's like saying "If there were any easy-to-fix bugs in colortbl, they would have been fixed by now." tex.stackexchange.com/questions/39976/…
    – lockstep
    Commented Jan 4, 2012 at 23:08
  • 2
    @lockstep & Mico: Here at tex.SE some astonishing solutions have been presented, thus I was just so bold as to ask whether there is some solution to the problem. In the footmisc manual is not written "It's not possible" but "Further work on the interaction between the two packages [footmisc & hyperref] is proposed, but not yet scheduled.", which sounds like it could be possible with enough time and knowledge of TeX. Maybe one needs just the right idea, and maybe somebody already had some solution but never published it? Thus I thought: better ask, as the worst case would be no answer.
    – Stephen
    Commented Jan 5, 2012 at 18:27
  • 1
    After six month, there are now two (!) solutions. To quote my comment: "Here at tex.SE some astonishing solutions have been presented". I know it was the right place to ask! Now that there are real solutions, I did accept one of those instead of your answer. Sorry! But I gave a +1 for it.
    – Stephen
    Commented Oct 5, 2012 at 17:17
  • 1
    Notified the maintainers of hyperref and footmisc.
    – Stephen
    Commented Oct 6, 2012 at 8:34
11

Another possibility: the fnpct package handles multiple footnotes and supports hyperref correctly. However, since the main purpose of the package is a different one you might want to use its option dont-mess-around.

\documentclass{article}
\usepackage{fnpct}
 % uncomment if don't want the kerning and punctuation switching:
% \setfnpct{dont-mess-around}
\usepackage[colorlinks]{hyperref}
\begin{document}

Text\footnote{First footnote}\footnote{Second footnote}\footnote{Third footnote}
Text\footnote{Fourth footnote} Text

\newpage\null%so we see that the hyperlinks are correct
\end{document}

enter image description here

4
  • Hey, that also works with a \footnotemark after a \footnote - but not with two consecutive \footnotemarks. +1 nevertheless!
    – Stephen
    Commented Oct 5, 2012 at 17:23
  • 5
    I like a package having an option like dont-mess-around.
    – Dohn Joe
    Commented May 12, 2015 at 12:31
  • 2
    @DohnJoe Me too :)
    – cgnieder
    Commented May 12, 2015 at 13:08
  • For \multfootnote automagic, and for package babel using French, see this comment
    – hdl
    Commented Mar 4, 2016 at 14:43
3

Here is a (slight) improvement of the (very nice!) solution provided by @Holle that takes in account the optional argument of the \footnote command (as provided by the LaTeX kernel). It makes use of the expl3 syntax.

\documentclass{article}
\usepackage[colorlinks]{hyperref}

\ExplSyntaxOn
\NewCommandCopy{\__old_footnote}{\footnote}
\let\__next_token\relax

\RenewDocumentCommand {\footnote} { O{} m }{
  \tl_if_empty:nTF {#1}{
    \__old_footnote { #2 }
  }{
    \__old_footnote [#1] { #2 }
  }
  \futurelet\__next_token\__next_token_is_footnote:
}

\cs_new_protected:Npn \__next_token_is_footnote:
{\if_meaning:w\footnote\__next_token\textsuperscript{,}\fi}

\ExplSyntaxOff

\textheight=3cm
\begin{document}

Text\footnote{First footnote}\footnote{Second footnote}\footnote{Third footnote}
Text\footnote{Fourth footnote} Text

Text\footnote[10]{Fifth footnote} Text

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .