The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to...

81
The Not So Short Introduction to L A T E X2 ε Or L A T E X2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth Schlegl Version 2.1, 16th July, 1995

Transcript of The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to...

Page 1: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

The Not So ShortIntroduction to LATEX2ε

Or LATEX2e in 69 minutes

by Tobias OetikerHubert Partl, Irene Hyna and Elisabeth Schlegl

Version 2.1, 16th July, 1995

Page 2: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

ii

This document is “public domain”. It may be printed and distributed free of charge in its original form(including the list of authors). If it is changed or if parts of it are used within another document, then the authorlist must include all the original authors AND that author (those authors) who has (have) made the changes.When this document is used commercially, the GNU copyleft applies.

Page 3: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Thank you!

Much of the material used in this introduction comes from an Austrianintroduction to LATEX 2.09 written in German by:

Hubert Partl <[email protected]>Zentraler Informatikdienst der Universitat fur Bodenkultur Wien

Irene Hyna <[email protected]>Bundesministerium fur Wissenschaft und Forschung Wien

Elisabeth Schlegl <no email>in Graz

If you are interested in the German document you can find a versionupdated for LATEX2ε by Jorg Knappen at CTAN:/tex-archive/info/lkurz

While preparing this document I asked for reviewers on comp.text.tex. Igot a lot of response. The following individuals helped with corrections,suggestions and material to improve this paper. They put in a big effort tohelp me get this document into its present shape. I would like to sincerelythank all of them. Naturally, all the mistakes you’ll find in this book aremine. If you ever find a word which is spelled correctly, it must have beenone of the people below dropping me a line.

Rosemary Bailey, David Carlisle, Chris McCormack,David Dureisseix, Elliot, Robin Fairbairns,Alexandre Guimond, Neil Hammond, Rasmus Borup Hansen,Martien Hulsen, Eric Jacoboni, Alan Jeffrey, Byron Jones,David Jones, Andrzej Kawalec, Jorg Knappen, Maik Lehradt,Claus Malten, Hubert Partl, John Refling, Mike Ressler,Chris Rowley, Craig Schlenter, and Josef Tkadlec.

Page 4: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth
Page 5: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Preface

LATEX[1] is a typesetting system which is most suited to producing scientificand mathematical documents of high typographical quality. The system isalso suitable for producing all sorts of other documents, from simple lettersto complete books. LATEX uses TEX[2] as its formatting engine.

This short introduction describes LATEX2ε and should be sufficient formost applications of LATEX. For a complete description of the LATEX systemrefer to [1, 3].

LATEX is available for most computers from the IBM PC upwards. Onmany university computer networks the system is already installed, readyto operate. Information on how to access the local LATEX installation shouldbe provided in the Local Guide [4]. If you have problems getting started,ask the person who gave you this booklet. The scope of this document isnot to tell you how to install and set up a LATEX system, but to teach youhow to write your documents so that they can be processed by LATEX.

This Introduction is split into 4 chapters:

Chapter 1 tells you about the basic structure of LATEX2ε documents. Youwill also learn a bit about the history of LATEX. After reading thischapter you should have a rough picture of LATEX. The picture willonly be a framework, but it will enable you to integrate the informationprovided in the other chapters into the big picture.

Chapter 2 goes into the details of typesetting your documents. It explainsmost of the essential LATEX commands and environments. After read-ing this chapter you will be able to write your first documents.

Chapter 3 explains how to typeset formulae with LATEX. Again a lot of ex-amples help you to understand how to use one of LATEX main strengths.At the end of this chapter you find tables, listing all the mathematicalsymbols available in LATEX.

Chapter 4 adds in some bits and bobs about LATEX which are not essential,but very handy. Among other things you will learn how to includeeps graphics into your documents or how to add an index to yourpublication.

Page 6: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

vi Preface

It is important to read the chapters in sequential order. The book is notthat big after all. Make sure to carefully read the examples, because a greatpart of the information is contained in the various examples you will find allthrough out the book.

If you need to get hold of any LATEX related material, have a look in one ofthe CTAN ftp archives. For the US it is at ftp.shsu.edu, for Germany it isftp.dante.de and for the UK it is ftp.tex.ac.uk. If you are not in oneof these countries, choose the archive closest to you.

If you have ideas for something to be added, removed or altered in thisdocument, please let me know. I am especially interested in feedback fromLATEX novices about which bits of this intro are easy to understand andwhich could be explained better.

Tobias Oetiker <[email protected]>Deptartment of Electrical Engineering, Swiss Federal Institute ofTechnology

The current version of this document will be available onCTAN:/tex-archive/info/lshort

Page 7: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Contents

Thank you! iii

Preface v

1 Things You Need to Know 11.1 The Name of the Game . . . . . . . . . . . . . . . . . . . . . 1

1.1.1 TEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.1.2 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2.1 Author, Book Designer, and Typesetter . . . . . . . . 21.2.2 Layout Design . . . . . . . . . . . . . . . . . . . . . . 21.2.3 Advantages and Disadvantages . . . . . . . . . . . . . 3

1.3 LATEX Input Files . . . . . . . . . . . . . . . . . . . . . . . . . 41.3.1 Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.3.2 Special Characters . . . . . . . . . . . . . . . . . . . . 41.3.3 LATEX Commands . . . . . . . . . . . . . . . . . . . . 51.3.4 Comments . . . . . . . . . . . . . . . . . . . . . . . . . 5

1.4 Input File Structure . . . . . . . . . . . . . . . . . . . . . . . 61.5 The Layout of the Document . . . . . . . . . . . . . . . . . . 7

1.5.1 Document Classes . . . . . . . . . . . . . . . . . . . . 71.5.2 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . 71.5.3 Page Styles . . . . . . . . . . . . . . . . . . . . . . . . 10

1.6 Big Projects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

2 Typesetting Text 132.1 Linebreaking and Pagebreaking . . . . . . . . . . . . . . . . . 13

2.1.1 Justified Paragraphs . . . . . . . . . . . . . . . . . . . 132.1.2 Hyphenation . . . . . . . . . . . . . . . . . . . . . . . 14

2.2 Special Characters and Symbols . . . . . . . . . . . . . . . . . 152.2.1 Quotation Marks . . . . . . . . . . . . . . . . . . . . . 152.2.2 Dashes and Hyphens . . . . . . . . . . . . . . . . . . . 152.2.3 Ellipsis ( . . . ) . . . . . . . . . . . . . . . . . . . . . . . 152.2.4 Ligatures . . . . . . . . . . . . . . . . . . . . . . . . . 16

Page 8: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

viii CONTENTS

2.2.5 Accents and Special Characters . . . . . . . . . . . . . 162.3 International Language Support . . . . . . . . . . . . . . . . . 162.4 The Space between Words . . . . . . . . . . . . . . . . . . . . 172.5 Titles, Chapters, and Sections . . . . . . . . . . . . . . . . . . 182.6 Cross References . . . . . . . . . . . . . . . . . . . . . . . . . 202.7 Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.8 Emphasised Words . . . . . . . . . . . . . . . . . . . . . . . . 202.9 Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.9.1 Itemise, Enumerate, and Description . . . . . . . . . . 212.9.2 Flushleft, Flushright, and Center . . . . . . . . . . . . 222.9.3 Quote, Quotation, and Verse . . . . . . . . . . . . . . 222.9.4 Printing Verbatim . . . . . . . . . . . . . . . . . . . . 232.9.5 Tabular . . . . . . . . . . . . . . . . . . . . . . . . . . 24

2.10 Floating Bodies . . . . . . . . . . . . . . . . . . . . . . . . . . 252.11 Adding New Commands and Environments . . . . . . . . . . 28

2.11.1 New Commands . . . . . . . . . . . . . . . . . . . . . 282.11.2 New Environments . . . . . . . . . . . . . . . . . . . . 29

3 Typesetting Mathematical Formulae 313.1 General . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313.2 Grouping in Math Mode . . . . . . . . . . . . . . . . . . . . . 333.3 Building Blocks of a Mathematical Formula . . . . . . . . . . 333.4 Math Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . 363.5 Vertically Aligned Material . . . . . . . . . . . . . . . . . . . 363.6 Math Font Size . . . . . . . . . . . . . . . . . . . . . . . . . . 383.7 Describing Variables . . . . . . . . . . . . . . . . . . . . . . . 393.8 Theorems, Laws, . . . . . . . . . . . . . . . . . . . . . . . . . . 393.9 List of Mathematical Symbols . . . . . . . . . . . . . . . . . . 41

4 Specialities 494.1 Fonts and Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . 494.2 Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

4.2.1 Line Spacing . . . . . . . . . . . . . . . . . . . . . . . 514.2.2 Paragraph Formating . . . . . . . . . . . . . . . . . . 514.2.3 Horizontal Space . . . . . . . . . . . . . . . . . . . . . 524.2.4 Vertical Space . . . . . . . . . . . . . . . . . . . . . . 53

4.3 Page Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534.4 Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . 554.5 Indexing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564.6 Including EPS Graphics . . . . . . . . . . . . . . . . . . . . . 57

Page 9: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

List of Figures

1.1 A Minimal LATEX File . . . . . . . . . . . . . . . . . . . . . . 61.2 Example of a Realistic Journal Article . . . . . . . . . . . . . 7

4.1 Page Layout Parameters . . . . . . . . . . . . . . . . . . . . . 54

Page 10: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth
Page 11: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

List of Tables

1.1 Document Classes . . . . . . . . . . . . . . . . . . . . . . . . 81.2 Document Class Options . . . . . . . . . . . . . . . . . . . . . 81.3 Some of the Packages Distributed with LATEX . . . . . . . . . 91.4 The Predefined Page Styles of LATEX . . . . . . . . . . . . . . 10

2.1 Accents and Special Characters . . . . . . . . . . . . . . . . . 172.2 Float Placing Permissions . . . . . . . . . . . . . . . . . . . . 26

3.1 Math Mode Accents . . . . . . . . . . . . . . . . . . . . . . . 413.2 Lowercase Greek Letters . . . . . . . . . . . . . . . . . . . . . 413.3 Uppercase Greek Letters . . . . . . . . . . . . . . . . . . . . . 413.4 Binary Relations . . . . . . . . . . . . . . . . . . . . . . . . . 423.5 Binary Operators . . . . . . . . . . . . . . . . . . . . . . . . . 423.6 BIG Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 433.7 Arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.8 Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.9 Large Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . 433.10 Miscellaneous Symbols . . . . . . . . . . . . . . . . . . . . . . 443.11 Non-Mathematical Symbols . . . . . . . . . . . . . . . . . . . 443.12 AMS Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . 443.13 AMS Greek and Hebrwe . . . . . . . . . . . . . . . . . . . . . 443.14 AMS Binary Relations . . . . . . . . . . . . . . . . . . . . . . 453.15 AMS Arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.16 AMS Negated Binary Relations and Arrows . . . . . . . . . . 463.17 AMS Binary Operators . . . . . . . . . . . . . . . . . . . . . 463.18 AMS Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . 473.19 Math Alphabets . . . . . . . . . . . . . . . . . . . . . . . . . 47

4.1 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504.2 Font sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504.3 Math fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . 504.4 TEX Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534.5 Index Key Syntax Examples . . . . . . . . . . . . . . . . . . . 574.6 Key Names for graphicx Package . . . . . . . . . . . . . . . . 58

Page 12: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth
Page 13: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Chapter 1

Things You Need to Know

In the first part of this chapter you will get a short overview about the philosophyand history of LATEX2ε. The second part of the chapter focuses on the basicstructures of a LATEX document. After reading this chapter you should have arough knowledge of how LATEX works. When reading on, this will help you, tointegrate all the new information into the big picture.

1.1 The Name of the Game

1.1.1 TEX

TEX is a computer program by Donald E. Knuth [2]. It is aimed at typeset-ting text and mathematical formulae.

TEX is pronounced “Tech,” with a “ch” as in the German word “Ach”or in Scottish “Loch.” In an ASCII environment TEX becomes TeX.

1.1.2 LATEX

LATEX is a macro package which enables authors to typeset and print theirwork at the highest typographical quality, using a predefined, professionallayout. LATEX was originally written by Leslie Lamport [1]. It uses the TEXformatter as its typesetting engine.

Recently the LATEX package has been updated by the LATEX3 team, ledby Frank Mittelbach, to include some long-requested improvements and toreunify all the patched versions which have cropped up since the release ofLATEX 2.09 some years ago. To distinguish the new version from the old, itis called LATEX2ε. This documentation deals with LATEX2ε.

