Typography & Fonts

  • JNext lesson
  • KPrevious lesson
  • FSearch lessons
  • EscClear search

The difference between a document that looks “typed” and one that looks “published” comes down to typography: font choice, spacing, ligatures, and the hundreds of micro-decisions that most readers never consciously notice but always feel. This chapter covers how to control all of it.

Engines and Font Systems

Your choice of engine determines what fonts you can use:

  • Engine: pdflatex | Font System: Type1 (.pfb), built-in only | Math Fonts: Traditional: mathpazo, newtxmath
  • Engine: xelatex | Font System: OpenType/TrueType system fonts | Math Fonts: unicode-math with OpenType math
  • Engine: lualatex | Font System: OpenType/TrueType system fonts | Math Fonts: unicode-math with OpenType math
    This book uses xelatex with fontspec and unicode-math. These packages let you use any font installed on your system.

Setting Fonts with fontspec

\usepackage{fontspec}
\usepackage{unicode-math}

\setmainfont{STIX Two Text}       % Serif text
\setsansfont{Inter}                % Sans-serif
\setmonofont{JetBrains Mono}[Scale=0.85]  % Monospace
\setmathfont{STIX Two Math}       % Math

Font Features

OpenType fonts support features you can enable:

\setmainfont{STIX Two Text}[
    Numbers=OldStyle,           % 0123456789
    Ligatures=TeX,              % ff, fi, fl, ffi, ffl
    BoldFont={STIX Two Text Bold},
    ItalicFont={STIX Two Text Italic},
    BoldItalicFont={STIX Two Text Bold Italic}
]

Font Showcase

Here are recommended combinations for academic documents:

  • Text Font: STIX Two Text | Math Font: STIX Two Math | Character: Classic, Times-like. Used in this book.
  • Text Font: Libertinus Serif | Math Font: Libertinus Math | Character: Elegant, humanist. Open source.
  • Text Font: TeX Gyre Termes | Math Font: TeX Gyre Termes Math | Character: Times clone. Widely available.
  • Text Font: TeX Gyre Pagella | Math Font: TeX Gyre Pagella Math | Character: Palatino clone. Warm, readable.
  • Text Font: Latin Modern | Math Font: Latin Modern Math | Character: Computer Modern successor. The LaTeX default.

    Tip: If you’re submitting to a journal, check their requirements first. Many journals specify Computer Modern (the default) or Times. STIX Two is a safe choice when no font is specified — it’s designed for scientific publishing and covers virtually every mathematical symbol.

Text Formatting Commands

Font Styles

  • Command: \textbf{...} | Switch: \bfseries | Output: Bold | Use: Emphasis, terms
  • Command: \textit{...} | Switch: \itshape | Output: Italic | Use: Foreign words, titles
  • Command: \textsl{...} | Switch: \slshape | Output: Slanted | Use: Rarely used
  • Command: \textsc{...} | Switch: \scshape | Output: Small Caps | Use: Acronyms
  • Command: \texttt{...} | Switch: \ttfamily | Output: Monospace | Use: Code
  • Command: \textsf{...} | Switch: \sffamily | Output: Sans-serif | Use: Contrast
  • Command: \emph{...} | Switch: \em | Output: Emphasis | Use: Context-aware

    Tip: Use \emph instead of \textit. Within already-italic text, \emph switches to upright, maintaining visual contrast. \textit stays italic and the emphasis is lost.

Font Sizes

  • Command: \tiny | Approximate size (11pt base): 6pt
  • Command: \scriptsize | Approximate size (11pt base): 8pt
  • Command: \footnotesize | Approximate size (11pt base): 9pt
  • Command: \small | Approximate size (11pt base): 10pt
  • Command: \normalsize | Approximate size (11pt base): 11pt
  • Command: \large | Approximate size (11pt base): 12pt
  • Command: \Large | Approximate size (11pt base): 14pt
  • Command: \LARGE | Approximate size (11pt base): 17pt
  • Command: \huge | Approximate size (11pt base): 20pt
  • Command: \Huge | Approximate size (11pt base): 25pt

    Microtype

