# Vertical space in standalone document

Consider this example:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\vspace{0.5cm}%
\begin{tikzpicture}
\draw (0, 0) rectangle (4, 4);
\end{tikzpicture}

\end{document}


The output is:

I wanted to insert some vertical space above the rectangle using the \vspace command. However, it doesn't work.

How to insert a vertical space in a standalone document?

• Try inserting a phantom vertical rule. Jan 12, 2021 at 14:23
• @Bernard I have no idea what it is and how to do it. Jan 12, 2021 at 14:24
• a standalone document is essentially an \mbox @Bernard means use \rule{0pt}{5cm} or some such to make white space (use \rule{1pt}{5cm} to debug what it is doing and see the rule. Jan 12, 2021 at 14:26
• @DavidCarlisle, could you please provide an example? Jan 12, 2021 at 14:31
• just replace the vspace by \rule{1pt}{5cm} Jan 12, 2021 at 14:34

According to the documentation of standalone , the class provides the option:

border={〈length (left)〉 〈length (bottom)〉 〈length (right)〉 〈length (top)〉}

\documentclass[
border={0pt 0pt 0pt 1cm}
]{standalone}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}
\draw (0, 0) rectangle (4, 4);
\end{tikzpicture}

\end{document}