Lengths & spacing

To tell LaTeX “leave 2cm here” or “add a line’s worth of space,” you write a length. This page starts with the units of length and their exact conversions, then covers stretchable rubber lengths, the commands that actually emit space — \hspace, \vspace, and friends — and finally how to define and reuse lengths like variables.

Units of length

A length is written as a number plus a unit (12pt, 2.5cm, -3mm — decimals and negative values are allowed). Units fall into two families. Absolute units are fixed regardless of the font (pt, mm, in, …), while font-relative units scale with the current font size (em, ex). The latter are handy when you want spacing to grow naturally as the font grows.

The pivot is **pt (the TeX point). TeX defines 1 inch = 72.27pt, and every conversion hangs off that. The confusing one is bp (the big point), the PostScript/PDF point where 1 inch = 72bp**. pt and bp differ by about 0.4%, so watch the mix-up when exchanging graphics with bp-based tools.

UnitWhat it is / conversionNotes
ptTeX point. 1in = 72.27ptThe reference for all lengths
bpBig point. 1in = 72bpThe PostScript/PDF point
mmMillimeter. 1mm ≈ 2.845ptMetric
cmCentimeter. 1cm = 10mmMetric
inInch. 1in = 72.27ptImperial
pcPica. 1pc = 12ptTraditional typographic unit
spScaled point. 1pt = 65536spTeX's smallest unit (internal)
em≈ current font size / width of MFont-relative; for horizontal space
exx-height of the current fontFont-relative; for vertical space
ddDidot point. 1dd ≈ 1.07ptEuropean tradition; cc = 12dd

sp (the scaled point) is TeX’s smallest internal unit for representing lengths: 1pt = 65536sp. You essentially never type it, but it marks the finest precision TeX can work in. The European letterpress units **dd (Didot point) and cc** (cicero, cc = 12dd) are also available, but rarely appear in modern documents.

The font-relative **em roughly equals the current font size (traditionally the width of a capital M) and suits indentation and horizontal gaps; ex** is the x-height of lowercase x and is used for vertical fine-tuning. In a 10pt font, 1em ≈ 10pt. Math mode adds a dedicated unit, **mu** (the math unit), equal to 1/18 of an em — the spaces like \quad are defined in it.

Rubber lengths (elastic space)

A fixed length like 12pt is a rigid length. A length that can stretch and shrink as needed is a rubber length. You give it room to grow with plus and room to shrink with minus. For example 1cm plus 2mm minus 1mm means “normally 1cm, stretch up to 1.2cm, shrink down to 0.9cm.” LaTeX uses this slack to even out lines and pages naturally.

latex
% 通常 1cm、最大 1.2cm まで伸び、最小 0.9cm まで縮む縦アキ
\vspace{1cm plus 2mm minus 1mm}

The special rubber length with infinite stretch is **\fill**. Its natural length is 0, but it grows as much as needed — perfect for “push everything else apart to fill the rest.” Several \fills on the same line or column split the space equally. For weighted ratios use **\stretch{n}** (which is n times \fill): \hspace{\stretch{2}}…\hspace{\stretch{1}} divides the gap 2:1.

Horizontal space

The basic command for horizontal space within a line is **\hspace{length}**: \hspace{2cm} inserts a 2cm gap. But an \hspace that lands at the start or end of a line is discarded when LaTeX breaks the paragraph (so no stray space clings to the margin). To keep the space even at a line edge, use the starred **\hspace*{length}**.

\hfill** is shorthand for \hspace{\fill}; it pushes whatever is on either side as far apart as possible — the standard way to place one word flush left and another flush right. (It is also discarded at a line edge, so use \hspace*{\fill} if you must keep it.) Instead of blank space you can fill the gap with a rule via **\hrulefill or with dots via \dotfill** — common between a heading and its page number.

latex
Name:\hspace{2cm}Date:\par
\noindent 第1章 はじめに\dotfill 1\par
\noindent\hfill

For small, fixed gaps the font-relative commands are convenient. **\quad** is 1em (= 18mu) and **\qquad** is twice that, 2em. For a very thin sliver use **\,** (a thin space, 3mu). Because they track the font, the visual balance holds when the type size changes.

Vertical space

For vertical space — between paragraphs, say — use **\vspace{length}**. As with \hspace, space that lands at a page boundary is discarded (so no stray gap opens at the top of a page). To keep it even across a page break, use **\vspace*{length}**. \vfill is \vspace{\fill}, pushing the rest of the column apart vertically — handy for centering a one-line page.

For everyday vertical gaps there are three ready-made commands: **\smallskip, \medskip, \bigskip, whose defaults in the standard classes are 3pt plus 1pt minus 1pt, 6pt plus 2pt minus 2pt, and 12pt plus 4pt minus 4pt** respectively. All are rubber lengths, so they flex slightly to fit the page. Reaching for these instead of hard-coded values keeps the whole document consistent.

Defining & using lengths

If you reuse the same length throughout a document, making a length register — like a variable — eases maintenance. **\newlength{\mylen}** declares a new length \mylen, **\setlength{\mylen}{2em} assigns its value, and \addtolength{\mylen}{1pt}** adjusts it. Change the value in one place and every reference updates.

You can also compute with existing lengths such as \textwidth (the body width), \linewidth (the current line width), and \baselineskip (the leading). Just prefix a factor to scale them — 0.8\textwidth is 80% of the body width. For richer arithmetic, load the **calc package**, which lets you write expressions with + - * /.

document.tex
\usepackage{calc}
% ...
\newlength{\halfcol}
\setlength{\halfcol}{(\textwidth - 2em) / 2}
\noindent\hspace*{0.8\textwidth}右寄せの見出し

Building lengths relative to existing widths this way keeps proportions intact even when you change the paper size or margins. An expression based on \textwidth makes for a far more change-resilient document than a hard-coded value like 8cm.