TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have text that I need to repeat quite a few times:

\newcommand{\repeatme}{text to repeat that is somewhat long and verbose}

I'd like to underline this text and have it not cause hbox overflow errors. Thus I try (using the soul package, as if I use ulem or underline it'll hbox):

Blah blah blah, \ul{\repeatme}

This gives this error:

I came across hyphenatable material enclosed in group braces,
which I can't handle. Either drop the braces or make the material
unbreakable using an \mbox (\hbox). Note that a space
also counts as possible hyphenation point. See page 4 of the manual.

My current workaround is this:

\newcommand{\repeatmeul}{\ul{text to repeat that is somewhat long and verbose}}


Blah blah blah, \repeatmeul

But that fails... wrong. Surely there's a more elegant way!

share|improve this question

Hope the MWE explains every thing.

\newcommand*{\repeatme}{text to repeat that 
is somewhat long and verbose} %<----without underline
\newcommand{\repeatmeul}{\uline{text to repeat that 
is somewhat long and verbose}} % ,---using ulem
\newcommand{\repeatmeulsoul}{\ul{text to repeat that 
is somewhat long and verbose}} %<--- using soul
This is going to be a small task for \verb|ulem| -- \repeatmeul. 
And  another example of using \verb|soul| -- 
\repeatmeulsoul. And this is with underline -- \ul\repeatme. Here we used 
\verb|soul| package. And a similar one with \verb|ulem| won't work since the material inside \verb|{}| 
is considered as a box -- that won't break.

This code works with the following output.

enter image description here

Conclusion: Use \ul\repeatme or \repeatmeulsoul using soul package. Or use \repeatmeul using ulem package. Do not use \uline\repeatme from ulem, it won't work.

PS: If this MWE doen't work for you, you should consider updating your packages.

share|improve this answer

The following surely works (with soul)


It's always a pain to get things expanded inside \ul or similar commands. On the other hand, underlining is frowned upon in typographic circles.

With \expandafter\ul\expandafter{\repeatme}, the macro \ul is presented the expansion of \repeatme rather than the macro itself, so that this is equivalent to writing

\ul{text to repeat that is somewhat long and verbose}

but shorter.

share|improve this answer
Unfortunately I'm required to use underlines. What's the difference between \ul{\repeatme} and \ul\repeatme and \expandafter\ul\expandafter{\repeatme}? What's actually going on, in other words? – alcaras Mar 26 '12 at 17:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.