Sorry if this has been asked before. I could not find an answer to this problem yet. I'm finding some issues when highlighting text defined by newcommand:
\documentclass{article}
\usepackage{color,soul}
\newcommand{\etal}{\emph{et al.}}
\begin{document}
\hl{A statement \etal}
\end{document}
gives error Package soul Error: Reconstruction failed.
Surprisingly, \hl{A statement \emph{et al.}}
works just fine.
What am I doing wrong? Is there anything I can do to fix this? Using \emph{et al.}
instead of \etal
is not my preferred solution, since sometimes I just want to highlight text that's already there.
This answer doesn't solve the problem either, since \hl{A statement {\etal}}
returns the same error. I've checked this other solution, but I'm not sure how to use it for my own defined command…
Thanks!
Best Answer
The
soul
analyzes the macro arguments of\hl
and the relatedsoul
macros. All font switching macros like\emph
and\bf
(the later being outdated, of course) are 'registered' to preventsoul
to analyze them but to execute them immediately ('expand') in order to perform the highlighting after this expansion.works since
\emph
is registered already, but\etal
is not. This can be done however with\soulregister\etal7
will enable
\etal
forsoul
usage, 'abusing' the\soulregister
feature a little bit. The documentation does not reveal that7
is possible.