LATEX is pronounced “Lay-tech.” If you refer to LATEX in an ASCIIenvironment you type LaTeX. LATEX2ε is pronounced “Lay-tech two e” andtyped LaTeX2e.

Page 14: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2 Things You Need to Know

1.2 Basics

1.2.1 Author, Book Designer, and Typesetter

To publish something, authors give their typed manuscript to a publish-ing company. A book designer of the publishing company then decides thelayout of the document (column width, fonts, space before and after head-ings, . . . ). The book designer writes his instructions into the manuscriptand then gives it to a typesetter, who typesets the book according to theseinstructions.

A human book designer tries to find out what the author had in mindwhile writing the manuscript. He decides on chapter headings, citations,examples, formulae, etc. based on his professional knowledge and from thecontents of the manuscript.

In a LATEX environment, LATEX takes the role of the book designer anduses TEX as its typesetter. But LATEX is “only” a program and thereforeneeds more guidance. The author has to provide additional informationwhich describes the logical structure of his work. This information is writteninto the text as “LATEX commands.”

This is quite different from the WYSIWYG1 approach which most mod-ern word processors such as Word for Windows or WordPerfect take. Withthese applications, authors specify the document layout interactively whiletyping text into the computer. All along the way, they can see on the screenhow the final work will look when it is printed.

When using LATEX it is normally not possible to see the final outputwhile typing the text. But the final output can be previewed on the screenafter processing the file with LATEX. Then corrections can be made beforeactually sending the document to the printer.

1.2.2 Layout Design

Typographical design is a craft. Unskilled authors often commit seriousformatting errors by assuming that book design is mostly a question ofaesthetics—“If a document looks good artistically it is well designed.” Butas a document has to be read and not hung up in a picture gallery, thereadability and understandability is of much greater importance than thebeautiful look of it. Examples:

• The font size and numbering of headings have to be chosen to makethe structure of chapters and sections clear to the reader.

• The line length has to be short enough that it does not strain the eyesof the reader, while long enough to fill the page beautifully.

1What you see is what you get.

Page 15: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

1.2 Basics 3

With WYSIWYG systems, authors often generate aesthetically pleasingdocuments with very little or inconsistent structure. LATEX prevents suchformatting errors by forcing the author to declare the logical structure ofhis document. LATEX then chooses the most suitable layout.

1.2.3 Advantages and Disadvantages

A topic often discussed when people from the WYSIWYG world meet LATEXpeople, is “the advantages of LATEX over a normal word processor” or theopposite. The best thing you can do when such a discussion starts, is tokeep a low profile, as it often gets out of hand. But sometimes you cannotescape . . .

The main advantages of LATEX over normal word processors are the following:

• Professionally crafted layouts are available which make a documentreally look as if “printed.”

• The typesetting of mathematical formulae is supported in a convenientway.

• The user only needs to learn a few easy to understand commands,which specify the logical structure of a document. They almost neverneed to tinker with the actual layout of the document.

• Even complex structures such as footnotes, references, table of con-tents, and bibliographies can be generated easily.

• For many typographical tasks not directly supported by basic LATEX,there exist free add-on packages. For example, packages are availableto include PostScript graphics or to typeset bibliographies conform-ing to exact standards. Many of these add-on packages are describedin The LATEX Companion [3].

• LATEX encourages authors to write well structured texts because thisis how LATEX works—by specifying structure.

• TEX, the formatting engine of LATEX2ε, is highly portable and free.Therefore the system runs on almost any hardware platform available.

LATEX also has some disadvantages:

• More resources (memory, disk-space, computing power) are requiredto run a LATEX system than a simple word processor. But thingsare getting better, as Word for Windows 6.0 needs even more diskspace than a normal LATEX system. When it comes down to processorusage, LATEX beats any WYSIWYG system, as it only needs a lot of

Page 16: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

4 Things You Need to Know

CPU time when a document is actually processed, while WYSIWYGpackages hog the CPU all the time.

• Although within a predefined document layout some parameters canbe adjusted, the design of a whole new layout is difficult and takes alot of time.2

1.3 LATEX Input Files

The input for LATEX is a plain ASCII text file. You can create it with anytext editor. It contains the text of the document as well as the commandswhich tell LATEX how to typeset the text.

1.3.1 Spaces

“Whitespace” characters such as blank or tab are treated uniformly as“space” by LATEX. Several consecutive whitespace characters are treatedas one “space”. Whitespace at the start of a line is generally ignored and asingle linebreak is treated like a “space”.

An empty line between two lines of text defines the end of a paragraph.Several empty lines are treated the same as one empty line. The text belowis an example. On the right hand side is the text from the input file and onthe left hand side is the formatted output.

It does not matter whether you enterone or several spaces after a word.

An empty line starts a new para-graph.

It does not matter whether youenter one or several spacesafter a word.

An empty line starts a newparagraph.

1.3.2 Special Characters

The following symbols are reserved characters, that either have a specialmeaning under LATEX or are not available in all the fonts. If you enter themin your text directly, they will normally not print, but rather coerce LATEXto do things you did not intend.

$ & % # _ ~ ^ \

As you will see, these characters can be used in your documents all thesame by adding a prefix backslash:

2Rumour says, that this is one of the key elements which will be addressed in theupcoming LATEX3 system

Page 17: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

1.3 LATEX Input Files 5

$ & % # \$ \& \% \# \_ \ \

The other symbols and many more can be printed with special commandsin mathematical formulae or as accents.

1.3.3 LATEX Commands

LATEX commands are case sensitive and take one of the following two formats:

• They start with a backslash \ and then have a name consisting onlyof letters. Command names are terminated by a space, a number orany other ‘non-letter’.

• They consist of a backslash and exactly one special character.

LATEX ignores whitespace after commands. If you want to get a spaceafter a command, you have to put either and a blank or a special spacingcommand after the command name. The stops LATEX from eating up allthe space after the command name.

I read that Knuth divides the peopleworking with TEX into TEXniciansand TEXperts.Today is July 27, 1995.

I read that Knuth divides thepeople working with \TeX into\TeXnicians and \TeX perts.\\Today is \today.

Some commands need a parameter which has to be given between curlybraces after the command name. Some commands support optionalparameters which are added after the command name in square brackets [ ].The next example uses some LATEX commands. Don’t worry about them,they will be explained later.

You can lean on me! You can \textsllean on me!

Please, start a new line right here!Thank you!

Please, start a new lineright here!\linebreak[3]Thank you!

1.3.4 Comments

When LATEX encounters a % character while processing an input file, it ig-nores the rest of the present line. This is useful for adding notes to the inputfile, which will not show up in the printed version.

Page 18: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

6 Things You Need to Know

This is an example. This is an % stupid% Better: instructive <----example.

1.4 Input File Structure

When LATEX2ε processes an input file it expects it to follow a certain struc-ture. Thus every input file must start with the command

\documentclass...

This specifies what sort of document you intend to write. After that, youcan include commands which influence the style of the whole document oryou can load packages which add new features to the LATEX system. To loadsuch a package you use the command

\usepackage...

When all the setup work is done3, you start the body of the text withthe command

\begindocument

Now you enter the text mixed with some useful LATEX commands. Atthe end of the document you add the

\enddocument

command, which tells LATEX to call it a day. Anything which follows thiscommand will be ignored by LATEX.

Figure 1.1 shows the contents of a minimal LATEX2ε file. A slightly morecomplicated input file is given in Figure 1.2.

3The area between \documentclass and \begindocument is called preamble.

\documentclassarticle\begindocumentSmall is beautiful.\enddocument

Figure 1.1: A Minimal LATEX File

Page 19: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

1.5 The Layout of the Document 7

1.5 The Layout of the Document

1.5.1 Document Classes

The first information LATEX needs to know when processing an input file isthe type of document the author wants to create. This is specified with the\documentclass command.

\documentclass[options]class

Here class specifies the type of document to be created. Table 1.1 lists thedocument classes explained in this introduction. The LATEX2ε distributionprovides additional classes for other documents including letters and slides.The options parameter customises the behaviour of the document class. Theoptions have to be separated by commas. In Table 1.2 the most commonoptions for the standard document classes are listed.

Example: An input file for a LATEX document could start with the line

\documentclass[11pt,twoside,a4paper]article

it instructs LATEX to typeset the document as an article with a base font sizeof eleven points and to produce a layout suitable for double sided printingon a4 paper.

1.5.2 Packages

While writing your document, you will probably find that there are someareas where basic LATEX cannot solve your problem. If you want to include

\documentclass[a4paper,11pt]article\usepackagelatexsym\authorH.~Partl\titleMinimalism\frenchspacing\begindocument\maketitle\tableofcontents\sectionStartWell and here begins my lovely article.\sectionEnd\ldots and here it ends.\enddocument

Figure 1.2: Example of a Realistic Journal Article

Page 20: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

8 Things You Need to Know

Table 1.1: Document Classes

article for articles in scientific journals, presentations, short reports,program documentation, invitations, . . .

report for longer reports containing several chapters, small books, PhDtheses, . . .

book for real books

slide for slides. The class uses big sans serife letters.

Table 1.2: Document Class Options

10pt, 11pt, 12pt Sets the size of the main font for the document. Ifno option is specified, 10pt is assumed.

a4paper, letterpaper, . . . Defines the paper size. The default sizeis letterpaper. Besides that, a5paper, b5paper,executivepaper, and legalpaper can be specified.

fleqn Typesets displayed formulae left-aligned instead of centred.

leqno Places the numbering of formulae on the left hand sideinstead of the right.

titlepage, notitlepage Specifies whether a new page should bestarted after the document title or not. The article class doesnot start a new page by default, while report and book do.

twocolumn Instructs LATEX to typeset the document in two columns.

twoside, oneside Specifies whether double or single sided outputshould be generated. The classes article and report are singlesided and the book class is double sided by default.

openright, openany Makes chapters begin either only on righthand pages or on the next page available. This does not workwith the article class, as it does not know chapters. Thereport class by default starts chapters on the next page availableand the book class starts them on right hand pages.

Page 21: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

1.5 The Layout of the Document 9

graphics, coloured text or source code from a file into your document, youneed to enhance the capabilities of LATEX. Such enhancements are calledpackages. Packages are activated with the

\usepackage[options]package

command. Where package is the name of the package and options is a list ofkeywords which trigger special features in the package. Some packages comewith the LATEX2ε base distribution (See Table 1.3). Others are providedseparately. You may find more information on the packages installed atyour site in your Local Guide [4]. The prime source for information aboutLATEX is The LATEX Companion [3]. It contains descriptions of hundredsof packages along with information of how to write your own extensions toLATEX2ε.

Table 1.3: Some of the Packages Distributed with LATEX

doc Allows the documentation of LATEX programs.Described in doc.dtx and in The LATEX Companion [3].

exscale Provides scaled versions of the maths extension font.Described in ltexscale.dtx.

fontenc Specifies which font encoding LATEX should use.Described in ltoutenc.dtx.

ifthen Provides commands of the form‘if. . . then do. . . otherwise do. . . .’Described in ifthen.dtx and The LATEX Companion [3].

latexsym To access the LATEX symbol font, you should use thelatexsym package. Described in latexsym.dtx and in TheLATEX Companion [3]

makeidx Provides commands for producing indexes. Described insection 4.5 and in The LATEX Companion [3].

syntonly Processes a document without typesetting it.Described in syntonly.dtx and in The LATEX Compan-ion [3]. This is useful for quick error checking.

Page 22: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

10 Things You Need to Know

1.5.3 Page Styles

LATEX supports three predefined header/footer combinations—so-called pagestyles. The style parameter of the

\pagestylestyle

command defines which one to use. Table 1.4 lists the predefined page styles.

Table 1.4: The Predefined Page Styles of LATEX

plain prints the page numbers on the bottom of the page in the middleof the footer. This is the default page style.

headings prints the current chapter heading and the page number inthe header on each page while the footer remains empty. (This isthe style used in this document)

empty sets both the header and the footer to be empty.

It is possible to change the page style of the current page with the com-mand

\thispagestylestyle

In The LATEX Companion [3] there is a description how to create yourown headers and footers.

1.6 Big Projects

When working on big documents, you might want to split the input file intoseveral parts. LATEX has two commands which help you doing that.

\includefilename

you can use this command in the document body, to insert the contents ofanother file. Note that LATEX will start a new page before processing thematerial input from filename.

The second command can be used in the preamble. It allows you to

