0

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:

enter image description here

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?

5
  • Try inserting a phantom vertical rule.
    – Bernard
    Jan 12, 2021 at 14:23
  • @Bernard I have no idea what it is and how to do it.
    – Viesturs
    Jan 12, 2021 at 14:24
  • 2
    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?
    – Viesturs
    Jan 12, 2021 at 14:31
  • just replace the vspace by \rule{1pt}{5cm} Jan 12, 2021 at 14:34

1 Answer 1

4

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.