[texhax] Put figure/table in the center
Robin Fairbairns
Robin.Fairbairns at cl.cam.ac.uk
Sun Oct 26 08:42:06 CET 2003
> On Sun, 26 Oct 2003, Tran Hong Quang wrote:
>
> > How can I put figure/table in the center?
ross too assumed you mean horizontally in the center...
> \begin{figure}
> \begin{center}
> .... whatever ....
> .... more stuff ...
> \end{center}
> \caption{....}
> \end{figure}
>
> works for most instances of ... whatever ...
and adds unnecessary vertical space -- see:
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=vertspacefloat
which explains that you should use:
\begin{figure}
\centering
.... whatever ....
\caption{....}
\end{figure}
> However, you may come across some environments for which this
> doesn't work, due to TeX's vertical/horizontal mode mechanism.
> In that case, a simple fix is to stat as follows:
>
> \begin{figure}
> \begin{center}\leavevmode
which is odd because i once believed that {center} was to avoid the
need to leave vertical mode...
> I use this a lot with Xy-pic diagrams, which create a TeX \hbox:
>
> \begin{figure}
> \begin{center}\leavevmode
> ... perhaps some customising definitions ...
> \begin{xy}
> ....
> ....
> \end{xy}
> etc.
if it creates an \hbox, why the need to enclose it in a center
environment? \centering\leavevmode would be enough.
More information about the texhax
mailing list