Page 23: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

1.6 Big Projects 11

instruct LATEX to only input some of the \included files.

\includeonlyfilename,filename,. . .

After this command is executed in the preamble of the document. Only\include commands for the filenames which are listed in the argument ofthe \includeonly command will be executed. Note that there is no spacebetween the filename and the comma.

Page 24: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth
Page 25: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Chapter 2

Typesetting Text

After reading the previous chapter you should know about the basic stuff aLATEX2ε document is made off. In this chapter I will fill in the remainingstructure you will need to know in order to produce real world material.

2.1 Linebreaking and Pagebreaking

2.1.1 Justified Paragraphs

Often books are typeset with each line having the same length. LATEX insertsthe necessary linebreaks and spaces between words by optimising the con-tents of a whole paragraph. If necessary it also hyphenates words that wouldnot fit comfortably on a line. How the paragraphs are typeset depends onthe document class. Normally the first line of a paragraph is indented andthere is no additional space between two paragraphs. Refer to section 4.2.2for more information.

In special cases it might be necessary to order LATEX to break a line:

\\ or \newline

start a new line without starting a new paragraph.

\\*

additionally prohibits a pagebreak after the forced linebreak.

\newpage

starts a new page.

Page 26: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

14 Typesetting Text

\linebreak[n], \nolinebreak[n], \pagebreak[n] and \nopagebreak[n]

do what their names say. They enable the author to influence their actions,with the optional argument n. It can be set to a number between zero tofour. By setting n to a value below 4 you leave LATEX the option of ignoringyour command if the result would look very bad.

LATEX always tries to produce the best linebreaks possible. If it cannotfind a way to break the lines in a manner which meets its high standards,it rather lets one line stick out on the right of the paragraph. LATEX thencomplains (“overfull hbox”) while processing the input file. This happensmost often when LATEX cannot find a suitable place to hyphenate a word. Bygiving the \sloppy command you can instruct LATEX to lower its standardsa little. It then prevents such over-long lines by increasing the inter-wordspacing — even if the final output is not optimal. In this case a warning(“underfull hbox”) is given to the user. In most cases the result does notlook too bad.

2.1.2 Hyphenation

LATEX hyphenates words whenever necessary. If the hyphenation algorithmdoes not find the correct hyphenation points you can remedy the situationby using the following commands, to tell TEX about the exception.

The command

\hyphenationword list

causes the words listed in the argument to be hyphenated only at the pointsmarked by “-”. This command should be given in the preamble of the inputfile and should only contain words built from normal letters. The case ofthe letters is ignored. The example below will allow “hyphenation” to behyphenated as well as “Hyphenation” and it prevents “FORTRAN”, “For-tran” and “fortran” from being hyphenated at all. No accented charactersor symbols are allowed in the argument.

Example:

\hyphenationFORTRAN Hy-phen-a-tion

The command \- inserts a discretionary hyphen into a word. This alsobecomes the only point hyphenation is allowed in this word. This commandis especially useful for words containing special characters (eg. accented char-acters), because LATEX does not automatically hyphenate words containingaccented characters.

I think this is: supercalifragilisticex-pialidocious

I think this is: su\-per\-cal\-%i\-frag\-i\-lis\-tic\-ex\-pi\-%al\-i\-do\-cious

Page 27: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.2 Special Characters and Symbols 15

Several words can be kept together on one line with the command

\mboxtext

It causes its argument be kept together under all circumstances.

My phone number will change soon.It will be 0116 291 2319.

The parameter filename should con-tain the name of the file.

My phone number will change soon.It will be \mbox0116 291 2319.

The parameter\mbox\emphfilename shouldcontain the name of the file.

2.2 Special Characters and Symbols

2.2.1 Quotation Marks

For quotation marks you should not use the " as on a typewriter. In pub-lishing there are special opening and closing quotation marks. In LATEX,use two ‘s on for opening quotation marks and two ’s for closing quotationmarks.

“Please press the ‘x’ key.” ‘‘Please press the ‘x’ key.’’

2.2.2 Dashes and Hyphens

LATEX knows four kinds of dashes. You can access three of these with dif-ferent numbers of consecutive dashes. The fourth kind is the mathematicalminus:

daughter-in-law, X-ratedpages 13–67yes—or no?0, 1 and −1

daughter-in-law, X-rated\\pages 13--67\\yes---or no? \\$0$, $1$ and $-1$

The names for these dashes are: - hyphen, -- en-dash, --- em-dash and$-$ minus sign.

2.2.3 Ellipsis ( . . . )

On a typewriter a comma or a period takes the same amount of space asany other letter. In book printing these characters occupy only a little spaceand are set very close to the preceding letter. Therefore you cannot enter

Page 28: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

16 Typesetting Text

“ellipsis” by just typing three dots, as the spacing would be wrong. Insteadthere is a special command for these dots. It is called

\ldots

Not like that ... but like that:New York, Tokyo, Budapest, . . .

Not like that ... but like that:\\New York, Tokyo, Budapest, \ldots

2.2.4 Ligatures

Some letter combinations are typeset not just by setting the different lettersone after the other, but actually by using special symbols.

ff fi fl ffi. . . instead of ff fi fl ffi . . .

These so-called ligatures can be prohibited by inserting a \mbox betweenthe two letters in question. This might be necessary with words built fromtwo words.

Not shelffulbut shelfful

Not shelfful\\but shelf\mboxful

2.2.5 Accents and Special Characters

LATEX supports the use of accents and special characters from many lan-guages. Table 2.1 shows all sorts of accents being applied to the letter o.Naturally other letters work too.

To place an accent on top of an i or a j, their dots have to be removed.This is accomplished by typing \i and \j.

Hotel, naıve, eleve,smørrebrød, ¡Senorita!,Schonbrunner Schloß Straße

H\^otel, na\"\i ve, \’el\‘eve,\\sm\o rrebr\o d, !‘Se\~norita!,\\Sch\"onbrunner Schlo\ssStra\ss e

2.3 International Language Support

If you need to write documents in languages other than English, LATEX mustapply different hyphenation rules in order to produce correct output.

For many languages, these changes can be accomplished by using thebabel package by Johannes Braams. To use this package, your LATEX sys-tem has to be specially configured. Your Local Guide [4] should give moreinformation on this.

Page 29: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.4 The Space between Words 17

If your system is already appropriately configured, you can activate thebabel package by adding the command

\usepackage[language]babel

after the \documentclass command. Which languages your system sup-ports should also be listed in the Local Guide.

For some languages babel also specifies new commands, which simplifythe input of special characters. The German language for example, containsa lot of umlauts (aou). With babel you can enter an o by typing "o insteadof \"o.

Some computer systems allow you to input special characters directlyfrom the keyboard. LATEX can handle such characters. Since the December1995 release of LATEX2ε, support for several input encodings is includedin the basic distribution of LATEX2ε. Check the inputenc package. Whenusing this package you should consider that other people might not be ableto display your input files on their computer, because they use a differentencoding. For example, the German umlaut a on a PC is encoded as 132 andon some Unix systems using ISO-LATIN 1 it is encoded as 228. Therefore,use this feature with care.

2.4 The Space between Words

To get a straight right margin in the output, LATEX inserts varying amountsof space between the words. At the end of a sentence it inserts slightly morespace, as this makes the text more readable. LATEX assumes that sentencesend with periods, question marks or exclamation marks. If a period followsan uppercase letter this is not taken as a sentence ending since periods after

Table 2.1: Accents and Special Characters

o \‘o o \’o o \^o o \~oo \=o o \.o o \"o

o \u o o \v o o \H o o \c oo. \d o o

¯\b o Äoo \t oo

œ \oe Œ \OE æ \ae Æ \AEa \aa a \aa A \AA

ø \o Ø \O Ãl \l ÃL \Lı \i \j ¡ !‘ ¿ ?‘

Page 30: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

18 Typesetting Text

uppercase letters are normally for abbreviations.Any exception from these assumptions has to be specified by the au-

thor. A backslash in front of a space generates a space which will not beenlarged. A tilde ‘~’ character generates a space which cannot be enlargedand which additionally prohibits a linebreak. The command \@ in front of aperiod specifies, that this period terminates a sentence even when it followsa uppercase letter.

Mr. Smith was happy to see hercf. Fig. 5I like BASIC. What about you?

Mr.~Smith was happy to see her\\cf.~Fig.~5\\I like BASIC\@. What about you?

The additional space after periods can be disabled with the command

\frenchspacing

which tells LATEX not to insert any more space after a period than afterordinary character. This is very common in non-English languages. In thiscase the command \@ is not necessary.

2.5 Titles, Chapters, and Sections

To help the reader find his or her way through your work, you should divideit into chapters, sections, and subsections. LATEX supports this with specialcommands which take the section title as their argument. It is up to you touse them in the correct order.

For the article class the following sectioning commands are available:

\section... \paragraph...\subsection... \subparagraph...\subsubsection... \appendix

For the report and the book class you can use two additional sectioningcommands:

\part... \chapter...

As the article class does not know about chapters, it is quite easyto add articles as chapters to a book. The spacing between sections, thenumbering and the font size of the titles will be set automatically by LATEX.

Two of the sectioning commands are a bit special:

• The \part command does not influence the numbering sequence ofchapters.

• The \appendix command does not take an argument. It just changesthe chapter1 numbering to letters.

1For the article style it changes the section numbering

Page 31: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.5 Titles, Chapters, and Sections 19

LATEX creates a table of contents by taking the section headings and pagenumbers from the previous run of the document. The command

\tableofcontents

expands to a table of contents at the place where it is issued. A new doc-ument has to be processed (“LATEXed”) twice to get a correct table of con-tents. In some circumstances it might be necessary to compile the documenta third time. LATEX will tell you when this is necessary.

All sectioning commands listed above also exist as “starred” versions.A “starred” version of a command is built by adding a star * after thecommand name. They generate section headings which will not show upin the table of contents and which will not get numbered. The command\sectionHelp for example would become \section*Help.

Normally the section headings show up in the table of contents exactlyas they were entered in the text. Sometimes this is not possible, becausethe heading is too long to fit into the table of contents. The entry for thetable of contents can therefore be specified as an optional argument beforethe actual heading.

\chapter[Read it! It’s Exciting]This is a very longand especially boring title

The title of the whole document is generated by issuing a

\maketitle

command. The contents of the title has to be defined by the commands

\title..., \author... and optionally \date...

before calling \maketitle. In the argument of \authors you can supplyseveral names separated by \and commands.

An example of some of the above mentioned commands can be found inFigure 1.2 on page 7.

Apart from the sectioning commands explained above, LATEX2ε intro-duced 3 additional commands, for use with the book class.

\frontmatter, \mainmatter and \backmatter

They are useful for dividing your publication. The commands alter chap-ter headings, and page numbering to work as you would expect it in a book.

Page 32: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

20 Typesetting Text

2.6 Cross References

In books, reports and articles there are often cross references to figures,tables and special segments of text. LATEX provides the following commandsfor cross referencing

\labelmarker, \refmarker and \pagerefmarker

Where marker is an identifier chosen by the user. LATEX replaces \refby the number of the section, subsection, figure, table, or theorem wherethe corresponding \label command was issued. \pageref prints the pagenumber of the corresponding \label command. Here also the numbers fromthe previous run are used.

A reference to this subsection lookslike: “see section 2.6 on page 20.”

A reference to this subsection\labelsec:this looks like:‘‘see section~\refsec:this onpage~\pagerefsec:this.’’

2.7 Footnotes

With the command

\footnotefootnote text

a footnote will be printed at the foot of the current page.

Footnotesa are often used by peopleusing LATEX.

aThis is a footnote

Footnotes\footnoteThisis a footnote are often used

by people using \LaTeX.

2.8 Emphasised Words

In manuscripts produced by typewriter, important words get underlined. Inprinted books these words are emphasised. The command to switch to anemphasised font is called

\emphtext

Its argument is the text to be emphasised.

Page 33: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.9 Environments 21

If you use emphasising in an alreadyemphasised text, then LATEX uses anupright font for emphasising.

\emphIf you use\emphemphasising in analready emphasised text, then\LaTeX uses an\emphupright font foremphasising.

2.9 Environments

To typeset special purpose text, LATEX defines many different environmentsfor all sorts of formatting:

\beginname text \endname

Where name is the name of the environment. Environments can be calledseveral times within each other as long as the calling order is maintained.

\beginaaa...\beginbbb...\endbbb...\endaaa

