Note: the red lines have the same length.
\documentclass{minimal}
\usepackage[showframe,paperwidth=4cm,paperheight=4cm,margin=1cm]{geometry}
\begin{document}
%
\vspace*{\fill}%
\fbox{test}%
\vspace*{\fill}%
%
\end{document}
Note: the red lines have the same length.
\documentclass{minimal}
\usepackage[showframe,paperwidth=4cm,paperheight=4cm,margin=1cm]{geometry}
\begin{document}
%
\vspace*{\fill}%
\fbox{test}%
\vspace*{\fill}%
%
\end{document}
I think the difference you observed came from the \topskip
that is automatically inserted. You can see the effect by commenting and uncommenting the \topskip0pt
macro below.
\documentclass{minimal}
\usepackage[showframe,paperwidth=4cm,paperheight=8cm,margin=1cm]{geometry}
\usepackage{lipsum}
\newcommand{\vstretch}[1]{\vspace*{\stretch{#1}}}
\begin{document}
\topskip0pt
\vstretch{1}
\noindent\fbox{test}%
\vstretch{1}
\end{document}
I got the solution.
\documentclass{minimal}
\usepackage[showframe,paperwidth=4cm,paperheight=4cm,margin=1cm]{geometry}
\begin{document}%
\noindent%
\begin{minipage}[c][\textheight][c]{\textwidth}%
\centering\fbox{test}%
\end{minipage}%
\end{document}