Commands and environments

5.3.1 Commands and environments

The \emph{text } command instructs L A TEX to emphasize its argument, text. The \& command has no argument. It instructs L A TEX to typeset & (see Section 5.4.4). The flushright environment instructs L A TEX to right justify the content, the text between the two commands

\begin{flushright} \end{flushright}

The content of the document environment is the body of the article (see Section 4.1) and the content of the abstract environment is the abstract.

Rule

Environments An environment starts with the command

\begin{name } and ends with

\end{name } Between these two lines is the content of the environment, affected by the definition of

the environment.

Rule

Commands AL A TEX command starts with a backslash, \, and is followed by the command name. The name of a command is either a single non-alphabetic character other than a tab or end-of-line character or a string of letters, that is, one or more letters.

So # and ’ are valid command names. The corresponding commands \# and \’ are used in Sections 5.4.4 and 5.4.7, respectively. input and date are also valid command names. However, input3, in#ut, and in ut are not valid names because 3, #, and should not occur in a multicharacter command name. Note that is a command name, the command \ produces a blank.

L A TEX has a few commands, for instance, $ (see Section 7.1) that do not follow this naming scheme, that is, they are not of the form \name. See also Section 15.1.8 for special commands with special termination rules.

5.3 Commanding L A TEX

Rule

Command termination L A TEX finds the end of a command name as follows:

If the first character of the name is not a letter, the name is the first character. If the first character of the name is a letter, the command name is terminated by the

first nonletter. If the command name is a string of letters, and is terminated by a space, then L A TEX

discards all spaces following the command name.

While input3 is an invalid name, \input3 is not an incorrect command. It is the \input command followed by the character 3, which is either part of the text following the command or the argument of the command.

L A TEX also allows some command names to be modified with *. Such commands are referred to as *-ed commands. Many commands have *-ed variants. \hspace* is an often-used *-ed command (see Section 5.8.1).

Rule

Command and environment names Command and environment names are case sensitive. \ShowLabels is not the same as \showlabels.

Rule

Arguments Arguments are enclosed in braces, { }. Optional arguments are enclosed in brackets, [ ].

Commands may have arguments, typed in braces immediately after the command. The argument(s) are used in processing the command. Accents provide very simple examples. For instance, \’{o}—which produces ´o—consists of the command \’ and the argument o (see Section 5.4.7). In \bibliography{article1}, the command is \bibliography and the argument is article1 (see Section 16.2.2).

Sometimes, if the argument is a single character, the braces can be dropped: \’o also typesets as ´ o. Some environments also have arguments. For example, the alignat environment (see Section 9.5.4) is delimited by the commands

\begin{alignat}{2} and \end{alignat}

70 Chapter 5 Typing text

The argument, 2, is the number of columns—it could be any number 1, 2, . . . A com- mand or environment may have more than one argument. The \frac command (see

Section 7.4.1) has two, $\frac{1}{2}$ typesets as 1 2 . The user-defined command \con has three (see Section 15.1.2).

Some commands and environments have one or more optional arguments, that is, arguments that may or may not be present. The \sqrt command (see Section 7.4.5) √

has an optional argument for specifying roots other than the square root. To get 3 25, type \sqrt[3]{25}. The \documentclass command has an argument, the name

of a document class, and an optional argument, a list of options (see Section 10.2), for instance,

\documentclass[12pt,draft,leqno]{amsart}

Tip If you get an error when using a command, check that:

1. The command is spelled correctly, including the use of uppercase and lowercase letters.

2. You have specified all required arguments in braces.

3. Any optional argument is in brackets, not braces or parentheses.

4. The command is properly terminated.

5. The package providing the command is loaded with the \usepackage command.

Most errors in the use of commands are caused by breaking the termination rule. We can illustrate some of these errors with the \today command, which produces to- day’s date. You have already seen this command in Section 2.4 (see also Section 5.4.8). The correct usage is

\today\ is the day or \today{} is the day which both typeset as

July 19, 2006 is the day In the first case, \today was terminated by \ , the command that produces an inter-

word space. In the second case, it was terminated by the empty group { }.

5.3 Commanding L A TEX

If there is no space after the \today command, as in \todayis the day you get the error message ! Undefined control sequence.

l.3 \todayis the day

L A TEX thinks that \todayis is the command, and, of course, does not recognize it. If you type one or more spaces after \today:

\today is the day L A TEX interprets the two spaces as a single space by the first space rule (see page 64),

and uses that one space to delimit \today from the text that follows it. So L A TEX produces

July 19, 2006is the day Section 15.1.8 discusses how best to avoid such errors.

Tip If a command—or environment—can have an optional argument and none is given, and

the text following the command starts with [, then type this as {[}.

This may happen, for instance, with the command \item (see page 123). To get an example for an environment, see Section 9.6.1 for subsidiary math environments and page 229 for the alignment options. See what happens if no option is given but the math starts, say, with [x].

Dokumen yang terkait

c. Bridging Teknik memanjat pada celah vertikal yang lebih besar (gullies). Caranya dengan menggunakan kedua tangan dan kaki sebagai pegangan pada kedua celah tersebut. Posisi badan mengangkang kaki sebagai tumpuan dibantu juga tangan sebagai penjaga kese

0 1 10

2. Marah: adalah kunci setiap kejahatan. Nabi saw. telah berpesan pada seseorang untuk menjauhi sikap marah dengan sabda beliau: "Janganlah engkau marah". Beliau mengulanginya berkali-kali. (H.R Bukhari). - Kebersihan Hati

2 5 14

Object Oriented Programming dengan Delphi (

1 4 75

E volusi dan aplikasi sistem informasi berbasis komputer

1 8 18

b. Data Manipulation Language (DML) : Digunakan untuk memanipulasi data dengan menggunakan perintah : select, - SISTEM BASIS DATA 1.rar (7,386Kb)

1 3 15

Hubungan Pola Asuh Orang Tua dan Kesiapan Psikologis Anak dengan Kebersihan Toilet Traning pada Anak Usia Prasekolah di Paud Ab-Arisalah Kota Lubuklinggau

0 1 8

Hubungan Pengetahuan dsn Sikap dengan Tindakan Hygiene Penjual makanan Jajanan di Lingkungan Sekolah Dasar Kaamatan Baturaja Timur Kabupaten Ogan Komering UIU Tahun 2013 A. Gani

1 3 14

Faktor faktor yang berhubungan dengan manfaatan Posyandu lansia oleh kelompok usia lanjut didesa Kemalara dalam wilayah kerja Puskesmas Kemalaraja OKU Tahun 2013. Saprianto, M.Kes

3 3 21

Korelasi umur, pekerjaan, dan keberadaan kontainer dengan kejadian penyakit malaria di desa simpang Martapura wilayah Kabupaten Ogan Komering Ulu Selatan tahun 2014 – A. Gani

0 0 18

Pengaruh Ekstrak Daun Jambu Biji (Psidiu Guajava Linn) dan Ekstrak daun Teh Hijau (Camelia Sinensis) terhadap Pertumbuhan Escherichia Coli In Vitro dan Perbandingannya dengan Kotrimoksazol

2 16 20