In my large latex document, I have some figures which take a considerable height of the page (80-95%). Latex puts each of these figures alone on a page, aligned on top. I would like to have each figure aligned vertically to center. Is that possible, and if so, how? :)
-
As the answers tell, centering is the usual behavior; however it's the whole block (figure and caption) that's vertically centered. – egreg Sep 10 '11 at 21:25
I'm curious which documentclass you're using, as "normal" behavior (as defined in the LaTeX kernel file latex.ltx
) is to center the float vertically on a floats-only page.
If you need to get the float to be centered on a floats-only page, you should add the following instructions to your preamble.
\makeatletter
\setlength{\@fptop}{0pt plus 1fil}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother
To have the figure/table be aligned at the top, you would delete the plus 1fil
after 0pt
in the instruction setting the length of the \@fptop
variable.
By default, LaTeX will place a large float on a page by itself if the float's height exceeds 50% of the parameter \textheight
. To change this threshold to, say, 0.75
, you should issue the command \renewcommand\floatpagefraction{0.75}
. Happy TeXing!
-
This does not answer the OP's question, in my opinion, he/she is only interested in a vertical centered solution (not top-aligned) and there was no mention of horizontal centering. – Werner Sep 10 '11 at 21:06
-
@Werner -- Yes, I initially misread the question, and have revised it since then. :-) – Mico Sep 10 '11 at 21:13
The [p]
float placement specifier puts the float (figure
or table
) on a page of its own, vertically centered. The following MWE illustrates that:
\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\begin{document}
\lipsum[1-2]
\begin{figure}[p]
\centering\rule{0.8\linewidth}{0.5\textheight}
\caption{A big figure}
\end{figure}
\lipsum[3-10]
\end{document}
Note that by specifying the optional [p]
parameter to your float, only that float will appear on the corresponding page.
-
1I think the OP's issue is that his/her floats on floats-only pages are aligned along the page's top margin instead of being centered vertically. This must be happening because he/she is using a document class or some package that overrides LaTeX's default setup of centering the float vertically on a floats-only page. Will using the
[p]
placement specification solve this lack-of-vertical-centering issue? – Mico Sep 10 '11 at 23:41 -
@Mico: It may if they still include the figure inside a designated float, since they abide by the regular optional parameter for placement convention. However, if the documentclass provides a new environment (not a float), then neither of our solutions will do the trick; your's hooks on float-related spacing. – Werner Sep 11 '11 at 8:13
-
2I'm using "book" documentclass, with a lot of packages, most of them are recommended by our print service. Indeed, after your pointer (fptop) I started looking, and yes, there it was --- forcing top alignment. – Nikola Knezevic Sep 11 '11 at 12:38