Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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)

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

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.

share|improve this answer
    
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? –  Matthias Sep 16 '11 at 7:09
1  
@Matthias: Then it is even simpler: write the one line as \includegraphics[width=\linewidth]{VUB_logo.pdf}}% –  Martin Scharrer Sep 16 '11 at 7:20
1  
\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). –  egreg Sep 16 '11 at 9:26
    
@Martin: thanks, your solution works fine. –  Matthias Sep 24 '11 at 11:01
    
@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! –  Matthias Sep 24 '11 at 11:02
add comment

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}
share|improve this answer
    
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. –  Matthias Sep 24 '11 at 11:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.