Text formatting

Bold, italic, underline, fonts, sizes and colors in LaTeX.

LaTeX formats text with commands that wrap the text they change.

The basics

Sometimes you need to match \textbf{Bold} statements with \textit{Nuance}.
\underline{Underlining} is also possible, but used less often.

For code or variable names, we often use \texttt{Typewriter font}.

Prefer \emph{text} over \textit{text} for emphasis. \emph switches back to upright text when it sits inside an already italic sentence, so the emphasis stays visible.

Font families and sizes

Size commands apply from where you write them until the end of the current group or environment. Family commands take the text as an argument.

\tiny This is tiny text
\small This is small text
\normalsize This is normal text
\large This is large text
\Huge This is huge text

\textrm{Roman (serif) font}
\textsf{Sans-serif font}
\texttt{Monospace font}

To limit a size change to part of the text, wrap it in braces: {\large like this}.

Colors

Load the xcolor package in the preamble, before \begin{document}.

\usepackage{xcolor}

\textcolor{red}{Important Error!}
\textcolor{blue}{Blue Text}
\colorbox{yellow}{Highlighted Text}