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.

After reading this question Should I use center or centering for figures?, I want to know the answer of the following.

When should we use \begin{center} instead of \centering?

For example, should we use this one?

{%
\centering
<other contents>
}

or this one?

\begin{center}
<other contents>
\end{center}
share|improve this question
    
@Werner I just looked at the post and don't think it adequately answered the questions. We can always define a new environment to avoid the use of \begin so is there every a need for it? –  dustin May 28 '13 at 22:45
    
The typical approach in such situations is to request more clarification from the original answer(s), perhaps issue a bounty. In extreme situations when a new (similar) question is asked, answers could be merged with an existing question, but otherwise there is duplication on the site which is avoided through closing... –  Werner May 28 '13 at 22:55
    
@Werner if anything, can you merge David Carlisle's answers since his answers really shine light on when to use one over the other? –  dustin May 28 '13 at 23:09
    
The best I can do is flag it for moderator attention, since they have the capability to merge content on the site. –  Werner May 28 '13 at 23:14

2 Answers 2

up vote 56 down vote accepted

First of all, \centering needs a \par (or an empty line) before the closing brace

{\centering
  contents\par
}

Usually it's used inside some environment that provides the necessary \par, such as minipage or figure. Try

abc{\centering def}ghi

to see the effect.

The main difference with center is that \centering doesn't leave vertical space before and after it: \begin{center} is defined in terms of trivlist.

\def\center{\trivlist \centering\item\relax}
\def\endcenter{\endtrivlist}
\def\centering{%
  \let\\\@centercr
  \rightskip\@flushglue\leftskip\@flushglue
  \parindent\z@\parfillskip\z@skip}

Note that it's an error to use

\center

because this will last “forever” (up to the end of the current group, anyway). The command exists just as a side effect of the existence of the center environment.

share|improve this answer

The difference between center and \centering is that the latter just sets the paragraph parameters but the former is a list (actually implemented via \trivlist) as such, it gets the standard vertical spacing used by all LaTeX display environments such as verbatim or verse or quote, as well as theorems.

So if you just want to center something that is already vertically positioned (as is often the case inside a figure environment) then \centering is what you need, but if you want to implement a displayed construct that happens to need centred content, then center is what you should use.

share|improve this answer
1  
So it would be appropriate then for it to be used as a title of a new idea of a long document then. I wasn't thinking about the display environment advantages over the just centering it aspect. –  dustin May 28 '13 at 22:50
    
@dustin possibly, although better to say used in the definition of such a title as it is better to use logical markup like \section or \idea in the document even if that is just defined to do some font and spacing commands. section titles often have other requirements though such as not allowing page breaks before following text. –  David Carlisle May 28 '13 at 22:54
    
For a formal document, of course, use one of those constructs but I was speaking of something informal such as notes. –  dustin May 28 '13 at 22:56
5  
@dustin bad habits is bad habits:-) even if you are just typing up some lecture notes and only you plan to ever see the document your future self will thank you (or me:-) if you stick \newcommand\idea[1]{\begin{center}#1\end{center}} and use \idea rather than use \begin{center} explicitly. –  David Carlisle May 28 '13 at 22:59

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.