# Colored underlining without affecting vertical spacing

I'm using the coloured underlining trick described in the ulem package manual (p.3). The underlining looks good, but interacts poorly with align-like environments, where (in contrast to \uline) it affects the height of the row:

It is possible to have a version of \reduline that, modulo colour, behaves as \uline?

\documentclass{article}
\usepackage{amsmath}
\usepackage{ulem}
\usepackage{xcolor}

\newcommand\reduline{\bgroup\markoverwith{\textcolor{red}{\rule[-0.5ex]{2pt}{0.4pt}}}\ULon}

\begin{document}

\begin{align*}
\uline{ABCD} + EFGH \\
\reduline{ABCD} + EFGH \\
ABCD + EFGH
\end{align*}
\end{document}

• The accents package is preferable to put accents under mathematical symbols and doing this would be easy (but not from the cellphone I'm typing this on) – JPi Aug 21 '16 at 19:58

Well, this works....

\documentclass{article}
\usepackage{amsmath}
\usepackage{ulem}
\usepackage{xcolor}

\newcommand{\reduline}[1]{{\color{red}\uline{{\color{black}#1}}}}

\begin{document}

\begin{align*}
\uline{ABCD} + EFGH \\
\reduline{ABCD} + EFGH \\
ABCD + EFGH
\end{align*}
\end{document}


Example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{accents}

\newcommand{\redlb}[1]{{\color{red}\underaccent{\bar}{\color{black}#1}}}

\begin{document}

\begin{align*}
{A} + B \\
\redlb{A} + B \\
A + B
\end{align*}
\end{document}


Your red under-bar is wider than mine. The author of the accents package questions the wisdom of using wide bars, but if you want one of those then you can find out as an answer to a different question how to accomplish that. Strangely, wide tildes are easier.

EDIT

And here's how to get a wide tilde under accent:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{accents}
\DeclareMathAccent{\wtilde}{\mathord}{largesymbols}{"65}

\newcommand{\redlb}[1]{{\color{red}\underaccent{\bar}{\color{black}#1}}}
\newcommand{\redwt}[1]{{\color{red}\underaccent{\wtilde}{\color{black}#1}}}

\begin{document}

\begin{align*}
A + B \\
\redlb{A} + B \\
\redwt{A} + B
\end{align*}
\end{document}

• Thanks - however it's underlining that I need. Updated example code and PNG. – Roly Aug 21 '16 at 23:22
• see new answer. – JPi Aug 21 '16 at 23:32