0

I'm trying to vertically fill the whole height of a page with 3 evenly spaced boxes. This is what I have now

enter image description here

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[many]{tcolorbox}
\usepackage{calc}
\usepackage{lipsum}
\newlength{\boxheight}
\setlength{\boxheight}{136.80573pt}
\newlength{\vertspace}
\setlength{\vertspace}{(\textheight - 3\boxheight)/2 - 7pt}
% ----------------
\begin{document}
\begin{tcolorbox}[sharp corners, draft]
\lipsum[1]
\end{tcolorbox}
\vspace{\vertspace}

\begin{tcolorbox}[sharp corners]
\lipsum[1]
\end{tcolorbox}
\vspace{\vertspace}

\begin{tcolorbox}[sharp corners]
\lipsum[1]
\end{tcolorbox}
\end{document}

the -7pt in the definition of \vertspace is the vertical space between two boxes given by a new paragraph. As you can see there's still a little bit of space left at the bottom, but I'm not sure why. Even if I use \vfill, the space at the bottom remains.

How should I calculate \vertspace? Is there a better way to go about it?

  • 1
    What about using \vfill? – Phelype Oleinik Jun 19 at 20:30
  • Just tried it and the space at the bottom remains. – noibe Jun 19 at 20:39
  • Oh, sorry for the noise... Ignore me then :-) – Phelype Oleinik Jun 19 at 20:42
1

enter image description here

You can use fill space there is no need to calculate the space between boxes. Also it is almost always best to leave a blank line before \vspace.

The small gap at the bottom is de to the fact that the frame drawn is leaving for the usual case of text on the last line so there is for descenders such as y and g . If you want the bottom of the last box to fill that space rather than sit on the last baseline on the page then you can add a negative space the depth of `\strutbox.

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage[many]{tcolorbox}
\usepackage{calc}
\usepackage{lipsum}
\newlength{\boxheight}


% ----------------
\begin{document}
\begin{tcolorbox}[sharp corners, draft]
\lipsum[1]
\end{tcolorbox}

\vspace{\fill}

\begin{tcolorbox}[sharp corners]
\lipsum[1]
\end{tcolorbox}

\vspace{\fill}

\begin{tcolorbox}[sharp corners]
\lipsum[1]
\end{tcolorbox}

\vspace{-\dp\strutbox}

\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.