27

I am using \uwave{Some text here} to put a wave like emphasis under the text. Is it possible to change the color of only the wave and leave the text black?

2 Answers 2

30

It is highly recommended that you post a minimal example. It is possible to only color the wave part by redefining the command \uwave or by creating a new command named \redwave as you like.

\documentclass[11pt]{article} 
\usepackage{xcolor}
\usepackage{ulem}
\makeatletter
\def\uwave{\bgroup \markoverwith{\lower3.5\p@\hbox{\sixly \textcolor{red}{\char58}}}\ULon}
\font\sixly=lasy6 % does not re-load if already loaded, so no memory problem.
\makeatother
\begin{document}
  \uwave{This is a long test}
\end{document}

The ulem package uses the wiggle from the 6-pt lasy font and we just use textcolor to color it.

One could extend the above code to give it a more semantic name, as suggested by TH and also to give an optional color. The MWE below defines a command \colorwave for this purpose.

\documentclass[11pt]{article} 
\usepackage{xcolor}
\usepackage{ulem}
\usepackage{lipsum}
\makeatletter
\newcommand\colorwave[1][blue]{\bgroup \markoverwith{\lower3.5\p@\hbox{\sixly \textcolor{#1}{\char58}}}\ULon}
\font\sixly=lasy6 % does not re-load if already loaded, so no memory problem.
\makeatother
\begin{document}
 \colorwave[red]{This is a long test} \lipsum*[1].\par
 \colorwave[green]{This is a long test} \lipsum*[1]
\end{document}

enter image description here

3
  • 2
    Nice. One could make a \colorwave based on this where the color to use is passed in as an argument.
    – TH.
    Dec 18, 2010 at 1:45
  • @TH Sure and it will be better rather than redefining the original command.
    – yannisl
    Dec 18, 2010 at 3:54
  • For thicker line consult this link. Or substitute: lasy6 -> lasyb10 scaled 652
    – user23191
    Dec 11, 2012 at 11:06
0

I think this answer is simpler:

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

\newcommand{\coloredwave}[2]{
    \textcolor{#1}{\uwave{\textcolor{black}{#2}}}
}

\begin{document}

\coloredwave{red}{This text will be underlined with a red wavy line.}

\end{document}
1

You must log in to answer this question.

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