2

I use the following command in my preamble for highlighting.

\newcommand{\zz}[1]{{\color{blue}\sffamily #1}}

However, I'd like to add the functionality so that I can also include math in it. Currently, statements like

\zz{Testing, $\mathcal{T}$, $4$, $5$}

will cause issues during compilation because something about sffamily not agreeing with math mode. It will still output the correct PDF, but since I'm getting that error, I feel like I'm doing something fundamentally wrong in the command definition.

I tried looking at using conditionals, however the closest I got was

\newcommand{\zz}[1]{
\ifthenelse{\relax\ifmmode}
{\color{blue} #1}
{\color{blue}\sffamily #1}
}

which did not work. Any help is greatly appreciated!

Zim
  • 133

0 Answers0