2

I have a specification that requires text to be vertically centered on a page and an image bottom aligned on the same page. To accomplish this effect, I use the following, using \vspace*{\fill} to get the vertical text alignment, and \vspace{-4cm} to ensure that the text is centered on the page (and not centered in the whitespace above the image).

\documentclass{article}
\usepackage{todonotes}
\begin{document}
\centering
\vspace*{\fill}
Here is some vertically centered text
\vspace*{\fill}
\vspace{-4cm}
\missingfigure[figwidth=6cm,figheight=4cm]{Testing a long text string}
\end{document}

Is there a simple way to accomplish this effect without hard-coding the image height?

This is the desired result

1

If you \smash the image object, then you don't have to worry about it's height:

enter image description here

\documentclass{article}
\usepackage{todonotes}
\begin{document}
\centering
\vspace*{\fill}
Here is some vertically centered text

\vspace*{\fill}
\vspace*{-4cm}
\missingfigure[figwidth=6cm,figheight=4cm]{Testing a long text string}

\newpage

\vspace*{\fill}
Here is some vertically centered text

\vspace*{\fill}
\smash{\missingfigure[figwidth=6cm,figheight=4cm]{Testing a long text string}}
\end{document}
  • This approach also eliminates the horizontal centering of the figure. Is there a method that maintains the horizontal centering? I tried \makebox[0pt][c]{...} but it does not give the desired effect. – canzar May 8 '15 at 20:18
  • @canzar: Use \mbox{..}. – Werner May 8 '15 at 20:20
  • This works beautifully, but I don't understand why LaTeX centers the \mbox{...} but not the 0x0 box resulting from the smash. Do you know why it works this way? – canzar May 8 '15 at 20:33

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.