The microtype package makes subtle adjustments to character spacing that dramatically improve text appearance:

\usepackage{microtype}

That single line enables:

  • Character protrusion. Hyphens and punctuation extend slightly into the margin, making the text block look more even.
  • Font expansion. Characters stretch or compress by tiny amounts (undetectable to the eye) to reduce hyphenation and improve line breaks.
  • Tracking. Letter spacing adjustments for small caps and other contexts.

Important: microtype is one of the highest-value, lowest-effort improvements you can make. Load it in every document. There’s no downside.

Colors

The xcolor package provides color support:

\usepackage{xcolor}

% Named colors
\definecolor{ramanujanblue}{RGB}{25,55,95}
\definecolor{accentgold}{RGB}{180,140,50}

% Using colors
\textcolor{ramanujanblue}{Blue text}
{\color{accentgold} Gold text}
\colorbox{lightgray}{Highlighted text}

% Mixing colors
\textcolor{ramanujanblue!50}{50% blue}
\textcolor{ramanujanblue!50!accentgold}{Blue-gold mix}

Color Models

  • Model: RGB | Example: {25,55,95} (0–255) | Use: Screen colors
  • Model: rgb | Example: {0.1,0.22,0.37} (0–1) | Use: Normalized
  • Model: HTML | Example: {19375F} (hex) | Use: Web colors
  • Model: cmyk | Example: {1,0.42,0,0.63} (0–1) | Use: Print colors

    Warning: Use color sparingly in academic documents. One accent color for links and headings is usually enough. Colored text in the body is distracting. Reserve color for diagrams, code highlighting, and structural elements.

Ligatures and Special Characters

Ligatures are combined character forms that improve appearance:

  • Input: ff | Output: ff | Note: f-f ligature
  • Input: fi | Output: fi | Note: f-i ligature
  • Input: fl | Output: fl | Note: f-l ligature
  • Input: ffi | Output: ffi | Note: f-f-i ligature
  • Input: ffl | Output: ffl | Note: f-f-l ligature
  • Input: --- | Output: — | Note: Em dash
  • Input: -- | Output: — | Note: En dash
  • Input: `` | Output: ” | Note: Open double quote
  • Input: '' | Output: ” | Note: Close double quote
    With xelatex and fontspec, ligatures are enabled by default. You can disable them selectively:
{\addfontfeatures{Ligatures=NoCommon} difficult offline}

Paragraph and Line Spacing

Line Spacing

\usepackage{setspace}

\singlespacing          % Default
\onehalfspacing         % 1.5 spacing (common for theses)
\doublespacing          % Double spacing (some US journals)

% Or locally:
\begin{spacing}{1.3}
  This paragraph has 1.3x line spacing.
\end{spacing}

Paragraph Spacing and Indentation

\setlength{\parindent}{1.5em}   % Indentation (default ~15pt)
\setlength{\parskip}{0pt}       % Space between paragraphs

% No indent + space between paragraphs (European style):
\usepackage{parskip}

Important: Pick either indentation or paragraph spacing, never both. Indentation is traditional for books and papers. Paragraph spacing (with parskip) is common in technical documentation and online-first content.

Hyphenation

LaTeX hyphenates words automatically to improve line breaks. You can guide it:

% Suggest hyphenation points
\hyphenation{mathe-mat-ics type-set-ting}

% Prevent hyphenation of a word
\mbox{unhyphenatable}

% Global: prevent all hyphenation
\usepackage[none]{hyphenat}

% Allow hyphenation after a slash
co-\slash author

Exercises:

  1. Set up a document using Libertinus Serif and Libertinus Math fonts. Compile with xelatex and compare the output to the default Computer Modern.
  2. Create a color scheme with three colors (primary, accent, muted) and use them consistently for headings, links, and highlighted boxes.
  3. Add microtype to an existing document and compare the PDF output with and without it. Look for differences in line breaks, margin alignment, and hyphenation.
  4. Create a document with old-style figures enabled and compare the numbers 0123456789 in both old-style and lining (default) styles.