Skip to main content
Understanding LaTeX lengths and units is essential for precise document formatting. This guide covers all measurement units, how to use them effectively, and practical examples for common formatting tasks.
Key concept: LaTeX uses different units for different purposes. Understanding when to use each unit type will help you create professional, consistent documents.Related topics: Single vs double-sided documents | Spacing | Headers & footers

LaTeX Units Overview

Absolute Units

Fixed measurements that don’t change based on font or context.

Relative Units

Units that scale with font size or document context.

Basic Length Usage

Setting Lengths

Measuring Existing Elements

Practical Applications

Page Layout Dimensions

Font-Relative Spacing

Advanced Length Operations

Length Arithmetic

Conditional Lengths

Spacing Commands

Horizontal Spacing

Vertical Spacing

Length Variables and Customization

Document-Wide Settings

Creating Length Commands

Math Mode Spacing

Math Units

Units in Different Contexts

Tables and Figures

Custom Environments

Best Practices

Unit selection guidelines:
  1. Use em for font-dependent spacing - Scales automatically with font changes
  2. Use ex for vertical spacing - Based on lowercase letter height
  3. Use pt for precise control - When exact measurements are needed
  4. Use cm/mm for page layout - Intuitive for physical dimensions
  5. Use relative units when possible - Better for responsive designs
  6. Avoid mixing unit systems - Stick to metric OR imperial consistently

Common Patterns

Debugging Length Issues

Measuring and Displaying

FAQ

Use relative units (em, ex) when spacing should scale with the font (e.g., paragraph spacing, indents). Use absolute units (pt, cm) for fixed physical dimensions (e.g., margins, figure sizes).
em and ex scale with the current font, so changes to font size affect spacing. For fixed spacing independent of font, use absolute units like pt or cm.
Use \the\length to print a value (e.g., \the\textwidth) and packages like layouts to visualize page geometry. See the Debugging section for examples.
Use the geometry package and specify margins in cm/mm for clarity. For responsive layouts, consider percentages of \paperwidth/\paperheight.

Quick Reference

Essential Length Commands

Common Length Variables


Next: Learn about Headers and footers to customize page headers and footers, or explore Page numbering for advanced numbering schemes.