Typevia
LaTeX Basics

Introduction to Text Formatting

In word processors like Microsoft Word or Google Docs, you format text by clicking buttons on a toolbar. In LaTeX, formatting is handled through commands. While this might feel different at first, it provides much more precision and consistency, especially in long documents like theses or reports.

Text formatting allows you to draw attention to specific words, define terms, or follow specific academic styling guidelines. In this guide, we will cover the three most common text decorations: bold, italics, and underline.


1. Making Text Bold

Bold text is used to provide strong emphasis or to highlight keywords. In LaTeX, there are two primary ways to make text bold: using a command with an argument or using a "switch."

The \textbf Command

The most common way to bold text is the \textbf{...} command. Everything inside the curly braces will appear in bold.

This is normal text. \textbf{This text is bold.} Back to normal.

The \bfseries Switch

Sometimes you want to turn on bold formatting for a larger block of text (like an entire paragraph) without wrapping everything in braces. For this, we use \bfseries.

Note: A "switch" stays active until it reaches the end of its current "scope" (usually the end of an environment or a set of curly braces).

{
\bfseries
This entire block of text will be bold because it is inside 
the curly braces along with the bold series switch.
}
This text is back to normal.

2. Italics and Slanted Text

Italics are frequently used for book titles, foreign words, or subtle emphasis. LaTeX offers a few different ways to handle this.

The \textit Command

To italicize a specific string of text, use the \textit{...} command.

The scientific name for a domestic cat is \textit{Felis catus}.

Italics vs. Slanted (\textsl)

While they look similar, "italic" and "slanted" are technically different font shapes. Italics often use different letter shapes (like a cursive 'a'), while slanted text is simply a tilted version of the normal font.

\textit{This is italic text.}
\textsl{This is slanted text.}

The Importance of \emph

LaTeX provides a special command called \emph{...} (short for emphasis). While it usually looks just like italics, it is semantic. This means it tells LaTeX "this text is important," and LaTeX decides how to show that based on the context.

If you use \emph inside text that is already italicized, LaTeX will automatically switch back to normal (upright) text to ensure the emphasis stands out.

This is normal text with an \emph{emphasized} word.

\textit{This is an italicized sentence with an \emph{emphasized} word inside it.}

3. Underlining Text

Underlining is less common in professional typesetting (italics are usually preferred), but it is still necessary for certain document types.

The Basic \underline Command

LaTeX includes a built-in \underline{...} command. However, it has a significant flaw: it cannot wrap text. If an underlined sentence reaches the end of a line, it will continue off the edge of the page instead of breaking to the next line.

This is a \underline{simple underline}.

Using the ulem Package

To get professional-looking underlines that break across lines, you should use the ulem package. First, add \usepackage{ulem} to your document's preamble (the area before \begin{document}). Then, use the \uline{...} command.

\usepackage{ulem} % Add this to your preamble

...

\uline{This is a very long sentence that needs to be underlined and 
will successfully wrap to the next line without any issues.}

Warning: By default, the ulem package changes all \emph commands to underlines. To prevent this and keep \emph as italics, load the package with the normalem option: \usepackage[normalem]{ulem}.


4. Combining Styles

You can nest formatting commands to apply multiple styles to the same text. For example, you might want text that is both bold and italicized.

Nesting Commands

To combine styles, simply place one command inside the braces of another. The order does not matter.

\textbf{\textit{This text is bold and italic.}}

\textit{\textbf{This is also bold and italic.}}

\textbf{\textit{\uline{This text is bold, italic, and underlined!}}}

5. Summary Table

Here is a quick reference for the commands covered in this guide:

EffectCommandDescription
Bold\textbf{...}Best for short phrases.
Bold Switch{\bfseries ...}Best for large blocks or custom environments.
Italics\textit{...}Standard italic font.
Emphasis\emph{...}Smart formatting; toggles between italic/upright.
Underline\uline{...}Requires ulem package; supports line breaking.

6. Best Practices and Common Pitfalls

Use \emph Instead of \textit

Whenever you want to emphasize text for meaning (rather than just styling a title), use \emph. It makes your document's logic clearer and handles nested formatting automatically.

Don't Over-Format

Beginners often use bold, italics, and underlining all at once. This makes a document look cluttered and harder to read. Choose one method of emphasis and use it consistently.

Braces Must Match

A very common error is forgetting the closing brace }. This will cause a compilation error.

  • Wrong: \textbf{Hello world
  • Right: \textbf{Hello world}

Avoiding Underlines in Modern Documents

In the era of typewriters, underlining was used because they couldn't do italics. In modern typesetting, underlining is often considered "noisy" because the line cuts through the "descenders" of letters (like the tails on 'g', 'j', 'p', 'q', and 'y'). Use italics for emphasis whenever possible!