Latex Seminar Iii

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Latex Seminar Iii as PDF for free.

More details

  • Words: 2,954
  • Pages: 10
LaTeX Seminar III: Environments and More Advanced Mathematical Typesetting Clifford E. Weil March 24, 2004

1

General Environments

We have already encountered two environments. They are the document environment and the thebibliography environment. All environments begin with \begin{environment name} and end with \end{environment name} Each environment is designed to typeset a special structure and therefore comes with its own set of special symbols and in some cases, commands. We’ll begin with some easy ones but ones that are used frequently.

1.1

Abstract

The abstract environment is used to put an abstract at the beginning of a document. It always comes immediately after the \maketitle command. In the source file you type \begin{abstract} then the text of your abstract followed by \end{abstract} When the file is compiled LaTeX produces the word, “Abstract” centered just below the title, increases the margins and lowers the type size, typesets the abstract and then undoes all of the formatting changes it made.

1.2

Center

Typing in the source file \begin{center} and then some text followed by \end{center} centers that text in the compiled file.

1

1.3

Quote

Short quotes are simply put between quotation marks. But for longer ones use the same procedure as above. The actual quote is typeset with larger margins.

1.4

The List Environments

There are three of these. They are: description, itemize and enumerate. For all three each item in the list begins with the command \item. The difference between the three lies in the amount each item is indented and how they are numbered. The numbering can be changed by using an optional argument. First the description environment will be demonstrated. \begin{description} \item This is the first item in the list. \item The second item in the list is somewhat longer and for that reason requires more than one line to display. \item The third and last item is much shorter. \end{description} In the compiled file the above produces. This is the first item in the list. The second item in the list is somewhat longer and for that reason requires more than one line to display. The third and last item is much shorter. Note the indentation conventions. These settings are what distinguishes the different list environments. To number the items, use the optional argument for the \item command. \begin{description} \item[i] This is the first item in the list. \item[\textmd{ii}] The second item in the list is somewhat longer and for that reason requires more than one line to display. \item[iii] The third and last item is much shorter. \end{description} produces i This is the first item in the list. ii The second item in the list is somewhat longer and for that reason requires more than one line to display. iii The third and last item is much shorter. Note how the command \textmd{ii} produces the label without bold. The itemize list environment differs from description in that items are begun with a • and the indentations are different. In this case the optional argument has the effect of replacing the •. For example 2

\begin{itemize} \item This is the first item in the list. \item[ii] The second item in the list is somewhat longer and for that reason requires more than one line to display. \item[c] The third and last item is much shorter. \end{itemize} will produce • This is the first item in the list. ii The second item in the list is somewhat longer and for that reason requires more than one line to display. c The third and last item is much shorter. The most frequently used list environment is the enumerate environment. It is especially efficient when used with the enumerate package, which allows the user to easily select the numbering method. Here’s an example. \begin{enumerate} \item This is the first item in the list. \item The second item in the list is somewhat longer and for that reason requires more than one line to display. \item The third and last item is much shorter. \end{enumerate} will produce 1. This is the first item in the list. 2. The second item in the list is somewhat longer and for that reason requires more than one line to display. 3. The third and last item is much shorter. To change the enumeration to say lettering in parentheses, type \begin{enumerate}[(a)] and the outcome will be (a) This is the first item in the list. (b) The second item in the list is somewhat longer and for that reason requires more than one line to display. (c) The third and last item is much shorter. These list environments can be nested up to 4 levels deep. That is, an item in a list can itself be a list, and one of the items in that list can also be a list, etc. One word of caution. There shouldn’t be a blank line before a list environment. Finally if none of these three list environments suit your purposes, you can define your own list environment. But doing so is an advanced topic. 3

2 2.1

Environments Used in Mathematical Typesetting The Equation Environment

