[Tex/LaTex] How to highlight equations in mathematics

highlighting

How I can highlight equation as given below:

enter image description here

Best Answer

You can play around with the spacing:

enter image description here

\documentclass{article}

\usepackage{xcolor,amsmath}
\DeclareMathOperator{\suc}{Suc}

\begin{document}

By applying rule~2 (\texttt{apply\_rupple\_step}), the left hand side of the step-case is rippled to:
\[
  \colorbox{orange}{\strut
    case $b'$ of $0 \Rightarrow (\suc a) \mid (\suc z) \Rightarrow \suc(\colorbox{white}{$\max a \lfloor z \rfloor$})$%
  }
  {} = \max \lfloor b' \rfloor
  \colorbox{orange}{\strut
    $\suc \colorbox{white}{a}$%
  }
\]

\end{document}

Ultimately you can just use \colorbox{<color>}{<stuff>} to highlight content. I've added \strut to ensure a consistent baseline height of the resulting coloured box, as well as using text where it seemed necessary. Note that <stuff> inside a \colorbox is set in text mode.