Horizontal and vertical space in LaTeX (hspace, vspace, hfill)

\hspace{1cm} adds horizontal space inside a line and \vspace{1cm} adds vertical space between paragraphs. \hfill and \vfill add space that stretches as far as it can.

Horizontal space

The argument of \hspace is a length with a unit: pt, mm, cm, in, or em and ex, which depend on the font size. A negative length moves the text back. LaTeX drops \hspace at a line break; \hspace* is kept there.

Left\hspace{2cm}right, and a gap of\hspace{1em}one em.
Result
The compiled example

Open in the editor

Vertical space

Put \vspace{...} between two paragraphs, with an empty line before it. \smallskip, \medskip and \bigskip are fixed steps of 3 pt, 6 pt and 12 pt. LaTeX drops \vspace at the top of a page; \vspace* is kept there.

First paragraph.

\vspace{1cm}

Second paragraph, one centimetre lower.

\bigskip

Third paragraph after a big skip.
Result
The compiled example

Open in the editor

Space that fills the line or the page

\hfill takes all free space in a line and pushes the text after it to the right. Two of them share the space equally. \vfill does the same vertically and pushes what follows to the bottom of the page.

\noindent Left \hfill Centre \hfill Right

\vfill

\noindent This line stands at the bottom of the page.
Result
The compiled example

Open in the editor

Fixed spaces between words

\, is a sixth of an em wide, \enspace half an em, \quad one em and \qquad two em. An em is roughly the font size.

a\,b, a\enspace b, a\quad b, a\qquad b
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages