I recently learned that I can center a text vertically in the remaining space on a page by using \vfill
before and after the text, like so
\documentclass{article}
\usepackage{lipsum}
\def\ctext#1{\begin{center}\MakeUppercase{#1}\end{center}}
\begin{document}
\lipsum[1]
\vfill
\ctext{center}
\vfill
\end{document}
This divides the empty space by 50% before and 50% after the text. Is there a way to generalize this to be able to place text relatively throughout the page? In other words, a command, let's say \vpfill
, that creates a vertical space which is a percentage of the space that would be left at the end of the page.
% First page is exactly as before but using \vpfill intsead of \vfill
\lipsum[1]
\vpfill{0.5}
\ctext{center 1}
% \vpfill{0.5} % Unnecessary (?) since 50% of the space remains anyways
\newpage % Second page
\lipsum[1]
\vpfill{0.4} % Creates space that is 40% of the remaining empty space
\ctext{center 1}
\vpfill{0.2} % Creates space that is 20% of the remaining empty space
\ctext{center 2}
% \vpfill{0.4} % Unnecessary (?) since 40% of the space remains anyways