I want to highly text which contains math in shades of grey with allowing for linebreaks. Based on this excellent post, I tried:
\documentclass{article}
\usepackage{xcolor}
\usepackage{soul}
\newcommand{\mathcolorbox}[2]{\colorbox{#1}{$\displaystyle #2$}}
\newcommand{\hlfancy}[2]{\sethlcolor{#1}\hl{#2}}
\begin{document}
This works: \hlfancy{gray}{colored $a=b$ math}.
This does not: \hlfancy{gray!60}{colored $a=b$ math}.
\end{document}