Underlining is the one piece of text formatting that people who know typesetting will tell you to drop — and it is not snobbery. Typewriters had no italic type, so the only way to mark a word was to run the carriage back and strike underscores beneath it. In a manuscript sent to a printer, a single line under a word was an instruction to the compositor: set this in italic. Underlining was never a style. It was the notation for one. LaTeX inherits that history twice over: \underline is really a math command and will shove a long phrase into the right margin rather than wrap it, and ulem — the package everyone installs to fix that — states its own purpose on CTAN as making output “look as if it comes from a typewriter”. This page covers how to underline in LaTeX with \underline, \uline and \ul, how ulem and soul differ, and when \emph was the answer you actually wanted.
Why \underline overflows the margin instead of wrapping
Because \underline is a math command, and it sets its argument inside one unbreakable box. It needs no package and works in text as well as in formulas, but its home is math mode — it is the rule you draw under a variable in $\underline{x}$. Used in a sentence, LaTeX quietly opens math mode around the argument, sets the whole thing as a single horizontal box, and rules a line beneath it. A box has no line-breaking opportunities inside it, so when the phrase is wider than the measure, TeX has nowhere to break and lets it run past the right margin.
% fine for a single short word
This word is \underline{underlined} in running text.
% the box has no break points, so TeX pushes it into the margin
\underline{a phrase far too long to fit on one line of this measure}The symptom in the log is worth recognising, because it is a warning and not an error: Overfull \hbox (…pt too wide) in paragraph at lines …, and the fragment TeX prints beside it comes out as []$[]$. Those two dollar signs are the confession — LaTeX is showing you that it wrapped your sentence in math mode in order to underline it. The second, quieter defect is where the rule sits. \underline puts it at a fixed depth without looking at the letters above it, so in a word with descenders the line can appear to cut through the g and the p.
So the honest division of labour is this: \underline for mathematics, where the argument is a symbol and lives inside a formula anyway, and a package the moment the rule has to sit in a sentence. Two packages own that job and they are not interchangeable. ulem gives you underlines and strike-outs that break across lines; soul gives you a highlighter and letterspacing. Before loading either, though, it is worth knowing what an underline originally meant, because that usually settles whether you want one at all.
Why typographers tell you not to underline
Because an underline is a substitute, and the thing it stands in for is right there on your keyboard. Typewriters had no bold and no italic; the only way to mark a word was to run the carriage back and strike underscores beneath the letters already typed. In the print trade that same stroke did a second job: on a marked-up typescript, underlining was an instruction to the compositor. One straight line under a word meant set it in italic, a wavy line meant bold, two lines meant small capitals and three meant full capitals. The author underlined because the author could not set italics. The compositor, who could, read the line and threw it away.
That is why the underline survives in software and vanishes from typography manuals: word processors inherited the typewriter’s keys, while metal type never had an underline to offer in the first place. LaTeX’s own tooling is candid about the lineage. Donald Arseneau’s ulem, whose copyright notice runs from 1989, is described on CTAN as replacing \em and \emph with underlining “so as to make output look as if it comes from a typewriter”, and its manual says it suits text “that may need to be underlined in a manuscript submitted for publication”. ulem was not written to decorate a finished PDF. It was written to produce a typescript.
The working rule follows. If you only want the reader to lean on a word, write \emph{...} and let the document class decide what emphasis looks like — italic in most classes, and correctly flipping back to upright when emphasis nests inside emphasis. Save real underlines for the places where the line carries information rather than tone: a deletion in a marked-up draft, a signature line, a blank to be filled in, a link. Everything below assumes you have a reason of that kind.
ulem: underlines and strike-outs that break across lines
Load \usepackage[normalem]{ulem} and write \uline{...} where you would have written \underline{...}: the rule now breaks at line ends, stretches through the interword spaces, and tolerates hyphenation inside. The package carries the whole vocabulary of proof marks — a double rule, a wavy rule, a line through the word, diagonal hatching over it, dashes and dots — because that is exactly the vocabulary a marked-up manuscript needs. Inside math mode \uline quietly hands the job back to \underline, so it is safe to use everywhere.
| Command | What it draws |
|---|---|
\uline | Underline; breaks at line ends |
\uuline | Double underline; the proof mark for small capitals |
\uwave | Wavy underline; the proof mark for bold |
\sout | Strike-out: a rule through the middle of the word |
\xout | Cross-out: the text overprinted with repeated / |
\dashuline | Dashed underline |
\dotuline | Dotted underline |
Two parameters govern the rule, and they are set in different ways for a reason that catches people out. \ULthickness is the thickness and defaults to .4pt, but it is a macro rather than a length, so it takes \renewcommand{\ULthickness}{0.8pt} and \setlength will not touch it. \ULdepth is the drop from the baseline to the rule and is a real length, set with \setlength; its default is the flag value \maxdimen, which tells ulem to work the depth out from the current font instead. Those two knobs explain more of the package than they look like: \sout is defined as nothing but an underline with \ULdepth set to -.55ex. A negative depth lifts the rule off the baseline and straight through the middle of the word — a strike-through, in ulem, is an underline drawn in the wrong place on purpose. \xout is blunter still; it simply overprints the text with repeated / characters.
\usepackage[normalem]{ulem}
\renewcommand{\ULthickness}{0.8pt} % a macro, so \renewcommand
\setlength{\ULdepth}{1.8pt} % a length, so \setlength
\uline{important} \uuline{urgent} \uwave{boat}
\sout{wrong} \xout{removed}
\dashuline{dashing} \dotuline{dotty}Why \emph suddenly underlines: the normalem option
Because plain \usepackage{ulem} redefines emphasis, and the manual says so without apology: “In LaTeX ulem replaces italics with underlining in text emphasized by \em or \emph.” It is not a bug but the package’s original purpose — remember what it was built to produce. The effect, though, is that a document which used \emph happily for two hundred pages sprouts a rule under every emphasised phrase the moment you load the package to underline one word. Nesting makes it worse: ordinary \emph alternates between italic and upright as emphasis nests, while ulem’s version, in the manual’s words, “generates multiple underlining; it does not alternate on and off.”
The fix is one word among the options: \usepackage[normalem]{ulem}. Emphasis then behaves normally again and rules appear only where you write \uline and its siblings. The same switch exists as a declaration — \normalem turns the substitution off, \ULforem turns it back on — so you can flip it mid-document if you really are preparing a typescript. In practice, load ulem with [normalem] every time unless you can say out loud why not.
\usepackage[normalem]{ulem}
% \emph keeps its italics; a rule appears only where you ask for one
This is \emph{emphasis}, and this is \uline{underlined}.
% \ULforem brings the substitution back, \normalem switches it off againsoul: highlighting with \hl, letterspacing with \so
If what you want is a yellow marker-pen highlight, or letters spread apart for emphasis, soul is the package — and it gets there by a completely different road. It hands the text to TeX’s hyphenation machinery, gets syllables and characters back, and then acts in the gaps between them. That is why it can space a word out and still let the line break inside it. Melchior Franz, who wrote it, headed off the obvious guess about the name in the manual: “the package name soul is only a combination of the two macro names \so (space out) and \ul (underline) — nothing poetic at all.” It is maintained today by the Oberdiek Package Support Group, and since version 3 it has absorbed the old soulutf8, so UTF-8 input works without loading anything extra.
| Command | Effect |
|---|---|
\so | Letterspacing — spaces the letters out |
\caps | Spacing tuned for runs of capitals and small capitals |
\ul | Underline, breaking across lines |
\st | Strike-out (overstriking) |
\hl | Highlight; yellow by default, needs color or xcolor |
Colour is set effect by effect: \setulcolor for the underline, \setstcolor for the strike-out, \sethlcolor for the highlight, and an empty argument switches colouring off again. The highlight is yellow by default; the two rules are black. One trap deserves stating plainly: \hl only highlights if color or xcolor has been loaded. Without it the command falls back to underlining without complaint, which on screen looks exactly like a highlight that failed to appear. Define your own tint with \definecolor and hand it to \sethlcolor.
\usepackage{color,soul}
\definecolor{lightblue}{rgb}{.90,.95,1}
\sethlcolor{lightblue}
\so{letterspacing} \ul{underlining} \st{overstriking}
\hl{this is highlighted in light blue}
\ul{Auf{}lage} % {} keeps the fl ligature from forming
\so{foo \mbox{little} bar} % \mbox, not bare braces, around hyphenable textThe price of the character-by-character engine is that the argument is no longer ordinary LaTeX. soul must read every token before TeX’s paragraph builder sees it, so a handful of constructions are forbidden — and the failure is loud: Package soul error: Reconstruction failed, with a black square left in the output at the offending spot so you can find it on the page. The rules worth committing to memory:
- Math needs
$...$. A formula works between dollars; the LaTeX form\(...\)does not. - Braces group, but must not hide a break point.
\so{foo {little} bar}raisesReconstruction failed, because the group contains a hyphenation point — and a space counts as one. Write\so{foo \mbox{little} bar}instead. - No nesting.
\ul{foo \so{bar} baz}is not allowed. If you truly need it, box the inner material first and accept that the box will not break. - Ligatures have to be split by hand. Inside
\ul,\stand\hl, insert{}or\nullwhere the ligature should not form (\ul{Auf{}lage}). \verb, environments and command definitions are out. For material that must pass through untouched,\soulomit{...}is the escape hatch.
ulem vs soul: which one to load
Take ulem for proof marks and soul for highlighting; if you need both, load both — the command names do not collide, since ulem provides \uline and soul provides \ul. ulem is the more forgiving of the two: you can put almost anything in the argument, and when it breaks awkwardly it at least breaks. soul fits its rule to the letters more carefully and throws in \hl and \so for the same import, but its argument is a restricted language, as the list above shows. A draft that needs “strike this out, underline the replacement” is shortest through ulem with [normalem]; a draft that needs a yellow marker for a reviewer has only one candidate, because ulem has no highlight at all.
Marking deletions and additions in a draft
The most defensible use of \sout and \uline is a draft that has to show what changed. Do not write the line commands into the prose, though. Write what you mean and let a macro decide how it prints: \deleted{...} and \added{...} behind a switch cost three lines of preamble and save a search-and-destroy pass before submission. They also leave the source readable, because \deleted{the old estimate} says something that \sout{the old estimate} does not.
\usepackage[normalem]{ulem}
\newif\ifrevisions
\revisionstrue % final version: \revisionsfalse
\newcommand{\deleted}[1]{\ifrevisions\sout{#1}\fi}
\newcommand{\added}[1]{\ifrevisions\uline{#1}\else #1\fi}
% The estimate was \deleted{0.42} \added{0.51}.Two habits keep this from going wrong. Keep revision marks and emphasis in separate vocabularies — \emph for tone, \deleted and \added for history — so that throwing the switch never touches the meaning of the text. And put “compile once with the switch off and look at the PDF” into the submission checklist, because a stray strike-through in a camera-ready file is exactly the kind of thing nobody notices until it is printed.
Underlining CJK text, and the tagged-PDF caveat
Two limits are worth knowing before you commit. First, both packages were written for Latin script. ulem and soul reason in words, hyphenation points and interword glue, none of which a run of Japanese, Chinese or Korean supplies, so a long underlined CJK passage tends to break in the wrong places or not at all. The Japanese TeX community answers this with packages of its own — jumoline, with its \Underline, \Midline and \Overline commands, is the usual recommendation, distributed outside CTAN and not part of a stock TeX Live. Second, CTAN files both ulem and soul under the topic “tagged PDF incompatible”, which matters as LaTeX moves toward accessible output; and a yellow \hl that reads beautifully on screen turns into a grey smear in monochrome print. Check both before the deadline rather than after it.