90

Given a simple paragraph, how do I underline a word in that paragraph?

(Note: I post this here because it wasn't really obvious using google or this site and my TexNicCenter is somehow missing this highlighting option.)

4
  • 10
    One reason why it might be missing is that AFAIK underlining is traditionally not used in professional typesetting. Instead italic or bold fonts are used for highlighting. Another alternative would be colored text. In my early LaTeX days I got told to break with this "MS Word habit". Feel free to use it, I just thought it is worth mentioning. Commented Mar 14, 2011 at 14:07
  • 1
    @M.Scharrer : I want to use it to highlight a part of a textTT formatted source string. Bold/emphasis typeface for textTT doesn't work very well (esp. on-screen).
    – Martin
    Commented Mar 14, 2011 at 14:37
  • 3
    The @ syntax uses the first three characters after it, so @M.Scharrer doesn't work. Because out both usernames start the same you need to use at least @MartinS (the space can be dropped). Commented Mar 14, 2011 at 14:57

3 Answers 3

82

Use \usepackage[normalem]{ulem} and then \uline{...}. It allows line breaks in the underlined text. Other forms of underlining (double, waves) or emphasis (crossed out, ...) are also supported. See the image in Url with fragments in bold for examples.

3
  • 1
    When you use \uline the line will be pretty far away from the text but when you use \underline{..} everything will just look fine (this is my personal feeling about it). Comparison between both (Image 7KB)
    – BlueWizard
    Commented May 14, 2015 at 9:27
  • @JonasDralle: I guess that \uline draws the line at the maximum distance independent of the content while \underline directly uses the bounding box of the content. Test it again with content which has a depth, like the word gym. Note that \underline is AFAIK designed for math and will not break around lines. So it might be fine for single words but not for longer texts. Commented May 18, 2015 at 21:04
  • 2
    @JonasDralle Use a word which has letters such as g. See Comparsion between both (Image, 10kb). \uline is always at the same height, whereas \underline on different heights.
    – koppor
    Commented Jan 11, 2017 at 19:17
54

Easy enough: \underline{...}

Note that this is the simplest form. See the answer by Martin Scharrer for some advanced info.

1
  • 15
    The problem with \underline is that it doesn't supports line breaks i.e. hyphenation in its content, e.g. like \mbox or better \fbox. For smaller words this might be ok, but not for longer ones or multiple words. Commented Mar 14, 2011 at 14:00
18

Beside \underline you can also use the packages soul and ulem.

https://texfaq.org/FAQ-underline

You must log in to answer this question.

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