Vertical Spacing in LaTeX – How to Add Vertical Space Inside a \framebox

add-vertical-spaceboxvertical-spacingvspace

Consider the MWE below. I would like to add some vertical space above the blue square, inside the framebox (indicated by red arrow).

Why is \vspace ignored? Which command should I use?

MWE:

\documentclass[twocolumn,a5paper]{article}

\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{tikz}

\begin{document}

\begin{figure}[t]
\centerline{\framebox{
\begin{tikzpicture}
\filldraw[blue] (0,0) |- (1,2) |- cycle;
\end{tikzpicture}
}}
\caption{Rectangle}
\end{figure}

\lipsum[1]

\begin{figure}[t]
\centerline{\framebox{
\vspace{2cm} %Why ignored?
\begin{tikzpicture}
\filldraw[blue] (0,0) |- (1,1) |- cycle;
\end{tikzpicture}
}}
\caption{Square}
\end{figure}

\lipsum[2]

\end{document}

enter image description here

Best Answer

I'm not sure why \vspace is ignored; \vspace*, which preserves space at the top of a page is ignored as well.

But inserting the equivalent of a strut at the top of the box will leave the white space you are looking for:

\begin{figure}
\centering
\framebox{
%\vspace{2cm} %Why ignored?                                                     
\vrule height 2cm width 0pt
\begin{tikzpicture}
\filldraw[blue] (0,0) |- (1,1) |- cycle;
\end{tikzpicture}
}
\caption{Square}                                                                        
\end{figure}

output of code example

Related Question