LaTeX Seminar III: Environments and More Advanced Mathematical Typesetting

Similar documents
Just Enough L A TEX, Week 4

Environments, Equations, and Tables

Become a L A TEX Guru

MATLAB for the Sciences

Using L A TEX Tom Edgar

Introduction to L A TEX

CLV Manual. How to Use CLV L A TEX Style. Odié N. Gementera SPI Publisher Services

Learning LaTeX: The Basics

A Beginner s guide to L A TEX for CSCA67/MATA67. Kohilan Mohanarajan

Typesetting Text. Spring 2013 TEX-Bit #1 Math 406

L A TEX examples. a b c a b c b b a c b c c b a. This table was typeset with the following commands.

Math 235: Introduction to LaTeX

L A TEX for Psychological Researchers

L A TEX Introduction. 1 Basic Resources: Melissa Desjarlais (amended by Dr. Dena Morton)

Tables, Lists and Matrices. MAT 218 Mathematical Computing. February 2, 2016

LaTeX A Tutorial. Mohsen Alimomeni, 2010

CSE 150: Notation Examples

An Introduction to L A TEX

L A T E X Workshop. Bijulal D & Anu Thomas Industrial Engineering and Operations Research Indian Institute of Technology

An Interactive Introduction to L A TEX

Basics. Options. Commands

Getting started with Latex

LATEX Seminar Week 2 Jonathan Blair & Evan Ott. Document classes, basic math formatting, basic pictures, tables and matrices

An Interactive Introduction to L A TEX. Part 1: The Basics. John Lees-Miller. writel A TEX

An Introduction to LATEX

PHYS 87. Check that it works by typesetting the tripple ensted list of the pervious exercise.

Getting Started with L A TEX

Math 291: Lecture 5. Dr. Fagerstrom. Minnesota State University Moorhead web.mnstate.edu/fagerstrom

Learn how to [learn] LATEX

Lecture 3-Introduction to Latex (II)

L A TEX for Psychological Researchers

L A TEX Primer. Randall R. Holmes. August 17, 2018

Introduction to L A TEX for MCS-236

Text typesetting guide


1 Different Document Classes

Introduction to LaTeX. Paul Fodor Stony Brook University

Began as TeX, in 1982 (Knuth). Purely a typesetting tool. LaTeX added macros, maintaining TeX as it s typesetting engine (Lamport).

Intro to LaTeX Workshop

Assessments for CS students:

Not-So-Frequently Asked Questions for L A TEX

Getting Started with L A T E X for a Technical Document or Thesis

L A TEX: Online module 9

A Very Brief Introduction to L A T E X MAT 3535

L A TEX Tutorial. 1 Introduction. 2 Running L A TEX. J. E. Rice. May 2010

L A TEX and Basic Text Editing

A GRADUATE STUDENT'S GUIDE TO LATEX AND AMS-LATEX

Preparing Basic Manuscripts with L A TEX

TUTORIAL 10: ARRAYS AND MATRICES. 1. Welcome. Hello. My name is Dr. Christopher Raridan (Dr. R). I want to welcome you to the L A TEX Tutorial Series.

A Demonstration of the L A TEX 2ε Class File for the Oxford University Press Ltd Journal. First Author 1 and Second Author 2.

Illinois Wesleyan s Introduction to L A TEX

Guide to L A TEX. Daniel M. Kane

Paul Gartside. March 2, 2013

Guide to using L A TEX

Introduction to L A TEX

Introduction to MCS 220 and L A TEX

Writing Mathematics in L A TEX by Example

An Introduction to LATEX

Introduction to L A TEX

PHYS-4007/5007: Computational Physics

The Name of the Game. An Introduction to LATEX. Why L A TEX? The Name of the Game

Part - I : Short Course Typing Text

Interval Notation (mixed parentheses and brackets)

Preparation of ADSA and IJDE Manuscripts

A Beginner s Guide to LATEX. Last Revised: August 21, 2013

L A TEX. The Logo. Introduction to L A TEX. Overview. Primary Benefits. Kinds of Documents. Bill Slough and Andrew Mertz

Introduction to LATEX

A Short Introduction to L A TEX

Intro to LATEX I. Aaron Erlich POLS/CSSS 510, Why LATEX? Programming Document Structure Floats Tables Lists Math

Helen Cameron. A Brief Overview of LATEX

Multiline math displays

Workshop: A Simple Introduction to L A TEX

1 Obtaining LyX and L A TEX

Using LaTex and BibTex to Write Academic Documents. Ligang He Department of Computer Science University of Warwick

4.7 Approximate Integration

Mikkel Madsen

Helen Cameron. A Brief Overview of LATEX

Using the amsthm Package

Using the amsthm Package

Meeting One. Aaron Ecay. February 2, 2011

A Brief Introduction to LaTeX

CS 189 L A TEX and Linux: Displaying Text

Lecture slides for MA2730 Analysis I

What is LaTeX. Is a document markup language and document preparation system for the TeX typesetting program

Latex Tutorial 1 L A TEX. 1.1 Text

Basic instructions for writing a paper

Math 291: Lecture 4. Dr. Fagerstrom. Minnesota State University Moorhead web.mnstate.edu/fagerstrom

NCSU Linguistics Eric Wilbanks & Jeff Mielke. November 21, An open-source typesetting language used for document mark-up

L A TEX Seminar Fall Semester 2007

A quick guide to L A TEX

LATEX TYPESETTING SYSTEM. CAAM 519, CHAPTER 3

COMP496/901: Academic Presentation and Writing Skills Using LaTeX

AXIOMS FOR THE INTEGERS

Indian T E X Users Group

L A TEX minicourse. dstowell, mag, sar, scannell,... September Typeset by FoilTEX

EBESS and MESS Presents: Learn to LaTeX. Presented by Joshua Tambunan 13 February 2018

Typing Mathematics. Darrin Doud

A Grasshopper s Approach to L A TEX

looks slightly different when set in display style. (See next section).

Workshop on LaTeX. Outline. Muhammad Mostafa Monowar 11/13/2017

Transcription:

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 \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 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 \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 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 \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 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 \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 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 (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 Environments Used in Mathematical Typesetting 2.1 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. For example typing $\begin{pmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9 \end{pmatrix}$ produces 1 2 3 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 {a n } is bounded means there is a number M such for each n, a n 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. 1 cos 2x sin 2 x dx = dx (1) 2 = 1 (1 cos 2x) dx (2) 2 = 1 2 x 1 sin 2x + C 2 2 (3) = x sin x cos x + C. 2 2 (4) 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 1 cos 2x sin 2 x dx = dx 2 = 1 (1 cos 2x) dx 2 = 1 2 x 1 sin 2x + C 2 2 = x sin x cos x + C. 2 2 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 next entry Final entry in first line Entry 1 in column 2 next entry Final entry in second line (1) 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 4 5 6 7 8 9 1 1 2 3 4 5 6 7 8 9 2 2 4 6 8 10 12 14 16 18 3 3 6 9 12 15 18 21 24 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