A well-designed page is invisible. The reader doesn’t notice margins, headers, or spacing; they just find the text easy to read. This chapter covers the tools that make that happen.
The geometry Package
geometry is the standard way to set page dimensions:
% Simple: uniform margins
\usepackage[margin=1in]{geometry}
% Different margins
\usepackage[
top=1in,
bottom=1in,
left=1.25in,
right=1in
]{geometry}
% A5 with tight margins (for print)
\usepackage[
a5paper,
top=20mm,
bottom=20mm,
inner=15mm,
outer=15mm
]{geometry}
% Specify text area dimensions
\usepackage[
textwidth=5.5in,
textheight=8.5in,
centering
]{geometry}
Twoside Layouts
For two-sided printing (the default for book), use inner/outer instead of left/right:
\usepackage[
twoside,
inner=1.25in, % Binding side (larger)
outer=1in % Outer edge
]{geometry}
The inner margin is where the binding goes. Make it slightly larger so text isn’t swallowed by the spine.
Tip: This book uses two layouts. The US Letter version:
[margin=1in]. The A5 print version:[top=20mm, bottom=20mm, left=15mm, right=15mm]. Both share the same content through a common preamble file.
Headers and Footers with fancyhdr
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % Clear all
\fancyhead[LE]{\small\textit{Book Title}} % Left on even pages
\fancyhead[RO]{\small\textit{\leftmark}} % Right on odd pages
\fancyfoot[C]{\thepage} % Centered page number
\renewcommand{\headrulewidth}{0.4pt} % Header line
\renewcommand{\footrulewidth}{0pt} % No footer line
The position codes:
L= Left,C= Center,R= RightE= Even pages,O= Odd pagesLE= Left on even pages,RO= Right on odd pages
Automatic marks:
\leftmark— current chapter name\rightmark— current section name
Plain Pages
Chapter opening pages use the plain style by default. To customize them:
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
}
Title Formatting with titlesec
\usepackage{titlesec}
% Chapter: "Chapter N" above, title below
\titleformat{\chapter}[display]
{\huge\bfseries\color{ramanujanblue}}
{\chaptertitlename\ \thechapter}
{20pt}
{\Huge}
% Section: number and title inline
\titleformat{\section}
{\Large\bfseries\color{ramanujanblue}}
{\thesection}
{1em}
{}
% Spacing: {left}{before}{after}
\titlespacing{\chapter}{0pt}{50pt}{40pt}
\titlespacing{\section}{0pt}{3.5ex plus 1ex minus 0.2ex}
{2.3ex plus 0.2ex}
Table of Contents
\tableofcontents
\listoffigures % Optional
\listoftables % Optional
Customizing TOC Depth
% Show down to subsections in TOC
\setcounter{tocdepth}{2}
% Number down to subsubsections
\setcounter{secnumdepth}{3}
For more advanced TOC styling, the tocloft package provides full control over fonts, spacing, and leader dots.
Multi-Column Layouts
Class Option
\documentclass[twocolumn]{article}
This sets the entire document in two columns.
Local Multi-Column
For multi-column sections within a single-column document, use multicol:
\usepackage{multicol}
\begin{multicols}{3}
Content flows across three columns here.
Column breaks happen automatically.
\end{multicols}
Title Pages
The Default Title
\title{My Document}
\author{Name \and Co-Author}
\date{\today}
\maketitle
Custom Title Pages
For full control, use the titlepage environment:
\begin{titlepage}
\centering
\vspace*{2cm}
{\Huge\bfseries\color{ramanujanblue} Book Title}
\vspace{1cm}
{\Large Subtitle}
\vspace{2cm}
{\large\textbf{Author Name}}
\vfill
{\small Institution \\ \today}
\end{titlepage}
\vspace* works at the top of a page (unlike \vspace, which is ignored). \vfill pushes content to the bottom.
Footnotes and Margin Notes
This has a footnote\footnote{The footnote text appears
at the bottom of the page.}.
\marginpar{This appears in the margin.}
Spacing Commands
- Command:
\vspace{...}| Effect: Vertical space (flexible) - Command:
\vspace*{...}| Effect: Vertical space (even at page top) - Command:
\hspace{...}| Effect: Horizontal space - Command:
\vfill| Effect: Fills remaining vertical space - Command:
\hfill| Effect: Fills remaining horizontal space - Command:
\newpage| Effect: Start new page - Command:
\clearpage| Effect: Start new page, flush all floats - Command:
\cleardoublepage| Effect: Start new right-hand page (book class) - Command:
\phantom{...}| Effect: Invisible space matching text dimensionsThis Book as a Case Study
This book demonstrates the layout techniques from this chapter:
- Class:
bookwith[11pt,letterpaper,twoside,openright] - Margins:
[margin=1in]viageometry - Fonts: STIX Two Text/Math via
fontspec/unicode-math - Headers: Book title (even left) and chapter name (odd right) via
fancyhdr - Colors:
ramanujanbluefor headings and links,accentgoldfor tips - Title formatting: Custom chapter/section styles via
titlesec - Boxes: Seven custom
tcolorboxenvironments for code, output, tips, warnings, exercises, keyboard shortcuts, and comparisons - Two variants: The same content compiles to both US Letter (11pt, 1in margins) and A5 (10pt, 15–20mm margins) through separate main files sharing a common preamble
Exercises:
- Create a document with custom margins (1.5in left for binding, 1in right, 0.75in top/bottom). Add headers with your document title on even pages and section name on odd pages.
- Design a title page for a fictional thesis using the
titlepageenvironment. Include: university name, degree, title, author, advisor, date, and a university logo placeholder.- Create two versions of the same document: one optimized for screen reading (wide margins, large text) and one for print (narrow margins, smaller text). Use separate main files with a shared preamble.
- Set up a multi-column index or glossary using the
multicolpackage with three columns.