How to Add Vertical Space Before a TikZ Picture
At a glance
- 1. End the paragraph
Use \par before the spacing command so LaTeX inserts the space between paragraphs.
- 2. Add the space
Place \vspace{8mm} before the TikZ picture, adjusting the length to suit your layout.
- 3. Handle page tops
Use \vspace* instead if the space must remain when the picture starts a page.
Use \vspace{...} to add vertical space before a tikzpicture. If text comes immediately before the picture, end its paragraph first with \par (or a blank line). This puts the spacing in the vertical list between paragraphs, where it works predictably.
Add space before a TikZ picture
Put the spacing command directly before the picture. Change 8mm to the amount you need:
\par
\vspace{8mm}
\noindent
\begin{tikzpicture}
\draw (0,0) -- (2,0);
\end{tikzpicture}
If the picture should start at the left margin, this is enough. A TikZ picture is placed like a box in the text; it does not automatically create the same paragraph spacing as a displayed equation.
Here is a complete minimal example:
\documentclass{article}
\usepackage{tikz}
\begin{document}
Text above the picture.
\vspace{8mm}
\noindent
\begin{tikzpicture}
\draw[thick] (0,0) -- (3,0);
\draw[thick] (1.5,0) circle (0.5);
\end{tikzpicture}
\par
Text below the picture.
\end{document}
The blank line after the first sentence ends that paragraph. The \vspace{8mm} command inserts the requested gap before the next paragraph, and \noindent prevents that paragraph from being indented. The \par after the picture ends the paragraph containing it, so the following text starts as a new paragraph.
When to use \vspace*
Ordinary \vspace{...} can be discarded at a page break. If the picture happens to land at the top of a page, LaTeX may remove the space above it. Use the starred command when that gap must remain:
\par
\vspace*{8mm}
\begin{tikzpicture}
\draw (0,0) -- (2,0);
\end{tikzpicture}
The star does not force the picture to a new page; it only preserves the vertical space if a page break occurs there.
Centering the picture
If you want the picture centered, \centering is often preferable to the center environment when you want to control spacing yourself. Group it so the declaration affects only the picture:
\par
\vspace{8mm}
{\centering
\begin{tikzpicture}
\draw (0,0) -- (3,0);
\end{tikzpicture}
\par}
The center environment is also valid, but it adds its own vertical space above and below its contents. If the gap looks larger than expected, that built-in spacing may be contributing.
Common mistakes
- Putting
\vspacein the middle of a paragraph: End the paragraph with\parfirst. Otherwise, the command may attach space to a line rather than create the clear paragraph-to-picture gap you intended. - Using
\vspace*for every case: The starred version is only needed when space must survive a page break. Use ordinary\vspacefor normal spacing between paragraphs. - Adding space inside the TikZ picture: A spacing command before
\begin{tikzpicture}changes the gap before the whole picture. A command inside the environment affects content within the picture or its bounding box, not the surrounding paragraph layout. - Overlooking other layout spacing: A
centerenvironment, a list, or a figure environment can add or control spacing independently. Adjust the surrounding environment if that is where the extra gap comes from.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.