Margins & page area

This page covers how to set the paper size, the margins, and the area your text is set into (the “text area” or body). The short version: rather than computing lengths yourself, use the **geometry package** — it is far easier and far safer. We focus on geometry, then look at the underlying LaTeX length parameters it sets for you, and at how single- vs double-sided printing changes the margins.

geometry is the standard package for setting paper size and margins together (written by Hideo Umeki; now maintained by the LaTeX Project and David Carlisle). It knows every standard paper size, so you rarely write dimensions yourself — usually one line does it. There are two equivalent ways to give options: as arguments to \usepackage, or via the \geometry{...} command.

latex
% どちらか一方でよい(両方同じ意味)
\usepackage[a4paper, margin=1in]{geometry}

% または
\usepackage{geometry}
\geometry{a4paper, margin=1in}

That alone gives A4 paper with a 1-inch margin on all four sides. \geometry may be called any number of times in the preamble, and a later setting of the same key overrides an earlier one. Option order does not matter ([left=2cm, right=3cm] equals [right=3cm, left=2cm]).

Pick the paper size by name. a4paper, letterpaper, b5paper, and a5paper are provided, along with A0–A6, B0–B6, legalpaper, executivepaper, and more. For a custom size use paperwidth= and paperheight= (or papersize={width,height}). For landscape orientation, add landscape and the width and height swap.

The main geometry keys

geometry has two families of keys — one for specifying margins, one for specifying the size of the text area — and fixing one lets the other be computed from the paper size. Here are the ones you reach for most.

OptionMeaning
margin=All four margins at once; margin={A,B} means left/right = A, top/bottom = B
left= / right= / top= / bottom=Each margin individually (lmargin/rmargin/tmargin/bmargin are aliases)
inner= / outer=Inner/outer margins under two-sided layout; aliases of left/right
hmargin= / vmargin=hmargin={left,right} (side margins), vmargin={top,bottom} (top/bottom margins)
textwidth= / textheight=Set the text-area width/height directly (width/height are related)
total={幅,高さ}Size of the whole body block (incl. header/footer per the include keys)
bindingoffset=Binding offset; adds that length to the inner (or left, for oneside) margin
includehead / includefootCount the header (\headheight+\headsep) / footer (\footskip) as part of the body height
landscapeLandscape orientation; swaps width and height

One caveat: geometry’s top= / bottom= mean the margin from the paper edge to the top/bottom of the body block — they are not the same as LaTeX’s native length \topmargin discussed below. geometry converts to the native lengths correctly for you, so you can think purely in terms of this intuitive “distance from the edge.”

A worked example

A common paper setup — A4, 25 mm side margins, 30 mm top/bottom, a 5 mm binding offset, with the header counted into the margin — can be written as follows. If you do not give the text-area width and height, they are derived automatically from the paper size and margins.

document.tex
\documentclass{article}
\usepackage{geometry}
\geometry{
  a4paper,
  hmargin=25mm,      % 左右の余白
  vmargin=30mm,      % 上下の余白
  bindingoffset=5mm, % 綴じ代(内側に追加)
  includehead,       % ヘッダを版面の高さに含める
}
\begin{document}
本文がこの版面に組まれます。
\end{document}

To fix the text-area size instead, give textwidth= or total= rather than margins. For example \geometry{a4paper, textwidth=15cm, textheight=24cm} places a text area of that size centered on the page, with side and top/bottom margins balanced automatically (horizontal auto-centering is the default for oneside).

The underlying LaTeX length parameters

geometry is convenient precisely because it sets — consistently, on your behalf — the page-layout length parameters that LaTeX actually carries internally. The main ones are:

ParameterMeaning
\textwidthWidth of the body (text area)
\textheightHeight of the body (text area)
\oddsidemarginLeft-margin offset on odd pages (all pages in oneside), measured from the origin
\evensidemarginLeft-margin offset on even pages, under two-sided layout
\topmarginDistance from the origin (1 inch from the top) to the top of the header
\headheightHeight of the box holding the running head
\headsepGap between the header and the top of the body
\footskipBaseline-to-baseline distance from the last text line to the footer
\marginparwidthWidth of marginal notes
\paperwidth / \paperheightThe physical paper dimensions

The subtlety here is that \oddsidemargin and \topmargin are measured as an offset from a point one inch inside the top-left corner of the paper (the origin). So the real left margin is “1 inch + \oddsidemargin.” That one-inch offset is a historical TeX convention, and setting these by hand with \setlength means hand-computing how the text-area width and height relate to the margins — it is easy to change \textwidth and find the margins no longer add up.

latex
% 手で合わせる古典的なやり方(誤りやすい)
\setlength{\oddsidemargin}{0pt}   % 実際の左余白 = 1in + 0pt
\setlength{\textwidth}{16cm}
\setlength{\topmargin}{0pt}
\setlength{\textheight}{24cm}
% → 右余白・下余白は自分で辻褄を合わせる必要がある

For these reasons, letting geometry handle margins is strongly recommended. When you want to see the current values, the layout package’s \layout command outputs a diagram page that visualizes all of these parameters.

latex
\usepackage{layout}
% ...本文中で
\layout   % 現在のページレイアウトを図で出力

Single- vs double-sided (oneside / twoside)

How the side margins behave depends on whether the document is **single-sided (oneside) or double-sided (twoside)**. article defaults to oneside; book defaults to twoside. In oneside, every page has the same side margins (only \oddsidemargin is used). In twoside, so that the inner (binding-side) margins line up across a spread, the left and right margins are swapped between odd and even pages — odd pages use \oddsidemargin, even pages use \evensidemargin.

In two-sided layouts you usually make the inner (binding-side) margin wider than the outer one. With geometry, enable twoside and set the margins with inner= / outer=, and optionally add bindingoffset= to the inner side. You can pass twoside as a class option or directly to geometry.

document.tex
\documentclass[twoside]{book}
\usepackage{geometry}
\geometry{
  a4paper,
  inner=30mm,        % 綴じ側(内側)は広めに
  outer=20mm,        % 小口(外側)は狭めに
  bindingoffset=5mm, % 綴じ代をさらに内側へ追加
}
\begin{document}
% 奇数ページと偶数ページで内外の余白が入れ替わる
\end{document}

If you want a two-sided layout whose margins are *not* swapped on alternate pages (with marginal notes always on the same side), use geometry’s asymmetric option.

Changing the layout mid-document

To change the margins for only some pages — a wide page for a landscape table, a different layout for an appendix — call **\newgeometry{...} in the body to switch to a new layout, and \restoregeometry** where you want the preamble layout back. \newgeometry resets all previously given geometry options except the paper-size ones, then applies only what you pass it. Both commands insert a \clearpage, so the switch never happens mid-page.

latex
% プリアンブルの余白で組まれている途中で…
\newgeometry{margin=1cm}   % ここから余白を狭く(改ページが入る)

% 広い版面が必要なページ(大きな図表など)

\restoregeometry           % 元のレイアウトに戻す(再び改ページ)

To drop in a single landscape page, combine \newgeometry{landscape, ...}, or use the purpose-built lscape / pdflscape packages’ landscape environment. When you want to style headings or the header/footer rather than change the page geometry, the titlesec and fancyhdr packages (covered on their own pages) are the right tools.