[Tex/LaTex] Vertical centering of figure in landscape environment

floatslandscapevertical alignment

I am using the pdflscape package to insert landscape pages in my document. On one of these I would like to have a figure that is vertically centered on the page, but I can't find how to do it.

MWE:

\documentclass{article}

\usepackage{graphicx}
\usepackage{pdflscape}

\begin{document}
A portrait mode page...

\begin{landscape}
\begin{figure}[!h]
\centering
\fbox{\includegraphics[width=\linewidth]{VUB_logo.pdf}}
\caption{Some caption}
\end{figure}
\end{landscape}

Another portrait mode page...
\end{document}

This results in something like this (only landscape page shown):
Landscape page with figure not vertically centered

While what I would like is this:
Landscape page with figure vertically centered
(note the vertical centering)

Best Answer

I would do it using a \parbox which has the maximum height (i.e. \textwidth because of the rotation) and contains some \vfill macros before and after the content to push it into the middle. Note that in such cases you shouldn't use the figure floating environment but add the captions using \captionof{figure} (capt-of or caption package). The float only interferes here. Because the content has already the maximum width you don't need to center it horizontally. This can however be done using the [c] option of the \parbox.

\documentclass{article}

\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{capt-of}

\begin{document}
A portrait mode page...

\begin{landscape}
\parbox[c][\textwidth][s]{\linewidth}{%
\vfill
\fbox{\includegraphics[width=\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax]{VUB_logo.pdf}}
\captionof{figure}{Some caption}
\vfill
}
\end{landscape}

Another portrait mode page...
\end{document}

I also compensated for the \fbox dimension to not generate an overfull box.