Miscellaneous displayed text environments

6.8 Miscellaneous displayed text environments

There are four more displayed text environments, of limited use in math: quote, quotation, verse, and verbatim. We also discuss an inline version of the verbatim environment, the \verb command.

Quotes The quote environment is used for short (one paragraph) quotations:

which is typed as: \begin{quote}

It’s not that I’m afraid to die. I just don’t want to be there when it happens. \emph{Woody Allen}

Literature is news that STAYS news. \emph{Ezra Pound}

\end{quote} Note that multiple quotes are separated by blank lines.

144 Chapter 6 Text environments

Quotations In the quotation environment, blank lines mark new paragraphs:

is typed as \begin{quotation}

KATH: Can he be present at the birth of his child? ED: It’s all any reasonable child can expect

if the dad is present at the conception. \begin{flushright}

\emph{Joe Orton} \end{flushright} \end{quotation}

Verses

A verse environment,

is typed as \begin{verse}

I think that I shall never see\\

A poem lovely as a tree. Poems are made by fools like me,\\

But only God can make a tree. \begin{flushright}

\emph{Joyce Kilmer}

6.8 Miscellaneous displayed text environments 145

\end{flushright} \end{verse}

Lines are separated by \\ and stanzas by blank lines. Long lines are typeset with hanging indent.

Verbatim typesetting Finally, there is the verbatim text environment. You may need it if you write about

L A TEX or some other computer program or if you have to include portions of a source file or user input in your typeset work. Most of the displayed source in this book was written in a verbatim environment. For instance, you may have to write to a journal about an article you are proofreading:

Formula (2) in Section 3 should be typed as follows: \begin{equation}

D = \{\, x_0 \mid x_0 \Rightarrow a_1 \,\} \tag{2} \end{equation}

Please make the necessary corrections. The problem is that if you just type

Formula (2) in Section 3 should be typed as follows: \begin{equation}

D = \{\, x_0 \mid x_0 \Rightarrow a_1 \,\} \tag{2} \end{equation} Please make the necessary corrections.

it typesets as

Formula (2) in Section 3 should be typed as follows: (2)

D= {x 0 |x 0 ⇒a 1 }

Please make the necessary corrections. To get the proper typeset form, type it as follows:

Formula (2) in Section 3 should be typed as follows: \begin{verbatim} \begin{equation}

D = \{\, x_0 \mid x_0 \Rightarrow a_1 \,\} \tag{2} \end{equation}

146 Chapter 6 Text environments

\end{verbatim} Please make the necessary corrections.

Rule

verbatim text environments

A verbatim environment cannot be placed within Another verbatim environment The argument of a command The closing line, \end{verbatim}, must be on a line by itself.

A violation of the first rule results in unmatched environment delimiters. You get an error message such as

! \begin{document} ended by \end{verbatim}.

A violation of the second rule gives an error message such as ! Argument of \@xverbatim has an extra }.

Tip There are two traps to avoid when using the verbatim environment.

1. If the \end{verbatim} line starts with spaces, a blank line is added to the typeset version.

2. Any characters following \end{verbatim} on the same line are dropped and you get a L A TEX warning.

To illustrate the first trap, type the last two lines of the previous example as fol- lows:

\end{verbatim} Please make the necessary corrections.

Then you find an unintended blank line before the last line. The second trap can be seen if you type the last line of the above example as

\end{verbatim} Please make the necessary corrections. When typeset, Please make the necessary corrections. does not appear, and you

receive a warning LaTeX Warning: Characters dropped after

‘\end{verbatim}’ on input line 17.

6.8 Miscellaneous displayed text environments 147

Several improved versions of the verbatim environment are provided by the verbatim package (see Section 12.3.1). To use this package, include the command

\usepackage{verbatim} in the preamble. In fact, the rules discussed in this section are those of the verbatim