In the following sections all important environments are explained.

2.9.1 Itemise, Enumerate, and Description

The itemize environment is suitable for simple lists, the enumerate en-vironment for enumerated lists, and the description environment for de-scriptions.

1. You can mix the list environ-ments to your taste:

• But it might start to looksilly.

• If you over-do it.

2. Therefore remember:

Stupid things will not becomesmart because they are ina list.

Smart things though, can bepresented beautifully in alist.

\beginenumerate\item You can mix the listenvironments to your taste:\beginitemize\item But it might start tolook silly.\item If you over-do it.\enditemize\item Therefore remember:\begindescription\item[Stupid] things will notbecome smart because they arein a list.\item[Smart] things though, can bepresented beautifully in a list.\enddescription\endenumerate

Page 34: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

22 Typesetting Text

2.9.2 Flushleft, Flushright, and Center

The environments flushleft and flushright generate paragraphs whichare either left or right aligned. The center environment generates centredtext. If you do not issue \\ to specify linebreaks, LATEX will automaticallydetermine linebreaks.

This text isleft aligned. LATEX is not trying tomake each line the same length.

\beginflushleftThis text is\\ left aligned.\LaTeX is not trying to makeeach line the same length.\endflushleft

This text is rightaligned. LATEX is not trying to make

each line the same length.

\beginflushrightThis text is right\\ aligned.\LaTeX is not trying to makeeach line the same length.\endflushright

At the centreof the earth

\begincenterAt the centre\\of the earth\endcenter

2.9.3 Quote, Quotation, and Verse

The quote environment is useful for quotes, important phrases and exam-ples.

A typographical rule of thumb for theline length is:

No line should containmore than 66 characters.

That’s why multicolumn print is of-ten used in newspapers.

A typographical rule of thumbfor the line length is:\beginquoteNo line should contain more than66~characters.\endquoteThat’s why multicolumn print isoften used in newspapers.

There are two similar environments: the quotation and the verse en-vironments. The quotation environment is useful for longer quotes goingover several paragraphs. The verse environment is useful for poems wherethe line breaks are important. The lines are separated by issuing a \\ atthe end of a line and a empty line after each verse.

Page 35: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.9 Environments 23

I know only one English poem byheart. It is about Humpty Dumpty.

Humpty Dumpty sat ona wall:

Humpty Dumpty had agreat fall.

All the King’s horsesand all the King’smen

Couldn’t put Humptytogether again.

I know only one English poem byheart. It is about Humpty Dumpty.\beginflushleft\beginverseHumpty Dumpty sat on a wall:\\Humpty Dumpty had a great fall.\\All the King’s horses and allthe King’s men\\Couldn’t put Humpty togetheragain.\endverse\endflushleft

2.9.4 Printing Verbatim

Text which is enclosed between \beginverbatim and \endverbatimwill be directly printed, as if it was typed on a typewriter, with all linebreaksand spaces, without any LATEX command being executed.

Within a paragraph, similar functionality can be accessed with

\verb+text+

The + is just an example delimiter character. You can use any characterexcept letters, * or blank. Many LATEX examples in this booklet are typesetwith this command.

The \ldots command . . .

10 PRINT "HELLO WORLD ";20 GOTO 10

The \verb|\ldots| command \ldots

\beginverbatim10 PRINT "HELLO WORLD ";20 GOTO 10\endverbatim

theÃstarredÃversionÃoftheÃÃÃÃÃÃverbatimenvironmentÃemphasisestheÃspacesÃÃÃinÃtheÃtext

\beginverbatim*the starred version ofthe verbatimenvironment emphasisesthe spaces in the text\endverbatim*

The \verb command can be used in a similar fashion with a star:

likeÃÃÃthisÃ:-)Ã \verb*|like this :-) |

The verbatim environment and the \verb command may not be usedwithin parameters of other commands.

Page 36: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

24 Typesetting Text

2.9.5 Tabular

The tabular environment can be used to typeset beautiful tables withoptional horizontal and vertical lines. LATEX determines the width of thecolumns automatically.

The table spec argument of the

\begintabulartable spec

command defines the format of the table. Use an l for a column of leftaligned text, r for right aligned text and c for centred text, pwidth for acolumn containing justified text with linebreaks, and | for a vertical line.

Within a tabular environment & jumps to the next column, \\ starts anew line and \hline inserts an horizontal line.

7C0 hexadecimal3700 octal

11111000000 binary1984 decimal

\begintabular|r|l|\hline7C0 & hexadecimal \\3700 & octal \\11111000000 & binary \\\hline \hline1984 & decimal \\\hline\endtabular

Welcome to Boxy’s paragraph.We sincerely hope you’ll all en-joy the show.

\begintabular|p4.7cm|\hlineWelcome to Boxy’s paragraph.We sincerely hope you’llall enjoy the show.\\\hline\endtabular

With the @... construct it is possible to specify the column separator.This command kills the intercolumn space and replaces it with whatever isincluded in the curly braces. One common use for this command is ex-plained below in the decimal alignment problem. Another possible usage isto suppress leading space in a table with @.

no leading space \begintabular@ l @\hlineno leading space\\\hline\endtabular

Page 37: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.10 Floating Bodies 25

leading space left and right \begintabularl\hlineleading space left and right\\\hline\endtabular

Since there is no built-in way to align numeric columns on a decimalpoint2, we can “cheat” and do it by using two columns: a right-aligned inte-ger and a left-aligned fraction. The @ command in the \begintabularline replaces the normal intercolumn spacing with just a “.”, giving the ap-pearance of a single, decimal-point-justified column. Don’t forget to replacethe decimal point in your numbers with a column separator (&)! A columnlabel can be placed above our numeric “column” by using the \multicolumncommand.

Pi expression Valueπ 3.1416ππ 36.46

(ππ)π 80662.7

\begintabularc r @. lPi expression &\multicolumn2cValue \\\hline$\pi$ & 3&1416 \\$\pi^\pi$ & 36&46 \\$(\pi^\pi)^\pi$ & 80662&7 \\\endtabular

2.10 Floating Bodies

Today most publications contain a lot of figures and tables. These elementsneed special treatment because they cannot be broken across pages. Onemethod would be to start a new page every time a figure or a table is toolarge to fit on the present page. This approach would leave pages partiallyempty which looks very bad.

The solution to this problem is to ‘float’ any figure or table, which doesnot fit on the current page, to a later page while filling the current page withbody text. LATEX offers two environments for floating bodies. One for tablesand one for figures. To take full advantage of these two environments it isimportant to understand approximately how LATEX handles floats internally.Otherwise floats may become a major source of frustration because LATEXnever puts them where you want them to be.

Let’s first have a look at the commands LATEX supplies for floats:

2If the ‘tools’ bundle is installed on your system, have a look at the dcolumn package

Page 38: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

26 Typesetting Text

Any material enclosed in a figure or table environment will be treatedas floating matter. Both float environments support an optional parameter

\beginfigure[placement specifier] or \begintable[placement specifier]

called the placement specifier. This parameter is used to tell LATEX aboutthe locations the float is allowed to be moved to. A placement specifier isconstructed by building a string of float placing permissions. See Table 2.2.

A table could be started with the following line e.g.

\begintable[!hbp]

The placement specifier [!hbp] allows LATEX to place the table right here(h) or at the bottom (b) of some page or on a special floats page (p) andall that even if it does not look that good (!). If no placement specifier isgiven, the standard classes assume [tbp].

LATEX will place every float it encounters, according to the placementspecifier supplied by the author. If a float cannot be placed on the currentpage it is deferred either to the figures or the tables queue3. When a newpage is started, LATEX first checks if it is possible to fill a special ‘float’ pagewith floats from the queues. If this is not possible, the first float on eachqueue is treated as if they had just occurred in the text: LATEX tries againto place them according to their respective placement specifiers (except ‘h’which is no longer possible). Any new floats occurring in the text get placedinto the appropriate queues. LATEX strictly maintains the original order ofappearance for each type of float.

That’s why a figure which cannot be placed, pushes all the further figuresto the end of the document. Therefore:

If LATEX is not placing the floats as you expected, it is often onlyone float jamming one of the two float queues.

3These are fifo - ‘first in first out’ queues!

Table 2.2: Float Placing Permissions

Spec Permission to place the float . . .h here at the very place in the text where it occurred. This is

useful mainly for small floats.t at the top of a pageb at the bottom of a pagep on a special page containing only floats.! without considering most of the internal parametersa which

could stop this float from being placed.

aSuch as the maximum number of floats allowed on one page

Page 39: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.10 Floating Bodies 27

Having explained the difficult bit, there are some more things to mentionabout the table and figure environments. With the

\captioncaption text

command you can define a caption for the float. A running number and thestring “Figure” or “Table” will be added by LATEX.

The two commands

\listoffigures and \listoftables

operate analogously to the \tableofcontents command, printing a listof figures or tables respectively. In these lists, the whole caption will berepeated. If you tend to use long captions, you must have a shorter versionof the caption going into the lists. This is accomplished by entering theshort version in brackets after the \caption command.

\caption[Short]LLLLLoooooonnnnnggggg

With \label and \ref you can create a reference to a float within yourtext.

The following example draws a square and inserts it into the document.You could use this if you wanted to reserve space for images you are goingto paste into the finished document.

Figure~\refwhite is an example of Pop-Art.\beginfigure[!hbp]\makebox[\textwidth]\framebox[5cm]\rule0pt5cm\captionFive by Five in Centimetres \labelwhite\endfigure

In the example above4 LATEX will try really hard (!) to place the figure righthere (h). If this is not possible, it tries to place the figure at the bottom (b)of the page. Failing to place the figure on the current page, it determines ifit is possible to create a float page containing this figure and maybe sometables from the tables queue. If there is not enough material for a specialfloat page, LATEX starts a new page and once more treats the figure as if ithad just occurred in the text.

Under certain circumstances it might be necessary to use the

\clearpage

command. It orders LATEX to immediately place all floats remaining in thequeues and then start a new page.

4assuming the figure queue is empty

Page 40: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

28 Typesetting Text

Later in this introduction you will learn how to include PostScript draw-ings into your LATEX2ε documents.

2.11 Adding New Commands and Environments

In the first chapter, I explained that LATEX needs information about thelogical structure of the text to pick the right layout. This is a neat idea, butin practice you often get to the limits of this, because LATEX just does nothave a specialised environment or command for your exact purpose.

One solution is to use several LATEX commands to produce the layoutyou have in mind. If you have to do this once, then there is no problem, butif it occurs repeatedly, it takes a lot of time. If you ever want to change thelayout you have to work through the whole input file and edit all the itemsin question.

To solve this problem, LATEX allows you to define your own commandsand environments to the language.

2.11.1 New Commands

To add your own commands, use the

\newcommandname[num]definition

command. Basicly, the command requires two arguments. The name ofthe command you want to create and the definition of the command. Thenum argument in square brackets is optional. You can use it to create newcommands which themselves take up to 9 arguments.

The following two examples should help you to get the idea. The firstexample defines a new command called \tnss this is short for “The Not SoShort Introduction to LATEX2ε”. Such a command could come in handy ifyou have to write the title of this book over and over again.

“The not so Short Introduction toLATEX2ε” . . . “The not so Short In-troduction to LATEX2ε”

\newcommand\tnssThe not so Short Introduction

to \LaTeXe% in the document body :‘‘\tnss’’ \ldots ‘‘\tnss’’

The next example illustrates how to use the num argument. The #1sequence gets replace by the argument you specify. If you wanted to usemore than one argument, use #2 and so on.

Page 41: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

2.11 Adding New Commands and Environments 29

• The not so Short Introductionto LATEX2ε

• The very Short Introduction toLATEX2ε

\newcommand\txsit[1]The \emph#1 ShortIntroduction to \LaTeXe

% in the document body:\beginitemize\item \txsitnot so\item \txsitvery\enditemize

LATEX will not allow you to create a new command which already exists.If you explicitly want to override an existing command you have to usethe \renewcommand. Apart from its name, it uses the same syntax as the\newcommand command. In certain cases you might also want to use the\providecommand command. It works like \newcommand, but if the newcommand is already defined, LATEX2ε just ignores it.

2.11.2 New Environments

Analogously to the \newcommand command there is a command to createyour own environments. When writing this introduction, I have createdspecial environments for the structures I used repeatedly through out theintroduction: “examples”, “bits of code” and “command definition boxes”.The \newenvironment command uses the following syntax:

