4

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!

3
  • 1
    \soulregister\etal7 works for me...
    – user31729
    Dec 6 '17 at 7:35
  • Thank you!! I didn't know you could add the 7 to whatever command, even if self-defined!
    – ana
    Dec 7 '17 at 7:03
  • the 7 is a hidden feature of soul.
    – user31729
    Dec 7 '17 at 7:11
4

The soul analyzes the macro arguments of \hl and the related soul macros. All font switching macros like \emph and \bf (the later being outdated, of course) are 'registered' to prevent soul to analyze them but to execute them immediately ('expand') in order to perform the highlighting after this expansion.

\hl{A statement \emph{et al.}} 

works since \emph is registered already, but \etal is not. This can be done however with

\soulregister\etal7

will enable \etal for soul usage, 'abusing' the \soulregister feature a little bit. The documentation does not reveal that 7 is possible.

\documentclass{article}
\usepackage{color,soul}
\newcommand{\etal}{\emph{et al.}}

\soulregister{\etal}{7}
\begin{document}

\hl{A statement \emph{et al.}}


\hl{A statement \etal}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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