8

I cannot get my grips around the different effects of \begin{center} and \centering when used on tables (not inside tables). The MWE should explain the issue clearly:

\documentclass{article}
\begin{document}

\begin{center}
\begin{tabular}{ll}
\\
\emph{Definite benefit} & \emph{Definite cost} \\
Self-respect & Expense \\
\\
\emph{Possible benefit} & \emph{Probable cost} \\
Compensation & Trauma \\
\\
\end{tabular}
\end{center}

works to center, but not

{\centering
\begin{tabular}{ll}
\\
\emph{Definite benefit} & \emph{Definite cost} \\
Self-respect & Expense \\
\\
\emph{Possible benefit} & \emph{Probable cost} \\
Compensation & Trauma \\
\\
\end{tabular}
}

Why?

\end{document}

First table centered, the other one not.

1 Answer 1

10

A paragraph is set using the settings at the end of the paragraph. You have a {} group around the centering which means that its settings are discarded before the paragraph ends. Include a blank line before the } or rely on a surrounding environment such as table.

9
  • 1
    That works perfectly… but I'm not sure I fully understand. Why is the \centering discarded, alternatively why does the blank line make the \centering matter?
    – trmdttr
    Aug 6, 2013 at 10:06
  • 1
    Is it because the paragraph is bound by the {}?
    – trmdttr
    Aug 6, 2013 at 10:06
  • 2
    @trmdttr all local assignments (including those made by \centering are discarded at the end of a group. So you want the centred paragraph to end within the scope of those assignments, which means that it has to be before the } or don't have a {} group at all. Aug 6, 2013 at 14:37
  • 1
    @FangJing OK then I don't understand your comment, yes there is just one paragraph, consisting of the tabular \centering is a local declaration so its effect ends at the } so there are no paragraph ends within its scope, so it does nothing Jan 10, 2019 at 23:32
  • 1
    @FangJing a tabular is like a big letter so {\centering \begin{tabular}..\end{tabuar}} is like {\centering A} and in both cases the paragraph ends after the } Jan 12, 2019 at 2:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .