I'm using the soul package to highlight fragments of text, using the \hl command. However, this package has problems if you have a command within the \hl command. They can usually be solved by putting the command within \mbox{}, but the problem is that if what we want to protect is a \cite command then the text inside is not breakable in multiple lines if needed, which is a problem.
My minimum working example that fails:
\documentclass[preprint,12pt,authoryear]{elsarticle}
\usepackage{color,soul}
\begin{document}
\hl{A statement \citep{ref1,ref2,ref3,ref4,ref5,ref6}}.
\bibliographystyle{elsarticle-harv}
\bibliography{references.bib}
\end{document}
It can be partially solved by replacing \citep{...} with \mbox{\citep{...}}:
\documentclass[preprint,12pt,authoryear]{elsarticle}
\usepackage{color,soul}
\begin{document}
\hl{A statement \mbox{\citep{ref1,ref2,ref3,ref4,ref5,ref6}}}.
\bibliographystyle{elsarticle-harv}
\bibliography{references.bib}
\end{document}
But in that case the citation text is not breakable and therefore I get the text getting out of the margin.
Another approach that I tried was to put the \citep command within {...}:
\documentclass[preprint,12pt,authoryear]{elsarticle}
\usepackage{color,soul}
\begin{document}
\hl{A statement {{\citep{ref1,ref2,ref3,ref4,ref5,ref6}}}.
\bibliographystyle{elsarticle-harv}
\bibliography{references.bib}
\end{document}
This last one approach leads to the error "Package soul Error: Reconstruction failed".
Any idea about how to solve this? I'm really lost here...
\soulregister\citep7
in the preamble