In Cool Text Highlighting in LaTeX, Gumbo offered, in a comment to Caramdir's answer, \hlc, a modification of soul's \hl to allow choosing the highlighting color on the fly. \hlc accepts $2$
as argument but will not accept \boldsymbol{$2$}
, complaining that Argument of \boldsymbol has an extra }.
When I register the command \boldsymbol
with soul
, see the documentation of soul "Adding font commands" (page 15), nothing at all happens.
Here is a MWE:
\documentclass[11pt]{book}
\usepackage{xcolor}
\usepackage{bm}
\usepackage{soul}
\soulregister{\boldsymbol}{1}
\newcommand{\hlc}[2][yellow]{\sethlcolor{#1}\hl{#2}}
\begin{document}
A. \boldsymbol{$2$}
B. \hlc[yellow]{$2$}
C. \hlc[yellow]{\textbf{Two}}
%D. \hlc[yellow]{\boldsymbol{$2$}}
\end{document}
$\boldsymbol{2}$
? – egreg Jun 19 '17 at 15:47