The soul package

Underlines, strikes out, highlights and letterspaces text that still breaks across lines: \ul, \st, \hl, \so and \caps.

Loading the package

\usepackage{soul}

\underline puts its text in a box that cannot break, so a long underlined passage runs into the margin. The commands of soul work syllable by syllable: the text breaks at the end of a line and is hyphenated like normal text.

\hl highlights with a coloured background and needs xcolor or color. Without a colour package it underlines the text instead.

Main commands

\ul{text}Underlines.
\st{text}Strikes out.
\hl{text}Highlights with a yellow background.
\sethlcolor{green}Colour of the highlighting; \setulcolor and \setstcolor set the colour of the lines.
\so{text}Letterspaces the text.
\caps{Text}Letterspaced small capitals.
\setul{0.4ex}{0.2ex}Depth and thickness of the underline.

Complete example

\documentclass{article}
\usepackage{xcolor}
\usepackage{soul}
\begin{document}
\ul{Underlined text}, \st{struck-out text} and \hl{highlighted text}.

\sethlcolor{green}
\hl{A highlighted passage that is long enough to reach the end of the
line continues on the next line, and words are hyphenated as usual.}

\so{Letterspaced text} and \caps{Small Capitals}.
\end{document}
Result
The compiled example

Open in the editor

Compiled with pdfLaTeX from TeX Live 2023.

Pitfalls

Related pages