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

Sometimes I want to underline some text, and it extends past the end of a line. Why does \underline{} not automatically wrap my text for me ?

Also, how can I underline text so that it will still wrap ?

share|improve this question
up vote 48 down vote accepted

In text mode, the \underline command will enclose its argument in a horizontal box, which doesn't allow linebreaks. Use the \ul command of the soul package instead.




A sentence that is just included to fill the line. \underline{Some text with underlining.}

A sentence that is just included to fill the line. \ul{Some text with underlining.}


enter image description here

EDIT: As for why \underline works the way it does, see this entry in the UK TeX FAQ for starters. It would seem that Leslie Lamport (the author of LaTeX) implemented just a "quick fix", and that only later package authors came up with more satisfactory solutions for underlining. See sections 2 and 7 of the soul documentation to get an idea of how complicated things are.

share|improve this answer
This mostly answers my question, but do you also know why \underline has this behavior ? – gabkdlly Jan 24 '11 at 10:03
There is also the ulem package with gives \uline. The package should be loaded with the normalem option, otherwise the \emph macro is changed to underline the text. – Martin Scharrer Apr 17 '11 at 19:48
@gabkdlly: Basically \underline boxes the text using \hbox, i.e. the primitive version of \mbox. Both aren't breakable by design. The ulem package for example avoids this issue by boxing each word separately by searching for the spaces between them. This still doesn't allow for hyphenation. – Martin Scharrer Apr 17 '11 at 19:51
The soul package gave me trouble when the underlined text contained cite. The ulem package worked better. – Vebjorn Ljosa Aug 15 '12 at 21:20
If there is a better way to do this that is non-breaking, it should be replaced in the main environment. I am restricted on the packages I can use, therefore I cannot fix this behavior because the improvements were never backported. – Elliot Apr 22 '13 at 18:24

The \ul command from the soul package has troubles with Umlauts -- the ulem package doesn't and therefore seems to be the better option for those not exclusively writing in English.

share|improve this answer
It should be noted that the comment to underline text is \uline for that package. – Keba Apr 29 '15 at 21:51

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.