19

Note: the red lines have the same length.

alt text

\documentclass{minimal}
\usepackage[showframe,paperwidth=4cm,paperheight=4cm,margin=1cm]{geometry}
\begin{document}
%
\vspace*{\fill}%
\fbox{test}%
\vspace*{\fill}%
%
\end{document}
16

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}
  • And thanks you for pointing out \topskip0pt as the source of problem. – xport Dec 17 '10 at 15:27
  • I am trying to use this topskip0pt trick in a situation where I am including chapters, but unfortunately, doing so seems to insert a blank page afterward that I do not want. How can I avoid that happening? – jdc Feb 21 '15 at 21:09
  • @jdc Better to ask a different question with a minimal. You probably adding some space and the page overflows forcing TeX to issue a new page. – Yiannis Lazarides Feb 22 '15 at 5:16
10

I got the solution.

alt text

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

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.