About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-10-15: New blog post: Tales for Our Times Book Launch.


2.12 Declarations

The term declaration is used to refer to a command that affects the document from that point onwards. The declaration itself does not produce any text and, in most cases, its effect can be localised by placing the declaration within a group. For example, \bfseries is a declaration that switches the current font weight to bold, so the following code

Here is some normal text.
\bfseries Here is some bold text.

will appear in the typeset document looking like:

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

Some declarations don't immediately have a visible effect. For example, the declarations

\raggedright \raggedleft \centering

only set the paragraph justification to ragged-right, ragged-left or centred, respectively, if the declaration is still in effect at the end of the paragraph. That is, if it is still in effect at the next \par or blank line.

Example:

This is an example paragraph illustrating the paragraph justification declarations. The default justification is fully justified. \raggedright The paragraph justification can be switched to ragged-right or \raggedleft ragged-left. \par

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

Above, the justification at the paragraph break is ragged-left, so that's the justification used for the entire paragraph. Compare with:

{This is an example paragraph illustrating the paragraph justification declarations. The default justification is fully justified. \raggedright The paragraph justification can be switched to ragged-right or \raggedleft ragged-left.} \par

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

Above, the justification at the paragraph break is fully-justified, since both the declarations \raggedright and \raggedleft are cancelled when their local scope (signified by the curly braces) ends. This type of mistake most often occurs when people try to centre text doing something like:

{\centering Some text that is supposed to
be centred.
}


Next paragraph.
The paragraph break (blank line) must go before the closing brace.
{\centering Some text that is supposed to
be centred.

}

Next paragraph.

While we're on the subject of centred text, don't be tempted to use \centerline. It's obsolete [15].


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