This environment is for a mathematical formula which is only one line in length and for which a number is desired. For that reason it is best to include the \label command. A simple example is \begin{equation}\label{eq1} \{x\in \mathbb R; \sin x > 0 \text{ and } x>2\} \end{equation} will produce {x ∈ R; sin x > 0 and x > 2} (1) and consequently if you wish to refer to this equation later in the document, you need only type Recall \eqref{eq1}. and you will get “Recall (1)”.

2.2

The Array Environment

This is the prototype for many of the environments to follow. The command \begin{array} has one compulsory argument by which the number of columns in the array and their alignment are specified. For example \begin{array}{clrlc} says that the array will have 5 columns: the first will be centered, the second flush left, the third flush right the fourth flush left and the fifth centered. The columns in each row of an array are separated by the & sign and the end of a row is designated by \\. For Example typing $$\begin{array}{lcr} a+b+c & u+v & r+s+t\\ a-c & u-v+w &r-s\\ c-b+a+d &v-w &s-t \end{array}$$ produces a+b+c u+v r+s+t a−c u−v+w r−s c−b+a+d v−w s−t The & sign indicates the point of alignment and the \\ indicates the end of a row (or line). Note that there is no \\ at the end of the last row. These two symbols are used in the same way whenever they appear. The use of \\ to start a new line is used throughout LaTeX. You will see that many of the environments to follow use the same basic structure of the array environment.

4

2.3

The Cases Environment

