# Why highlighting math with soul doesn't combine with l2tabu option for the nag package?

I have found that highlighting mathematical formulas with soul package does not work if the nag package is used with l2tabu option. A minimal (not) working example is:

\documentclass{book}

\RequirePackage[l2tabu, orthodox]{nag}
\usepackage{soul}

\begin{document}
\hl{$0.47\pm0.06$}
\end{document}


However, if l2tabu option is omitted, everything works fine. Note that if not highlighting math, but normal text, my minimal example will work. The question is why such behavior and how can this be improved?

Short answer: soul is not compatible with nag.

Preferred answer: avoid nag, it does nothing that can't be obtained by using correct style to begin with; avoid soul, too.

Longer answer: if you really need both packages

\RequirePackage[l2tabu, orthodox]{nag}
\documentclass{book}

\usepackage{soul}
\usepackage{etoolbox}
%\usepackage{hyperref} % try with and without it

\makeatletter
{\ifcat$\noexpand\SOUL@@}% old test {\ifx\nag@maybedispmath\SOUL@@}% new test {}{} % the argument of \SOUL@addmath must be delimited by active$
\begingroup\lccode\~=\$\lowercase{\endgroup\def\SOUL@addmath~#1~}{% {\let\protect\noexpand \edef\x{\global\SOUL@word={\the\SOUL@word{{\hbox{$#1$}}}}}\x}% \SOUL@scan } }{}% end of \@ifpackageloaded \makeatother \begin{document} \hl{$0.47\pm0.06\$}

Remember that nag must be loaded before \documentclass.