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.

What is the correct way to center figures and tables (figure, table)?

\begin{center}
...
\end{center}

or

\begin{centering}
...
\end{centering}
share|improve this question
1  
Definitely never put the center environment around the figure environment! See Tables and sections get misplaced. (Not that I say Yiannis did this) –  Martin Scharrer Apr 11 '11 at 16:27
    
@MartinScharrer Definitely relevant that question but the answer only says don't do [X]. As such it's not as useful as lockstep's answer, which provides an explanation. –  Marc van Dongen Jun 22 '13 at 6:26
add comment

1 Answer

up vote 152 down vote accepted

The correct way is

\begin{figure}
\centering
... (Code for pictures, captions) ...
\end{figure}

\begin{center} ... \end{center} inside a figure environment will result in (generally unwanted) additional vertical space.

Note that while \centering produces proper spacing, manually adding this command to every figure environment (and to every table and custom-made float) is tedious and goes against the idea of separating the content of a document from the format. Even better ways are to add the following to your document preamble (thanks to egreg for the tip):

\makeatletter
\g@addto@macro\@floatboxreset\centering
\makeatother

or to load the floatrow package which allows to control the justification of float contents from the preamble (with objectset=centering as default).

share|improve this answer
46  
Also note that \centering is a declaration, not an environment. That \begin{centering} works is an unfortunate consequence of the way environments work internally in LaTeX: The environment foo essentially consist of two macros \foo and \endfoo which are called by \begin{foo} and \end{foo}, respectively (along with some error checking, such as proper nesting). But since \endfoo is called via \csname endfoo\endcsname, that macro doesn't actually have to exist. This means that even stuff such as $\begin{alpha}\end{alpha}$ works (but should of course not be used). –  Villemoes Dec 1 '10 at 10:56
12  
There's also the more esoteric \g@addto@macro\@floatboxreset\centering which, of course, should be preceded by \makeatletter and followed by \makeatother. –  egreg Apr 10 '11 at 14:25
    
Thanks for mentioning the floatrow package which looks very, very powerful (I should have found that before, now changing all figure/table definitions in my thesis will be quite some work). However, the documentation is so long and there are so many possibilities of configuration, that it will be very hard to figure out the best setup.. is there a tuturial with a "recommended" setup for a twopage thesis? :-( –  Martin Apr 11 '11 at 1:12
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.