Latest news 2021-09-06: new blog post "Legacy Documents and TeX Live Docker Images".

2.7 Grouping (or Scope)

A segment of code may be grouped by placing it within { and } (curly braces). Most commands that occur within a group will be local to that group. For example, \bfseries changes the font weight to bold, so the following segment of code:

Here is some text. {This text \bfseries is in a group.} Here is some more text.

will appear in the typeset document looking like:

Image showing typeset output (click here for a more detailed description).

As can be seen, the font change only stays in effect until it reaches the end of the group (signified by the closing curly brace }.) For a command to be in the same scope as another command, both commands must be within the same group. For example, in the following, \bfseries and \itshape are in the same scope:

{\bfseries Some bold \itshape and italic text}

But below, they are in different scopes:

{\bfseries Some bold text} {\itshape and some italic text}

Environments form an implicit scope.

This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).

© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs