4

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:

enter image description here

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}
1
  • 2
    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
    Commented Aug 21, 2016 at 19:58

2 Answers 2

7

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}

enter image description here

2
  • The trick seems doesn't allow line breaks in the inner text. (I'm using it in a normal text paragraph) Commented Feb 22, 2023 at 9:48
  • I needed to add \color{black} to the end of the \reduline command for it to switch back to black outside the command. Commented Sep 26, 2023 at 14:36
1

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}

enter image description here

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}
2
  • Thanks - however it's underlining that I need. Updated example code and PNG.
    – Roly
    Commented Aug 21, 2016 at 23:22
  • see new answer.
    – JPi
    Commented Aug 21, 2016 at 23:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .