Page citation in soul

I'm using the soul package.

This works:

\ul{lorem ipsum}


This doesn't work:

\ul{lorem \cite{foo} ipsum}


This does work:

\ul{lorem {\cite{foo}} ipsum}


Neither of these works:

\ul{lorem  \cite[42]{foo}  ipsum}
\ul{lorem {\cite[42]{foo}} ipsum}


because soul says, "I came across hyphenatable material enclosed in group braces, which I can't handle."

soul suggests to put it in an \mbox or \hbox; neither of these worked for me.

I've read Hyphenatable material enclosed in group braces but I'm not sure how relevant it is. (I tried its suggestions and couldn't get anything working.)

How can I place such a citation in soul? Ideally, the citation should be hyphenatable.

M(N)WE:

\documentclass{article}

\usepackage[american]{babel}
\usepackage[style=mla]{biblatex}
\usepackage{soul}

\begin{document}

\begin{thebibliography}{9}
\bibitem{lamport94}
Leslie Lamport,
\emph{\LaTeX: A Document Preparation System}.
2nd Edition,
1994.
\end{thebibliography}

The \ul{underlined text on \cite[42]{lamport94} is underlined}, presumably.

\end{document}


The proposed solution (replacing soul with ulem) doesn't seem to work on an actual BibTeX entry:

mwe.tex

\documentclass{article}

\usepackage[american]{babel}
\usepackage[normalem]{ulem}

\usepackage[style=mla]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@ARTICLE{uncivil,
author = {Ismael, Jacqueline S. and Shereen T. Ismael},
title = {The Arab Spring and the uncivil state},
journal = {Arab Studies Quarterly},
year = {2013},
volume = {35.3},
pages = {229--240},
owner = {wchargin},
timestamp = {2014.02.12}
}
\end{filecontents*}

\begin{document}

The \uline{underlined text on \cite[42]{uncivil} is underlined}, presumably.

\printbibliography
\end{document}


The first pdflatex and bibtex commands work fine, but running pdflatex again gives the error:

! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup
\egroup \UL@putbox \fi \if...
l.11 ... text on \cite[42]{uncivil} is underlined}
, presumably.

-
I made your second MWE self-contained using filecontents. BTW even more strange to me is, that the output looks still fine despite the error messages. – Speravir Feb 19 '14 at 2:22
Thanks for that. Yes, I had noticed that the output looks fine, but the PDF processing stops and all, so there must be something going on... I can't help but think that if it's generating errors, there'll be something else trouble down the road by ignoring them. – WChargin Feb 19 '14 at 2:23
Don't use underlining. It's not used in good typography. – egreg Feb 19 '14 at 9:22
@egreg I know; it's a school assignment that mandates that you underline your thesis statement, even though it may look terrible and contradict any design standard. Thanks though. – WChargin Feb 19 '14 at 15:19

Both your examples work fine with if you put the unbreakable material inside \mbox.

1. 1st MWE

\documentclass{article}

\usepackage[american]{babel}
\usepackage[style=mla]{biblatex}
\usepackage{soul}

\begin{document}

\begin{thebibliography}{9}
\bibitem{lamport94}
Leslie Lamport,
\emph{\LaTeX: A Document Preparation System}.
2nd Edition,
1994.
\end{thebibliography}

The \ul{underlined text on \mbox{\cite[42]{lamport94}} is underlined}, presumably.

\end{document}


2. 2nd MWE

\documentclass{article}

\usepackage[american]{babel}
\usepackage[normalem]{ulem}

\usepackage[style=mla]{biblatex}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@ARTICLE{uncivil,
author = {Ismael, Jacqueline S. and Shereen T. Ismael},
title = {The Arab Spring and the uncivil state},
journal = {Arab Studies Quarterly},
year = {2013},
volume = {35.3},
pages = {229--240},
owner = {wchargin},
timestamp = {2014.02.12}
}
\end{filecontents*}

\begin{document}

The \uline{underlined text on \mbox{\cite[42]{uncivil}} is underlined}, presumably.

\printbibliography
\end{document}


-
It doesn't work for \usepackage[style=mla]{biblatex} though. (Sorry, will update question.) – WChargin Feb 19 '14 at 15:23
@WChargin For me, both the MWEs work with \mbox – karlkoeller Feb 19 '14 at 15:54
Yep, working for me too now. Must have been some silly mistake on my part. Thanks for your help. – WChargin Feb 21 '14 at 3:10

You can use \uline from ulem As noted by Karl, you have to put the \cite inside a \mbox to make it work with second mwe also.

\documentclass{article}

\usepackage[american]{babel}  % biblatex likes it
\usepackage{biblatex}         % for \cite
\usepackage[normalem]{ulem}             % for \uline

\begin{document}

\begin{thebibliography}{9}
\bibitem{lamport94}
Leslie Lamport,
\emph{\LaTeX: A Document Preparation System}.
2nd Edition,
1994.
\end{thebibliography}

The \uline{underlined text on \mbox{\cite[42]{lamport94}} is underlined}, presumably.

\end{document}


This is just a work around though.

-
Hmm, strange... although this example works, it doesn't seem to work with an actual BibTeX entry. Please see my edit. – WChargin Feb 19 '14 at 1:57
It works putting the citation in a \mbox – karlkoeller Feb 19 '14 at 7:40
@karlkoeller Thanks. Morning, I was in a hurry to edit. – Harish Kumar Feb 19 '14 at 7:56