# Underlining with ulem package breaks footnotes

For some reason, footnotes do not seem to work with the ulem package.

\documentclass{article}
\usepackage{ulem}
\begin{document}
\uline{test\footnote{note}}
\end{document}


gives

! Undefined control sequence.
\@footnotemark ...rk \ifhmode \spacefactor \@x@sf
\fi \relax


when I try to compile it using pdflatex. Is there any chance to fix this or some kind of workaround?

• You might use soul and its \ul command. If you're underlining a word for giving it a special meaning, then the footnote marker shouldn't be underlined anyway and the standard \underline would suffice. If you're underlining a whole sentence, emphasize it in a different way, with italics, for instance; your readers will be grateful. – egreg Jun 23 '14 at 10:34
• Thanks for your advice. But my requirements for underlining with the ulem package are kind of external. – porst17 Jun 23 '14 at 11:13

Put problematic parts in a box (see the documentation). But -- as Heiko reminds in the comment -- if you put the whole footnote in the box you will loose the text. So you should use \footnotemark/\footnotetext:

\documentclass{article}
\usepackage{ulem}
\begin{document}
\uline{test\mbox{\footnotemark}}\footnotetext{note}\uline{ blalbalb}\footnote{blub}
\end{document}

• Perfect example of RTFM. – porst17 Jun 23 '14 at 11:05
• \footnotemark and \footnotetext are needed. – Heiko Oberdiek Jun 23 '14 at 11:36
• @HeikoOberdiek: Blush. That's the draw back of a too large zoom. You are completly right. I will edit the answer. – Ulrike Fischer Jun 23 '14 at 11:45

Two variants of underlining:

\documentclass{article}
\usepackage{ulem}
\begin{document}
%   \uline{test\footnote{note}}

\uline{test}\footnote{note}

or

{test}\footnote{ \uline{note}}
\end{document}


• +1 Underlining should not be used at all, anyways. And it certainly makes no sense to underline a text that is long enough to contain a footnote. – yo' Jun 23 '14 at 10:29
• There are certainly use cases, where underlining makes sense - regardless of the footnotes. Judging underlining is not part of the question. – porst17 Jun 23 '14 at 11:04