THE LATEX COMPANION
by Michel GOOSSENS, Frank MITTELBACH, Alexander SAMARIN
Table of Contents
1 Introduction 1
1.1 A Short History of TEX and LaTeX . . . 1
1.1.1 In the Beginning There Was TeX . . 1
1.1.2 Then Leslie Lamport Developed LaTEX . 2
1.1.3 With LaTeX toward the Year 2000? . . 3
1.2 LaTeX and Its Components . . . . . 3
1.2.1 How Does LaTeX Work? . . . . . 3
1.2.2 Output Processors . . . . . 6
1.3 The Concept of Generic Markup . . . . 6
1.3.1 What Is Generic Markup? . . . . 6
1.3.2 Advantages of Generic Markup . . . 8
1.3.3 Separation of Content and Form . . 8
1.4 Necessity of Layout Markup . . . . . 9
1.4.1 Pitfalls of Layout Markup . . . 9
1.4.2 When to Use Layout Markup . . . 10
2 The Structure of a LaTeX Document 11
2.1 The Structure of a Source File . . . . 11
2.1.1 Processing of Options and Packages . 13
2.1.2 Splitting the Source File into Parts . 16
2.1.3 Combining Several Files . . . . 17
2.2 Logical Structure. . . . . . . . 17
2.3 Sectioning Commands . . . . . . . 18
2.3.1 Numbering Headings. . . . . . 20
2.3.2 Formatting Headings . . . . . 24
2.3.3 Changing Fixed Heading Texts . . . 30
2.4 Structure of the Table of Contents . . . 31
2.4.1 Typesetting a Contents List . . . 32
2.4.2 Entering Information into the Contents Files 35
2.4.3 Defining a New TOC-Like File . . . 36
2.4.4 Multiple Tables of Contents . . . 36
2.5 Managing References . . . . . . . 40
2.5.1 varioref---More Flexible Cross-References . 41
2.5.2 References to External Documents . . 45
3 Basic Formatting Tools 47
3.1 Phrases and Paragraphs . . . . . . 48
3.1.1 letterspace---Changing Inter-Letter Spacing 48
3.1.2 ulem---Emphasize via Underline . . . 49
3.1.3 xspace---Gentle Spacing after a Macro . 50
3.1.4 Paragraph Justification . . . . 50
3.1.5 doublespace---Changing Inter-Line Spacing . 52
3.1.6 picinpar---Typeset a Paragraph with
a Rectangular Hole . . . . . 53
3.1.7 shapepar---Typeset a Paragraph with
a Specified Shape . . . . . 54
3.2 List Structures . . . . . . . . 56
3.2.1 Modifying the Standard Lists . . . 56
3.2.2 Making Your Own Lists . . . . 60
3.3 Simulating Typed Text . . . . . . 66
3.3.1 alltt---A Verbatim-Like Environment . . 66
3.3.2 verbatim---A Style for Literal Text . 66
3.3.3 moreverb---More Verbatim-Like Environments 66
3.4 Footnotes, Endnotes, and Marginals . . . . 70
3.4.1 Customizing Footnotes . . . . . 70
3.4.2 Marginal Notes . . . . . . 74
3.4.3 Endnotes . . . . . . . . 74
3.5 Using Multiple Columns . . . . . . 75
3.5.1 multicol---A Flexible Way to Handle
Multiple Columns . . . . . . 76
3.5.2 Typesetting in Columns. . . . . 76
3.5.3 Customizing the multicols Environment . 77
3.5.4 Floats and Footnotes in multicol . . 79
3.5.5 ftnright---Right Footnotes in a Two-Column
Environment . . . . . . . 80
3.6 Simple Version Control . . . . . . 80
4 The Layout of the Page 83
4.1 Geometrical Dimensions of the Layout . . . 84
4.2 Changing the Layout . . . . . . . 87
4.2.1 Page Layout Packages . . . . . 88
4.2.2 Typesetting Pages in Landscape Mode . 90
4.3 Page Styles . . . . . . . . . 91
4.3.1 Writing New Page Styles . . . . 92
4.3.2 Customizing Page Styles with fancyheadings 96
4.4 Visual Formatting . . . . . . . 99
5 Tabular Material 101
5.1 Comparing the tabbing and tabular Environments . 102
5.2 Using the tabbing Environment . . . . 102
5.2.1 The program Environment . . . . 104
5.3 array---Extending the tabular Environments . . 104
5.3.1 Examples of Preamble Commands . . . 105
5.3.2 Style Parameters . . . . . . 110
5.3.3 Defining New Column Specifiers . . . 112
5.3.4 Some Peculiarities of the array Implementation 113
5.3.5 tabularx---Automatic Calculation of the
Column Widths. . . . . . . 113
5.3.6 delarray---Specifying Delimiters Surrounding
an Array . . . . . . . 117
5.4 Multipage Tabular Material. . . . . . 118
5.4.1 supertab---Making Multipage Tabulars . . 119
5.4.2 longtable---Sophisticated Multipage Tabulars 122
5.4.3 A Final Comparison . . . . . 126
5.5 Bells and Whistles . . . . . . . 129
5.5.1 dcolumn---Defining Column Alignments . . 129
5.5.2 hhline---Combining Horizontal and Vertical Lines 130
5.6 Applications . . . . . . . . . 131
5.6.1 Hyphenation in Narrow Columns . . . 132
5.6.2 Footnotes in Tabular Material . . . 132
5.6.3 Managing Tables with Wide Entries . . 133
5.6.4 Columns Spanning Multiple Rows . . . 134
5.6.5 Tables Inside Tables . . . . . 136
5.6.6 Two More Examples . . . . . 139
6 Mastering Floats 141
6.1 Understanding Float Parameters . . . . . 141
6.2 Improved Float Control . . . . . . 144
6.3 float---Creating New Float Types . . . . 146
6.3.1 I Want My Float ``Here''!. . . . 149
6.4 Different Kinds of Floating Environments . . 150
6.4.1 floatfig---Narrow Floating Figures . . 150
6.4.2 wrapfig---Wrapping Text around a Figure 151
6.4.3 subfigure---Figures inside Figures . . 152
6.4.4 endfloat---Place Figures and Tables at the End 153
6.5 Customizing Your Captions . . . . . . 154
7 Font Selection 157
7.1 Introduction to NFSS . . . . . . . 157
7.2 Understanding Font Characteristics . . . . 159
7.2.1 Monospaced and Proportional Fonts . . 159
7.2.2 Serifed and Sans Serif Fonts . . . 160
7.2.3 Font Families and Their Attributes . . 160
7.2.4 Encoding Schemes . . . . . . 164
7.3 Using Fonts in Text . . . . . . . 165
7.3.1 Standard NFSS Font Commands . . . 165
7.3.2 Combining Standard Font Commands . . 170
7.3.3 Font Commands versus Declarations . . 171
7.3.4 Accessing All Characters of a Font . 172
7.3.5 Changing the Default Text Fonts . . 173
7.3.6 LaTeX 2.09 Font Commands . . . . 174
7.4 Using Fonts in Math . . . . . . . 174
7.4.1 Special Math Alphabet Identifiers . . 175
7.4.2 Text Font Commands in Math . . . 178
7.4.3 Mathematical Formula Versions . . . 178
7.5 Standard Packages. . . . . . . . 180
7.5.1 Providing New Text Fonts . . . . 180
7.5.2 Providing New Math Fonts . . . . 183
7.5.3 slides---Producing Overhead Slides . . 185
7.5.4 Processing Older Documents . . . . 185
7.5.5 Special Packages for NFSS . . . . 186
7.6 The Low-Level Interface . . . . . . 187
7.6.1 Setting Individual Font Attributes . . 188
7.6.2 Setting Several Font Attributes . . 192
7.6.3 Automatic Substitution of Fonts . . 193
7.6.4 Using Low-Level Commands in the Document 193
7.7 Setting Up New Fonts . . . . . . 194
7.7.1 Overview . . . . . . . . 194
7.7.2 Declaring New Font Families and Font
Shape Groups . . . . . . . . 194
7.7.3 Modifying Font Families and Font Shape Groups 202
7.7.4 Declaring New Encoding Schemes . . . 202
7.7.5 Internal File Organization . . . . 203
7.7.6 Declaring New Fonts for Use in Math . 205
7.7.7 The Order of Declaration . . . . 209
7.8 Warning and Error Messages . . . . . 210
8 Higher Mathematics 215
8.1 The AMSLaTeX Project . . . . . . . 215
8.2 Fonts and Symbols in Formulae. . . . . 216
8.2.1 Names of Math Font Commands . . . 216
8.2.2 Mathematical Symbols . . . . . 217
8.3 Compound Symbols, Delimiters, and Operators . . 223
8.3.1 Multiple Integral Signs . . . . 223
8.3.2 Over and Under Arrows. . . . . 223
8.3.3 Dots. . . . . . . . . 224
8.3.4 Accents in Math . . . . . . 224
8.3.5 Superscripted Accents . . . . . 225
8.3.6 Dot Accents . . . . . . . 225
8.3.7 Roots . . . . . . . . 225
8.3.8 Boxed Formulae . . . . . . 225
8.3.9 Extensible Arrows . . . . . . 226
8.3.10 \overset, \underset, and \sideset . . . 226
8.3.11 The \smash Command. . . . . . 227
8.3.12 The \text Command . . . . . . 227
8.3.13 Operator Names . . . . . . 228
8.3.14 "mod and Its Relatives . . . . 229
8.3.15 Fractions and Related Constructions . . 229
8.3.16 Continued Fractions . . . . . 230
8.3.17 Big-g-g-g Delimiters . . . . . 230
8.4 Matrix-Like Environments and Commutative Diagrams . 231
8.4.1 The cases Environment . . . . . 231
8.4.2 The Matrix Environments . . . . 231
8.4.3 The Sb and Sp Environments . . . 233
8.4.4 Commutative Diagrams . . . . . 233
8.5 Alignment Structures for Equations . . . . 235
8.5.1 The align Environment . . . . . 236
8.5.2 The gather Environment. . . . . 236
8.5.3 The alignat Environment . . . . 237
8.5.4 The multline Environment . . . . 237
8.5.5 The split Environment . . . . . 238
8.5.6 Alignment Environments as Parts of Displays . 239
8.5.7 Vertical Spacing and Page Breaks in
Equation Structures . . . . . 239
8.5.8 The \intertext Command . . . . . 240
8.6 Miscellaneous . . . . . . . . 240
8.6.1 Equation Numbers . . . . . . 240
8.6.2 Resetting the Equation Counter . . 241
8.6.3 Fine-Tuning Spacing in Math Mode . . 242
8.6.4 A Few Points to Note . . . . 242
8.6.5 Options and Sub-Packages to the amstex Package 243
8.6.6 AmSLaTeX Document Classes . . . 244
8.7 Examples of Multiple-Line Equation Structures . 244
8.7.1 The split Environment . . . . 244
8.7.2 The multline Environment . . . . 247
8.7.3 The gather Environment . . . . 248
8.7.4 The align Environment . . . . . 248
8.7.5 Using the align and split Environments
within gather. . . . . . . 249
8.7.6 Using the alignat Environments . . 250
8.8 Extensions to the theorem Environment . . 251
8.8.1 Defining New Theorem Environments . . 252
8.8.2 Examples of the Definition and Use of Theorems 253
8.8.3 Special Considerations . . . . . 254
8.9 Mathematical Style Parameters . . . . . 255
8.9.1 Controlling the Size of Characters . . 255
8.9.2 LaTeX Math Style Parameters . . . 256
9 LaTeX in a Multilingual Environment 259
9.1 TEX and Non-English Languages . . . . 259
9.1.1 The Virtual Font Mechanism . . . 261
9.2 Babel--- LaTeX Speaks Multiple Languages . . 262
9.2.1 The User Interface . . . . . 263
9.2.2 The german Option . . . . . 264
9.2.3 The Structure of the babel Language
Style Files. . . . . . . 265
9.3 Implementing Typographic Rules . . . . . 272
9.3.1 Traditional French Typographic Rules . 272
9.3.2 Commands of the french Package . . 273
9.3.3 Structure of the french Package . . 274
10 Portable Graphics in LaTeX 275
10.1 Ornaments . . . . . . . . . . 277
10.1.1 Boxed Minipages . . . . . . 277
10.1.2 Shadow Boxes . . . . . . . 277
10.1.3 Fancy Frames . . . . . . . 278
10.2 The picture Environment . . . . . . 280
10.2.1 Bezier Approximations . . . . . 280
10.2.2 Putting Multiple Boxes . . . . . 281
10.2.3 Drawing Binary or Ternary Trees . . 282
10.2.4 Drawing Bar Charts . . . . . 283
10.2.5 Examples of the barenv Environment . . 286
10.2.6 Drawing Arbitrary Curves . . . . 287
10.2.7 Other Packages . . . . . . 293
10.3 Enhancements to the picture Environment - epic . 293
10.3.1 Description of the Commands . . . 295
10.4 Extending the epic Package . . . . . 300
10.4.1 eepic's Extensions to LaTeX . . . 300
10.4.2 eepic's Extensions to epic . . . 301
10.4.3 New Commands with eepic . . . . 301
10.4.4 Compatibility . . . . . . . 302
10.4.5 Examples . . . . . . . . 303
10.5 Packages Based on epic . . . . . . 303
10.5.1 Drawing Bipartite Graphs . . . . 303
10.5.2 Drawing Trees . . . . . . 307
11 Using PostScript 311
11.1 The PostScript Language . . . . . . 311
11.1.1 About the Language . . . . . 311
11.1.2 What Is Encapsulated PostScript? . . 313
11.2 dvips---A DVI to PostScript Converter . . . 315
11.3 Merging Text and PostScript Graphics . . . 317
11.3.1 Simple Figures . . . . . . 319
11.3.2 Draft Figures . . . . . . 320
11.3.3 More Complex Figure Arrangements . . 320
11.4 Rotating Material . . . . . . . 320
11.4.1 Rotating Tabular Material . . . 324
11.4.2 Rotating a Figure . . . . . 327
11.4.3 Rotated Captions Only . . . . 327
11.5 Using Revision Bars . . . . . . 328
11.5.1 The User Interface . . . . . 328
11.5.2 Changebar Parameters . . . . . 329
11.5.3 Deficiencies and Bugs . . . . 330
11.6 Boxing and Gray Shading . . . . . 330
11.7 Color Output . . . . . . . . 331
11.8 Overlaying Text on the Output Page . . . 332
11.9 The NFSS Revisited . . . . . . . 332
11.9.1 Naming Those Thousands of Fonts . . 332
11.9.2 The PSNFSS System . . . . . 334
11.9.3 Using the PostScript Pi Fonts . . 335
11.9.4 Generic Commands in the Style pifont . 337
11.9.5 The Symbol Font . . . . . 337
11.9.6 Setting Up New PostScript Fonts Yourself 339
11.9.7 Replacing AllTeX Fonts with PostScript Fonts 340
11.10 DCPS - The Cork Encoding with PostScript Fonts . 340
12 Index Generation 345
12.1 Syntax of the Index Entries . . . . . 346
12.1.1 Simple Index Entries . . . . . 347
12.1.2 Generating Subentries . . . . . 348
12.1.3 Page Ranges and Cross-References . . 348
12.1.4 Controlling the Presentation Form . . 349
12.1.5 Printing Those Special Characters . . 350
12.1.6 Points to Note . . . . . . 350
12.1.7 Consistency and Index Entries . . . 351
12.2 Preparing the Index . . . . . . . 352
12.2.1 Generating the Raw Index . . . . 352
12.2.2 Generating the Formatted Index . . 353
12.3 Running the MakeIndex Program . . . . 353
12.3.1 Detailed Options of the MakeIndex Program 355
12.3.2 Error Messages . . . . . . . 356
12.4 Customizing the Index . . . . . . 357
12.4.1 Example of Index Style Files . . . 358
12.4.2 A Stand-Alone Index . . . . . 358
12.4.3 Changing the ``Special Characters'' . . 360
12.4.4 Changing the Output Format of the Index 361
12.4.5 Treating Funny Page Numbers . . . 363
12.4.6 Glossary Entries . . . . . . 364
12.5 Modifying the Layout . . . . . . 364
12.5.1 Multiple Indexes . . . . . . 365
12.5.2 A Reimplementation of the Index Commands 367
13 Bibliography Generation 371
13.1 Entering the Citations . . . . . . 372
13.1.1 Customizing the Citations . . . . 373
13.1.2 Customizing the Bibliography Labels . . 374
13.2 Using BibTeX with LaTeX . . . . . . 375
13.2.1 A List of BibTeX Style Files . . 376
13.2.2 Examples of BibTeX Styles . . . 378
13.3 Multiple Bibliographies in One Document . . 385
13.3.1 The chapterbib Package . . . . 385
13.3.2 The bibunits Package . . . . 386
13.4 Bibliography Data Base Management Tools . . 392
13.5 The General Format of the bib File . . . 398
13.5.1 The General Format of a BibTeX Entry . 398
13.5.2 The Text Part of a Field Explained . 398
13.5.3 Abbreviations in BibTeX . . . . 402
13.5.4 A BibTeX Preamble . . . . . 404
13.5.5 Cross-References . . . . . . 404
13.5.6 Some Further Remarks . . . . . 405
13.6 Detailed Description of the Entries . . . 405
13.7 Understanding BibTeX Styles . . . . 407
13.7.1 A General Description of a BibTeX Style File 407
13.7.2 The BibTeX Style File Commands . . 410
13.7.3 The Built-In Functions . . . . . 410
13.7.4 The Documentation Style btxbst.doc 410
13.8 Introducing Small Changes in a Style File 414
13.8.1 Adding a New Field . . . . . 414
13.8.2 Foreign Language Support . . . . 416
13.9 makebst---Customizing Bibliographic Style Files . 419
13.9.1 Running makebst . . . . . . 419
14 LaTeX Package File Documentation Tools 421
14.1 Documenting Package Files . . . . . 421
14.2 The User Interface for the doc Package . . 422
14.2.1 General Conventions . . . . . 422
14.2.2 Describing New Macros and Environments . 423
14.2.3 Cross-Referencing All Macros Used . . 424
14.2.4 Producing the Actual Index Entries . . 424
14.2.5 Additional Bells and Whistles . . . 424
14.2.6 The Driver File . . . . . . 425
14.2.7 A Simple Example of a File Documented
with doc . . . . . . . . 426
14.3 The docstrip Utility . . . . . . . 432
14.3.1 Batch File Commands . . . . . 433
14.3.2 Conditional Inclusion of Code . . . 434
14.4 An Example of an Installation Procedure . . 435
APPENDICES
A LaTeX Overview for Package and Class Writers 439
A.1 Linking Markup and Formatting . . . . 439
A.1.1 Defining New Commands . . . . . 440
A.1.2 Defining New Environments . . . . 442
A.1.3 Defining and Changing Counters . . . 445
A.1.4 Defining and Changing Space Parameters . 448
A.2 Page Markup---Several Kinds of Boxes . . . 452
A.2.1 LR Boxes . . . . . . .. . 453
A.2.2 Paragraph Boxes . . . . . . . 456
A.2.3 Rule Boxes . . . . . . . . 459
A.2.4 Manipulating Boxed Material . . . . 460
A.3 Package and Class File Structure . . . 461
A.3.1 The Identification Part . . . . 463
A.3.2 The Initial Code Part . . . . 464
A.3.3 The Declaration of Options . . . . 464
A.3.4 The Execution of Options . . . . . 465
A.3.5 The Package Loading Part . . . . . 466
A.3.6 The Main Code Part . . . . . . 467
A.3.7 Special Commands for Package and Class Files 467
A.3.8 Special Commands for Class Files . . 468
A.4 calc---Arithmetic Calculations . . . . 469
A.5 ifthen---Advanced Control Structures . . 471
B TEX Archive Sites 477
B.1 The Main TEX Internet Sites. . . . . 477
B.2 Mail Servers . . . . . . . . 481
B.3 TEX User Groups . . . . . . . 481
Bibliography 483
Index 495