\newenvironmentname[num]beforeafter

Like the \newcommand command, you can use \newenvironment withan optional argument and without. The material specified in the beforeargument is processed before the text in the environment gets processed.The material in the after argument gets processed when the \endnamecommand is encountered.

The example below illustrates the usage of the \newenvironment com-mand.

My humble subjects . . . \newenvironmentking\beginquote\endquote

% use this in the body part\beginkingMy humble subjects \ldots\endking

The num argument is used the same way as in the \newcommand com-mand. LATEX makes sure that you do not define an environment whichalready exists. If you ever want to change an existing command, you canuse the \renewenvironment command. It uses the same syntax as the\newenvironment command.

Page 42: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth
Page 43: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Chapter 3

Typesetting MathematicalFormulae

Now you are ready! In this chapter we will attack the main strength of TEX:mathematical typesetting. But be warned, this chapter only scratches the sur-face. While the things explained here are sufficient for many people, don’tdespair if you can’t find a solution to your mathematical typesetting needs. Itis highly likely that your problem is addressed in AMS-LATEX2ε

1 or some otherpackage.

3.1 General

LATEX has a special mode for typesetting mathematics. Mathematical textwithin a paragraph is entered between \( and \), between $ and $ or between\beginmath and \endmath.

Add a squared and b squared to get csquared. Or using a more mathemat-ical approach: c2 = a2 + b2

Add $a$ squared and $b$ squaredto get $c$ squared. Or usinga more mathematical approach:$c^2=a^2+b^2$

TEX is pronounced as τεχ.

100 m3 of water

This comes from my ♥

\TeX is pronounced as$\tau\epsilon\chi$.\\[6pt]100~m$^3$ of water\\[6pt]This comes from my $\heartsuit$

Larger mathematical equations or formulae are preferably typeset onseparate lines. Therefore you enclose them between \[ and \] or between\begindisplaymath and \enddisplaymath. This produces formulae

1CTAN:/tex-archive/macros/latex/packages/amslatex

Page 44: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

32 Typesetting Mathematical Formulae

which are not enumerated. If you want LATEX to enumerate them, you canuse the equation environment.

Add a squared and b squared to get csquared. Or using a more mathemat-ical approach:

c2 = a2 + b2

And just one more line.

Add $a$ squared and $b$ squaredto get $c$ squared. Or usinga more mathematical approach:\begindisplaymathc^2=a^2+b^2\enddisplaymathAnd just one more line.

With \label and \ref you can reference an equation within the text.

ε > 0 (3.1)

From (3.1) we gather . . .

\beginequation \labeleq:eps\epsilon > 0\endequationFrom (\refeq:eps) we gather\ldots

There are differences between math mode and text mode. For example,in math mode:

1. Most spaces and linebreaks do not have any significance, as all spacesare either derived logically from the mathematical expressions or haveto be specified using special commands such as \,, \quad or \qquad.

∀x ∈ R : x2 ≥ 0 (3.2) \beginequation\forall x \in \mathbfR:\qquad x^2 \geq 0\endequation

2. Empty lines are not allowed. Only one paragraph per formula.

3. Each letter is considered to be the name of a variable and will betypeset as such. If you want to typeset normal text within a formula(normal upright font and normal spacing) then you have to enter thetext using the \textrm... commands.

x2 ≥ 0 for all x ∈ R (3.3)\beginequationx^2 \geq 0\qquad\textrmfor all x\in\mathbfR\endequation

Page 45: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.2 Grouping in Math Mode 33

3.2 Grouping in Math Mode

Most math mode commands act only on the next character. So if you wantseveral characters affected by a command you have to group them togetherusing curly braces: ....

ax + y 6= ax+y (3.4) \beginequationa^x+y \neq a^x+y\endequation

3.3 Building Blocks of a Mathematical Formula

In this section the most important commands used in mathematical type-setting will be described. For a list of all symbols available take a look atsection 3.9 on page 41.

Lowercase Greek letters are entered as \alpha, \beta, \gamma, . . . ,uppercase letters2 are entered as \Gamma, \Delta, . . .

λ, ξ, π, µ, Φ, Ω $\lambda,\xi,\pi,\mu,\Phi,\Omega$

Exponents and Subscripts can be specified using the ^ and the _character.

a1 x2 e−αt a3ij

ex2 6= ex2

$a_1$ \qquad $x^2$ \qquad$e^-\alpha t$ \qquad$a^3_ij$\\$e^x^2 \neq e^x^2$

The square root sign is entered as \sqrt, the nth root is generatedwith \sqrt[n]. The size of the root sign is determined automatically byLATEX.

√x

√x2 +

√y 3

√2 $\sqrtx$ \qquad

$\sqrt x^2+\sqrty $\qquad $\sqrt[3]2$

The commands \overline and \underline create horizontal linesdirectly over or under an expression.

m + n $\overlinem+n$

2There is no uppercase Alpha defined in LATEX2ε because it looks the same as a normalroman A. Once the new math coding is done, things will change.

Page 46: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

34 Typesetting Mathematical Formulae

The commands \overbrace and \underbrace create long horizontalbraces over or under an expression.

a + b + · · ·+ z︸ ︷︷ ︸26

$\underbrace a+b+\cdots+z _26$

To add mathematical accents such as small arrows or tilde signs to vari-ables you can use the commands given in table 3.1. Wide hats and tildes,covering several characters are generated with \widetilde and \widehat.With the ’ symbol you enter a dash.

y = x2 y′ = 2x y′′ = 2\begindisplaymathy=x^2\qquad y’=2x\qquad y’’=2\enddisplaymath

Often vectors are specified by adding small arrow symbols on top of avariable. This is done with the \vec command. To denote the vector from Ato B the two commands \overrightarrow and \overleftarrow are useful.

~a−→AB

\begindisplaymath\vec a\quad\overrightarrowAB\enddisplaymath

Names of log-like functions are often typeset in an upright font and notitalic as variables. Therefore LATEX supplies the following commands totypeset the most important function names:

\arccos \cos \csc \exp \ker \limsup \min \sinh\arcsin \cosh \deg \gcd \lg \ln \Pr \sup\arctan \cot \det \hom \lim \log \sec \tan\arg \coth \dim \inf \liminf \max \sin \tanh

limn→0

sin x

x= 1

\[\lim_n \rightarrow 0\frac\sin xx=1\]

For the modulo function there are two commands: \bmod for the binaryoperator “a mod b” and \pmod for expressions such as “x ≡ a (mod b).”

A built-up fraction is typeset with the \frac...... command.Often the slashed form 1/2 is preferable, because it looks better for smallamounts of ‘fraction material.’

Page 47: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.3 Building Blocks of a Mathematical Formula 35

1 12 hours

x2

k + 1x

2k+1 x1/2

$1\frac12$~hours\begindisplaymath\frac x^2 k+1 \qquadx^ \frac2k+1 \qquadx^ 1/2 \enddisplaymath

To typeset binomial coefficients or similar structures you can use eitherthe command ... \choose ... or ... \atop .... The second com-mand produces the same output as the first one, but without braces.

(n

k

)x

y + 2

\begindisplaymathn \choose k\qquad x \atop y+2\enddisplaymath

The integral operator is generated with \int, the sum operatorwith \sum. The upper and lower limits are specified with ^ and _ as withsubscripts and superscripts.

n∑

i=1

∫ π2

0

\begindisplaymath\sum_i=1^n \qquad\int_0^\frac\pi2 \qquad\enddisplaymath

