0

I use the soul package to highlight some changes in my documents for review purposes. However I can't get it to work with equations (or other environments for that matter).

Basically I create a command that will highlight with my color:

\newcommand{\MA}[1]{{\sethlcolor{cyan}\hl{#1}}}   %highlighting

then I want to use it like in the MWE bellow. I know about putting a \protect command before \begin{equation} but the problem with that is that I would have to do it manually. Is there a way of protecting the equations from within the \newcommand definition.

Additionally, it seems that the protect methodology compiles well but only highlights until the first protected equation and everything after it remains uncolored.


MWE

\documentclass[12pt]{article}
\usepackage{xcolor}      % Colors
\usepackage{soul}        % Highlighting and strikeout

\newcommand{\MA}[1]{{\sethlcolor{cyan}\hl{#1}}}   %highlighting

\begin{document}

This is not highlighted. \MA{But this is.}

\MA{
this equation
\begin{equation}
    a+b=c
\end{equation}
will not work.
}

\end{document}
  • The soul manual clearly states that math is allowed when it's used with the $....$ way, but there is no information for equation – user31729 Jun 30 '15 at 15:47
1

You can obtained the same result with the empheq package (needless to load amsmath in that case):

\documentclass[12pt]{article}
\usepackage{empheq}
\usepackage{xcolor} % Colors
\usepackage{soul} % Highlighting and strikeout

\newcommand{\MA}[1]{{\sethlcolor{cyan}\hl{#1}}} %highlighting
\newcommand*\hlbox[1]{%
\colorbox{cyan!30!}{\quad#1\quad}}
\begin{document}

This is not highlighted. \MA{But this is.}

This equation
\begin{empheq}[box =\hlbox ]{gather}
  a+b=c \\
  a^2 + b^2 = c^2
\end{empheq}
works with \texttt{empheq}.

\end{document} 

enter image description here

  • 1
    Thanks @Bernard for presenting the empheq package. It might provide useful in the future. However my objective is to be able to highlight a few paragraphs with equations in-between without having to specifically go and change each equation. – Miguel Jul 6 '15 at 15:21
  • Note that of you use the overload option of empheq, you can keep the old sytax, jusr adding the optional argument – i mean the example code should simply write as: \begin{gather}[box=\hlbox] … \end{gather}. – Bernard Jul 6 '15 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.