# detect previous character state

I am using the following tex-file:

\documentclass{book}

\begin{document}
foo\footnote{test.}\footnote{test2}
\end{document}


And the result is two adjacent superscript numbers:

I want to add a comma between the two numbers. Something in the line of

if (supercript number as the last char) print ,


Is there a general way to achieve that, not limited to the footnote example?

-
I am looking for the way to do it, not necessarily footnotes. I will have a look into footmisc to find the code. –  Andy Oct 18 '11 at 11:28

There is no control possible on what has already been set; however this can be done by redefining suitably \footnote:

\makeatletter
\let\kernel@footnote\footnote
\renewcommand\footnote[1]{\kernel@footnote{#1}%
\@ifnextchar\footnote{\textsuperscript{\,}}{}}


However this would break declaring an optional argument to \footnote and some more work is needed for this (and would also eat spaces after footnotes).

Happily, Robin Fairbairns has already thought to the problem in his package footmisc:

\usepackage[multiple]{footmisc}


The consecutive footnote marks will be separated by a comma; if you want a thin space, declare

\renewcommand{\multfootsep}{\,}

-