2

Usually commands of the form:

{\command <text>}

affect only <text> and nothing else. In other words, the scope of such commands is limited to the group they are nested in. In the case of the \centering command this is clearly not the case, since the code:

a{\centering b\\}

centers both a and b. Why is this the case? In other words, why does the scope of the \centering command extend beyond the group it is nested in? Also, are there any other commands of the "switch" variety which also have an effect on text outside of their group?

1
  • 5
    \centering affects a paragraph (and with \centering active \\ ends a paragraph). Commented Nov 2, 2019 at 19:16

1 Answer 1

4

You see the same if you do

  aaaaaa\Large

where the baseline spacing (but not the font) of the previous text will be affected,

a Paragraph is broken into lines and the resulting lines are justified based on the settings at the end of the paragraph, so if you enable \centering (or change the baseline spacing) before ending a paragraph then you get a (usually unwanted) affect on the preceding text..

3
  • So if I understand correctly the type of LaTeX commands which affect prior text are commands which necessarily affect an entire line or an entire paragraph of text, such as horizontal justification commands, vertical spacing commands, as well as font size commands. The remaining question then is this: which commands affect just the current line, and which commands affect the entire current paragraph? Commented Nov 3, 2019 at 16:59
  • @TheRiddler not vertical spacing other than baseline space, essentially anything that sets \leftskip, \rightskip, \hsize \baselineskip or \lineskip Commented Nov 3, 2019 at 17:40
  • @TheRiddler while technically it works as described, it's better to think of it as user error and that \centering should always have a blank line before. Commented Nov 3, 2019 at 17:42

You must log in to answer this question.

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