# Underline colored text with linebreak

I would like to underline colored text with a black line, and preserve line breaking. My best solution so far is using \uline from the ulem package. However, I cannot get my desired result. My attempts are:

\documentclass{article}
\usepackage{ulem}
\usepackage{color}

\begin{document}

This is a long text. This is a long text.
\color{red}\uline{This is underlined text.
This is underlined text. This is underlined text.}\color{black}
This is a long text. This is a long text.

This is a long text. This is a long text.
\uline{\color{red}This is underlined text.
This is underlined text. \color{black}}
This is a long text. This is a long text.

This is a long text. This is a long text.
\textcolor{red}{\uline{This is underlined text.
This is underlined text. }}
This is a long text. This is a long text.

This is a long text. This is a long text.
\uline{\textcolor{red}{This is underlined text.
This is underlined text. }}
This is a long text. This is a long text.

\end{document}


As you can see, every attempt has a flaw.

Is there a solution to this? Many thanks!

EDIT:

I am now using the cloze package, which does not have the shortcomings above and has not let me down yet. It is definitely an option for everyone who can switch to LuaLaTeX.

• (1) welcome, (2) did you read the ulem manual? This seems to be mentions in section 2. Ahh, no that makes the line red. Nevermind – daleif Jan 19 '17 at 15:27

## 1 Answer

If it is just a command that gives red text underlined with black line, then this might work

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


If not, don't get your hopes up too hight, things get complicated when you parse in the way \ulem does.

BTW: who is even using underlining these days?

• Thanks for your answer! I use underlining for cloze texts. But I might switch to LuaLaTeX now because of a very nice cloze package... – FlorianL Jan 19 '17 at 23:36
• @FlorianL: The usual way to appreciate the work of users here is to upvote and accept answers, instead of leaving a Thank you comment only! – user31729 Feb 20 '17 at 0:17