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

basic-lengths.tex
Ready to use this syntax? Continue in the browser editor when you want to adapt the example in a real project.Open LaTeX Cloud Studio

Measuring Existing Elements

measuring.tex

Practical Applications

Page Layout Dimensions

page-dimensions.tex

Font-Relative Spacing

font-relative.tex

Advanced Length Operations

Length Arithmetic

length-arithmetic.tex

Conditional Lengths

conditional-lengths.tex

Spacing Commands

Horizontal Spacing

horizontal-spacing.tex

Vertical Spacing

vertical-spacing.tex

Length Variables and Customization

Document-Wide Settings

document-settings.tex

Creating Length Commands

length-commands.tex

Math Mode Spacing

Math Units

math-spacing.tex

Units in Different Contexts

Tables and Figures

table-figure-units.tex

Custom Environments

custom-environments.tex

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

best-practices.tex

Debugging Length Issues

Measuring and Displaying

debugging-lengths.tex

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.