1

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}
schremmer
  • 2,107

1 Answers1

1

I have no issue if I use the correct syntax:

\documentclass[11pt]{book}
\usepackage{xcolor}
\usepackage{bm}
\usepackage{soul}

\newcommand{\hlc}[2][yellow]{\sethlcolor{#1}\hl{#2}}

\begin{document}
A. $\boldsymbol{2}$

B. \hlc[yellow]{$2$}

C. \hlc[yellow]{\textbf{Two}}

D. \hlc[red]{$\boldsymbol{2}$}

E. \hlc{$\boldsymbol{2}$}

\end{document}

enter image description here

egreg
  • 1,121,712