package. The verbatim environment has some interesting variants and a number of them are discussed in Section 3.4 of The L A TEX Companion, 2nd edition [46]. For instance, the alltt package, which is part of the standard L A TEX distribution (see Section 12.3) is used to type the command syntax in this book. See the full syntax of \newtheorem on page 128 for an example.

Verbatim typesetting inline The verbatim environment also has an inline version called \verb. Here is an exam-

ple: Some European e-mail addresses contain \%;

recall that you have to type \verb+\%+ to get \%. which prints

Some European e-mail addresses contain %; recall that you have to type \% to get %.

The character following the \verb command is a delimiter. In this example I have used +. The argument starts with the character following the delimiter, and it is termi- nated by the next occurrence of the delimiter. In this example, the argument is \%.

Choose the delimiter character carefully. For instance, if you want to typeset $\sin(\pi/2 + \alpha)$ verbatim, and you type \verb+$\sin(\pi/2 + \alpha)$+ then you get the error message ! Missing $ inserted.

<inserted text>

l.5 \verb+$\sin(\pi/2 + \alpha

Indeed, the argument of \verb is $\sin(\pi/2 because the second + terminates the \verb command. Then L A TEX tries to typeset \alpha)$+, but cannot because it is not in math mode. Use another character, such as !, in place of +:

\verb!$\sin(\pi/2 + \alpha)$!

148 Chapter 6 Text environments

Rule

verb commands

The entire \verb command must be on a single line of your source file. There can be no space between the \verb command and the delimiter. The \verb command cannot appear in the argument of another command. The \verb command cannot be used within an aligned math environment. Do not use * as a delimiter.

If you violate the first rule, as in \verb!$\sin(\pi/2 +

\alpha)$! you get the error message ! LaTeX Error: \verb command ended by end of line.

l.6 \verb!$\sin(\pi/2 + The \verb command has a *-ed version which prints spaces as symbols. For

example, \today the is typed as \verb*+\today the+. The \verb command can perform the function of the verbatim environment. The last error message, which was displayed in a verbatim environment, may be typed as follows:

you get the error message\\[8pt] \verb|! LaTeX Error: \verb command ended by end of line.|\\ \verb| |\\ \verb|l.6 \verb!$\sin(\pi/2 +|\\[8pt]

Rule

Simulating verbatim with verb

1. End the line before the verbatim environment with \\[8pt].

2. Each line xxx of the verbatim environment is placed in the construct: \verb|xxx | If | occurs in xxx, then choose a different delimiter.

6.8 Miscellaneous displayed text environments 149

3. The last line yyy of the verbatim environment is placed in the construct: \verb|yyy |\\[8pt] If | occurs in yyy, then choose a different delimiter.

CHAPTER

Typing math

L A TEX was designed for typesetting math. I address this topic in detail.

A math formula can be typeset inline, as part of the current paragraph, or dis- played , on a separate line or lines with vertical space before and after the formula. In this and the next chapter we discuss formulas that are set inline or displayed on

a single line. In Chapter 9 we address multiline math formulas. We start with a discussion of L A TEX’s basic math environments (Section 7.1), spac- ing rules in math (Section 7.2), and continue with the equation environment (Sec- tion 7.3). The basic constructs of a formula—arithmetic (including subscripts and superscripts), binomial coefficients, ellipses, integrals, roots, and text—are discussed in detail in Section 7.4. From the basic constructs of that section, you can build very complicated formulas, one step at a time. The process is illustrated in Section 7.4.7.

Delimiters, operators, and math accents are dealt with in Sections 7.5–7.7. In Sec- tion 7.8, we discuss three types of stretchable horizontal lines that can be used above or below a formula: braces, bars, and arrows. There are also stretchable arrow math symbols.

Section 7.9 is our Formula Gallery, in which you find a large number of illustra- tions, some straightforward, some more imaginative, of the math constructs introduced in the preceding sections.

152 Chapter 7 Typing math

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