A command is used to tell LaTeX to do a particular thing
at that point in the document. These are the basic forms a command
- A Control Word.
This is a backslash \ followed by letters (A,...,Z,a,...,z). [Commands gobble following space]There can be no non-alphabetical characters in the command, apart from the initial backslash, and the name is always case-sensitive so, for example,
\Gammahave different meanings. One command that often trips up new users is
\LaTeX, which prints the LaTeX logo: . This command has three captial letters and two lower case letters. If you get the case of any of the letters incorrect, you will get an “undefined control sequence” error.⚠There must be no space between the backslash and the start of the command name. Some command names are made up of two or more names joined together, such as
\tableofcontents. Make sure you don't insert any spaces in the control word. This will either lead to an error or an unexpected result. For example,✔
Most LaTeX commands have fairly self-explanatory names. (For example,
\chapterstarts a new chapter and
\rightarrowprints an arrow pointing to the right.) However, in most cases, you need to use U.S. spelling (for example,
This is the most common form of command. Any spaces immediately following a command of this type are ignored, so for example
There is one command that you must use in every document you create, and that is the
\documentclasscommand. This command must be placed at the very start of your document, and indicates what type of document you are creating. This command is described in more detail later.
- A Starred Command
Some commands have variants that are indicated by an asterisk at the end of the name. For example,
\chaptermakes a numbered chapter whereas
\chapter*is makes an unnumbered chapter. A starred command is the version of the command with the asterisk. (On a UK keyboard the asterisk character is usually located on the same key as the digit 8.)
This may seem like a different form to a control word, described above. After all, I've just said that a control word can only contain alphabetical characters. However a starred command is actually a control word (such as
\chapter) followed by an asterisk. The control word checks to see if the next character is an asterisk. If it is, it performs one action, otherwise it performs another action.
This type should therefore just come under the previous category, but as you will often hear of “starred commands” it seemed better to have a separate category.
- A Control Symbol.
This is a backslash followed by a single non-alphabetical character. For example \% will print a percent symbol. Spaces are not ignored after this type of command, for example17.5\% VAT
It's also possible to have starred forms of control symbols. For example \\ forces a line break. If it's not followed by an asterisk a page break is allowed at that line break, but if it is followed by an asterisk
\\*no page break is allowed at that line break. (If a page break is needed, it will be made at the end of the previous line instead.)
- Character Sequence.
Some special sequences of characters combine to form an instruction. For example ffi is the command to produce the ligature, and the sequence of symbols !` is the command to produce the upside down exclamation mark ¡
- An Internal Command.
This is like the first type, a control word, but the @ character appears in the command name (for example
\c@section) however internal commands should only be used in class files or packages. The @ symbol takes on a special meaning when a file is included using
\documentclass(a class file) or
For example, in a class file or package
\c@sectionis an internal representation of the section counter, whereas in a .tex file
\c@sectionis interpreted as the command
\c(the cedilla accent command) that takes the character @ as its argument, followed by section, which produces the rather odd looking [\@ and @ in macro names].
Don't be tempted to use internal commands until you have first grasped the basics. You have been warned!
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).