10

I often mess up by putting an empty line(or \par) after the closing brace.j

What makes the behavior different with \par being before or after }?

MWE: After.tex

\documentclass{article}
\begin{document}
{\centering Foo}

Bar
\end{document}

Before.tex

\documentclass{article}
\begin{document}
{\centering Foo

}  
Bar
\end{document}
14

TeX's line breaker breaks up a paragraph of text based on the settings at the end of the paragraph, so the vertical baseline spacing, and left and right skips used eg for centering are all based on the values in force at the end.

If you go

{\centering Foo}\par

then the group ends (and all the settings made by \centering are discarded) before the paragraph ends and so teh paragraph is set with normal justified settings and the only affect of \centering is that it set \parindent to zero, as that is used at the start.

If you go

{\centering Foo\par}

then you get a centred paragraph, the group then ends and the centering settings are discarded.

  • 4
    you might also note that a size change, like \Huge will be retained, but will use the baseline appropriate for the font outside the group, which will usually be wrong. – barbara beeton Feb 19 '17 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.