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.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.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.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 bPitfalls
- A number without a unit, as in
\hspace{1}, stops with Illegal unit of measure (pt inserted). Zero needs a unit too:0pt. \vspacein the middle of a paragraph takes effect after the current line, not at the place where it stands.- Several spaces or several empty lines in the source add nothing: LaTeX treats them as one space and one paragraph break. Do not build space with
\\ \\either; see Line break and new paragraph in LaTeX.
Compiled with pdfLaTeX from TeX Live 2023.