This environment is used to define a function using two or more cases. This example will demonstrate how the environment works. In the source file typing Let $$ f(x) = \begin{cases} 1&\text{if } x\in \mathbb R \text{ is rational} \\ 0&\text{otherwise.} \end{cases} $$ in the compiled file will produce Let ( 1 if x ∈ R is rational f (x) = 0 otherwise.

2.4

The Matrix Environments

There are five of these distinguished by what delimiters you wish to bound your matrix. The names of the five environments are matrix, pmatrix, bmatrix vmatrix and Vmatrix. In the first case there are no symbols around the matrix, in the second the matrix is enclosed in parentheses, in the third, by braces [ ], in the fourth, by vertical lines | | and in the fifth by double vertical lines k k. For example typing $\begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9\end{pmatrix}$  1 2 3 produces 2 4 6 3 6 9

2.5

The Assertion Environments

These environments are used to state corollaries, definitions, lemmas, propositions, remarks, theorems etc. One environment for each type of assertion is made with the \newtheorem command. The package amsthm must be included in the \usepackage command in the preamble. Due to the many different but accepted numbering options used in technical articles, the process of creating these environments is rather complicated. The \newtheorem command has two compulsory arguments and two optional ones, but at most one of the optional ones is used in creating any one assertion environment. We begin with the simplest situation. Suppose the author wishes to have definitions, lemmas and theorems; each numbered separately; that is, Definition 1, Lemma 1, Definition 2, Theorem 1 etc. Here’s what is typed in the preamble. \newtheorem{definition}{Definition} \newtheorem{lemma}{Lemma} 5

\newtheorem{theorem}{Theorem} The name of the environment is in the first argument while the title that LaTeX will produce in in the second. This process creates three new environments: definition, lemma and theorem. In the source file the first time the author wishes to state a definition, type \begin{definition}\label{def1} followed by the statement of the definition and ended, of course, with \end{definition} For example in the document typing \begin{definition}\label{def1} A sequence ${a n}$ is bounded means there is a number $M$ such that for each $n$, $a n \le M$. \end{definition} produces Definition 1. A sequence {an } is bounded means there is a number M such for each n, an ≤ M . LaTeX automatically numbers the first definition as Definition 1. To refer to this definition later in the text, simply type By Definition \ref{def1} LaTeX automatically produces, “By Definition 1”. Next suppose the author wishes to state a Lemma. Type \begin{lemma}\label{lem1} followed by the statement of the lemma and ended with \end{lemma} This lemma is named Lemma 1. and when Lemma \ref{lem1} is typed in the source file, LaTeX inserts. “Lemma 1”. Next a theorem is to be stated by typing \begin{theorem}\label{th1} followed by the statement of the theorem and ended by \end{theorem} The correspond remarks made about definition and lemma above hold for theorem as well. The number assigned to Definition 1 would change if later the author decides to insert a definition before Definition 1, say one that is labeled \label{def0}. Then LaTeX will number the new first definition as Definition 1 and the previous Definition 1 becomes Definition 2. LaTeX also automatically changes these numbers where they are referred to later in the text. The next definition stated would logically be labeled def2 and would be called Definition 3 even if it occurs after say Lemma 4. Many readers find this numbering scheme confusing and prefer to have assertions numbered according to the order in which they occur in the article. To accomplish this goal in the preamble type \newtheorem{definition}{Definition} \newtheorem{lemma}[definition]{Lemma} \newtheorem{theorem}[definition]{Theorem} 6

This process creates three new environments: definition, lemma and theorem just as before. Their use in the document is the same as before. The difference is that LaTeX numbers the assertions in the order that they appear in the article. So in the previous example with the new meaning for these environments, we would have Definition 1, Definition 2, Lemma 3 and Theorem 4. A combination of the two numbering schemes is possible as well. Suppose the definitions are to be numbered consecutively, but the other two: lemmas and theorems, are to be numbered according to their order of appearance. That goal is attained by typing in the preamble \newtheorem{definition}{Definition} \newtheorem{lemma}{Lemma} \newtheorem{theorem}[lemma]{Theorem} In a long article containing several sections it’s sometimes more convenient to number assertions according the section number. This is done by using the second optional argument. The easiest case is \newtheorem{definition}{Definition}[section] \newtheorem{lemma}{Lemma}[section] \newtheorem{theorem}{Theorem}[section] which will number each assertion separately; that is, if we are dealing with Section 3, Definition 3.1, Lemma 3.1 and Theorem 3.1. To number them consecutively simply change the commands to \newtheorem{definition}{Definition}[section] \newtheorem{lemma}[definition]{Lemma} \newtheorem{theorem}[definition]{Theorem} That minor change will result in assertions being numbered according to the order that they appear in a particular section. For example, then we could have, Definition 3.1, Lemma 3.2 and Theorem 3.3. The \newtheorem command also has what is called a ∗ version. The star simply means that no number is assigned. This version is useful for including the statement of a well known theorem that has a widely accepted name; for example Zorn’s Lemma. Here is how to use this version. Again in the preamble type \newtheorem*{zl}{Zorn’s Lemma} and in the document where the author wishes to state Zorn’s Lemma by name, type \begin{zl}\label{zl} followed by the statement of Zorn’s Lemma and ending with \end{zl} Then LaTeX produces a theorem named, “Zorn’s Lemma” but with no number.

2.6

The Proof Environment

For assertions that require a proof the proof environment is provided. It is relative newcomer to the LaTeX family of environments. It doesn’t appear in any of the manuals I’ve suggested for these seminars. It begins with 7

\begin{proof} followed by the proof of the assertion and ending with \end{proof} The environment insert the word, “Proof.” at the beginning of the proof and puts the symbol  (the widely accepted end-of-proof symbol) at the end of the last line in the proof. There is an optional argument which allows the user to begin the proof with a word or phrase other than the default one. For example \end{proof}[\textbf{Proof of Main Theorem}] will begin the proof with Proof of Main Theorem. If the proof ends with an environment, the end of proof symbol will be put at the end of the following, otherwise blank, line. To avoid this, put the command \qedhere at the end of the last line of the environment. Then the symbol, , appears at the end of last line of the environment.

2.7

Environments Used in Multi-Lined Mathematical Expressions

These environments are used when the mathematical expression to be typeset is too long to fit on one line. they require the amsmath package. The most frequently used of these is the align environment, which is a new environment replacing the older one called eqnarray. It is used when the multi-Lined formula has logical points in the lines that should be aligned; for example a string of equalities. The following example comes from calculus. Z Z 1 − cos 2x 2 dx (1) sin x dx = 2 Z 1 = (1 − cos 2x) dx (2) 2 1 1 sin 2x = x− +C (3) 2 2 2 x sin x cos x = − + C. (4) 2 2 is obtained by typing \begin{align} \int\sin^{2}x\,dx&=\int\frac{1-\cos 2x}{2}\,dx\\ &=\frac{1}{2} x-\frac{\sin 2x}{2} + C\\ &=\frac{x}{2}-\frac{\sin x\cos x}{2} +C \end{align} Note that there is no \\at the end of the last line. To eliminate the numbers replace {align} by {align*}. Perhaps the author would like to have one number that refers to the entire argument. This can be done using the equation environment and the split environment. We’ve already discussed the equation environment. The split environment works just like the align environment. 8

\begin{equation}\label{sin-squared} \begin{split} \int\sin^{2}x\,dx&=\int\frac{1-\cos 2x}{2}\,dx\\ &=\frac{1}{2}x-\frac{\sin 2x}{2} + C\\ &=\frac{x}{2}-\frac{\sin x\cos x}{2} +C \end{split} \end{equation} produces Z Z 1 − cos 2x 2 dx sin x dx = 2 Z 1 = (1 − cos 2x) dx 2 1 sin 2x 1 +C = x− 2 2 2 x sin x cos x = − + C. 2 2

(1)

If alignment isn’t called for, use the gather environment. It centers each of the lines and assigns each a number. To skip the numbers, use gather*. In the unstarred form of either align or gather, putting the command \nonumber at the end of a line but before the \\results in no number being placed at the end of the line.

2.8

The Tabbing and Tabular Environments

These two environments weren’t discussed in the seminar, but are included with the notes. As it’s name indicates, the tabbing environment recreates the popular tab feature of typewriters. Here’s how it works. The command \= sets a tab and the command\> moves to the next tab. To set the tabs, after typing\begin{tagging}, I suggest typing a line looking like this for, say three columns. XXXXXXXXXXXXX\=YYYYYYYYY\=ZZZZZZZZZZZZZZZZZZZZZZ\kill This sets the tabs or more precisely, the width of each of the three columns and the \kill produces no output. The second line actually begins the text for the columns. So the next two lines might be something line this. Entry 1 in column 1\>next entry\> Final entry in first line\\ Entry 1 in column 2\>next entry\> Final entry in second line\\ Continue in this fashion until you’ve completed all lines. Then type \end{tabbing}. If the appropriate number op dummy characters have been inserted in the first line the result will look like this. Entry 1 in column 1 Entry 1 in column 2

next entry next entry

Final entry in first line Final entry in second line

If it looks like this 9

Entry 1 in column next1 entry Entry 1 in column next2 entry

Final entry in first line Final entry in second line

not enough Xs were put in the first line. Go back and add some. To create tables with vertical and/or horizontal lines separating rows and columns and to position the text in columns, (flush right, flush left or centered) use the tabular environment. The starting command has a compulsory argument in which the number of columns and their individual alignment is determined. The format reminds one of the array environment. This multiplication table

1 2 3

1 1 2 3

2 2 4 6

3 3 6 9

4 4 8 12

5 5 10 15

6 6 12 18

7 7 14 21

8 8 16 24

9 9 18 27

is produced by typing \begin{tabular}{|c||c|c|c|c|c|c|c|c|c|c|}\hline &1&2&3&4&5&6&7&8&9\\ \hline 1&1&2&3&4&5&6&7&8&9\\ \hline 2&2&4&6&8&10&12&14&16&18\\ \hline 3&3&6&9&12&15&18&21&24&27\\ \hline \end{tabular}. As you probably guessed, the command \hline produces a horizontal line running the width of the table.

10

Related Documents

Latex Seminar Iii
October 2019 4
Latex
November 2019 54
Latex
November 2019 61
Latex
November 2019 69
Latex
October 2019 75
Latex
November 2019 53