For braces and other delimiters there exist all types of symbols in TEX(e.g. [ 〈 ‖ l). Round and square braces can be entered with the corre-sponding keys, curly braces with \, all other delimiters are generated withspecial commands (eg. \updownarrow). For a list of all delimiters availble,check table 3.8 on page 43.

a, b, c 6= a, b, c\begindisplaymatha,b,c\neq\a,b,c\\enddisplaymath

If you put the command \left in front of an opening delimiter or \rightin front of a closing delimiter, TEX will automatically determine the correctsize of the delimiter.

1 +(

11− x2

)3\begindisplaymath1 + \left( \frac1 1-x^2

\right) ^3\enddisplaymath

In some cases it is necessary to specify the correct size of a mathematicaldelimiter by hand, therefore you can use the commands \big, \Big, \bigg

Page 48: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

36 Typesetting Mathematical Formulae

and \Bigg as prefixes to most delimiter commands3.

((x + 1)(x− 1)

)2

((((

∥∥∥∥∥∥∥∥∥∥∥∥∥∥

$\Big( (x+1) (x-1) \Big) ^2$\\$\big(\Big(\bigg(\Bigg($\quad$\big\\Big\\bigg\\Bigg\$\quad$\big\|\Big\|\bigg\|\Bigg\|$

To enter three dots into a formula you can use several commands.\ldots typesets the dots on the baseline, \cdots sets them centred. Besidethat there are the commands \vdots for vertical and \ddots for diagonaldots. In section 3.5 you can find another example.

x1, . . . , xn x1 + · · ·+ xn

\begindisplaymathx_1,\ldots,x_n \qquadx_1+\cdots+x_n\enddisplaymath

3.4 Math Spacing

If the spaces within formulae chosen by TEX are not satisfactory, they can beadjusted by inserting special spacing commands. The most important are:\, for a tiny space, \Ã for a medium sized space ( Ã stands for a “space”character), \quad and \qquad for large spaces and \! which shrinks a space.

∫∫

D

dx dy instead of∫ ∫

D

dxdy

\begindisplaymath\int\!\!\!\int_D dx\,dy \quad\textrminstead of \quad\int\int_D dx dy\enddisplaymath

3.5 Vertically Aligned Material

To typeset arrays, use the array environment. It works somewhat similarto the tabular environment. The \\ command is used to break the lines.

3These commands do not work as expected if a size changing command has been used,or the 11pt or 12pt option has been specified. Use the exscale or amstex packages tocorrect this behaviour

Page 49: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.5 Vertically Aligned Material 37

X =

x11 x12 . . .x21 x22 . . ....

.... . .

\begindisplaymath\mathbfX =\left( \beginarraycccx_11 & x_12 & \ldots \\x_21 & x_22 & \ldots \\\vdots & \vdots & \ddots\endarray \right)\enddisplaymath

The array environment can also be used to typeset which have one bigdelimiter by using a “.” as a invisible \right delimiter:

y =

a if d > cb + x in the morningl all day long

\begindisplaymathy = \left\ \beginarraylla & \textrmif $d>c$\\b+x & \textrmin the morning\\l & \textrmall day long\endarray \right.

\enddisplaymath

For formulae running over several lines or for equation systems you canuse the environments eqnarray and eqnarray* instead of equation. Ineqnarray each line gets an equation number. In the eqnarray* no linenumbers are produced.

The eqnarray and the eqnarray* environments work like a 3-columntable of the form rcl, where the middle column can be used for the equalsign or the not-equal sign. The \\ command breaks the lines.

f(x) = cos x (3.5)f ′(x) = − sin x (3.6)∫ x

0

f(y)dy = sin x (3.7)

\begineqnarrayf(x) & = & \cos x \\f’(x) & = & -\sin x \\\int_0^x f(y)dy &= & \sin x

\endeqnarray

Long equations will not be automatically divided into neat bits. Theauthor has to specify where to break them and how much to indent. Thefollowing two methods are the most common ones used to achieve this.

sinx = x− x3

3!+

x5

5!−

− x7

7!+ · · · (3.8)

\begineqnarray\sin x & = & x -\fracx^33!

+\fracx^55!-\nonumber\\

& & -\fracx^77!+\cdots\endeqnarray

Page 50: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

38 Typesetting Mathematical Formulae

cos x = 1− x2

2!+

+x4

4!− x6

6!+ · · · (3.9)

\begineqnarray\lefteqn \cos x = 1

-\fracx^22! + \nonumber\\

& & +\fracx^44!-\fracx^66!+\cdots

\endeqnarray

The \nonumber command causes LATEX not to generate a number forthis equation.

3.6 Math Font Size

In math mode TEX selects the font size according to context. Superscriptsfor example get typeset in a smaller font. If you want to add roman text to anequation and use the \textrm command, the font size switching mechanismwill not work, as \textrm temporarily escapes to text mode. Use \mathrminstead to keep the size switching mechanism active. But pay attention,\mathrm will only work well on short items. Spaces are still not active andaccented characters do not work4.

2nd 2nd (3.10) \beginequation2^\textrmnd \quad2^\mathrmnd\endequation

Sometimes you need to tell LATEX about the correct font size nevertheless.In math mode the fontsize is set with the four commands:

\displaystyle (123), \textstyle (123), \scriptstyle (123) and\scriptscriptstyle (123).

corr(X,Y ) =

n∑

i=1

(xi − x)(yi − y)

√√√√n∑

i=1

(xi − x)2n∑

i=1

(yi − y)2

\begindisplaymath\mathrmcorr(X,Y)=\frac\displaystyle\sum_i=1^n(x_i-\bar x)(y_i-\bar y)

\displaystyle\sqrt\sum_i=1^n(x_i-\bar x)^2

\sum_i=1^n(y_i-\bar y)^2\enddisplaymath

4The AMS-LATEX package makes the \textrm command work with size changing.

Page 51: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.7 Describing Variables 39

3.7 Describing Variables

For some formulae you might want to add a section after the formula whereyou describe the variables used in the expression. The following exampleshould help you to get this done.

a2 + b2 = c2

Where: a, b - are adjunct to the rightangle of a right-angled triangle.

c - is the hypotenuse of thetriangle.

\begindisplaymatha^2+b^2=c^2\enddisplaymath\settowidth\parindent

Where:\

\makebox[0pt][r]Where:\ $a$, $b$ - are

adjunct to the right angleof a right-angled triangle.

$c$ - is the hypotenuse ofthe triangle.

If you often need to typeset material like this, now the time is rightto try out the \newenvironment command. Use it to create a specialisedenvironment for describing variables. Check the description at the end ofthe previous chapter.

3.8 Theorems, Laws, . . .

When writing mathematical documents, you probably need a way to type-set “Lemmas”, “Definitions”, “Axioms” and simmilar structures. LATEXsupports this with the command

\newtheoremname[counter]text[section]

The name argument is a short keyword used to identify the “theorem”.Whith the text argument you define the actual name of the “theorem” whichwill be printed in the final document.

The arguments in square brackets are optional. They are both used tospecify the numbering used on the “theorem”. With the counter argumentyou can specify the name of a previously declared “theorem”. The new“theorem” will then be numbered in the same sequence. The section argu-ment allows you to specify the sectional unit within which you want your“theorem” to be numbered.

After executing the \newtheorem command in the preamble of your doc-ument, you can use the following command within the document.

Page 52: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

40 Typesetting Mathematical Formulae

\beginname[text]This is my interesting theorem\endname

This should be enough theory. The following examples will hopefullyremove the final remains of doubt, and make it clear that the \newtheoremenvironment is way to complex to understand.

Law 1 Don’t hide in the witness box

Jury 2 (The Twelve) It could beyou! So beware and see law 1

Law 3 No, No, No

% definitions for the document% preamble\newtheoremlawLaw\newtheoremjury[law]Jury%in the document\beginlaw \labellaw:boxDon’t hide in the witness box\endlaw\beginjury[The Twelve]It could be you! So beware andsee law \reflaw:box\endjury\beginlawNo, No, No\endlaw

The “Jury” theorem uses the same counter as the “Law” theorem. There-fore, it gets a number which is in sequence with the other “Laws”. Theargument in square brackets is used to specify a title or something similarfor the theorem.

Murphy 3.8.1 What can go wrong,will go wrong.

\newtheoremmurMurphy[section]\beginmur What can go wrong,will go wrong. \endmur

The “Murphy” theorem gets a number which is linked to the numberof the current section. You could also use another unit, like chapter orsubsection for example.

Page 53: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.9 List of Mathematical Symbols 41

3.9 List of Mathematical Symbols

In the following tables you find all the symbols normally accessible frommath mode.

To use the symbols listed in Tables 3.12–3.165, the package amssymbmust be loaded in the preamble of the document and the AMS math fontsmust be installed on the system. If the AMS package and fonts are notinstalled, on your system, have a look atCTAN:/tex-archive/macros/latex/packages/amslatex

Table 3.1: Math Mode Accents

a \hata a \checka a \tildea a \acutea

a \gravea a \dota a \ddota a \brevea

a \bara ~a \veca A \widehatA A \widetildeA

Table 3.2: Lowercase Greek Letters

α \alpha θ \theta o o υ \upsilon

β \beta ϑ \vartheta π \pi φ \phi

γ \gamma ι \iota $ \varpi ϕ \varphi

δ \delta κ \kappa ρ \rho χ \chi

ε \epsilon λ \lambda % \varrho ψ \psi

ε \varepsilon µ \mu σ \sigma ω \omega

ζ \zeta ν \nu ς \varsigma

η \eta ξ \xi τ \tau

Table 3.3: Uppercase Greek Letters

Γ \Gamma Λ \Lambda Σ \Sigma Ψ \Psi

∆ \Delta Ξ \Xi Υ \Upsilon Ω \Omega

Θ \Theta Π \Pi Φ \Phi

5These tables were derived from symbols.tex by David Carlisle and subsequentlychanged extensivly as suggested by Josef Tkadlec

Page 54: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

42 Typesetting Mathematical Formulae

Table 3.4: Binary Relations

You can produce corresponding negations by adding a \not command asprefix to the following symbols.

< < > > = =

≤ \leq or \le ≥ \geq or \ge ≡ \equiv

¿ \ll À \gg.= \doteq

≺ \prec  \succ ∼ \sim

¹ \preceq º \succeq ' \simeq

⊂ \subset ⊃ \supset ≈ \approx

⊆ \subseteq ⊇ \supseteq ∼= \cong

< \sqsubset a = \sqsupset a 1 \Join a

v \sqsubseteq w \sqsupseteq ./ \bowtie

∈ \in 3 \ni , \owns ∝ \propto

` \vdash a \dashv |= \models

| \mid ‖ \parallel ⊥ \perp

^ \smile _ \frown ³ \asymp

: : /∈ \notin 6= \neq or \neaUse the latexsym package to access this symbol

Table 3.5: Binary Operators

+ + − -

± \pm ∓ \mp / \triangleleft

· \cdot ÷ \div . \triangleright

× \times \ \setminus ? \star

∪ \cup ∩ \cap ∗ \ast

t \sqcup u \sqcap \circ

∨ \vee , \lor ∧ \wedge , \land • \bullet

⊕ \oplus ª \ominus ¦ \diamond

¯ \odot ® \oslash ] \uplus

⊗ \otimes © \bigcirc q \amalg

4 \bigtriangleup 5 \bigtriangledown † \dagger

¢ \lhd a ¤ \rhd a ‡ \ddagger

£ \unlhd a ¥ \unrhd a o \wr

Page 55: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.9 List of Mathematical Symbols 43

Table 3.6: BIG Operators∑

\sum⋃

\bigcup∨

\bigvee⊕

\bigoplus∏\prod

⋂\bigcap

∧\bigwedge

⊗\bigotimes∐

\coprod⊔

\bigsqcup⊙

\bigodot∫\int

∮\oint

⊎\biguplus

Table 3.7: Arrows

← \leftarrow or \gets ←− \longleftarrow ↑ \uparrow

→ \rightarrow or \to −→ \longrightarrow ↓ \downarrow

↔ \leftrightarrow ←→ \longleftrightarrow l \updownarrow

⇐ \Leftarrow ⇐= \Longleftarrow ⇑ \Uparrow

⇒ \Rightarrow =⇒ \Longrightarrow ⇓ \Downarrow

⇔ \Leftrightarrow ⇐⇒ \Longleftrightarrow m \Updownarrow

7→ \mapsto 7−→ \longmapsto \nearrow

← \hookleftarrow → \hookrightarrow \searrow

\leftharpoonup \rightharpoonup \swarrow

\leftharpoondown \rightharpoondown \nwarrow

­ \rightleftharpoons ⇐⇒ \iff (bigger spaces) ; \leadsto a

aUse the latexsym package to access this symbol

Table 3.8: Delimiters

( ( ) ) ↑ \uparrow ⇑ \Uparrow

[ [ or \lbrack ] ] or \rbrack ↓ \downarrow ⇓ \Downarrow

\ or \lbrace \ or \rbrace l \updownarrow m \Updownarrow

〈 \langle 〉 \rangle | | or \vert ‖ \| or \Vertb \lfloor c \rfloor d \lceil e \rceil

/ / \ \backslash . (dual. empty)

Table 3.9: Large Delimiters \lgroup

\rgroup

\lmoustache

\rmoustache

| \arrowvert ‖ \Arrowvert \bracevert

Page 56: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

44 Typesetting Mathematical Formulae

Table 3.10: Miscellaneous Symbols

. . . \dots · · · \cdots... \vdots

. . . \ddots

~ \hbar ı \imath \jmath ` \ell

< \Re = \Im ℵ \aleph ℘ \wp

∀ \forall ∃ \exists 0 \mho a ∂ \partial′ ’ ′ \prime ∅ \emptyset ∞ \infty

∇ \nabla 4 \triangle 2 \Box a 3 \Diamond a

⊥ \bot > \top ∠ \angle√

\surd

♦ \diamondsuit ♥ \heartsuit ♣ \clubsuit ♠ \spadesuit

¬ \neg or \lnot [ \flat \ \natural ] \sharpaUse the latexsym package to access this symbol

Table 3.11: Non-Mathematical Symbols

These symbols can also be used in text mode.

† \dag § \S c© \copyright

‡ \ddag ¶ \P £ \pounds

Table 3.12: AMS Delimiters

p \ulcorner q \urcorner x \llcorner y \lrcorner

Table 3.13: AMS Greek and Hebrwe

z \digamma κ \varkappa i \beth k \daleth ג \gimel

Page 57: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.9 List of Mathematical Symbols 45

Table 3.14: AMS Binary Relations

l \lessdot m \gtrdot + \doteqdot or \Doteq6 \leqslant > \geqslant : \risingdotseq

0 \eqslantless 1 \eqslantgtr ; \fallingdotseq

5 \leqq = \geqq P \eqcirc

≪ \lll or \llless ≫ \ggg or \gggtr $ \circeq

. \lesssim & \gtrsim , \triangleq

/ \lessapprox ' \gtrapprox l \bumpeq

≶ \lessgtr ≷ \gtrless m \Bumpeq

Q \lesseqgtr R \gtreqless ∼ \thicksim

S \lesseqqgtr T \gtreqqless ≈ \thickapprox

4 \preccurlyeq < \succcurlyeq u \approxeq

2 \curlyeqprec 3 \curlyeqsucc v \backsim

- \precsim % \succsim w \backsimeq

w \precapprox v \succapprox ² \vDash

j \subseteqq k \supseteqq ° \Vdash

b \Subset c \Supset ± \Vvdash

< \sqsubset = \sqsupset \backepsilon

∴ \therefore ∵ \because ∝ \varpropto

p \shortmid q \shortparallel G \between

` \smallsmile a \smallfrown t \pitchfork

C \vartriangleleft B \vartriangleright J \blacktriangleleft

E \trianglelefteq D \trianglerighteq I \blacktriangleright

Table 3.15: AMS Arrows

L99 \dashleftarrow 99K \dashrightarrow ( \multimap

⇔ \leftleftarrows ⇒ \rightrightarrows · \upuparrows

¿ \leftrightarrows À \rightleftarrows ¸ \downdownarrows

W \Lleftarrow V \Rrightarrow » \upharpoonleft

´ \twoheadleftarrow ³ \twoheadrightarrow ¹ \upharpoonright

¾ \leftarrowtail ½ \rightarrowtail ¼ \downharpoonleft

® \leftrightharpoons ­ \rightleftharpoons º \downharpoonright

Á \Lsh  \Rsh à \rightsquigarrow

" \looparrowleft # \looparrowright ! \leftrightsquigarrow

x \curvearrowleft y \curvearrowright

ª \circlearrowleft © \circlearrowright

Page 58: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

46 Typesetting Mathematical Formulae

Table 3.16: AMS Negated Binary Relations and Arrows

≮ \nless ≯ \ngtr & \varsubsetneqq

\lneq \gneq ' \varsupsetneqq

\nleq \ngeq " \nsubseteqq

\nleqslant \ngeqslant # \nsupseteqq

\lneqq \gneqq - \nmid

\lvertneqq \gvertneqq ∦ \nparallel

\nleqq \ngeqq . \nshortmid

\lnsim \gnsim / \nshortparallel

\lnapprox \gnapprox \nsim

⊀ \nprec \nsucc \ncong

\npreceq \nsucceq 0 \nvdash

\precneqq \succneqq 2 \nvDash

\precnsim \succnsim 1 \nVdash

\precnapprox \succnapprox 3 \nVDash

( \subsetneq ) \supsetneq 6 \ntriangleleft

\varsubsetneq ! \varsupsetneq 7 \ntriangleright

* \nsubseteq + \nsupseteq 5 \ntrianglelefteq

$ \subsetneqq % \supsetneqq 4 \ntrianglerighteq

8 \nleftarrow 9 \nrightarrow = \nleftrightarrow

: \nLeftarrow ; \nRightarrow < \nLeftrightarrow

Table 3.17: AMS Binary Operators

u \dotplus ¦ \centerdot ᵀ \intercal

n \ltimes o \rtimes > \divideontimes

d \Cup or \doublecup e \Cap or \doublecap r \smallsetminus

Y \veebar Z \barwedge [ \doublebarwedge

¢ \boxplus ¯ \boxminus Ä \circleddash

£ \boxtimes ¡ \boxdot \circledcirc

h \leftthreetimes i \rightthreetimes ~ \circledast

g \curlyvee f \curlywedge

Page 59: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

3.9 List of Mathematical Symbols 47

Table 3.18: AMS Miscellaneous

~ \hbar \hslash k \Bbbk

¤ \square ¥ \blacksquare s \circledS

M \vartriangle N \blacktriangle \complement

O \triangledown H \blacktriangledown a \Game

♦ \lozenge ¨ \blacklozenge F \bigstar

∠ \angle ] \measuredangle ^ \sphericalangle

\diagup \diagdown 8 \backprime

@ \nexists ` \Finv ∅ \varnothing

ð \eth 0 \mho

Table 3.19: Math Alphabets

Example Command Required packageABCdef \mathrmABCdef

ABCdef \mathitABCdef

ABCdef \mathnormalABCdef

ABC \mathcalABC

ABC \mathcalABC euscript with with option: mathcal

\mathscrABC euscript with option: mathscr

ABCdef \mathfrakABCdef eufrak

ABC \mathbbABC amsfonts or amssymb

Page 60: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth
Page 61: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Chapter 4

Specialities

Don’t read this chapter! — Or, at least, if you feel confident enough, you cannow start writing your documents in LATEX. The purpose of this chapter is toadd some ‘spice’ to your LATEX knowledge. A much more complete descriptionof specialities and enhancements possible with LATEX can be found in the LATEXManual [1] and The LATEX Companion [3].

4.1 Fonts and Sizes

LATEX chooses the appropriate font and font size based on the logical struc-ture of the document (sections, footnotes, . . . ). In some cases one might liketo change fonts and sizes by hand. To do this you can use the commandslisted in Tables 4.1 and 4.2.

The small and bold Romans ruledall of great big Italy.

\small The small and\textbfbold Romans ruled\Large all of great big\textitItaly.

In math mode you can use the font changing commands to temporarilyexit math mode and enter some normal text. If you want to switch to anotherfont for math typesetting there exists another special set of commands. Referto Table 4.3.

In connection with the font size commands, curly braces play a significantrole. They are used to to build groups. Groups limit the scope of most LATEXcommands.

He likes large and small let-ters.

He likes \LARGE large and\small small letters.

The font size commands also change the line spacing, but only if the

Page 62: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

50 Specialities

Table 4.1: Fonts

\textrm... roman \textsf... sans serif\texttt... typewriter

\textmd... medium \textbf... bold face

\textup... upright \textit... italic\textsl... slanted \textsc... small caps

\emph... emphasised \textnormal... document font

Table 4.2: Font sizes

\tiny tiny font

\scriptsize very small font

\footnotesize quite small font

\small small font\normalsize normal font\large large font

\Large larger font

\LARGE very large font

\huge huge

\Huge largest

Table 4.3: Math fonts

Command Example Output

\mathcal... $\mathcalB=c$ B = c\mathrm... $\mathrmK_2$ K2

\mathbf... $\sum x=\mathbfv$∑

x = v\mathsf... $\mathsfG\times R$ G× R\mathtt... $\mathttL(b,c)$ L(b, c)\mathnormal... $\mathnormalR_1=R_1$ R = R1

\mathit... $finder\neq\mathitfinder$ finder 6= finder

Page 63: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

4.2 Spacing 51

paragraph ends within the scope of the font size command. The closingcurly brace should therefore not come too early. Note the position of the\par command in the next two examples.

Don’t read this! It is nottrue. You can believe me!

\Large Don’t read this! It is nottrue. You can believe me!\par

This is not true. But re-member I am liar.

\Large This is not true.But remember I am liar.\par

To conclude this journey into the land of fonts and font sizes, here is alittle word of advice1:

Remember! The MO RE fonts you use in a document themore readable and beautiful it becomes.

4.2 Spacing

4.2.1 Line Spacing

If you want to use larger inter line spacing in a document, you can changeits value by putting the

\linespreadfactor

command into the preamble of your document. Use \linespread1.3 for“one and a half” line spacing, and \linespread1.6 for “double” linespacing. Normally the lines are not spread, therefore the default line spreadfactor is 1.

4.2.2 Paragraph Formating

In LATEX, there are two parameters influencing paragraph layout. By placinga definition like

\setlength\parindent0pt\setlength\parskip1ex plus 0.5ex minus 0.2ex

in the preamble of the input file2 the appearance of paragraphs can bechanged. These two lines increase the space between two paragraphs whilesetting the paragraph indent to zero. In continental Europe, paragraphs areoften separated by some space and not indented.

1Attention: This is a bit of satire. I hope you realise that!2Between the \documentclass and the \begindocument commands

Page 64: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

52 Specialities

If you want to indent a paragraph which is not indented, you can use

\indent

at the beginning of the paragraph3. Obviously this can only work, when\parindent is not set to zero.

To create a non indented paragraph you can use

\noindent

as the first command of the paragraph. This might come in handy, whenyou start a document with body text and not with a sectioning command.

4.2.3 Horizontal Space

LATEX determines the spaces between words and sentences automatically.To add horizontal space, use:

\hspacelength

If such a space should be kept, even if it falls at the end or the start of aline, use \hspace* instead of \hspace. The length in the simplest case justis ‘a number plus a unit. The most important units are listed in Table 4.4.

This is a space of 1.5 cm. This\hspace1.5cmis a spaceof 1.5 cm.

The command

\stretchn

generates a special rubber space. It stretches, until all the remaining spaceon a line is filled up. If two \hspace\stretchn commands are issuedon the same line, they grow according to the stretch factor.

x x x x\hspace\stretch1x\hspace\stretch3x

3To indent the first paragraph after each section head, use the indentfirst package inthe ‘tools’ bundle

Page 65: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

4.3 Page Layout 53

Table 4.4: TEX Units

mm millimeter ≈ 1/25 inchcm centimeter = 10 mmin inch ≈ 25 mmpt point ≈ 1/72 inch ≈ 1

3 mmem approx width of an m in the current fontex approx height of an x in the current font

4.2.4 Vertical Space

The space between paragraphs, sections, subsections, . . . is determined au-tomatically by LATEX. If necessary, additional vertical space between twoparagraphs can be added with the command:

\vspacelength

This command should normally be used between two empty lines. If thespace should be preserved at the top, or at the bottom of a page, use thestarred version of the command \vspace* instead of \vspace.

The \stretch command in connection with \pagebreak can be used totypeset text on the last line of a page, or to centre text vertically on a page.

Some text \ldots

\vspace\stretch1This goes onto the last line of the page.\pagebreak

Additional space between two lines of the same paragraph or within atable is specified with the

\\[length]

command.

4.3 Page Layout

LATEX2ε allows you to specify the paper size in the \documentclass com-mand. It then automatically picks the right text margins. But some times,you may not be happy with the predefined values. Naturally, you can changethem. Figure 4.1 shows all the parameters which can be changed. The fig-ure was produced with the layout package from the tools bundle4.

4CTAN:/tex-archive/macros/latex/packages/tools

Page 66: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

54 Specialities

Header

Body

Footer

MarginNotes

i8¾ -

i7

?

6

i1¾ -

¾-i3i10¾ -

¾- i9

6

?

i11

i2?

6i4

6

?

i5

6

?

i6

6

?

1 one inch + \hoffset 2 one inch + \voffset

3 \oddsidemargin = 22pt 4 \topmargin = 22pt

5 \headheight = 13pt 6 \headsep = 19pt

7 \textheight = 595pt 8 \textwidth = 360pt

9 \marginparsep = 7pt 10 \marginparwidth = 106pt

11 \footskip = 27pt \marginparpush = 5pt (not shown)

\hoffset = 0pt \voffset = 0pt

\paperwidth = 597pt \paperheight = 845pt

Figure 4.1: Page Layout Parameters

Page 67: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

4.4 Bibliography 55

LATEX provides two commands to change these parameters. They areusually used in the document preamble.

The first command assigns a fixed value to any of the parameters:

\setlengthparameterlength

The second command, adds a length to any of the parameters.

\addtolengthparameterlength

This second command is actually more useful than the \setlength com-mand, because you can now work relative to the existing settings. To addone centimetre to the overall text width, I would put the following commandsinto the document preamble:

\addtolength\hoffset-0.5cm\addtolength\textwidth1cm

4.4 Bibliography

With the thebibliography environment you can produce a bibliography.Each entry starts with

\bibitemmarker

The marker is then used to cite the book within the document.

\citemarker

The numbering of the entries is generated automatically. The parameterafter the \beginthebibliography command sets the maximum width ofthese numbers.

Page 68: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

56 BIBLIOGRAPHY

Partl [1] has proposed, that . . .

Bibliography

[1] H. Partl: German TEX, TUG-boat Vol. 9, No. 1 (’88)

Partl~\citepa hasproposed, that \ldots

\beginthebibliography99\bibitempa H.~Partl:\emphGerman \TeX,TUGboat Vol.~9, No.~1 (’88)\endthebibliography

4.5 Indexing

A very useful feature of many books is their index. With LATEX and thesupport program makeindx5 indexes can be generated quite easily. In thisintroduction, only the basic index generation commands will be explained.For a more in depth view please refer to The LATEX Companion [3].

To enable the indexing feature of LATEX the makeidx package must beloaded in the preamble with:

\usepackagemakeidx

and the special indexing commands must be enabled by putting the

\makeindex

command into the input files preamble.The contents of the index is specified with

\indexkey

commands. Where key is the index entry. You enter the index commandsat the points in the text where you want the final index entries to point to.Table 4.5 explains the syntax of the key argument with several examples.

When the input file is processed with LATEX, each \index commandwrites an appropriate index entry together with the current page numberto a special file. The file has the same name as the LATEX input file, but a

5On systems supporting filenames longer than 8 characters, the program may be calledmakeindex.

Page 69: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

4.6 Including EPS Graphics 57

Table 4.5: Index Key Syntax Examples

Example Index Entry Comment\indexhello hello, 1 Plain entry\indexhello!Peter Peter, 3 Subentry under ‘hello’\indexSam@\textslSam Sam, 2 Formated entry\indexLin@\textbfLin Lin, 7 Same as above\indexJenny|textbf Jenny, 3 Formated page number\indexJoe|textit Joe, 5 Same as above

different extension (.ind). This .ind file can then be processed with themakeindx program.

makeidx filename

The makeindx program generates a sorted index with the same base filename, but this time with the extension .idx. If now the LATEX input fileis processed again, this sorted index gets included into the document at thepoint where LATEX finds

\printindex

The showidx package which comes with LATEX2ε prints out all indexentries in the left margin of the text. This is quite useful for proofreading adocument and verifying the index.

4.6 Including EPS Graphics

With the figure and the table environment LATEX provides the basic fa-cilities to work with floating bodies such as images or graphics.

There are also several possibilities to generate the actual graphics withbasic LATEX or a LATEX extension package. Unfortunately, most users findthem quite difficult to understand. Therefore this will not be explained anyfurther in this manual. For more information on that subject please refer toThe LATEX Companion [3] and the LATEX Manual [1].

A much easier way to get graphics into a document, is to generate themwith a specialised software package6 and then include the finished graphicsinto the document. Here again, LATEX packages offer many ways to do that.In this introduction, only the use of Encapsulated PostScript (EPS) graphicswill be discussed, because it is quite easy to do and widely used. In order

6Such as XFig, CorelDraw!, Freehand, GNU Plot, . . .

Page 70: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

58 BIBLIOGRAPHY

to use pictures in the EPS format, you must have a PostScript printer7

available for output.A good set of commands for inclusion of graphics is provided in the

graphicx package by D. P. Carlisle. It is part of a whole family of packagescalled the “graphics” bundle8.

Assuming you are working on a system with a PostScript printer avail-able for output and with the graphicx package installed, you can use thefollowing step by step guide to include a picture into your document:

1. Export the picture from your graphics program in EPS format.

2. Load the graphicx package in the preamble of the input file with

\usepackage[driver]graphicx

driver is the name of your “dvi to postscript” converter9. This infor-mation is required by the package because the actual graphics inclusionis done by the printer driver. Knowing the driver, the graphicx packageinserts the correct commands into the .dvi file for the printer driverto include the desired EPS graphics.

3. Use the command

\includegraphics[key=value, . . . ]file

to include file into your document. The optional parameter accepts acomma separated list of keys and associated values. The keys can beused to alter the width, height and rotation of the included graphic.Table 4.6 lists the most important keys.

Table 4.6: Key Names for graphicx Package

width scale graphic to the specified widthheight scale graphic to the specified heightangle rotate graphics clockwise

The following example code will hopefully make things clear:

7Another possibility to output PostScript is the GhostScript program available fromCTAN:/tex-archive/support/ghostscript

8CTAN:/tex-archive/macros/latex/packages/graphics9The most widely used program is called dvips.

Page 71: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

4.6 Including EPS Graphics 59

\beginfigure\begincenter\includegraphics[angle=90, width=10cm]test.eps\endcenter\endfigure

This includes the graphic stored in the file test.eps. The graphic is firstrotated by 90 degrees and then scaled to the final width of 10 cm. The aspectratio is 1.0 because no special height is specified.

For more information please refer to [8].

Page 72: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth
Page 73: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Bibliography

[1] Leslie Lamport. LATEX: A Document Preparation System. Addison-Wesley, Reading, Massachusetts, second edition, 1994, ISBN 0-201-52983-1.

[2] Donald E. Knuth. The TEXbook, Volume A of Computers and Typeset-ting, Addison-Wesley Publishing Company (1984), ISBN 0-201-13448-9.

[3] Michel Goossens, Frank Mittelbach and Alexander Samarin. The LATEXCompanion. Addison-Wesley, Reading, Massachusetts, 1994, ISBN 0-201-54199-8.

[4] Each LATEX installation should provide a so-called LATEX Local Guide,which explains the things which are special to the local system. It shouldbe contained in file called local.tex. Unfortunately some lazy sysopsdo not provide such a document. In this case, go and ask you localLATEX guru for help.

[5] LATEX3 Project Team. LATEX2ε for authors. Comes with the LATEX2εdistribution as usrguide.tex.

[6] LATEX3 Project Team. LATEX2ε for Class and Package writers. Comeswith the LATEX2ε distribution as clsguide.tex.

[7] LATEX3 Project Team. LATEX2ε Font selection. Comes with the LATEX2εdistribution as fntguide.tex.

[8] D. P. Carlisle. Packages in the ‘graphics’ bundle. Comes with the‘graphics’ bundle as grfguide.tex, available form the same source yourLATEX distribution came from.

Page 74: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

Index

\!, 36", 15$, 31’, 34\(, 31\), 31\,, 32, 36-, 15−, 15\-, 14–, 15—, 15., space after, 18. . . , 16\@, 18\[, 31\\, 13, 22, 24, 53\\*, 13\], 31^, 33_, 33|, 24~, 18

A4 paper, 8A5 paper, 8accent, 16acute, 17\addtolength, 55advantages of LATEX, 3æ, 17amssymb, 41amstex, 36\and, 19\appendix, 18array, 36, 37

arrow symbols, 34article class, 8\atop, 35\author, 19\authors, 19

B5 paper, 8babel, 16, 17\backmatter, 19backslash, 5base font size, 8\begin, 21\bibitem, 55bibliography, 55\Big, 35\big, 35\Bigg, 36\bigg, 35\bmod, 34bold face, 50book class, 8braces, 35

\caption, 27\cdots, 36center, 22\chapter, 18\choose, 35\cite, 55\clearpage, 27coloured text, 9comma, 15commands, 5

\!, 36\(, 31\), 31

Page 75: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

INDEX 63

\,, 32, 36\-, 14\@, 18\[, 31\\, 13, 22, 24, 53\\*, 13\], 31\addtolength, 55\and, 19\appendix, 18\atop, 35\author, 19\authors, 19\backmatter, 19\begin, 21\bibitem, 55\Big, 35\big, 35\Bigg, 36\bigg, 35\bmod, 34\caption, 27\cdots, 36\chapter, 18\choose, 35\cite, 55\clearpage, 27\date, 19\ddots, 36\displaystyle, 38\documentclass, 7\emph, 20, 50\end, 21\footnote, 20\footnotesize, 50\frac, 34\frenchspacing, 18\frontmatter, 19\hline, 24\hspace, 52\Huge, 50\huge, 50\hyphenation, 14\include, 10, 11

\includegraphics, 58\includeonly, 11\indent, 52\index, 56\int, 35\item, 21\label, 20, 32\LARGE, 50\Large, 50\large, 50\ldots, 16, 36\left, 35\linebreak, 14\linespread, 51\listoffigures, 27\listoftables, 27\mainmatter, 19\makeindex, 56\maketitle, 19\mathbf, 50\mathcal, 50\mathit, 50\mathnormal, 50\mathrm, 38, 50\mathsf, 50\mathtt, 50\mbox, 15, 16\multicolumn, 25\newcommand, 28, 29\newenvironment, 29\newline, 13\newpage, 13\newtheorem, 39\noindent, 52\nolinebreak, 14\nonumber, 38\nopagebreak, 14\normalsize, 50\overbrace, 34\overleftarrow, 34\overline, 33\overrightarrow, 34\pagebreak, 14\pageref, 20

Page 76: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

64 INDEX

\pagestyle, 10\paragraph, 18\parindent, 51\parskip, 51\part, 18\pmod, 34\printindex, 57\providecommand, 29\qquad, 32, 36\quad, 32, 36\ref, 20, 32\renewcommand, 29\renewenvironment, 29\right, 35, 37\scriptscriptstyle, 38\scriptsize, 50\scriptstyle, 38\section, 18\setlength, 51, 55\sloppy, 14\small, 50\sqrt, 33\stretch, 52\subparagraph, 18\subsection, 18\subsubsection, 18\sum, 35\tableofcontents, 19\textbf, 50\textit, 50\textmd, 50\textnormal, 50\textrm, 38, 50\textsc, 50\textsf, 50\textsl, 50\textstyle, 38\texttt, 50\textup, 50\thispagestyle, 10\tiny, 50\title, 19\underbrace, 34\underline, 33

\usepackage, 9, 17\vdots, 36\vec, 34\verb, 23\vspace, 53\widehat, 34\widetilde, 34

comments, 5cross references, 20curly braces, 5, 49

dash, 15, 34\date, 19dcolumn, 25\ddots, 36decimal alignment, 25delimiters, 35describing variables, 39description, 21diagonal dots, 36dimensions, 52displaymath, 31\displaystyle, 38document font size, 8document title, 8\documentclass, 7dotless ıand , 17double line spacing, 51double sided, 8

ellipsis, 16em-dash, 15\emph, 20, 50emphasise, 20empty, 10en-dash, 15Encapsulated PostScript, 57\end, 21enumerate, 21environment, 21environments

array, 36, 37center, 22description, 21

Page 77: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

INDEX 65

displaymath, 31enumerate, 21eqnarray, 37equation, 32figure, 26, 27flushleft, 22flushright, 22itemize, 21math, 31quotation, 22quote, 22table, 26, 27tabular, 24thebibliography, 55verbatim, 23verse, 22

eqnarray, 37equation, 32equation system, 37executive paper, 8exponent, 33exscale, 36

figure, 26, 27floating bodies, 25flushleft, 22flushright, 22font, 49font encoding, 9font size, 49, 50footer, 10\footnote, 20\footnotesize, 50formulae, 31\frac, 34fraction, 34\frenchspacing, 18\frontmatter, 19

German, 17GhostScript, 58graphics, 9, 57graphicx, 58grave, 17

Greek letters, 33grouping, 49

header, 10textttheadings, 10\hline, 24horizontal

brace, 34dots, 36line, 33space, 52

\hspace, 52\Huge, 50\huge, 50hyphen, 15\hyphenation, 14hyphenation rules, 16

\include, 10, 11\includegraphics, 58\includeonly, 11\indent, 52indentfirst, 52index, 56\index, 56input file, 6inputenc, 17\int, 35integral operator, 35international, 16italic, 50\item, 21itemize, 21

Knuth, Donald E., 1

\label, 20, 32Lamport, Leslie, 1language, 16\LARGE, 50\Large, 50\large, 50LATEX 2.09, 1LATEX2ε, 1LATEX3, 1, 4

Page 78: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

66 INDEX

layout, 53\ldots, 16, 36\left, 35left aligned, 22legal paper, 8letter paper, 8ligature, 16line spacing, 51linebreak, 13\linebreak, 14\linespread, 51\listoffigures, 27\listoftables, 27long equations, 37

\mainmatter, 19makeidx, 56makeidx package, 56\makeindex, 56makeindex program, 56\maketitle, 19margins, 53math, 31math font size, 38math spacing, 36\mathbf, 50\mathcal, 50mathematical

accents, 34delimiter, 35functions, 34minus, 15

mathematics, 31\mathit, 50\mathnormal, 50\mathrm, 38, 50\mathsf, 50\mathtt, 50\mbox, 15, 16minus sign, 15Mittelbach, Frank, 1modulo function, 34\multicolumn, 25

\newcommand, 28, 29\newenvironment, 29\newline, 13\newpage, 13\newtheorem, 39\noindent, 52\nolinebreak, 14\nonumber, 38\nopagebreak, 14\normalsize, 50

œ, 17option, 7optional parameters, 5\overbrace, 34overfull hbox, 14\overleftarrow, 34\overline, 33\overrightarrow, 34

package, 6, 7packages

amssymb, 41amstex, 36babel, 16, 17dcolumn, 25exscale, 36graphicx, 58indentfirst, 52inputenc, 17layout, 53makeidx, 56showidx, 57

page layout, 53page style, 10

empty, 10headings, 10plain, 10

\pagebreak, 14\pageref, 20\pagestyle, 10paper size, 8, 53\paragraph, 18parameter, 5

Page 79: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

INDEX 67

\parindent, 51\parskip, 51\part, 18period, 15placement specifier, 26plain, 10\pmod, 34PostScript, 58preamble, 6\printindex, 57\providecommand, 29

\qquad, 32, 36\quad, 32, 36quotation, 22quotation marks, 15quote, 22

\ref, 20, 32\renewcommand, 29\renewenvironment, 29report class, 8reserved characters, 4\right, 35, 37right aligned, 22roman, 50

sans serif, 50Scandinavian letters, 17\scriptscriptstyle, 38\scriptsize, 50\scriptstyle, 38\section, 18\setlength, 51, 55showidx, 57single sided, 8slanted, 50slide class, 8\sloppy, 14\small, 50small caps, 50space, 4special character, 16\sqrt, 33square brackets, 5

square root sign, 33\stretch, 52structure, 6\subparagraph, 18subscript, 33\subsection, 18\subsubsection, 18\sum, 35sum operator, 35

table, 24table, 26, 27table of contents, 19\tableofcontents, 19tabular, 24\textbf, 50\textit, 50\textmd, 50\textnormal, 50\textrm, 38, 50\textsc, 50\textsf, 50\textsl, 50\textstyle, 38\texttt, 50\textup, 50thebibliography, 55\thispagestyle, 10three dots, 36tilde, 34tilde ( ~), 18\tiny, 50title, 8, 19\title, 19two column, 8

umlaut, 17\underbrace, 34underfull hbox, 14\underline, 33units, 52, 53upright, 50\usepackage, 9, 17

\vdots, 36

Page 80: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

68 INDEX

\vec, 34vectors, 34\verb, 23verbatim, 23verse, 22vertical dots, 36vertical space, 53\vspace, 53

whitespace, 4after commands, 5at the start of a line, 4

\widehat, 34\widetilde, 34WYSIWYG, 2, 3

Page 81: The Not So Short Introduction to LATEX2tpr/latex/lshort2e.pdfThe Not So Short Introduction to LATEX2" Or LATEX2e in 69 minutes by Tobias Oetiker Hubert Partl, Irene Hyna and Elisabeth

INDEX 69