Typevia
Fonts and Typography

Understanding LaTeX Typography

In traditional word processors, changing a font is often a matter of clicking a dropdown menu. In LaTeX, font management is handled through a system of commands designed to maintain typographic consistency. LaTeX categorizes fonts into three main attributes: Family, Series, and Shape.

By understanding these categories, you can control the appearance of your text precisely, ensuring your document is both readable and professional.

1. The Three Main Font Families

LaTeX divides fonts into three primary "families." By default, LaTeX uses the Computer Modern font, but these commands work regardless of the specific typeface loaded.

  1. Roman (Serif): This is the default family for body text. It features small strokes (serifs) at the ends of characters, which help guide the eye along lines of text.
  2. Sans Serif: These fonts lack the small strokes at the ends of characters. They are often used for headings or digital displays.
  3. Typewriter (Monospaced): Every character occupies the same width. This is primarily used for computer code, URLs, or simulating terminal output.

Code Example: Switching Families

To change the family of a specific block of text, use the following commands:

\documentclass{article}
\begin{document}

This is the default Roman (Serif) text.

\textsf{This text is in Sans Serif family.}

\texttt{This text is in Typewriter/Monospaced family.}

\end{document}

Note: These commands only affect the text inside the curly braces {}. This is known as "local" formatting.


2. Modifying Font Series and Shape

Once you have chosen a family, you can modify its Series (the thickness/weight) and its Shape (the slant or style).

Font Series (Weight)

The most common series modification is making text bold.

  • Command: \textbf{bold text}

Font Shape

LaTeX provides several ways to change the shape of your characters:

  • Italics: \textit{italic text} — Used for emphasis or titles.
  • Slanted: \textsl{slanted text} — Similar to italics, but the characters are just skewed rather than having different glyph designs.
  • Small Caps: \textsc{Small Caps Text} — Uses capital letters, but the "lowercase" letters are smaller versions of the uppercase ones.

Code Example: Combining Styles

You can "nest" these commands to achieve multiple effects, such as bold-italics.

\documentclass{article}
\begin{document}

You can make text \textbf{bold}, \textit{italicized}, 
\textsl{slanted}, or in \textsc{Small Caps}.

You can also \textbf{\textit{combine styles}}, like bold and italics 
together, provided the font family supports it.

\end{document}

3. Commands vs. Declarations

In LaTeX, there are two ways to apply font styles: Commands and Declarations. Understanding the difference is vital for efficient document styling.

Commands (The Argument Approach)

Commands like \textbf{...} take an argument in braces. They are best for short snippets of text.

Declarations (The Switch Approach)

Declarations act like a light switch: once you turn them on, everything following them is affected until the end of the current "scope" (usually the end of an environment or a set of braces).

StyleCommandDeclaration
Bold\textbf{...}\bfseries
Italics\textit{...}\itshape
Sans Serif\textsf{...}\sffamily
Typewriter\texttt{...}\ttfamily

Code Example: Using Declarations

Declarations are often used inside environments or within custom braces to limit their effect.

\documentclass{article}
\begin{document}

This is normal text.

{
\itshape
This entire block is italicized because it is inside 
braces with the italic shape declaration.
}

Back to normal text automatically.

\end{document}

4. Changing Font Sizes

LaTeX does not use "points" (like 12pt or 14pt) for individual words. Instead, it uses a set of relative size commands. These sizes are relative to the base font size defined in your \documentclass (usually 10pt, 11pt, or 12pt).

The standard sizes, from smallest to largest, are:

  1. \tiny
  2. \scriptsize
  3. \footnotesize
  4. \small
  5. \normalsize (Default)
  6. \large
  7. \Large
  8. \LARGE
  9. \huge
  10. \Huge

Code Example: Size Variations

Note that font size commands are declarations, so they do not take braces as arguments.

\documentclass{article}
\begin{document}

{\tiny tiny text} \par
{\small small text} \par
{\normalsize normal text} \par
{\large large text} \par
{\huge huge text} \par
{\Huge Huge text}

\end{document}

Tip: Always use braces { \large ... } to contain the size change, otherwise the rest of your document will remain at that size!


5. Best Practices and Semantic Markup

When writing in LaTeX, it is a best practice to focus on meaning rather than appearance.

Use \emph for Emphasis

While \textit explicitly tells LaTeX to use italics, \emph tells LaTeX to "emphasize" the text.

  • In normal text, \emph will italicize.
  • If you use \emph inside already italicized text, it will switch back to upright text to ensure the emphasis stands out.

Code Example: Semantic Emphasis

\documentclass{article}
\begin{document}

This is \emph{emphasized} text.

\textit{This is a whole sentence in italics that contains \emph{emphasized} words.}

\end{document}

Avoid Underlining

In professional typography, underlining is generally avoided because it "cuts" the descenders of letters (like y, g, and p), making them hard to read. Use bold or italics for emphasis instead.


6. Common Pitfalls to Avoid

  1. Forgetting to close braces: If you write \textbf{Hello, the rest of your document might turn bold or, more likely, LaTeX will throw an error saying "Emergency stop."
  2. Using \bf or \it: You may see old tutorials using {\bf text}. These are "Old LaTeX 2.09" commands. They still work but are deprecated and can conflict with other formatting. Always use \textbf{} or \bfseries.
  3. Over-formatting: Using too many different font sizes and styles on one page makes a document look cluttered and unprofessional. Stick to 2–3 variations per page.
  4. Math Mode Confusion: Font commands for text (like \textit) do not work the same way inside math mode ($...$). To change fonts in math, use commands like \mathbf{...} or \mathit{...}.

Summary Example

Here is a practical application of these concepts in a short document fragment:

\documentclass[12pt]{article}
\begin{document}

\section*{Project Specifications}

The following \textbf{requirements} must be met:
\begin{itemize}
    \item All code must be written in \texttt{Python 3.10}.
    \item The final report must be submitted in {\scshape Small Caps} format for headers.
    \item {\large \color{red} Warning:} Do not ignore the \emph{safety} protocols.
\end{itemize}

\end{document}

By mastering these font commands, you can move away from "manual" styling and begin to leverage the full typographic power of LaTeX.