Synopsis:
{\centering ... }
or
\begin{group} \centering ... \end{group}
Center the material in its scope. It is most often used inside an environment such as figure
, or in a parbox
.
This example’s \centering
declaration causes the graphic to be horizontally centered.
\begin{figure} \centering \includegraphics[width=0.6\textwidth]{ctan_lion.png} \caption{CTAN Lion} \label{fig:CTANLion} \end{figure}
The scope of this \centering
ends with the \end{figure}
.
Unlike the center
environment, the \centering
command does not add vertical space above and below the text. That’s its advantage in the above example; there is not an excess of space.
It also does not start a new paragraph; it simply changes how LaTeX formats paragraph units. If ww {\centering xx \\ yy} zz
is surrounded by blank lines then LaTeX will create a paragraph whose first line ‘ww xx’ is centered and whose second line, not centered, contains ‘yy zz’. Usually what is desired is for the scope of the declaration to contain a blank line or the \end
command of an environment such as figure
or table
that ends the paragraph unit. Thus, if {\centering xx \\ yy\par} zz
is surrounded by blank lines then it makes a new paragraph with two centered lines ‘xx’ and ‘yy’, followed by a new paragraph with ‘zz’ that is formatted as usual.
© 2007–2018 Karl Berry
Public Domain Software
http://latexref.xyz/_005ccentering.html