11

The following MWE gives me an error. This should work, shouldn't it?

\documentclass{article}
\usepackage{color,soul}
\begin{document}
\hl{A statement \cite{hong_groups_2004}}
\end{document}

Here's the error:

! Argument of \@citex has an extra }.
<inserted text> 
                \par 
l.4 \hl{A statement \cite{hong_groups_2004}}
1
17

Try enclose \cite{hong_groups_2004} in an extra pair of curly brackets ({}), without those, soul may do funny things with the \cite-command:

\documentclass{article}
\usepackage{color,soul}
\begin{document}
\hl{A statement {\cite{hong_groups_2004}}}
\end{document}

Section 2.1 and 2.2. in the manual describes some problems and possible solution. In addition, I suggest that you use the more robust soulutf8 by Heiko Oberdiek to avoid possible future errors. With soulutf8, it is possible to use utf8, which is a must if you use other languages than US English.

New MWE:

\documentclass[UKenglish]{article}
\usepackage[utf8]{inputenx}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{color,soulutf8}

\begin{document}
\hl{A statement {\cite{hong_groups_2004}}}

Normal text.

\hl{Highlighted text with æøåÆØÅ}

\end{document}

Edit: If the additional pair curly brackets ({}) does not solve the error, try enclose the command in and mbox{} instead, i.e. mbox{\cite{hong_groups_2004}}.

My best tip is to read the manual subsection 2.3.1 to see if you recognise some of the boarder line cases described there. This may give you some hint regarding possible solutions.

3
  • 3
    This solution gets rid of the citex error, but creates a new one: ! Package soul Error: Reconstruction failed.
    – elplatt
    May 23 '16 at 18:44
  • 1
    @elplatt I found putting \protect before the citations is a decent solution. Oct 20 '19 at 21:57
  • 1
    @kevinkayaks. It partially works. I have a command called replace which changes the color and strikes the text. In the text I have two citations. Using project before the two of them makes it compile, which is great! BUT only the text color is applied to the entire text. For some reason the strike style is applied only until just before the first citation. Mar 23 at 14:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.