# Vertical centering of figure in landscape environment

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):

While what I would like is this: (note the vertical centering)

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.

• Thanks Martin, I will try this out now. One remark though, what I forgot the mention was that I only included the fbox in my example to more clearly mark the extent of the figure. So what would your solution look like without the fbox? Sep 16 '11 at 7:09
• @Matthias: Then it is even simpler: write the one line as \includegraphics[width=\linewidth]{VUB_logo.pdf}}% Sep 16 '11 at 7:20
• \centering\vspace*{\fill} immediately after \begin{landscape} and \vfill before \end{landscape} will not require the \parbox (and even the \noindent you forgot to add before the \parbox). Sep 16 '11 at 9:26
• @egrep: Yours works too but the result is slightly different: the vertical centering is based on the figure alone, not on the figure + its caption (may because both are not wrapped together in a float environment?). But the result looks nice anyway. So thanks! Sep 24 '11 at 11:02
• @Matthias you can try to add the space of caption using Mar 17 '16 at 11:04

Have you tried resetting the length parameters \@fptop and \@fpbot to their default value of 0pt plus 1fil? These parameters govern the amount of "fil" above and below a float on a float-only page. It may be that one of the packages you use has reset the @fptop parameter to something like 0pt. :-( You'd put the following commands in your document's preamble:

\makeatletter
\setlength{\@fptop}{0pt plus 1fil}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother


By the way, you may also want to look into using the rotating package and its commands \begin{sidewaysfigure} ... \end{sidewaysfigure}. Not only would you have a couple fewer commands to type each time you need to create a landscape-oriented float :-), you'd also get to benefit from the rotating package's habit of vertically centering the contents of the float on the page. The following MWE demonstrates its use. Happy TeXing!

\documentclass{article}
\usepackage{rotating}
\begin{document}
\begin{sidewaysfigure}
\centering
\includegraphics[width=\linewidth]{VUB_logo.pdf}
\caption{A sideways figure}
\end{sidewaysfigure}
\end{document}

• thanks for your input. I'm afraid your first solution does not work for me (the figure is not vertically centered), I tried it with and with out a figure environment. You second solution works but the pdf page is not put in landscape mode, with pdflscape's landscape environment it is. So I'm sticking with the solution provided above. Sep 24 '11 at 11:18
• I am using a preamble diployed by my university and they set \setlength{\@fptop}{0pt}. I don't know why this is needed? It screwed totally my sidewaysfigure environment positioning of my figure. Could you explain, why this @fptop is probably changed? Apr 23 '14 at 15:49
• I could not find this answer with the keywords positioning and sidewaysfigure nor in other combination. Only after I identified my problem I was able to find it in combination with the \setlength{\@fptop}{0pt} string. Maybe we should answer this problem as a separately question! Apr 23 '14 at 15:57