Latex Companion (Year2001) (WithOCR)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 556

The ETEX Companion

Mchel Goossens
CN Division, CERN, Geneva, Switzerland

Frank MitteZbach
L4QX3 Project Coordinator, Mainz, Germany

Alexander Smarin
ISO, Geneva, Switzerland

vv
Boston

ADDISON-WESLEY San Francisco * New York * Toronto London * Munich Paris Madrid
Sydney
Tokyo

Montreal

Capetown

Singapore

Mexico City

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and we were aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers discounts on this book when ordered in quantity for special sales. For more information, please contact: Pearson Education Corporate Sales Division 201 W. 103rd Street Indianapolis, IN 46290 (800) 428-5331 corpsales @pearsoned.com Visit AW on the Web: www.awl.com/cseng/

Library of Congress Cataloging-in-Publication Data Goossens, Michel. The LaTeX companion / by Michel Goossens, Frank Mittelbach p. cm. Includes bibliographical references (p.) and index. ISBN 0-20 1-54199-8 1 . Samarin, 1. LaTeX (Computer file) 2. Computerized typesetting. I. Mittelbach, Frank. 1 I I .Title. Alexander. I Z253.4.L38666 1993 686.2'2544536-dc20 93-23 150 CIF'
Reproduced by Addison-Wesley from camera-ready copy supplied by the authors. Copyright O 1994 by Addison-Wesley All rights resewed. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. Printed in the United States of America. Published simultaneously in Canada. Text printed on recycled and acid-fiee paper. ISBN 0201541998 15 1617181920 CRS 04 03 02 01 15th Printing November 2001

To OUR WIVES CHRISTEL, AND TATIANA AND SONS ALEXEI, ANDREI, ARNO, NICOLAS, AND ROMAN FOR THEIR PATIENCE AND UNDERSTANDING.
mINA,

Addison-WesleySeries on Tools and Techniques for Computer Typesetting


This recently inaugurated series focuses on tools and techniques needed for computer typesetting and information processing with traditional and new media. Books in the series address the practical needs both of users and of system developers. Initial titles comprise A T E X users; forthcoming works will expand that core. Ultimately, the handy references for L series will cover other typesetting and information processing systems, as well, especially insofar as those systems offer unique value to the scientific and technical community. The series goal is to enhance your ability to produce, maintain, manipulate, or reuse articles, papers, reports, proposals, books, and other documents with professional quality. Ideas for this series should be directed to the editor: mittelbachQaw1 .corn. ,Allother comments and questions should be sent to Addison-Wesley: awcseQaw1 .corn. Series Editor Frank Mittelbach Manager LATEX3 Project, Germany Editorial Board JacquesAndre Irisa/Inria-Rennes, France Barbara Beeton Editor, TUGboat, USA David Brailsford University of Nottingham, UK Tim Bray Textuality Services, Canada Peter Flynn University College, Cork, Ireland Leslie Lamport Creator of L A W , USA Chris Rowley Open University, UK Richard Rubinstein Perot Systems, USA Paul Stiff University of Reading, UK

Series Titles The L A W Companion, by Michel Goossens, Frank Mittelbach, and Alexander Samarin The L A W Graphics Companion, by Michel Goossens, Sebastian Rahtz, and Frank Mittelbach The L A W Web Companion, by Michel Goossens and Sebastian Rahtz Also from Addison-Wesley: L A W : A Document Preparation System, Second Edition, by Leslie Lamport

Preface
W X is a generic typesetting system that uses TEX as its formatting engine. This companion is a detailed guide through the visible and not-so-visiblebeauties of PQX. As such, it is a comprehensive treatise of those points not fully discussed in Leslie Lamport's P Q X : A Document Preparation System (henceforth referred to as the I f Q X book) [49]. Extensions to basic W X , as described in that book, are discussed, so that the W X book, together with this companion, provide a ready reference to the full functionality of the IPQX system. A T E X Due to its flexibility, ease of use, and professional typographic quality, L is presently used in almost all areas of science and the humanities. Unlike many word processors, P Q X (and its underlying formatting engine TEX)comes free of charge and is not linked to any particular computer architecture or operating system. Since L A T E X source files are plain text files, it is possible to ship them, and the packages referenced, from any computer to any other computer in the world (over electronic networks or via normal mail). The recipient will be able to obtain a final output copy identical to the one generated at the sender's site, independently of the hardware used. Thus members of groups, geographically spread over several sites in different countries, or even on dfferent continents, can now work together in composing complex documents where different parts can be dealt with by different individuals, and then brought together without problems. Moreover, the use of electronic manuscripts has the potential to speed up the publication of papers by publishers. L A T E X is not difficult to learn and a beginner can benefit from the system after reading through the first few chapters of Lamport's L A T E X book, the basic reference on W X . After some experience, you will probably have to solve some more advanced problems whose solution cannot be found directly in that book. If you are one of those users who would like to know how W X can be extended

to create the nicest documents possible without becoming a (LA)TEXguru1, then this book is for you. You will be guided, step by step, through the various important areas of W X and be shown the links that exist between them. The structure of a I!QX document, the basic formatting tools, and the layout of the page are all dealt with in great detail. A sufficient library of packages in the area of floats, graphics, tables, Postscript, and multi-language support are presented in a convenient way. This book is the first volume to include all of the important L A T E X tools, such as: up-to-date descriptions of version 2 of the New Font Selection Scheme (NFSSZ), the A%S-LATEX mathematics extensions, the epic and eepic extensions to WX's p i c t u r e environment, and the Makelndex and BIBTEX programs for producing and controlling the generation of indices and bibliographic references. Finally, an overview of ways to define new commands and environments, lengths, boxes, general lists, etc., as well as ways of facilitating the handling of these objects, complete the picture. All three of us have been involved for several years in the support and development of IAQX applications in various professional environments and countries. We have taught the secrets of L A T E X to many different audiences, and have been listening to the user community by following the discussions in the text processing related news groups and at TEX conferences. This has allowed us to gather a coherent view of a vast collection of subjects, which, we think, you might need one day if you want to fully exploit the richness and strengths of the W X system. Note, however, that this book is not a replacement for, but a companion to, the L A T E Xbook. You are assumed to have read the first part of that book, and in. any case, it should be considered a reference for precise and full description of the W X commands. To make the presented information even more complete and useful, our readers are kindly invited to send their comments, suggestions, or remarks to any one of the authors. W e shall be glad to correct any remaining mistakes or oversights in a future edition, and are open to suggestions for improvements or the inclusion of important developments that we may have overlooked.

LATEX~E-T~~ New I4QX Release


Over the years many extensions have been developed for L A T E X with one unfortunate result: incompatible LATEX formats came into use at different sites. Thus, to process documents from various places, a site maintainer was forced to keep L A T E X (with and without NFSS), SLITEX,ANS-IQX, and so on. In addition, when looking at a source file it was not always clear what format the document was written for.
'A WTEX guru is a person knowing the internals of both L A T E X and primitive TEX by heart. In this book we use the logo (L~)TEX whenever we refer to both TEX and L A T E X .

vii

To put an end to this unsatisfactory situation a new L A T E X release was announced for fall 1993 that brings all such extensions back under a single format and thus prevents the proliferation of mutually incompatible dialects of L A T E X 2.09. With the new font selection will be standard and style files like amstex (formerly AmS-LATEX format) or slides (formerly SLITEXformat) will become extension packages, all working with the same base format. The introduction of a new release also made it possible to add a small number of often-requested features (like an extended version of \newcommand). All the new possibilities are described in this book, thus allowing you to make full use of the new IPQX release. To make it easy to distinguish between old W X 2.09 sources and new sources (makinguse of new features), the first command in a L A T E Xdocument was changed from \documentstyle to \documentclass, thus enabling the software to automatically detect an old source file and switch to compatibility mode if necessary.

The m X 3 Project
K@Xis presently being rewritten under the coordination of one of the authors (Frank Mittelbach), Chris Rowley and Rainer Schopf. This endeavor is called the m X 3 Project [571. A lot of the functionality described in this book as extensions to basic W X will be available in that system: as part of the kernel, or in one of the extension packages. To help funding, half of the royalties from t h s book will go directly to the W X 3 Project. Therefore, when buying this book, you not only obtain a handy, complete, and up-to-date reference to many important and useful packages available with L A T E X today, but you also actively contribute to making W&X more powerful and user-friendly in the future.

Acknowledgments
We first of all wish to thank Peter Gordon, our editor at Addison-Wesley, who not only made this book possible, but through his constant encouragement kept us on the right track. His suggestions and ideas made the companion richer, both in content and in form. W e also wish to acknowledge Marsha Finley, of Superscript Editorial Production Services, for the efficiency with whch she helped us with the practical aspects relating to the preparation of this book. Helen Goldstein, associate editor at Addison-Wesley, was always ready to advise us whenever we asked. We gratefully recognize all of our many colleagues in the (LA)TEXworld who developed the packages, not only those described here, but also the hundreds of others, which help users typeset their documents better and faster. Without the A T E X would not be the magnificent continuous effort of all these enthusiasts, L

and flexible tool it is today. We hope we have done some justice to them by mentioning, when first describing a given package, the original author and/or other major contributors, as far as this information was known to us. We are especially indebted to Johannes Braams, David Carlisle, Michael Downes, Sebastian Rahtz, and Rainer Schopf for their careful reading of the manuscript. Their numerous comments, suggestions, corrections, and hints have substantially improved the quality of the text. Roger Woolnough proofread an early version of the manuscript, Silvio Levy the chapter on NFSS. Finally we want to express our gratitude to CERN for allowing us to use its computer facilities for preparing the compuscript.

How to Read This Book


The titles of the various chapters should convey relatively clearly the subject area addressed in each case. In principle, all chapters can be read more or less independently and, if necessary, pointers are given to where complementary information can be found in other parts of the book.
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5

gives a short introduction to the IN&X system. discusses generic and document-oriented markup. describes L A T E X S ' basic typesetting commands. explains which tools are available to globally define the visual layout of the pages of a document by using pagestyles. shows how to assemble material into columns and rows with the extended tabular and array environments, and their multipage equivalents-supertabular and longtable. provides a general treatment of floating material. discusses in detail L A T E X S ' New Font Selection Scheme (NFSSZ) and presents its various user commands. It is shown how to add new fonts, both in math and text mode. reviews the amstex package, whch adds many powerful typesetting commands in the field of mathematics. looks at the problem of using L A T E X in the multi-language or non-English environment. The babel system and other languagespecific packages are described.
,

Chapter 6 Chapter 7

Chapter 8 Chapter 9

Chapter 10

addresses the field of device-independent graphcs showing how the epic, eepic and other packages extend the possibilities of L A T E X S ' basic picture environment.

Chapter 11

shows how the Postscript page description language not only can turn L A T E X into a full-blown graphics utility, but also how it makes it possible, via the NFSS, for a user to choose a font from amongst hundreds of font families, available as Postscript Type 1 outlines. tackles the problems associated with preparing an index. The program Makelndex is described in detail. surveys how L A T E X S ' companion program BIBTEX tries to solve problems related to maintaining bibliographic data bases. Various existing bibliographic styles are discussed and the format of the BETEX language used in the style files is presented in detad, allowing the user to customize an existing style. shows how to document I4QX files using the doc package and its companion program DOCSTRIP. first reviews how to handle and manipulate the basic L A T E X programming structures. The extensions introduced by the calc package in the field of arithmetic operations, and extended control structures added to 14QXZE are discu~sed.~ explains how to get the files described in this book from the E X Users Groups. various TEX archives or from the T

Chapter 12 Chapter 13

Chapter 14 Appendix A

Appendix B

In order to make the examples as independent as possible from basic TEX, extensive use has been made of the packages calc and ifthen, which are described in the appendices A.4 and A.5. You should study the extensions to W X , introduced in these packages, if you want to understand how many of the examples in this book function in detail. Many examples make use of new features in w X 2 ~especially ; font changes for text are all done in LATEX~E style, i.e., with the commands shown in table 7.2 on page 171. Abbreviated forms, like C\bf word) are normally not used, since they are style defined commands and may or may not be available for all classes of documents. While it is certainly possible to make good use of most parts of this book within a I4QX 2.09 environment (the event of w X 2 happened ~ after 90%of the book was finished) we suggest that you upgrade to the new version as soon as possible so that the worldwide community of W X users again speaks a single is able to identify and process old documents language. As said above, LATEX~E written for L A T E X 2.09. However, packages written or updated for W X Z E will not run with the old system.
-

2 ~ UTE~ n 2.09 programming structures like if-then-else were made available in the package ifthen; in U T E X ~ this ~ package is extended and enhanced.

Typographic Conventions
As explained in the discussion about the links between content and form or generic and layout markup, it is essential that the presentation of the material conveys immediately its function in the framework of the text. Therefore, we present below the typographic conventions used in this book. W X command and environment names are in monospaced type (for example, \caption, enumerate, \begin(tabular)), while names of package and class files are in sans-serif type (e.g., article). The syntax of L'QX constructs is presented inside a rectangular box. Command arguments are shown in italic type.

Lines containing examples with H E X commands are indented and are typeset in a monospaced type at a size somewhat smaller than that of the main text.
\chapter{Title of the Chapter) \sectionCSection Title) Some text.. .

When it is important to show the result of a series of commands, then the input and output are shown side by side as follows:
The right column shows the input text to be treated by W X . In the left column one sees the result after typesetting.
The right column shows the input text to be treated by \LaTeX{). In the left column one sees the result after typesetting.

For large examples, where the input and output cannot be shown conveniently alongside one another, the following layout is used:
I Input text
I

This i s a wide l i n e , whose input commands and output r e s u l t cannot be shown n i c e l y i n two columns.

Thls is a wide line, whose input commands and output result cannot be shown nicely in two columns.
I

Output text

Cross-references to page numbers where a given subject is treated in Leslie Lamport's L Q X book are shown in the margin in parentheses and are preceded by a calligraphic L,as seen here. They correspond to the page numbers as they

were in the first edition that described L A T E X 2.09; all differences to J4&X2are noted in t h s book. Commands to be typed by the user on a computer terminal are shown in monospaced type and are underlined, e.g.: This is user input.

Using All Those Packages


In this book we describe over 150 packages and options that extend or modify WX's basic possibilities. In order to show their action, we (in principle) have to load them all at the same time. For various reasons that is impractical, if not impossible. Indeed many packages, like program, use up a lot of counters, and TEX only allows a total of 256 counters. Therefore, when you hit this limit you must reduce the number of files you load simultaneously. In the production of this book we used a different strategy: we prepared some of the examples as separate files and included them as Encapsulated Postscript. Moreover, we used the package hackalloc. It redefines the allocation primitive so that all allocation becomes group-local. T h s means that by loading packages only when they are needed inside a brace group, the counter and length variables will be deallocated when you exit from the group. This procedure, however, can have some side effects, and should only be used with great care. However, we used most of the packages together, with the result that we had to recompile TEX several times during the preparation of this book. One of the log files produced during the last steps of the preparation showed the following summary:
Here is how much of TeXJs memory you used: 9692 strings out of 16716 118315 string characters out of 133654 236569 words of memory out of 262141 8131 multiletter control sequences out of 9500 81058 words of font info for 228 fonts, out of 90000 for 255 20 hyphenation exceptions out of 607 34i,23nJ41p,509bJ1403sstack positions out of 300i,40n,60p,3000bJ4000s Output written on companion.dvi (555 pages, 2008780 bytes).

As you can see, we nearly reached the font limit (which cannot be raised further) because of the many fonts shown in chapter 7, and the usage for strings, characters, main memory, and control sequences is probably much higher than in any IP@Xrun you ever made. This is not surprising given that the whole book is produced in a single L A T E X run with all those packages working together to produce the examples. Even when you do not reach a limit of the kind mentioned above, there are other interference effects between different packages. For instance, some extensions such as french make some characters active (i.e., some characters act as though they were control sequences). Problems may result when such a

character is then encountered in another package. This means that not all of the packages described in this book can be used together. Sometimes you can solve the problem by loading problematic packages as one of the last \usepackage declarations. Also, some packages make the Q character active (e.g., amstex), and this can have nasty consequences if you load other packages that use the @ character. As a rule of thumb, if you observe some odd behavior when you add a package to an existing list of packages, which seemed to work nicely together before, there might be a compatibility problem. Try loading the new file at the end, and if that does not work, take out each of the other files one by one. In this way you might find the file or files that are responsible for the problem.

Contents

1 Introduction 1 1.1 A Short History of T E X and IPQX . . . . . . . . . . . . . . . . . . . 1 1.1.1 In the Beginning There Was TEX . . . . . . . . . . . . . . . 1 1.1.2 Then Leslie Lamport Developed L A T E X ........... 2 1.1.3 With IPQX toward the Year 2000? . . . . . . . . . . . . . . 3 1.2 L A T E X and Its Components . . . . . . . . . . . . . . . . . . . . . . . 3 1.2.1 How Does IPQX Work? . . . . . . . . . . . . . . . . . . . . 3 1.2.2 Output Processors . . . . . . . . . . . . . . . . . . . . . . . 6 6 1.3 The Concept of Generic Markup . . . . . . . . . . . . . . . . . . . . 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 W&X Document 2.1 The Structure of a Source File . . . . . . . . . . . . . . . . . . . . . 2.1.1 Processing of Options and Packages . . . . . . . . . . . . 2.1.2 Splitting the Source File into Parts . . . . . . . . . . . . . 2.1.3 Combining Several Files . . . . . . . . . . . . . . . . . . . . 2.2 Logical Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Sectioning Commands . . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Numbering Headings . . . . . . . . . . . . . . . . . . . . . 2.3.2 Formatting Headirlgs . . . . . . . . . . . . . . . . . . . . . 2.3.3 Changing Fixed Heading Texts . . . . . . . . . . . . . . . .

11 11 13 16 17 17 18 20 24 30

xiv
2.4

Contents
Structure of the Table of Contents . . . . . . . . . . . . . . . . . . 2.4.1 Typesetting-a Contents List . . . . . . . . . . . . . . . . . 2.4.2 Entering Informationinto the Contents Files . . . . . . . 2.4.3 Defining a New TOC-Like File . . . . . . . . . . . . . . . . 2.4.4 Multiple Tables of Contents . . . . . . . . . . . . . . . . . Managing References . . . . . . . . . . . . . . . . . . . . . . . . . . 2.5.1 varioref-More Flexible Cross-References . . . . . . . . . 2.5.2 References to External Documents . . . . . . . . . . . . . Phrases and Paragraphs . . . . . . . . . . . . . . . . . . . . . . . . 3.1.1 letterspace-Changing Inter-Letter Spacing . . . . . . . . 3.1.2 u lem-Emphasize via Underline . . . . . . . . . . . . . . . 3.1.3 xspace-Gentle Spacing after a Macro . . . . . . . . . . . 3.1.4 Paragraph Justification . . . . . . . . . . . . . . . . . . . . 3.1.5 doubles pace-Changing Inter-Line Spacing . . . . . . . . 3.1.6 picinpar-Typeset a Paragraph with a Rectangular Hole 3.1.7 shapepar-Typeset a Paragraph with a Specified Shape . List Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2.1 Modifying the Standard Lists . . . . . . . . . . . . . . . . . 3.2.2 Making Your Own Lists . . . . . . . . . . . . . . . . . . . . Simulating Typed Text . . . . . . . . . . . . . . . . . . . . . . . . . 3.3.1 alltt-A Verbatim-Like Environment . . . . . . . . . . . 3.3.2 verbatim-A Style for Literal Text . . . . . . . . . . . . . . 3.3.3 moreverb-More Verbatim-Like Environments . . . . . . Footnotes, Endnotes, and Marginals . . . . . . . . . . . . . . . . . 3.4.1 Customizing Footnotes . . . . . . . . . . . . . . . . . . . . 3.4.2 Marginal Notes . . . . . . . . . . . . . . . . . . . . . . . . . 3.4.3 Endnotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using Multiple Columns . . . . . . . . . . . . . . . . . . . . . . . . . 3.5.1 multicol-A Flexible Way to Handle Multiple Columns . 3.5.2 Typesetting in Columns . . . . . . . . . . . . . . . . . . . . 3.5.3 Customizing the multicols Environment . . . . . . . . . 3.5.4 Floats and Footnotes in multicol . . . . . . . . . . . . . . 3.5.5 ftnright-Right Footnotes in a Two-Column Environment Simple Version Control . . . . . . . . . . . . . . . . . . . . . . . . . 31 32 35 36 36 40 41 45

2.5

3 Basic Formatting Tools

3.1

3.2

3.3

3.4

3.5

3.6

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 Pagestyles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 4.3.1 Writing New Page Styles . . . . . . . . . . . . . . . . . . . . 92

Contents 4.3.2 Customizing Page Styles with fancyheadings Visual Formatting . . . . . . . . . . . . . . . . . . . . .

xv

.......
.......

4.4

96 99

5 Tabular Material 5.1 Comparing the tabbing and t a b u l a r Environments . . . . . . . 5.2 Using the tabbing Environment . . . . . . . . . . . . . . . . . . . . 5.2.1 The program Environment . . . . . . . . . . . . . . . . . . 5.3 array-Extending the t a b u l a r Environments . . . . . . . . . . . . 5.3.1 Examples of Preamble Commands . . . . . . . . . . . . . 5.3.2 Style Parameters . . . . . . . . . . . . . . . . . . . . . . . . 5.3.3 Defining New Column Specifiers . . . . . . . . . . . . . . 5.3.4 Some Peculiarities of the array Implementation . . . . . 5.3.5 tabularx-Automatic Calculation of the Column Widths 5.3.6 delarray-Specifying Delimiters Surrounding an Array . 5.4 Multipage Tabular Material . . . . . . . . . . . . . . . . . . . . . . . 5.4.1 su pertab-Making Multipage Tabulars . . . . . . . . . . . 5.4.2 longtable-Sophisticated Multipage Tabulars . . . . . . . 5.4.3 A Final Comparison . . . . . . . . . . . . . . . . . . . . . . 5.5 Bells and Whistles . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.5.1 dcolumn-Defining Column Alignments . . . . . . . . . . 5.5.2 hhline-Combining Horizontal and Vertical Lines . . . . 5.6 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.6.1 Hyphenation in Narrow Columns . . . . . . . . . . . . . . 5.6.2 Footnotes in Tabular Material . . . . . . . . . . . . . . . . 5.6.3 Managing Tables with Wide Entries . . . . . . . . . . . . . 5.6.4 Columns Spanning Multiple Rows . . . . . . . . . . . . . . 5.6.5 Tables Inside Tables . . . . . . . . . . . . . . . . . . . . . . 5.6.6 Two More Examples . . . . . . . . . . . . . . . . . . . . . .
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

7.1 7.2

157 Introduction to NFSS . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Understanding Font Characteristics . . . . . . . . . . . . . . . . . 159

xvi

Contents
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 UsingFontsinText . . . . . . . . . . . . . . . . . . . . . . . . . . . 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 L A T E X 2.09 Font Commands . . . . . . . . . . . . . . . . . . 174 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 Standard Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 7.5.1 Providing New Text Fonts . . . . . . . . . . . . . . . . . . 180 7.5.2 Providing New Math Fonts . . . . . . . . . . . . . . . . . . 183 7.5.3 sl ides-Producing Overhead Slides . . . . . . . . . . . . . 185 7.5.4 Processing Older Documents . . . . . . . . . . . . . . . . 185 7.5.5 Special Packages for NFSS . . . . . . . . . . . . . . . . . . 186 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 Setting Up New Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . 194 7.7.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 7.7.2 Declaring New Font Farmlies 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 Warning and Error Messages . . . . . . . . . . . . . . . . . . . . . . 210

7.3

7.4

7.5

7.6

7.7

7.8

8 Higher Mathematics 215 8.1 The AMS-I!TEXProject . . . . . . . . . . . . . . . . . . . . . . . . . 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 . . . . . . . . . . . . . . . . . . . . 2 2 3

Contents
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\smashCommand . . . . . . . . . . . . . . . . . . . . 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-gDelimiters . . . . . . . . . . . . . . . . . . . . . . 230 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 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 s p l i t 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 \ i n t e r t e x t Command . . . . . . . . . . . . . . . . . 240 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 AJ@-I!QX Document Classes . . . . . . . . . . . . . . . . 244 Examples of Multiple-Line Equation Structures . . . . . . . . . . . 244 8.7.1 The s p l i t 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 s p l i t Environments w i t h gather 249 8.7.6 Using the alignat Environments . . . . . . . . . . . . . . 250

xvii

8.4

8.5

8.6

8.7

xviii
8.8

Contents

8.9

Extensions to the theorem Environment . . . . . . . . . . . . . . . 8.8.1 Defining New Theorem Environments . . . . . . . . . . . 8.8.2 Examples of the Definition and Use of Theorems . . . . 8.8.3 Special Considerations . . . . . . . . . . . . . . . . . . . . Mathematical Style Parameters . . . . . . . . . . . . . . . . . . . . 8.9.1 Controlling the Size of Characters . . . . . . . . . . . . . 8.9.2 W X Math Style Parameters . . . . . . . . . . . . . . . . .

251 252 253 254 255 255 256

9 W X in a Multilingual Environment 259 9.1 TEX and Non-English Languages . . . . . . . . . . . . . . . . . . . . 259 9.1.1 The Virtual Font Mechanism . . . . . . . . . . . . . . . . . 261 9.2 Babel-IPQX 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 WTEX

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 ThepictureEnvironment . . . . . . . . . . . . . . . . . . . . . . . 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 DrawingBar Charts . . . . . . . . . . . . . . . . . . . . . . 283 10.2.5 Examples of the barenv Environment . . . . . . . . . . . 286 10.2.6 Drawing Arbitrary Curves . . . . . . . . . . . . . . . . . . 287 10.2.7 Otherpackages . . . . . . . . . . . . . . . . . . . . . . . . . 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 L A T E X . . . . . . . . . . . . . . . . . . 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 DrawingTrees . . . . . . . . . . . . . . . . . . . . . . . . . 307

Contents 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 d v i 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 All TEX 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 Makelndex Program . . . . . . . . . . . . . . . . . . . 353 12.3.1 Detailed Options of the Makelndex Program . . . . . . . 355

xix

xx

Contents
12.3.2 ErrorMessages . . . . . . . . . . . . . . . . . . . . . . . . . Customizing the Index . . . . . . . . . . . . . . . . . . . . . . . . . 12.4.1 Example of Index Style Files . . . . . . . . . . . . . . . . . 12.4.2 A Stand-Alone Index . . . . . . . . . . . . . . . . . . . . . . 12.4.3 Changing the "Special Characters" . . . . . . . . . . . . . 12.4.4 Changing the Output Format of the Index . . . . . . . . . 12.4.5 Treating Funny Page Numbers . . . . . . . . . . . . . . . . 12.4.6 Glossary Entries . . . . . . . . . . . . . . . . . . . . . . . . 12.5 Modifying the Layout . . . . . . . . . . . . . . . . . . . . . . . . . . 12.5.1 Multiple Indexes . . . . . . . . . . . . . . . . . . . . . . . . 12.5.2 A Reimplementation of the Index Commands . . . . . . 356 357 358 358 360 361 363 364 364 365 367

12.4

13 Bibliography Generation 13.1 Entering the Citations . . . . . . . . . . . . . . . . . . . . . . . . . . 13.1.1 Customizing the Citations . . . . . . . . . . . . . . . . . . 13.1.2 Customizing the Bibliography Labels . . . . . . . . . . . . 13.2 Using BETEX with W X . . . . . . . . . . . . . . . . . . . . . . . . . 13.2.1 A List of BETEX Style Files . . . . . . . . . . . . . . . . . . 13.2.2 Examples of BETEX Styles . . . . . . . . . . . . . . . . . . . 13.3 Multiple Bibliographies in One Document . . . . . . . . . . . . . . 13.3.1 The chapterbib Package . . . . . . . . . . . . . . . . . . . . 13.3.2 The bibunits Package . . . . . . . . . . . . . . . . . . . . . 13.4 Bibliography Data Base Management Tools . . . . . . . . . . . . . 13.5 The General Format of the .bib File . . . . . . . . . . . . . . . . . 13.5.1 The General Format of a BETEXEntry . . . . . . . . . . . . 13.5.2 The Text Part of a Field Explained . . . . . . . . . . . . . 13.5.3 Abbreviations in BETEX . . . . . . . . . . . . . . . . . . . . 13.5.4 A BETEXPreamble . . . . . . . . . . . . . . . . . . . . . . . 13.5.5 Cross-References . . . . . . . . . . . . . . . . . . . . . . . . 13.5.6 Some Further Remarks . . . . . . . . . . . . . . . . . . . . 13.6 Detailed Description of the Entries . . . . . . . . . . . . . . . . . . 13.7 Understanding BETEX Styles . . . . . . . . . . . . . . . . . . . . . . 13.7.1 A General Description of a BIBTEXStyle File . . . . . . . . 13.7.2 The BETEX Style File Commands . . . . . . . . . . . . . . . 13.7.3 The Built-In Functions . . . . . . . . . . . . . . . . . . . . . 13.7.4 The Documentation Style btxbst .doc . . . . . . . . . . . 13.8 Introducing Small Changes in a Style File . . . . . . . . . . . . . . 13.8.1 Adding a New Field . . . . . . . . . . . . . . . . . . . . . . 13.8.2 Foreign Language Support . . . . . . . . . . . . . . . . . . 13.9 makebst-Customizing Bibliographic Style Files . . . . . . . . . . 13.9.1 Running makebst . . . . . . . . . . . . . . . . . . . . . . . 14 W X Package File Documentation Tools 14.1 Documenting Package Files . . . .

371 372 373 374 375 376 378 385 385 386 392 398 398 398 402 404 404 405 405 407 407 410 410 410 414 414 416 419 419
42 1

. . . . . . . . . . . . . . . . . . 421

Contents
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
A T E X Overview for Package and Class Writers 439 A AL A.1 Linking Markup and Formatting . . . . . . . . . . . . . . . . . . . . 439 A.1.1 Defining New Commands . . . . . . . . . . . . . . . . . . . 440 A.1.2 Defining New Environments . . . . . . . . . . . . . . . . . 442 A.1.3 Defmmg and Changing Counters . . . . . . . . . . . . . . 445 A.1.4 Defining and Changing Space Parameters . . . . . . . . . 447 A.2 Page Markup-Several Kinds of Boxes . . . . . . . . . . . . . . . . 451 A.2.1 LRBoxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 A.2.2 Paragraph Boxes . . . . . . . . . . . . . . . . . . . . . . . . 455 A.2.3 Rule Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 A.2.4 Manipulating Boxed Material . . . . . . . . . . . . . . . . . 459 Package and Class File Structure . . . . . . . . . . . . . . . . . . . 460 A.3 A.3.1 The Identification Part . . . . . . . . . . . . . . . . . . . . 462 A.3.2 The Initial Code Part . . . . . . . . . . . . . . . . . . . . . . 463 A.3.3 The Declaration of Options . . . . . . . . . . . . . . . . . . 463 A.3.4 The Execution of Options . . . . . . . . . . . . . . . . . . . 464 A.3.5 The Package Loading Part . . . . . . . . . . . . . . . . . . . 465 A.3.6 The Main Code Part . . . . . . . . . . . . . . . . . . . . . . 466 A.3.7 Special Commands for Package and Class Files . . . . . . 466 A.3.8 Special Commands for Class Files . . . . . . . . . . . . . . 467 A.4 calc-Arithmetic Calculations . . . . . . . . . . . . . . . . . . . . . 468 ifthen-Advanced Control Structures . . . . . . . . . . . . . . . . 470 A.5 B TEX Archive Sites 475 B.l TheMainT~XInternetSites . . . . . . . . . . . . . . . . . . . . . . 475 B.2 Mad Servers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479 B.3 TEXUser Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479

xxi

Bibliography Index

481

493

List of Tables

UTEX'S standard sectioning commands . . . . . . . . . . . . . . . . . . Syntax of the sectioning commands . . . . . . . . . . . . . . . . . . . Commands holding fixed texts for section headings . . . . . . . . . A summary of the minitoc parameters . . . . . . . . . . . . . . . . . . Effective \ b a s e l i n e s t r e t c h values . . . . . . . . . . . . . . . . . . . . Commands controlling an enumerate list environment . . . . . . . . Commands controlling an itemize list . . . . . . . . . . . . . . . . . Length parameters used by multicols . . . . . . . . . . . . . . . . . Counters used by multicols . . . . . . . . . . . . . . . . . . . . . . .

20 20 31 37 53 57 59 78 78

Standard paper-size options in LATEX^^ . . . . . . . . . . . . . . . . . 86 Default values for the page layout parameters (letterpaper) . . . . . 87 Page style defining commands in L A T E X . . . . . . . . . . . . . . . . . . 96 The preamble options in the array package . . . . . . . . . . . . . . . Comparing the TabularC and tabularx environments . . . . . . . . The Surats of the Holy Koran (supertabular) . . . . . . . . . . . . . The Surats of the Holy Koran (supertabular*) . . . . . . . . . . . . . The Surats of the Holy Koran (longtable) . . . . . . . . . . . . . . . . A summary of longtable commands . . . . . . . . . . . . . . . . . . A comparison of the longtable and supertabular environments . A comparison of the table declarations for longtable 105 116 120 121 123 124 127

andsupertabular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Example of a t h r e e p a r t t a b l e environment . . . . . . . . . . . . . . 133

radv

List of Tables

Float placement specifiers of the float package

. . . . . . . . . . . . . 149
170 171 173 176 181 182 182 183 184 190 191 192 206

The standard size-changing commands . . . . . . . . . . . . . . . . . Font-changing commands and declarations . . . . . . . . . . . . . . . Font attribute hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Predefined math alphabet identifiers in NFSS . . . . . . . . . . . . . . NFSS classification of the Computer Modern fonts . . . . . . . . . . . The Concrete families . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Pandora families . . . . . . . . . . . . . . . . . . . . . . . . . . . . The Old German text font families . . . . . . . . . . . . . . . . . . . . The Euler math families . . . . . . . . . . . . . . . . . . . . . . . . . . . Weight and width classification of fonts . . . . . . . . . . . . . . . . . Classification of font shapes . . . . . . . . . . . . . . . . . . . . . . . . The standard encodings used in NFSS . . . . . . . . . . . . . . . . . . The math symbol types . . . . . . . . . . . . . . . . . . . . . . . . . . .

Font commands available in mathematics with amstex . . . . . . . . 218 Math mode accents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Greek letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Binary operation symbols . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Relation symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Arrow symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Miscellaneous symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Variable-sized symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 Log-like symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 Delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 Large delimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 L A T E Xmath constructs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 AMS Greek and Hebrew . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 AMSdelimiters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .220 A M S arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 A M S negated arrows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 A M S binary relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 A M S negated binary relations . . . . . . . . . . . . . . . . . . . . . . . 222 A M S binary operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 AMS miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 The mathematical spacing commands . . . . . . . . . . . . . . . . . . 242 List of existing theorem styles . . . . . . . . . . . . . . . . . . . . . . . 253 The extended T E X font layout accepted at Cork in 1990 . . . . . . . Translation of document element names in the babel system . . . . Options supported by the babel system . . . . . . . . . . . . . . . . . Comparison of French and English typography . . . . . . . . . . . . . 261 267 267 274

List of Tables

xxv

11.1 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.10 11.11 11.12

Major options of the dvips program . . . . . . . . . . . . . . . . . . . Overview of dvi-driver support for various packages . . . . . . . . . Rotating tabular information . . . . . . . . . . . . . . . . . . . . . . . . Example of the sidewaystable environment . . . . . . . . . . . . . . . K . Berry's font file name classification scheme . . . . . . . . . . . . . NFSS classification of the basic Postscript fonts . . . . . . . . . . . . Fonts used by various PSNFSS packages . . . . . . . . . . . . . . . . . The characters in the Postscript font ZapfDingbats . . . . . . . . . . The characters in the Postscript font Symbol . . . . . . . . . . . . . . Accessing the Greek characters in the Postscript font Symbol . . . . Original Adobe font layout for the Helvetica font . . . . . . . . . . . E X font layout with Helvetica . . . . . . . . . . . . . . . . . . . . . DC T

316 317 325 326 332 333 334 336 338 338 341 341

12.1 Input style parameters for MakeIndex . . . . . . . . . . . . . . . . . . 358 12.2 Output style parameters for MakeIndex . . . . . . . . . . . . . . . . . 359 13.1 13.2 13.3 13.4 13.5 13.6 Selection of BIBTEX style files . . . . . . . . . . . . . . . . . . . . . . . . entry types as defined in most styles . . . . . . . . . List of BIBTEX'S List of BIBTEX'S standard entry fields . . . . . . . . . . . . . . . . . . . style file commands . . . . . . . . . . . . . . . . . . . . . List of BIBTEX style file built-in functions . . . . . . . . . . . . . . . . . List of BIBTEX The BETEX style files of the Delphi system . . . . . . . . . . . . . . . . 377 408 409 412 413 418

14.1 Overview of doc package commands


A.l A.2 A.3 A.4 A.5

. . . . . . . . . . . . . . . . . . . 429
449 450 451 461 473

(I4)T~x's units of length . . . . . . . . . . . . . . . . . . . . . . . . . . . Predefined horizontal spaces . . . . . . . . . . . . . . . . . . . . . . . Predefined vertical spaces . . . . . . . . . . . . . . . . . . . . . . . . . Commands describing the structure of package and class files . . . The important internal \boolean switches . . . . . . . . . . . . . . .

List of Figures

Main files needed by TEX and IFQX

....................

An example of a document preamble . . . . . . . . . . . . . . . . . . . Structuring a W X document . . . . . . . . . . . . . . . . . . . . . . . The hierarchical structure of a simple I t Q X document . . . . . . . . The hierarchical structure of a complex K&X document . . . . . . . Numbering the section headings . . . . . . . . . . . . . . . . . . . . . The layout for a display heading . . . . . . . . . . . . . . . . . . . . . The layout for a run-in heading . . . . . . . . . . . . . . . . . . . . . . Changing the style of a heading . . . . . . . . . . . . . . . . . . . . . . Conventions for the \secdef command . . . . . . . . . . . . . . . . . Generating table of contents entries . . . . . . . . . . . . . . . . . . . Parameters defining the layout of a contents file . . . . . . . . . . . . Mini-table of contents-input example . . . . . . . . . . . . . . . . . . Mini-table of contents-output example . . . . . . . . . . . . . . . . .

12 16 18 19 21 25 26 28 29 33 34 38 39
53 54 55 55 62 67 71 81

Spaced-out paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . A "window" in a paragraph . . . . . . . . . . . . . . . . . . . . . . . . . United Kingdom . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A paragraph embedded figure . . . . . . . . . . . . . . . . . . . . . . . The structure of a general list . . . . . . . . . . . . . . . . . . . . . . . Verbatim-like a l l t t environment . . . . . . . . . . . . . . . . . . . . . Schematic layout of footnotes . . . . . . . . . . . . . . . . . . . . . . . The placement of text and footnotes with the ftnright package . . .

XXViii

List of Figures

4.1 4.2 4.3 4.4 4.5 4.6 6.1 6.2 6.3 6.4 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 9.1 9.2 9.3 10.1 10.2 10.3 10.4 10.5 10.6 10.7

The page layout for The BTEX Companion . . . . . . . . . . . . . . . . Page styles used in The BTEX Companion . . . . . . . . . . . . . . . . Schematic overview of how L A T E X S ' marker mechanism works . . . . The page layout parameters for the fancyheadings package . . . . . The default page layout with the fancyheadings package . . . . . . . A T E Xbook . . . . . . . . . . Running header/footer settings for the L Two "nonstandard" floats-Program and algorithm . . . . . . . . . An example with a narrow floating figure . . . . . . . . . . . . . . . . A wrapf igure example . . . . . . . . . . . . . . . . . . . . . . . . . . . Three subfigures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

85 93 95 97 98 99 148 151 152 153

Major font characteristics . . . . . . . . . . . . . . . . . . . . . . . . . 159 Comparison of serifed and sans serif letters . . . . . . . . . . . . . . 160 Comparison between upright and itahc shapes . . . . . . . . . . . . . 161 Comparison between caps and small caps . . . . . . . . . . . . . . . . 162 Outline and shaded shapes . . . . . . . . . . . . . . . . . . . . . . . . . 163 Scaled and designed fonts . . . . . . . . . . . . . . . . . . . . . . . . . 164 The Initial font y i n i t by Yannis Haralambous . . . . . . . . . . . . . 183 Output of the nfssfont.tex program for the font msbm7 . . . . . . . . 207 Dates and dialects in babel . . . . . . . . . . . . . . . . . . . . . . . . . 265 Example using babel's option german . . . . . . . . . . . . . . . . . . 268 Example using babel's option francais . . . . . . . . . . . . . . . . . . 270 Example of a bar chart-2-D option . . . . . . . . . . . . . . . . . . . . Example of a bar chart-3-D option . . . . . . . . . . . . . . . . . . . . Example of a picture generated with the Feynman package . . . . . Example of chemical formula . . . . . . . . . . . . . . . . . . . . . . . Electronic circuit symbols prepared with picture commands . . . . Line drawing commands with the epic and eepic packages . . . . . . A graph made with the epic and eepic packages . . . . . . . . . . . . 288 289 294 295 295 304 305 314 319 320 321 321 321 323 327 342 343 344

11.1 Examples of the capabilities of Postscript . . . . . . . . . . . . . . . . 11.2 A single centered figure . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 A figure in draft mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.4 Pre-1991Europe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.5 Central America . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.6 A map of the world . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.7 Rotation of paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.8 A normal, turned. and sideways picture within a figure . . . . . . . . 11.9 Example of a page typeset with the Computer Modern fonts . . . . . 11.10 Example of a page typeset with the Mathtime fonts . . . . . . . . . . 11.11 Example of a page typeset with the Lucida Math fonts . . . . . . . .

List of Figures 12.1 The sequential flow of index processing . . . . . . . . . . . . . . . . . 12.2 Stepwise development of index processing . . . . . . . . . . . . . . . 12.3 Example of \index commands and the showidx package . . . . . . . 12.4 Printing the index and the output of the showidx option . . . . . . . 12.5 Changing the special characters in Makelndex . . . . . . . . . . . . . . 12.6 Changing the output format of the index . . . . . . . . . . . . . . . . 12.7 Adding leaders to an index . . . . . . . . . . . . . . . . . . . . . . . . . 12.8 Example input file for multiple indexes . . . . . . . . . . . . . . . . . 12.9 Output file showing multiple indexes . . . . . . . . . . . . . . . . . . 12.10 Multiple indexes-input file . . . . . . . . . . . . . . . . . . . . . . . . 12.11 Multiple indexes-running L A T E X and Makelndex . . . . . . . . . . . . 12.12 Multiple indexes-output example . . . . . . . . . . . . . . . . . . . . 13.1 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.9 13.10 13.11 13.12 13.13 13.14 13.15 13.16 13.17 13.18 14.1 14.2 14.3 14.4 14.5 14.6 14.7
A.1

rodx
346 347 354 354 361 362 362 366 366 368 369 370 375 379 380 381 382 383 384 387 388 389 390 391 395 396 397 416 417 418 426 427 428 435 436 437 438 452 468

Data flow when running BBTEXand L A T E X ................ Example of a file using BBTEX . . . . . . . . . . . . . . . . . . . . Running L?&X with a BBTEXbibliography data base . . . . . . . . . . ExampleofaB~T~Xdatabase ....................... Output examples of the plain and unsrt BBTEX styles . . . . . . . . . Output examples of the alpha and abbrv BBTEX styles . . . . . . . . Output examples of the acm and apalike BBTEX styles . . . . . . . . Multiple bibliographies in one file (input file) . . . . . . . . . . . . . . Multiple bibliographies in one file (generated output) . . . . . . . . . Example input for the bi bunits package . . . . . . . . . . . . . . . . . Running multiple bibliographes with the bibunits style . . . . . . . Multiple bibliographies using the bibunits style (output) . . . . . . . List of entries in bsample .bib using biblist . . . . . . . . . . . . . . . List of entries in bsample.bib using printbib . . . . . . . . . . . . . . List of entries in bsample .bib using showtags.sty . . . . . . . . . . . Adapting a BBTEX style to Dutch . . . . . . . . . . . . . . . . . . . . . Customizing a BBTEX style file for a different language . . . . . . . . Ignoring articles in BBTEXsorting . . . . . . . . . . . . . . . . . . . . . doc driver file example . . . . . . . . . . . . . . . . . . . . . . . . . . . Example of a file documented with the doc system . . . . . . . . . . Documentation generated by the doc system . . . . . . . . . . . . . . The batch file for the "file-error" system . . . . . . . . . . . . . . . . . The transcript file when installing the "file-error" system . . . . . . The source of the doc file for the "file-error" system . . . . . . . . . Output generated by running the file f ileerr dtx through W X .

A.2

A title page example . . . . . . . . . . . . . . An example of a class file extending article

............... ...............

xxx
B.l B.2 B.3

List of Figures
An example ftp session to the Aston CTAN T E X archive (part 1) . . . 477 An example ftp session to the Aston CTAN T E X archive (part 2) . . . 478 Example of TEX mail servers . . . . . . . . . . . . . . . . . . . . . . . . 4 79

C H A P T E R

Introduction
L A T E X is not just a system for typesetting mathematics. Its applications span the one-page memorandums, business or personal letters, newsletters, articles about exact sciences and developments in the humanities, and full-scale book and reference works on all topics. Nowadays, versions of L A T E X exist for practically every large mainframe, workstation, or personal computer. To better understand why this happened, the first section of this chapter looks back at E X and W X , and then asks where to go next. The second section the origins of T gives an overview of the I f Q X system as a whole. This orientation should help the reader to clearly understand the r81e of the various components and files created by L A T E X . The important difference between generic and visual markup is the subject of the next sections. The advantages of the generic approach are exm plhined in the context of the separation of the content and form of a document, and it is emphasized that documents should be built on the generic principle as much as possible. When, for the sake of clarity, it proves necessary to use visual markup, the latter should be classified into categories whose definitions are grouped at the beginning of the document and then used locally. T h s practice guarantees consistency and ease of use.

1.1 A Short History of T~Xand W X


1.1.1 I n the Beginning There Was Q X
In May 1977, Donald Knuth of Stanford University 1381 started work on a textprocessing system which is now known as TEX and METAFONT [39-431. In E X book [39] Knuth writes: "TEX [is] a new typesetting the foreword of the T

Introduction
system intended for the creation of beautiful books-and especially for books that contain a lot of mathematics. B y preparing a manuscript in TEX format, you will be telling a computer exactly how the manuscript is to be transformed into pages whose typographic quality is comparable to that of the world's finest printers." TEXhas become popular with thousands of scientists because it can be used for transforming any kind of writing into articles, reports, proposals, books, poetry, and other formats in a way that can be specified completely by the writer through a rich language of commands. The companion program METAFONT allows the design of typefaces to be used to print the output pages. TEXis particularly useful when the document contains mathematical formulae or when book-llke quality appearance is desired. Moreover, it is a portable system, running on a wide range of computer platforms, from micros to mainframes, and its behavior is identical on all machines, a fact extremely important in the scientific and t e c h c a l community. Related to this portability is TEX'S printing device independence, so that a document can be printed on anything from a CRT screen, a medium-resolution dot matrix or laser printer, to a professional high-resolution phototypesetter. Because of these qualities, and since it is available in the public domain, T E X has become the de facto standard text-processing system in many academic departments and research laboratories, whilst it also gains momentum in the professional publishing world as a printing engine. It is available on every conceivable computer platform, from I B M PC-like personal computers and Macintoshes, via UNU( and V M S workstations, to supercomputers like the Cray. In addition, excellent previewers are available that run on most workstations and other graphic displays. In h s foreword to TEX and METAFONT, New Directions in Typesetting [37] Gordon Bell wrote over ten years ago that "Don Knuth's Tau Epsilon C h (TEX)is potentially the most significant invention in typesetting in this century. It introduces a standard language in computer typography and in terms of importance could rank near the introduction of the Gutenberg press." Recently, Donald Knuth officially announced that TEX would not undergo any further development [47] in the interest of stability.

1.1.2 Then Leslie Larnport Developed L A T E X


At the beginning of the 1980s, Leslie Lamport started work on a document preparation system called W X , based on the T E X formatter. The system adds a level of abstraction to the plain TEX commands and lets the user concentrate on the structure of a document rather than on formatting details. A few high-level commands allow the user to easily compose most documents. You do not have to worry about typography. Such details are left to the document designer who has the task of providing style files for every application.

1.2 K&X and Its Components

L A T E X S ' functionality, in conjunction with a few auxiliary programs, includes the generation of indices, bibliographies, cross-references, and tables of contents, and the inclusion of figures-features that are lacking in basic TEX.

1.1.3 With K&X toward the Year 2000?


Since the number of TEXand especially L A T E Xusers has grown to many thousands in the last few years, E Q X has spread into areas for which it is not necessarily optimized (law texts, critical editions of classic authors, poetry, side-by-side multi-language editions, newsletters, to name a few). Recent issues of TUGboat, the journal of the TEX Users Group, have carried a number of articles about the shortcomings of TEX,W X and their associated programs [55,59,61,88,91]. After a meeting with Leslie Larnport at the 1989 T E XUsers Group meeting in Stanford, Frank Mittelbach, Chris Rowley, and Rainer Schijpf started work on a A T E X , the so-called W X 3 Project [57]. The reimplementation and extension of L main idea is to build an optimized and efficient kernel with basic commands complemented by various packages that will handle functionality in specific areas (like tables, pictures, and mathematics). The new system will provide a complete reimplementation of the style file user interface, making it easier to develop and maintain one's own styles. In March 1992 at the German DANTE TEX Users meeting in Hamburg a discussion group, NTS, for "The New Typesetting System," was set up to discuss E X should be extended to provide the functionality and coordinate areas where T needed for creating "masterpieces of the Publishing Art" [81].

1.2 L A T E X and Its Components


This section introduces the basic principles of the IF&Xenvironment, and describes briefly the various files and programs, about which an informed ETEX user should know. More details can be found in an article by Joachim Schrod, "The Components of TEX" [76].

1.2.1 How Does W X Work?


W X reads and writes several files and you should have a clear understanding of their function. Figure 1.1 on the next page shows schematically the flow of information in a P Q X run and presents a list of the various files needed. The most important file in any L A T E X run is the input source file. It is a plain text file, usually prepared with a text editor, and in general has the extension .tex. Files containing structure and layout definitions (extensions .c l s , .sty) are usually stored in some standard directories. W X is distributed with five standard document classes, namely, article, report, book, slides, and letter.

Introduction

User's input file (tex)

bbl, ind

Working files
idx I

Format file (f mt) Class and package files ( c l s , s t y ) Font metrics ( t f m ) Font definitions (f d)

I4'T-X

TEX output file (dvi)

Postscript

Screen

Printer

Text file

Explanation File extension . t e x , .l t x E Q X input file .d v i TEX formatted output file .log, .t e x l o g , . l i s , . l i s t TEX transcript file .mf METAFONT sources file .fd Font definition file Font image file .pk .tfm Font metrics file .pool, .poo, . p o l String pool file .fmt Format file .c l o , . c l s , . d t x , . s t y LATEX layout & structure file .aux IN&X auxiliary file .t o c Table of contents file .l o f List of figures file .lot List of tables file .bbl, .bib, .blg, .b s t BIBTEX related files Index and Makelndex related files . idx, . i l g , .ind, .i s t
Figure 1.1:Overview of the main files needed by TEX and LATEX

1.2 BTEX and Its Components

These basic document classes can be further customized by specifying one or more class options or using additional packages like those described in t h s book. The dimensions of the characters for fonts used by TEX are called font E X font metrics). For each font used metrics and are encoded in .t f m files (for T in a document there must be a .t f m file describing height, depth, and width as well as kerning information for every character. TEX only uses these character boxes in its line-breaking algorithm when composing paragraphs. TEX hyphenates words automatically using a language-independent trie-algorithm [53]. For each language, a different set of word-breaking hyphenation patterns can be specified when a format (extension .fmt) file is generated. The L Q X format (usually called l p l a i n .f m t or latex. f m t ) mainly contains a precompiled image of all W X commands, and the .tfm information for the several preloaded fonts. The correspondence between internal font names and external font files is stored in font-definition files (extension .f d). The output from W X is a set of files. One of them (extension .dvi) contains a representation of the formatted text where the type and position on the page are specified for each character to be output. These .dvi files specify only font names-they do not contain the actual character images. TEX positions its (character)boxes with a resolution better than a thousandth of an inch, so that the output file generated by T E Xcan be effectively considered device independent, hence the name .dvi. To visualize the result the .dvi file must be transformed by a "dvi driver" into the desired output format (e.g., Postscript). For every run, LaTeX generates a transcript file that usually has the extension .log or .l i s but may have others (or even none at all), depending on the operating system. This file contains information, most of which also appears on the screen, such as the names of the files read, the numbers of the pages processed, warning and error messages, and other pertinent data. Other K&X output files contain information about cross-referencing (extension .aux), table of contents (extension .toc), list of figures (extension .lof), and list of tables (extension . l o t ) . They are used in a subsequent W&X run to produce particular elements of the document. A file with extension .idx contains all indexed items. They can be sorted by a program like Makelndex, which was written by Pehong Chen and Michael Harrison. MakeIndex reads the .idx file that contains the index entries and the corresponding page numbers, sorts these items, unifies them, and writes them as W X input into a file (extension .ind). Index style information can be specified in an .ist file. Messages created by Makelndex are written to the .i l g file (see chapter 1 2 for more details). BETEX (see chapter 13)is a program written by Oren Patashnik for the preparation of bibliographies. BETEX handles reference data bases collected in .bib files. W&X writes information about the references required in a document into its .aux file(s);the latter are then read by BETEX,which generates a sorted bibliography in a .bbl file. The .bbl file is used by I!QX in a subsequent run. The

Introduction
kind of sorting and the format of the "cite keys" are defined by bibliography styles, specified in .bst files. The messages generated by BETEXare written to a .blg transcript file.

1.2.2 Output Processors (dvi Drivers)


Once the document has been successfully processed by TEX, you will probably want to see the result. Several options are open, namely: Generate a high-quality (greater than 1000 dpi) copy on paper. In this case the .dvi file is translated into dots on a film via a dedicated driver or PostScript is generated. Generate a medium-quality (300 dpi) copy on paper. Different dvi drivers, specific to a given printing device, can be used. More and more often, PostScript is becoming the obvious choice. The contents (text and graphics) can be visualized on a computer graphics screen, where utilities like xdvi (on X Window System) can be used. Again, PostScript previewers can use the latter language for looking at the information in the document. The contents may be viewable on a "dumb" character-only terminal. Graphics cannot be shown in thls case, but the text is formatted in columns narrow enough to fit nicely on screen less than 80 columns wide. This kind of documentation is often used for bundling computer program descriptions with the code. It is clear from the above that the PostScript language plays an important r61e in the process of document visualization. METAFONT sources (.mf) exist for all Computer Modern and I Q X fonts, and thus bitmap images (.pk) can be generated for any kind of printer. PostScript Type 1 renderings of the Computer Modern, W X , American Mathematical Society, and Euler fonts also exist and are commercially available from Blue Sky Research and Y&Y. Moreover, Adobe and A T E X other type foundries offer a vast choice of fonts, which can be used with L (see section 11.9). This means that you can decide what is the best (and most pleasing) way to present the information in your document.

1.3 The Concept of Generic Markup


1.3.1 What Is Generic Markup?
Originally, markup was the annotation of manuscripts by a copyeditor telling the typesetter how to format the manuscript. It consisted of handwritten notes

1.3 The Concept of Generic Markup

such as: "Set this heading in 12-point Helvetica Italic on a 10-point text body, justified on a 22-pica slug with indents o f 1 em on the left and none on the right." With the introduction of computers, these remarks could be coded electronically using a special coding system. Each phototypesetter had its own proprietary "language," called markup language by analogy with the old manual system. Since many typesetting companies also provided a "keyboarding" service, the markup source of the documents to be typeset was always the same and the lack of compatibility was not an issue. When, however, authors and clients of typesetting companies started to type their own manuscripts this situation created problems. They could only do the typing if they knew in advance the markup format of their typesetting vendor. If they typed on their own system, it was likely that the markup format of their document would be incompatible with that of the typesetter. The situation only got worse when people started using computers for document preparation. As in the case of phototypesetting systems, documents were coded with specific markup commands. These are low-level formatting commands such as "carriage return," "center the following text," and "go to the next page." A document containing the following specific markup (SCRIPT [3 11):
.pa ;.sp 2 ;.ce ;.bd Title of chapter SP

can only be converted to other typesetting systems at great cost. Another exarnple of specific markup (plain TEX) is:
\vfill\eject\begingroup\bf\obeylines\vskip 20pt \hfil TITLE OF CHAPTER \vskip lOpt\endgroup\bigskip

A movement was started to create a standard markup language, which all typesetting vendors would be persuaded to accept as input. It would be the typesetter's problem to translate this language into the language of their own photocomposition machines. This markup language was a generic markup language. Generic markup means adding information to the text indicating the logical components of a document such as paragraphs, headings, and footnotes. The formatting (visualrepresentation) associated with a component is decoupled from its function (position) in the (hierarchical)structure of the text. LATEX is, to a large extent, an example of a "generic markup language" (GML). Thanks to the class file mechanism, the visual style of the various document elements are described in a single place outside of the source document itself. Building on the pioneering GML work by Charles Goldfarb and also taking into account ideas of Brian Reid's Scribe system, the International Standards Organization developed the SGML (Standard Generalized Markup Language)

Introduction

standard (IS0 8879), which was published in 1986. SGML is a markup language for representing documents in an exchangeable format. SGML is intended "for publishmg in its broadest definition, ranging from single medium conventional publishng to multimedia data base publishing. SGML can also be used in office document processing when the benefits of human readability and interchange with publishing systems are required." [34]For an introduction to SGML, see [27,92]. SGML is a meta-language. That is, it specifies the rules by which an infinite variety of markup languages can be created. SGML should not concern itself with the formatting of marked-up documents, i.e., there should be no "layout" tags in SGML, like "new page," "new line," or "rule." Instead, these layout-oriented features are properties of certain format components. For example, a heading of level 1 may, in a given layout style, be starting a new page, or a rule may be used to separate a heading from the body of a memo. As a practical typesetting tool, authored by a scientist, U T E E X combines and balances the advantages of high-level generic characteristics a la SGML, with layout specific support. The class file mechanism makes it possible to produce the same source document in different layouts, while enough bells and whistles are available to fine-tune important documents for producing the highest quality.

1.3.2 Advantages of Generic Markup


The use of a consistent layout throughout a document helps the reader understand the various visual clues associated with a given component. It also allows' the document to be reused for producing online documentation, or eases the automatic extraction of information via predefined keywords. One should also bear in mind the fact that typography is a creative skill, requiring a level of experience and craftsmanship that is rarely found in the untrained layman. Therefore the development of a new style is better left to specialist designers, and casual users should restrict themselves mostly to small and consistent modifications of an already existing style. Extreme care should be taken not to upset the subtle visual balance between the various document elements.

1.3.3 Separation of Content and Form


In order to ensure that all logical document elements receive the same typographical treatment throughout the document, you should define new document elements in a generic way in the document preamble. B y this means you can be sure that the same presentation will be used everywhere to flag the element in question. As an example, when writing a reference manual you might want to have every occurrence of a command typeset in a given font, and entered in the index automatically. Or you might choose to put the description of a command with its

1.4 Necessity of Layout Markup

parameters in a shaded box, always in an identical way. You might even contemplate giving a certain presentation form to your t a b u l a r material. Therefore, it is best to define a corresponding style for your t a b u l a r environment in the document preamble. Similar considerations apply for lists, headings, and so on. Definitions of (and possible later changes) need only be made in one place in the preamble, and they will propagate automatically to your complete document. Another advantage of using generic commands is that it is extremely simple to apply a different style just by selecting a different class in the \documentclass or specifying additional options to the \documentclass and \usepackage commands (see section 2.1 on page 11).

1.4 Necessity of Layout Markup


Notwithstanding all the benefits of generic markup, as discussed above, in the final preparation of your document you will sometimes need to overrule the decisions made by TEX. An example is the representation of data in a t a b u l a r environment where the clarity of the layout of the data in the table can contribute substantially to a better understanding of the presentation. Moreover, when the final version of a document is being readied, it frequently occurs that the author has to insert line and page breaks in some strategic places.

1.4.1 Pitfalls of Layout Markup


As already pointed out, it is not good practice to make certain layout markup A T E X decisions inside the text of a document. It is much better to define a new L environment, like Ctab for a centered t a b u l a r environment, if that is what is generally desired. Similarly, local font changes inside an environment should be limited and the generic nature of the use of a given font should be formalized by delirung a corresponding specific new environment or command. Otherwise, any change in the presentation of your material results in an enormous amount of manual labor-you have to find and modify every instance of your layout markup. You should also not misuse generic structural commands to obtain a given visual effect. For example, the sectioning commands like \paragraph should not be used to get the first few words in a paragraph in bold face. Sectioning commands have a structural function inside a document (see section 2.3.1 on page 20) and using them to customize the local layout might generate some surprises when you switch to a different implementation of the same class structures-like seeing some of your paragraphs getting preceded by numbers! You are better off d e h g a dedicated command llke \Boldtext or \Boldpar to obtain the desired effect.

10

Introduction

1.4.2 When to Use Layout Markup


When preparing the final form of a document you will find that it is often necessary to intervene locally at the micro-level to obtain a certain visual effect. Nevertheless it is always preferable to hide as much as possible the layout markup behnd the generic markup. You can do this, for example, by building into the generic commands facilities for checking the space left on the page, for calculating the width of certain text strings, and so on.

C H A P T E R

The Structure of a LATEX

Document
As explained earlier it is important to separate the form and structure of a document. In this chapter we show how this general principle is implemented in L A T E X . The first section of this chapter shows how document class files, packages, options, and preamble commands can affect the structure and layout of a d0cument.l The logical scbdivisions of a document are discussed in general, before explaining in more detail how sectioning commands and their arguments define a hierarchical structure, how they generate numbers for titles, and how they produce running heads and feet. Different ways of typesetting section titles are presented with the help of examples. It is also shown how the information that is written to the table of contents can be controlled and how the look of this table, as well as that of the lists of tables and figures, can be customized. The final section introduces W X commands for managing cross-references and their scoping rules.

2.1 The Structure of a Source File


You can use W X for several purposes, like writing an article or a letter, or producing your overhead slides. Clearly, documents for different purposes may
'Compared to BTEX 2.09, in BTEXZ~ the general structure of the source file has been reorganized and enhanced. Older documents will be treated automatically using a compatibility mode.

12

The Structure of a UTFX Document

Figure 2.1: An example of a document preamble The class of this document is article. The layout is influencedwith the formatting request twocolumn (typeset in two columns) and the option a4paper (paper to print on is A4). The first \usepackage declaration informs W X that this document contains commands and structures provided by the package multicol. W e also use the babel package with the options german (support for German language) and french (support for French language). Finally, for this document the default height of the text body was enlarged by two centimeters. need different logical structures, i.e., different commands and environments. We say that a document belongs to a class of documents having the same general structure (but not necessarily the same typographical appearance). You specify the class your document belongs to by starting your W&X file with a \documentclass command, where the mandatory parameter specifies the name of the document class. The document class defines the available logical commands and environments (for example, \chapter in the report class) as well as a default formatting for those elements. An optional argument allows you to modify the formatting of those elements by supplying a list of class options. For example, 1 1 pt is an option recognized by most document classes that instructs W X to choose eleven point as the basic document type size. Many I4QX commands described in this book are not specific to a single class but can be used with several classes. A collection of such commands is called a package and you inform W X about your use of certain packages in your document by placing one or more \usepackage commands after \documentclass. Just like the \documentclass declaration, the \usepackage declaration has a mandatory argument that is the name of the package and an optional argument that can contain a List of package options that modify the behavior of the package. The document classes and the packages are realized in external files with the extension . c l s and .sty, respe~tively.~ Code for class options is sometimes stored in files (in this case with the extension . clo) but is normally directly specified in the class or package file. See appendix A for more information on
'1n J4&X2.09 "style files" had the extension . s t y . Since nearly all such style files for W T E X 2.09 can be used without modifications as packages in IATEXZE,. s t y was chosen as the extension for packages in IATEXZE.

2.1 The Structure of a Source File

13

declaring options. However, in case of options, the file name can differ from the option name, for example, the option 1 1 pt might be related to art11.clo when used in the article class and to bkil. clo inside the book class. Commands between the \documentclass command and \beginCdocument) are in the so-called document preamble. All style parameters must be defined in that area, either in package or class files or directly in your document before the \beginCdocument) command, which sets the values for some of the global parameters; an example is shown in figure 2.1 on the facing page. As a rule, nonstandard W X package files contain general modifications or improvements3 with respect to standard I Q X , while commands in the preamble define changes for the current document. Thus, if you want to modify the layout of your document you have several possibilities: change the standard settings for parameters in a class file by options defined for that class; add one or more packages to your document and make use of them; change the standard settings for parameters in a package file by options defined for that package; define your own local packages containing special parameter settings and load them with \usepackage after the package or class they are supposed to modify (this is explained in the next section), and make last minute adjustments inside the preamble. And if you want to get deeper into LATEX'S internals, you can, of course, define your own general purpose packages that can be manipulated with options. For this you will find additional information in appendix A.

2.1.1 Processing of Options and Packages


The algorithm in LATEX~E used to process the options of \documentclass and \usepackage is more powerful than the mechanism that handled options in the I4QX 2.09 \documentstyle command. There is a clear distinction between declared options (of a class or package) and general purpose package files.4
3~ lot of them have become de facto standards and are described in this book. This does not mean, however, that packages that are not described in this book are necessarily less important or useful, of inferior quality, or that they should not be used. We merely concentrated on a few of the more established ones and for the others we chose to explain what functionality is possible in a given area. 41n H E X 2.09 the options of the \documentstyle command were a mixture of declared options (executed directly) and undeclared options (which resulted in a .sty file to be read after the \documentstyle command finished processing). In w X 2 this ~ is now cleanly separated.

14

The Structure of a L A T E X Document The latter have to be specified using the \usepackage command. Think of options as properties of the whole document (when used in \documentclass) or as properties of inhvidual packages (if specified in \usepackage). You can only specify options in a \usepackage command if these options are declared by the package. Otherwise, you will receive an error message, informing you that your specified option is unknown to the package in question. Options to the \documentclass are handled slightly differently. If a specified option is not declared by the class it will assumed to be a "global option." All options to \documentclass (declared and global ones) are automatically passed as class options to all \usepackage declarations. Thus, if a package file loaded with a \usepackage declaration recognizes (i.e., declares) some of the class options it can take appropriate actions; otherwise, the class options will be ignored while processing that package. Since all options have to be defined inside the class or package file their action is under the control of the class or package (it can be anythmg from setting internal switches to reading an external file). For this reason their order in the optional argument of \documentclass or \usepackage is irrelevant. If you want to use several packages, all taking the same options (for example, none), it is possible to load them all with a single \usepackage command by specifying the package names as a comma separated list in the mandatory argument, e.g.:
\usepackage [germanl {babel) \usepackage [german]Ivarioref) \usepackageCmulticol) \usepackage{epic)

is equivalent to
\usepackage [german] Cbabel,varioref 1 \usepackageImulticol,epic)

B y specifying german as a global option this can be further shortened to


\documentclass [germanl {book) \usepackage{babel,varioref,multicol,epic~

since then german will be passed to all packages specified and thus will be processed by those packages that declare it. Finally, when the \begin(document) is reached, all global options are checked to see whether they have been used by any package; if not, you will get an error message. The reason for the error is usually a spelling mistake in your option name or the removal of a \usepackage command loading a package that used this option.

2.1 The Structure of a Source File

15

Therefore, if you want to make some modifications to a document class or a package (for example, parameter changes or redefinitions of some commands), you should put the relevant code into a separate file with the extension .sty. Then load this file with a \usepackage command after the package whose behavior you wish to modify (or the document class if your mo&fications concern class issues). Such a local package Me should contain one special declaration at the beginning which tells LATEX^^ for which distribution (release)it was originally written, namely:

The format must be the string LaTeX2e. If the optional release argument is specified it should contain the release date of your w X 2 distribution ~ in the form YYYY/MM/DD. For example

would specify the LATEX^^ release distributed on the first of February 1994 (LATEX&is distributed twice a year on fixed dates). The purpose of this command is the detection of obsolete releases of LATEX~E. If, for example, your package makes use of a command that had a bug in the 1994/02/01 release and that was corrected in the 1994/08/01 release, a specification of 1994/08/01 in the optional argument of \NeedsTeXFormat will output a warning if your package is used with an older W X 2 release. A newer release date is accepted without a warning. The other way to modify the layout is by placing the relevant code directly into the preamble of your document. However, there is one important T~Xncal difference between commands inside package or class files and commands in the preamble: L A T E X has many internal commands that you cannot type inside your document without special precautions. These internal commands have names containing the @ character. It must be recalled that nonalphabetic characters cannot normally appear in the name of U&Xcommands. (Apart from about two dozen commands, which have two-character names composed of a backslash (\) followed by a single non-letter, all other command names consist of a \ symbol followed by one or more letters.) Yet, when executing commands in a package file, IPQX considers the @ as a letter. This allows package files to work smoothly with these internal commands while they cannot be used as suchin the document preamble. Nevertheless, you can work with internal commands in the preamble by bracketing the area where the @ should be considered as a letter inside \makeatletter and \makeatother commands. As an example, let us consider the command that instructs I4QX to reset some counter whenever some other counter is incremented (the internal command \@addtoreset).Thus, when using the article document class, you can number equations w i t b sections by

( L 150)

16

The Structure of a L A T E X Document


writing the code shown below into your preamble.

. ..
\makeatletter % 'Q' is now a normal "letter" for TeX \Qaddtoreset{equation)Isection) \makeatother % 'Q7 is restored as a "non-letter" character for TeX \begin{document)

As explained above, inside a package file the @ is considered a normal letter and can be used in command names. Therefore you should be careful never to use the \ m a k e a t l e t t e r and \makeatother commands inside package files.

2.1.2 Splitting the Source File into Parts


IF&X source documents can be conveniently split into several parts by using \include commands. Moreover, documents can be reformatted piecewise by specifying as arguments of an \includeonly command only those files IPQX has to reprocess. For the other files that are specified in \include statements, the counter information (page, chapter, table, figure, equation,. . .) d l be read from the corresponding .aux files as long as they have been generated during a previous run. For instance in the case shown in figure 2.2 the user only wants to reprocess files chapl .t e x and appenl .tex. Beware that W X only issues a warning message like "No f i l e xxx. t e x " when it cannot find a file specified in an \include statement, not an error message, and continues processing. If the information in the .aux files is up-to-date, it is possible to process only part of a document and have all counters, cross-references, and pages correct in the reformatted part. However, if one of the counters (including the

(L76,188)

\documentclass~book~ \includeonly{chapl,appenl) \begin{document) \include{chapl) \include{chap21 \include{chap3) \include{appenl) \include{appen2) \end{document)

% the document class "book" % only include chapl and appenl


% % % % %
input input input input input chapl.tex chap2.tex chap3.tex appenl .tex appen2.tex

Figure 2.2: Structuring a IPQX document

2.2 Logical Structure

17

page number for cross-references) changes in the reprocessed part, then the complete document might have to be rerun to get the index, table of contents, and bibliographc references consistently correct. Therefore, while it is certainly an advantage to split a larger document into smaller parts and to work on more manageable files with a text editor, partial reformatting should only be used with great care and when still in the developing stage for one or more chapters. However, when a final and completely correct copy is needed, the only safe procedure is to reprocess the complete document. If the document is too large to process in a single run, you should \include each section i n the cowect sequence.

2.1.3 Combining Several Files


When sending a L A T E Xdocument to some other person you may have to send local or uncommon package files (e.g., your private modifications to some packages) along with the source. In such cases it is often helpful if you can put all the information required to process the document into a single file. For this, W X offers you the environment f ilecontents. This environment takes one argument, the name of a file; its body should consist of the contents of this file. It is only allowed to appear before a \documentclass declaration. If W&X encounters such an environment it will check whether it can find the mentioned file name. If not, it will write the body of the environment verbatim into a file in the current directory and inform you about this action. On the A T E X it will inform you that it other hand, if a file with that name was found by L has ignored this instance of the f ilecontents environment because the file is already provided. To get a list of (nearly)all files used in your document, specify the command \listf iles in the preamble.

2.2 Logical Structure


The standard IK&X classes contain commands and environments to define the different hierarchical structural units of a document (e.g., chapters, sections, appendices). Each such command defines a nesting level inside a herarchy and each structural unit belongs to some level. A typical document (like an article) consists of a title, some sections with probably a multilevel nested substructure, and a list of references. To describe such a structure the title-generating command \maketitle,the sectioning commands such as \section and \subsection,and the thebibliography environment are used (figure 2.3 on the following page). The commands should be correctly nested. Thus, a \subsection command should only be issued after a previous \section.

( L 23,157)

18

The Structure of a W X Document

\documentclass{article) % the standard class "articleJJ \begin{document) \maketitle \section{ . . . I \section{ 1 \subsection{ . . . I \subsubsection{ . . . I \section{ 1 \begin{thebibliography) ... \end{thebibliography) \end{document)

... ...

Figure 2.3: The hierarchical structure of a simple L A T E X document T h s example shows the nesting structure of a L A T E X document. In the case of the article class no \chapter command is available. Longer works (like reports, manuals, and books) start with more complex title information, are subdivided into chapters (and parts), provide cross-reference information (table of contents, list of figures, list of tables, and indices) and probably have appendices. In such a document you can easily distinguish the front matter, body and back matter (figure 2.4 on the next page). In the front matter the so-called starred f o m of the \section sectioning command is used normally. This form suppresses the numbering of a heading. Sectional units with fixed names, such as "Introduction," "Index," and "Preface," are usually not numbered. In the standard classes, the commands \tableof contents, \ l i s t o f t a b l e s , \ l i s t o f f igures, and the theindex and thebibliography environments internally invoke the command (\sect ion or \chapter) using their starred form.

2.3 Sectioning Commands


Standard L A T E X provides the set of sectioning commands shown in table 2.1 on page 20. The \chapter command defines level zero of the hierarchical structure of a document, the \section level one, and so on, whereas the optional \part command defines the level minus one (or zero in classes that do not define \chapter). Not all of these commands are defined in all document classes: the article class does not have \chapter and the letter class does not support sectioning commands at all. It is also possible for a package to define further sectioning commands, allowing either additional levels or variants for already supported levels.

2.3 Sectioning Commands

19

\documentclass{book) \begin{document) %--------------------\maketitle \section*{ ...) \tableofcontents \listoffigures \listoftables %--------------------\part{ ...1 \chapter{ ...) \section{ ... 1 \chapter{ ...I \part{. . .)

% the standard class "bookJJ


front matter of the document

% % % %

e.g. sectionnamedlike "Preface" chapter with the table of contents chapter with the list of figures chapter with the list of tables body of the document

%---------------------

back matter of the document % following chapters are appendices \appendix \chapter{ ...1 \chapter{. . .) \begin{thebibliography) \end{thebibliography) \begin{theindex) \end(theindex) \end{document)

Figure 2.4: The hierarchical structure of a complex W X document The more complex example shown here subdivides the document into front matter, body and back matter. Each of these contains lower level document elements, like the table of contents in the front matter, chapter, sections and subsections in the body, and appendices, an index and a bibliography in the back matter. Generally the sectioning commands automatically perform one or more of the following typesetting actions: produce the heading number reflecting the hierarchcal level; store the heading as an entry for a table of contents (into the .toc file); save the contents of the heading to be (perhaps) used in a running head and/or foot; and format the heading. All sectioning commands have a common syntax as shown in table 2.2 on the next page. The starred form (e.g., \section*. . .I) suppresses the numbering

(L23,157)

20

The Structure of a LATEX Document

\ p a r t (book and report) \chapter \subsection \paragraph

level -1 level0 level 2 level 4

\ p a r t (article) \section \subsubsection \subparagraph

level 0 level 1 level 3 level 5

Table 2.1: WX's standard sectioning commands

form \section{title) \ s e c t i o n Ctoc-entry1 {title) \section*{title)

numbering Yes Yes no

.t o c
title toc-entry no

running h/f title toc-entry no

Table 2.2: Syntax of the sectioning commands

for a title. The optional argument is used when the text string for the table of contents and the running head and/or foot is different from the printed title. The remaining part of t h s section will discuss how the appearance of section headings can be modified. You will learn how to define a command like \ s e c t i o n that has the above syntax, produces a table of contents entry if desired, but has a thick rule above its heading text or uses a normal-sized italic font rather than a large bold one. First there are some examples on how to change the numbering of headings. Further examples demonstrate how to enter information about headings into the table of contents. Finally, changes to the general layout of headings are discussed, showing what L A T E X offers to define them.
I

2.3.1 Numbering Headings


To support numbering, I4QXuses a counter for each sectional unit and composes the heading number from these counters. Perhaps the change desired most often concerning the numbering of titles is to alter the nesting level up to which a number should be produced. This is controlled by a counter named secnumdepth, which holds the highest level with numbered headings. For example, some documents have none of their headings numbered. Instead of always using the starred form of the sectioning commands, it is more convenient to set the counter secnumdepth to -2 in the document preamble. The advantage of this method is that an entry in the table of contents can still be produced, and that arguments from the sectioning

( L 157,160)

2.3 Sectioning. Commands

\newcounter{part) \newcounterCchapter) \newcounter{section)[chapter] \newcounter{subsection)[sectionl \newcounter{subsubsection)[subsection]% \newcounter{paragraph)[subsubsection] \newcounter{subparagraph)[paragraph]

% % % %

(-1) parts (0) chapters (1) sections (2) subsections (3) subsubsections % (4) paragraphs % (5) subparagraphs

Figure 2.5: Numbering the section headings

commands can produce information in running headings. As discussed above, these features are suppressed in the starred form. To number all headings down to \subparagraph or whatever the deepest sectioning level for the given class is called, the following declaration is certainly sufficient.

Finally, using the \addtocounter command gives an easy way of numbering a few more or less levels without worrying about the level numbers of the corresponding sectioning commands. For example, if you find that you need one more level with numbers you can just add

in the preamble of your document. Every sectioning command has an associated counter, which by convention has the same name as the sectioning command (e.g., the command \subsection goes together with the counter subsection). This counter holds the current number for the given sectioning command. Thus, in the report class, the commands \chapter, \section, \subsection, and so on represent the hierarchical structure of the document and a counter llke subsection keeps track of the number of \subsections used inside the current \section. Normally, when a counter at a given hierarchical level is stepped, then all lower level counters (i.e., those with higher level numbers) are reset. So, for example, the report class file contains the d e h t i o n s shown in figure 2.5. These commands declare the ~ a r i o u s counters. The level one (section) counter is reset when the level zero (chapter) counter is stepped, and similarly the level two (subsection) counter is reset whenever the level one (section) counter is stepped. The same mechanism is used down to the \subparagraph

22

The Structure of a L A T E X Document

command. Note that in the standard classes the part counter is completely decoupled from the other counters, and has no influence on the lower level sectioning commands. This means that \chapters in the book or report class or \sections in article will be numbered consecutively even if a \part command intervenes. Changing this is simple, you just have to replace the corresponding definition of the chapter counter, e.g.,

The behavior of an already existing counter can be changed with the command \@addtoreset,e.g.,

Remember that this instruction should only be issued inside an option file or in the document preamble between \makeatletter and \makeatother commands, as explained in section 2.1.1. Every counter in L A T E X ,including the sectioning counters, has an associated command constructed by prefming the counter name with \the, which generates a typeset representation of the counter in question. In case of the sectioning commands this representation form is used to produce the full number associated with the commands, as in the following definitions:

In the above example \thesubsection produces an arabic number representation of the subsection counter prefixed by the command \thesection and a dot. This kind of recursive definition eases modifications to the counter representations since changes do not need to be made in more than one place. If, for example, you want to number chapters using capital letters, you can redefine the command \thechapter:
D.7 A Different Looking Section
Due to the default definitions not only the numbers on chapters change; but lower-level sectioning commands also show this representation of the chapter number.
\renewcommand{\thechapter){\Alph{chapter)) \section{A Different Looking Section) Due to the default definitions not only the numbers on chapters change; but lower-level sectioning commands also show this representation of the chapter number.

Thus by changing the counter representation commands it is possible to change the number displayed by a sectioning command. However, the representation of the number cannot be changed arbitrarily by this method. Suppose you want to produce a section heading with the number surrounded by a box.

2.3 Sectioning Commands


Given the above examples one straightforward approach would be to redefine \ t h e s e c t i o n , e.g.,
\renewcomand{\thesection~~\fbox~\thechapter.\arabic{section)))

23

But this is not correct, as one sees when trying to reference such a section.
4 7 A mistake L-i
Referencing a section in this format produces which we can see looking at get a boxed reference.
\renewcommand{\thesection) ~\fbox~\thechapter.\arabic{section))) \section{A mistake)\labelCwrong) Referencing a section in this format produces a funny result which we can see looking at section"\ref{wrong). We get a boxed reference.

In other words, the counter representation commands are also used by WX's cross-referencing mechanism (the \ l a b e l , \ r e f commands, see section 2.5). Therefore, we can only make small changes to the counter representation commands so that their use in the \ r e f command still makes sense. To produce the box around the heading number without spoiling the output of a \ r e f we have to redefine L A T E X S ' internal command \@seccntformat, which is responsible for typesetting the counter part of a section title. The default d e h t i o n of \@seccntformat typesets the \ t h e representation of the section counter (i.e., in the example above it uses the \ t h e s e c t i o n command), followed by a fixed horizontal space of lem. Thus to correct the problem, rewrite the above example as follows.
4 L I7

This is correct

Referencing a section using this definition generates the correct result for the section reference 4.7.

\makeatletter \renewcommandC\Qseccntf ormat) [I] {\fbox C\csname the#l\endcsname)\hspaceCO.5em)) \makeatother \sectionCThis is correct)\label{sec:OK) Referencing a section using this definition generates the correct result for the section reference-\ref{sec:OK).

You can see that the framed box around the number in the section heading is now only defined in the \@seccntformat command, and hence the reference labels come out correctly5. Also note that we reduced the space between the box and the text to 0.5em (instead of the default lem). The definition of
S~he command \@seccntformat takes as argument the section level identifier, which is appended to the \the prefix to generate the presentation form needed via the \csname, \endcsname command constructor. In our example, the \Qseccntformat command is called with the section argument and thus the replacement text \fbox(\csname thesection\endcsname\hspaceCO .5eml> is generated. See the TEX book for more details about the \csname command.

24

The Structure of a L Q X Document


\@seccntformat applies to all headings defined with the \ @ s t a r t s e c t i o n command (which is described in the next section). Therefore, if you wish to use different definitions of \@seccntformat for different headings you must put the appropriate code into every heading definition.

2.3.2

Formatting Headings

NTEX provides a generic command called \ @ s t a r t s e c t i o n , which can be used to define a wide variety of heading layouts. To define or change a sectioning command one should find out whether \ @ s t a r t s e c t i o n can do the job. If the desired layout is not achievable that way then \secdef can be used to produce sectioning formats with arbitrary layout. Headings can be loosely subdivided into two major groups: display and runin headings. A display heading is a heading which is separated by a vertical space from the preceding and the following text-most headings in this book are of this type. A run-in heading is characterized by a vertical separation from the preceding text, but the text following the title continues on the same line as the heading itself, only separated from the latter by a horizontal space.
Run-in headings. The present example shows what a run-in heading looks like. Text in the paragraph following the heading continues on the same line as the heading.
\paragraphCRun-in headings.1 The present example shows what a run-in heading looks like. Text in the paragraph following the heading continues on the same line as the heading.

The \ @ s t a r t s e c t i o n Command The generic command \ @ s t a r t s e c t i o n allows both types of headings to be defined. Its syntax and argument description is as follows:

name This is the name of the sectioning command being defined, without the preceding backslash-for example, to define a command named \ s e c t i o n ,
the word s e c t i o n should be specified.

level This is a number, denoting the depth level of the sectioning command. This level is used to decide if the sectioning command gets a number (if the
level is less or equal to secnumdepth, see section 2.3.1 on page 20) or shows up in the table of contents (if the value is less or equal to tocdepth, see section 2.4.1 on page 32). It should therefore reflect the position in the command herarchy of sectioning commands, where the outermost sectioning command has level zero.6
-

6 ~ the n book and report classes,the \part command actually has level -1 (see figure 2.5).

2.3 Sectioning Commands

25

Text before the heading.

beforeskip indent
4
C

( 1 . 1 ) Heading text.
afterskip (>O)
Text after the heading.

Figure 2.6: The layout for a display heading

indent The indentation of the heading with respect to the left margin. By making the value negative, the heading will start in the outer margin. Making it positive will indent all lines of the heading by this amount. beforeskip The absolute value of this parameter defines the space to be left in front of the heading. If the parameter is negative, then the indentation of the paragraph following the heading is suppressed. This dimension is a rubber length, i.e., it can take a stretch and shrink component. Note that W X starts a new paragraph before the heading, so that additionally the value of \parskip is added to the space in front. afterskip This is the space to be left following a heading. It is the vertical space after a display heading or the horizontal space after a run-in heading. The sign of afterskip controls whether a display (afterskip2 0) or run-in heading (afterskip < 0) is produced. Note that in the first case a new paragraph is started so that the value of \parskip is added to the space after the heading. An unpleasant side effect of this parameter coupling is that it is impossible to define a display heading with an effective "after space" of less than \parskip using the \ @ s t a r t s e c t i o n command. When you try to compensate for a positive \parskip value by using a negative afterskip,you change the display heading into a run-in heading. style This is the style of the heading text. This argument can take any instruction that influences the typesetting of text, e.g., \Large, \bf s e r i e s or \raggedright (see the examples below).
Figures 2.6 and 2.7 on the following page show these parameters graphically in the case of display and run-in headings respectively.

26

The Structure of a L A T E X Document

Text before the heading.


-

beforeskip

afterskip ((0)
Heading.

after the heading. More text after the heading.

Figure 2.7: The layout for a run-in heading We shall now show how these arguments are used in practice to define new sectioning commands. Let us suppose that you want to change the \section command of a class like report to look roughly like this:

. .. some text above.


4.6.3 This Is an Example of a Section Heading

The heading is set in normal-sized italic and the separation from the preceding text is exactly one baseline. The separation from the text following is half a baseline and this text is not indented.

\ldots\ some text above. \subsection{This Is an Example of a Section Heading) The heading is set in normal-sized italic and the separation from the preceding text is exactly one baseline. The separation the text following is half a baseline and this text is not indented.

In this case the following redefinition is needed:


\renewcommand~\subsection){\Qstartsection {subsection)% % the { 2 ) % % the {omm)% % the {-\baselineskip)% % the {0.5\baselineskip)% % the {\normalfont\normalsize\itshape~% % the

name level indent bef oreskip afterskip style

The first argument is subsection, the name of the sectioning command. In the sectional herarchy, subsection is at level two. The third argument is Omm since the heading should start at the left margin. The absolute value of the fourth argument specifies that a distance equal to one baseline must be left in front of the heading and, since the parameter is negative, the indentation of the paragraph following the heading should be suppressed. The absolute value of the fifth parameter (afterskip)specifies that a distance equal to half a baseline must be left following the heading and, since the parameter is positive,

2.3 Sectioning Commands

27

a display heading has to be produced. Finally, according to the sixth parameter, the heading should be typeset in an italic font using a size equal to the normal document type size. It is important to note that within the definition every unnecessary space was suppressed by putting a percent sign after every right brace in the second argument of \renewcommand. Besides the fact that unnecessary spaces in a definition take up memory they sometimes find their way into the document and produce funny results. Another layout, which is sometimes found in fiction books, is given by the following definition:
\renewcommandC\section)C\Qstartsection {section)% (13% Clem)% {\baselineskip)% C-\f ontdimen2\font plus -\fontdimen3\font minus -\fontdimen4\fant)% ~\normalfont\normalsize\scshape))%

% % % % %

the the the the the

name level indent bef oreskip afterskip

% the style

This defines a run-in heading using small capitals. The space definition for the horizontal afterskip deserves an explanation: it is the value of the stretchable space between words taken from the current font, negated to make a run-in heading. Detads about \f ontdimens can be found in section 7.7.2 on page 200. The result will be something like:

. .. some text above.


THEMAN started to run away from the truck. He saw that he was followed by

\ldots\ some text above. \section{The man) started to run away from the truck. He saw that he was followed by

Of course, for such a layout one should turn off numbering of the headings by setting secnumdepth to -1. Which commands can be used for setting the styles of the heading texts by using the style argument of the \@startsection command? Apart from the font changing directives (see chapter 7) few instructions can be used here. A \centering command produces a centered display heading and a \raggedright declaration makes the text left justified. The usage of \raggedleft is possible, but may give somewhat strange results. You can also use \hrule\medskip, \newpage, or slrnilar commands that introduce local changes. The examples in figure 2.8 on the next page show the results of various possible definitions for the style argument. In the standard I Q X document classes, words in long section headings can be hyphenated. If this is not wanted, then hyphenation can be turned off locally

28

The Structure of a LATX Document


\Csubsection{This is a Section Heading) The style is specified by \verb!\centering\itshape! commands. \Lsubsection{This is a Section Heading) The style is specified by \verb!\raggedright\itshape! commands. \Rsubsection{This is a Section Heading) The style is specified by \verb ! \raggedlef t\itshape ! commands. \Hsubsection{This is a Section Heading) The style is specified by \verb ! \hrule\medskip\itshape ! commands.

4.6.3 This is a Section Heading The style is specified by \centering\itshape commands. 4.6.4 This is a Section Heading The style is specified by \raggedright\itshape commands. 4,6.5 This is a

Heading
t\itsha~e

The style is 'pecified by commands.

4.6.6 This is a Section Heading The style is specified by \hrule\medskip\itshape commands.

Figure 2.8: Changing the style of a heading B y changing the style argument of the \ @ s t a r t s e c t i o ncommand, various effects can be acheved. by defining and using a command like \nohyphens7 in the style part of the \ @ s t a r t s e c t i o n command. Another problem is that, if the user tries to advise TEX on how to split the heading over a few lines using the """ symbol or the \ \ command, then side effects may result when formatting the table of contents. In this case the simplest solution is to repeat the heading text without the specific markup in the optional parameter of the sectioning command. Finally, a few words about the suppression of the indentation for the first paragraph after a display heading. Standard W ! & X document classes, following (American)English typographc tradition, suppress the indentation in t h s case. All first paragraphs after a display heading can be indented by specifying the package indentfirst (David Carlisle).
The \secdef Command

The highest-level sectioning commands \part and \chapter produce their titles without using \ @ s t a r t s e c t i o n . In a similar way, you can construct your own sectioning commands without limitations. You must, however, follow a few conventions to allow I Q X to take all the necessary typesetting actions when executing them. The command \secdef can help you when defining such commands by providing an easy interface to the three possible forms of section headings, as shown in figure 2.9 on the facing page in the case of the \part command.

2.3 Sectioning Commands

29

With the definition \newcommandC\part){\secdef following actions take place:


\part (title) \part Ctoc-entry1 C title3 \part *{ title)
wdl invoke will invoke will invoke

\cmda\cmdb) the

\cmda [title](title) \cmda Ctoc-entry] {title) \cmdb( title)

Figure 2.9: Conventions for the \secdef command The commands you will have to provide are a (re)definition of \part and a definition of the commands labeled \cmda or \cmdb respectively. Note that \cmda has an optional argument containing the text to be entered in the table of contents .toc file, while the second (mandatory) argument, as well as the single argument to \cmdb, specifies the heading text to be typeset. In the schematic example below, the extended functionality of I$&X2's\newcommand is used. It allows the definition of an optional argument; see also section A. 1.1.

An explicit example is a simplified variant of \appendix. T h s redefines the \section command to produce headings for appendices (by invoking either the \Appendix or \sAppendix command), changing the presentation of the section counter and resetting it to zero. The modified \section command also starts a new page, sets a special format for the first page (see chapter 4), prohibits floats

from appearing at the top of the first page, and suppresses the indentation of the first paragraph in a section.
\renewcommand{\appendix)a \renewcommand{\section){% Redefinition of \section \newpage\thispagestyle{plain)% \secdef\Appendix\sAppendix)% \setcounterCsection)CO)% \renewcommandC\thesection>{\AlphCsection))%

1 In the definitionbelow you can see how \Appendix advances the section counter using the \ref stepcounter command (the latter also resets all subsidmy counters and defines the "current reference string," see section 2.5). It writes a line into the .toc file with the \addcontentsline command, performs the formatting of the heading title, and saves the title for running heads and/or feet by

30

The Structure of a LATX Document calling \ s e c t ionmark.


\newcommandC\Appendix) [21 [?I C% Complex form \refstepcounterCsection)% \addcontentslineCtoc)Cappendix)'/. ~\protect\numberlineC\appendixname-\thesection #I)% C\flushright\large\bfseries\appendixname\ \thesection\par \nohyphens\centering#2\par)% \sectionmark~#l~\vspace~\baselineskip))

The \sAppendix command (starred form) only performs the formatting.


\newcommandC\sAppendix) [l] 1% Simplified (starred) f o m C\flushright\large\bfseries\appendixname\par \nohyphens\centering#l\par)% \vspaceC\baselineskip))

Applying these definitions will produce the following output:

Appendix A The List of all Commands


~h~~ follows the text of the first section in the appendix. Some more text in the appendix. Some more text in the appendix.

\appendix \section{The List of all commands) Then follows the text of the first section in the appendix. text in the appendix. Some more text in the appendix.

Do not forget that the e x q p l e shown above represents only a simplified version of a redefined \ s e c t i o n command. We did, among other things, not take into account the secnumdepth counter, which contains the numbering threshold. You might also have to foresee code dealing with various types of document formats, like one- and two-column output, or one- and two-sided printing (see chapter 4).

2.3.3 Changing Fixed Heading Texts


Some of the standard heading commands produce fixed texts, for example \ c h a p t e r produces the string "Chapter" in front of the user supplied text. Similarly some environments generate headings with k e d texts. For example, by default the a b s t r a c t environment displays the word "Abstract" above the text A T E X had these strings of the abstract supplied by the user. Earlier versions of L hard-coded inside the system so that it was rather difficult to change them. The X has these strings replaced by command sequences (see table 2.3 present W on the next page) so that you can easily customize them to obtain your favorite names. This is shown in the example below, where the default name "Abstract," as defined in the article class, is replaced by the word "Summary."

2.4 Structure of the Table of Contents

31

Command
\contentsname \ l i s t f igurename \listtablename \bibname \indexname \chaptername \appendixname \partname \abstractname

Default text Contents List of Figures List of Tables Bibliography Index Chapter Appendix Part Abstract

Table 2.3: Commands holding fixed texts for section headings

This book describes how to modify the appearance of documents produced with kqx.

\begin{abstract) This book describes how t o modify the appearance of documents produced with \LaTeX .

The standard H E X class files define a few more strings. See section 9.2, especially table 9.2 on page 267, for a full list and a discussion of the Babel system, which provides translations of these strings in over twenty languages.

2.4 Structure of the Table of Contents


A table o f contents is a special list with the titles of the section units specifying the page numbers where each section starts. This list can be rather complicated if many units of several nesting levels are included, and it should be formatted carefully because it plays an important r61e as a navigation aid for the reader. Similar lists exist containing reference information about the floating elements in a document, namely, the list o f tables and the list of figures. The structure of these lists is simpler, since their contents, the captions of the floating elements, are a l l on the same level. Standard W X can automatically create these three contents lists. By default, W X enters text generated by one of the arguments of the sectioning commands into the .t o c file. Similarly, L A T E X maintains two more files, one for the list of figures ( .l o f ) and one for the list of tables ( . l o t ) , which contain the text specified as the argument of the \caption command for figures and tables. A T E X run is read The information written into these files during a previous L
(L 70,158)

(L186)

(L:158)

32

The Structure of a LATEX Document


and typeset (normally at the beginning of a document) during a subsequent I Q X run by invoking the commands: \tableof contents,\listoff igures and
\listoftables.

To generate these cross-reference tables, it is always necessary to run I4QX at least twice, once to collect the relevant information, and a second time to read back the information and typeset it in the correct place in the document. Because of the additional material to be typeset in the second run, the crossreferencing information may change, thus making a further W&X run necessary. This is one of the reasons for the tradition of using different page-numbering systems for the front matter and the main text: in the days of hand typesetting any additional iteration made the final product much more expensive. The following sections will discuss how to typeset and generate these contents lists. It will also be shown how information can be entered directly into one of these standard files, or even how to open and write into a supplementary file completely under user control.

2.4.1 Typesetting a Contents List


As discussed above, contents lists consist of entries of different types, corresponding to the structural units that they represent. Apart from these standard entries, these lists may contain any commands. A standard entry is specified by the command:

The parameters are: type type of the entry, e.g., section,or figure; actual text as specified in the argument of the sectioning or \caption text commands; and page page number. A piece of code that generates the table of contents corresponding to part of a book is shown in figure 2.10 on the facing page. Note that section numbers are entered as a parameter of the \numberline command to allow formatting with the proper indentation. It is also possible for the user to create a table of contents by hand with the help of the command
\contentsline.

To format an entry in the table of contents files, standard K&X makes use of the following command:

The last two parameters coincide with those of \contentsline,since the

2.4 Structure of the Table of Contents

33

hput text

\contentsline {section) (\numberline (2.4)Structure of the Table of Contents)(SI) \contentdine (subsection) (\numberline (2.4.1)Typesetting a Contents List){32) \contentsline {subsection) {\numberline (2.4.23Entering Information into the Contents Files){35)

2.4

Structure of the Table of Contents . . . . . . . . . . . 2.4.1 Typesetting a Contents List . . . . . . . . . . 2.4.2 Entering Information into the Contents Files
Output text

.............. .............. ..............

31 32 35
I

Figure 2.10: Generating table of contents entries latter itself usually invokes a \Odottedtocline command. The other parameters are the following: level The nesting level of an entry. This parameter allows the user to control how many nesting levels will be displayed. Levels greater than the value of counter tocdepth will not appear in the table of contents. indent This is total indentation from the left margin. numwidth The width of the box that contains the number if text has a \numberline command. T h s is also the amount of extra indentation added to the second and later lines of a multiple line entry. Additionally, the command \Odottedtocline uses the following formatting parameters, which specify the visual appearance of all entries: \Qpnumwidth The width of the box in whch the page number is set. \Qtocrma.rg The indentation of the right margin for all but the last line of multiple line entries. Dimension, but changed with \renewcommand! \Odotsep The separation between dots, in mu (math ~ n i t s ) It .~ is a pure number (like 1.7 or 2). B y making this number large enough you can get rid of the dots altogether. Changed with \renewcommand as well! A pictorial representation of the effects described is shown in figure 2.1 1 on the next page. The field identified by numwidth contains a left justified section number, if any. You can achieve the proper indentation for nested entries by varying the settings (of indent and numwidth.

8~here a r e 18 mu u n i t s; t o an em, where the latter is taken from the \f ontdimen2 o f the math e t! section 7. symbol font symbols.S 7.2 f o r more information about \f ontdimens.

34

The Structure of a L A T E X Document

-b k indent+numwidth

\linewidth

4 -

+his is heading text. This i s k \@tocrmarg -c( heading text. T b s is heading text. . . . . . . . . . . . k \ @ p n u m w i d t h ~

Figure 2.11: Parameters defining the layout of a contents file

The command \ c o n t e n t d i n e is implemented to take its first argument type, and then use it to call the corresponding \l@type command, which does the actual typesetting. One separate command for each of the types must be defined in the style file. For example, in the report class one finds the following definitions:

B y defining \latype to call \@dottedtocline and specifying three arguments (level, indent and numwidth) the remaining arguments, text and page, of \contentsline will be picked up by \@dottedtocline as arguments four and five. Note that some section levels build their table of contents entries in a somewhat more complicated way, so that the standard document classes have defmitions for \ l @ p a r tand \l@chapterthat do not use \@dottedtocline. Generally they use a set of specific formatting commands, perhaps omitting ellipses and typesetting in a larger font. A possible example is shown below:

n
1

PW~
Chapter 1.1 Section

l.l.l

..... ...... ...

Subsection number Unnumbered subsection.

\contentsline{part){\numberline{II)Part){l~ \contentsline{chapter){\numberlineC1)Chapter)C2) \contentsline{section)% {\numberlineCl.l)Section){3) \contentsline{subsection~% {\numberline{l.l.l)Subsection)~4) \contentsline{subsection)% (\numberline{)Subsection without number){5) \contentsline{subsection~% {Unnumbered subsection){6)

2.4 Structure of the Table of Contents

35

The level down to which the heading information is displayed in the table of contents is controlled by the counter tocdepth. It can be changed, for example, with the declaration:

(L160)

In this case sectional heading information down to the second level (i.e., part, chapter, and section)will be shown.

2.4.2 Entering Information into the Contents Files


W X offers two commands to enter information directly into a contents file:

The extension of the contents file, usually .toc, .lof, or .lot. The type of the entry. For the .toc file the type is normally the same as the heading according to whose format an entry must be typeset. For the .lof or .lot files, figure or table is specified. text The actual information to be written to the file mentioned. LATEX commands should be protected by \protect to delay expansion. The \addtocontents command does not contain a type parameter and is intended to enter user-specific formatting information. For example, if you want to generate additional spacing in the middle of a table of contents, the following command can be issued: file type

The \addcontentsline instruction is usually invoked automatically by the document sectioning commands, or by the \caption commands. If the entry contains numbered text, then \numberline must be used to separate the section number (number) from the rest of the text for the entry (heading) in the text parameter:

For example, a \caption command inside a figure environment saves the text annotating the figure as follows:
\addcontentsline{lof}{figure]% {\protect\numberline{\thef igure}captioned text}

Sometimes \addcontentsline is used i n the source to complement the actions of standard INEX. For instance, in the case of the starred form of the

36

The Structure of a U T F X Document

section commands, no information is written to the .t o c file. So if you do not want a heading number (starred form) but an entry in the .t o c file you can write somethmg like:

This produces an indented "chapter" entry in the table of contents, leaving the space where the chapter number would go free. Omitting the \numberline command would typeset the word "Foreword" flush left instead.

2.4.3 Defining a New TOC-Like File


If you want to make a list comprising a l l the examples in a book, you need to create a new contents file, and then make use of the facilities described above. First, two new commands must be defined: \ l i s t o f examples wdl read the information written to the .xmp file (see below) and typeset it at the point in the document where the command is called. The second command, \ecaption, associates a caption with each environment and writes its argument to the .xmp contents file. The \ l i s t o f examples command invokes \QstarttocCxxx) which reads the external file (with the extension xxx) and then reopens it for writing. T h s command is also used by the commands \tableofcontents, \ l i s t o f f igures, and \ l i s t o f t a b l e s . The supplementary file could be given an extension such as xmp. A command like \chapter*<List of examples) can be put just in front of \listofexamples to produce a title and, if desired, a command \addcontentdine can signal the presence of this list to the reader by entering it into the .t o c file. The actual typesetting of the individual entries in the .xmp file is controlled by \lQexample. In the example below, the captions are typeset as paragraphs followed by an italicized page number.

You can also look at section 6.3 on page 146, where in the case of floats, the command \ l i s t o f will generate a list of floats of the type specified as its argument.

2.4.4 Multiple Tables of Contents


The minitoc package, initially written by Nigel Ward and Dan Jurafsky and completely redesigned by Jean-Pierre Drucbert, creates a mini-table of contents (a "minitoc") at the beginning of each chapter with the book or report classes.

2.4 Structure of the Table of Contents


\dominitoc \faketableofcontents \minitoc minitocdepth

37

\mtcindent \mtcf ont

must be put just in front of \tableof contents, to initialize the rninitoc system (Mandatory). this command replaces \tableof contents when you want minitocs but no table of contents. this command must be put right after each \chapter command where a minitoc is desired. aW X counter that indicates how many levels of headings will be displayed in the minitoc (default value is 2). the length of the left/right indentation of the minitoc (default value is 24pt). command defining the font that is used for the minitoc entries (The default definition is a small roman font.

Table 2.4: A summary of the minitoc parameters

The mini-table of contents will appear at the beginning of a chapter, after the \chapter command. The parameters that govern the use of this package are discussed in table 2.4. For each mini-table, an auxiliary file with extension .mtc<N>,where <N> is the chapter number, will be created? B y default, these mini-tables contain only references to sections and subsections. The minitocdepth counter, similar to tocdepth, allows the user to modify this behavior. As the minitoc takes up room on the first page(s) of a chapter, it will alter the page numbering. Therefore, three runs normally are needed to get correct information in the mini-table of contents. To turn off the \minitoc commands, merely replace the package minitoc with minitocoff on your \usepackage command. This assures that a l l \minitoc commands will be ignored. An example of the use of the minitoc package is given in figure 2.12 on the next page, where we put the global tocdepth counter to one, so that only section titles wdl be shown in the table of contents of the document (you can see the result in the upper left part of figure 2.13 on page 39). The depth counter for the mini-tables, minitocdepth, is put equal to two, so that section and subsection titles appear in each such table (as seen in the remaining five pictures in figure 2.13 on page 39). The text of the chapter starts immediately after the end of the mini-table.
g ~ e c a u sof e the special extensions this package will not work without modifications on MS-DOS or MS-Windows, or more exactly, on any operating system that does not allow long file extensions.

38

The Structure of a JKQ-X Document

\documentclass{book) \usepackageCtimes) \usepackage{minitoc)


\setcounterCtocdepth)C1) \setlengthC\mtcindent}{24pt) \renewcommand{\mtcfont)C\small\rm) \setcounter~minitocdepth)o

% % % %

depth of table of contents indentation of minitocs, default font for minitocs, default depth for minitoc

\beginCdocument) \dominitoc \tableofcontents \chapter{Afghanistan) \minitoc \section{Afghanistan Geography) \subsection{Total area) 647.500 km2 \subsection{Land area) 647,500 km2

% generate minitocs % generate global table of contents

% minitoc after first chapter title

.....

continuation of chapter 1

\chapter{Albania) \minitoc \sectionCAlbania Geography) \subsection{Total area) 28,750 km2 \subsectionCLand area) 27,400 km2

% minitoc after second chapter title

.. . . .

continuation of chapter 3

Figure 2.12: Mini-table of contents-input example

i ! i E--

r !

A o* I

t ! 3 ! e Ia

E lE g
i
bir

icI

ls ic i 'g ' li E ?g 1 lI
I 5 i F l !

:;;;!

; ; i;;:!r ,,,,,,t

!r e
i E
!. i

IIt

I ${g
t3:t t

i E 5
r

Ft"r i !l iF
5i
f

tBtt?Er E' o Fg$f+i


1 5 t5 * e t [5 r 1 : : : :

I I I

E
t

::: :::

dt

-. t\)

3
F' F.

L 9 g g
ii'

;$;iil;i riiffiiili

6'

u)

I /
X

5 gt E i i i :
i

i t s

t -

gf rlIiEi $gIiii i'itii$[i $i


I t 9 3 . [ : : : : : : I s

: :: : :

. t .

;Fffi;;;ii;;i iF iiry;qi' ii;i


l l l : l i : i : : : : : i : i : '.l.'I .' . . l . :
slualuoJ Jo aIqPI aql Jo a.InlJnrls

g g 9 g 6 E 5 6

40

The Structure of a L A T E X Document

2.5 Managing References


W X has commands that make it easy to manage references in a document. In particular, it supports cross-references(internal references between elements within a document), bibliographic citations (references to external documents), and indexing of selected words or expressions. Indexing facilities will be discussed in chapter 12, and bibliographic citations in chapter 13. To allow cross-referencing of elements inside a document, you should assign a "key" (consisting of a string of letters, digits, and punctuation) to the given structural element and then use that key to refer to that element elsewhere.

( L 71,186)

The \ l a b e l command assigns key key-string to the current element of the document. \ r e f typesets a string, identifying the given element-such as the section, equation, or figure number depending on the type of structural element that was active when the \ l a b e l command was issued. The \pageref command typesets the number of the page where the \ l a b e l command was given. The key strings should of course be unique, and as a simple aid it can be useful to prefix them with a string identifying the structural element in question: s e c might represent sectional units, f i g would identify figures, and so on.
A reference of this subsection\labelCsec: this)
looks like: "see section-\refCsec:this) on page"\pagerefCsec:this)".

A reference of this subsection looks like: "see section 2.5 on page 40".

For building cross-reference labels, the "currently active" structural element of a document is determined in the following way. The sectioning commands (\chapter, \ s e c t i o n , . . .), the environments equation, f i g u r e , t a b l e , and the theorem family, as well as the various levels of the enumerate environment, and \ f o o t n o t e set the current reference string, which contains the number generated by Fl&X for the given element. This reference string is usually set at the beginning of an element and reset when the scope of the element is exited. Notable exceptions to this rule are the t a b l e and f i g u r e environments where the reference string is defined by the \caption commands. This allows several \ c a p t i o n and \ l a b e l pairs inside one environment. As it is the \ c a p t i o n directive that generates the number, the corresponding \ l a b e l command must follow the \ c a p t i o n command in question otherwise an incorrect number will be generated. This is shown clearly in the following example, where only the labels ' f i g :in2' and ' f i g : i n s ' are placed correctly to generate the needed reference numbers for the figures. In the case of ' f i g : in4' it is seen that environments (in this case c e n t e r ) limit the scope of references, since we obtain the number of the current section, rather than the number of the figure.

2.5 Managing References

41

Text before is referenced as '2.5'.

.. . figure body . ..
Figure 4.14: Caption First

. . . figure body . ..
Figure 4.15: Caption Second

\label(sec:before) Text before is referenced as '\ref{sec:before)'. \label(before) \beginCf igure) [HI \label{fig:inl) \beginCcenter) \fboxC\ldotsC) figure body \ldots) \caption{Caption First)\labelCfig:inZ) \fboxC\ldotsC) figure body \ldots) \captionCCaption Second)\label(fig:in3) \endCcenter) \labelCfig:in4) \endCfigure) \label(sec:after) \raggedright The labels are: 'beforeJ (\refCsec:before)),

The labels are: 'before' (2.5),'fig:inll (2.5),'fig:inZ2 (4.14),'fig:in3'(4.15), 'fig:in4'(2.5),'after' (2.5).

For each key-string declared with labelf key-string), W X records the current reference string and the page number. Thus, multiple \label commands (with different key identifiers key-string) inside the same sectional unit ulll generate an identical reference string but, possibly, different page numbers.

2.5.1 varioref-More Flexible Cross-References


In many cases it is helpful, when referring to a figure or table, to put both a \ref and a \pageref command into the document, especially when there are one or more pages between the reference and the object. Therefore, some people use a command like

to reduce the number of keystrokes necessary to make a complete reference. But since one never knows where the referenced object finally falls, this method can result in a citation to the current page, which is disturbing and should therefore be avoided. The package varioref, written by Frank Mittelbach, tries to solve that problem.
The User Interface

\vref will produce a \ref only when reference and \label are on the same page. It will also create one of the strings: "on the facing page," "on the preced-

42

The Structure of a UTFX Document


ing page," or "on the following page" (if label and reference differ by one). It will produce both \ r e f and \pageref when the difference is larger. The word "facing" is used when label and reference both fall onto a double spread. However, if a special page numbering scheme is used instead of the usual arabic numbering (for example, \pagenumbering(romad) then there will be no distinction between one or many pages off.
\vpageref Csamepagel [otherpagel (key-string)

Sometimes you may only want to refer to a page number. In that case a reference should be suppressed if you are citing the current page. For this purpose the \vpageref command is defined. It produces the same strings as \vref except that it does not start with a \ r e f , and it produces the string saved in \ r e f t e x t c u r r e n t if label and reference fall onto the same page. Defining \ r e f t e x t c u r r e n t to produce something like "on this page" ensures that

...

see the diagram \vpageref{ex:foo)


'I..

which shows

...

does not come out as . see the diagram which shows . .. ", which could be rnisleadmg. You can put a space in front of \vpageref; it will be ignored if the command does not create any text at all. If some text is added, an appropriate unbreakable space is automatically placed in front of the text. In fact, \vpageref allows even more control by using its two optional arguments. The first one specifies the text to be used if label and reference fall on the same page. This is helpful when both are close together, so that they may or may not be separated by a page break. In such a case, you will usually know whether the reference comes before or after the label so that you can code something like:

...

see the diagram \vpageref[above]{ex:foo)

which shows

..

The resultant text will be: ". . . see the diagram above which shows ...", when both are on the same page, or ". . . see the diagram on the page before which shows . . ." (or something similar, depending on the settings of the \ r e f t e x t . . b e f o r e and \ r e f t e x t . .a f t e r commands, see below) if they are separated by a page break. Note, however, that, if you use \vpageref with the optional argument to refer to a figure or table, depending on the float placement parameters, the float may show up at the top of the current page and therefore before the reference, even if it follows it in the source file.1
~ O T O ensure that a floating object always follows its place in the source use the option flafter which is described in section 6.2.

2.5 Managing References

43

Maybe you even prefer to say . see the above diagram" when diagram and reference fall onto the same page, i.e., reverse the word order compared to our previous example. In fact, in some languages the word order automatically changes in that case. To allow for this variation the second optional argument otherpage can be used. It specifies the text preceding the generated reference if object and reference do not fall on the same page. Thus, one would write
'I..

... see the

\vpageref[above diagram] [diagramlCex:fool which shows

...

to achieve the desired effect.


Language Support

The package supports the options defined by the babel system (see section 9.2); thus a declaration like

will produce texts suitable for the German language. To allow further customization, the generated text strings are all defined via macros (which will be predefined by the language options). Backward references use \reftextbef ore if the label is on the preceding page but invisible, and \ r e f t e x t f acebef ore if it is on the facing page (that is, if the current page number is odd). Similarly, \ref t e x t a f t e r is used when the label comes on the next page but one has to turn the page, and \ r e f t e x t f a c e a f t e r if it is on the next, but facing page. These four strings can be redefined with \renewcommand. Finally, the string corresponding to \ref t e x t f araway is used whenever label and reference differ by more than one, or when they are nonnumeric. This macro is a bit different because it takes one argument, the symbolic reference string, so that you can make use of \pageref in its replacement text. For instance, if you wanted to use your macros in German language documents you would say something like:

To allow some random variation in the generated strings you can use the command \ r e f t e x t v a r i o inside the string macros.

This command takes two arguments and selects one or the other for printing depending on the number of \vref or \vpageref commands already encountered in the document.

44

The Structure of a WTFX Document

As an example, the default definitions of the various macros described in this section are shown below.
\newcommand{\reftextfaceafter) {on the \reftextvarioCfacing){next) page) \newcommand{\reftextfacebefore) Con the \reftextvario{facing)Cpreceding) page) \newcommand{\reftextafter) Con the \reftextvario{following){next) page) \newcommand{\reftextbefore) Con the \reftextvarioCpreceding pagelfpage before)} \newcommand{\reftextcurrent) {on \reftextvario{this){the current) page) \newcommand{\reftextfaraway)[l]Con page"\pageref(#l))

Thus, if you want to customize the package according to your own preferences, just write appropriate redefmtions of the above commands in a file with the extension .s t y (e.g., vrf l o c a l . sty). If you also put \RequirePackageCvarioref) (see A.3 on page 460) at the beginning of this file, then your local package will automatically load the varioref package.
A Few Warnings

Defining commands, like the ones described above, pose some interesting problems. Suppose, for example, that a generated text like "on the next page" gets broken across pages. If this happens, it is very difficult to find an acceptable algorithmic solution and, in fact, this situation can even result in a document that will always change from one state to another (i.e., inserting one string, finding that this is wrong, inserting another string on the next run which makes the first string correct again, inserting .. .). The current implementation of the package varioref considers the end of the generated string as being relevant. For example, table 5 on the current (page break) page would be true if table 5 were on the page containing the word "page," not the one containing the word "current." However, t h s is not completely satisfactory, and in some cases may actually result in a possible loop (where L A T E X is requesting an additional run over and over again). Therefore all such situations will produce a L A T E X error message so that you may inspect the problem and perhaps decide to use a \ref command in that place. Also, be aware of the potential problems that can result from using \ref textvario: if you reference the same object several times in nearby places the change in wording every second time will look strange. A final warning: every use of \vref internally generates two macro names. As a result, you may run out of name space or main memory if you make heavy use of this command on a small TEX installation. For this reason the command

2 . 5 Managing References
\fullref is also provided. It can be used whenever you are sure that label and reference cannot fall on nearby pages.

45

2.5.2 References to External Documents


David Carlisle, using earlier work of Jean-Pierre Drucbert, developed a package xr, which implements a system for external references. If, for instance, a document needs to refer to sections of another document, say other.tex,then you can specify the xr package in the main file and give the command \externaldocumentCother) in the preamble. Then you can use \ref and \pageref to refer to anything that has been defined with a \label command in either other.tex or your main document. You may declare any number of such external documents. If any of the external documents, or the main document, uses the same \label, then a conflict will occur because the label has been multiply defined. To overcome t h s problem \externaldocument has an optional argument. If you declare \externaldocument [A-I Cother), then all references from the file other.tex are prefixed by A-. So, for instance, if a section in the file other.tex had a \label{intro), then this could be referenced with \refCA-intro). The prefix need not be A-; it can be any string chosen to ensure that all the labels imported from external files are unique. Note, however, that if one of the packages you are using declares certain active characters (like : in French or " in German) then these characters should not be used inside \label commands. Similarly, you should not use them in the optional argument to \externaldocument.

C H A P T E R

Basic Formatting Tools

The way information is presented visually can influence, to a large extent, the message as it is understood by the reader. Therefore, it is important that you use the best possible tools available to convey the precise meaning of your words. It must, however, be emphasized that visual presentation forms should aid the reader in understanding the text, and should not distract his or her attention. Therefore, visual consistency and uniform conventions for the visual clues are a must, and the way given structural elements are highlighted should be the same throughout a document. This constraint is most easily implemented by defining a specific command or environment for each document element that has to be treated specially and grouping the commands and environments in a package file or in the document preamble. In this way, by using exclusively these commands, you can be sure of a consistent presentation form. The present chapter explains various ways for highlighting parts of a document. Section one looks at how short text fragments or paragraphs can be made to stand out. The second section deals with L A T E Xlists. First the various parameters and commands controlling the standard L A T E X lists, enumerate, itemize, and description, are discussed. Then the general list environment is introduced and you will learn how to build custom layouts by varying the values of the parameters controlling the list environment. Typesetting texts verbatim is the subject of the third section. Various ways of presenting "typed" texts (like computer listings), with or without expansion of tabs, are discussed. The fourth section looks at the different kind of "notes," such as footnotes, marginal notes, and endnotes, while section five presents a package that makes it easy to typeset text in multiple columns. The chapter concludes with a discussion of a package that allows some kind of version control.

48

Basic Formatting Tools

3.1 Phrases and Paragraphs


Parts of a text can be hghlighted by choosing a visual appearance different from the one used for the main text. Parameters which can be customized are font shape and weight (see section 7.3.1 on page 165). Text can also be underlined, or the spacing between letters can be varied. The means for performing the latter two operations will be discussed in this section. Two methods for modifying the appearance of a paragraph will be introduced and you will also learn how to create ragged-right text and how to modulate the inter-line distance inside paragraphs.

3.1.1 letters pace-Changing Inter-Letter Spacing


The package letterspace (by Philip Taylor) introduces the \letterspace command, whch allows changing the width of a piece of text by changing the spaces between letters and between words (the latter is called tracking). The desired width can also be specified as a function of the natural width of the box containing the text by using the \naturalwidth parameter, as shown in the example below. The first line shows a slightly compressed text, the second line is typeset at its natural width, and the third line is expanded by 10%.Lines four and five show the text spread out uniformly over half the line and the full line, respectively.
Time for good men Time for good men (natural size) Time for good men Time for good men T i m e f o r g o o d
\letterspace t o .9\naturalwidth {Time for good men) \letterspace {Time for good men (natural s i z e ) ) \letterspace t o l.l\naturalwidth {Time for good men) \letterspace t o .5\linewidth{Time for good men) \letterspace t o \linewidth{Time for good men)

m e n

This \letterspace command should be used only with great care, since it changes the "grey" level of the text, and will disturb the reader. Its use should be restricted to situations where you need to compensate for shortcomings in a font's original widths, for example, if you want to obtain special effects or modulate the number of characters that fit on a line by adapting the density of the type. It can be very useful for creating nicer looking titles, since text at larger font sizes looks better with a looser tracking. It can also be used as a way for hghlighting phrases. For instance, in the example below we use the \letterspace command to space out the title and to highhght the word "void" in the text, by spacing out its first three letters.

3.1 Phrases and Paragraphs

49

The f i r s t day
In the beginning God created the heaven and the earth. Now the earth was unformed and v o i d, and darkness was upon the face of the deep; and the spirit of God hovered over the face of the waters.

\centering\mboxC\Large\textbfC\letterspace to 1.3\naturalwidthCThe first d a y ) ) ) \beginCquotation) In the beginning God created the heaven and the earth. Now the earth was unformed and \letterspace to 1.7\naturalwidthCvoi)d, and darkness was upon the face of the deep; and the spirit of God hovered over the face of the waters. \endCquotation)

3.1.2 u le m-Emphasize via Underline


LATEX encourages the use of the \emph command and the \em declaration

( L 16-18)

for marking emphasis, rather than explicit font changing declarations, like \ b f s e r i e s or \itshape.' The package ulem (by Donald Arseneau) redefines the \emph command to use underlining, rather than italics. It does allow line breaks, and even primitive hyphenation, within the underlined text. Every word is typeset in an underlined box, so automatic hyphenation is normally disabled, but explicit discretionary hyphens (\-) can still be used. The underlines continue between words and stretch just like ordinary spaces do. Since spaces delimit words, there may be some difficulty with syntactical spaces (e.g., " 2 . 3 p t u ) . Some effort is made to handle such spaces. If problems occur you might try enclosing the offendmg command in braces, since everything inside braces is put inside an \mbox. Thus, braces will suppress stretching and line breaks in the text they enclose. Note that nested emphasis constructs are not always treated correctly by this package (see the gymnastics below to get the inter-word spaces correct by putting each nested word separately inside an \emph expression).
No, I did not act in the movie Persecution and Assassination o f Jean-Paul Marat, as ~erformed bv the Inmates of the Asvlum of Charenton under the Direction of the Marauis de Sade! But I & l see it.
No, I did \emphCnot) act in the movie \emphC\emphCThe) \emph{Persecut ion) \emph{and) \emphCAssassination) \emphCof) \emphCJean-Paul) \emphCMarat), as performed by the Inmates of the Asylum of Charenton under the Direc\-tion of the Marquis deeSade!) But I \emphCdid) see it.

You can turn this feature off and on by using \normalem and \ULf o r e The next example shows which other variations are possible.
Just underlining (under-line), a wavy underline (under-wave), a line through text (swkxw?), crossing out text WBRg/M//WM,
Just underlining (\ulineCunder-line)), \ \ a wavy underline (\uwaveCunder-wave)), \ \ a line through text (\soutCstrike out)), \\ crossing out text (\xoutCcross out, X out)),

'see chapter 7 for the new font commands introduced in BTEXZE.

50

Basic Formatting Tools

They are "optional features" and by default their definitions in the package file are commented out, so you have to activate them by hand.

3.1.3 xspace-Gentle Spacing after a Macro


The small package xspace (by David Carlisle) defines the \xspace command, which should be used at the end of a macro designed to be used mainly for text. It adds a space unless the macro is followed by certain punctuation characters. \xspace saves you from having to type \ , or 0 after most occurrences of a macro name in text. However, if either of these constructs follows \xspace, a space is not added by \xspace. This means that it is safe to add \xspace to the end of an existing macro without making too many changes in your document. Possible candidates for \xspace are commands for abbreviations like "e.g.," and "i.e.,".

(L14,154)

Notice the use of the \a command to generate the right kind of space. If used to the right of a punctuation character it prevents extra space from being added: the dot will not be regarded as an end of sentence symbol. Using it on the left forces LATEX to interpret the dot as an end of sentence symbol. Sometimes \xspace may make a wrong decision and add a space when it is ) , as this has the effect of not required. In such cases, follow the macro with C suppressing the space.
\newcommand{\USA){United States of America\xspace) \newcommand{\GB){Great Britain\xspace) The \USA has 50 states.\\ \GB, the \USA and Canada have close cultural links.

The United States of America has 50 states. Great Britain, the United States of America and Canada have close cultural links.

3.1.4 Paragraph Justification (L111-2)


In some documents, paragraphs are not aligned at the right margin (like in this paragraph). The W X flushlef t environment typesets an enclosed paragraph in t h s way. But the paragraph typesetting parameters have no universal effect, because most environments (such as minipage, tabular, and the list family) and commands (like \parbox, \footnote, and \caption) restore the alignment of paragraphs. That is, they set the \rightskip distance to zero. To put ragged right text inside such environments and commands you can issue the command \setlength(\rightskip)COpt plus If il) withn their

3.1 Phrases and Paragraphs

51

scope. Inside list-like environments another rubber length, \ @ r i g h t s k i p , is used instead of \ r i g h t s k i p . In the following example, which uses the minipage environment internally, we redefine \ r i g h t s k i p to obtain the desired effect. Note that we only allow \ r i g h t s k i p to be stretchable to a maximum of 2 cm, in order to limit the possible white space at the right of the page.
In the beginning God created the heaven and the earth. Now the earth was unformed and void, and darkness was upon the face of the deep; and the spirit of God hovered over the face of the waters.
\setlength(\rightskip}{Opt plus 2cm) In the beginning God created the heaven and the earth. Now the earth was unformed and void, and darkness was upon the face of the deep; and the spirit of God hovered over the face of the waters.

Other ways of typesetting paragraphs are flush right and centered, with the f l u s h r i g h t and c e n t e r environments respectively. In these cases the line breaks are usually indicated with the \ \ command, whereas for ragged right text (the f l u s h l e f t environment discussed above) you can let IPQX do the line brealung itself. The three environments discussed in t h s section work by changing declaE X typesets paragraphs. These declarations are also rations that control how T available as W X commands, as shown in the following table of correspondence.

(L112)

environment: command:

center \centering

f lushleft \raggedright

flushright \raggedlef t

These commands, which do not start a new paragraph unlike the corresponding environments, can be used inside other environments and in a parbox, in particular, to control the alignment inside the p columns of an a r r a y or t a b u l a r environment. Note, however, that certain precautions should be taken in this case, as discussed on page 108,where the command \PreserveBackslash is introduced. The inter-word spacing in a justified paragraph (the white space between individual words) is controlled by several TEX parameters-the most important ones are \ t o l e r a n c e and \emergencystretch. B y setting them suitably for your document you can prevent most or all of the "Overfull box" messages without any manual line breaks. \ t o l e r a n c e is a measure for how much the inter-word space in a paragraph is allowed to diverge from its optimum value.2 This command is a TEX (not DQX) counter and therefore it has an uncommon assignment syntax, e.g., \tolerance=500. Lower values makes TEX try harder to stay near the optimum; higher values allow for loose typesetting. The default value is often 200. When T E X is unable to stay in the given tolerance you wdl find overfull boxes in your output (i.e., lines sticking out into the margin like this).
2 ~ hoptimum e is font defined: see section 7.7.2 on page 201.

52

Basic Formatting Tools

B y enlarging the value of \tolerance TEX will also consider poorer but still acceptable line breaks, instead of turning the problem over to you for manual intervention. Sensible values are between 50 and 9999-do not use 10000 or hgher: this allows TEX to produce arbitrary bad lines (like this one). If you really need fully automated line breaking, it is better to set the length parameter \emergencystretch to a positive value. If TEX cannot break a paragraph without producing overfull boxes (due to the setting of \tolerance) and \emergencystretch is positive, it will add this length as stretchable space to every line, thereby accepting h e breaking solutions that have been rejected before. As a result you may get some underfull box messages because all the lines are now set in a loose measure, but this will still look better than a single horrible line in the middle of an otherwise perfectly typeset paragraph. L A T E X has two predefined commands influencing the above parameters: \fussy,which is the default; and \sloppy,which allows for relatively bad lines. \sloppy is automatically applied by L A T E X in some situations (e.g., when typesetting \marginpar arguments or p columns in a tabular environment) where perfect h e breaking is seldom possible due to the narrow measure.

3.1.5 doublespace-Changing Inter-Line Spacing


( L 94,155)

The \baselineskip is TEX'S parameter for defining the leading (normal vertical distance) between consecutive baselines. Standard L A T E X defines a leading approximately 20% larger than the design size of the font (see section 7.6.1 on page 188). Because it is not recommended to change the setting of \baselineskip directly, W X provides the \baselinestretch command to allow changing the \baselineskip at all sizes globally. Note that after issuing the \renewcommandC\baselinestretch)Ci .51 command, the leading will not increase immediately. A font size changing command (like \small, \Large, etc.) should be executed to make the new value come into effect. The package doublespace (by Stephen Page) defmes the spacing environment. The parameter coef is the value of the \baselinestretch for the text enclosed by the environment.

In the example in figure 3.1 on the facing page the coefficient "2" produces a leading larger than the "double spacing" required for some publications. In this case the leading is increased twice-once by \baselineskip (where TEX already adds about 20%space between baselines) and a second time by setting \baselinestretch. "Double spacing" means that the vertical distance between baselines is about twice as large as the font size. Since \baselinestretchrefers

3.1 Phrases and Paragraphs


In the beginning God created the heaven and the earth. Now the earth was unformed and void, and darkness was upon the face of the deep; and the spirit of God hovered over the face of the waters.

53

\begin{spacing){2) In the beginning God created the heaven and the earth. Now the earth was unformed and void, and darkness was upon the face of the deep; and the spirit of God hovered over the face of the waters. \end{spacing)

Figure 3.1: Spaced-out paragraphs

double Table 3.1: Effective \baselinestretch values for different font sizes

to the ratio between the desired distance and the \baselineskip,the values of \baselinestretch for different document base font sizes (and at two different optical spacings) can be calculated and are presented in table 3.1.

3.1.6 pici npar-Typeset a Paragraph with a Rectangular Hole


The package picinpar (by Friedhelm Sowa based on earlier work by Alan Hoenig) allows "windows" to be typeset inside paragraphs. The basic environment is window, which has two variants figwindow and tabwindow. These will also provide figure and table captions, respectively. The figwindow environment is similar to the wrapf igure environment described in section 6.4.2. As explained there, you should be careful whenmixing figwindow and normal f igure environments, since the latter can slip past the non-floating figwindow environments, and thus out-of-sequence figure numbers may result.

nl align material

Number of lines before the window starts; Alignment of the window inside the paragraph ( I , the default value, for left, c for centered, and r for right adjusted); Material to be shown in the window;

54
In this case we center a word printed vertically inside the paragraph. It is not difficult to understand e that tables can also be easily included with the tabwindow environment. When a paragraph ends, like here, and the window is not yet finished, then it just continues past the paragraph boundary, right into the next one(s).

Basic Formatting Tools


\begin(window~~i,c,% I\f boxI\short stackIH\\e\\l\\l\\o>>> ,I>] In this case we center a word printed vertically inside the paragraph. It is not difficult to understand that tables can also be easily included with the \textttCtabwindow) environment.\par When a paragraph ends, like here, and the window is not yet finished, then it just continues past the paragraph boundary, right into the next one(s). \end{window)

Figure 3.2: A "window" in a paragraph

explanation Explanatory text about the contents in the window (e.g., the caption for f igwindow and tabwindow.

Figure 3.2 shows how you can introduce a window in the middle of a paragraph. Notice the use of the \shortstack command to put the letters on top of each other. A figure or a table can also be included inside a paragraph. An example is shown in figure 3.4 on the next page where we put a map of Great Britain at the right side of the paragraph. The f igwindow environment also typesets the caption specified.

3.1.7 shape par-Typeset a Paragraph with a Specified Shape


The package file shapepar (by Donald Arseneau) defines the command \shapepar, which typesets paragraphs of a specified shape. The total size is adjusted automatically so that the entire shape is filled with text. The paragraph to be typeset should not contain any display math or \vadjust material, which includes \vspace commands. The paragraph is repeatedly formatted until its size and shape are right. As this is a slow process, this package is mainly intended for cards, invitations-not for whole books! The command \shapepar must be used at the beginning of a paragraph, and it applies to the entire paragraph.

( \shapeparCshape-spec)

paragraph material

The parameter shape-spec gives a description of the shape for the paragraph. The syntax rules for specifying this shape are very specific, and

3.1 Phrases and Paragraphs


Is this a dagger which I see before me, The handle toward my hand? Come, let me clutch thee. I have thee not, and yet I see thee still. Art thou not, fatal vision, sensible To feeling as to sight? or art thou but A dagger of the mind, a false creation, Proceeding from the heat- ' oppressed brain? I see thee yet, in form as palpable As this which now I draw. Thou marshall'st me the way that I was Figure 3.3: United Kingdom going; And such an instrument I was to use. Mine eyes are made the fools o' the other senses, Or else worth all the rest; I see thee still, And on thy blade and dudgeon gouts of blood, Which was not so before. (Macbeth, Act 11, Scene 1).

55
\begin{f igwindow) [3, r ,% C\fbox{\epsfig{file=ukmap.eps,width=27mm))),% {United Kingdom)] Is this a dagger which I see before me, The handle toward my hand? Come, let me clutch thee. I have thee not, and yet I see thee still. Art thou not, fatal vision, sensible To feeling as to sight? or art thou but A dagger of the mind, a false creation, Proceeding from the heat-oppressed brain? I see thee yet, in form as palpable As this which now I draw. Thou marshallJst me the way that I was going; And such an instrument I was to use. Mine eyes are made the fools o J the other senses, Or else worth all the rest; I see thee still, And on thy blade and dudgeon gouts of blood, Which was not so before. (\emph{Macbeth), Act 11, Scene 1 ) . \end(figwindow)

Figure 3.4: A paragraph embedded figure

those interested should consult the package file itself. There exist four predefined shapes, three of which have also an associated predefined command \diamondpar, \squarepar and \heartpar. Their effect is shown below:
0
Infandurn, regina. iubes renovare dolorem, Troianas ut opes e t lamentabile regnum eruerint Danai; quaeque ipse m i s e d m a vidi, et quorum pars magna fui. Quia talia fando Myrmidonum Dolopumve aut duri miles Ulixi temperet a lacrimis? Et iam nox umida caelo praecipitat, suadentque cadentia sidera somnos. Sed si tantus amor casus cognoseere nostros e t breviter Troiae supremum audire laborem, quamquam animus meminisse horret, luetuque refugit, incipiam. 0

Infandum, regina, iubes renovare dolorem, Troianas ut opes et lamentabile regnum cmerint Danai; quaeque ipse miserrima vidi, et quorum pars magna fui. Quis talia fando Myrmidonurn Dolopumve aut duri miles Ulixi ternperet a lacrimis? Et iam nox umida caelo praecipitat, suadentque cadentia sidera somnos. Sed si tantus amor casus cognoscere nostros et breviter Troiae supremum audire laborem, quamquam animus meminisse horret, luctuque refugit, incipiam.

\diamondpar{Infandum,

regina,

...)

\squareparCInfandum, regina,

...)

56
Infandum, regina, iubes renovare dolorem, Troianas ut opes et lamentabile regnum cruerint Dan& quaeque ipse miserrima vidi, et quorum pars Quis talia fando Myrmidonum magna h i . l i x i temperet a Dolopumve aut duri miles U lacrimis? Et iam nox umida caelo praecipitat, suadentque cadentia sidera somnos. Sed si tantus amor casus cognoscere nostros et breviter Troiae supremum audire laborem, quamquam animus meminisse horret, luctuque refugit, incipiam.

Basic Formatting Tools


Infandum, regina, iubes renovare dolorem, Troianas ut opes et lamentabile regnum cruerint Dan& quaeque ipse misemma vidi, et quorum pars magna fui. Quis talia fando Myrmidonum Dolopumve aut duri miles Ulixi temperet a lacrimis? Et iam nox umida caelo praecipitat, suadentque cadentia sidera somnos. Sed casus cognoscere si tantus amor nostros et breviter Troiae supremum audire laborem, quamquam animus meminisse horret, luctuque refugit, incipiam.

\heartpar{Inf andum, regina, . . .)

\shapepar\nutshape{Infandum, regina, . . . I

3.2 List Structures


Lists are a very general L A T E X construct and are used to build many of L A T E X S ' display-like environments. WX's standard list environments, enumerate, itemize, and description, are discussed in the next section, where we also show how they can be customized. The general list environment is discussed in section 3.2.2.

3.2.1 Modifying the Standard Lists


It is relatively easy to customize the three standard J2QX list environments, and the three sections below will look at each of these environments in turn. Changes to the default definitions of these environments can be made globally by redefining certain list-definingparameters in the document preamble, or they can be kept local. Customizing the enumerate List Environment

(L26,165-6)

IF&X's enumerated (numbered) list environment enumerate is characterized by the commands and representation forms shown in table 3.2 on the facing page. The first row shows the names of the counter used for numbering the four possible levels of the list. The second and third rows are the commands giving the representation of the counters and their default definition in the standard L A T E X class files. Rows four, five, and six contain the commands, the default definition, and an example of the actual enumeration string printed by the list. A reference to a numbered list element is constructed using the \theenmi, \theenumii,and other similar commands, prefixed by the commands \pQenumi, \p@enumii, etc., respectively. The last three rows in the table show the com-

3.2 List Structures

57

1 First level counter 1 enumi representation \theenmi default definition \arabic{enumi> label field \labelenmi default form \theenmi. numbering example l., 2. \p@enumi prefix default definition {) reference example 1, 2

Second level enumii \theenumii \alph{enumii) \labelenumii (\theenumii) (a), (b) \p@enumii \theenmi la, 2b

Third level enumiii \theenumiii \roman{enumiii) \labelenumiii \theenumiii. i., ii. \p@enumiii \theenumi(\theenumii) l(a)i, 2(b)ii

Fourth level enumiv \theenumiv \Alph{enumiv) \labelenumiv \theenumiv. A., B. \p@enumiv \p@enumiii\theenumiii l(a)iA, 2(b)iiB

Table 3.2: Commands controlling an enumerate list environment

mand, its default definition, and an example for the representation of references. It is important that you are careful to take into account the definitions of both the representation and reference building commands to get the references correct. We can now create several kinds of numbered description lists simply by applying what we have just learned. Our first example redefines the first and second level counters to use capital Roman digits and Latin characters. The visual representation should be the value of the counter followed by a dot. The default value of table 3.2 is used for the reference prefix command \p@enumi.
I. Introduction
A. Applications Motivation for research and applications related to the subject.

\makeatletter
\renewcommand{\theenumi){\Romadenumi)) \renewcommand{\labelenumi>{\theenumi.) \renewcommand{\theenumii){\Alph{enumii)) \renewcomand{\labelenumii)C\theenumii.) \renewcomand{\p@enumii)C\theenumi--)

B. Organization Explain organization of the report, what is included, and what is not.

II. Literature Survey III. Proposed Research

\makeatother \begin{enumerate) \item \textbf{Introduction) \begin{enumerate) \item \textbfCApplications) \newline Motivation for research and applications \label{ql) related to the subject. \item \textbf~~r~anization) \newline Explain organization of the report, what is included, and what is not. \label{q2> \end{enumerate) \item \textbf{Literature Survey) \label{q3) \item \textbf{Proposed Research) \label{q4) \end{enumerate) ql=\ref{ q l ) q2=\refCq21 q3=\refCq3) q4=\ref{ q 4 )

58

Basic Formatting Tools

You can also decorate an enumerate field by adding something to the label field. In the example below, we have chosen the paragraph sign ( 5 ) as a prefix for each label of the first level list elements.
51. text inside list, more text inside list, text inside list, 52. text inside list, more text inside list, text inside list, 53. text inside list, more text inside list, text inside list, more text inside list. w l = l w2=2
\renewcommandC\labelenumi)C\S\theenumi.) \beginCenumerate) \item text inside list, more text insids text inside list, \label(wl) \item text inside list, more text inside text inside list, \labelCwZ) \item text inside list, more text inside text inside list, more text inside
\endCenumerate) wl=\refCwl) wZ=\refCwZ>

list, list, list, list.

You might even want to select different markers for consecutive labels. For instance, in the following example, characters from the Postscript font ZapfDingbats are used. In this case there is no straightforward way for automatically making the \ r e f commands produce the correct references. You can, however, use the d i n g a u t o l i s t environment defined in the package file pifont, whch is part of the PSNFSS system (see section 11.9.3 on page 335). Note also that we have used the calc package for doing the addition inside the \ s e t c o u n t e r command (see section A.4 on page 468).
O text inside list, more text inside list, text inside list, more text inside list;
Q text inside list, more text inside list, text

\newcounterClocal)\renewcommandC\labelenumi~ C\setcounterClocal~C17l+\valueCenumi~>% \ding{\valueClocal)))


\item text inside text inside \item text inside text inside \item text inside text inside \endCenumerate) list, list, list, list, list, list, more more more more more more text text text text text text inside inside inside inside inside inside list, list; list, list; list, list.

inside list, more text inside list;


O text inside list, more text inside list, text inside list, more text inside list.

Finally, for those who do not want to get involved in customizing these commands themselves, there exists a package enumerate (by David Carlisle), which redefines the enumerate environment with an optional argument specifying the style in which the counter has to be printed. This argument can contain any one of the tokens A, a, I, i, or 1 for typesetting the value of the counter using (respectively)the \Alph, \alph, \Roman, \roman, or \ a r a b i c styles. Moreover, you can put any P Q X expression in the argument; however the tokens A, a, I, i , or 1 must be specified inside a C3 group if they should not be interpreted in the above manner.

3.2 List Structures

59

First level

Second level

Thrd level
\labelitemiii \m@th\ast

Fourth level
\labelitemiv \m@th\cdot

Commands Definition Representation

\labelitemi \m@th\bullet

\labelitemii \ b f s e r i e s --

Table 3.3: Commands controlling an i t e m i z e list The internal command \m@thin the above settings locally sets the value of the \mathsurround parameter to zero (extra space around in-line formulas). \m@th should be called whenever math mode is entered for non-math purposes to avoid extra spaces in cases where \mathsurround was made positive by the document class file. The cross-reference commands \ l a b e l and \ r e f can be used as with the standard enumerate environment. Note, however, that with t h s package the \ r e f command only produces the chosen representation of the counter valuenot the whole label. It prints the value in the same style as \item, as determined by the presence of one of the tokens A, a, I, i , or I in the optional argument.
EX i. text item one level one. More text item

one level one


EX ii. text item two level one.

example a) text item one level two. More text item one level two example b) text item two level two.
A-1 text item one level one for list two. A-2 text item two level one for list two.

This is how list entries are referenced: 'i', 'iia' and '1' or more fully 'EX i.' and 'A-1'.

\begin{enumerate) [EX i .I \item text item one level one. \label{LA} More text item one level one \item text item two level one. \begin{enumerate) [{example) a)] \item text item one level two. More text item one level two \label{LB) \item text item two level two. \end{enumerate) \end{enumerate) \begin{enumerate) [ { A ) - 11 \item text item one level one for list two. \labellLC) \item text item two level one for list two. \end{enumerate) This is how list entries are referenced: ' \ref{LA) ' , '\ref {LB) ' and ' \ref{LC) ' or and 'A-\refCLC)'. more fully 'EX-\ref{LA).'

Customizing the i t e m i z e List Environment

For a simple unnumbered i t e m i z e list, the labels are defined by the commands shown in table 3.3. To create a list with different labels, you can redefine the label-generating command. You can make that change local for one list, as in the example below, or you can make it global by putting the \ l a b e l i t e m i redefinition in the document preamble. The following simple list is a standard i t e m i z e list with a

(L26,165-6)

60

Basic Formattinn Tools

marker from the Postscript ZapfDingbats font (see section 11.9.3 on page 335) for the first level label:

GF

Text of the first item in the list. Text of the first sentence in the second item of the list. And the second sentence. ~k~ sentence in the text of the of the list. item

\newenvironment{MYitemize){% \renewcommand{\labelitemi)C\ding{43))% \begin{itemize)){\endfitemize)) \beginC~yitemizel \item Text of the first item in the list. \item Text of the first sentence in the second item of the list. And the second sentence. \item This sentence in the text of the third item of the list. \end{MYitemize)

Customizing the d e s c r i p t i o n List Environment

(L 26,165-6)

Using the d e s c r i p t i o n environment you can change the \ d e s c r i p t i o n l a b e l command that generates the label. In the following example the font for typesetting the labels is changed from bold to sans serif.
\renewcommand{\descriptionlabel) [ l ]% (\hspace(\labelsep)\textsf{#l)~ \begin{description) text inside list, text inside list,

A.

text inside list, text inside list, text inside list, more text inside list; text inside list, text inside list, text inside list, more text inside list;

B.
C.

text inside list, text inside list, text inside list, more text inside list.

text inside list, more \item[B. I text inside list, text inside list, more \item[C.l text inside list, text inside list, more \endCdescription)

text text text text text

inside inside inside inside inside

list; list, list; list, list.

The standard L A T E X class files set the starting point of the label box in a
d e s c r i p t i o n environment a distance of \ l a b e l s e p to the left of the left margin of the enclosing environment, so that the \ d e s c r i p t i o n l a b e l command in the example above first adds a value of \ l a b e l s e p to start the label aligned with the

left margin.

3.2.2 Making Your Own Lists


(L 112,166-8) Lists are generated by the generic environment l i s t :

The parameter default-label is the text to be used as a label when an \item command is issued without an optional argument. The parameter decls sets up

3.2 List Structures

61

the different geometrical parameters of the list environment (see figure 3.5 on the following page). That figure also shows the default values for those parameters. The parameters can all be redefined with the help of the \setlength or \addtolength commands. Several W X environments are defined with the help of list (for example, quote, quotation, center, f lushleft, and f lushright). Note that these environments have only one item, and the \item [I command is specified in the environment definition. As an example, we can consider the quote environment whose definition gives it the same left and right margins. The simple variant Quote, shown below, is identical to quote apart from the double quote symbols added around the text. Note the special precautions, which must be taken to eliminate undesirable and following (\unskip) the text. white space in front of (\ignorespaces)

. .. text before.
"Some quoted text, more quoted text. Some quoted text, more quoted text." Text following . ..

\newenvironment{Quote)"/. Definition of quote (\beginClistlO{% \setlength{\rightmargin)I\leftmargin)) \item [I ' ' \ignorespaces) C\unskip"\end{list)) \ldots\ text before. \begin{quotel Some quoted text, more quoted text. Some quoted text, more quoted text. \end{Quote) Text following \ldots

General lists are often used for documenting computer commands or program functions. For instance, in the following examples entry and its variants are used. In each case the name of the topic being described is entered as the parameter of the \item command.
Description: Returns from a function. If issued at top-level, the interpreter simply terminates, just as if end of input had been reached. Errors: None.
\beginCentry) \item[Description] Returns from a function. If issued at top-level, the interpreter simply terminates, just as if end of input had been reached. \item [Errors] None. \item [Return values] \mbox{)\\ Any arguments in effect are passed back to the caller \endCentry)

Return values: Any arguments in effect are passed back to the caller.

This example shows a typical problem with description-like lists when the text in the label (tenn) is wider than the width of the label. Standard L Q X lets the text of the term continue into the text of the description part. This is normally

62

Basic Formatting Tools

I
+

Text preceding list

1
C

+
Item 1
+

\rightmargin

\lef tmargin
A
4

Paragraph 1

Item 1

Paragraph 2

Item 2

I
Vertical lengths

Text following list Figure 3.5: The structure of a general list

extra indentation at beginning of every paragraph of a list except the one started All the vertical spaces below are rubber lengths with by \item. Can be negative, but is usually Opt. a value depending on the type size and the level of \itemindent extra indentation added to the horithe list. zontal indentation of the text part of the first \topsep space between first item and preceding line of an item. It is with respect to this reference paragraph. point that the starting position of the label is cal\partopsep extra space added to \topsep when enculated by subtracting the values of \labelsep vironment starts a new paragraph. and \labelwidth. Its value is usually Opt. \itemsep space between successive items. \labelwidth the nominal width of the box contain\parsep space between paragraphs within an item. ing the label. If the natural width of the label is <\labelwidth, then the label is typeset flush Horizontal lengths right inside a box of width \labelwidth. Oth\lef tmargin space between left margin of encloserwise, a box of the natural width is employed, ing environment (or of page if top level list) and which causes an indentation of the text on that left margin of this list. Must be nonnegative. Its line. value depends on the list level. \labelsep the space between the end of the label \rightmargin similar to \leftmargin but for the box and the text of the first item. Its default value right margin. Its value is usually Opt. is 0.5em.
\listparindent

3.2 List Structures

63

not desired, and to improve the visual appearance of the list we have started the description part on the next line. A new line was forced by putting an empty command. box on the same line, followed by the In the previous example, the \makelabel command (a command with one argument defining the layout of the \item label) and the two geometrical pararneters (\labelwidth and \leftmargin) were redefined, as shown below.3
I\\'

In the remaining part of this section various possibilities for controlling the width and mutual positioning of the term and description parts will be investigated. One method for accomplishing this is to change the width of the label. The environment is declared with an argument specifying the desired width of the label field (normally chosen to be the widest term entry). Note the redefinition of the \makelabel command where you specify how the label will be typeset. As this redefinition is put inside the definition of the Ventry environment, the argument placeholder character # must be escaped to ## to signal L A T E X that you are referring to the argument of the \makelabel command, and not to the argument of the outer environment.
Description:

Returns from a function. If issued at top-level, the interpreter simply terminates, just as if end of input had been reached. None. Any arguments in effect are passed back to the caller.

Errors: urn values:

\beginCVentry>CReturn values} \item [Description] Returns from a function. If issued at top-level, the interpreter simply terminates, just as if end of input had been reached. \item [Errors] None. \item[Return values] Any arguments in effect are passed back to the caller. \end{Ventry}

3 ~ this n and some of the following examples, we have used the package calc and extended control structures of BT'XZE (see appendix A, sections A.4 and AS).

64

Basic Formatting Tools

The Ventry environment is defined by:

However, several lists with varying widths for the label field on the same page might look typographically unacceptable. Evaluating the width of the term is another possibility. If it is wider than \labelwidth, an additional empty box is appended with the effect that the description part starts on a new line. This matches the conventional method for displaying options in UNM manuals.
\newlength{\Mylen) \newcommand{\Lentrylabel) [I]{% \settowidthC\Mylen){\textsf {#l :)I% \ifthenelse{\lengthtestC\Mylen > \labelwidth))% {\parbox [bl {\labelwidth)% term > labelwidth {\makebox [Opt] [I]{\textsf C#1 :))\\)I% {\textsf{#l:))% term < labelwidth \hfil\relax) \newenvironment{Lentry) ~\renewcommand~\entrylabel~{\Lentrylabel)% \beginfentry)) I\endCentryl)

As the last line in the definition above shows, the Lentry environment is defined in terms of the e n t r y environment. The label generating command \ e n t r y l a b e l is now replaced by the \ L e n t r y l a b e l command. The latter first sets the length variable \Mylen equal to the width of the label. It then compares that length with \labelwidth. If the label is smaller than \labelwidth, then it is typeset on the same line as the description term; otherwise it is typeset in a zero width box with the material sticking out to the right as far as needed (forcing a new line) so that the description term starts one line lower.
Description: Returns from a function. If issued at top-level, the interpreter simply just as if end of input had been reached. Errors: None. Return values: Any arguments in effect are passed back to the caller.
\begidLentry) \item[~escriptionl Returns from a function. If issued at top-level, the interpreter simply terminates, just as if end of input had been reached. \item [~rrors] None. \item [Return values] Any arguments in effect are passed back to the caller. \end{Lentry)

3.2 List Structures

65

Yet another possibility is to allow multiline labels.


Descrip- Returns from a function. If issued tion: at top-level, the interpreter simply terminates, just as if end of input had been reached. Errors:
R~~~~~ values:
\begin{Mentry) \itemCDescriptionl Returns from a function. If issued at top-level, the interpreter simply terminates, just as if end of input had been reached. \item [Errors] None. \itemCReturn\\valuesl Any arguments in effect are passed back to the caller. \endCMentry)

None.

arguments in effect are passed back to the caller.

In this example we, once more, use the e n t r y environment as a basis, but t h s time the command \Mentrylabel replaces the \ e n t r y l a b e l command. The idea here is that large labels may be split over several lines. Certain precautions have to be taken to allow hyphenation of the first word in a paragraph, and therefore the \hspaceCOpt> command is introduced in the d e h t i o n . The material gets typeset inside a paragraph box of the correct width \ l a b e l w i d t h , whch is then top aligned and left adjusted into a box that is itself placed inside a box with a height of 1 ex and no depth. In this way, LATEX does not realize that the material extends below the first line.
\newcommand{\Mentrylabel) [I] % {\raiseboxCOpt) [iexl [Opt] {\makebox [\labelwidth] [11% {\parbox~t]C\labelwidth)~\hspace{Opt~\textsf~#l:))))} \newenvironment{Mentry)% ~\renewcommandC\entrylabel)C\Mentrylabel)\begin~entry))% C\endCentry))

An environment with an automatically incremented counter can be created by including a \ u s e c o u n t e r command in the declaration of the l i s t environment. This function is demonstrated with the Notes environment, which produces a sequence of notes. In this case, the first parameter of the l i s t environment is used to provide the automatically generated text for the term part.

After declaring the n o t e s counter, the default label of the Notes environment is defined to consist of the word NOTESin small caps, followed by the value

66

Basic Formatting Tools

of the n o t e s counter, using as its representation an arabic number followed by a dot.


NOTE 1. This is the text of the first note item. Some more text for the first note item. NOTE 2. This is the text of the second note item. Some more text for the second note item.
\beginCNotes) \item This i s t h e t e x t of t h e f i r s t note item. Some more t e x t f o r t h e f i r s t note item. This is the text of the second note item. Some more t e x t f o r t h e second note item.

3.3 Simulating Typed Text


It is often necessary to display informationverbatim, i.e., "as entered at the terminal." However, to guide the reader it might be useful to highlight certain textual strings in a particular way. This calls for the ability to use other L A T E Xcommands inside "verbatim" texts. The present section describes packages which make this easier.

3.3.1 allt t-A Verbatim-Like Environment


The package alltt (by Leslie Lamport) defines the a l l t t environment. This acts like a verbatim environment except that backslash '\' and the braces 'C' and 7' retain their usual meaning. Thus, other commands and environments can appear inside an a l l t t environment, as shown in figure 3.6 on the next page.

3.3.2

verbatim-A Style for Literal Text

The package verbatim (by Rainer SchopfJ reimplements the L A T E X environments verbatim and verbatim*. One of its major advantages is that it allows arbitrarily long verbatim texts. It also provides a comment environment that skips all text between the commands \begin{comment) and \end(comment). Moreover, it contains a redefinition of WX's \verb command, which is better at detecting the omission of the closing delimiter. The package also provides hooks to implement user extensions for defining customized verbatim-like environments. A few such extensions are realized in the package moreverb, described in the next section.

3.3.3

moreverb-More Verbatim-Like Commands and Environments

The package file moreverb (by Angus Duggan) is based on the verbatim package discussed above. It provides some interesting predefined verbatim-like com-

3.3 Simulating Tmed Text


\beginCalltt) One can have f o n t changes, l i k e : {\em{)emphasized t e x t \ / ) .

67

One can have f o n t changes, l i k e : emphasized t e x t .


A l i n e of s p e c i a l c h a r a c t e r s # $

&

"

A l i n e of s p e c i a l c h a r a c t e r s # $ %

-&--

I n s e r t t e x t from a f i l e "foo.text' by typing ' \input {f oo} ' Beware t h a t " r e t u r n " s t a r t s a new l i n e , so i f f o o . t e x ends with a " r e t u r n " you can wind up with an e x t r a blank l i n e i f you a r e not c a r e f u l .

I n s e r t t e x t from a f i l e "foo.texl' by typing '\(\backslash\)input\{foo\)'. Beware t h a t " r e t u r n " starts a new l i n e , so i f f oo.tex ends with a " r e t u r n " you can wind up with an e x t r a blank l i n e i f you a r e not c a r e f u l . The user can do mathematics t o o by typing \verb!\(...\)! or \verb!\[...\]!. Remember t h a t ' $ ' j u s t produces a d o l l a r s i g n . The same i s t r u e f o r t h e o t h e r s p e c i a l c h a r a c t e r s ' ^ ' , '-' i n s i d e math mode: use \(\backslash\) sp a s i n \(a\sp{2)\), use \(\backslash\)sb a s i n \(a\sb{2)\). \end{alltt)

The u s e r can do mathematics t o o by typing \ ( . . .\) o r \ [ \I Remember t h a t '$' j u s t produces a d o l l a r s i g n . The same i s t r u e f o r t h e o t h e r s p e c i a l c h a r a c t e r s I - ' , '-' i n s i d e math mode: use \ s p a s i n a 2 , use \ s b a s i n az.

. .. .

Figure 3.6: Verbatim-like a l l t t environment

mands for writing to and reading from files as well as several environments for the production of listings.

The verbatimwrite environment (originallywritten by Rainer Schopf)writes its contents to a file filename. At the right-hand side we show the original file (tabs are shown as D), whlle at the left-hand side we show the tabs expanded.

Top l e v e l One l e v e l up Level two Embedded tab

\begin{verbatimwrite)C *D*D*D* Top l e v e l Done l e v e l up DDLevel two DEmbeddedDtab \end{verbatirnwrite)

testtab.out)

The verbatimtab environment allows tab characters (shown as D) to be expanded properly to a number of space characters. (Remember that standard

68

Basic Formatting Tools

W X considers tab characters as single spaces.) The distance between tab stops
can be specified by an optional argument. By default the distance between tab stops is set to eight space characters.
123456789012345678901234567890123456

\begin{verbatimtab)
123456789012345678901234567890123456

I
I

one

two four

three

four

\end{verbatimtab) \begin{verbatimtab) I DoneDtwoDthreeDf our \end{verbatimtab) \ b e g i d v e r b a t imtab) [4] IDoneDtwoDthreeDf our \end{verbatimtab)

one two t h r e e

I \ v e r b a t b i n p u t Ctabstopl {filename) I
The command \verbatimtabinput will input the file filename given as the mandatory argument. The distance between tab stops can be specified by giving an optional argument tabsrop. Note that in the example below the text has a distance of four spaces between tab stops, whereas at the beginning of the section, when file t e s t t a b . out was written, the distance was equal to the default (eight spaces).

\verbatimtabinput [41 { t e s t t a b . out)

Top l e v e l One l e v e l up Level two Embedded tab

The boxedverbatim environment can be used to make verbatim text stand out by surrounding it with a box.
\begin{boxedverbatim) The boxedverbatim environment puts a frame around t h e verbatim environment. \end{boxedverbatim)

puts a frame around t h e verbatim environment.

An environment similar to the a l l t t environment described in section 3.3.1 on page 66 is called verbatimcmd. An example is shown below.

3.3 Simulating Typed Text

69

The verbatimcmd environment can be used to include commands in L6QX verbatim environments. Note that spaces after commands are significant, so empty groups { } should be used to separate words. Otherwise, you will find strange spaces in your output. And some display math

\beginCverbatimcmd) The verbatimcmd environment can be used to include ~\normalfont\itshapeC)commands) in \LaTeX verbatim environments. Note that spaces after commands are { \ ) significant, so empty groups \ should be used to separate words. Otherwise, you will find C\normalfont\itshape strange) spaces in your output. And some display math \ [a\spCb\sbCc)d)\l \endCverbatimcmdl

\begin{listing) [stepl { f i r s t l i n e ) \begin{list ing*) [stepl { f i r s t l i n e ) .

. ..\end{listing) . . \end{list ing*)

The listing environment is like a verbatim environment, but with each line numbered. The starred version listing* shows a blank character as . An optional argument step specifies the step between numbered lines (default i r s t l i n eis the number of the first line. value is l),and the required argument f If the user specifies step as "1,"then all lines will be numbered. The listing environment below is invoked by the command \begin{listing) [21 { 3 ) , which w i l l number each second line starting at number "3."
4

6
8

The listing environment numbers the lines in it. It takes an optional argument, which is the step between numbered lines (line 1 is always numbered if present), and a required argument, which is the starting line.

\begin{listing) [2] C 3 ) The listing environment numbers the lines in it. It takes an optional argument, which is the step between numbered lines (line 1 is always numbered if present), and a required argument, which is the starting line. \end{listing)

The listingcont(*) environment (example on the following page) continues where the previous listing(*) environment left off. The non-starred versions of these environments expand tabs using a default tab width of eight characters while the starred versions do not handle tabs.

70

Basic Formatting Tools


This listingcont environment continues where the previous listing environment left off Both the listing and listingcont environments expand tabs " 1 1 with a default tab width of 8. \beginClistingcont) This listingcont environment continues where the previous listing environment left off Both the listing and listingcont environments expand tabs " D " with a default tab width of 8. \endClistingcont)

10
12

14

I \list inginput Cstepl {firstline)Cfilename)I


The \listinginput command allows a file filename to be read as a listing. Numbering begins with the first line at firstline and then proceeds in steps of step. As an example, the file testtab. out,writtenby the verbatimwrite environment as shown at the beginning of the present section, can be read (and listed) with the command \listinginput{l){testtab.out).
1 2 3 4 5

Top level One level up Level two Embedded tab

3.4 Footnotes, Endnotes, and Marginals


L A T E X has facilities to typeset "inserted" text, such as marginal notes, footnotes, figures, and tables. The present section looks more closely at hfferent kinds of notes, while chapter 6 on page 141 describes floats in more detail.

3.4.1 Customizing Footnotes


Footnotes in I Q X are usually simple to use and provide a quite powerful mechanism to typeset material at the bottom of a page.4 This material can consist of several paragraphs and can include lists, inline or display mathematics, tabular material, and so on. W&X offers several parameters to customize footnotes. They are shown schematically in figure 3.7 on the next page. A sharp distinctionis made between footnotes in the main text and footnotes inside a minipage environment. The former are numbered using the footnote counter, while inside a minipage the \footnote command is redefined to use
4 ~ interesting n and complete discussion of this subject appeared in the French TEX Users' Group magazine Cahiers GUTenberg [5,62].

(L 91,156) (L 99,195)

3.4 Footnotes. Endnotes. and Marninals

71

Main body text.


ootnotesep\f o o t n o t e r u l e \@makeintext

produced by \@makefnmark
\@makefn t e x t

produced by \@makefnmark

Figure 3.7: Schematic layout of footnotes

the mpf ootnote counter. Thus the representation of the footnote mark is obtained by the \thef ootnote or the \thempf ootnote command depending on the context. B y default it is an arabic number in text and a lowercase letter inside a minipage environment. You can redefine this to get a different representation by specifying, for example, for main text footnotes:
text text text* text text text textt text *The first t ~ h second e
\renewcommandC\thefootnote)~\fnsymbol~footnote~~ text text text\footnoteCThe first) text text text text\footnoteCThe second) text

Footnotes produced with the \ f o o t n o t e command inside a minipage environment use the mpfootnote counter and are typeset at the bottom of the parbox produced by the minipage. However, if you use the \footnotemark command in a minipage it wdl produce a footnote mark in the same style and sequence as the main text footnotes-i.e., stepping the f o o t n o t e counter and using the \thef ootnote command for the representation. This behavior allows you to produce a footnote inside your minipage that is typeset in sequence with the main text footnotes at the bottom of the page: you place a \f ootnotemark inside the minipage and the corresponding \f o o t n o t e t e x t after it.
Footnotes in a minipage are numbered using lowercase letters.' at the bottom This text references a of the page.5 ahside minipage
\begin~minipage)~\linewidth) Footnotes in a minipage are numbered using lowercase letters.\f ootnoteCInside minipage) \par This text references a footnote at the bottom of the page.\footnotemark \endCminipage)\footnotetextCAt bottom of page)

In the article class, footnotes are numbered sequentially throughout the


5 ~bottom t o f

page

72

Basic Formatting Tools

document. In report and book footnotes are numbered inside chapters. You can change this by using the \@addtoreset command (see section 2.3.1). However, do not try to number your footnotes within pages with the help of this mechanism. Since L A T E X is looking ahead while producing the final pages your footnotes would most certainly be numbered incorrectly. To number footnotes per page you can use the package footnpag (by Joachim Schrod). To manage the footnote numbers, this package writes information to an auxiliary file, with name "jobname. fot." You must therefore run W X at l@ast twice to ensure that all footnotes get the correct numbers. Also, in this implementation, the optional argument of \footnote is no longer available; but this seems to be a small disadvantage, since you should not have to use this argument with this layout style anyway. The \Qmakefnmark command generates the footnote marker from the \Othefnmark command, which holds the current footnote's mark, created by \thefootnote or supplied by you through the optional argument of the \footnote command. The default definition is the superscript mark:

The appearance of the standard footnote can be changed by customizing the parameters shown in figure 3.7 on the preceding page and described below:
\footnotesize The font size used inside footnotes (see also table 7.1 on

page 170).
\f ootnotesep The height of a strut placed at the beginning of every footnote. If it is greater than the \baselineskip used for \f ootnotesize,then addi-

tional vertical space will be inserted above each footnote. See section A.2.3 for more information about struts.
\skip\f ootins A low-level T E X command that defines the space between the

main text and the start of the footnotes. You can change its value with the \setlength or \addtolength commands by putting \skip\,footins into the first argument, e.g.,

\f ootnoterule A macro to draw the rule separating footnotes from the main text. It is executed right after the vertical space of \skip\f ootins. It should

take zero vertical space, i.e., it should use a negative skip to compensate for any positive space it occupies, for example:

3.4 Footnotes, Endnotes, and Mar-als

73

You can also construct a fancier "rule," e.g., one consisting of a series of dots:

The \ f o o t n o t e command executes \Qmakef n t e x t inside a \parbox, with a width of \columnwidth. The default version looks something like:

A more complicated variant could use a l i s t environment. Each footnote is typeset as a list with one item.

IK&X does not allow you to use another \ f o o t n o t e command inside a \ f o o t n o t e , as is common in some disciplines, but you can use the \f ootnotemark command inside the first footnote and then put the text of the footnote's footnote as the argument of a \f o o t n o t e t e x t command. What if you want to reference a given footnote? For this you can use WX's normal \ l a b e l and \ r e f mechanism, although you may want to define your own command to typeset the reference in a special way, for instance: This is some text.' ... as shown in footnote (1)on page 73 ,...
l ~ e xinside t referenced footnote. \newcommandC\fnref )[I1 C" ( \ r e f C#l))) T h i s i s some t e x t . \ f o o t n o t e { T e x t i n s i d e r e f e r e n c e d footnote\labelCfn:myfoot).)\par ... a s shown i n footnote\fnref{fn:myfoot) page-\pageref {fn:myf o o t ) , . . .

on

Standard W&X does not allow you to construct footnotes inside tabular material. In section 5.6.2 we shall show several ways of tackling that problem. The package fnpara (by Dominik Wujastyk and Chris Rowley) completely changes the presentation6 of footnotes. With this package, footnotes are typeset7 as run-in paragraphs, instead of being stacked one on top of another. It is suitable for texts, such as critical editions, that contain many short footnote^.^
This is an example of a footnote typeset as a run-in paragraph. This is another example of a footnote typeset as a run-in paragraph. See, e.g., the EDMAC system [Sl] for examples of what kind of footnotes and endnotes are common in critical editions.

'

74

Basic Formatting Tools

I \marginpar [left-text] {right-text) 1


(L61,178)
The \marginpar command generates a marginal note. This command typesets the text given as an argument in the margin, the first line at the same height as the line in the main text where the \marginpar command occurs. When only the mandatory argument right-text is specified, then the text goes to the right margin for one-sided printing; to the outside margin for two-sided printing; and to the nearest margin for two-column formatting. When you specify an optional argument, then it is used for the left margin, while the second (mandatory) argument is used for the right. There are a few important things to understand when using marginal notes. Firstly, the \marginpar command does not start a paragraph, that is, if it is used before the first word of a paragraph, the vertical alignment may not match the beginning of the paragraph. Secondly, if the margin is narrow, and the words are long (as in German), you may have to precede the first word by a \hspace{Opt) command to allow hyphenation of the first word. These two \marginlabel potential problems can be eased by defining a command \marginlabel{text), uses the outside which starts with an empty box \mboxC), typesets a marginal note ragged left, marginfornotes. and adds a \hspaceCOpt) in front of the argument.

3.4.2 Marginal Notes

B y default, in one-sided printing the marginal notes go on the outside margin. These defaults can be changed by the following declarations: \reversemarginpar marginal notes go into the opposite margin with respect to the default one; \normalmarginpar marginal notes go into the default margin. As explained in table 4.2 on page 87, there are three parameters to define the style of marginal notes: \marginparwidth, \marginparsep, arid
\marginparpush.

3.4.3 Endnotes
Scholarly works usually group notes at the end of each chapter or at the end of the document. These are called endnotes. Endnotes are not supported in standard I Q X , but they can be created in several ways. The package endnotes (by John Lavagnino) typesets endnotes in a way similar to footnotes. It uses an extra external Me, with extension .e n t , to hold the text of the endnotes. This file can be deleted after the run since a new version is generated each time.

3.5 Using Multiple Columns

75

To include the contents of the file in the document, commands like the following could be issued:

These commands start a new page, open a group to limit the redefinitions of the parameters and commands, redefine some paragraph parameters, and set the font size for the endnotes (\enotesize). Then the command \theendnotes will typeset the endnotes accumulated in memory at that point in the text. Finally the group is ended, so that the redefinitions remain localized. With this package you can output your footnotes as endnotes by simply giving the command:

The user interface for endnotes is very similar to the one for footnotes after substituting the word "foot" for "end." The following example shows the principle of the use of endnotes, where you save text in memory with the \endnote command, and then typeset all accumulated text material at a point in the document controlled by the user.
This is simple text.' This is simple text.' Some more text.3
This is simple text.\endnote{The first endnote. ) This is simple text.\endnote{The second endnote.) Some more text.\endnote{And the third endnote.) \theendnotes \bigskip % output endnotes here This is some more simple text.

Notes
'The f i r s t endnote. h he second endnote. 3 ~ n the d third endnote.

This is some more simple text.

3.5 Using Multiple Columns


Standard L A T E X offers the possibility of typesetting text in one- or two-column mode, but you cannot mix both on one page. The package multicol (written by Frank Mittelbach) defines the environment mult i c o l s , which allows switching between different multicolumn layouts on the same page. Whenusing the twocolumn option, you have the choice of putting your footnotes in the right column only; t h s is achieved with the ftnrig ht package (also by Frank Mittelbach).

76

Basic Formatting Tools

3.5.1 mu lt icol-A Flexible Way to Handle Multiple Columns


( L 82,162)
With standard W&X it is possible to produce documents with one or two columns (twocolumn). However, it is impossible to produce only parts of a page in twocolumn format since the commands \twocolumn and \onecolumn always start a fresh page. Ad&tionally, the columns are never balanced. This sometimes results in a slightly weird distribution of the material. The multicol package solves these problems by defining an environment, multicols, with the following properties: It can create an arbitrary number of columns (up to ten), whch can fill several pages. When the environment ends, the columns on the last page will be balanced so that they are all of nearly equal length. The environment can be used inside other environments such as f i g u r e or minipage where it will produce a box containing the text distributed into the requested number of columns. This means that you no longer need to hand-format your layout in cases like these. Between individual columns, vertical rules of user defined widths can be inserted. The formatting can be customized globally or for individual environments.

3.5.2 Typesetting in Columns

I \ b e g i n { m u l t i c o l s ~ { c o ~ u m n s[preface] ~ [skipq
Normally you can start the environment simply by specifying the number of desired columns.
Here is some text to be are very narrow try typedistributed over several setting ragged right. columns. If the columns
\beginCmulticols)(2) Here is some text to be distributed over several columns. If the columns are very narrow try typesetting ragged right. \endCmulticols)

However, you may be interested in prefixing the multicolumn text with a bit of single-columnmaterial. This can be achieved with the optional argument preface. W X will try to keep the preface and the start of the multicolumn text on the same page.

3.5 Using Multiule Columns

77

Some advice
Here is some text to be distributed over several columns. If the columns are very narrow try typesetting ragged right.

\begin{multicols)C2) [\section*{Some advice)] Here is some text to be distributed over several columns. If the columns are very narrow try typesetting ragged right. \end{multicols)

The m u l t i c o l s environment starts a new page if there is not enough free space left on the current page. T h s is controlled by a global parameter. However, when using the preface argument the default setting for this parameter may be too small. In t h s case you can either change the global default (see below) or adjust the value for the current environment by using the second optional skip as follows:
\begin{multicols){3) [\section*CIndex)l [7cml Text Text Text Text . . . \endCmulticols3

This would start a new page if there were less than 7cm free space.

3.5.3 Customizing the mult i c o l s Environment


The m u l t i c o l s environment recognizes several parameters that can control formatting. Their meaning is described in the following sections. The default values can be found in table 3.4 (dimensions) and table 3.5 (counters) on the next page. If not stated otherwise, all changes to the parameters have to be placed before the start of the environment for which they should apply.
Free Space

The m u l t i c o l s environment first checks whether the amount of free space left on the page is at least equal to \ p r e m u l t i c o l s or to the value of the optional argument skip, when it is specified. If the requested space is not available, a \newpage is issued. Similar action is taken when the end of the environment is reached, this time using the length parameter \ p o s t m u l t i c o l s . Before and after the environment, a vertical space of length \ m u l t i c o l s e p is placed.
Column Width and Separation

The column width inside the m u l t i c o l s environment will automatically be calculated using the number of requested columns and the current value of \linewidth. Between every two columns a space of \columnsep is left.

Basic Formattine Tools

\postmulticols \multicolsep \columnsep

20.0pt 12.0pt plus 4.0pt minus 3.0pt 10.0pt

Table 3.4: Length parameters used by multicols

collectmore unbalance columnbadness finalcolumnbadness tracingmulticols

10001 9999

Table 3.5: Counters used by multicols

Vertical Lines
Between every two columns, a rule of width \columnseprule is placed. If this parameter is set to Opt, the rule is suppressed.
Here is some text to be distributed over several columns. In this example ragged right typesetting is used.
\setlength{\columnseprule)C0pt) \begin{multicols){3) \raggedright Here is some text to be distributed over several columns. In this example ragged right typesetting is used. \endCmulticols)

If you choose a rule width larger than the column separation, the rule will overprint the column text.

Column Formatting
B y default (the \f lushcolumns setting),the multicols environment tries to keep all columns the same length by stretching the available vertical space inside the columns. If you specify \raggedcolumns the surplus space will instead be placed at the bottom of each column. At the end of the environment, the remaining text will be balanced to produce columns of equal length. If you wish to place more text in the left columns

3.5 Usine Multiule Columns

79

you can advance the counter unbalance. This will add space to the rightmost column. The counter unbalance determines the number of additional lines that should be put into the leftmost column. It will automatically be restored to zero at the end of multicols.
Here is some text to be distributed over several columns. In this example ragged right typesetting is used.
\begin{multicols){3) \raggedright Here is some text to be distributed over several columns. In this example ragged right typesetting is used. \setcounterCunbalance)C1) \end{multicolsl

Column balancing is further controlled by the two counters columnbadness and f inalcolumnbadness. Whenever is constructing boxes (such as a column) it will compute a badness value expressing the quality of the box. Thereby, a zero value is optimal, and a value of 10000 is infinitely bad in L A T E X S ' eyes.g While balancing, the algorithm compares the badness of possible solutions and, if any column except the last one has a badness higher than columnbadness, the solution is ignored. When the algorithm finally finds a solution it looks at the badness in the last column and if this is larger than f inalcolumnbadness it will typeset this column with the excess space placed at the bottom allowing it to come out short. You can trace the algorithm by setting the counter tracingmult icols to a positive value (higher values give more tracing information).

3.5.4 Floats and Footnotes in multicol


Floats (for example figures and tables) are only partially supported within
multicols. You can use star forms of the float environments, i.e., requesting floats that span all columns. Column floats and \marginpars,however, are

not supported. Footnotes are typeset (full width) on the bottom of the page, and not under individual columns. Under certain circumstances a footnote may not fall on the same page as its reference in the text. If t h s is a possibility, multicols will produce a warning. In that case, you should check the page in question and if the footnote reference and footnote text really are on different pages, you will have to resolve the problem locally by issuing a \pagebreak command in a strategic place. The reason for this behavior is that multicols has to look ahead to assemble material and may not be able to use all material gathered later on. The amount of look ahead is controlled by the collectmore counter.

9 ~ the f box turns out to be overfull the badness value is set to 100000, to mark this special case.

80

Basic Formatting Tools

3.5.5

ft nrig ht-Right Footnotes in a Two-Column Environment

It is sometimes desirable to group all footnotes in a two-column document at the bottom of the right column. This can be achieved by specifying the ftnright package (by Frank Mittelbach). The effect of this package is shown in figure 3.8 on the facing page-the first page of the original documentation of the ftnright implementation. It is clearly shown how the various footnotes collect in the lower part of the right-hand column. The main idea for the ftnright package is to assemble the footnotes of all columns on a page and place them all together at the bottom of the right column. Allowing for enough space between footnotes and text and, in addition, setting the footnotes in smaller type.1 Furthermore, the footnote markers are placed at the baseline instead of raising them as superscripts.ll T h s package can be used together with most other class files for L A T E X . Of course, the ftnright package will only take effect with a document using a two-column layout specified with the twocolumn option on the \document class command. In most cases, it is best to use ftnright as the very last package to make sure that its settings are not overwritten by other options. It is unfortunate that WQX 2.09 had no provisions to make such changes without overwriting internal routines. The ftnright package uses the values of \.textheight and \skip\f ootins (the space between text and footnotes). The values used are the ones current when ftnright is read. You can change both of them in the preamble of your document by calling the macro \preparef ootins afterwards to reinitialize the footnote algorithm, for example:

~ will not be necessary Once the ftnright package is updated for w X 2 this any longer because within IN EX^^ it is possible to make use of a hook at the \begin{document) command where execution of \preparef ootins could be forced internally.

3.6 Simple Version Control


With the comment environment (provided by the verbatim package) it is possible to ignore some passages in the document during the formatting process. The
losome journals use the same size for footnotes and text, which sometimes makes it difficult to distinguish footnote and main text. "of course, this is only done for the mark preceding the footnote text and not the one used within the main text, where a raised number or symbol set in smaller type will help to keep the flow of thoughts uninterrupted.

aEe4red prrtxal Jo ]uaruaJuld tq61rutlaq] qll.lr seloutooJ aq1 :g.gamErg

uaqg aceld pw aAEdD uo srunloJ lle Jo seloutmJ 11e aqt tlquesse ol sI lnofel srql ro; eaprurgu aql z lou Jo sea lr laqtaqa Jlesurq loJ aBpnf wr Jepeel InJssaJrns aql pw radpdslql ul patuasatdsl uoga slqlJo llnsar aqJ ;no,{q ,rau aql go uo;ldl.resaq I.I

qliNe^o (s! ^lFnlrs qctqa uoudo ol,{lstuounf,opu Jo peelsur u llla uogdoelllsEs?dntes,(lluarna srqrtqa)uoldofpoq6nfT ardl .8 'pusuuoc ellfstuauncop\ aql ul uolldo al,{lstueunoop s $ uunTocoet segrr.ds,(lpuoueperesn eql ueqa lo (1oq6nfT oIII) InoFq uunloaoal s Sulsnol,{lsluaunlop ? qlla laaJa {luo e{q 'esinor 'aoleq aes IIla uolldo aql JO IIra ea se locTqp lndfno 0 \ pus To3aleuo\ 'uunTo.ttre1s0\ solspu oql * asardl.,[ 'p40uaurun 'sq8noql aog eql deel ot dlarl ed,0 rrllEus ur jo

.sqouooj eql 3ur^!3 .lxq p@ setou qrnu q.nu'uoluldo,{u ool ul tooJ roJ azrs ouEs oql ssn voqgnl u uo,{sl plsp@s e{I .e poJitd lou s! uarsopSullnsil aql txal oql tnoqSnorqlpolruuds soun apoa ot srequnu ,{u!l suSrsw Eqt 'ttl uoqdo cop arll .sn srieu oqe epw slqt oruls selou Jo 1oo; yo tuauacqd oqt pe8upqc ,(luouoqdo slql le|'|t.rlou eseld .z .a8edauo uo roJlp usJ suunloaJo iaqunu aql ojurs 'uouql eql ls sqoqooj uunloc $n lou @c no^ .I '6tl90/26 uo posr^d lst sa uopquauncop etdl 6 l/90/26pelgpp0.l ^ iaqunu uol$e^ etlt sq elr! -E srql ur p*lursep $ qalqa tq6 Frutl uoqdo atlts FlJiJ erU *

lo las loqu{s IIrm 'slxel wua9 puer rtqunu pasru s Jeqa lxat urcu oln ulqlla posnauo oql lou pw lxal qoulooJ eql SupeeJerd ot etqe Eulaq auo,fuemol puewoJal ptnod I .qoql lnu oqt JoJ.uop ,(luo sr s|qt .ostnoJ JO 9 'aoulooJ '[/] lreuours pelJ@f{ pw srrltJoluo{ur.9,aql'3e'qoqu,{sro$oqunu,{!!!aql .9 [g] ploqrrqrsl w1 ,{q qooq .pasn.Iru aqtJo rnpla aqt roJ pellnsuoJ oslE I sapulmJ Jo lno,(pl aqt uO [6] atlqnL etesueduoaotpasnaqplnoqsoredsalus8euel?qlos,arsdsou,{dncco wf ^q papuaruoml osl sr lr lEql punoJl'uo tel?-I .Il] ,eseold .[9gl .z] plnoqspwuuoc slql d aTuafoulool\ lDql'rlou zurEIAIUsq3slleseCSraquelng eql yo lmqnef aq1 .(q pueuuor aql Sulugopd ,{q U ppe uB. oltu oql reJerdoqn aldoog p pa:rdsurvm pesn I lno{pl eql .asodjndsrqt loJ aurtnol 'oJuauludd_ tndtno fl.1;gl aql peurpou pw f:t e ualqord atoutooJ aqt alt8 ol paprmp 1 'Eur11asad,{t ,{tipnb q3!q Jo stredsu UPUoJ aoqs plnoqs alcruE slql aJurspw .salout@Jeql

unEe mm I tgl ,,xgJ Jo auoJlno eql qlra pegsrl?ssrp atntnc,, lnoqe a[rrup eql elola J ueq^.\ JO Suorsuelxe ',(le:rtuesaloupuaeq1arou8r pegdual o1 sr rapaelaql lql os 'quoJ pw {opq q3nas 01urudu sr lr 1eq1 'eu qlra $JEE u qrns Sursnlooq p peel Je^e llra lno,(u1 mq oqm auof:ala aunss I lng luaunmpalrlue eqlJo pua aqt :o :alduqc f:a^a Jo pue aql le uaql Eunuud '.a.r 'saloupueolur satoutooJ unl ol sr {Ilrqrssod Jeqtouv

srql

reqlo ,(w qlh

, suorldo:eqto fq ua11uruelo 1ou an s8uups sll tEqt arns aluu ol pwuuoJ aT,{lstueuncop\ aql ur uondo lm1 ,Oea eq1 m uorldo e1f1s srql esn ot lsaq sr lr 'saw3 lsou uI / ^ls . tq6rf,ulf ,{q pa8@r{J slDualul eql e8wqJ lou ssp qJrqa fy1 :o3 uorldo a1,(1s reqlaSot pesn aq lq8ru uoltdo al,(ts srqJ

uolldoaldlsaqlJoesneql

Z.I

'eldurs i(lSurqsruotsp sselequeteuaE eullnol lndlno y3.61 aqt ot sa8uuqoifuesseJeu eql ,q8noua,(lEulsudrns pw 'lno,{el leau e saleraua8srql {urql I .ile u! IIV n slducsadns w ueql 3ursrcr3o peelsur eurlawq aql tE esJeIJ?u atoulooJ aql aruld o1 paprop 'arouequnC I " FJ qtr^ pa:udard suorlecrlqndlsou ur pesn sr qcrqm a1u :otu:edasaloulooJ 3ql lluo plnoc auo ler{l pepr3apI ,ad,{t ralJuus ur setoulooJeqt Sunlas 'uoltlpp?ufpw'lxalpwseloulmJuaaataqacedsq8noua rog3urmo11y uunloc tq8r: aqt Jo uolloq eql le raqleEol

'{la:nus tnofel e qcns ul seloulooJpro^s ot lseq suas tr sllnsa: aq1;o auos p 3ur1m1 tnq ,a8ed aqlJo uoDoq eql eq ot suees saloulooJroJ erld [eJusu eql 'arnpoJ srql q1,46 aSed ews aql uo suunlor Jo slequnu tuereIrp uaampq Eurqclrasmoltu plnoa qcrqm suunloc:o; uqluoEp Surcuuluq Esa uoqdo e1,{1s srqlgo poB urpu eql'oslnoJJO 'aJedsalrqaJo sdu8patrsapun acnpordseloulm; uoqs acurslwseald fre^ I@l t.usmp llnser eql UIBAE lnq 'e8ud eql Jo uouoq eql l seloulmJ epra-a8pdpesn I 'IS] uoudo al{ls runloJ-rllnu oql uI 'ecuds;o slunow 1ua:agrpfdncm ,(aqtuaqn ,(lprcadsa 'saloulooJ ulpluoJ suunloJ qloq uaqa {sunlJ slml lr 1ng lueserdac saloutoo;ou,{1reau3rlqSr:1yueq lq8ru (uunlor qf,Ee repun ,(letendassaloutooJ eql Surrpld ..a.1) .au paraqloq sfemp XE'1;,I,(q ue{ul qceo:dde aq1 lno,{el runloc-tllnu E ur seloulmJ Jo tueuerptd rql

uollJnpoJluJ I

I66l

'0I lsn8nv

qreqlelllhtr {uBrc

*lnofel uunloJ-rlFru u ur seloulood

Iorluof, uolsra1 aldu4s g.

82

Basic Formattine Tools


version package discussed in the remainder of this chapter goes one step further by allowing you some elementary version control. The version package (by Stephen Bellantoni) defines environments and commands to provide some kind of version control with L A T E X . To use this facility you should issue, somewhere near the beginning of the document, commands to set up the version control tag environments, as follows:

The material bracketed inside a tagname environment has to be processed (typeset) by L A T E Xin a normal way.

The material bracketed inside a tagname environment must be ignored (not typeset) by P Q X . rag is a name chosen by the user. As many version control environments as needed can be defined in t h s way by the user. For example:
The answer is YES.
\includeversion~YES)\excludeversionCNO) The answer is \begin{NO)NO.\end{NO)% \begin{YES)YES.\end{YES>

The version package also defines a comment environment whose material, by default, is ignored. This behavior can, however, be redefined by issuing the
command\includeversion(comment).
AB A Ignored by default. B
A\begin{comment> \end{comment)B Normally ignored.

\includeversion(comment) A\begin{comment) Ignored by default \end{comment)B

C H A P T E R

The Layout of the Page

The text of a document usually occupies a rectangular area on the paper-the so-called body of the text. Above the body there is a running header and below the body a running footer. They can consist of one or more lines containing the page number; information about the current chapter, section, time, and date; and possibly other markers. The fields to the left and the right of the body are called the margins. Usually they are left blank, but small pieces of text, like remarks or annotations, so-called marginal notes, can appear there. The size, shape and position of these fields on the output medium (paper or screen) and the contents of the running headers and footers are called the page layout. In this chapter we will see how to specify different layouts. Often a single document requires several hfferent page layouts. For instance, the layout of the first page of a chapter, which carries the chapter title, is generally different from the other pages in that chapter. The standard L A T E X document classes allow document formatting for rectoverso (two-sided)printing. There exist some differences between the layouts for one- and two-sided printing. In the first case the margins on odd- and evennumbered pages are equal, while in the second case care should be taken that the texts on both sides of the paper overlap. Generally one talks about the inner and outer margins. For two-sided printing, inner means the left margin on odd-numbered pages and the right margin on even-numbered ones, while for one-sided printing, inner always indicates the left margin. In a book spread, odd-numbered pages are those on the right-hand side.

84

The Layout of the Page

4.1 Geometrical Dimensions of the Layout


(L163)
The dimensional parameters controlling the page layout are described below and are shown schematically in figure 4.1 on the next page. Height of the body (without header and footer). Width of the body. Width of space between columns of text in multicolumn mode. \columnseprule Width of a vertical line separating the two adjacent columns in multicolurnn output (default Opt, i.e., no visible rule). \columnwidth Width of single column in multicolumn mode. Calculated by K&X from \textwidth and \columnsep as appropriate. \linewidth Width of the current text line. Usually equals \columnwidth but might get different values in environments that change the margins. \evensidemargin For two-sided printing, the extra space added at the left of even-numbered pages. \oddsidemargin For two-sided printing, the extra space added at the left of odd-numbered pages, else the extra space added at the left of all pages. \f ootskip Vertical distance separating the baseline of the last line of text and the baseline of the footer. \headheight Height of the header. \headsep Vertical separation between header and body. \topmargin Extra vertical space added at the top of the header. \marginparpush Minimal vertical space between two successive marginal notes (not shown in the figure). \marginparsep Horizontal space between body and marginal notes. \marginparwidth Width of marginal notes.
\textheight \textwidth \columnsep

The default values for these parameters are presented in table 4.2 on page 87. In the W X Z E release two additional parameters describing the physical page are available:
\paperheight \paperwidth

Height of the paper to print on. Width of the paper to print on.

B y default these parameters are set to values corresponding to US-letter paper size in the four standard classes. Most of the other layout parameters in LATEXZE class files are specified in terms of the physical page size so that they automatically change when \paperwidth or \paperheight is modified at the beginning of the class file. Changing them in the preamble of your document does not have this effect, since by that time, the values for the other parameters are already calculated.

4.1 Geometrical Dimensions of the Layout

85

+-YI
1

Footer

I I I I I I

1 3 5 7 9 I1

one inch + \hoffset \oddsidemargin = 31pt \headheight = 12pt \textheight = 522pt \marginparsep = 7pt \footskip = 36pt \hoffset = Opt

4
6 8 10

one inch + \voffset \topmargin = 28pt \headsep = 20pt \textwidth = 348pt \marginparwidth = 71pt \marginparpush = 5pt (not shown) \voffset = Opt

Figure 4.1: The page layout for The BTEX Companion A picture similar to this can be produced by the command \layout, which is defined in the package file layout (by Kent McPherson). The real sizes are shown reduced by a factor of two.

86

The Layout of the Page

letterpaper legalpaper executivepaper a4paper a5paper b5paper

8112 x 8112 x 7114 x z 8114 x ~ 5 ' -7 x

11 14 10112 113/4 1 8114 ~ g7I8

inches inches inches inches inches ~ inches

210 x 297 148x210 176x250

mm rnrn rnm

Table 4.1: Standard paper-size options in w X 2 ~

To ease the adjustments necessary to print on different paper, the L A T E X & class files support a number of options that set those parameters to the physical size of the requested paper as well as adjusting the other parameters (like \textheight) that depend on them. The list of paper-size options supported by the standard classes is shown in table 4.1. Thus to print on A4 paper you can simply specify

Additional or different options may be available for other classes but there seems to be little point in providing, say, an aOpaper option for book that would produce incredibly wide text lines. Standard-conforming dvi-drivers place the reference point for TEX one-inch down and to the right of the upper left-hand corner of the paper. These oneinch offsets are called driver margins. The reference point can be shifted by redefining the lengths \hof f s e t and \vof f set. B y default their values are zero. In general, the values of these parameters should never be changed. They provide, however, a convenient way to shft the complete page image (body, header, footer, and marginal notes) on the output plane without disturbing the layout. The driver margins are inherited from TEX, and are not needed in L A T E X S ' parameterization of the page layout. A change to \topmargin shifts the complete text vertically, while changes to \oddsidemargin and \evensidemargin shift it horizontally. To simplify calculations, you can "subtract out" the driver margins by setting \hof f s e t and \vof f s e t to -lin, and consider the reference point to be at the upper left-hand corner of the paper. Note that some dvi-drivers introduce their own shfts in the placement of the text on paper. To make sure that the reference point is properly positioned, you can run the test file testpage. tex (by Leslie Lamport, with modifications by Stephen Gildea) through W&X and the dvi-dnver in question. The resulting output page will show the position of the reference point with respect to the edges of the paper. For I ~ T E X ~this E file was rewritten by Rainer Schopf to interactively support the standard paper size options.

4.2 Changing the Layout

87

lOpt
\columnseprule

lOpt

lOpt

Table 4.2: Default values for the page layout parameters (letterpaper) These values are identical for the three standard W X document classes (article, book, and report). If a different paper-size option is selected the values may change.

4.2 Changing the Layout


When you want to redefine the values of one or more of the page layout parameters, the \setlength or \addtolength commands should be used. Nevertheless, it is recommended that these parameters be changed only in a class or package file and/or in the document preamble. Initially, it is advisable to use TEX'S\baselineskip parameter for setting vertical distances. T b s parameter is the distance between the baselines of two consecutive lines of text set in the "normal" document type size inside a paragraph. \baselineskip may be considered to be the height of one line of text. Therefore, the following setting always means "two lines of text."
\normalsize \setlength{\headheight)C2\baselineskip)

% set normal \baselineskip % Height of heading

To guarantee that \baselineskip is set properly, first invoke \normalsize to select the type size corresponding to the document base size.

88

The Layout of the Page

Sometimes it is convenient to calculate the page layout parameters according to given typographic rules. For example, the requirement "the text should contain 50 lines" can be expressed using the command given below. It is assumed that the height of all (except one) lines is \baselineskip and the height of the top line of the text body is \topskip ( t h s is TEX'S\baselineskip length parameter for the first line with a default value of 10pt). Note that in the examples in this chapter the W X package calc (whch simplifies the calculational notation) and the extended control structures of m X 2 ~ are used (see appendix A, sections A.4 and A.5).

A requirement like "the height of the body should be 198mm" can be met in a similar way, and the calculation is shown below. First calculate the number of lines that the body of the desired size can contain. To evaluate the number of lines, you should divide one dimension by another to obtain the integer part. Yet, TEX is unable to perform this kind of operation directly, and therefore the dimensions are first assigned to counters. Note that the latter assignment takes place with a high precision since sp units are used internally.
\setlengthC\textheight)% % subtract top line (198mm-\topskip) % from desired size \newcounter(tempc) % 1st temporary counter \setcounterCtempc)(\textheight) % assign counter 1 \newcounter~tempcc) % 2nd temporary counter \setcounterCtempcc)~\baselineskip) % assign counter 2 \setcounter(tempc)% % divide counters C\valueCtempc3/\valueCtempcc)) \setlength~\textheight)C\baselineskip*\value~tempc)+\topskip)

The value of the vertical.distance, \topmargin, can also be customized. As an example, suppose you want to set this margin so that the space above the text body is two times smaller than the space below the text body. The following calculation shows how to determine the needed value in the case of A4-sized paper (the paper height is 297rnm).
\setlengthC\topmargin)% C(297mm-\textheight)/3

lin - \headheight -\headsep)

4.2.1 Page Layout Packages


Because the original W X class files are based on American page sizes, European users have developed several packages that adapt the page layout parameters for metric sizes. Examples of such packages are a4 (which generates rather

small pages), a4dutch (by Johannes Braams and Nico Poppelier), which is well documented, and a4wide (by Jean-Franqois Lamy), which produces somewhat longer lines. Often, there exist locally developed files under such names as well. For A5-sized pages one has the package files a5 and a5comb (by Mario Wolczko). Volker Kuhlmann, on the other hand, took another approach in his package vpage, where he provides commands to set the margins for all kinds of metric and American paper sizes. To use this package you must first select a paper size with \setpapersize [orient] (size), where size can be Af our, Bf ive, Usletter, and many more, whle the optional parameter orient specifies the orientation (portrait, the default, or landscape). You can even specify your own paper size if you want. The page margins are set with the command

or with

If you are using Uslegal paper, and you want all margins equal to 1 inch and no headers and footers, then you can say:

In general, when changing the page layout you should take into account some elementary rules of legibility (see, e.g., [75]). Studies of printed material in the English language have shown that a line should not contain more than ten to twelve words, which corresponds to not more than 60 to 70 characters per line. The number of lines on a page depends on the type size being used. The code below shows one way of calculating a \textheight that depends on the document base size (the internal IPQX variable \Optsize holds the number 0,I, or 2 for the base font sizes lOpt, 1lpt, and 12pt respectively).
\ifthenelse{\@ptsize = 01% 10-point typeface as base size {\setlengthC\textheight)C53\baselineskip~){) \ifthenelse(\@ptsize = 11% 11-point typeface as base size {\setlengthC\textheight)C46\baselineskip)){) \ifthenelseC\@ptsize = 2 ) % 12-point typeface as base size {\setlength~\textheight)C42\baselineskip~){) \addtolengthC\textheight)C\topskip)

Another important parameter is the amount of white space surrounding the text. As printed documents are likely to be bound, enough white space should

90

The Layout of the Page

be left in the inner margin of the text to allow for this. If \oddsidemargin is fixed, then the calculation of \evensidemargin for two-sided printing is based on the following relationship:
width-of-paper = (lin+\hoffset)*2+\oddsidemargin+\textwidth+\evensidemagin

Two-sided printing is turned onby specifying the twoside class option, which sets Boolean register Qtwoside to true. A calculation of the horizontal page layout parameters, showing how to take into account the document base size and one- or two-sided printing, is as follows:
\ifthenelseC\Qptsize = 01% 10-points typeface as base size ~\setlength(\textwidth)C5.00in}% \setlengthC\marginparwidth>Cl.OOin}% \ifthenelse~\boolean(Qtwoside}}% C\setlength~\oddsidemargin1{0.55in}% two-sided \setlengthC\evensidemargin}O.75in)%

1
C\setlength\oddsidemargin}CO.55in)% \setlengthC\evensidemargin}O.55in)%
one-sided

1C1
Similarly, when there are a lot of marginal notes in a document, it is worthwhile changing the layout to increase the margins. As an example, the a4dutch package defines a command \WideMargins. This macro modifies the geometrical parameters in such a way that the width reserved for marginal notes is set to 1.5 inches by decreasing the width of the text body.

4.2.2 Typesetting Pages in Landscape Mode


Usually one considers the longer side of the paper to be the vertical orientation (so-called portrait orientation). For some documents, such as slides or tables, it is better to use the other (landscape) orientation, where the longer side is horizontally oriented. Modern printers and dvi-drivers usually allow printing in both orientations. The landscape and portrait orientations require different page layouts. Although you should refrain from making changes to the geometrical page layout parameters after the \begin(document) command, it is still possible to change these parameters between pages. This facility is exploited by the package portland (by Hubert Partl) with commands for switching between portrait and landscape mode.

4.3 Page Styles

91

The first command (re)sets the page layout to the initial portrait orientation values (i.e., the values at \begindocument)). The second command sets the page layout so that the horizontal and vertical dimensions are interchanged with respect to their initial values. The total body area remains unchanged. Apart from changing the page layout, both commands issue a \clearpage, which terminates the current page and sets a few internal LATEX dimensions. This package also defines two environments, p o r t r a i t and landscape, which can be used instead of the above commands. The package file requires some customization in that you need to supply the height of the paper being used as the parameter \paperheight. The default is the height of A4 paper.' If you use a dvi-driver that allows mixing portrait and landscape modes in the same run (for example, dvips), it is worth adding the relevant \special commands just after the \clearpage commands to get the various pages printed correctly. If you only want to switch between landscape and portrait mode for the text, without affecting the running head and feet, then you can use David Carlisle's package Iscape, which also defines a landscape environment that rotates the pages in.its scope through 90 degrees. In this case, you might not have to worry about hiiving to enter the \special commands yourself, since this package uses Tomas Rolucki's rotate package and requires his dvi-driver dvips (see section 11.2).

4.3 Page Styles


While the dimensions remain the same for almost all pages of a document, the format of the running headers and footers (page style) may change in the course of a document. The page style is selected by two commands:

(L161)

The first command sets the page style of the current and succeeding pages to style; the second is similar, but for the current page only. WX's standard page styles are: Both the header and footer are empty. empty plain The header is empty and the footer contains the page number. headings The header contains information determined by the document class and the page number; the footer is empty. myheadings Similar to headings, but the header can be controlled by the user.
'Once this package is updated for k T ~ x 2 it ~ should be able to directly use the \paperheight and \paperwidth parameters supplied by the class files.

92

The Layout of the Pane The first two are used in the standard classes. Usually for the title page, a command \thispagestyleCempty) is issued. For the first page of major sectioning commands (like \part or \chapter, but also \maketitle) the standard L A T E X class files issue a \thispagestyle{ plai n) command. This means that when you specify a pagestyleCempty) command at the beginning of your document, you will still get page numbers on the page where a \chapter or \maketitle command is issued. To get the intended behavior, you must follow each such command with a thispagestyleCempty) command or redefine the plain style to empty, i.e., \let\ps@plain=\ps@empty. In small or medium-size documents sophisticated switching of page styles is not necessary. Usually the page style is selected in the document class. But for larger documents, such as books, you should take into account typographic tradition. For example, the front matter normally has roman page numbers while the body of the document carries arabic page numbers; parts and chapters should start on an (odd-numbered) right-hand page, and so on. The page number is controlled by the counter page.

T h s command resets the counter to 1and redefines the command \thepage to \style{page). Ready-to-usepage counter styles are: Alph, alph,Roman,roman, and arabic (see section A.1.3).

(L192)

Both of these commands terminate the current paragraph and page. In twosided printing \cleardoublepage also makes sure the next page is a right-hand (odd-numbered)one. As an example, the structure of this book, as far as page styles is concerned, is shown schematically in figure 4.2 on the facing page. Note the definition of the \clearemptydoublepage command, which generates a completely blank page, without any page markers, when needed.

4.3.1 Writing New Page Styles


The formatting commands associated with each style argument of the \pagestyle command are controlled by defining a corresponding macro \ps@style. These macros, in turn, define internal IJQX commands, which format the running headers and footers. \@oddhead For two-sided printing it generates the header for the oddnumbered pages, otherwise it generates the header for all pages. \@oddfoot For two-sided printing it generates the footer for the oddnumbered pages, otherwise it generates the footer for all pages.

4.3 Page Styles

93

\documentclass[ ...]{companion)

. ..

%%"/. class file sets the default page style

\newcommand~\clearemptydoublepage)C\newpe~\pagestyle~empty)\cleardoublepage~} \beginCdocument) 7 =================== Front matter ............................. \title{The \LaTeX{) companion) \author{. . . I \pagenumbering{romad % page numbers are roman digits % title page uses "empty" page style \maketitle \includeCchO) % copyright page uses "empty" page style \clearemptydoublepage \tableofcontents % the first page uses "empty" page style \clearemptydoublepage % go to odd numbered page y ..................... B ody of the document .................... \pagenumbering{arabic) % page numbers are arabic digits \include{chl) % first page uses "empty" page style \clearemptydoublepage % go to odd numbered page \include{ch2) \clearemptydoublepage % go to odd numbered page

.. . . ..

=================== Appendices

...............................

% special page style for index

Figure 4.2: Page styles used in The BTEX Companion

\@evenhead For two-sided printing it generates the header of the evennumbered pages. \@evenfoot For two-sided printing it generates the footer of the evennumbered pages. The d e h t i o n of the plain page style, producing only a centered page number in the footer, is equivalent to:

The usage of section titles in running headers or footers is certainly a problem. Sectioning commands allow the capture of (part of the) titles by involung the commands \chaptermark,\sectionmark,and so on. These commands can

94

The Layout of the Pane be defined to do nothing or to do proper formatting. For instance, in the book class these commands are defined (approximately)as follows:

In the case of a chapter, the word "Chapter" (or its equivalent in a given language, see table 9.2 on page 267 in section 9.2) followed by the sequence number of the chapter (stored in counter chapter) and the contents of (a short version of) the chapter title will be stored in \chaptermark. For a section, the section number (stored in the counter section) followed by the contents of (a short version of) the section title will be stored in \sect ionmark. Traditionally a running header or footer contains the most recent secondlevel title (e.g., section title) on the current page. Generally, you cannot simply save and enter sectioning titles into a running header or footer. Due to the asynchronous nature of TEX'Spage breaking algorithm, it is not possible to know beforehand which sectioning command will appear on the page just before the page break occurs. TEX solves this problem with its markers mechanism: the user puts markers inside the text and, before writing (shipping out) the current page to the .dvi Me, TEX'Soutput routine determines whch are the first and last markers on the current page.

(L161-2)

A T E X commands are for setting markers at a given point in the These two L text. The first command sets a pair of left and right markers. Usually this command is invoked immediately following a sectioning command. The second command also sets a pair of markers, but it only changes the right one, leaving the other untouched. This command is invoked immediately after a sectioning command.

These two commands contain the current settings for the left and right markers as defined by L A T E X S ' output routine from the various \markboth and \markright commands for the page being shipped out. \leftmark contains the lefr-head argument of the last \markboth command before the end of the page. \rightmark contains the right-head argument of the first \markright or \markboth on the page, if one exists; otherwise it contains the one most recently defined. The marking commands work reasonably well for right markers "numbered within" left markers (for example,when the left marker is changed by a \chapter command and the right marker is changed by a \section command). However,

4.3 Page Styles

95

marker pair \markbothCLI)C) \newpage% - - - -page \markrightCRI.l) \markbothCL2)CI \markrightCR2.1) \newpage% ----page \markright{R2.2) \markright(R2.3) \markright{R2.4) \newpage% - - - -page \markbothCL3){) \markright{R3.1) \newpage% - - - -page \newpage% - - - -page \markright{R3.2) \markboth{L4)C) \markboth(L5){) \newpage% - - - -page \markrightCR5.1) \endCdocument) CL1)C) break ---CL1)CRl.l) CL2)C) CL2)CR2.1) break --CL2)CR2.2) CL23CR2.3) CL2lCR2.4) break

printer markers left right L1

L2

Rl. I

---CL310 CL33CR3.1)

L2

R2.2

break break

------L3)CR3.2) CL4H) {L5)0

L3 L3

R3.1

break

---CL5)CR5.1)

L5 L5

R3.2 R5.1

Figure 4.3: Schematic overview of how WX's marker mechanism works

it produces somewhat anomalous results if a \markboth command is preceded by some other mark command on the same page-see the page receiving ~5 R 3 . 2 in Figure 4.3. This figure shows schematically which left and right markers are generated for the pages being shipped out. In the headings page style the sectioning commands set the page headers automatically by using \markboth and \markright, as shown in table 4.3 on the next page. The standard page style myheadings is similar to headings, but it allows the user to customize a header by defining the commands \markboth and \markright described above. It also provides a way to control capturing titles from other sectional units like table of contents, list of figures, and index. In fact the commands ( \ t a b l e o f c o n t e n t s , \ l i s t o f f i g u r e s , and \ l i s t o f t a b l e s ) and the environments ( t h e b i b l i o g r a p h y and t h e i n d e x ) use the \ c h a p t e r * command, which does not invoke \chaptermark, but issues a \Qmkboth command. The page style headings defines \Qmkboth as \markboth, while the page style myheadings defines \Qmkboth to do nothing and leaves the decision to the user.

96

The Layout of the Page

Printing style two-sided printing

Command

\markbotha \markr i g h t one-sided printing \markright a Specifies an empty right marker (see figure 4.3 on the precedmg page)

Document class book, r e ~ o r t I article \section \chapter \subsection \sect ion \section \chapter

Table 4.3: Page style defining commands in L A T E X

4.3.2

CustornizingPage Styleswithfancyheadings

The package fancyheadings (by Piet van Oostrum) allows easy custornization of page headers and footers. It provides the following functions: three-part headers and footers; rules in header and footer; headers and footers wider than \textwidth; multiline headers and footers; separate headers and footers for even and odd pages; separate headers and footers for chapter pages. To use t h s page style, a command \pagestyleCf ancy) must be given. The latter must be issued after any changes to \textwidth. The following commands supply the information for the six fields in the footer and the header for layout fancy as shown in figure 4.4 on the next page.
\lhead [LH-even] CLH-odd) \If oot [LF-even1CLF-odd) \chead [CH-even] CCH-odd) \cf oot [CF-even1C CF-odd) \rhead [RH-even] CRH-odd) \rf oot [RF-even1CRF-odd3

The information in the L-fields will be left adjusted, that in the C-fields centered, and that in the R-fields right adjusted. The thickness of the rules below the header and above the footer is controlled by the length parameters \headrulewidth (default 0.4pt) and \footrulewidth (default Opt). A thickness of Opt makes a rule invisible. More complicated changes are possible by redefimng the \headrule and/or \f ootrule commands. The headers and footers are typeset in a box of width \headwidth, which is by default set equal to the value of \textwidth. The box can be made wider (or narrower) by using the \setlength command to specify \headwidth. The headers and footers will stick out of the page on the same side as marginal notes. For example, to span marginal notes, add both \marginparsep and \marginparwidth to \headwidth (see figure 4.6 on page 99).

4.3 Page Stvles

97

'&Gv;nI I I I I I I

--------,r-------------CH-even RH-even I I LH-odd CH-odd


I I I I I

RH-odd

:
I I I I I

I I I Even page I I I I LF-even CF-even RF-even I L - - - - - - - - - - - - - J L - - - - - - - -

Odd page

I
I LF-odd - - - - - J

CF-odd

RF-odd

Figure 4.4: The page layout parameters for the fancyheadings package

Each of the six fields is set in an appropriate parbox, so you can use multi-line material with the \ \ command. Extra space can be added by \vspace commands. Note that in this case the lengths \headheight or \f ootskip will probably have to be increased. Some W&X commands, like \chapter,use a \thispagestyle command to automatically switch to the plain page style, thus overriding the page style currently in effect. To customize such pages use the fancyplain page style. This page style sets up fancy for normal pages and in addition redefines the page style plain to also use the page style fancy with the following modfications. The rules' thickness is defined by \plainheadrulewidthand \plainfootrulewidth, whch both default to Opt. The six fields can be defined separately for plain and normal pages by using the \fancyplain command:

T h s command can be used inside both the optional and mandatory arguments of the \ . .head and \ . .foot commands defined above. For example,

shows the specification for the left header field \lhead in a two-sided document. In this case, F1 is the specification for an even-numbered plain page; F2 for an even-numbered normal page; F3 for an odd-numbered plain page; and F4 for an odd-numbered normal page. The default settings for the parameters are the following:
\headrulewidth \plainheadrulewidth 0.4pt Opt \footrulewidth \plainfootrulewidth Opt Opt

98

The Layout of the Page

I I I I I I I

\rightmark

-------------

\leftmark 1 r \le f tmark - - I I I I I I I I I I I I I I I

- -

-\;igh;m;rk

1
I I I I I I I I

Even page

Odd page

\thepage

\thepage

L - - - - - - - - - - - - - J

L - - - _ _ - - - - - - - - - - J

Figure 4.5: The default page layout with the fancyheadings package

The default layout is a slanted running header and a footer containing the page number:

Plain output pages have an empty head and carry only the page number in the center of the footer, while normal pages have a centered page number in the footer and markers in the header, as shown in figure 4.5. To illustrate the more advanced possibilities of the fancyheadings package, you can consider a layout that has two lines containing the section and the subsection titles in the lower right-hand corner of the page. In this case, you should specify something like:
\documentclass~book) \usepackage{fancyheadings) \pagestyleCfancy) \renewcommandC\sectionmark)[I] C\markbothC#l>C)) \renewcommandC\subsectionmark~~11C\markright~#l~~ \rfootC\leftmark\\\rightmark) ..... % further preamble commands \beginCdocument)

As a final example, figure 4.6 on the facing page shows the definitions for a page style similar to the one used by Leslie Larnport for his LATEX book.

4.4

Visual Formatting

99

\documentclass{book) \usepackageCfancyheadings) \pagestyleCfancyplain) \addtolengthC\headwidth)C\marginparsep) \addtolengthC\headwidth){\marginparwidth) % remember chapter title \renewcommandC\chaptermark) [I]% {\markboth{#l)C)) % section number and title \renewcommand{\sectionmark) [I] % {\markright{\thesection\

l.IHortollr*IIWw

1.1

HOW

to Read T ~ I S ~wlt

me bTLX wrrmulolaih.m.'pOndiii pssm by mmdu.nlthh

many cx,s,,n8,001~.nd hh hhdddaiU1-+. Iho~n8h ,O m Ihrmlmclmlb *n.r,,,mtmgLTrX i n k f n n r r r a t ~ l U r R X p m y M w d i o ~ d uullt,ar,nrhlptsorr,w~,""~,IIII~"Ihl~,w~hhh.hhhhhhrhrIp~,s~~ L.T.X. r o l l o m i d . d md m*,mnnmlr b: con,""c,al m I b , Ihr m m l m orromluvnplr run k ! M r . In! uuln Th BlbBX blbliopphy mil M*d"d.. lndiilnginollu..lwrdlwvord mr lhld dvrnkr L ~ T ~ T N~~ * F ~ =,-On , L~- INFSS lihnni md bow crrrr Ihc .ddlrlon oCmw ionis to thr m r c We I Mm p"troIsrDawnallrr PollSolpl,rnllcnr bud m s d a n m l Inih.pcrrfrorurl"m~~a~,~",,~"t~,hh,nrlunaio<Enupl",Ud~~~ &lo ,wo md how r h g cnn k mm,puln,d (dd.rnUd.,drn, W l l h

**,p
C W r r 6"s .area m o r a i r w of I K m y wIc m o o film. w h ~ h rr srulohb I m u u v l l h b T ~ X .Th mltopllau.rr lmpdby m b l a I d l o n n s nnr.o.l~lhrod.rorLun~~~smgII.i.ix.iborL Chlplers~z d a n k Ulr &mSLTcXcrmllonr. . v d * l e w u m . l h u n u

"'""."""""*'""'"'"'"'"'"""""""&.,'".
F l " !

\lhead[\fancyplain{){\bfseries\thepage)]% (\fancyplainC){\bfseries\rightmark)) \rhead[\fancyplain{){\bfseries\leftmark)]% C\fancyplain{)C\bfseries\thepage)) \cf ootC1

In~~~cruvmrr~~mour~am~~on~o~oc~~~~~nnlnlnlnlnlnlnlnypDN~fL1T~X. thr b o b , * T u r n i s -4 m drvi, N.", ur loo* I . d.r.loprr"l. I . . Imgu.p=vring mslppndla non.lslinmpu.I~X. V V Z ~ C Rurnm.Gmk L md ~ T*nb ~ row X I&

I ~ ~ , . ~ ~ ~ , ~ ~ , ~ ~ ~ ~
m,-,

wllh.ilrupnl.mnmnjmmmnnd.or.,llhlrwhmur,"glhrnyleoe,m"damW inlhlr y l d . mapof *is w MIL help t o e m ~h LTIX~ whlh


~vr~npm -M rn m .hqtcr ld s lo 0 tb ?A cd80m ur en,rru, or T " In ~ ~ f .w Ih ~h,. ~mchom CZ-II~ of , Ih an ~ h . ~ ~ h ~ sty,e Id ~ hc~ , ,h P " , . . , " ",our pt.ofIh.,rlul. ll lr our lnlrnilon lo Who. c ~ , o n a a d c d c the k . e W uonhhwe Dlm $0 have a LmLaI I(U Cn$crn*Is~f LTiX. mdrhow how s m f f p n d i . w h o d - n a r ~ ~ a s u l l y b v o l a b a T c X pum.mn v&ddmd,b

*I

-,

nin~n$n).I~oe~on~uld~md~clo~sra nr m x lp ol nn rr~y

Figure 4.6: Running header/footer settings for the W X book

4.4 Visual Formatting


As mentioned in the introduction, the final stage of an important production often needs some hand-formatting to avoid some bad page breaks. For this A T E X offers you the \pagebreak, \nopagebreak, \newpage purpose standard L and \clearpage commands as well as the \samepage declaration, although the latter is considered obsolete in IF&XZE. (With the \samepage declaration together with a suitable number of \nobreak commands you can request that a certain portion of your document should be kept together. Unfortunately, the results are often not satisfactory; in particular, IPQX will never make a page larger than its nominal height (\textheight) but rather moves everythmg in the A T E X Z Ecommand scope of the \samepage declaration to the next page. The L \enlargethispage* described below offers you an alternative here.) It is common in book production to "run" a certain number of pages (normally double spreads) short or long to avoid bad page breaks later on. T h s means that the nominal height of the pages is reduced or enlarged by a certain offers amount, for example, a \baselineskip. To Support t h s practice, LATEXZ~ the command

(L90,190)

If, for example, you want to enlarge or reduce the size of some pages by one additional line of text, you would define

100

The Layout of the Page

and use those commands between two paragraphs on the pages in q u e s t i ~ n . ~ \enlargethispage enlarges the \textheight for the current page but otherwise does not change the formatting parameters. Thus, if \flushbottom is in force the text will fill the \textheight for the page in question, if necessary by enlarging or shrinking vertical space within the page. This way, the above definitions add or remove exactly one line of text from a page while keeping the positions of the other lines. This is important to give a uniform appearance.

The companion command \enlargethispage* also enlarges or reduces the page height, but this time the resulting final page will be squeezed as much as possible (i.e., depending on the available whte space on the page). This can be helpful if you wish to keep a certain portion of your document together on one page, even if it makes the page slightly too long. (Otherwise,just use the minipage environment.) The trick is to request a large enough amount of extra space and then place an explicit page break where you want the page break to happen, e.g.:
\enlargethispage*ClOOcm) \begidcenter) \beginCtabular){1111)

% absurd r e q u e s t % s l i g h t l y too long % tabular % f o r c e d page break

.. . .
\endCtabular) \end(center) \pagebreak

From the description above it is clear that both commands should be used only in the final part of the production, since any later alterations in the document (adding or removing a single word, if you are unlucky) can make your hand-formatting obsolete-resulting in ugly-looking pages.

2 ~ uto e the many examples in this book, we had to use this trick a few times to avoid half-empty pages. For example, the double spread on pages 70-71 is enlarged by one \baselineskip.

CHAPTER

Tabular Material
Data is often most efficiently presented in tabular form. TEXuses powerful primitives for arranging material in rows and columns. Since, however, they only implement a low-level, formatting-oriented functionality, several macro packages have been developed that build upon those primitives to provide a higher-level command language and a more user-friendly interface. A T E X ,tables are most conveniently constructed with the t a b u l a r or array In L environments, although in some cases the tabbing environment might prove useful. After a short look at the tabbing environment, the extensions to UTEX'Sbasic t a b u l a r and array environments provided by the array package are described. The latter package offers an increased functionality, especially in the area of a more flexible positioning of paragraph material, a better control of inter-column and inter-row spacing, and the possibility of defining new preamble specifiers. Combining the strengths of the array and tabularx packages, you will be able to construct complex tables in a simple way. The next sections deal with the problem of multipage tables. Two environments, supertabular and longtable, d l split a table automatically when a page is full, or when the user instructs W X to go to a new page. The following sections deal with packages that can be used in combination with those already described. In particular: delarray automatically calculates the height of delimiters around tabular material, dcolumn makes it easy to align numbers on the decimal separator, and hhline specifies the way horizontal or vertical rules interact. The final section gives some practical advice and shows a series of interesting complex examples typeset with the tools described in this chapter.

102

Tabular Material
Mathematically oriented readers should consult the chapter on advanced mathematics, especially section 8.5, which discusses the alignment structures for equations, and study the examples starting on page 244. And for those of you having access to a Postscript output device, many more possibilities for manipulating tabular material are available (see section 11.4.1).

5.1 Comparing the t a b b i n g and t a b u l a r Environments


W X has two families of environments that allow material to be lined up in
columns-namely, the tabbing environment, and the t a b u l a r and array environments. The main differences between the two kinds of environment are: The tabbing environment is not as general as the t a b u l a r environment. It can only be typeset as a separate paragraph, whde a t a b u l a r can be placed anywhere in the text or inside mathematics. The tabbing environment can be broken between pages, while the standard t a b u l a r environment cannot. With the tabbing environment the user must specify the position of each tab A T E X can automatically stop explicitly, while for the t a b u l a r environment L determine the width of the columns. It is simpler to change the typesetting of the material inside a tabbing environment, so that it is somewhat easier to typeset computer programs this way. tabbing environments cannot be nested, while t a b u l a r environments can, thus allowing complex alignments to be realized. Sometimes it is convenient to put one or more t a b u l a r O r tabbing environments inside a floating element (see chapter 6) like a t a b l e environment. This is useful if you want to keep tabular material together and to allow text to flow around that material. Be careful, however, not to confuse the t a b u l a r and t a b l e environments, since the former allows material to be aligned in columns, while the latter is a logical document element identifying its contents as belonging together and allowing it to be floated jointly. In particular, one t a b l e environment can contain several t a b u l a r environments. Tabular material that is longer than one page can be typeset with the longtable or supertabular environments, described in section 5.4.

5.2 Using the tabbing Environment


(L62-3,179-82) This section deals with some of the lesser known features of the tabbing environment. First it must be realized that formatting is under the complete control

5.2 Using the tabbing Environment

103

of the user. Somewhat unexpectedly, when moving to a given tab stop, you will always end up at the exact horizontal position where it was defined, independently of where the current point is. This means that the current point can move backwards and overwrite previous text. Be aware that the usual L A T E X commands for making accents-\', \ ' and \=-are redefined inside the tabbing environment. The accents are available by typing \ a J , \ a c and \a= instead. The \- command, which normally signals a possible hyphenation point, is also redefined, but this is not important since the lines in a tabbing environment are never broken. The scope of commands in rows is usually limited to the region between tab stops. A style parameter \tabbinpep, used together with the \ ' command, allows text to be typeset at a given distance flush right from the previous tab stop. Its default value is set equal to \labelsep, which in turn is usually 5pt. There exist a few common ways to define tab stops: using a line to be typeset, or explicitly specifying the skip to the next tab stop. The next example shows a wrong choice for the pattern on the first line, since the first column on the second line is longer than the one specified. The last line redefines the tab position and shows the different uses of the backquote.
confused embrouille confused mind esprit trouble \begidtabbing1 confusiondeconfiture \textbfCconfused) \= embrouill\aJe \= conjecturehypothPse Greek)
\em confused mind \= esprit trouble \kill \textbfCconfused) \> embrouill\a' e \> \em confused mind\> esprit trouble \ \ \textbfCconfusion)\> d\aleconfiture \\[3mm] \textbfCconjecture)\=hypoth\acese \ ' (from Greek)\ \ \endCtabbing)

The tabbing environment is most useful for aligning information into columns whose width is constant and known. The following is from table A.l on page 449.
pc Pica = 12pt cc Cicero = 12dd cm Centimeter = lOmm
u

\newcommandC\Rivpt)C\ruleC.4pt)C4pt)) \beginCt abbing) dd\quad \= \hspace{.55\linewidth) \= \kill pc \> Pica = 12pt \> \makebox[lpc]C\Rivpt\hrulefill\Rivpt~ \\ cc \> Cicero = 12dd \> \makebox[lcc]C\Rivpt\hrulefill\Rivpt~ \\ cm \> Centimeter = 10mm \> \makebox[lcmlC\Rivpt\hrulefill\Rivpt) \ \ \endCtabbing)

104

Tabular Material

5.2.1

The program Environment

The program package file (by Martin Ward) is a complex example of what can be done with a tabbing environment. It can help you typeset computer program sections, and is especially optimized for Pascal code. The package defines the program and programbox environments, and commands for keywords and emphasized (bold) letters. The latter commands, which are used to represent program fragments, have one argument that produces a subscript index. Inside a program environment newlines are significant. Each line is in math mode, hence spaces in the input file are not significant. A \ \ command causes a line break in the output. The programbox environment typesets a program in a L A T E X box. This is useful for keeping a piece of code on one page or for typesetting small programs in running text. Below is a complete Pascal program. It is an example of the notation used for procedures and functions. Note the \mbox command for introducing text in the output and the \rcomment command for generating flush right comments.
\beginCprogrambox) \mboxCA fast exponentiation procedure:) A fast exponentiation procedure: \BEGIN % becin for \FOR i:=l \TO 10 \STEP 1 \DO i : = l ~ l O ~ l & lexpt l(2,i); \ \ Inewline 1 0 \OD ~XPO i);, newline() & \WHERE \rcommentC~comment flush to the right margin) A comment flush to the right margin \PROC 1 expt I (x ,n) \BODY where procexpt(z,n) = z:=I; z := 1; \DO \IF n=O \THEN \EXIT \FI; do if n = 0 then exit fi; -do if odd(n) then exit fi; -\DO \IF 1 odd 1 (n) \THEN \EXIT \FI ; n := n/2; x := x + x od; n:=n/2; x:=x*x \OD; n:=n-1; z:=ztx&, n:=n-1; z:=z*x \OD; print(.). Iprint l (2) \ENDPROC end \END \endCprogrambox)

5.3 array-Extending the t abular Environments


In general, when tables of any degree of complexity are required, it is usually easier to consider the tabular-like environments defined by W X . These environments align material horizontally in rows and vertically in columns.
\beginCarray) [pas] Ccols) rows \end(array) \beginCtabular) [pas] {cols) rows \end{tabular) \beginCtabular*)Cwidth) [pos] (~01s) rows \end{tabular*)

5.3 array-Extending the tabular Environments

105

Centered adjusted column. Right adjusted column.

Table 5.1: The preamble options in the array package

Over the years several extensions have been made to the tabular environment family, as described in the W X book. The remaining part of this chapter will explore the added functionality of the array package (developed by Frank Mittelbach, with contributions from David Carlisle). Table 5.1 shows the various options possible in the cols preamble declaration of the environments in the tabular family.

(1 63-5,182-5)

5.3.1 Examples of Preamble Commands


If you would like to use a special font, such as \bfseries in a flushed left column, you can write >C\bf s e r i e s l l . You no longer have to start every entry of the column with \bf series.

106

Tabular Material

Notice the use of the \extrarowheight declaration in the second example below. It adds a vertical space of 4pt above each r0w.l

The difference between the three paragraph building options p (the paragraph box is aligned at the top), m (the paragraph box is aligned in the center), and b (the paragraph box is aligned at the bottom) is shown schematically in the following examples.

In columns, which have been generated with p, m, or b, the default value of \parindent is Opt. This can be changed with the \setlength command, for instance: >C\setlength{\parindent)Cicm)Cp( ...I.
'1n fact the effect of \extrarowheight will only be visible if the sum of its value, added to the. product \baselineskipx\arraystretch (see section 5.3.2), is larger than the actual height of the cell, or more precisely, in the case of m orb, the height of the first row of the cell.

5.3 array-Extending the tabular Environments

107

The < option was originally developed for the following application:
>C$lc<C$) generates a column in math mode in a tabular environment. The use of thls type of preamble in an array environment results in a column in LR

mode because the additional $3cancel the existing $3.


\setlength{\extrarowheight)C2pt) \ [ \beginCarraylCI1 1 >C$ll<{$l I > \hline lo!-{lo!) & a big number \\ 10-C-999) & a small number \ \ \hline \endCarray) \I

There is an important difference between rQ(\hspace{5mm))l and r ! C\hspaceC5mm)ll. In the former case the inter-column space is exactly equal to 5mm. In the latter case a space of 5mm is added to the inter-column space (\arraycolsepor \tabcolsep depending on the environment used).

p E q I-zEiEzq p E q piiEiEq

\beginCtabular){rQ{\hspaceC5mm))l) \fboxCLEFT BOX) & \fboxCRIGHT BOX) \end{t abular) \par \vspace{\baselineskip) \par \beginCtabular)Cr ! C\hspace{5m))l) \fboxCLEFT BOX) & \fboxCRIGHT BOX) \endCtabular)

Variable Width Vertical Rules Variable width vertical rules can also be constructed with the help of a ! Cdecl) declaration and the basic TEX command \vrule with a width argument. This command is used since it automatically fills the height of the column, whereas for LARX's \rule command an explicit height must be specified.
\beginCtabular>CIc!C\vrule width 3pt)clcl) \hline A & B & C \ \ \hline 100 & 10 & 1 \\ \hline \endCtabular)

108
Typesetting Narrow Columns

Tabular Material

When you have a narrow column, you must not only make sure that the first word can be hyphenated (see page 65) but that short texts are also easier to typeset in ragged right mode (without being aligned at the right margin). This is obtained by preceding the material with a \raggedright command (see section 3.1.4). Since this environment redefines the line-breaking command \\, we must store the row-ending \\ command of the tabular or array environments. Therefore, we define the command \PreserveBackslash, which will reset the \\ command to its correct value.

As shown in the example below, we can now typeset material inside a tabular environment ragged right, ragged left, or centered and still have control of the line breaks. W e also show that the first word is now, indeed, hyphenated correctly, although in the case of Dutch, we helped TEX a little by choosing the possible hyphenation points ourselves. Note also the hyphenation of the accented French word "PossibilitPs," while the second French word "esperances" is not hyphenated. The reason is that in the first case the hyphenation point lies before the accent, while in the latter case it falls after.
Superconciousness is a long word Ragged left text in column one Possibil- Mogelijkheden en ites et esperances hoop Centered text in column two Ragged right text in column three
\let\PBS=\PreserveBackslash %shorthand \beginCtabular)% {I>{\PB~\raggedleft\hspace<Opt>~pC14m~% I >{\PBS\centering\hspace{Opt))p{l4m)% I >C\~~S\ra~~edri~ht\hspace~Opt))pC14mm> I) \hline & Superconciousness is a long word Possibilit\'es et esp\'erances & Moge\-lijk\-heden en hoop \\ \hline & Ragged left text in column one Centered text in column two & Ragged right text in column three \\ \hline \endCtabular)

Controlling the Horizontal Separation between Columns

The way the tabular environment handles the width of columns, the separation between column separators and column contents, and the various rules will be studied using a series of examples. When there are no vertical rules, the use of @ I ) specifiers will eliminate the horizontal space between columns. The table content is of the form:
\begin{tabular)C BOXES & BOXES \end{tabular)

...)
\\

%"/."/."/."/."? <----

Part which varies BOXES & BOXES \\

5.3 array-Extending the t a b u l a r Environments

109

The varying t a b u l a r preamble is shown at the right in each case.


BOXES BOXES BOXES BOXES BOXES BOXES BOXES BOXES

BOXESBOXES BOXESBOXES

When there are vertical bars, you can control the space both in front and following the vertical column separator. To show the behavior induced by the presence of horizontal rules, the latter have also been added in the following example.
\beginCtabular)C
BOXES & BOXES BOXES & BOXES \end{tabular)

. . . I %".%%"%%% <---- Part which varies


\\ \\
\hline \hline \hline

Adding one more degree of complexity, the following series of examples shows how the t a b u l a r environment treats double rules.
\begin(tabular)C ...I %"/."/."/."/."A <---- Part which varies \hline\hline BOXES & BOXES \ \ \hline\hline BOXES & BOXES \ \ \hline\hline \end(tabular)

BOXES BOXES

-pE

11

BOXE

110

Tabular Material

In general, when you want to eliminate all spacing between columns, it is more straightforward to redefine the \arraycolsep and \tabcolsep lengths. Moreover, the last example shows a misuse of the 0C. . . 3 qualifier, since to control the width between the double vertical (and at the same time horizontal) bars, the \doublerulesep parameter should be redefined.

5.3.2 Style Parameters (L185)


The visual appearance of the tabular-like environments can be controlled by various style parameters. These parameters can be changed using the \setlength or \addtolength commands anywhere in the document. Their scope can be general or local. In the latter case the scope should be explicitly delimited by braces or another environment.
\arraycolsep Half the width of the horizontal space between columns in an array environment (default value 5pt). \tabcolsep Half the width of the horizontal space between columns in a tabular environment (default value 6pt). \arrayrulewidth The width of the vertical rule that separates columns (if a I is specified in the environment preamble) or by the rules created by \hline, \cline, or \vline (default value 0.4pt). When using the array package, this

width is taken into account when calculating the width of the table (standard WQX sets the rules in such a way that they do not affect the final width of the table). \doublerulesep The width of the space between lines created by two successive I I characters in the environment preamble, or by two successive \hline commands (default value 2pt). \arraystretch Fraction with which the normal inter-row space is multiplied, for example a value of 1.5 would move the rows 50%further apart. This is set with \renewcommand (default value 1.0).

5.3 array-Extending the tabular Environments


\extrarowheight Extra parameter introduced in the array package. Its value

111

is added to the normal height of every row of the table while the depth remains the same. This is important for tables with horizontal lines because it is often necessary to fine-tune the distance between those lines and the contents of the table (default value Opt). Environment TabularC below shows how these style parameters are used to generate a table with a given number of equal-width columns and a total width for the table equal to \linewidth. Use is made of the calc package, hscussed in section A.4. W e also use the command \PreserveBackslash,defined on page 108. Our environment, TabularC, takes the number of columns as its argument. This number, let us call it x, is used to calculate the actual width of each column by subtracting two x times the column separation and (x + 1)times the width of the rules from the width of the line. The remaining distance is divided by x to obtain the length of a single column. The contents of the column are centered, the \ \ command is restored, and hyphenation of the first word is allowed.

Applying this definition gives the following result:


Material in column one Column one again Once more column one column two
and column two column two

This is column three This is column three Last time column three

\beginTabularC){B> \hline Material in column one & column two & This is column three \ \ \hline Column one again & and column two & This is column three \ \ \hline Once more column one & column two & Last time column three \\ \hline \end{TabularC)

It is equally simple to construct environments for other column configurations. If you feel a little uncomfortable with all these commands and parameters,

112

Tabular Material
then you canuse the t a b u l a r x environment, which makes this sort of calculation for you. (See section 5.3.5 and table 5.2 on page 116 for a comparison.)

5.3.3 Defining New Column Specifiers


If you have a one-off column in a table, then it is handy to be able to type:
>{some declarations)c<{some more deck3

Yet it becomes rather verbose if you often use columns of this form. Therefore, for repetitive use of a given type of column specifier, the following command has been defined to specify a new type of column:

I \newcolumntypeCcol) Cnargl (decl) I


Here, col is a one-letter specifier to identify the new type of column inside a preamble, narg is an optional parameter, giving the number of arguments t h s specifier takes, and decl are legal declarations, for example:
\newcolumntype(x)(>(some

declarations)c<Csome more decls))

The newly defined x column specifier can then be used in the preamble arguments of all a r r a y or t a b u l a r environments in which one needs columns of this form. Quite often you may need math-mode and LR-mode columns inside a t a b u l a r or a r r a y environment. Thus, you can define:

From now on you can use C to get centered LR-mode in an array, or centered math-mode in a tabular. Note that \newcolumntype takes the same first optional argument as \newcommand, which declares the number of arguments of the column specifier being defined. However, the current implementation does not support the extended syntax of \newcommand introduced in LATEX~E. A rather different use of the \newcolumntype command takes advantage of the fact that the replacement text in \newcolumntype may refer to more than one column. Suppose that a document contains a lot of t a b u l a r environments that require the same preamble, and you wish to experiment with different preambles. You can define:

5.3 arrav-Extending the t a b u l a r Environments

113

The replacement text in a \newcolumntype command can be any of the primitives of array, or any new letter defined in another \newcolumntype command. To display a list of all currently active \newcolumntype definitions on the terminal use the \showcols command in the preamble.

5.3.4 Some Peculiarities of the array Implementation


Error messages generated when parsing the column specification refer to the preamble argument after it has been rewritten by the \newcolumntype system, not to the preamble entered by the user. The use of \ e x t r a c o l s e p is subjected to the restrictions that there can be at most one \ e x t r a c o l s e p command per Q or ! expression and the command must be directly entered into the Q expression, not as part of a macro definition. Thus \newcommand(\ef )(\extracolsepC\f ill)) ... QC\ef 3 does not workwith this package, but \newcolumntype~e)~QC\extracolsep(\f ill)) could be used instead.

5.3.5 tabu larx-Automatic Calculation of the Column Widths


The package tabularx (by David Carlisle) implements a version of the t a b u l a r * environment in which the widths of certain columns are calculated automatically depending on the total width of the table. The columns, whose widths are automatically calculated, are denoted in the preamble by the X qualifier. The latter column specification will be converted to pCsome value) once the correct column width has been calculated. The next table, which contains the titles of Shakespeare's comedies, has I X I X I X I). been declared with \begin(tabularx)(IOOmm)C
The Two Gentlemen of Verona Love's Labour's Lost The Merry Wives of Windsor Twelfth Night All's Well That Ends Well Cymbeline The Taming of the Shrew A Midsummer Night's Dream Much Ado About Nothing Troilus and Cressida Pericles Prince of T~re The Tempest The Comedy of Errors The Merchant of Venice As You Like It Measure for Measure The Winter's Tale

114

Tabular Material
Changing the declaration to \begin{tabularx){\linewidth)C will produce the following table layout:
The Two Gentlemen of Verona Love's Labour's Lost The Merry Wives of Windsor Twelfth Night All's Well That Ends Well Cymbeline The Taming of the Shrew A Midsummer Night's Dream Much Ado About Nothing Troilus and Cressida Pericles Prince of Tyre The Tempest

I XI X 1 X 1 )

The Comedy of Errors The Merchant of Venice As You Like It Measure for Measure The Winter's Tale

Commands Used to Typeset the X Columns


B y default the X specificationis turned into pCsome value). Such narrow columns often require a special format, which may be achieved using the > syntax. Thus you may give a specification like >{\small)X. Another format which is useA T E X S ' \raggedright macro ful in narrow columns is ragged right. However, L redefines \\ in a way that conflicts with its use in a tabular or array environment (see also the discussion of the command \PreserveBackslash on page 108). For this reason, the command \arraybackslash is defined in the tabularx package. It may be used after a \raggedright, \raggedleft, or \centering declaration. The result is that a tabularx preamble may specify >{\raggedright\arraybackslash)X. This specification is saved with: \newcolumntype{Y){>(\small\raggedright\araybackslash>X). You may then use Y as a tabularx preamble argument. The X columns are set using the p column, which corresponds to \parbox Ctl . You may want to set the columns with, for example, an m column corresponding to \parbox Ccl . It is impossible to change the column type using the > syntax, so another system is provided. The command \tabularxcolumn can be defined as a macro, with one argument, which expands to the tabular preamble specification to be used for X henceforth. The supplied argument when the command is executed determines the actual column width. The default definition is \newcommand(\tabularxcol~ [I] CpC#1)3. A possible alternative definition is

Column Widths
Normally, all X columns in a single table are set to the same width. It is nevertheless possible to make tabularx set them to different widths. A preamble like
{>{\setlength{\hsize)C

.5\hsize))X>{\setlength{\hsize>{1.

5\hsize))x>

5.3 array-Extending the t a b u l a r Environments

11 5

specifies two columns; the second will be three times as wide as the first. However, when using this method the following two rules should be obeyed: The sum of the widths of all X columns should remain unchanged. In the above example, the new widths should add up to that of two standard X columns.
\multicolumn entries that cross any X column should not be used.

Superconciousness Mogelijkheden en hoop is a long word Some text in col- A somewhat longer text in column two umn one

\tracingtabularx \begin{tabularx)C\linewidth)% {I>C\setlengthC\hsize)C.8\hsize}lXI% >C\setlengthC\hsize)C1.2\hsize~}XI} Superconciousness is a long word & Moge\-lijk\-heden en hoop \\ Some text in column one & A somewhat longer text in column two \\ \end{tabularx)

Differences between tabularx and tabular* Both the tabular* (standard W X ) and the tabularx environments take the same arguments, to produce a table of a specified width. The main differences are:
tabularx modifies the widths of the columns, whereas tabular* modifies

the widths of the inter-column spaces.


t a b u l a r and tabular* environments may be nested with no restriction. However, if one tabularx environment occurs inside another, then the inner one must be enclosed within C 3.

The body of the tabularx environment is, in fact, the argument to a command, and there are certain restrictions: the commands \verb and \verb* may be used, but they may treat spaces incorrectly, and the argument cannot contain a % or an unmatched C or 3.
tabular* uses a primitive capability of TEXto modify the inter-column space of an alignment. tabularx has to set the table several times as it searches

for the best column widths, and is therefore much slower. Also, the fact that the body is expanded several times may break certain T E X constructs. Table 5.2 on the following page shows a comparison of the tabularx environment with the TabularC environment described in section 5.3.2.

116

Tabular Material

\beginCTabularC)C4) Material in column one This is column three Material in column one This is column three Once more column one column three \end{TabularC)

& & again & & & &

column two column four and column two column four column two \hfill column four

\beginCtabularx~C\linewidthl{IXIXIXlXll . . . . . same contents . . .

\newcolumntype~Y~~>~\centering\arraybackslash)X)% \beginCtabularx)~\linewidth)CIYlYIYIYI) . . . . same contents . . .

. .

Material in column one Material in column one again Once more column one Material in column one Material in column one again Once more column one Material in column one Material in column one again Once more column one

column two and column two column two column two and column two column two column two and column two column two

This is column three This is column three column three This is column three This is column three column three This is column three This is column three column three

column four column four column four column four column four column four column four column four column four

Table 5.2: Comparing the TabularC and t a b u l a r x environments As seen above, the TabularC and the t a b u l a r x environments can both do the job of typesetting the layout you want. David Carlisle, the author of the t a b u l a r x package, remarks nevertheless, "If the user is happy with doing TEX arithmetic, then in a situation where the column width can be pre-calculated, the TabularC method is much better as it avoids the problem of multiple expansion (which is used in the tabularx package). t a b u l a r x is mainly of benefit when some of the columns are ' c J type columns, so that the width of the 'p' columns cannot be pre-calculated, as they depend on the table entries."

5.3 array-Extending the t a b u l a r Environments

117

Tracing the Output on the Terminal

If this declaration is made, say in the document preamble, then all following
t a b u l a r x environments will print information about column widths as they

repeatedly reset the tables to find the correct widths. For instance, in the case of the last example we got the following output.
Target width: \linewidth = 204.0pt. X Columns Column Width Table Width 3 433.19998pt 204.0pt 2 89.40001pt 203.99998pt Reached target.

5.3.6 delarray-Specifying Delimiters Surrounding an Array


A useful extension to the array package when dealing with delimiters can be found in the package file delarray C b y David Carlisle). It lets the user specify the delimiters, which must surround the whole environment by providing implicit \ l e f t \ r i g h t pairs around the a r r a y construct.

Any delimiter may surround the preamble. Plain TEX or AMS-TEX users may recognize the following environments (see also sections 8.4.1 and 8.4.2):

x, 1x1 =

ifx10;

\[

1x1 = \begin{Cases) x,& if $x\geO$; \\[2mml -x,& otherwise. \\ \endCCases)

-x, otherwise.

\I

118

Tabular Material

x-h
a=
0

x-h
0

0 1

\[

x-h
\I

a = {\begin{Matrix) x-\lambda & 1 & 0 \ \ 0 & x-\lambda & I \ \ 0 & 0 & x-\lambda \ \ \end{Matrix)
>-2.

This feature is especially useful if the Ctl or C b l arguments are also used. In these cases the result is not equivalent to surrounding the environment by \ l e f t . . .\right, as can be seen by comparing the following examples:

5.4 Multipage Tabular Material


With Leslie Lamport's original implementation, a tabular environment must always fit on one page. If the tabular becomes too large the text overwrites the page's bottom margin, and you get an Overfull \vbox message.

5.4 Multipage Tabular Material

119

Two package files are available to construct tables longer than one page,
su pertab and longtable. They have a similar functionality, but, for an elementary

use, the former's commands are perhaps more intuitive. If you want, however, to have a finer control on the width of the table, then the latter package has to be used. The next sections will review each of them in turn, and finally show, using a more complex example, the difference between the two approaches.

5.4.1 su pe rtab-Making Multipage Tabulars


The package supertab (original by Theo Jurriens, revised by Johannes Braams) defines the environment supertabular. It uses the t a b u l a r environment internally, but it evaluates the used space every time it encounters a \ \ command. If the tabular reaches the value of \textheight it automatically inserts an \end{tabular) command, starts a new page, and inserts the table head on the new page continuing the tabular. This means that the width of the columns, and hence the complete table, can vary on consecutive pages. The new commands introduced with supertabular are: defines the contents of the tabular head, except the first when \tablef i r s t h e a d is defined. The argument can contain full rows (ended by \\) as well as inter-row material like \hline. \tablef irsthead{. . . I defines the contents of the first occurrence of the tabular head. This command, which is optional, should be used when the head text on the first page is different from the one specified with
\tablehead{. \tablehead. \tabletail{.

. .3

. .) . .)

\tablelasttail{.

\topcaption{. . .) \bottomcaption{. . .) \tablecaption{. . .)

defines material to be inserted at the end of each page, but the last if \ t a b l e l a s t t a i l is defined. defines material to be inserted at the end of the supertabular. This command, whch is optional, should be used when the tail text on the last page is different from the one specified with \ t a b l e t a i l . provides a caption for the \supertabular, either at the top or at the,bottom of the table. When \tablecaption is used the caption wdl be placed at the default location, whch is at the top.

Inside a supertabular environment new lines are defined as usual by \\ commands. All column definition commands can be used, including @{ . . .3 and PC. . .3. You can, however, not use the optional positioning arguments, like t and b, which can be specified with \begin{tabular) or \begin{tabular*).

120

Tabular Material

Table 1: Surats of the Holy Koran The Opening The Family Of lmran The ~ o o d The Elevated Places Repentance Hud The Thunder The Rock The Israelites Marium The Prophets The Believers The Criterion The Ant The Sptder Luqman The Allies The Originator The Rangers The Companies HaMim The Embellishment The Kneeling Muhammad The Chambers The Scatterers The Star The Beneficient The Iron The Banishment 002 O M 006 008 010 012 014 016 018 020 022 024 026 028 030 032 034 036 038 040 042 044 046 048 050 052 054 056 058 060 TheCow Women Thecattle The Spoils Of War Yunus Yusuf Ibrahim TheBee Thecave TaHa The Pilgrimage The Light The Poets The Narrative TheRomans The Adoration Saba Ya Seen Suad The Believer The Counsel The Evident Smoke The Sandhills The Victory Qaf The Mountain TheMoon The Great Event The Pleading One The Examined One

061 063 065 067 069 071 073 075 077 079 081 083 085 087 089 091 093 095 097 099 101 103 105 107 109 111 113

TheRanks The Hypocrites The Divorce The Kingdom The Sure Calamity Nuh The Wrapped Up The Resurrection The Emissaries Those Who Pull Out The Covering Up The Defrauders The Mansions Of The Stars The Most High The Daybreak TheSun The Early Hours The Fig The Majesty The Shaking The Ternble Calamity lime The Elephant The Daily Necessaries The Unbelievers Thename TheDawn

062 064 066 068 070 072 074 076 078 080 082 084 086 088 090 092 094 096 098 1W I02 I04 106 108 110 112 114

Friday Lass And Gain The Prohibition The Pen The Ways Of Ascent The Jinn The Clothed One The Man The Great Event He Frowned The Cleaving Asunder The Bursting Asunder The Night-Comer The Overwhelming Calamity The City The Night The Expansion The Clot The Clear Evidence The Assaulten The MultiplicationOf Wealth And Children The Slanderer The Qureaish The Heavenly Fountain The Help The Unity TheMen

Table 5.3: The Surats of the Holy Koran (supertabular) Example of the supertabular Environment The first example (table 5.3) has a simple layout, and building the multipage table is easy in t h s case. Note the change of the width of the table between the first and second pages (left- and right-hand side of picture). The commands used to obtain the given layout are shown below.
\tablecaption{Surats of the Holy Koran) \tablehead{\hline) \tabletailC\hline) \beginCsupertabular)CIcllcll) 001 & The Opening & 002 & The Cow 003 & The Family Of Imran & 004 & Women

....
113 & The Dawn \end{supertabular)
& 114 & The Men

\\ \\
\\

Example of the supertabular* Environment The width of a supertabular can be fixed to a given width, such as the width of the text, \textwidth, as in table 5.4 on the facing page. Compared to table 5.3

5.4 Multipage Tabular Material

121

Table I: Surats of the Holy Koran 001 003 005 007 The Opening The Famtly Of lmran The Food The Elevated Places Repentance Hud The Thunder TheRock The Israelites Marium The Prophets The Believers The Criterion The Ant The Spider Luqman The Allies The Originator The Rangers The Companies HaMim The Embellishment The Kneeling Muhammad The Chambers The Scaneren The Star The Beneficient W2 The Cow W4 Women 006 The Cattle 008 The Spoils Of War 010 Yunus 012 Yusuf 014 Ibrahim 016 The Bee 01 8 The Cave 020 TaHa 022 The Pilgrimage 024 The Light 026 The Pwts 028 The Namtive 030 The Romans 032 The Adoration 034 Saba 036 Ya Seen 038 Suad 040 The Believer 042 The Counsel 044 The Evident Smoke 046 The Sandhills 048 The Victory 050 Qaf 052 The Mountain 054 The Moon

continuedfmm previous page

N b . a n d n a m e o f S u r a t 057 The Iron Nb. and name of Surat


059 061 063 065 067 069 071 073 075 077 079 081 083 085 087 089 091 093 095 097 099 101 103 105 107 109 111

Nb. and name of Surat


The Banishment TheRanks The Hypocrites The Divorce The Kingdom The Sure Calamity Nuh The Wrapped Up The Resurrection The Emissaries Those Who Pull Out The Covering Up The Defrauders The Mansions Of The Stars The Most High The Daybreak The Sun The Early Hours The Fng The Majesty The Shaking The Terrible Calamity lime The Elephant The Daily Necessaries The Unbelievers Thename

009
011 013 015 017 019 021 023 025 027 029 031 033 035 037 039 041 043 045 047 049 051 053 055

Nb. and name of Surat 058 The Pleading One 060 The Examined One 062 Friday 064 Loss And Gain 066 The Prohibition 068 The Pen 070 The Ways Of Ascent 072 The Jinn 074 The Clothed One 076 The Man 078 The Great Event 080 He Frowned 082 The Cleaving Asunder 084 The Bunting Asunder 086 The Night-Comer 088 The OverwhelmingCalamity 090 The City 092 The Night 094 The Expansion 096 The Clot 098 The Clear Evidence 100 The Assaulters 102 The MultiplicationOf Wealth And Children 104 The Slanderer 106 The Qureaish 108 The Heavenly Fountain 110TheHelp 112 The Unity 114The~en-

I
I

Table 5.4: The Surats of the Holy Koran (supertabular*)

information has also been added at the top and bottom of each page, and a rubber (stretch) space has been introduced between the two last columns. Note the different spacings between these columns on the first (left) and second (right) page. In this case, the commands to obtain the given layout are the following:
\tablecaption{Surats of the Holy Koran) \tablefirsthead{\hline \multicolumn{2){Il!){Nb. and name of Surat) & \multicolumn{2)~1I}{Nb. and name of Surat)\\\hline) \tablehead{\hline \multicolumn~4){IlI)% {\small\slshape continued from previous page)\\ \hline \multicolumn{2){I11)CNb. and name of Surat) & \multicolumn{2){1I){Nb. and name of Surat) \ \ \hline) \tabletail{\hline\multicolumn{4){~r~)% {\small\slshape continued on next page)\\\hline) \tablelasttail{\hline) \begin{supertabular*){\textwidth)% {Icl@{\hspace*{2mm}\extracolsep{\fill~~~c@~\extracolsep~lmm))1~~ 001 & The Opening & 002 & The Cow \\ & 004 & Women \\ 003 & The Family Of Imran

. .. .

113 & The Dawn

& 114 & The Men

\\

122

Tabular Material Known Problems

When a float occurs on the same page as the start of a supertabular, unexpected results can occur. When the float is defined on the same page, you might end up with the first part of the supertabular on a page of its own. When the list of unprocessed floats is not empty it will be made empty by the first part of the supertabular (if the latter is split across pages) because it calls \clearpage. The supertabular environment should not be used inside a floating environment such as table as this will result in TEX trying to put the whole supertabular on one page. Sometimes you might shll end up with overfull \vbox messages. These cases are described in the (documented version of the) package file.

5.4.2 longtable-Sophisticated Multipage Tabulars


As pointed out at the beginning of this section, for more complex long tables, where you want to control the width of the table across page boundaries, the package longtable (by David Carlisle) should be considered. As with the supertabular environment, it also shares some features with the table environment. In particular it uses the same counter, table, and has a similar \caption command. The \listoftables command lists tables produced by either the table or longtable environments. The main difference between the supertabular and longtable environments is that the latter saves the information about the width of each longtable environment in the auxiliary .aux file, and uses this information on a subsequent run to know the widest width needed for the table in question. Thus it can construct the table with the adequate width. ,This feature has to be activated with the \setlongtables command. Note, however, that when one more longtable environment is added in the middle of a previous sequence, all subsequent tables will have the wrong width because the information read will be for the wrong table (the numbering will be one unit off). Problems also happen when, for one of the tables, the widest entry is shortened. As longtable always saves the widest width needed for a given table, it will never be able to reduce the size in the .aux file, so the table will always come out too wide. The only possibility in this case A T E Xwithout the command \setlongtables to get is to rerun your file through L rid of the wrong values in the .aux files, and then to run W X twice more with \setlongtables to get the correct values. Since longtable uses WX's pagebreaking algorithm, the page breaks will not be affected by the precise width of the columns in the longtable fragments. Therefore, you should not worry about the fact that the table fragments have different widths, and should not use the \setlongtables command unless your document is ready and you want to print a final version.

5.4 Multipage Tabular Material

123

Surats of the Holy Koran The Opening The Family Of Inuan TheFwd The Elevated Places W9 Repentance 011 Hud 013 TheThunder 015 TheRock 017 The Israelites 019 Marium 021 The Prophets 023 The Believers 025 The Criterion 027 The Ant 029 The Spider 031 Luqman 033 The Allies 035 The Originator 037 The Rangen 039 The Companies 041 HaMim 043 The Embellishment 045 The Kneeling 047 Muhammad 049 Thechambers 05 1 The Scatterers 053 The Star 055 The Beneficient 057 Thelmn 001 003 005 007 002 Thecow 004 Women 006 The Cattle 008 The Spoils Of War 010 Yunus 012 Yusuf 014 Ibrahim 016 The Bee 018 TheCave 020 TaHa 022 The Pilgrimage 024 The Light 026 The Poets 028 TheNarrative 030 TheRomans 032 The Adoration 034 Saba 036 Ya Seen 038 Suad 040 The Believer 042 The Counsel 044 The Evident Smoke 046 The Sandhills 048 The Victory 050 Qaf 052 The Mountain 054 The M w n 056 The Great Event 058 The Pleading One

Surats of the Holy Koran The Banishment The Ranks 063 The Hypocrites 065 The Divorce 067 The Kingdom 069 The Sure Calamity 07 1 Nuh 073 The Wrapped Up 075 The Resurrection The Emissaries Those Who Pull Out The Covering Up The Defrauden The Mansions Of The Stars The Most High The Daybreak The Sun The Early Houn The Fig The Majesty The Shaking The Terrible Calamity Time The Elephant The Daily Necessaries 109 The Unbelievers The Flame The Dawn

060 062 064 066 068 070 072 074 076 078 080 082 084 086 088 090 092 094 096 098
100

102 104 106 108 110 112 114

The Examined One Friday Loss And Gain The Prohibition The Pen The Ways Of Ascent TheRnn The Clothed One TheMan The Great Event He Frowned The Cleaving Asunder The Bunting Asunder The Night-Comer The Overwhelming Calamity TheCity TheNight The Expansion The Clot The Clear Evidence The Assaulten The Multiplication Of Wealth And Children The Slanderer The Qureaish The Heavenly Fountain The Help The Unity The Men

Table 5.5: The Surats of the Holy Koran (longtable)

In order to make the difference clear, the first example given with supertabular (table 5.3 on page 120) is repeated here, but using longtable (table 5.5). Since, in this case, we have activated the \setlongtables command, you can see that the width of the table is identical on both pages (the left and right parts of the picture). The commands that were utilized to generate the table are shown below.
\setlongtables \begin~longtable3lcllcll3 \caption*CSurats of the Holy Koran) \hline \endhead \hline \endf oot & 002 & The Cow 001 & The Opening

\\

.. ..

\\ \\

113 & The Dawn \endClongtable)

& 114 & The Men

The commands controlling the global formatting of the longtable environment are grouped in table 5.6 on the next page. The longtable environment will never break a row in the middle (this is

Tabular Material Parameters (default values are shown in parentheses) ( \ f i l l ) Glue to the left of the table. ( \ f i l l ) Glue to the right of the table. (\bigskipamount) Glue before the table. (\bigskipamount) Glue after the table. (20) Number of rows per chunk (TEXcounter). (4in) Width of parbox containing the caption. Setlongtables Use column widths from the previous run. \setlongtables Optional arguments to \beginClongtable) Position as specified by \LTlef t and \LTright, usually none center. Ccl Center the table. Place the table flush left. 111 Place the table flush right. C r l Commands available inside longtable Rows appearing at top of every page. \endhead \endfirsthead Rows appearing at top of first page. \endf oot Rows appearing at bottom of every page. Rows appearing at bottom of last page. \endlastf oot Row is "killed" (not typeset), but it is used in calculating \kill the widths. Caption "Table xx foo," with a "foo" entry in the list of \captionCfoo) tables. Caption "Table xx foo," with a "bar" entry in the list of \caption [burl Cfoo) tables. Caption "Table xx foo," with no entry in the list of \caption [I (foe) tables. Caption "foo," with no entry in the list of tables. \caption*Cfoo) \newpage Forces a page break. Table 5.6: A summary of longtable commands important for paragraph cells with p, m, and b specifiers). You can use footnotes and \newpage commands inside the l o n g t a b l e environment. Table 5.6 gives an overview of the various parameters and commands controlling the l o n g t a b l e environment. For instance, the commands \endhead and \endfirsthead specify the text to appear on top of the table sections on all pages and on the first page (compare this with the commands \tablehead and \ t a b l e f i r s t h e a d for the supertabular environment described in section 5.4.11, while the commands \endf oot and \ e n d l a s t f o o t specify what is to appear at

\LTlef t \LTright \LTpre \LTpost \LTchunksize \LTcapwidth

5.4 Multivane Tabular Material

125

the bottom of the table sections (compare with the supertabular commands \tabletail and \tablelasttail). W e shall now discuss some of the other parameters and commands.

In order that TEX can set multipage tables, it is necessary to break them up into smaller chunks so that TEX does not have to keep everything in memory at one time. B y default longtable uses a value of 20 rows per chunk. This can be changed with a command such as \setcounter(LTchunksize~(10~. These chunks do not affect page breaking. When T E X has a lot of memory available \LTchunksize can be put to a big number, making TEX run faster. Note that \LTchunksize must be at least as large as the number of rows in each of the head or foot sections.

When the \setlongtables command is given before a table starts, WQX uses the information about the width of the table collected in a previous run. As already stated in the discussion above, this command should only be used when your document is complete and only cosmetic changes remain.

I \caption [short title1 (full title3 I


The \caption command and its variant \caption* are essentially equivalent to writing a special \multicolumn entry

where n is the number of columns of the table. The width of the caption can be controlled by redefining the parameter \LTcapwidth. That is, you can write \setlength\LTcapwidth3Cwidth) in the document preamble. The default value is 4in. As with the \caption command in the figure and table environments, the optional argument specifies the text to appear in the list of tables if this is different from the text to appear in the caption. When captions on later pages should be different from those on the first page, place the \caption command with the full text in the first heading, and put a subsidiary caption using \caption [ 1 in the main heading, since (in t h s case) no entry is made in the list of tables. Alternatively, if the table number should not be repeated each time, you can use the \caption* command. As with the table environment, cross-referencing the table in the text is possible with the \label command.

126

Tabular Material
B y default, longtable centers the tables (for example, \LTleft and \LTright are both \fill). Any length can be specified for these two parameters, but at least one of them should be a rubber length so that it fills up the width of the page, unless rubber lengths are added between the columns using the \extracolsep command. For instance, a table can be set flush left using the definitions:

or just by specifying \begin{longtable) [l]. You can use the \LTleft and \LTright parameters also to typeset a multipage table filling the full width of the page; for instance, the equivalent to

similar to the code discussed on page 121 for table 5.4 is

In general if \LTleft and \LTright are fixed lengths, the table will be set to the width of
\textwidth

\LTleft

LTright

5.4.3 A Final Comparison


Table 5.7 on the next page shows the result of typesetting a multipage table spread over three pages (page boundaries are schematically represented by the thin lines). The differences between the supertabular and longtable environments can clearly be seen. Using identical input data, you can see that the top line, corresponding to supertabular,typesets the contents on a page by page basis resulting in a varying width for the table sections. The longtable environment, on the other hand, uses the widest entry in the table to give the complete table the same width across page boundaries. Another difference is that the pages generated by supertabular tend to be shorter than the "standard" pages of the document. This is due to the fact that supertabular uses its own pagebrealung algorithm. longtable uses WX's standard page-breaking, so that in this case there is no variation in the length of the page. As a user you must decide whether the little increased complexity of longtable is important for presenting your data. Table 5.8 on page 128 shows that the table declarations are, in both cases, quite similar.

Tableg: Codes of the languagesof Me world (supembular)

mde aa am ay
ba hh bo ca cy da el es fa fo ga

sn ha
hu

Languagesmdes(ISO639:1988) language mde language mde language Afar ab Abkhazlan a Afnkaans Amharic ar Arabic ae Assamese Aymara az Azerbaijani Bashldr be Byelorussian hg Bulgarian Bihari hi Bislama bn Bengali; Bangla Tibetan hr Breton Catalan co Corsican cs Czeeh Welch Danish de German a% Bhutani Greek en English eo Esperanto Spanish et Estonian eu Basque Persian fi Finn~sh fj F~ji Faeroese fr FreMh fy Fnsian Irish gd SmtsGaelic gl Galician Guarani gu Gujarat~ Hausa hi Hindi hr Cmatian Hungarian hy Armenian continuedonMctt page

m t i n u e d f m previouspage code language code language code language ia lntedlngua ie Intedlngue ik lnupiak in Indonesian ia lcelandlc it Itallan iw Hebrew ja Japanese ji Ylddish jw Javanese ka Georgian kk Kazakh kl Greeniandic h Cambodian kn Kannada ko Korean ka Kashmiri ku Kurdish ky Kirghiz la Latin In Lingala lo Laothian It Lithuanian lv Latvian, Leliish mp Malagasy mi Maori mk Macedonian m l Maiayalam mn Mongolian mo Moldavian mr Marathi ma Malay mt Maltese my Burmese na Nauru ne Nepali nl Dutch no Nomegian oc Oantan om (A1an)Ommo or Ohya I W S Punjabi p1 Polish ps Pashto, Pushto pt Portuguese uu Qu&ua mlinuedon nextpage

wntinuw'lmmpreviws page mde language mde rm Rhaeto-Romance rn N Russtan nr sa Sanskrit ad ah SeWCroatian si sl Slovenlan am BO Somali su BB Siswati st sv Swedish sw ta th tl tr tw uk Tamil Thai Tagalog TuMsh TWI Ukrainian te ti tn ts

language Kirundl Kinyamanda Sindhi Singhalese Samoan Albanian Sesotho Swahili Tegulu Tigrinya Satswana Tsonga

code language ro Romanian ~g sk an sr su tg tk to tt Sangm Slovak Shona Setilan Sudanese Tajik Turkmen Tonga Tatar

ur Urdu vo Volapuk

uz Uzbk

vi Wetnamese rro Wolof xh Xhosa yo Yomba zh Chinese

zu Zulu

Table 10: Cadesdthelanguages ofthe world (longtable)

mde aa am ay
ba hh bo ca cy da el es

language Afar Amhatic Aymara Bashldr Bihari Tibetan Catalan Welch Danish Greek Spanish

Lquagemdes (1% 639:1988) mde language mde language ab Abkhazian a Afnkaans ar Amble as Assamese az Aze~aijani
be hi hr co

wnlinuw'lmmpreviouspage code language mde language iw Hebrew ja Japanese ji Yiddish ka h ks la lt


mp
mr my

mde language jw Javanese kl Greenlandic ko Korean ky Mrghiz lo Laothian Macedonian mo Moldavian mt Maltese
mk

Byelo~ussian hg Bulgarian Bislama bn Bengall; Bangla Breton Conican cs Clech dz Bhutani eo Esperanto eu Basque fj Fiji fy Frisian g1 Galiaan hr Cmatian ik lnupiak it Itallan wntinuedon nextpage

ae German en English et Estonian fi Finnish fr French

na

no

Georgian Cambodian Kashmlri Latin Lithuanian Malagasy Maiayalam Marathi Burmese Nauru Nomegian

h k h Kannada Kurdish Lingala Latvian, Lettish mi Maon Mongolian ma Malay kk km ku In lv ne Nepali om (Alan) Ommo pl Polish

mtinuedlrompreviowpags code language code sl Slovenian sm so Somall sq ss Siswati st sv Swedish sw ta th tl tr tw uk Tamil That Tagalog Turkish Twi Ukrainian te ti tn ts

language Samoan Albanian Sesotho Swahlli Tegulu lgnnya Setswana Tsonga

mde sn sr su

language Shona Setiian Sudanese Tajik Turkmen Tonga Tatar

tg tk to tt

ur Urdu
vo Volaplk

uz Uzbek

nl Dutch or Oriya ps Pashto, Pushto

vi Vietnamese rro Wolol xh Xhosa


yo

fa Persian fo F a e m ga Irish g n Guarani ha Hausa hu Hungarian ia Interlingua in Indonesian

pa smts Gaelic
gu Gularati

oc Ocdtan pa Punjabi pt Portuguese


qu Quechua

Yoruba zh Chinese

zu Zulu

hi hy ie is

Hindi Armenian lnterlingue Icelandic

rm RhaetoRomance rn Kiwndi ru Russian rw Mnyamanda aa Sanskrit sh S e b C m t i a n ad Sindhi ai Singhalese

ro Romanian sg Sangm ek Slovak wntinued on nexipage

128

Tabular Material

Declaration for the supertabular case


\tablefirsthead{\hline \multicolumn{6){lcl){Languages codes (IS0 639:1988))\\ code & language & code & language & code & language \\\hline> \tablehead{\hline \multicolumn{6){I1I~C\small\slshape continued from previous page) \\\hline code & language & code & language & code & language \\\hline) \tabletail~\hline\multicolumn{6~{~r~){\small\slshapecontinued on next page) \\\hline) \tablelasttail{\hline) \topcaption{Codes of the languages of the world (supertabular)) \begidcenter) \begin{supertabular)II*{3){cl)I) \ttfamily aa & Afar & \ttfamily ab & Abkhazian & ............ \ttfamily zh & Chinese & \ttfamily zu & Zulu
&

&

\\

Declaration for the longtable case


\setlongtables \begin{longtable) [ c l C I* { 3 ) { c l ) I) \caption{Codes of the languages of the world (longtable)) \ \ \hline \multicolumn~6){lcl){Language codes (IS0 639:1988)) \\ \ \ \hline code & language & code & language & code & language \endfirsthead \hline \multicolumn{6){~1~){\small\slshape continued from previous page) \ \ \hline \ \ \hline code & language & code & language & code & language \endhead \ \ \hline \hline\multicolumn~6~{Irl){\small\sl continued on next page) \endfoot \hline \endlastfoot \ttfamily aa & Afar & \ttfamily ab & Abkhazian & ............

........................................................................
\ttfamily zu & Zulu
&
&

\ttfamily zh & Chinese & \end{longtable)

\\

Table 5.8: A comparison of the table declarations for longtable and supertabular

5.5 Bells and Whistles

129

5.5 Bells and Whistles


Two further package files, working nicely together with the environments described earlier, are introduced in this section. The first makes it easier to align decimal numbers inside a column, while the other introduces a larger choice for the possible combinations of vertical and horizontal lines inside tabular-like environments.

5.5.1 dcol u mn-Defining Column Alignments


The package file dcolumn (by David Carlisle) proposes a system for defining columns of entries in array or tabular, which are to be aligned on a "decimal point." Entries with no decimal part, no integer part, and blank entries are also dealt with correctly. The package defines a "Decimal" column specifier, D, with three arguments.
DCinputsep)Coutputsep)Cdecimal places) inputsep A single character, used as separator in the .t e x file (for example, " ." or ,' ,'7. n the output. It can be the same as the outputsep The separator to t)e used i: first argument, but may b cz any math-mode expression, such as \cdot. decimal places The maximunI number of decimal places in the column. If t h s is negative, any number of decimal places is allowed in the column, and all entries will be centered on the separator. Note that this can cause a column to be too wide (see the first two columns in the example below).

If you do not want to use all three entries in the preamble, you can customize the preamble specifiers using \newcolumntype as demonstrated below.

The newly defined "d" specifier takes a single argument specifying the number of decimal places. The decimal separator in the .tex input file is the normal dot " . ", while the output file uses the math mode ".".

In this case the "." specifier has no arguments; the normal dot is used in both input and output, and the typeset entries should be centered on the dot.

The " ," specifier defined here uses the comma " ," as a decimal separator

130

Tabular Material

in both input and output, and the typeset column should have (at most) two decimal places after the comma. These definitions are used in the following example, where it can be noted that the first column, with its negative value for decimal places (signaling that the decimal point should be in the center of the column)is wider than the second column, although they both contain the same input material.
I

(L182)

The following is a variant of an example in the W X book.


GG&A Hoofed Stock
\newcolumntypeC+)~DC/)C\mboxC--~~~4~> % Separator will be a / and , \beginCtabular)CIrl I+lpC2cm)l,I) \hline \multicolumn~4)CIcl)CGG\&A Hoofed Stock) \\ \hline\hline & \multicolumnC1~Ccl)CPrice)& & \ \ \clineC2-2) \multicolumnC1)~Icl l ) C Y e a r ) & \mbox~low)/\mbox~high)

Year 1971

Price low-high 97-245

II
72 245-245

I
I

I 731

II
245-2001

Comments Bad year for farmers in the West. Light trading due to a heavy winter. No gnus was very good gnus this year.

I
I

Other 23,45

435,23

& \multicolumnC1~CcI~CComments~ & \multicolumnC1)CcI)COther) \\ \hline 1971 & 97/245 &Bad year for farmers in \\ \hline the West. & 23,45

72 &245/245 &Light trading due to a heavy winter. & 435,23\\ \hline 73 &245/2001 &No gnus was very good gnus this year. & 387,56\\ \hline \end(tabular)

5.5.2 hhl i ne-Combining Horizontal and Vertical Lines


The hhline package file (by David Carlisle) introduces the command \hhline, whlch behaves like \hline except for its interaction with vertical lines.

The declaration decl consists of a list of tokens with the following meanings:

5 . 6 Applications
=

131

"

A double \hline the width of a column. A single \hline the width of a column. A column without \hline,i.e., a space the width of a column.

I
:

A \vline that "cuts" through a double (or single) \hline. A \vline that is broken by a double \hline.
A double \hline segment between two \vlines. The top rule of a double \hline segment. The bottom rule of a double \hline segment.
*3)==#) expands to ==#==#==#, as in the

t b

* form for the preamble.

If a double \vline is specified ( I I or : :1, then the \hlines produced by \hhline are broken. To obtain the effect of an \hline "cutting through" the double \vline,use a #. The tokens t and b can be used between two vertical rules. For instance,

I t b I produces the same lines as #, but is much less efficient. The main use for these are to make constructions like It : (top left corner) and :b l (bottom right corner). If \hhline is used to make a single \hline,then the argument should only contain the tokens "-", """, and " I " (and * expressions). An example using most of these features is:
\setlengthC\arrayrulewidth)C.8pt) \beginCtabular)Cl IccI Iclcl I) \hhlineCIt:==:t:==:tl) a & b & c & d \ \ \hhlineCI:==:l-I-Ill 1 & 2 & 3 & 4 \ \ \hhlineC#==#-I=#) i & j & k & 1 \ \ \hhlineCII--11--113 w & x & y & z \ \ \hhlineCIb:==:b:==:bl) \endCt abular)

The lines produced by \hline consist of a single (TEXprimitive) \hrule. The lines produced by \hhline are made up of lots of small line segments. TEX will place these very accurately in the .dvi file, but the dvi driver used to view or print the output might not line up the segments exactly. If this effect causes a problem you can try increasing \arrayrulewidth to reduce the effect.

5.6 Applications
The following examples involve somewhat more comp1.e~ placement requirements, allowing advanced functions such as the provision of nested tables. Here, we will put to work many of the features described in this chapter.

132

Tabular Material

5.6.1 Hyphenation in Narrow Columns


T E X does not hyphenate the first word in a paragraph, so very narrow cells can produce overflows. This is corrected by starting the text with \hspace{Opt). Char\fbox{\parbox{llmm)CCharacteristics~ \fbox.[\parbox{11mm)% {\hspaceCOpt)Characteristics))

5.6.2 Footnotes in Tabular Material


As already stated in section 3.4.1 footnotes appearing inside tabular material are not typeset by standard L A T E X . Only the t a b u l a r x and l o n g t a b l e environments, discussed earlier, will treat footnotes correctly. As you generally want your "table notes" to appear just below the table, you will have to tackle the problem yourself by managing the note marks and by, for instance, using \multicolumn commands at the bottom of your t a b u l a r environment to contain your table notes. You can also put your t a b u l a r or a r r a y environment inside a minipage environment, since in that case footnotes are typeset just following that environment. Note the redefinition of \ t h e f o o t n o t e that allows us to make use of the \f ootnotemark command inside the minipage environment. Without this redefinition \f ootnotemark would have generated a footnote mark in the style of the footnotes for the main page, as explained in section 3.4.1.
Postscript type 1 fonts

Couriera Charterb NimbusC URW AntiquaC URW GroteskC Utopiad

cour, courb, courbi, couri bchb, bchbi, bchr, bchri unmr, unmrs uaqrrc ugqp putb, putbi, putr, putri

aDonated by IBM. b~onated by Bitstream. CDonatedby URW GmbH. d~onated by Adobe.

\renewcommand(\thefootnote)C\thempfootnote) \begin{tabular)(ll) \multicolumn~2){c)C\bfseries Postscript type 1 fonts) \\ Courier\f ootnoteCDonated by IBM. 3 & cour, courb, courbi, couri \\ Charter\footnote(Donated by Bitstream.) & bchb, bchbi, bchr, bchri \\ Nimbus\footnote{Donated by URW GmbH.) & unmr, unmrs \\ URW Antiqua\footnotemark[\value~mpfootnote~l & uaqrrc \\ URW Grotesk\footnotemark[\value~pfootnote~l & ugP \\ Utopia\f ootnote{Donated by Adobe. 1 & putb, putbi, putr, putri

5.6 Avvlications

133

Of course this approach does not automatically limit the width of the footnotes to the width of the table, so a little iteration with the minipage width argument might be necessary. Another way to typeset table notes is with the package threeparttable by Donald Arseneau. This package has the advantage that it indicates unambiguously that you are dealing withnotes inside tables and, moreover, it gives you full control of the actual reference marks and offers the possibility of having a caption for your tabular material. In this sense, the threeparttable environment is similar to the nonfloating t a b l e environment setup described in section 6.3.1. Table 5.9: Postscript type 1 fonts
Couriera cour, courb, courbi, couri Charterb bchb, bchbi, bchr, bchri unmr, unmrs NimbusC U R W AntiquaC uaqrrc URW GroteskC ugqp Utopiad putb, putbi, putr, putri aDonated by IBM. b ~ o n a t e by d Bitstream. CDonated by U R W GmbH. d ~ o n a t e by d Adobe.
\beginCthreeparttable) \caption[Example of a \nxLenv{threeparttable) environment]{\textbfCPostScript type 1 fonts)) \begin{tabular){@{)ll@C)) Courier\tnote{a) & cour, courb, courbi, couri \ \ Charter\tnote{b) & bchb, bchbi, bchr, bchri \\ Nimbus\tnoteCc) & unmr, unmrs \\ URW Antiqua\tnoteCc) & uaqrrc \\ URW Grotesk\tnote{c) & ugqp \\ Utopia\tnoteCd) & putb, putbi, putr, putri\\ \endCtabular) \begin{tablenotes) \item[al Donated by IBM. \item[b] Donated by Bitstream. \item[cl Donated by URW GmbH. \itemCdl Donated by Adobe. \end{tablenotes) \end{threeparttable)

5.6.3 Managing Tables with Wide Entries


Sometimes it is necessary to balance white space in narrow columns uniformly over the complete width of the table. For instance, the following table has a rather wide first row, followed by a series of narrow columns.
this-is-a-rather-long-row C1 C2 C3 2.1 2.2 2.3 3.1 3.2 3.3

You can put some rubber length in front of each column with the help of the \extracolsep command. The actualvalue of the rubber length is not important, as long as it can shrink enough to just fill the needed space. In this case you must of course specify a total width for the table.

134

Tabular Material

this-is-a-rather-long-row
C1 2.1 3.1 C2 2.2 3.2 C3 2.3 3.3

\begin{tabular*){\linewidth)% {!{\extracolsep{4in minus 4in))ccc) \multicolumn{3){c){this-is-a-rather-long-row)\\ C1 &C2 &C3 \ \ 2.1R2.2R2.3 \\ 3.1R3.2R3.3 \end{tabular*)

In the preceding example we did not have a lot of success, since the entries are spread out too much. W e can, however, precalculate the width of the wide entry and specify it as the total width of the tabular*.
this-is-a-rather-long-row
C1 2.1 3.1 C2 2.2 3.2 C3 2.3 3.3
\newlength{\Mylen) \settowidth{\~ylen)(this-is-a-rather-long-row) \begin{tabular*){\Mylen)% {!{\extracolsep{4in minus 4in))ccc) \multicolumn{3){c){this-is-a-rather-long-row>\\ Cl RC2 RC3 \ \ 2.1R2.2R2.3 \ \ 3.1R3.2R3.3 \end{tabular*)

The result is already quite acceptable, but to achieve correct alignment we need to take into account the column separation (\tabcolsep) on both sides of an entry. We can obtain an even better alignment by adequately choosing the column alignments and inter-column spaces.
this-is-a-rather-long-row
C1 2.1 3.1 C2 2.2 3.2 C3 2.3 3.3
\settowidth{\~ylen)Cthis-is-a-rather-long-row) \addtolength{\Mylen)C2\tabcolsep) \begin{tabular*){\Mylen)% {!{\extracolsep{4in minus 4in))ccc) \multicolumn{3){c){this-is-a-rather-long-row>\\ Cl RC2 RC3 \ \ 2.1R2.2R2.3 \\ 3.1R3.2R3.3 \endCtabular*)

Alternatively we can suppress the inter-column spaces at the left and right of the tabular* by using QC3 expressions.
this-is-a-rather-long-row
C1 2.1 3.1 C2 2.2 3.2 C3 2.3 3.3
\settowidth{\Mylen)fihis-is-a-rather-long-row) \begin{tabular*){\Mylen)% {Q{\extracolsep{4in minus 4in))cccQ{)) \multicolumn{3){@{)cQ{)~~this-is-a-rather-long-row~\\ Cl RC2 RC3 \ \ 2.lR2.2R2.3 \\ 3.1R3.2R3.3 \endCtabular*)

5 . 6 . 4 Columns Spanning Multiple Rows


You can simulate a cell spanning a few rows vertically by putting the material in a zero-height box and raising it.

5.6 Applications

135

m u lti row-Vertical Alignment in Tables


The package file multirow (unknown author) automates the procedure of constructing tables with columns spanning several rows by defining a \multirow command. Fine-tuning is possible by specifying optional arguments. This can be useful when any of the spanned rows are unusually large, if \strut's are used asymetrically about the centerline of spanned rows, or when descenders are not taken into account correctly. In these cases the vertical centering may not come out right, and the fixup argument m o v e can then be used to introduce vertical shifts by hand.

1 \multirowInrow) [njotl {width) [vmovel {contents) 1


Inside array,this command is somewhat less useful since the lines have an extra \jot of space (a length, by default equal to 3pt,which is used for opening up displays), which \multirow does not account for. F W g this (in general) is almost impossible, but a semiautomatic fix is to set the length parameter \bigstrutj ot to \jot, and then use the second argument njot of \multirow with a value equal to half the number of rows spanned. You have some ability to control the formatting within cells. Just before the text to be typeset is expanded, the \multirowsetup macro is executed to set up any special environment. Initially, \multirowsetup contains just \raggedright, but it can be redefined with \renewcommand. The \multirow command works in one or more columns, as shown in the example below.
\begin~tabular~~IlIlIl~lI3 \hline \multirow{4~~14mm){Text in column 13 & C2a & \multirowC43C14mm3% {Text in column 3) & C4a \\ & C2b & & C4b \\ & C2c & & C4c \\ & C2d & & C4d \\\hline \end{t abular)

column 1
C2d

column 3
C4d

You are now in a position to typeset the small example shown at the beginning of this section without having to use the \raisebox command. First

136

Tabular Material
you must change the alignment inside the \multirow paragraph to \ c e n t e r i n g and then calculate the width of the text in the column, which is required by the \multirow command. If the column with the spanned rows has a fixed width, like in our other examples, this step is unnecessary.
\renewcommand{\multirowsetup~~\centering~ \newlength{\LL) \settowidth(\LL)(100) \begin{tabular){Iclclcl) \hline \multirowC2)C\LL)~lOO)a \multicolumn{2){cI~Cqqq) \\\cline(2-3) & A & B \\\hline 20000000 & 10 & 10 \\\hline \end{t abular)

The effect of the optional vertical positioning parameter vmove can be seen below. Note the effect of the upward move by 3 mm of the lower third of the table.
Column g2a Column g2b Column g2c Column g2d Column g2a Column g2b column g2c Column g2d gZa Column g2b Column g2c Column g2d
\beginCtabular){IlIlI) \hline \multirow(4){25mm){Common text in column 1) & Column g2a \\\cline{2-2) & Column g2b\\\cline(2-2) & Column g2c \\\cline{2-2) & Column gZd\\\hline \multirow(4)(25mm) C-3mml {Common text in column 1) & Column g2a \\\cline{2-2) & Column g2b\\\clineC2-2) & Column g2c \\\cline(2-2) & Column g2d\\\hline \multirow(4){25mm)[3mml{Common text in column 13 & Column g2a \\\cline(2-2) & Column g2b\\\cline{2-2) & Column g2c \\\cline{2-2) & Column gZd\\\hline \end{tabular)

Common text in column 1

Common text in column 1 Common text in column 1

5.6.5 Tables Inside Tables


The example below shows how, with a little bit of extra effort, you can construct X . complex table layouts with W The family of t a b u l a r environments allows vertical positioning with respect to the baseline of the text in which the environment appears. B y default the environment appears centered, but this can be changed to align with the first or last line in the environment by supplying a t or b value to the optional position argument. However, this does not work when the first or last element in the

5 . 6 Applications
environment is a \hline command-in that case the environment is aligned at the horizontal rule.
Tables with no versus tables hline commands used used.
Tables \begin{tabular) [ t l{ l ) with no\\ hline \ \ commands \\ used \end{tabular) versus tables \begin(tabular) [ t l C I1 I 1 \hline with some \\ hline \ \ commands \\ \hline \endCtabular) used.

137

hline commands

To achieve proper alignments in such a case you can make use of two special versions of \hline, which can be defined in a package file. The variable \Garstrutbox is a strut corresponding to the material in a cell of the table.

o o e 1 0

/././././. Done locally to get restored to correct value for backup in \ \


\advance\backup\extratabsurround

0 0 0 0 0

/././././. This will give some extratab space above the line
\ r u l e { O p t ) { \ b a c k u p ) ) \ \ [-\backup] \hline)

1 1 e 1 1

/ . / 0 / . / . /this . will provide for the same space below


0

\newcommand\lasthline~\hline\multicolumn{1~~~){) \global\backup-\ht\Oarstrutbox L/.LL/. o 0 o o this time globally

Using \f irsthline and \lasthline will cure the problem, and the tables will ahgn properly as long as their first or last line does not contain extremely large objects.
Tables with no versus tables line commands used used.
Tables \begidtabular1[ t l C1) with no\\ line \\ commands \ \ used \endCtabular) versus tables \beginCtabular) [ t ] CI 11 ) \firsthline with some \\ line \ \ commands \\ \lasthline \endCtabular) used.

line

The implementation of these two commands contains an extra dimension, to add some additional space at the top and which is called \extratabsurround,

138

Tabular Material
the bottom of such an environment. This is helpful for properly aligning nested tabular material, as shown in the following example:

name

telephone telephone time 8-10 telephone 5520104

Martin

I
Peter

telephone 3356677

instructions Mary should answer forwarded message. telephone 5 5 54434 No telephone 22 11456

I
James

month Sep-May Jun Jul-Aug

telephone No telephone

instrqctions Use P.O. Box 007 NY.

T h s example was produced by the following input:

\beginCtabular){IccI) \hline \textit{name) & \textit{telephone) \\\hline\hline John & \firsthline \begin{tabular) [t]C 1 cc 1) \textit{day) & \multicolumn(l){cI){\textitCtelephone~ \\\hline\hline Wed & 5554434 \\\hline Mon & \begin(tabular) [ t l ( l cc 1) \firsthline \textit(time) & \textit{telephone) \\\hline\hline 8--10 & 5520104 \ \ 1--5 & 2425588 \\\lasthline \end{tabular) \\\lasthline \end{tabular) \\\hline Martin &

5 . 6 Applications
\firsthline \begin{tabular) [ t ] { 1 cp{4.5cm) 1 ) \textit{telephone) & \multicolumn~1~~c~~{\textit{instructions~ \\\hline\hline 3356677 & Mary should answer forwarded message. \\\lasthline \end{tabular) \\\hline Peter & \firsthline \begin{tabular) [ t l C 1 cl 1 1 \textit{month) &\multicolumn~l){c 1 ) { \ i t s h a p e telephone) \\\hline\hline Sep--May & 5554434 \\ Jun & No telephone \\ Jul--Aug & 2211456 \\ \lasthline \end{tabular) \\\hline James & \firsthline \begin{tabular) [ t l { I cll \textit{telephone) & \multicolumn{l){cl~~\itshape instructions) \\\hline\hline No telephone & Use P.O. Box 007 NY. \\\lasthline \end{tabular) \\\lasthline \end{tabular)

139

5.6.6 Two More Examples


The IPQX code below shows how you can combine various techniques and packages described earlier in this chapter. W e have used the package tabularx to generate a twelve-column table with columns 3 to 1 2 of equal width. W e used the package multirow to generate the stub head, "Prefix," which spans two rows in column 1. In order to position the stub head properly, we must calculate the width of the title beforehand.
\setlength~\tabcolsep)Clmm) \newlength{\Tl)\settowidth{\Tl){Pref ix) \newcommand{\T) [ I ]{ $ l o { # I ) $ ) \ b e g i n { t a b u l a r x ~ ~ \ l i n e w i d t h ~ l l ~ l ~ * { l O ~ ~ \ s m a\hline llX \multicolumn{12){~cl)C\textbf~refixes used in the SI system of u n i t s ) ) \\\hline \multicolumn{2)~Icl)~Factor) & \ T { 2 4 ) & \ T { 2 1 ) & \ T { 1 8 ) & \ T { 1 5 ) & \ T { 1 2 ) & \ T { 9 ) & \ T { 6 ) & \ T { 3 ) &\TI21 &\T{ )\\\cline{l-2) \multirow~2>{\Tl)CPrefix~&Name & yotta &zetta &exa &peta &era &giga &mega &kilo &hecto &deca \ \ &Symbol & Y &Z &E &P &T &G &M &k &h &da \\\hline \multirow{2){\T1){Prefix)&Symbol & Y &z &a &f &P &n &$\mu$ &m &c &d \\ &Name & yocto &zepto &atto &femto &pic0 hano &micro hilli kcenti &deci \\\cline{l-2) \multicolumnC2)~lclHFactor~& \T{-24)&\T{-21)&\T{-18)t\T{-15)&\T{-12~&\T{-9)&\T{-6>&\T{-3>&\T{-2)&\T{-l)\\\hline \end{tabularx)

Tabular Material Prefixes used in the SI system of units


1018 1015 1012 lo9 loG lo3 Factor - 102"021 Name yotta zetta exa peta tera giga mega kilo G M k E P r PrefutSymbolu Z a f p n p m z Symbol y Prehx Name yocto zepto atto femto pic0 nano micro milli 10-'8 10-l5 10-l2 10-"0-6 Factor 10 deca hecto da h c d centi deci lo-' 10-I

lo2

You can use various other LATEX environments inside a t a b u l a r environment, as the following example shows.
A picture environment (see page 281)
\fboxC\begin(picture)(12,6.3) \bezierC200)(2.00,6.00) (7.00,6.00>(9.00,3.00)

....
\end{picture))

D l

A rotated object ( t u r n environment, see figure 11.7 on page 323)


\fbox(\begin{turn)C-45) \fbox{\parbox[b]{l3mm){A \end{turn))

b C d E f G h I jKlMnPqR13

D l
4( I )

A rotated t a b u l a r (see section 11.4.1) with Encapsulated Postscript images


\fboxC\begin(turn)C-90) \beginCtabular){(cccI) \hline $\clubsuit$& &$\diamondsuit$ \\ &\begin{tabular)C I c 1 c I) \hline \epsfigCf ile=Escher .eps ,width=lOmm) & Escher \\\hline Escher & \epsfigCfile=Escher.eps,width=lOmm~ \\\hline \end{tabular) & \\ &\heartsuit$ & & $\spadesuit$\\\hline \end{tabular) \end{turn))

CHAPTER

Mastering Floats

Documents would be easier to read if all the material that belongs together were never split between pages. However, this is often techcally impossible and T E X will, by default, split textual material between two pages to avoid partially filled -pages. Nevertheless, when this is not desired (as with figures and tables), the material must be "floated" to a convenient place, such as the bottom or the top of the current or next page, to prevent half-empty pages. B y default, L Q X provides two floating environments, f i g u r e and t a b l e , (L59,60,176-78) whose style parameters are described in section 6.1. Sometimes you may need environments for floating other kinds of objects like computer listings, which are examined in section 6.3. Section 6.4 discusses a few floating environments and subfigures, while section 6.5 explains how to customize captions.

6.1 Understanding Float Parameters


Floats are often problematical in the present version of L A T E X , since the system was developed at a time when the amount of graphical material in a document was considerably less than it is now. Therefore, placing floats (tables and figures) works relatively well as long as the space they occupy is not too large compared with the space taken up by the text. If, however, a lot of floating material is present (lots of pictures or tables) then it is often the case that all material from a certain point onwards floats to the end of the document. If this effect is not desired, you can issue from time to time a \clearpage command, which wdl print all unprocessed floats. You can also try to fine-tune the float style parameters for a given document or use a package which allows you to always

142

Mastering Floats print a table or figure where it appears in the document. In the list below "float" stands for a table or a figure and a "float page" is a page that contains only floats and no text. Changes to the parameters will only take effect on the next page (not the current one).
topnumber Counter specifying maximum number of floats allowed at top of page (the default number is 2). Change with the \setcounter command. bottomnumber Counter specifying maximum number of floats allowed at bottom of page (the default number is 1). This can be changed with the \set counter command. totalnumber Counter specifying maximum number of floats allowed on a single page (the default number is 3). This can be changed with \setcounter. \topfraction Maximum fraction of the page that can be occupied by floats at

( L 176-78)

the top of the page (e.g., 0.2 means 20% can be floats; the default value is 0.7). This can be changed with \renewcommand.
\bottomfraction Maximum fraction of the page that can be occupied by floats

at the bottom of the page (the default value is 0.3). This can be changed with
\renewcommand. \textfraction Minimum fraction of a normal page that must be occupied by text (the default value is 0.2). This can be changed with \renewcommand. \f loatpagefraction Minimum fraction of a float page that must be occupied

by floats, thus limiting the amount of blank space allowed on a float page (the default value is 0.5). T h s can be changed with \renewcommand.
dbltopnumber Analog of topnumber for double-column floats in two-column style (the default number is 2). This can be changed with the \setcounter

command.
\dbltopfraction Analog of \topfraction for double-column floats on a

two-column page (the default value is 0.7). T h s can be changed with


\renewcommand. \dblfloatpagefraction Analog of \floatpagefraction for a float page of

double-column floats (the default value is 0.5). T h s can be changed with


\renewcommand. \f loatsep Rubber length specifying the vertical space added between floats appearing at the top or the bottom of a page (default 12pt plus 2pt minus 2pt for lOpt and l l p t document sizes, and 14pt plus 2pt minus 4pt for 12pt document sizes). This can be changed with \setlength. \textfloatsep Rubber length specifying the vertical space added between

floats, appearing at the top or the bottom of a page, and the text (default 20pt plus 2pt minus 4pt). This can be changed with \setlength.

6.1 Understanding Float Parameters


\ i n t e x t s e p Rubber length specifying the vertical space added below and above a float that is positioned in the middle of text when the h option is given (the default is similar to \f loatsep). This can be changed with \ s e t l e n g t h . \dblf l o a t s e p Rubber length which is the analog of \ f l o a t s e p for doublewidth floats on a two-column page (the default is like \f loatsep). T h s can be changed with \ s e t l e n g t h . \ d b l t e x t f l o a t s e p Rubber length which is the analog of \ t e x t f l o a t s e p

143

for double-width floats on a two-column page. (The default is like \ t e x t f l o a t s e p on a text page, but it is 8 p t p l u s 2f il on a page that contains only floats.) This can be changed with \setlength.
\topfigrule

Command to place a rule or somethng else between floats at the top of the page and the text. It is executed right before placing the \ t e x t f l o a t s e p that separates the floats from the text. Just like the \f ootnoterule it must not occupy any vertical space. arating text from the floats at bottom of page.

\botf i g r u l e Same as \topf i g r u l e , but put after the \ t e x t f l o a t s e p skip sep\dblf i g r u l e Similar to \topf i g r u l e , but for double-column floats.

Changing the values of the above parameters lets you modify the behavior of J2QX's algorithm for placing floats. But for getting better results, you should be aware of the subtle dependencies between the parameters. If you use the default values in a document you will observe that, with many floats, the formatted document will contain several float pages-pages containing only floats. Often there is a lot of white space on such pages, for example, you may see a page with a single float on it, occupying only half of the possible space, so that it would look better if L A T E X had filled the remaining space with text. The reason for this behavior is that the algorithm is designed to try placing as many dangling floats as possible after the end of every page. The procedure creates as many float pages as it can until there are no more floats to fill a float page. This float page production is controlled by the parameter \f loatpagef r a c t i o n , which specifies the minimum fraction of the page that must be occupied by float(s)-by default, half the page. Since in the standard settings every float is allowed to go on a float page (the default specifier is tbp), t h s setting means that every float that is a tiny bit larger than half the page is allowed to go on a float page by itself. Thus by enlarging its value you can prevents half-empty float pages. However, enlarging the value of \f loatpagef r a c t i o n makes it harder to produce float pages and, as a result, some floats may get deferred, which then in turn prevents other floats from being placed. For this reason it is often better to specify explicitly the allowed placements (for example, by saying \begin(f igure) Ctbl ) for the float producing the problem. Another common reason for ending up with all floats at the end of your

( L 176)

144

Mastering Floats chapter is the use of the bottom placement specifier, [bl. T h s means that the only acceptable place is at the bottom of a page, and if your float happens to be larger than \bottomfraction (which is by default quite small) then t h s float cannot be placed. This will also prevent all floats of the same type from being placed. The same happens if only [h] or [tl is specified and the float is too large for the remainder of the page or too large to fit \ t o p f r a c t i o n . In calculating these fractions, L A T E X will take into account the separation (i.e., \ t e x t f l o a t s e p ) between floats and main text. B y enlarging this value, you automatically reduce the maximum size a float is allowed to have to be placeable at the top or bottom of the page. In general, whenever a lot of your floats end up at the end of the chapter, look at the first of them to see if their placement specifiers are preventing them from being properly placed.

6.2 Improved Float Control


The float placement algorithm prefers to put floats at the top of the page, even if this means placing them before the actual reference. This is not always acceptable but there is no easy cure for this problem short of substantially changing WX's algorithm. T h s is done in the flafter package (by Frank Mittelbach) whch ensures that floats never come before their reference. Sometimes,however, less drastic solutions might be preferred. For example, if the float belongs to a section that starts in the middle of a page but the float is positioned at the top of the page, it will look as if the float belongs to the previous section. Thus you might want to forbid this behavior while still allowing floats to be placed on the top of the page in other situations. For t h s LATEX^^ offers you the following command.

I \suppressf l o a t s [placement]

The optional argument placement can be either t or b. If the command \suppressf l o a t s is placed somewhere in the document, then on this page any following floats for the areas specified by placement are deferred to a later page. If no placement parameter is given all further floats on this page are deferred. Thus, if you want to prevent floats from moving backward over section boundaries you can define your section commands in the following way:

Possible arguments to \ @ s t a r t s e c t i o n are discussed in section 2.3.2. Another way to influence the placement of floats in m X z E is to specify a ! in conjunction with the placement specifiers h, t, b. The placement of floats

6.2 Improved Float Control

145

on float pages is not affected. This means that for this float alone, restrictions given by the settings of the parameters described before (e.g., \textfraction) are ignored. Thus, such a float can be placed in the designated areas as long as neither of the following two restrictions is violated: the float fits on the current page, i.e., its height plus the material already contributed to the page does not exceed \textheight; there are no deferred floats of the same type. All other restrictions normally active (such as the number of floats allowed on a page, etc.) are ignored. For example, if you specify C! bl this float can be placed on the bottom of the page even if it is larger than the maximum size specified by \bottomfraction. Also, any \suppressfloats commands are ignoreed whilst processing t h s float. Please remember that the order of the given specifiers is irrelevant and that all specifiers should be given at most once. For example, [btl is the same as [tbl and thus does not instruct E Q X to try to place the float at the bottom and only then try to place it on the top. W X always uses the following order of tests found. unhl an allowed p1acement.i~
1. If ! is specified, ignore most restrictions as described above and continue. 2. If h is specified, try to place the float at the exact position. If this fails and no other position was specified, change the specifier to t (for a possible placement on the next page). 3. If t is specified, try to place it on the top of the current page. 4. If b is specified, try to place it on the bottom of the current page. 5. If p is specified, try to place it on a float page (or float column) when the current page (or column) has ended. 6. Stages 3 and 4 are repeated if necessary at the beginning of each subsequent page, followed by 5 at its end.

The afterpage package (by David Carlisle) implements a command \afterpage that causes the commands specified in its argument to be expanded after the current page is output. This package can be used in the situations described below.
w

Sometimes U T j $ s float positioning mechanism gets overloaded, and all floating figures and tables drift to the end of the document. You may flush out all the unprocessed floats by issuing a \clearpage command, but this has the effect of making the current page end prematurely. The present package allows you to issue the command \afterpageC\clearpage). This will let the current page be filled with text (as usual), but then a \clearpage command d l flush out all the floats before the next text page begins. With the multipage longtable environment (see section 5.4.2), you can experience problems when typesetting the text surrounding the long table,

146

Mastering Floats

and it might be interesting to "float" the longtable. However, since the latter can be several pages long, it might prove impossible to hold them in memory and float them in the way that the t a b l e environment is floated. Nevertheless, if the table is in a separate file, say l t f i l e .tex, you can now use one of:

The first form lets text appear on the same page at the end of the longtable, and the second ensures that the surrounding text starts again on a new page. You can also combine \afterpage with the float package and the CHI placement specifier, as explained at the end of section 6.3. Note that the \afterpage command does not work in twocolumn mode.

6.3 float-Creating New Float Types


The float package (by Anselm Lingnau) improves the interface for defining floating objects such as figures and tables in L A T E X . It adds the notion of a "float style" that governs the appearance of floats. New kinds of floats may be defined using a \newf l o a t command.

I \newf loatCtype)Cplacement){ext)

[within]

The \newf l o a t command takes four arguments, three obligatory and one optional with the following meaning:
type The "type" of the new class of floats, like program or algorithm. After the appropriate \newfloat, commands such as \beginCprogram) or \end{algorithm*) will be available. placement The default placement parameters for the given class of floats. They are, like in standard L A T E X : t , b, p, and h for top, bottom, page, and here, respectively. On top of that, there is a new type, H,which does not really correspond to a float, since it means: put it "here" and nowhere else. Note, however, that the H specifier is special and, because of implementation details cannot be used in the second argument to \newf l o a t . In other words, you cannot define a new float class that is placed by default "here." ext The file name extension of an auxiliary file for the list of figures (or whatA T E X writes the captions to this file. ever). L within This (optional) argument determines whether floats of tlvs class will be numbered within some sectional unit of the document. For example, if within is equal to chapter, the floats will be numbered within chapters. (In

6.3 float-Creating New Float Types

147

standard W X , this happens with figures and tables in the report and book document classes.)

The \ f l o a t s t y l e command sets a default float style. T h s will be used for all the floats that are subsequently defined using \newf l o a t , until another \ f l o a t s t y l e command appears. See \ r e s t y l e f l o a t below for redefining the style of the f i g u r e and t a b l e floats. The \ f l o a t s t y l e command takes one argument: the name of a float style, such as \f loatstyleCruled3. Specifying a string that does not name a valid float style produces an error message. The style argument can be one of the following:
p l a i n This is the float style that IPQX normally applies to its floats, i.e., nothing

in particular. The only difference is that the caption comes out below the body of the float, regardless of where it is given in the text. boxed The body of the float is surrounded by a box. The caption is printed below that box. r u l e d This float style is patterned after the table style of Concrete Mathematics [22]. The caption is printed at the top of the float, surrounded by rules; another rule finishes off the float.

The \floatname command defines the name that W X uses in the caption of a float, that is, "Figure" for a figure and so on. For example, \f loatnameCprogram3CProgran13. B y default, the \newf l o a t command sets the float name to its argument rype if no other name was specified afterwards.

The \f loatplacement command defines the default placement specifier for the given float class, for example, \f loatplacement(f igure3Ctp).

A \ r e s t y l e f l o a t command is necessary to change styles for the standard float types, f i g u r e and t a b l e . Since these aren't usually defined by \newf l o a t , they do not have a style associated with them. Thus, to typeset tables using the r u l e d float style, you would have to say:

Mastering Floats

This document shows some of the possibilities of float.sty for floating objects.

Program 1.2.1 A simple C++ Program.


#include <stream.h> main(int argc,char #argv[l)// get arguments

C
double sum = 0 // declare variable for (int i = 1; i < argc; i++) sum += atof (argv[il) ; / / convert args cout << "average=" << sum/argc;

\documentclass{article) \usepackageCfloat,times) \thispagestyleCempty) \floatstyle{ruled) \newfloat{Program3{thp~{lop)~section] \floatstyle{boxed> \newfloat(algorithm)Ithp){loa) \floatname{algorithm)CAlgorithm) \begin{document) This document shows some of the possibilities of \texttt{float.sty) for floating objects. \beginCProgram) \begin{verbatim) #include <stdio.h> int main(int argc, char **argv)

L L . 1
>
cosz =
1- - +

-...

Algorithm 1: Trigonometric Expansions.

for int i; (i = O; i < argc; ++i) printf ("argv[%d] = %s\nl1, i, argv [ill ; return 0; 3 \end{verbat im) \captionCThe program. 3 \end{Program)

...

Figure 6.1: Defining two "nonstandard" floats-Program and a l g o r i t h m

This command also lets yo6 change style for floats that were defined via
\newf l o a t , although this is, typographically speaking, not a good idea.

The \ l i s t o f command produces a list of all the floats of a given class. The first parameter, type, specifies the type of the float as given in the \newfloat command. The second argument, title, determines the text of the title that will be used to head the list of the information associated with the float elements, as specified by the \ c a p t i o n commands. The \ l i s t o f command is analogous to the built-in W X commands \ l i s t o f f i g u r e s and \ l i s t o f t a b l e s . Figure 6.1 is an example of the definition of two "nonstandard" floatsProgram and algorithm.

6.3 float-Creating New Float Types

149

6.3.1 I Want M y Float "Here"!


Sometimes you will find that m X ' s float placement specifiers are too restrictive. You may want to place a float exactly at the spot where it occurs in the input file, that is, you do not want it to float at all. It is a common misunderstanding that specifying [hl means "here and nowhere else." Actually, that specifier only directs L A T E X to try to place the float at the current position. If there is not enough room left on the page or if an in-line placement is forbidden because A T E X ignores t h s of the settings of the style parameters (see section 6.1) then L request and tries to place the float according to any other specifier given. Thus, if [htl is specified, it means that the Boat will appear on the top of some later page if it does not fit onto the current one. This can happen quite often if the floats you try to place in the middle of your text are moderately large and are thus likely to fall into positions where there is not enough space on the page for them. B y ignoring an h and trying other placement specifiers, I Q X avoids overly empty pages that would otherwise arise in such situations. However, in some cases you might prefer to leave large gaps on your pages, and for this reason the package float provides you with an [HI specifier that means "put the float herev-period. If there is not enough space left on the current page, the float will be printed at the top of the next page together with whatever follows, even if there is still room left on the current page. It is up to you to place your H floats in such a way so that you do not obtain large patches of white space at the bottom of a page. When you mix standard and [HI placement parameters, a float with a [tl specifier (for example) that appears before one with an [HI specifier in the input file might be incorrectly positioned after the latter in the typeset output, so that-for instance-figure 4 would precede figure 3. Note that the [HI specifier cannot be used in conjunction with the other placement specifiers. Consequently, a combination like [Hhtl would be illegal. CHI also cannot be used as the default placement specifier for a whole class of floats. To summarize, all the float placement specifiers are shown together in the following example of an H table.
t p H

Top of Page b Page of floats h Here, always

Bottom of page Here, if possible

Table 6.1: Float placement specifiers of the float package

\ b e g i d t a b l e ) [HI \begin{tabular){*2{>{\ttfamily)cl)) t & Top of page & b & Bottom of page \ \ p & Page of f l o a t s & h & Here, i f possible \ \ Here, always \end{t abular) \caption{Float placement s p e c i f i e r s of the \nxLpack{f l o a t ) package} \endCtable)

Another important point is that, by default, the float package does not modify the standard figure and table environments (unlike David Carlisle's

150

Mastering Floats now obsolete here package). Thus, if you want to use the C H I qualifier with these environments, you must first issue \ r e s t y l e f l o a t ( f igure3 and/or \ r e s t y l e f loat(tab1e) commands. Together with the afterpage package described in section 6.2, you can get an even finer control on the placement of your floats. Indeed, in some cases, although you specify the placement parameter as CHI, you do not really mean "at this point," but "somewhere close." You can acheve this using the \afterpage command as follows:
\afterpage{\clearpage\begin{f igure) [HI

. . .\end{f

igure))

This ensures that the figure is at the top of the next page. It also solves the sequencing problem, described above, since \clearpage stops any other figures from drifting past the C H I figure.

6.4 Different Kinds of Floating Environments


6.4.1 floatfig-Narrow Floating Figures
The floatfig package file (by Thomas J. Reid [71]) sets floating figures that do not fill the full width of the page.

I \begin{f

loatingf igure)I width1

If the width of such figures is only part of the page width, text lines can be set beside the figures. The floatfig package is fully compatible with L A T E X S ' standard f i g u r e facility:
1. Floating figures and standard figures may be requested in any sequence. 2. Floating figures can be captioned like standard figures.

3. Captioned floating figures are inserted in the list of figures, which may be printed by the standard \ l i s t o f f igures command.

The f loatingf igure environment can only be used in vertical mode, i.e., between paragraphs. The floating figure will be set as soon as possible after its request has been encountered. That means that & Q Xwill test whether there is enough vertical space on the current page. If the answer is negative, the figure moves to the next page. Floating figures are set alternately: i.e., on the right side of odd-numbered pages and on the left side of even-numbered pages. Figure 6.2 on the next page shows how the f loatingf igure environment is used. Note that the floatfig package may not be combined with the twocolumn option and that the floating figure will never appear in a paragraph that starts at the top of a page.

6.4 Different Kinds of Floating Environments

151

1 Aeneid Book One


ARMA vtrumque cano. Tmiae qui primus oh arir Itallam. fala profups. Laviniaque venit titaru. mu~tum i ~ et ~tenis c lactatus a aha vi superurn saevae memorem tunanis oh iram: rnulra quoque ct k l l o pasus, dum conderet urbem. inferrelque dms Latio. genus unde ~atinum.~ ~ b a n i q pnrcr, ue atque ahac moen~a Romac. Mura. mihi causar memon. quo numinc laeso. quldve dolens. deum lo, votvere -canus lnripnem plecare v w m , tot ad~re lat impulcm. Tantaene animtr caeleslibur irac Urbr antiqua full. 3 r i 1 lenuere ca Kanhago. ILaltm canm 'Iibsrinaquc Ian8 t ~ a . diver opvm ludiisque asperrimn I qunm luno fenur tcrrir magis omnibus I parrhobtla eolutr~e Sama: htc illius ma. eurms full: hoc regnum dcagentiburesre. r i qua fara sinant. iam tum lendilque fovetque. Ropenlcm red ~nimTracano asangum duel audlerat, qrias ~ t i m quae venerer arccs: htnc p p u ~ u r n meMed'terrancan late regem klloque superbumventururn C X C C ~ I O LI~Y~C ?ic : valvere parcas. ~dmetuens, vetensque mcmor Satumia M t i , prima q u d ad Troiam pro cans gcsserat A r g i c necdum etiam cvusae irarum saevique dolomr crcidcranr mirn0: manet dra mente r c ~ s t u m iudtcturn Pwidiq spretaequ~ iniuriv farmae, elgenus innsum, ctraptiGanymdis honorer. Hisaccensasupr, lacralosacquom toto~raa~ relcquiasDanaum . arque immttis Aeh~llv, arceb~,~onge Latta, multoqueper snnm ernbunt. acu fnus. maria omnta arcurn. Tantac molrs ent Ramanam condere genreml Vlx e conspeelu Slculae lclluris i n ele m vela dabant l a d . et rpumns ralir aem ruebant. cum luno. aetcmum wvans rub vtore votnur, ham =urn: 'Mene I"Float-fig 2 cepto desistere nelam, nec posse llalta Tcucmnrrn avertere regem? Quippe vetor fala. Pnllasnc cxurere c l a ~ ~ eArgivom m aque ~prorpo~itsubmergereponto.unius oh noxam ct furias Aiaclr Dilei? Ipra. lovls rapadurn iaculata e nubibus ignem. ~i~~ 2: caption [he nmw disiecitqueralesevcn1fqucaequ~nventis. floating ljgure illum expirantem tranrfiro wrore nummar Nrbine cornpull wapuloquc infixit aculo Art ego. quae divom incedo mgina. lov~squc el wror EI coniunr. una cum genrerot annosklla gero! Er quisquam numen lunonir adoret pneterea. rut suppler ans Impnet honorem? Talia Rammato xcum deu carde vnlutanr nimborum ,n pamam. l a a feta furent~hus

\documentclass~article~

..

LA

\usepackage{floatfig,epsfig) \begin{document) \initfloatingfigs \section{Aeneid Book One) \textsc{Arma) virumque cano, ... ..., atque altae moenia Romae. \par \begin{floatingfigure){6cm) \mbox{\epsfig{file=Mediterranean.eps)) \caption{The Mediterranean area) \end{floatingfigure) \quad Musa, mihi CaUSaS ... ...erat Romanam condere gentem! \par \begin{floatingfigureH7cm) \fbox{\parbox{66mm)C\rule[-2cm]{Omm){4cm)% \hf il Float-fig. 2)) \caption{Caption of the second narrow floating figure) \end{floatingfigure) \quad Vix e conspectu Siculae telluris in altum .... \end{document)

Figure 6.2: An example with a narrow floating figure

6.4.2

wrapfig-Wrapping

Text around a Figure

The package file wrapfig (by Donald Arseneau) defines the wrapf i g u r e environment. This environment allows a figure to be placed manually at the side of the page and wraps text around it.

I \begin{wrapf

igure) Cnlinesl {placement)Cwidth)

The wrapf igure environment takes two mandatory and one optional argument with the following meaning:
nlines (optional argument) defmng the number of narrow lines. Each display equation counts as three lines. placement horizontal placement (1for left and r for right). width width of the figure.

152

Mastering Floats
The paragraph below, which is illustrated in figure 6.3, is preceded with the following commands:
\begin{wrapfigure){r)C3in) \begin{boxit) \begidcenter) This is a "wrapfigure." \end{center) \caption{A wrapfigure example) \end{boxit) \end{wrapfigure) %% wrapfigure is a different type of \emphCnonfloating) figure..

wrapf igure is a different

type of nonfloating figure environment for W X . A figure of the specified width Figure 6.3: A wrapf igure example will appear on either the left or right of the page. W X will try to wrap text around the figure leaving a gap of \columnsep by producing a number of short lines of text. The number of short lines is based upon the height of the figure plus the length \intextsep. You can override this guess by specifying the optional argument. Note that wrapf igure should not be used inside another environment (e.g., list),but it does work in twocolumn page layout. Since it does not float, it may be out of sequence with floated figures. V Q X will not move a wrapf igure to its optimum place, so it is up to you to position it in the best fashion. Wrapfigures should be positioned just before printing your final copy, since any changes to the document can ruin their careful positioning. Here are some rules for good placement: The environment should be placed so as to not run over a page boundary. Only ordinary text should have to flow past the figure but not a section title. Equations are acceptable if they fit.
It is convenient to give \beginCwrapfigure) just after a paragraph has ended. If you want to start in the middle of a paragraph, the environment must be placed between two words where there is a natural line break.

6.4.3 su bfigure-Figures inside Figures


The subfigure package (by Steven Cochran) allows the creation of subfigures, each with its own caption, and it allows an optional global caption under the figure as a whole.

6.4 Different Kinds of Floating Environments

153

\beginCfigure) \centering \mbox~\subfigure~Big]~\epsfig~figure=elephant.eps,width=.30\textwidth))\quad \subfigure~Medium]~\epsfig~figure=elephant.eps,width=.25\textwidth))\quad \subfigure[Smalll~\epsfig~figure=elephant.eps,width=.20\textwidth))) \captionCThree subfigures) \labelCfig:subfigures) \end(figure)

(a) Big

(b)Medium

(c) Small

Figure 6.4: Three subfigures

The figure is horizontally centered with \subf igtopskip (default value 10pt) of vertical space added above and \subf igcapskip (default value 10pt) of vertical space added below, followed by the caption. The subfigure is followed by another \subf igtopskip of vertical space added at the bottom. If a caption is specified between square brackets (includmg a null caption, C 1) then the subfigure is labeled with a counter supplied by the macro \thesubf igure (defined by default as (\alphCsubf igure)) \space), yielding: "(a) ," "(b) ," etc. If desired, this macro can be redefined. The counter used for labeling the subfigures is subf igure and is incremented for each subfigure regardless of whether a caption was printed. Figure 6.4 shows how three pictures can be ahgned horizontally with a tabular environment. Each subfigure has its own caption, plus the figure as a whole has its global caption. The figure can be referenced in the text through the key specified on the \ l a b e l command.

6.4.4 endfloat-Place Figures and Tables at the End


Some journals require figures and tables to be separated from the text and grouped at the end of a document. They may also want a list of figures and tables to precede them.

154

Mastering Floats.

The endfloat package file (by James Darrell McCauley) puts figures and tables by themselves at the end of an article into a section named Figures or Tables. The list of tables and figures produced at the end of a document can be turned off by putting \nof iglist and \notablist in the preamble. Notes are left in the text. Thus " [Figure 4 about here. I " indicates approximately where the float would have normally appeared. These notes can be turned off by putting a \nomarkersintext command in the preamble of the document. The text of the notes, which is defined via the strings \f igureplace and \tableplace, can be changed with \renewcommand. The default definitions are the following:
\newcommandC\figureplace)C% For figures \beginCcenter)[\figurename-\thepostfig\ \newcommandC\tableplace)C% For tables \beginicenter)[\tablename~\theposttbl\

about here.]\end{center)> about here.]\end{center))

The endfloat package file creates two extra files with the extensions .fff and .ttt. If you use this package you may need an extra L Q X run to resolve changed cross-references due to float movements.

6.5 Customizing Your Captions


When you want to explain what is shown in your floating environment (figureor table in standard WX), you normally use \caption. The \caption command is only defined inside a float environment and, apart from typesetting the text you specify and putting it in the list of figures or tables, it also increments the counter associated with the float in question. The command has the following syntax:

I \caption [short text] Clong text) I


The optional argument short text goes into the list of figures or tables. If only the mandatory argument long text is specified then it is the latter that is used in those lists. If the caption is longer than one line, you are strongly advised to use the optional argument to provide a short and informative description of your float. Otherwise, the list of figures and tables will become unreadable and it will be difficult to locate the necessary mformation. Internally, \caption invokes the command:

The number for the caption, numb,is generated internally depending on the type of float. The argument text is the text to be typeset. The default definition

6.5 Customizing Your Captions

155

for the part doing the typesetting for a caption is something like:
\newcommand{\Qmakecaption)[21~% #I is e.g. Figure 1, #2 is caption text \vspace{lOpt)\sbox{\tempbox)(#l : # 2 ) % \ifthenelse{\lengthtestC\vd\tempbox > \linewidth)% { #1: #2\par)% More than one line {\begin{center)#l: #2\end{center))%

After an initial skip of lOpt, the material is typeset in a temporary box


\tempbox, and its width is compared to the line width. If the material fits on

one line then the text is centered; if the material does not fit on a line, it will be typeset as a paragraph with a width equal to the line width. You can, of course, define other ways of formatting your captions, and you can even supply different commands for making captions for each of the different types of floats. For example, the command \Qmakef igcaption can be usedinstead of \@makecaption to format the captions for a f igure environment.
\newcommand{\Qmakef igcaption) [21{ . . . . I \renewcommand{\figure> {\let\@makecaption\Qmakefigcaption\Qfloat~figure))

As an example of a different way of formatting captions, the package


hangcaption (by David Jones) defines \isucaption (a variant of the \caption

command), which produces captions with a hanging indentation. If the caption is less than a full line, it will be centered. The length variable \captionwidth can be set to control the width of the caption. The interesting part of the definition, whch can be compared to the code above, is:
\newcommand{\@isucaption)~2]{% #1 is e.g. Figure I , #2 is caption text \par\vspace{iOpt)\sbox~\tempbox)I#l: #2)% \ifthenelse{\lengthtestC\vd\tempbox > \linewidth)% <> 1 line? {\sbox~\tempbox){#i:\ 1 % Measure text of part 1 \addtolength{\captionwidth)C-\wd\tempbox % Subtract from width \mboxI#l :\ )\parbox [tl C\captionwidth){#2)))% place two boxes {\begin{center)#l: #2\endCcenter>)% One line only

C H A P T E R

Font Selection
7.1 Introduction to NFSS
(LA)TEXas a typesetting system does half of the job of producing the desired result: from the user's input it calculates positions for characters on a page. But it has only a primitive knowledge about such characters, which it basically regards as black boxes having a width, height, and depth. This information is stored in external files, one for each font, that are called T E X font metric or .t f m files. The character shapes that correspond to such a .t f m file come into play at a later stage, after (LA)TEXhas produced its .d v i file. The character placement information in the . d v i file and the information about the character shapes present in the .pk file or in outline descriptions (e.g., Postscript) are combined by a driver program that produces the image on the output medium. Usually you need one driver program for every output medium-e.g., for screen representation, low resolution laser printer, etc. When T E X was developed in 1979, only a dozen fonts were set up for use with TEX: the 'Almost Computer Modern' fonts, also developed by Donald Knuth. Since only these fonts were available, a straightforward approach for accessing them was used: a few control sequences were defined that changed from one external font to another. This situation had not greatly changed much five years later by the time W X was first released. Only the names of the fonts supplied with (D)TEXhad changed, from 'Almost Computer Modern' to 'Computer Modern' (which are almost the same as the 'Almost Computer Modern'). So it was quite natural that L A T E X S ' font selection scheme followed the plain T E X concept with the addition of size-changing commands that allowed typesetting in ten predefined sizes.

158

Font Selection
As a result L A T E X S ' font selection was far from general. For instance, when defmng a heading command to produce a bolder font (by using a \bf command in its definition), the use of, say, \ s f (for a sans serif font) inside such a heading did not produce a bold sans serif font but rather a medium weight sans serif font (the bold attribute was ignored). Similarly, when, say, \bf was used inside emphasized text, the result was not a bold italic font, as normally desired, but rather a plain roman bold font. T h s behavior was caused by the fact that all the font-changing commands, like \bf, referred to a fixed external font and so, rather than requesting an attribute change of the current font, they replaced the current font with another. Of course, L A T E Xenhanced the plain TEXmechanism to a certain extent by providing a set of size-changing commands, yet the underlying concept of the original release had a major drawback: the correspondence tables were hard-wired into L A T E X , so that changing the fonts was a difficult if not impossible task. Since that time, low-priced laser printers have become available and with them a large number of font families from the Postscript world and other worlds. Also the number of fonts in METAFONT source format (freely available to every (LA)TEXinstallation) increased drastically. But, unfortunately, there was no easy and standard method of integrating these new fonts into WX-typesetting with W X meant typesetting in Computer Modern on almost all installations. Of course, individual fonts could be loaded using the \newfont command, but this capability cannot be called integration: it requires a great deal of user intervention, since such additional fonts do not change size under the control of size commands, and it does not allow a whole document to be typeset in a different font family. There have been a few efforts to integrate other fonts into L A T E X , but this was done by exchanging one hard-wired font table with another, thus malung the resultant L A T E X variant as inflexible as the original one, and only forced the use of a different set of fonts. This unsatisfactory situation finally was changed with the release of the New Font Selection Scheme (NFSS) [58,60] in 1989 written by Frank Mittelbach and Rainer Schopf, which became widely known after it was successfully used in AMS-ILQX (see chapter 8). This system contains a generic concept for varying font attributes individually and integrating new font families easily into an existing L A T E X system. The concept is based on five attributes that can be defined independently to access different fonts, font characteristics, or font families. In order to realize the concept, some of the L A T E X commands were redefined and some new commands were added. Later on, a prototype version for scalable fonts was coded by Mark Purtill. Starting from h s work, Frank Mittelbach designed and implemented NFSS2 integrating work by Sebastian Rahtz (on Postscript fonts) and several others. The following sections describe release 2 of NFSS, which was completed at

(1 116,200)

7.2 Understanding Font Characteristics

159

the end of 1992. This release is now part of LATEX'&, and, as far as the user interface is concerned, is intended for integration into I4TEX3. Since the concepts used by NFSS completely differ from the way fonts were handled in (LA)TEXpreviously, we start by discussing font characteristics in general and introduce the major attributes used in NFSS for orthogonal font switching. We then describe the use of the high-level interface-i.e., the commands a user normally has to deal with. This includes commands used in normal text (section 7.3), special features for use in mathematical formulas (section 7.4), and an overview of the packages available with NFSS (section 7.5). The next part of this chapter concerns the low-level interfaces that are useful when defining complex new commands and that are important when new fonts are to be A T E X . Finally we discuss all warning and error messages in made available in L section 7.8.

7.2 Understanding Font Characteristics


There are many design principles that divide fonts into individual overlapping classes. Knowledge of these characteristics often proves helpful when deciding which font family to use in a special context.

7.2.1 Monospaced and Proportional Fonts


Fonts can be either monospaced or proportionally spaced. In a monospaced font, each individual character takes up the same horizontal space regardless of its shape. In contrast, characters in a proportionally spaced font take up different amounts of space depending on the shape of the character (see figure 7.1). You can see that the 'i' of the monospaced font occupies the same space as the 'm,' while it is noticeably narrower in the proportional font. As a result, proportional fonts (also called typographcal fonts) normally allow more words to be placed on a page and are more readable than monospaced fonts. The extra spaces around individual characters of monospaced fonts make it more difficult for

iiiiiiiiii
(monospaced)

iiiii..iii
lTlllZllllllZlllllllllTLZnm

(proportionally spaced)

Figure 7.1: Major font characteristics

160

Font Selection

Figure 7.2: Comparison of serifed and sans serif letters

the eyes to recognize word boundaries and thus make monospaced text less readable. However, monospaced fonts do have uses. Withn the proper context, they enhance the quality of the printed document. For example, in tables or computer listings where proper alignment of information is important, a monospaced font is a natural choice. In computer science books, it is common to display computer programs in a monospaced font to make them easily distinguishable from surrounding explanations. But the use of monospaced fonts goes beyond marking portions of a document as special. One can even consider choosing a monospaced font as the base font for a complete document. Such a font has the flavor of the manual or electric typewriter engine; it looks handmade when used with unjustified paragraphs and therefore may be better suited to certain situations than a more professional-looking typographical font. Private letters are good candidates for monospaced type because the result looks more personalized. Keep in mind, however, that monospaced fonts look very poor when lines are justified. (See section 3.1.4 to learn how to turn off justification.)

7.2.2 Serifed and Sans Serif Fonts


Another useful classification is the presence or absence of serifs. Serifs are the tiny horizontal strokes at the extremities of character shapes (see figure 7.2). Originally serifs were produced by the chlsel,when roman capitals were engraved into stone. For this reason, serifed fonts are often referred to as "roman" fonts. Serifed fonts traditionally have been used for long texts because, it was argued, they are more readable. It was long thought that serifed letters give the eyes more clues for identification. T h s is certainly true if only parts of the characters are visible, but for fully visible text recent research has shown that reading speed is not substantially affected by the absence of serifs [75].

7.2.3 Font Families and Their Attributes


Besides the crude classifications of serifed vs. sans serif and monospaced vs. proportional, fonts are grouped into font famdies. Members of a font family share common design principles and are distinguished by variations in size, weight, width, and shape.

7.2 Understanding Font Characteristics

161

A A A

B B B

C C C

a a a

b b b

c c c

x x x

y y y

z z z

Figure 7.3: Comparison between upright and italic shapes The first line shows letters from the Computer Modern Serif family in upright shape, and the third line shows the same letters in italic shape. For better comparison, the second line gives the italic letters without the usual slant-i.e., the letters are artificially shown in an upright position. Font Shapes An important attribute when classifying a member of a font family is its shape. Of course, sometimes it is a matter of personal judgment whether a set of fonts with different shapes constitutes a single farmly or several. For example, Donald Knuth called his collection of 31 Computer Modern fonts a family [22,45],yet they form a meta-family of many families in the traditional sense.l Although there is no uniform naming convention for font shapes, this is unimportant as long as one sticks to one particular scheme within NFSS. Nearly every font famdy has one shape called the "upright" shape.2 For example, in the font family used in this book (Lucida Bright), the font that you are now reading is in the upright shape. Another important shape that is present in most families is the "italic" shape, which looks like this in the Lucida Bright family. Italic characters are slanted to the right and the individual letters generally are drawn differently from their upright counterparts, as shown in figure 7.3. Font families without serifs often lack a proper italic shape; instead they have a "slanted" shape in which the characters slant to the right but are otherwise identical to their upright counterparts. The terms "sloped" and "oblique" are also commonly used for this shape. Another common variant is the "small caps" shape, in which the lowercase letters are represented as capitals with a reduced height, as shown in figure 7.4.
~METAFONT,as a design tool, allows the production of completely different fonts from the same source description, so it is not surprising that in 1989 another family was created [45] based on the sources for the Computer Modern fonts. This family, Concrete Roman, was obtained merely by varying some METAFONT parameters in the source files; but since the result was so different, Knuth this time decided to give the family a different name. 'Sometimes you will also hear the term "roman" shape. This is due to the fact that until recently typesetting was nearly always done using serifed fonts. Thus, "roman" was considered to be the opposite of "italic" by many people. So be aware that in some books this term actually refers to the upright shape and not to a serifed font family.

162

Font Selection

EXAMPLE EXAMPLE EXAMPLE


(Normal Capitals) (Small Caps) (Faked Small Caps)

Figure 7.4: Comparison between caps and small caps If such a shape is not available for a specific family, typographers sometimes use upright capitals from smaller sizes,3but t h s practice does not produce the same quality as a well designed small caps font. Real small caps have different widths and weight than capital letters from the same font that have been reduced to the height of designed small caps (you can clearly see that the strokes in the faked capitals in figure 7.4 are much too thin). There are a few other, less important shapes. Some families contain fonts where the inner parts of the letters are drawn in a special fashion, most importantly perhaps the "outline" shapes, in which the inner parts of the letters are kept empty. For display purposes, some farmlies also contain fonts that could be classified as "shaded"-i.e., where the letters appear three-dimensional. Examples are shown in figure 7.5 on the next page. Special variants of the Computer Modern meta-family have been produced by setting the METAFONT parameters to special values. For example, there is "upright italic," a shape in which the individual letters are drawn in italic fashon but without the usual slant (see the second line in figure 7.3 on the preceding page). This shape was devised basically for showing the abilities of METAFONT as a tool for meta-design, but some users might take a fancy to such an unusual shape.

Weight and Width


Fonts of a certain shape within a family may differ in "weight." This characteristic refers to the thickness of the strokes used to draw the individual shapes. Once again, the commonly used names are not completely uniform, but it is relatively easy to arrive at a consistent classification. Some font manufacturers, for example, call the font weights intended to be used for normal text "book," while others call them "medium." For thin strokes the name "light" is common, while thicker strokes are usually called "bold." In larger font families, finer distinctions are often necessary, so that we sometimes find a range starting with "ultra light," going through "extra light," "light," "semi light," etc., and ending
3~ good rule of thumb is using capitals from a font that is about half a point larger than the x-height of the original font. See in section 7.7.2 on page 201 for a way to determine the x-height of any font used with TEX.

7.2 Understanding Font Characteristics

163

Figure 7.5: Outline and shaded shapes

with "ultra bold" at the other end. On the other hand, often only a few weights are present in a family. For example, the Computer Modern Roman family has only two weights, "medium" and "bold." Another equally important attribute of a font is its "width"-i.e., the amount of expansion or contraction with respect to the normal or medium width in the family. Computer Modern Roman has bold fonts in "medium width and "extended width." One application for condensed fonts is in marginal notes. Some typesetting systems can even condense fonts automatically to fit a given measure-e.g., to exactly fill a particular line in a heading. This capability is not directly possible with (LA)TEX,but in any case the results are often aesthetically questionable. Font Sizes Font sizes are traditionally measured in printer points (pt). There are 72.27 points to an inch. The font size is not an absolute measure of any particular characteristic; rather, it is just a value chosen by the font designer to guide the user. For example, in a lOpt font, letters of the alphabet are usually less then lOpt tall, and only characters like parentheses have approximately this height. Two fonts of the same size may not blend well with one another because the appearance of a font depends on many factors, such as the height of the lowercase letters (the so-called x-height), the depth of the descenders (the part of the letters below the baseline, as in the letter q), etc. In the (LA)TEXworld, fonts are often available in sizes that are powers of 1.2, i.e., in a geometric progression [39, p.171. T h s arrangement was chosen because it makes it easy to produce an enlarged master copy that later can be photographically reduced, thereby effectively enlarging the final output resolution. For example, if an A5 brochure is to be produced, one could print it with magnification of 1.44 fl on A4 paper. Photographic reduction from the 300 dpi (dots per inch) output of a normal laser printer would produce an effective output resolution of 432 dpi and thus would give higher quality than is normally possible with such a laser printer. However, this geometric ratio scheme used by (LA)TEXfonts produced with the METAFONT program is not common in the professional world, where the

164

Font Selection

Ten point type is different from magnified five point type

Figure 7.6: Scaled and designed fonts pointsizesusuallyfoundare 7, 8 , 9 , 10, 11, 12, 14, 16, 18, 20, 24, 30, and36. But not all fonts are available in all these sizes, and sometimes additional sizes are offered-e.g., so-called display sizes for large headings and tiny sizes for subscripts and superscripts. Note that the use of magnified or reduced fonts instead of fonts designed for a specific size is usually less than satisfactory, because to the human eye fonts do not scale in a linear fashion. The characters in handcrafted fonts of larger sizes usually are narrower than fonts magnified from a smaller size of the same family. While it is acceptable to scale fonts within a small size range, if necessary, one should use fonts designed for the desired size whenever possible. The difference between fonts scaled to a particular size and those designed for that size is shown in figure 7.6.

7.2.4 Encoding Schemes


To access a character from a font in a computer typesetting program, you need a way to specify that character in the input source. This point may seem trivial, since you can just type the 'A' on the keyboard when you want to get a typeset 'A' in the output, but what should you do to get a Spanish open-question mark (i)? This character is certainly not found on many computer keyboards. In (LAITEX, as in many other computer programs, this problem is solved by associating the characters in a font with numbers in the range of 0-255. Such a mapping is called a codepage or an encoding scheme. To illustrate what happens if we use a font with an encoding not suitable for our input, here is the the first sentence of this section again:
T o assecc a sapamep @ p oa~ @OHT RH a qoMnyTep TbIIIeCeTTMHP nporpaM, b~oy HeeA a qabr T O cneqaab~ TxaT sapaqTep aH Txe MHnyT coypqe.

The result is an interesting puzzle, but nothing that we want to see in ordinary documents. There are several methods in (LA)TEXto access characters in the current font. The most common method is to put a visible A s c n character into the source document, which is then translated into the glyph in the current font that is associated with that ASCII character number in the encoding of the font. For the fonts commonly used in (LA)TEX, the positions of the letters of the Latin alphabet

7.3 Using Fonts in Text

165

in the encoding are identical with their ASCII positions, so by typing an 'a'into the source document we get an 'a' in the output, rather than, say, '4.' But this mapping is not necessarily used for non-letters, as demonstrated by the input '< I >,' which comes out as 'i-i' in the standard (B)TEXencoding. More details and a table of the internally used encodings are given in sections 7.3.4 and 7.6.1.

7.3 Using Fonts in Text


When writing a IKQX document, appropriate fonts are normally chosen automatically by the logical tags used to structure the document. For example, the font attributes for a section heading, such as large size and bold weight, are defined by the document class and are applied when a \section command is used, so that you seldom need to specify font attributes yourself. However, occasionally it becomes necessary to specify font attributes directly. One common reason is the desire to change the overall font attributes, by choosing, for example, a different font family for the main text. This alteration often can be done by simply specifying an appropriate package. Some packages for this purpose are described in section 7.5, others are given in section 11.9. Another use for explicit font attributes can be to mark certain portions of the document as special-e.g., to denote examples, acronyms, company names, etc. For example, in this book, names of packages are formatted in a sans serif font. This formatting could be achieved by surrounding the names with \textsf C. .), but it is much better to define a new command (say, \Lpack) for this purpose so that additional information is added to the source document. B y defining individual commands for logically different things-even those that are currently being set in the same way-you will make it easier to change things consistently later. Last, but not least, in some cases you may wish to override a decision taken by the document class: you might want to typeset a table in a smaller size to make it fit on a page. This desire is legitimate, since document classes can format documents automatically only to a certain extent. Hand-formatting-like the insertion of page breaks, etc.-is thus often necessary for the final version. But explicit formatting makes further use of the document (if changes are made) difficult and error prone. Therefore, as with all visual formatting commands, you should try to minimize the direct use of font-changing commands in a document.

7.3.1 Standard NFSS Font Commands


The font used for the main text of a document is the "main font" or "normal font." It is automatically selected at the beginning of the document and also automatically selected in certain situations, such as in footnotes, figures, etc. Certain logical tags, like section headings, automatically switch to a different

166

Font Selection

typeface or size, depending on the document class. These changes happen behind the scenes, and the only action necessary by the author is to introduce the correct logical markup in the document. However, sometimes you want to highlight individual parts of the text, by choosing an appropriate typeface for it; this can be done with the commands described below. Most font change commands come in two forms: as a command with one argument, such as \textbf C . . .), and as a declaration form, for example \bf s e r i e s . The declarations do not take arguments but rather instruct L A T E X that from now on (up to the end of the current group of braces or environments) it should behave in a special way. Thus, you should not write something like \bf s e r i e s < . . .), as this would make everything bold from this point on to the end of the next environment. To change the fonts for individual words or short phases within your document you should make use of the font commands with one argument, whde declaration forms are often better in the definition of new environments or commands. For longer passages in your document, you can also use the environment form of the declaration (the declaration name without the preceding backslash) as shown in the following example:
Some words in this sentence are typeset in

bold letters.

Some words in this sentence are \begin{bfseries)typeset in bold\end{bfseries) letters.

A detailed comparison of command form and declaration form and their advantages and disadvantages in special situations is given in section 7.3.3.

The Main Document Font

To switch to the main document font you can use the command \textnormal or the declaration \normalf ont. They are usually only used in the definition of commands or environments when it is important to define commands that always typeset in the same font regardless of surrounding conditions. For example, the command to produce the command names in this book looks roughly like

avoiding the command names coming out like \ t h i s in certain places.


Standard Font Families

B y default, W&X maintains three font families that can be selected with short command sequences. These families are a serif text font, accessed with the command \textrm, a sans serif text font, accessed by \ t e x t s f , and a typewriter

7.3 Using;Fonts in Text

167

font (usually monospaced), accessed by \ t e x t t t . The declaration forms of these commands are \rmf amily, \sf f amily, and \ t t f amily, respectively. The names of the external font families accessed by these commands depend on the document class but can be changed by packages or in the preamble (see section 7.3.5). As an installation default, the serif font is Computer Modern Roman, the sans serif font is Computer Modern Sans, and the typewriter font is Computer Modern Typewriter. If you used a different setup, take care to define these default families so that the fonts can be mixed freely without visual clashes. You must also make sure that the external fonts exist in the correct resolution for the output device. In this book, the serif font family is Lucida Bright, the sans serif family is Lucida Sans and the typewriter family is Computer Modern Typewriter. These have been chosen by simply adding the package lucid brb.4 In most document classes, the serif font, accessed by \textrm, is also the main font of the document, so the command \textrm is not used often. But if a document designer has chosen a sans serif font as the main typeface, then \textrm would be the alternative font family.
Standard Font Series

Another attribute of a typeface that can be changed is the series. In NFSS the series is a combination of two attributes: width and weight (boldness). NFSS provides two commands for changing the series: \textmd and \ t e x t b f ; the corresponding declarations are \mdseries and \bf s e r i e s . The first command will select a font with medium values for the width and the weight, while the latter will switch to a bolder series. The actual values will depend on the document class and its options or subsequent packages. As a default for the Computer Modern families, \ t e x t b f will switch to a bold extended version of the current typeface, while \textmd will return to the medtum width and medium weight version of the current typeface. If finer control over the series attribute is desired, it is best to define additional high-level commands using the lower-level \f o n t s e r i e s declaration described in section 7.6.1. Some packages that make large font families available for use with L A T E X sometimes provide such extra commands.
Standard Font Shapes

A third font attribute that may be changed independently of the others is the shape of the current typeface. The default shape for most documents is the upright shape which can be accessed, if necessary, with the command \ t e x t u p or the declaration \upshape.
4 ~ get o Computer Modern Typewriter as the typewriter family we additionally redefined
\ttdefault to produce cmtt; see section 7.3.5 for more details on changing the default text

fonts.

168

Font Selection Probably the most important commands for changing the shape are \ t e x t i t and \ t e x t s c , which switch to an italic or CAPS AND SMALL CAPS font shape. The corresponding declarations are \ i t s h a p e and \scshape. An alternative to \ t e x t i t is the \ t e x t s 1 command (its declaration form is \slshape), which switches to the slanted shape. Often a font family only contains either an italic or a slanted shape, but Computer Modern Roman contains both. At the point where one switches from slanted to upright, the characters usually come too close together, especially if the last slanted character has an ascender. The proper amount of extra white space that should be added at this boundary is called the "italic correction." The value of this adjustment depends on the individual character shape and is therefore stored in the .tfm file. The italic correction will be automatically added by the font commands with arguments but must be inserted manually using \ / when declarations are used. For an upright font, the italic correction of the characters is usually zero or very small, but there are some exceptions. (In Computer Modern, to typeset a bold 'f' in quotes, you should say ' (\bf s e r i e s f \/) ' or ' \ t e x t b f (f 3 ' , lest you get a bold 'f in some fonts.) In slanted or italic fonts the italic correction is usually positive, with the actual value depending on the shape of the character. Thus the correct usage of shape-changing declarations that switch to slanted shapes is:
\raggedright When switching back from < \ i t s h a p e i t a l i c \ / ) o r <\slshape s l a n t e d \ / ) shapes t o an upright f o n t one should add t h e {\itshape i t a l i c correction), except when a small punctuation c h a r a c t e r follows.

( L 17)

When switching back from italic or slanted shapes to an upright font one should add the italic correction, except when a small punctuation character follows.

If you use the command forms with one argument instead, the italic correction is automatically added. See the further discussion of this topic in section 7.3.3. Small capitals are sometimes used in headings or to format names. For the latter case you can, for example, define the command \names with one of the following definitions:

or, using declarations,

The first definition simply switches to the desired shape, while the second form first resets all font attributes to their default. Which one should be used depends on the available fonts and on the type of document. If Computer Modern is being used, only the serif family contains a small caps shape, so the second definition

7.3 Using Fonts in Text

169

might be preferred in certain applications because it will use small caps even in a \ s f f amily context. The first command would result in a request for a medium series small caps shaped font in the Computer Modern Sans family. Because t h s font is not available, NFSS would try to find a substitute by first changing the shape attribute to its default, with the result that you would not get small caps. (See section 7.6.3 for further information about substitutions.) Another interesting use of the \scshape declaration is in the definition of an acronym tag in the following way:

This definition makes use of the TEXprimitive \lowercase that changes all characters withln its argument (or more exactly, only the characters that do not belong to command names) to lowercase. As a result, all characters in the argument of \ a c r o will be changed to lowercase and therefore typeset with small capitals. X is the \emph comAnother slightly special shape command available in m mand. This command denotes emphasis in normal text; the corresponding declaration is \em. Traditionally, emphasized words in text are set in italic; if emphasis is desired in an already italicized portion of the text, one usually returns to the upright font. The \emph command supports this convention by switching to the \ i t s h a p e shape if the current font is upright, and to the \upshape if the current font is already slanted (i.e., if the shape is \ i t s h a p e or \slshape). Thus the user does not have to worry about the current state of the text when using the \emph command or the \em declaration.
Nevertheless, one has to be careful about the proper use o f italic corrections on both ends o f the emphasized text. It is therefore better to use the \emph command, which automatically takes care of the italic correction on both sides.

(L 16,38)

\em Nevertheless, one has to be careful about the\/ \em proper\/) use of italic corrections on both ends of the emphasized text). It is therefore better to use the \verb=\emph= command, which \emphautomatically) takes care of the italic correction on both sides.

Note that underlining for emphasis is considered bad practice in the publishing world. Underlining is only used when the output device can't do highlighting in another way-for example, when using a typewriter. But section 3.1.2 discusses a package that changes \em to produce underlining.
Standard Font Sizes
IFl$X has ten size change declarations (see table 7.1 on the following page). Since size changes are normally used only in the definition of commands, they have no corresponding command forms with one argument. The names of the declarations have been retained in NFSS, but their functionality has changed slightly. In NFSS a size change command changes only the size of the current font and all other attributes stay the same; while in the old font selection scheme

(L 115,200)

170

Font Selection

\tiny \scriptsize \footnotesize \small

Size

size

Size
Size

\normalsize \large \Large \LARGE

Size

\huge \Huge

Size

Size

Size

Size

Size

Table 7.1: The standard size-changing commands of L Q X 2.09 a size change command also automatically switched to the main document font. In both and old E Q X the size selected by these commands depends on the settings in the document class file and possibly on options (e.g., 1 1 pt) to it. In general, \normalsize corresponds to the main size of the document, and the size change commands form an ordered sequence starting with \tiny as the smallest up to \Huge as the largest size. Sometimes more than one command refers to the same real size; for example, when a large \normalsize is chosen, \Huge can be the same as \huge. But the order is always honored. Unfortunately, there is currently no relative size change command in LATEXe.g., there is no command for requesting a size 2pt larger than the current one.

7.3.2 Combining Standard Font Commands


As already shown, the standard font-changing commands and declarations can be combined. The result is the selection of a typeface that matches the combination of all font attributes. For example:
One can typeset a text in a large sans

serif bold typeface.

one can typeset a t e x t {\sffamily\bfseries \large i n a large sans serif bold typeface.)

What happens behind the scenes is that the \sff amily command switches to the sans serif default family, then \bf series switches to the default bold series in this family, and \large finally selects a large size with all other font attributes unchanged. Font metric files (i.e., .tfm files) are loaded for all intermediate typefaces, even if these fonts are never used. In the preceding example, they would be 'sans serif medium 10pt' after the \sffamily, then 'sans serif bold extended 10pt' after the \bf series,then 'sans serif bold extended 14pt,' which is the font that is then finally used. Thus such high-level commands can force NFSS to unnecessarily load fonts that are never used. This normally does not matter, except for a small loss of processing speed when such a combination is used for the first time. However, if you have many different combinations of this type, you should consider defining them in terms of the primitive font-changing declarations (see section 7.6).

7.3 Using Fonts i n Text

171

Command

Corresponds to
{\rmf amily . . . } {\sf f amily . . .) {\ttf amily . . .) {\mdseries . . .) {\bf series. . .) {\upshape. . .) {\itshape. . .) {\slshape . . .) {\scshape . . . I {\em.. .) C\normalf ont

. .1

Action Typeset text in roman family Typeset text in sans serif family Typeset text in typewriter family Typeset text in medium series Typeset text in bold series Typeset text in upright shape Typeset text in italic shape Typeset text in slanted shape Typeset text in SMALL CAPS shape Typeset text emphasized Typeset text in the document font

Table 7.2: Font-changing commands and declarations The font-changing commands with arguments all start with \text. . . (except for the \emph command) to emphasize that they are for use in normal text and to be easily memorizable. They automatically take care of any necessary italic correction on either side of the argument.

7.3.3 Font Commands versus Declarations


We have already seen some examples of font commands that have arguments and change font attributes. Using such commands instead of the declarative forms has the advantage of consistency with other L A T E X structures. These commands are intended for typesetting short pieces of text in a specific famdy, series, or shape. Table 7.2 shows the effect of all such commands. A further advantage of using these commands is that they automatically take care of any necessary italic correction on either side of their argument. Thus, when using such commands, one does not have to worry about forgetting the italic correction when changing fonts. Only in very few situations is this additional space wrong; for example, most typographers recommend ornitting the italic correction if a small punctuation character, like a comma, directly follows the font change. Since the amount of correction required is partly a matter of taste, you can define in what situations the italic correction should be suppressed. This is done by specifying the characters that should cancel a The default definition for preceding italic correction in the list \no~orrlist.~ this command is

5 ~ npackage y that changes the \catcode of a character inside \nocorrlist must redeclare the list. Otherwise the changed character will no longer be recognized by the suppression algorithm.

172

Font Selection
It is best to declare the most often used characters first, because this will make the processing slightly faster. In addition to the global custornization it is possible to suppress the italic correction in individual instances. For this, the command \nocorr is provided. Note that you have to put \nocorr on the left or right end inside the argument of the \text. . . commands, depending on which side of the text you wish to suppress the italic correction.

When using the NF55 high-level commands, the proper use o f italic corrections is automatically taken care o f . Only sometimes one has to help ETEX by adding a \nocorr command.

\emphCWhen using the \NFSSC) high-level commands, the \emphCproper) use of italic corrections is automatically taken care o f ) . Only \emph{sornetimes) one has to help \LaTeX{) by adding a \verb=\nocorr= command.

In contrast, the use of the declaration forms is often more appropriate when you define your own commands or environments.
This environment produces boldface items.
It is defined in terms of LaT~x's itemize environment and NFSS declarations.

\newenvironment{bf itemize) C\begin{itemize)\normalfont\bfseries) ~\end~itemize)> itemize) \item This environment produces boldface items. \item It is defined in terms of \LaTeX1s \textttCiternize) environment and NFSS declarations. \end(bfitemize)

7.3.4 Accessing All Characters of a Font


Sometimes it is impossible to enter a character directly from the keyboard, even though the character exists in the font. Therefore, many useful characters are accessible via command names like \ss or \AE, which produce '13' and 'A?. Other characters are implicitly generated from sequences of letters ( t h s is a property in the of fonts) like ffi, which produces 'ffi,' and ---, which produces standard TEX fonts. In addition, there is the command \symbol, which allows you to access any character in a font by giving its number in the current encoding scheme as either a decimal, octal (preceded by ), or hexadecimal (preceded by ") number.
I-'

(L 40)

(L 200)

In the Cork font encoding (Tl),characters like P, 5 , and LI are included and can be accessed with the \symbol command.

In the Cork font encoding (\textttCTl)), characters like \symbolC"DE), \symbolC1237), and \symbol{32) are included and can be accessed with the \verb=\symbol= command.

The numbers corresponding to the characters in any font can be obtained by using the program nf ssf ont .tex, described in section 7.5.5.

7 . 3 Using Fonts in Text

173

Hook
\familydefault \seriesdefault \shapedefault \rmdefault \sfdefault \ttdefault \bfdefault \mddefault \itdefault \sldefault \scdefault \updefault

Default value Description


Encoding scheme for 'main font' Family selected for 'main font' Series selected for 'main font' Shape selected for 'main font' Family selected by \rmfamily and \textrm Family selected by \sffamily and \textsf Family selected by \ttfamily and \texttt Series selected by \bf series and \textbf Series selected by \mdseries and \textmd Shape selected by \itshape and \textit Shape selected by \slshape and \texts1 Shape selected by \scshape and \textsc Shape selected by \upshape and \textup Table 7.3: Font attribute hooks
\rmdefault m n cmr cmss cmtt bx m it s1 sc n

\encodingdefault OTI

For easy access to "old-style numerals," e.g., 1982, NFSS provides the command \oldstylenums,whch can be used in text and within formulas. In its argument you should place the digits that you want to typeset as nonaligning digits. If used in text, spaces in the argument are honored, but you should not try to put characters other than digits into it or the results will be unpredictable.

7.3.5

Changing the Default Text Fonts

To make it easier to modify the overall appearance of a document, NFSS provides a set of built-in hooks that modify the behavior of the high-level font-changing commands discussed in the previous sections. These hooks are shown in table 7.3. The values of these hooks can be set in package files or in the preamble of a document by using \renewcommand. Suitable values for these commands can be found by looking through the font tables in this chapter. For example, by writing in the preamble

a whole document would come out in Computer Modern Sans, because this redefinition changes the font family for the main font used by NFSS. More exactly, the main document font is determined by the values of \encodingdefault, \familydefault, \seriesdefault, and \shapedefault. Thus, you have to

174

Font Selection
make sure that these commands are defined in such a way that their combination points to an existing font shape in NFSS internal tables. The default value stored in \encodingdef ault currently is OTi,which means that NFSS assumes that most fonts use the original TEX encoding. A new standard, called the Cork encoding (see section 7.5.1), is expected to supplant the original TEX encoding. At that point, the default value of \encodingdef ault will be changed to T I . See also section 7.6.1 for more information on encoding schemes. Another example, this time involving a series-changing command, would be to define \bfdef ault to produce b so that the \bf series command will use bold instead of bold extended, which is the default under Computer Modern. However, there is some risk in using such a setting since, for example, in Computer Modern only the Roman family has bold variants with a medium width. Computer Modern Typewriter and Computer Modern Sans only have bold extended variants. Thus, without further adjustments, a request for, say, a bold sans serif font (i.e., \sff amily\bf series),would force NFSS to try font substitution, and finally select a medium-weight font. (But this outcome can be avoided, as explained in section 7.7.2, by specifying that the bold extended variants of the sans family should serve as substitutes for the bold medium ones.) Example in which some default values are changed can be found in the chapter about Postscript (section 11.9). The initial setting of \f amilydef ault means that changing only \rmdef ault will also change \familydefault to the new value as long as no special setting for \f amilydef ault is defined. However, if \f amilydef ault gets changed \rmdef ault is not affected.

7.3.6 W X 2.09 Font Commands


The two-letter font commands used in L A T E X 2.09, like \bf, are no longer defined A T E X Z Edirectly. Instead, they are defined in the W X Z E class files. For comby L patibility reasons the standard classes provide definitions for these commands that emulate their behavior in E Q X 2.09. However, it is legitimate for you to redefine them in a package or in the preamble according to your personal taste, something you should not do with basic NFSS commands like \bf series.

7.4 Using Fonts in Math


Unlike the situation in text, automatic changes in font shapes are generally not desired in math formulas. For mathematicians, individual shapes convey specific information: for example, bold upright letters may represent vectors. If the characters in a formula were to change because of surrounding conditions, the result would be incorrect. For this reason handling of fonts in mathematical formulas is different than in text.

7.4 Using Fonts in Math

175

Characters in a formula can be loosely put into two classes: symbols and alphabet characters (including digits). Internally, (LA)TEXdistinguishes between eight types of math characters (to account for appropriate spacing), but for the user the division into two classes is generally enough. Some symbols like = can be entered directly from the keyboard, but the bulk of them must be entered via a control sequence-e.g., \leq stands for r . The other main group of characters in a formula, the alphabet characters, are entered normally directly from the keyboard. Over two hundred symbols are predefined in a standard (LA)TEXsystem, thus allowing the user to typeset almost any desired formula. These symbols are scattered over several fonts, but they are accessed in such a way that the user does not to have to be aware of their internal representation. If ever necessary, further symbol fonts can be made accessible in a similar way; see section 7.7.6. The most important difference between symbols and alphabet characters is that symbols always have the same graphical representation withn one formula, while it is possible for the user to change the appearance of the alphabet characters. We will call the commands that change the appearance of alphabet characters in a formula "math alphabet identifiers" and the fonts associated with these commands "math alphabets." These alphabet identifiers are independent of surrounding font commands outside the formula, so that a formula does not change if it is placed (for example) inside a theorem environment whose text is, by default, typeset in italics. This behavior is very important, since character shapes in a mathematical formula carry a meaning that must not change because the formula is typeset in a different place in a document. Some people used to the old method of font selection may be surprised by the fact that commands like \bf s e r i e s cannot be used in formulas. T h s is the price we have to pay for the greater flexibility in choosing text font attributes-a flexibility that we do not want in a formula. W e therefore need a different mechanism (math alphabet identifiers) for changing the typeface of certain alphabet characters in complicated formulas.

7.4.1 Special Math Alphabet Identifiers


One alphabet and a huge number of symbols are not sufficient for mathematicians to express their thoughts. They tend to use every available typeface to denote special concepts. Besides the use of foreign alphabets like Greek letters, which usually are accessed as symbols-\alpha, \beta, etc.-we find sans serif letters for matrices, bold serif letters for vectors, and Fraktur fonts for groups, ideals, or fields. Others use calligraphical shapes to denote sets. The conventions are endless, and-even more importantly-they differ from one discipline to another. For this reason NFSS makes it possible to declare new math alphabet identifiers and associate them with any desired font shape group instead of relying only upon a predefined set that cannot be extended. These identifiers are special commands for use in a formula that typeset any alphabet character

176

Font Selection

Command
\mathcal \mathrm \mathbf \mathsf \mathtt \mathnormal \mathit

Example
$\mathcal{A)=a$ $\mathrm{max)-i$ $\sum x = \mathbf{v)$ $\mathsfCG)-IA2$ $\mathttCW) ( a >$ $\mathnormal{abc)=abc$ $dif f er\neq\mathit{dif f er)$

d =a maxi cx=v
C:

w(a) abc = abc d i f f e r * differ

Table 7.4: Predefined math alphabet identifiers in NFSS As the last lines show, the letters used in formulas are taken by default from the math alphabet \mathnormal. In contrast, the letters produced by \mathit have different spacing; thus t h s alphabet could be used to provide full-word variable names, which are common in some disciplines. in their argument in a specific typeface. (Symbols cannot be changed in this way.) It is possible for these identifiers to use different typefaces in different formulas, as we will see in section 7.4.3, but withm one formula they always select the same typeface regardless of surrounding conhtions.

Predefined Alphabet Identifiers


New math alphabet identifiers can be defined according to the user's needs, but NFSS already has a few built in. These identifiers are shown in table 7.4. In NFSS math alphabet identifiers are commands with one argument, usually a single letter or a single word to be typeset in a special font, e.g.,
Therefore C can be computed as
n

Therefore $\mathsfCG)$ \beginCequation)

can be computed as

(7.1)

~ = d + x % ~
i=l

\mathsfCG) = \mathcalCA) + \sum-Ci=l)-Cn) \endCequation)

\mathcal{B)-Ci)

This procedure differs from the way font commands were used before in L A T E X 2.09, where commands like \ r m would cause font changes (. .{ \ r m A). .). (For the most important two-letter font-changing commands like \ r m , \ s f , \bf, \it, and \tt the old syntax is still supported in the standard classes and for the others you can force the old behavior by specifying the package oldlfont; see section 7.5.5. However, we suggest that you refrain from using such commands in new documents.) As already mentioned, another difference between the old font selection scheme and NFSS is that text font declarations are no longer allowed in formulas, since they only change some characteristic of the current font rather

7.4 Using Fonts in Math

177

than switching to specific fonts. Thus, if you write C\bf s e r i e s . . I instead of \mathbf C . . 3 in a formula, NFSS will produce an error message. The command names for the math alphabet identifier are chosen to be descriptive rather than simple to type-i.e., they all start with \math. Therefore, if you use the commands more than occasionally in your document, consider defining some abbreviations in the preamble, for example

You may wonder what the default math alphabet is-i.e., from what alphabet the alphabet characters are selected if you do not specify an alphabet identifier explicitly, as in the formula $x = 123$. The answer is that there is no single default math alphabet. The (LAITEX system can be set up so that alphabet characters are fetched from different alphabets as long as the user has not explicitly asked for a specific one, and this is normally the case, as the following example shows.

As you can see, \mathrm does not change the digits and \mathnormal does not change the letters, thus the default for digits in the normal setup is the math alphabet associated with \mathrm and the default for letters is the one associated with \mathnormaL6 This behavior can be controlled with the \DeclareMathSymbol command, which is explained in section 7.7.6.
Defining New Alphabet Identifiers

New math alphabet identifiers are defined with the \DeclareMathAlphabet command. Suppose that you want to make a slanted sans serif typeface available as a math alphabet. First you decide on a new command name, such as \mathsf s l , that should be used to select your math alphabet. Then you consult the font tables in this chapter (starting on page 181)to find a suitable font shape group to assign to this alphabet identifier. You will find that there is, for example, the Computer Modern Sans family, consisting of a medium series with upright and slanted shapes. If you decide to use the slanted shape of this family, you tell NFSS by adding the following line to your preamble or package file:

6~ith the default setup of W X Z E using Computer Modem math fonts, \mathnormal will produce old style numerals, not the italic ones shown in the example, where Lucida is used.

178

Font Selection
More formally, \DeclareMathAlphabet has four arguments besides the identifier: the encoding scheme, the f a y , the series, and the shape of the font to be used. Now your alphabet identifier is ready for use in a formula: it will always switch to Computer Modern Sans medium slanted.

We demonstrate this with the formula


(7.5)

C A=~ atanp

We demonstrate this with the formula \beginCequation) \sum \mathsfslCA)-Ci) = a \tan \beta \end{equation)

It is also possible to redefine an existing math alphabet identifier in a package file or in the preamble of your document. For example, the declaration

will override the default settings for the \mathsf alphabet identifier. After that, \mathsf will switch to Pandora Sans in your formulas.

7.4.2 Text Font Commands in Math


As mentioned previously, text font declarations like \rmfa m i l y cannot be used in math. However, the font-changing commands with arguments-e.g., \textrmcan be used in both text and math. You can use these commands to temporarily exit the math context and typeset some text in the midst of your formula that logically belongs to the text surrounding the formula. Note that the font used to typeset t h s text will depend on surrounding conditions-i.e., it will pick up the current values of encoding, family, series, and shape, as in the next example.
The result will be
\sffamily The result will be \ [ x = 10 \textbf{ and thus 1 y = 12 \I

= 10 and

thus y = 12

As you see the Sans family was retained and the series was changed to bold. Perhaps more useful is the \text command, provided by the amstext package, which picks up the current values of encoding, family, series, and shape without changing any of them (see section 8.3.12).

7.4.3 Mathematical Formula Versions


Besides allowing parts of a formula to be changed by using math alphabet identifiers, NFSS also lets you change the appearance of a formula as a whole. Formulas are typeset in a certain "math version," and you can switch between math versions outside of math mode by using the command \mathversion,thereby changing the overall layout of the following formulas.

7 . 4 Using Fonts in Math


NFSS knows about two math versions called "normal" and "bold." Additional ones can be provided in special packages. For example, the concrete package (see section 7.5.1) sets up a math version called "euler" to typeset formulas in the same way as it was done in the book Concrete Mathematics [221. As the name indicates, \mathversion(normal) is the default. In contrast, the bold version will produce bolder alphabet characters and symbols. The following example shows the same formula first in the normal and then in the bold math ~ e r s i o n . ~

179

Using \mathversion might be suitable in certain situations like headings, but remember that changing the version means changing the appearance (and perhaps the meaning) of the whole formula. If you want to darken only some symbols or characters within one formula, you should not change the \mathversion. Instead, you should use the \mathbf alphabet identifier for characters and/or use the command \boldsymbol provided in the package amsbsy; see section 8.2.1 and table 8.1 on page 218. If you change the mathversion with the \mathversion command, NFSS looks in its internal tables to find out where to go to fetch all the symbols for this new math version. It also may change all or some of the math alphabet identifiers and associate them with other font shapes in this version. But what happens to any math alphabet identifiers that you have defined yourself, like the \mathsfsl in the earlier example? As long as you only declared them using \DeclareMathAlphabet, they will stay the same in every math version. If the math alphabet identifier is to produce a different font in a special math version, you must inform NFSS by using the \SetMathAlphabet command. For example, in the default setup the \mathsf alphabet identifier is defined to be:

The first line means that the default for \mathsf in all mathversions is Computer Modern Sans medium, and the second line states that in the bold math version
historical reasons NFSS has two additional commands to switch to its standard math versions: \boldmath and \unboldmath.

ma or

180

Font Selection the font Computer Modern Sans bold extended should be used instead. From the previous example, you can see that \SetMathAlphabet takes six arguments: the first is the name of the math alphabet identifier, the second is the math version name for which you are defining a special setup, and the other four are the encoding, family, series, and shape name you are associating it with. As noted earlier, it is possible to redefine an existing math alphabet identifier using \DeclareMathAlphabet. If you do this, all previous \SetMathAlphabet declarations for this identifier are removed from the internal tables of NFSS so that it will come out the same in all math versions unless you add new \SetMathAlphabet declarations for this identifier.

7.5 Standard Packages


Several packages are distributed with NFSS and are described in this section. Many others can be obtained from various electronic archives or from TEX organizations; you will find information on them in appendix B. Also, all of the font farmlies described below are freely available as METAFONT source code.

7.5.1 Providing New Text Fonts


One of the important advantages of using NFSS is the ease with whch new fonts for use in the main text can be integrated. Besides the Computer Modern famihes, whch are used by default, one can easily use other font families by adding the appropriate package after the \documentclass command. Of course, for successful processing and printing the corresponding font files (e.g., the .tfm and .pk files) must be installed on the system. The DC Fonts E X Users conference in Cork (1990), a standard encoding for text fonts At the T (TI)was developed that contains many diacritical characters (see table 9.1 on page 261) and allows typesetting in over thirty languages. At the University of Bochum (under the direction of Norbert Schwarz) the Computer Modern font families were then reimplemented, and additional characters were designed, so that the resulting fonts completely conform to this encoding scheme. Currently these fonts are released under the name DC fonts; the final version will be called "EC fonts." Their use is hghly recommended, and we hope that most other font families will soon be available in this encodmg scheme. By specifying the package tl enc after the \documentclass command, the Cork encoding (TI) is made the default encoding. Consequently, instead of using Computer Modern in OTI encoding, L A T E X uses the DC fonts. Postscript fonts can also be used with the Cork encoding; see section 11.10.

7.5 Standard Packages

181

family

series

shape(s)

Example of typeface

Computer Modem Roman (TI, OTI)

I cmr I

1 crnr 1
cmr cmss cmss cmss cmtt cmfib cmf r cmdh

m bx b m bx sbc m m m

n, it, sl, SC, u n, it, sl n n, sl n n n, it, sl, sc n n, it n

COMPUTER ROMAN SMALL C A P S Comp. Mod. Roman bold eztended italic Computer Modern Roman bold upright
Computer ~ o d e r n Sans slanted

/I
I

Computer Modern Sans (TI, OTI)

Computer Modern Sans bold extended Computer Modern Sans semibold condensed
C o m p u t e r Modern T y p e w r i t e r i t a L i c

Computer Modem Typewriter (TI, OTI) Computer Modem Fibonacci (TI, OTI)
Computer Modern Fibonacci

Computer Modem Funny Roman (TI, OTI)


computer Modern Funny Roman

Computer Modern Dunhill (TI, OTI)

Computer Modern Dunhill

Table 7.5: NFSS classification of the Computer Modern fonts

The Concrete Fonts

For the text of the book Concrete Mathematics [22], Donald Knuth designed a new typeface, to go with the Euler mathematics fonts designed by Hermann Zapf. This font family, called "Concrete Roman," was created from the Computer Modern METRFONT sources by supplying different parameter settings. Thus, starting from the work done for the D C fonts, it was relatively easy to create Concrete Roman fonts with the Cork encoding; a suitable set of METAFONT driver files is part of the NFSS distribution. The fonts available in these families are shown in table 7.6 on the following page. To access these font families in normal text it is best to use the package beton (by Frank Jensen), whch also takes care of small but important typographical details, like slightly enlarging the \baselineskip value. There is also the package concrete that, in addition to setting up Concrete Roman for text, defines a new math version named euler. This file, together with its documentation, can serve as a template for people who want to define their own combination of text and math fonts.

182

Font Selection

family
I

I series / shape(s) /
(
c
m

EMmple of the typeface


I

I ccr I m
ccr
I

I Concrete Roman ( T i . OT1) 1

I
Concrete Roman medium
Concrete Roman condensed slanted

n, sc sl it

(
I

(
I

Concrete Math (OML)


ccm

I Concrete Math u R

Table 7.6: The Concrete families

family

series

I shape(s)

Example of the typeface

Pandora Roman (OT1) n, sl m panr b n Panr Pandora Sans (OT1)


PSS IPss m Ib n, sl In

Pandora Roman medium Pandora Roman bold Pandora Sans medium slanted

Pandora Sans bold

Table 7.7: The Pandora families


The Pandora Fonts

The Pandora families designed by Nazeen N. Billawala consists of the Pandora Roman family and Pandora Sans family [ll,121. The complete set of variants is shown in table 7.7. Unfortunately, both families are currently available only E X encoding (OTI). To use Pandora as the main text it is best in the traditional T to load the pandora package after the \documentclass command.
Typesetting with Old German Fonts

There is a set of beautiful fonts for typesetting in bo@itdj, alfo rallea E e r u r r (Gothisch, also called Textur),Sd)waba+r (Schwabacher),and Sraftur (Fraktur)designed after traditional typefaces by Yannis Haralambous [25]. The collection also contains a font for initials that is shown in figure 7.7 on the facing page. To access these fonts, use the package oldgerm after the \documentclass command. This package defines the commands \gothf amily, \f rakf amily, and

7.5 Standard Packages

183

Figure 7.7: The Initial font y i n i t by Yannis Haralambous This font is set up as family y i n i t , series m, shape n, and encoding U.

family
ygoth yfrak yswab

I series I shape($
Gothic (U)

Example of the typeface

m
m

n n n

dannb botl~ic
gannil $Jrattur

Fraktur (U) Schwabacher (U)

Im

Zannie 6@wabc+er

Table 7.8: The Old German text font families Because these fonts contain many ligatures, necessary for traditional typesetting, and therefore do not follow any standard encoding, they are set up for NFSS with U encoding.
\swabf amily to switch to the corresponding font families. Since these families only consist of one shape in one series, commands like \bf s e r i e s or \ i t s h a p e have no effect when typesetting in these families. However, size-changing commands are honored. In addition, the package defines the corresponding font commands with arguments-that is, \ t e x t g o t h , \ t e x t f r a k , and \textswab.

7.5.2 Providing New Math Fonts


The Euler Fonts As mentioned above, Hermann Zapf designed a beautiful set of fonts for mathematics-upright characters with a handwritten flavor-named after the famous mathematician Leonhard Euler. These fonts can be accessed by specifying the package euler. This package does not provide an additional math

184

Font Selection

family eur eur eus euf

I series / shape(s)
m b m m n n n n

Example of the typeface Euler Roman medium Euler Roman bold

Euler Roman (U)

Euler Script (U)

EULE2 S ~ 2 W " S
Euler Trattur

Euler Fraktur (U)

Table 7.9: The Euler math families The fonts in the current distribution of the Euler math families, unfortunately, are available only in encoding schemes that differ from all other encoding schemes for mathematics. As a result, you need to redeclare several math symbols if these fonts are used (this is done by the package euler). For this reason, the fonts are assigned the encoding U until they have been reencoded.

version; instead it modifies the normal and the bold math versions so that they produce characters from these font families. If only the Se23IPT alphabet of the Euler fonts is of interest, you can use the euscript package, which makes this math alphabet available under the name \EuScript. To access the Eu[er Srattur fonts in formulas, use the package eufrak, which defines the math alphabet \EuFrak for you. The complete set of fonts in these families is shown in table 7.9. latexsym-Providing L A T E X Symbols Eleven math symbols provided by L A T E X 2.09 are no longer defined in the base setup of NFSS. These are

If you want to use these symbols specify the latexsym package in your document. Alternatively, these symbols are made available if you load the amsfonts or the amssymb package; see also section 8.6.5.

7.5 Standard Packages

185

Special Math Extension Fonts Normally the font used for large mathematical symbols is available in only one size. This is usually sufficient, since most of the characters included are available in several different sizes in this font and (LA)TEXis specially equipped to automatically chose the best fitting size. However, when a document requires a lot of mathematics in large sizes-e.g., in headings-the selected symbols may appear to be too small. In this case, you can use the package exscale, whch provides for using different math extension fonts. If this package is used, you need scaled versions of the cmexio font in the sizes 10.95pt, 12pt, 14.4pt, 17.28pt, 20.74pt, and 24.88pt. Additionally, cmex variants for the sizes 7pt to 9pt are necessary. These fonts are part of the AMS font package and can be found on many servers.

7.5.3 s lides-Producing Overhead Slides


For producing overhead slides with the original font selection, it was necessary to A T E X variant called SLITEX, since a completely different set of fonts use a special L was necessary. However, nowadays the same effect can be achieved simply by using the document class slides, whch provides basically the same functionality L I T E Xprogram. as the original S There are several advantages to this NFSS class: you do not need a special precompiled format file and you are able to choose special fonts for your slides simply by selecting appropriate packages. For example, if you have the Postscript Times family, you can produce slides using this family by saying

(1 131-38)

7.5.4 Processing Older Documents


oldlfont-LATEX 2.09 Compatibility fromI4T~X 2.09 in several ways As we have seen, NFSS-and thus YT~X2~-differS in the treatment of font commands. T h s difference is most noticeable in math formulas where commands like \bf series are not supported. Nevertheless, it is very simple to typeset older documents with NFSS. If you only want to reprint a document, m X z E will see the \documentstyle command and automatically switch to compatibilitymode emulating the old font A T E X selection mechanism of W X 2.09 as described in the first edition of the L book. Alternatively, you can add the package oldlfont after the \documentclass command. If you do so, all old font-selecting commands will be defined, fontchanging commands cancel each other and all these commands can be used in mathematical formulas.

186

Font Selection

Some authors may have used internally defined font commands like \ t w l r m or \ n i n t t in their documents. Such commands now generate an error message, because they are no longer defined (not even in compatibility mode). One reason they are not supported is that they were never available at all installations. To process a document containing such explicit font-changing commands you have to define them in the preamble using the commands described in section 7.6. For example, for the above commands, it would be sufficient to add the d e h t i o n s

to the preamble. Reusing parts of documents also is very simple: just paste them into the new document and watch what happens. There is a good chance that NFSS will happily process the old document fragment and, if not, it will explicitly inform you about the places where you have to change your source.
newlfont-NFSS1 Compatibility

In the first release of NFSS, the two-letter font-changing commands were redefined to modify individual attributes only-e.g., \ s f or \it behaved just hke the NFSSZ commands \ s f f amily and \ i t s h a p e . If you prefer this behavior for the shorthands, just load the package newlfont after the \documentclass command.

7.5.5 Special Packages for NFSS


synton ly-Checking

Syntax Only

The package syntonly implements the \syntaxonly declaration for L A T E X . This command can then be used in the preamble to run a document through W X for syntax checking (without getting any output), which goes about four times as fast as normally.
tracefnt-Tracing NFSS

The package tracefnt can be used to detect problems in the font selection system. This package supports several options that allow you to customize the amount of information displayed by NFSS on the screen and in the transcript file.
errorshow This option suppresses all warnings and information messages on

the terminal; they will be written to the transcript file only. Only real errors will be shown. Since warnings about font substitutions and so on can mean that the final result will be incorrect, you should carefully study the transcript file before printing an important publication.

7.6 The Low-Level Interface

187

warningshow When this option is specified warnings and errors are shown on the terminal. This setting gives you the same amount of information as w X Z E does without the tracefnt package loaded. infoshow This is the default when you load the tracefnt package. Extra information, whch is normally only written to the transcript file, is now also displayed on your terminal. debugshow This option additionally shows information about changes of text font and the restoration of such fonts after a group. Be careful when you turn on this option because it can produce very large transcript files that fill up your disk space. In addition to these "standard tracing" options8 the package tracefnt supports the following options: pausing T h s option turns all warning messages into errors to help detecting the detection of problems in important publications. loading This option shows the loading of external fonts. However, if the format or document class you use has already loaded some fonts then these will not be shown by this option.
The Program nfssfont

Within the NFSS distribution is a L A T E X file called nf ssf ont .t e x that can be used to test new fonts, produce font tables showing all characters, etc. This file is an adaption of the program t e s t f ont .tex originally written by Donald Knuth. When you run t h s file through W X , you will be asked to enter the name of the font to test. Your answer should be the external font name without any extension-e.g., cmrl0 (Computer Modern Roman 10pt) or y i n i t (Yannis Haralambous' Initial font). You are then requested to enter a command. Probably the most important one is \table, whch will produce a font chart like the one on page 207. To switch to a new test font, type \ i n i t ; to h s h the test, type \bye or \stop; and to learn about all the other possible tests (at the moment basically still tailored for OT1 encoding), type \help.

7.6 The Low-Level Interface


m l e the hgh-level font commands are intended for use in a document, the low-level commands are m a d y for d e h g new commands in packages, or in the preamble of a document; see also section 7.6.4. To make the best use of such font commands, it is helpful to understand the internal organization of fonts in the New Font Selection Scheme.
is suggested that package writers who support tracing of their packages use these four standard names if applicable.

188

Font Selection
One goal of NFSS is to allow rational font selection, with algorithms guided by the principles of generic markup. For this purpose, it would be desirable to allow independent changes for as many font attributes as possible. On the other hand, font families in real life normally contain only a subset of the imaginable font attribute combinations. Therefore, allowing independent changes in too many attributes results in too many combinations for which no real (external) font is available and a default has to be substituted. NFSS internally keeps track of five independent font attributes: the "current encoding," the "current farmly," the "current series," the "current shape," and the "current size." The encoding attribute was introduced in NFSS release 2 after it became clear that real support of multiple languages would be possible only by maintaining the character-encoding scheme independently of the other font attributes. The values of these attributes determine the font currently in use. NFSS also maintains a large set of tables used to associate attribute combinations with L A I T E X external fonts (i.e., .tfm files that contain the information necessary for ( to do its job). Font selection inside NFSS is then done in two steps: Some or all attributes are changed using the low-level commands \fontencoding,\fontf amily,\fontseries,\fontshape,and \f ontsize. The font corresponding to this new setting is selected by calling the \selectfont command. The second step comprises several actions. NFSS first checks whether or not the font corresponding to the desired attribute settings is already known to the system (i.e., the .tfm file is already loaded) and, if so, this font is selected. If not, the internal tables are searched to find the external font name associated with this setting. If such a font name can be found, the corresponding .tfm file is read into memory and afterward the font is selected for typesetting. If this process is not successful NFSS tries to find an alternative font as explained in section 7.6.3.

7.6.1 Setting Individual Font Attributes


Every font attribute has one command to change its current value. All of these commands will accept more or less any character string as an argument, but only a few values make sense. These values are not hard-wired into the NFSS system-they are only conventions set up in the internal tables. The following sections introduce the naming conventions used in the standard setup of NFSS, but anyone can change t b s setup by adding new font declarations to the internal tables. Obviously, anybody setting up new fonts for use with NFSS should try to obey these conventions whenever possible, since only a consistent naming convention can guarantee that appropriate fonts are selected in a generically marked-up document.

7.6 The Low-Level Interface

189

If you want to select a specific font using t h s interface-say, Computer Modern Dunlull bold condensed italic 14pt-a knowledge of the interface conventions alone is not enough, since there does not exist an external font for every combination of attribute values. You could try your luck by specifying something like the following set of commands

which would be correct according to the naming conventions, as we will see in the following sections. But since this attribute combination does not correspond to a real font, NFSS would have to substitute a different font. The substitution mechanismmay choose a font that is quite different from the one desired, so you should consult the font tables to see if the desired combination is available. (See section 7.6.3 for more details on the substitution process.) Every installation should have a local guide telling you exactly what fonts are available.
Choosing the Font Family

The font family is selected with the command \f ontf amily. Its argument is a character string that refers to a font family declared in the internal tables. The character string was defined when these tables were set up and is usually a short letter sequence-for example, cmr for the Computer Modern Roman family. The family names should not be longer than five letters, because they will be combined with possibly three more letters to form a file name, which on some systems can have at most eight letters.
Choosing the Font Series

The series attribute is changed with the \fontseries command. The series combines weight and width in its argument; in other words, it is not possible to change the width of the current font independently of its weight. T h s arrangement was chosen because it is hardly ever necessary to change weight or width individually. On the contrary, a change in weight (say, to bold) often is accompanied by a change in width (say, to extended) in the designer's specification. This is not too surprising, since weight changes alter the horizontal appearance of the letters and thus call for adjustment in the expansion (i.e., the width) to produce a well-balanced look. In the naming conventions for the argument for the \fontseries command the names for both the weight and the width are abbreviated so that each combination is unique. The conventions are shown in table 7.10 on the following page. These classifications are combined in the argument to \f ontseries; however, any instance of m (standing for medium in weight or width) is dropped, except when both weight and width are medium. The latter case is abbreviated with a single m. For example, bold expanded would be bx, whereas medium expanded would be x and bold medium would be b.

190

Font Selection
Width Classes ul e1 1 sl m sb b eb ub

Weight Classes

Ultra Light Extra Light Light Semi Light Medium (normal) Semi Bold Bold Extra Bold Ultra Bold

Ultra Condensed Extra Condensed Condensed Semi Condensed Medium Semi Expanded Expanded Extra Expanded Ultra Expanded

50% 62.5% 75% 87.5% 100% 112.5% 125% 150% 200%

uc ec c sc m sx x ex ux

Table 7.10: Weight and width classification of fonts The percent values are derived from [30]. To combine the abbreviations in the \font s e r i e s command, weight is used first and any instance of medurn (m) is dropped except when weight and width are both medium. In this case, a single m is used.

Choosing the Font Shape


To change the shape attribute the \f ontshape command is used. Again, for the standard shapes one- and two-letter abbreviations are used; these are shown in table 7.11 on the next page.

Choosing the Font Size


The font size is changed with the \f ontsizeC(size)){(skip) 1 command. This is the only font attribute command that takes two arguments: the (size) to switch to and the baseline (skip) (the distance from baseline to baseline for this size). Font sizes are normally measured in points, so by convention the unit is omitted. The same is true for the second argument. However, if the baseline skip should be a rubber length-that is, if it contains plus or minus-you have to specify a unit. Thus, a valid size change could be requested by

Even if such a request is valid in principle, no corresponding external font may exist in this size. In this case, NFSS would try to find a nearby size if its internal tables allow for size correction or would report an error if not. If you use fonts existing in arbitrary sizes, (for example, Postscript fonts) you can, of course, select any size you want, e.g.:
\fontsize~lin)C1.2in)\selectfont Happy Birthday

7.6 The Low-Level Interface

191

Abbreviation n it s1
SC

Description upright (or normal) shape italic shape slanted or oblique shape
SMALL CAPS SHAPE

ui o1

upright italic shape OUTLI[NE shape

Table 7.11: Classification of font shapes The standard abbreviations of the shapes for use in the \f ontshape command are shown here using the Computer Modern Roman family as an example. The outline shape was generated by applying the METAFONT code presented in [26]. will produce a birthday poster line with letters in one inch size. However, there is one problem with using arbitrary sizes: since NFSS doesn't know for sure whether or not you are going to use formulas in the requested size, it sets up all fonts used in formulas for the new size. For arbitrary size, t h s usually means that it has to calculate the font sizes for use in subscripts and subsubscripts etc. In turn, this probably means that it has to load a lot of new fonts-something you can tell by looking at the transcript file. For this reason it is possible that you finally h t some internal limit if you have too many different size requests in your document. If t h s happens, you should tell NFSS what sizes to load for formulas using the \DeclareMathSizes declaration, rather than letting it use its own algorithm. See section 7.7.6 for more information on how to do this.
Choosing the Encoding
A change of encoding is performed with the command \fontencoding,where the argument is the internal name for the desired encoding. This name must be known to NFSS, either as one of the predefined encodings shown in table 7.12 on the following page or as declared with the \DeclareFontEncoding command (see section 7.7.4). NFSS is based on the assumption that most (or, better, all) fonts for text are available in the same encoding as long as they are used to typeset in the same language. In other words, encoding changes only should become necessary if one is switching from one language to another. For example, an environment for typesetting in Cyrillic could be defined with
Some text no
PYCCICM

embedded

\newenvironmentCCyr) C\fontencoding~0T2~\fontfamily~cmr~\selectfont)~) Some text \begin(Cyr)po russki\endCCyr) embedded

where OT2 specifies the University of Washington Cyrillic encoding. For this to work the encoding must be declared in the preamble or a package file.

192

Font Selection

Encoding
T1

OTI OML OMS OMX


U

L..

Description Declared by TEX text Cork encoding N FSS TEX text as defined by Donald Knuth N FSS N FSS TEX math text (italic) as defined by Donald Knuth N FSS TEX math symbol as defined by Donald Knuth TEX math extended symbol as defined by Donald Knuth NFSS Unknown encoding (for arbitrary rubbish) N FSS Local encoding (for private encodings) -

Table 7.12: The standard encodings used in NFSS We hope that most of these encoding schemes will be superseded by standards defined by the TEXuser groups so that in the future a change of encoding will be necessary only if one is switching from one language to another. For this reason, the names of most encodings start with 0 to emphasize that they are old and obsolete.

7.6.2 Setting Several Font Attributes


When designing page styles (see 4.3) or layout-oriented commands, you often want to select a particular font-that is, you need to specify values for all attributes. For this task NFSS provides the command \usef ont, whch takes four arguments: the encoding, family, series, and shape. The command updates those attributes and then calls \selectf ont. If you also want to specify the size and baseline skip, place a \f ontsize command in front of it, e.g.,

which would produce the same result as the hypothetical example from page 189. Besides \usef ont,NFSS also provides you with the \DeclareFixedFont declaration that can be used to define new commands that switch to a completely fured font. Such commands are extremely fast since they do not have to look up any internal tables. They are therefore very useful in command definitions that have to switch back and forth between fixed fonts. For example, in the doc package (see chapter 14) the code-line numbers are typeset using the following definitions:

As you can see from the example, \DeclareFixedFont has six arguments: the name of the command to be defined followed by the five font attributes used by

7 . 6 The Low-Level Interface


NFSS. Instead of supplying fixed values (except for the size), the built-in hooks that describe the main document font are used (see also section 7.3.5). Thus, in the example above \CodelineFont still depends on the overall layout for the document (via the settings of \encodingdef a u l t , etc.). However, once the definition is carried out its meaning is frozen.

193

7.6.3 Automatic Substitution of Fonts


Whenever a font change request cannot be carried out because the combination is not known to FIFSS, the system tries to recover by using a font with similar attributes. Here is what happens: If the combination of encoding scheme, family, series, and shape is not declared (see section 7.7.2), NFSS tries to find a known combination by first changing the shape attribute to a default. If the resulting combination is still unknown, it tries changing the series to a default. As a last resort it changes the family to a default value. Finally the internal table entry is looked up to find the requested size. For example, if you ask for \ t t f amily\bf series\itshape-i.e., for a typewriter font in a bold series and italic shape (which usually does not exist)-then you will get a typewriter font in medium series and upright shape, since NFSS first resets the shape before changing the series. If you prefer a typewriter font with italic shape in such a situation you have to announce your intention to NFSS using the sub function, which is explained on page 198. The encoding scheme is never changed by the substitution process, because any alteration could produce wrong characters in the output. Recall that the encoding scheme defmes how to interpret the input characters while the other attributes define how the output should look. It would be catastrophic if, say, a f sign were changed into a $ sign on an invoice just because the software tried to be clever. Thus every encoding scheme must have a default family, series, and shape, and at least the combination consisting of the encoding scheme together with the corresponding defaults must have a definition inside NFSS, as explained in section 7.7.4.

7.6.4 Using Low-Level Commands in the Document


The low-level font commands described in the preceding sections are intended to' be used in the definition of higher-level commands, either in class or package files or in the document preamble. Whenever possible, you should avoid using the low-level commands directly in a document if you can use high-level font commands like \textsf instead. The reason is that the low-level commands are very precise instructions to switch to a particular font, while the high-level commands can be customized using packages or declarations in the preamble. Suppose, for example, that you have selected Computer Modern Sans in your document us-

194

Font Selection

ing \f ontf amily(cmss)\selectf ont. If you later decide to typeset the whole document with Postscript fonts-say, Times-applying a package unfortunately would change only those parts of the document that do not contain \f ontf amily commands.

7.7 Setting Up New Fonts


7.7.1 Overview
Setting up new fonts for use with NFSS basically means filling the internal tables of NFSS with the information necessary for later associating a font request in a document with the external .tfm file containing character information used by (LA)TEX.Thus the tables are responsible for associating with

the external .tfm file cmdunhl0. tfm. To add new fonts, you need to reverse this process. For every new external font you have to ask yourself five questions:
1. What is the font's encoding scheme-i.e., which characters are in what

2. 3.
4. 5.

positions? What is its family name? What is its series (weight and width)? What is its shape? What is its size?

The answers to the above questions will provide the information necessary to classify your external font according to the NFSS conventions, as described in section 7.6. The next few sections discuss how to enter new fonts into the NFSS tables so that they can be used in the main text. You normally need this information if you want to make use of new fonts-e.g., if you want to write a short package file for accessing a new font family. Later sections discuss more complicated concepts that come into play if you want to use, for example, special fonts for math instead of the standard ones.

7.7.2 Declaring New Font Families and Font Shape Groups


Each family/encoding combination has to be made known to NFSS through the command \DeclareFontFamily. This command has three arguments. The first two are the encoding scheme and the family name. The thnd is usually empty, but it may contain special options for font loadmg and is explained on page 200.

7.7 Setting UP New Fonts

195

Thus, if you want to introduce a new family-say, Computer Modern Dunhill with the old T E X encoding scheme-you would write

A font f a y normally consists of many individual fonts. Instead of announcing each family member individually to NFSS, you have to combine fonts that differ only in size and declare them as a group. Such a group is entered into the internal tables of NFSS with the \DeclareFontShape command, which has six arguments. The first four are the encoding scheme, the family name, the series name, and the shape name under which you want to access these fonts later on. The fifth argument is a list of sizes and external font names, given in a special format that we discuss below. The sixth argument is normally empty; its use is explained on page 200. We will first show a few examples and introduce terminology; then we will discuss all the features in detail. As an example, an NFSS table entry for Computer Modern Dud11 medium (series) upright (shape) in the encodmg scheme "TEXtext" could be entered as

assuming that there is only one external font for size lOpt available. If you also have this font available at 12pt, the declaration would be

If the external font is available in all possible sizes (as is the case with Type 1 Postscript (outline) fonts, or when the driver program is able to generate fonts on demand by calling METAFONT), the declaration becomes very simple. For example, Times Roman bold (series) upright (shape) in the "Cork text" encoding scheme could be entered as

The above example declares a size range with two open ends (no sizes specified to the left and the right of the -). As a result, the same external .tfm file (pstimb) is used for all sizes and is scaled to the desired size. If you have more than one .tfm file for a Postscript font-say, pstim for text sizes and psdtim for display sizes-the declaration would be
\~eclare~ont~ha~e{Tl]{tirnes>{m>{n]{ <-12> pstim (12-> psdtim ]{]

in which case the .tfm file pstim would be used for sizes less than 12pt and psdtim for all sizes greater than or equal to 12pt.

196

Font Selection The preceding examples show that the fifth argument of the command \DeclareFontShape consists of size specifications surrounded by angle brackets (i.e., <. . .>) intermixed with loading information for the individual sizes (e.g., font names). The part inside the angle brackets is called the "size info" and the part following the closing angle bracket is called the "font info." The font info is further structured into a "size function" (often empty) and its arguments; we discuss this case below. Within the arguments of \DeclareFontShape blanks are ignored to help make the entries more readable. In the unusual event that a real space has to be entered, you can use the command \space. Simple Sizes and Size Ranges The size infos-i.e., the parts between the angle brackets in the fifth argument to \DeclareFontShape-can be divided into "simple sizes" and "size ranges." A simple size is given by a single (decimal) number, like <lo> or <14.4>,and in principle can have any positive value. However, since the number represents a font size measured in points, you probably won't find values less than 4 or higher than 120. A size range is given by two simple sizes separated by a hyphen, to indicate a range of font sizes that share the same font info. The lower boundary (i.e., the size to the left of the hyphen) is included in the range, whle the upper boundary is excluded. For example, (5-10> denotes sizes greater than or equal to 5pt and less than 10pt. You can leave out the number on either side of the hyphen in a size range, with the obvious interpretation: <-> stands for all possible sizes, <-lo> stands for all sizes less than lOpt, and (12-> for all sizes greater than or equal to 12pt. Often several simple sizes have the same font info, in which case a convenient shorthand is to omit all but the last font infos, e.g.,

This example declares the font Pandora medium Roman as being available in several sizes, all of them produced by scaling from the same design size. Size Functions As noted earlier, the font info (the string after the closing angle bracket) is further structured into a size function and its argument. If there is a * in the font info string, everything to the left of it forms the function name and everything to the right is the argument. If there is no asterisk, as in all of the examples so far, the whole string is regarded as the argument and the function name is "empty." Based on the size requested by the user and the information in the \DeclareFontShape command, size functions produce the specification necessary for NFSS to find the external font and load it at the right size. They are also responsible for informing the user about anything special that happens. For example, some functions differ only in whether or not they issue a warning. This

7.7 Setting Up New Fonts

197

capability allows the system maintainer to set up NFSS in the way best suited for the particular site. The name of a size function consists of zero or more letters. Some of the size functions can take two arguments, one optional and one mandatory. Such an optional argument has to be enclosed in square brackets. For example, the specification

would select, for all possible sizes (we have the range 0 to m), the size function s with the optional argument 0 . 9 and the mandatory argument cmf ib8. The size specification in \DeclareFontShape are inspected in the order they are specified. When a size info matches the requested user size, the corresponding size function is executed. If this process yields a valid font no further entries are inspected. Otherwise the search is continued with the next entry. The standard size functions are Listed below. The documentation accompanying NFSS describes how to define additional functions if this should ever become necessary.
The "empty"Function Because the empty function is used most often, it has the shortest possible name. (Every table entry takes up a small bit of internal memory, so the syntax chosen tries to find a balance between a perfect user interface and compactness of storage.) The empty function loads the font info exactly at the requested size if it is a simple size. If there is a size range and the size requested by the user falls into the range, it loads the font exactly at the user size. For example, if the user requested 14.4, then the specification

would load the .tfm file panrl0. tfm at 14.4 pt. Since this font was designed for lOpt (it is the Pandora Roman font at lOpt), all the values in the .tfm file are scaled by a factor of 1.44. Sometimes one wants to load a font at a slightly larger or smaller size than the one requested by the user. This adjustment may be necessary when fonts from one family appear to be too large compared to fonts from other families used in the same document. For t h s purpose the empty size function allows an optional argument to represent a scale factor that, if present, is multiplied by the requested size to yield the actual size to be loaded. Thus,
<-> LO. 951 helvetica

would always load the font Helvetica at 95 percent of the requested size. If the optional argument is used, the empty size function will issue a warning to alert the user that a font is not loaded at its intended size.

198

Font Selection The "s"Function The s function has the same functionality as the empty function, but does not produce warnings (the s means silence). Writing
\~eclareFontShape{Tl>{times>{b>{n>{

<-> s

[O .9] pstimb >{>

avoids all the messages that would be written on the terminal if the empty function were used. Messages are still written to the transcript file so that you can find out what fonts have been used if something goes wrong. The "gen" Function Often the external font names are built by appending the font size to a string that represents the typeface-e.g., cmtt8, cmtt9, and cmttlO are the external names for the fonts Computer Modern Typewriter in 8, 9, and 10pt. If font names are organized in such a scheme, you can make use of the gen function to shorten the entry. This function combines the font info and the requested size to generate (hence gen) the external font names so that you can write
<8> <9> <lo> gen

cmtt

as a shorthand for

thereby saving eight characters in the internal tables of NFSS. This function combines both parts literally, so do not use it with decimal sizes like 14.4. Also ensure that the digits in the external font name really represent the design size (for example, cmrl7 is actually Computer Modern Roman at 17.28pt). Otherwise the gen function behaves like the empty function-i.e., the optional argument, if given, represents a scale factor and, if used, generates an information message. The "sgen" Function The sgen function is the silent variant of the gen function. It writes any message only to the transcript file. The "sub" Function Another important size function is the sub function, used to substitute a different font shape group if no external font exists for the current font shape group. In this case the argument is not an external font name but a different family, series, and shape combination separated by slashes (the encoding will not change for reasons explained before). For example, the Computer Modern Sans family has no italic shape, only a slanted shape. Thus it makes sense to declare the slanted shape as a substitute for the italic one by defining
\~eclare~ontShape{OT1~~cmss]{m]{it>{

<-> sub

cmss/m/el

7.7 Setting;UIJNew Fonts

199

Without this declaration, the automatic substitution mechanism of NFSS (see section 7.6.3) would substitute the default shape, Computer Modern Sans upright. Besides the substitution of complete font shape groups, there are other good uses for the sub function:
\~eclare~ontShape{OT1)Ccmss]{m]{sl)C <-8> sub * cmss/m/n <8> cmssi8 <9> cmssi9 <10><10.95>cmssilO <12><14.4> cmssil2 <17.28><20.74><24.88> cmssil7 I{)

T h s declaration means that for sizes below 8pt NFSS should look in the font shape declaration for OTl/cmss/m/n. Such substitutions can be chained. People familiar with the standard font distribution know that there is no Computer Modern Sans font smaller than 8pt, so the substituted font shape group will probably contain another substitution entry. Nevertheless using this device has the advantage that when you get an additional font you have to change only one font shape group declaration-other declarations that use this one benefit automatically. The size function sub generates an information message on the terminal about the substitution. If you want to prevent this message, use the ssub function instead. The "ssub" Function The ssub function has the same functionality as the sub function, but does not produces on-screen warnings (the first s means silence). The "subf " Function The subf function is a cross between the empty function and sub in that it loads fonts in the same way as the empty function but produces a warning that this was done as a substitution because the requested font shape is not available. Thus you can use this function to substitute some external fonts without the need to declare a separate font shape group for them, as in the case of the sub function. The "ssubf" Function This is the silent variant of the subf; it writes its messages only to the transcript file. The "fixed"Function This function disregards the requested size and instead loads the external font given as an argument. If present, the optional argument denotes the size (in points) at which the font will be loaded. Thus this function allows you to specify size ranges for which one font in some fixed size will be loaded.

200

Font Selection The "sfixed Function Once more, sf ixed is a silent variant. This function is used, for example, to load the font containing the large math symbols, which is often only available in one size. Font-Loading Options

As already mentioned, you need to declare each family using the command \DeclareFontFamily. The argument to this command, as well as the sixth argument to \DeclareFontShape,can be used to specify special operations that are carried out when a font is loaded. In this way, you can change parameters which are associated with a font as a whole. For every external font (IA)TEX maintains, besides the information about each character, a set of global dimensions and other values associated with each font. For example, every font has its own "hyphen character," the character that is inserted automatically when (LA)TEXhyphenates a word. Another example is the normal width and the stretchability of a blank space between words (the "interword space"), again a value maintained for every font and changed whenever (IA)TEXswitches to a new font. B y changing these values when a font is loaded, special effects can be achieved. Normally changes apply to a whole family; for example, you may want to prohibit hyphenation for all words typeset in the typewriter family. In this case, the third argument of \DeclareFontFamily should be used. If the changes should only apply to a specific font shape group, you have to use the sixth argument of \DeclareFontShape. In other words, when a font is loaded, NFSS first applies the argument of \DeclareFontFamily and then the sixth argument of \DeclareFontShape,so that it can override the load options specified for the whole family if necessary. Below we study the information that can be set in this way (unfortunately, not everything is changeable)and discuss some useful examples. This part of the interface addresses very low-level commands of TEX. Since it is so specialized, no effort was made to make the interface more LATEX-like. Therefore the methods for assigning integers and dimensions to variables are somewhat unusual. B y \hyphenchar\font=(number) (LA)TEXdenotes the character that is inserted as the hyphen when a word is hyphenated. The (number) represents the position of this character within the encoding scheme. The default is the value of \defaulthyphenchar,which is 45,representing the position of the character in most encoding schemes. If this number is set to - 1,hyphenation is suppressed. Thus, by declaring

you can suppress hyphenation for all fonts in the cmtt family with the encoding scheme OTI. Fonts with the Cork encoding have an alternate hyphen character in position 127, so that you can set, for example

7 . 7 Setting Up New Fonts

201

This makes the hyphen character inserted by (IA)TEX different from the compound-word dash entered in words like "so-called." (IA)TEX does not hyphenate words that already contain explicit hyphen characters (except just after the hyphen) which can be a real problem in languages where the average word length is much larger than in English. With the above setting this problem can be solved. Every (LA)TEXfont has an associated set of dimensions, changed by assignments of the form \f ontdimen(number)\f ont=(dimen), in whch (number) is the reference number for the dimension and ( dimen) is the value to be assigned. The default values are taken from the .t f m file when the font is loaded. Each font has at least seven such dimensions:
\f

ontdimenl specifies the slant per point of the characters. If the value is zero, the font is upright.

\f ontdimen2 specifies the normal width of a space used between words (interword space). \f ontdimen3 specifies the additional stretchabhty of the inter-word spacei.e., the extra amount of whte space that (IA)TEXis allowed to add to the space between words to produce justified lines in a paragraph. In an emergency (IA)TEXmay add more space than this allowed value; in that case an "underfull box" will be reported. \f ontdimen4 specifies the allowed shrinkability of the inter-word space-i.e., the amount of space that (LA)TEXis allowed to subtract from the normal inter-word space (\f ontdimen2) to produce justified lines in a paragraph. (IA)TEXwill never shrink the inter-word space below this minimum. \f ontdimen5 is the so-called x-height of the font. It defines the font-oriented dimension I ex. \f ontdimen6 is the so-called quad width. It defines the font-oriented dimension 1em. \f ontdimen7 specifies the amount of extra space added after end-of-sentence periods when \nonf renchspacing is in force. When changing the inter-word spacing associated with a font, you cannot use an absolute value because such a value must be usable for all sizes withn one font shape group. You therefore have to define the value by using some other parameter that depends on the font. You could say, for example

202

Font Selection

This declaration reduces the normal inter-word space to 70 percent of its original value. In a similar manner, the stretchability and shrinkability could be changed. Some fonts used in formulas need more than seven font dimensions. These are the symbol fonts called "symbols" and "largesymbols"; see section 7.7.6. TEX will not typeset a formula if these symbol fonts have fewer then 22 and 13 \f ontdimen parameters, respectively. The values of these parameters are used to position the characters in a math formula. Explaining the meaning of every such \f ontdimen parameter goes beyond the scope of this book; details can be [39]. found in appendix G of the T~Xbook One unfortunate optimization is built into the T E X system: TEX loads every .tfm file only once at one size. It is therefore not possible to define one NFSS font shape group (with the \DeclareFontShape command) to load some external font-say, cmttl0-and use another \DeclareFontShape command to load the same external font, this time changing some of the \f ontdimen parameters or some other parameter associated with the font. Trying to do t h s changes the values for both font shape groups. Suppose, for example, that you try to define a font shape with tight spacing by making the inter-word space smaller-e.g., saying
\~eclare~ontShape{Tl)Ctimes>{rn>h>C <-> pstim >{> \~eclare~ont~ha~e{~l)Ctimes>{c>{n>C <-> pstim {\fontdimen2\font=.7\fontdimen2\font>

This declaration would not work. The inter-word spacing for the medium shape would change when the tight shape was loaded to the values specified there, and this result is not what you wanted. The best way to solve this problem is to define a virtual font that contains the same characters as the original font, differing only in the settings of the font dimensions (see also section 9.1.1).

7.7.3 Modifying Font Families and Font Shape Groups


If you need a nonstandard font shape group declaration for a particular document, just place your private declaration in a package or the preamble of your document. This will overwrite any existing declaration for the font shape combination. Note, however, that the use of \DeclareFontFamily prevents a later loading of the correspondmg .f d file (see section 7.7.5). Also your new declaration has no effect on fonts already loaded.

7.7.4 Declaring New Encoding Schemes


Font changes that involve alterations in the encoding scheme require certain precautions. For example, in the Cork encoding, most accented letters have their own glyphs, whereas in the traditional TEX text encoding, accented letters have

7.7 Setting Up New Fonts


to be generated from accents and letters using the \accent primitive. (It is desirable to have glyphs for accented letters rather than using the \accent primitive because, among other things, the former approach allows correct hyphenation.) If the two approaches have to be mixed, perhaps because a font is only available in one of the encodings, you need to change the definitions of commands like \", so that they behave differently depending on the font. For these reasons, every encoding scheme has to be formally introduced to NFSS using the \DeclareFontEncoding command, which takes three arguments. The first argument is the name of the encoding under which you access it using the \f ontencoding command. See table 7.12 on page 192 for the list of standard encoding schemes and their internal NFSS names. The second argument contains any code (such as definitions) to be executed every time NFSS switches from one encoding to another using the \fontencoding command. The f i n a l argument contains code to be used whenever the font is accessed as a mathematical alphabet. Thus these arguments can be used to redefine commands that depend on the positions of characters in the encoding. To avoid spurious spaces in the output (coming from extra spaces in such arguments) the space character is ignored within them. In the unl~kely event that you need spaces in a definition in one of the arguments, use the \space command. The starting letters T, 0, and M are reserved for standard encodings and should not be used when you define your private encodings. For this purpose you should choose names starting with L for "local." T h s practice ensures that files using official encodings are portable. The NFSS maintainers will add new standard encodings to the NFSS documentation. Also, as we saw in section 7.6.3 on font substitution, the default values for family, series, and shape may need to be different for different encodmgs. For this, NFSS provides the command \Decl'areFontSubstitution, which again takes the encoding as the first argument. The next three arguments are the default values (associated with this encoding) for family, series, and shape for use in the automatic substitution process, as explained in section 7.6.3.

203

7.7.5 Internal File Organization


Font families can be declared when a format file is generated or in the document preamble, or they can be loaded on demand when a font change command in the document requests a combination that so far has been unused. The first option takes up internal memory in every W X run, even if the font is not used, while the second and the third possibilities take a little more time during document formatting, since the font definitions have to be read in during processing time. Nevertheless, it is preferable to use the latter solution for most font shape groups, because it allows you to typeset a wide variety of documents with a single L A T E Xformat.

204

Font Selection

When the format is generated, W X will read a file named f ontdef .l t x , which should contain the font family definitions normally used in documents. All other font family definitions should be declared in external files loaded on request: either package files or font definition (. f d) files (see below). If you place font family definitions in a package file you must explicitly load this package after the \documentclass command. But there is a third possibility: whenever NFSS gets a request for a font family f oo in an encoding scheme BAR and it has no knowledge about t h s combination, it will try to load a file B A R f 0 0 . f d. If t h s file exists, it is supposed to contain font shape group definitions for family f oo in encoding scheme BAR-that is, declarations of the form

In this way it is possible to declare a huge number of font families for the NFSS system without filling valuable internal memory with information that is almost never used. Unfortunately, this feature is not fully available on (LA)TEXsystems that use different search paths for the commands \ i n p u t and \openin. On such systems the .f d feature can be activated at installation time by supplying NFSS with a full path denoting the directories containing all the .f d files. As a result, however, local .f d files-those stored in the current directory-may not be usable on such systems. T h s is currently the case for some VMS installations, but we hope that this restriction will be lifted in the near future. To summarize, each . f d file should contain a l l font defmtions for one font family in one encoding scheme. It should consist of one or more \DeclareFontShape declarations and exactly one \DeclareFontFamily declaration. Other definitions should not appear in such a file, except perhaps for \ t y p e o u t commands informing the user about the font loading. As an alternative to the \ t y p e o u t command, you can use the plain T E X command \wlog, whch writes its argument only into the transcript file. Detailed information in the transcript file should be generated by all .f d files that are used in production, because loolung at t h s transcript will help to locate errors by providing information about the files and their version used in a particular job. If \ t y p e o u t or \wlog commands are used, it is important to know that spaces and empty lines in a .f d file are ignored. Thus you have to use the command \space in the argument to \ t y p e o u t or \wlog to obtain a blank space on the screen and the transcript file. New encoding schemes cannot be introduced via the .f d mechanism. NFSS will reject any request to switch to an encoding scheme that was not declared in f ontdef .l t x or in a package file.

7.7 Setting Up New Fonts

205

7.7.6 Declaring New Fonts for Use in Math


Specifying Font Sizes For every text size NFSS maintains three sizes that are used to typeset formulae (see also section 8.9.1). These are the size in which to typeset most of the symbols (selected by \ t e x t s t y l e or \displaystyle), the size for first order sub- and superscripts (\scriptstyle), and the size for higher order sub- and superscripts (\scriptscriptstyle). If you switch to a new text size, for which the corresponding math sizes are not yet known, NFSS tries to calculate them as fractions of the text size. Instead of letting NFSS do the calculation you might want to specify the correct values yourself by using \DeclareMathSizes. T h s declaration takes four aguments: the outer text sizes and the three math sizes for this text size. For example, the class file for The LATEX Companion contains settings like

The first declaration defines the math sizes for the 14pt heading size to be 14pt, lOpt, and 7pt, respectively. With the second declaration (the size for the chapter headmgs) we inform NFSS that no math sizes are necessary for 36pt text size. This avoids the unnecessary loading of more than thirty additional fonts which would have made it impossible to process The LATEX Companion with all its examples as a single document. However, you should be careful with &sabling math sizes, because if some formula is typeset in such a size after all, it Mill1 be typeset in whatever math sizes are still in effect from an earlier text size. Adding New Symbol Fonts We have already seen how to use math alphabet commands to produce letters with special shapes in a formula. We now discuss how to add fonts containing special symbols and how to make such symbols accessible in formulas. Such fonts are called "symbol fonts." The process of adding new symbol fonts is similar to declaring a new math alphabet identifier: \DeclareSymbolFont defines the defaults for all math versions, and \SetSymbolFont overrides the defaults for a particular version. The math symbol fonts are accessed via a symbolic name that is a string of letters. If, for example, you want to install the AMS fonts msbml0, shown in table 7.8 on page 207, you first have to make the typeface known to NFSS using the declarations described in the previous sections. These instructions would look like
\~eclareFontFamily{U>{msb)C) \DeclareFontShape{U)Cmsb>{m>{n>~ <5> <6> <7> <8> <9> gen * msbm <lo> <10.95> <12> <14.4> <17.28> <20.74> <24.88> msbmlO>C>

206

Font Selection
Meaning Ordinary Binary operator Opening Punctuation Example /
+
(
s

Type
\mathord \mathbin \mathopen \mathpunct

Type
\mathop \mathre1 \mathclose \mathalpha

Meaning Large operator Relation Closing Alphabet character

Example
-

\sum

1
A

Table 7.13: The math symbol types in your package file. In fact, only the \DeclareFontEncoding declaration must be in the package or class file; the other two can be placed in a .f d file. Then you have to declare that symbol font for all math versions by issuing the command

which makes the font shape group U/msb/m/n available as a symbol font under the symbolic name AMSb. If there were a bold series in this font family (unfortunately there is not), you could then change the setup for the bold math version by saying

After taking care of the font declarations, you can make use of this symbol font in math mode. But how do you tell NFSS that $ a \ l e s s d o t b$ should produce a < b, for example? For this, you have to introduce your own symbol names to NFSS, using \DeclareMathSymbol. For example, \ l e s s d o t would be declared using

The first argument to \DeclareMathSymbol is your chosen command name. Instead of a command name you can also use a single character in the first argument. For example, the euler package has several declarations of the form

that specify where to fetch the digits from. The second argument is one of the commands shown in table 7.13 and describes the nature of the symbol-whether it is a binary operator, a relation, etc. This information is used by (LA)TEX to leave the correct amount of space around the symbol when it is encountered in a formula. Incidentally, except for \mathalpha, these commands can be used directly in math formulas as functions with one argument, in which case they space their (possibly complex) argument as if it were of the corresponding type.

7.7 Setting Up New Fonts

207

Test of msbm7 on December 1,1993 at 2129

Figure 7.8: Output of the nfssfont.tex program for the font msbm7

In the third argument you name the symbol font from which the symbol should be fetched-that is, the symbolic name introduced with the \DeclareSyrnbolFont command. The fourth argument gives the symbol's position in the font encoding, either as a decimal, octal, or hexadecimal value. Octal (base 8) and hexadecimal (base 16) numbers are preceded by ' and ", respectively. If you look at figure 7.8, you can easily determine the positions of all A T E Xprogram nfssfont, glyphs in t h s font. Such tables can be printed using the L which is part of the NFSS distribution; see the section on page 187. Since \DeclareMathSymbol is used to specify a position in some symbol font, it is important that all external fonts associated with this symbol font via the \DeclareSymbolFont and the \SetSymbolFont commands have the same

208

Font Selection

character in that position. The simplest way to ensure this uniformity is to use only fonts with the same encoding (unless it is the U encoding, since this means unknown and thus may differ from font to font). If you look again at the font chart for msbm7, you will notice that this font contains so-called "blackboard bold" letters, e.g., ARC. If you want to use these letters as a math alphabet, you can define them using \DeclareMathAlphabet, but since this symbol font is already firmly present, it is better to use a shortcut:

That is, you give the name of your math alphabet identifier and the symbolic name of the previously declared symbol font. An important reason not to duplicate symbol fonts is that there is an upper limit of sixteen for the number of math fonts that can be active at any given time in (LA)TEX. In calculating this limit, each symbol font counts; math alphabets count only if they are actually used in the document, and they count locally in each math version. Thus, if eight symbol fonts are declared, you can use up to eight (possibly different) math alphabet identifiers within every version. To summarize: for introducing new symbol fonts you only need to issue a few \DeclareFont.. . declarations and a possibly large number of \DeclareMathSymbolcommands; so adding such fonts is best done in a package file.
Introducing New Math Versions

We've already mentioned that the standard setup predeclares two math versions, normal and bold. If you want to introduce additional versions, you have to use the declaration \DeclareMathVersion. This declaration has one argument, the name of the new math version. All symbol fonts and all math alphabets previously declared are automatically available in this math version; the default fonts are assigned to them-i.e., the fonts you have specified with
\DeclareMathAlphabetor\DeclareSymbolFont. \Set. . . commands, as shown in the previous sections for the bold mathversion.

You can then change the setup for your new version by issuing appropriate

Again, the introduction of a new math version is normally done in a package file.
Changing the Symbol Font Setup

Besides adding new symbol fonts to access additional symbols, the commands we have just seen also can be used to change an existing setup. This capability is of interest if you like to use special fonts in some or all math versions. The default settings in NFSS are:

7.7 Setting Ur,New Fonts


\SetSymbolFont ~operators~~bold){OT1)Ccmr)Cbx~~n) \DeclareSymbolFont{letters) {OML){cmm){m){it) \SetSymbolFont {letters) Cbold){OML){cmm){b3{it) \DeclareSymbolFont~symbols)~OMS~{cmsy~~m~~n) \DeclareSymbolFont~largesymbols~~OMX~~cmex~{m~~n~

In the standard setup, digits and text produced by "log-like operators" such as \log and \max are taken from the symbol font called operators. To change th~s situation so that these elements agree with the main text font-say Computer Modern Sans rather than Computer Modern Roman-you can say

Symbol fonts with the names symbols and largesymbols play a unique r61e in TEX and for this reason need a special number of \fontdimen parameters attached to them. Thus, only specially prepared fonts can be used for these two symbol fonts. In principle it is possible to add such parameters to any font at loading time by using the third parameter of \DeclareFontFamily or the sixth parameter of \DeclareFontShape. Information on the special parameters for these symbol fonts can be found in appendix G of [391.

7.7.7 The Order of Declaration


NFSS forces you to give all declarations in a specific order so that it can check whether or not you have specified all necessary information. If you declare objects in the wrong order, NFSS will complain. Here are the dependencies that you have to obey:

\DeclareFontFamily checks that the encoding scheme was previously declared with \DeclareFontEncoding. \DeclareFontShape checks that the font family is declared to be available in the requested encoding (\DeclareFontFamily). \DeclareSymbolFont checks that the encoding scheme is valid. \SetSymbolFont additionally ensures that the requested math version is already declared (\DeclareMathVersion) and that the requested symbol font is already declared (\DeclareSymbolFont).
\DeclareSymbolFontAlphabet checks that the command name for the al-

phabet identifier can be used and that the symbol font was previously declared.
\DeclareMathAlphabet checks that the chosen command name can be used and that the encoding scheme is already declared.

210

Font Selection
\SetMathAlphabet checks that the alphabet identifier was previously declared with \DeclareMathAlphabet or \DeclareSymbolFontAlphabet and that the math version and the encoding scheme are already known. \DeclareMathSymbolmakes sure that the command name can be used (that is, is either undefined or was previously declared to be a math symbol) and that the symbol font was previously declared.

Finally, when the \begin{document) command is reached, NFSS makes some additional checks, like verifying that substitution defaults for every encoding scheme point to known font shape group declarations.

7 . 8 Warning and Error Messages


The most striking difference between the old font selection and NFSS is probably the appearance of overfull box messages. For example, earlier drafts of t h s book produced messages like
Overfull \hbox (14.13165pt too wide) in paragraph at lines 775--775 [1\OTl/cmtt/m/n/8 oldlfont.sty {\errmessage{The package 'oldlfontJ does not make sense if you[]

As you can see, the message shows the overfull box text with internal font representations, such as \OTl/cmtt/m/n/8,which in NFSS are considerably longer and more detailed and which clearly show the encoding, family, series, and shape of the font in question. The old W X probably would have displayed something like \\ptt\@viiipt in this case (indeed, with two backslashes), but the NFSS display is more informative. However, if such overfull boxes contain formula material, the result unfortunately becomes nearly unreadable, since in a formula nearly every character is taken from a special font. For example,
Overfull \hbox (10.01093pt too wide) detected at line 23 $\OML/cmm/m/it/lO A \OMS/cmsy/m/n/lO --T [I [I \OML/cmm/m/it/lO x$

is the symbolic representation that (LA)TEXwould display for the simple formula

In such a case it is better to check the line number in your source (in t h s case 23) to find the offending text. The following alphabetical list describes the remaining warning and error messages issued by NFSS and explains their most likely causes. The warning messages are usually prefixed with the string Warning: or Inf0:. The error

7.8 Warning and Error Messages

211

messages either identify themselves as L A T E X errors or, if they should occur only in an improperly set up system, as T E X errors.
Calculating math sizes for size (text size)

NFSS has to guess the correct font sizes for subscripts and superscripts because it could not find the information for the current (text size) in its internal tables. This message usually is followed by several font size correction warnings because NFSS's initial guess is seldom successful. This situation can arise when you select an uncommon size using the \f ontsize command; see also section 7.7.6.
Checking defaults for (cdp)/(fontshape)

This message is written in the transcript file when NFSS is verifying that the substitution defaults for the encoding (cdp) are sensible. It is followed either by . . .okay or by an error message. In the latter case, the (fontshape) group specified with \DeclareFontEncoding is unknown to NFSS.
Command ( name) already defined

NFSS issues this message when you have tried to declare a command that already has a meaning. Your declaration is ignored and you have to choose a different name.
Command (name) invalid in math mode

This is either a warning or an error message that means you have used a command in math mode that should only be used in normal text. In case of an error message, use h to get further help.
Command (name) not defined as a math alphabet This error is issued when you try to use \SetMathAlphabet on a ( name) that was not previously declared with \DeclareMathAlphabet or \DeclareSymbolFontAlphabet to be a math alphabet identifier. Command \tracingfonts not provided You have specified \tracingf onts=. . . in the preamble of your document

but removed the tracefnt package from the document. This is just a friendly warning that can be ignored.
Corrupted NFSS tables

You will get this message when NFSS has tried some font substitution and detected a loop. If \DeclareErrorFont was set up correctly, you can continue, but this error always should be brought to the attention of your system mair~tainer.~
Encoding (name) has changed to (new name) for

...

This warning is issued when in the declaration of a symbol font different


g ~ hdeclaration e \DeclareErrorFontis used during installation and points to a font that should be used when everything else fails. See the installation description of NFSS for more details.

212

Font Selection

encoding schemes have been used in different math versions. This may mean that the \DeclareMathSymbol commands for t h s symbol font are not valid in all math versions.
Encoding scheme (name) unknown

The encodmg scheme (name) you have specified in a declaration or in \fontencoding is not known to the system. You either forgot to declare it using \DeclareFontEncoding or YOU misspelled its name.
External font ( name) loaded for size (size)
NFSS has ignored your request to load some font shape at size (size) and has loaded the external font ( name) instead. (This message is generated by the size function fixed.)

FontDef file :

( name) . . . You will find such a message in your transcript file of the (LA)TEXrun. (name) is the name of a font definition file that was loaded. Such files contain font shape group declarations and are described in section 7.7.5.

Font family (cdp)+( family) unknown

You tried to declare a font shape group with \DeclareFontShape without first declaring the font (family) as being available in the encoding (cdp) using \DeclareFontFamily.
Font (name) not found

The internal tables of NFSS have been corrupted and it was unable to find the external font ( name).
Font shape (fontshape) in size (size) not available

This message is issued by NFSS when it tries to select a font but finds that the requested combination is not available. Depending on the contents of the internal tables, it will then issue one of the following additional messages:
external font ( name) used
NFSS has selected the external font (name) in that particular situation and does not know to which font shape group it belongs. (This message is generated by the size function subf.)

size (size) substituted


NFSS has selected the correct shape, but since the requested size is not available NFSS has chosen the nearby size (size). This action is taken automatically if none of the simple sizes or size ranges in the (font shape) group declaration match.

shape (fontshape) tried


NFSS has selected a different (fontshape) group because the requested one is not avdable for the requested (size).(This message is generated by the size function sub.)

7.8 Warning and Error Messages


Font shape (fontshape) w i l l be s c a l e d t o s i z e (size) NFSS informs you that it has loaded your requested font by scaling it to

213

the desired size. T h s action keeps (LA)TEXhappy, but to print a document containing scaled fonts your printer driver must have these fonts in the correct size or must be able to scale them automatically.
Font shape (font shape) undefined. Using ' (other shape) ' i n s t e a d T h s information is given after NFSS has decided which substitution shape

it is going to use.
Font shape (fontshape) not found

This error message is issued when there is somethmg very wrong with a \DeclareFontShape declaration-e.g., if it does not contain any size specifications. Check the setup for the font shape group in question.
Math alphabet i d e n t i f i e r ( i d ) i s undefined i n math v e r s i o n (name)

You have tried to use the math alphabet identifier ( i d ) in a math version ( ( n a m e ) for ) whch it was not set up. Add an additional \SetMathAlphabet declaration to the preamble of your document to assign a font shape group for this alphabet identifier.
Math v e r s i o n (name) i s not defined

You tried to assign a math alphabet or a symbol font to a math version that is unknown to NFSS. You either misspelled its name or you forgot to declare t h s version (perhaps you have to add some package file). It is also possible that the math version you selected with \mathversion is not known to the system.

***

NFSS r e l e a s e I command (name) found This comes either as a warning or as an error message. NFSS has encountered the command ( name), whch is no longer valid in release 2. In most cases NFSS will be able to recover by substituting the corresponding release 2 command, but in any case, you should update the file that contains the offending command.

N o d e c l a r a t i o n f o r shape (fontshape) The sub or ssub size function used in a \DeclareFontShape command points to a substitution shape that is unknown to NFSS. Overwriting (something) i n v e r s i o n (name) . . . A declaration, like \SetSymbolFont or \DeclareMathAlphabet, has changed

the assignment of font shapes to (something) (a symbol font or a math alphabet) in the math version (name).
Redeclaring math alphabet (name) A\DeclareMathAlphabetor\DeclareSymbolFontAlphabet~~~~dwa~

issued to declare (name),which was already defined to be a math alphabet identifier. The new declaration overrides all previous settings for (name).

214 Redeclaring math symbol (name)

Font Selection

The command (name) was already declared as a math symbol and your declaration overrides the old definition.
Redeclaring math version ( name) You issued a \DeclareMathVersion command for a version that was already

declared. The new declaration overrides all previous settings for this version with the default values.
Redeclaring symbol font ( name) You issued a \DeclareSymbolFont command for a symbol font that was

previously declared. The new declaration overrides the symbol font in all math versions.
Size substitutions with differences up to (size) have occured

This message will appear at the end of the run in case NFSS selected at least one significantly different size because the requested size was not available. The (size) is the maximum deviation that was needed.
Some font shapes were not available, defaults substituted This message wdl appear at the end of the run in case NFSS had to use

automatic font substitution for some font shapes.


Symbol font (name) is not defined

You tried to make use of the symbol font (name), for example within a \DeclareMathSymbol command, without declaring it first with a \DeclareSymbolFont declaration.
This NFSS system isn't set up properly

If this error occurs, then NFSS has detected a mistake while trying to verify the font substitution tables. In this case either a \DeclareFontSubstitution or \DeclareErrorFont declaration is corrupted. Type h for additional information and inform your system maintainer. If you are the system maintainer, read section 7.7.4.
Try loading font information for ( cdp)+ ( family)

You will find such messages in the transcript file whenever NFSS tries to load a .f d file for the encoding/family combination ( cdp)/( family).
Undefined font size function (name) A size function used in \DeclareFontShape was misspelled. Check the entry

or tell your system maintainer.

***

Use (command) for (old command) *** Your source contains (old command),which is considered obsolete in NFSS release 2.

C H A P T E R

Higher Mathematics

Basic W&X offers a high level of mathematical typesetting capabilities. However, when complex equations or other mathematical constructs have to be input repeatedly, it is up to you to define new commands or environments to ease the burden of typing. The American Mathematical Society (AMS), recognizing that fact, has sponsored the development of extensions to TEX, known as A ~ - T E X . They make the preparation of mathematical compuscripts less time-consuming and the copy more consistent. Recently these extensions were ported to L A T E X . It is, however, important to distinguish between the original, non-WX implementation of AHS-TEX and the package amstex, popularily known modified form of it that constitutes the k?&X as the A d - K & X distribution [951. A sans serif font will be used to denote the L A T E X package amstex [951, and the standard AHS-TEX logo will be used for the original IIon-LATEX version.

8.1 T h e A3\/1S-H&X Project


AmS-TEXwas originally released for general use in 1982. Its main strength is that it facilitates mathematical typesetting, while producing output that satisfies the high standards of mathematical publishing. It provides a predefined set of natural commands such as \matrix and \text that make complicated mathematics reasonably convenient to type. These commands incorporate the typesetting experience and standards of the American Mathematical Society, to handle problematic possibilities, such as matrices within matrices or a word of text w i t h a subscript, without burdening the user.

216

Higher Mathematics
ANS-TEX, unlike IFTEX, does not have certain features that are very convenient for authors-automatic numbering that adjusts to addition or deletion of material being the primary one. Nor does it have the laborsaving abilities of L A T E X for preparing indexes, bibliographies, tables, or simple diagrams. These features are such a convenience for authors that the use of L A T E X spread rapidly X was available by the in the mid-1980s (a reasonably mature version of W end of 1983), and the American Mathematical Society began to be asked by its authors to accept electronic submissions in L A T E X . Thus, the A N S - m X project came into being in 1987 and three years later ANS-LATEX version 1.0 was released. The conversion of AmS-TEX'Smathematical capabilities to W X , and the integration with the NFSS, were done by Frank Mittelbach and Rainer Schopf, working as consultants to the AMS, with assistance from Michael Domes of the AMS technical support staff. To use the AmS-LATEX developments you should load the amstex package with a \usepackage command.

8.2 Fonts and Symbols in Formulae


8.2.1 Names of Math Font Commands
The list of math font commands specific to the amstex package is shown in table 8.1 on page 218, where for each case an example is shown. In addition, the math font commands of table 7.4 on page 176 can be used. In the amstex package, \boldsymbol is to be used for individual bold math symbols and bold Greek letters-everything in math except for letters (where one would use \mathbf). For example, to obtain a bold oo, +, T , or 0, you can use the commands \boldsymbol<\infty), \boldsymbol{+), \boldsymbol<\pi), or \boldsymbolIO). Since \boldsymbol takes a lot of typing, you can introduce new commands for bold symbols to be used frequently:
\newcommand~\bpi~~\boldsymbolC\pi)) \newcommand{\binfty){\boldsymbol{\infty)) \ [ B-\infty + \pi B-1 \sim \mathbf {B)-{\bin5 ty) \boldsymbol{+) \bpi \mathbf{B)-{\boldsymbolC1))

B,

+ TBI - BB, + rrB1

\I
For those math symbols where the command \boldsymbol has no effect because the bold version of the symbol does not exist in the currently available fonts, there exists a command "Poor man's bold" (\pmb),which simulates bold by typesetting several copies of the symbol with slight offsets. This procedure

8.2 Fonts and Symbols in Formulae

217

must be used for the extension and large operator symbols from the \cmex font, as well as the A M extra math symbols from the \msam and \msbm fonts.

\pmb With large operators and extension symbols (for example, 2 and does not currently work very well because the proper spacing and treatment of limits is not preserved. Therefore, the TEX operator \mathop needs to be used (see table 7.13 on page 206).

n)

To make an entire math formula bold (or as much of it as possible, depending on the available fonts), use \boldmath preceding the formula. The sequence \mathbf {\hat{A)) produces a bold accent character over the A. However, combinations like \mathcal{\hat{A)) will not work in ordinary LK&X because the \mathcal font does not have its own accents. In the amstex package the font change commands are defined in such a way that accent characters will be taken from the \mathrm font if they are not available in the current font (in addition to the \mathcal font, the \Bbb and \f r a k fonts don't contain accents).

8.2.2 Mathematical Symbols


Tables 8.3 on the next page to 8.12 on page 220 review the mathematical symbols available in standard L A T E X . You can put a slash through a W X symbol by preceding it with the \ n o t command, for instance. (L 42-47) (L 44)

Tables 8.13 on page 220 to 8.20 on page 222 show the extra math symbols of the A d - F o n t s , which are automatically available when you specify the amssymb package. However, if you want to define only some of them (perhaps because your TEX installation has insufficient memory to define all the symbol names), you can use the amsfonts package and the \DeclareMathSymbol command, whch is explained in section 7.7.6.

218
\Bbb \boldsymbol \frak \pmb \text

Higher Mathematics

Blackboard bold alphabet, e.g., $\BbbCNQRZ)$ gives: NQRZ. Used to obtain bold numbers and other nonalphabetic symbols, as well as bold Greek letters. Euler Fraktur alphabet, e.g., $\frakCE)=\frakCmc)-2$ gives: (2 = mc2. "Poor man's bold," used for math symbols when bold versions don't exist in the available fonts, e.g., $\pmb{\oint)$ gives: $ and $\pmb(\triangle)$ gives: A. Produce normal text with correct text-spacing in the current font used outside math, e.g., $E=mc^2\quad\text((Einstein) )$ gives: E = mc2 (Einstein).

Table 8.1: Font commands available in mathematics with the amstex package
2

fi

\hatla} \check{a)

a a

\acutela} \gravela}

a
d

\barfa} a \vec{a) ii

\dot{a} \ddot{a}

6
6

\brevela} \tilde{a)

Table 8.2: Math mode accents

Table 8.3: Greek letters


\pm n \cap o \diamond \mp U \CUP A \bigtriangleup \times w \uplus 7 \bigtriangledown + \div n \sqcap a \triangleleft \ast U \sqcup D \triangleright * \star v \vee a \lhda 0 \circ A \wedge tz \rhda \bullet \ \setminus 4 \unlhda - \cdot 1 \wr k \unrhda a Not predefined i n NFSS. Use the latexsym or amssymb package.
T X

@ 8 @

0
(3

0 t

Ll

Table 8.4: Binary operation symbols

8.2 Fonts and Svmbols in Formulae


2

219
-

*
z

I c

\geq \sim \mid \subset \supseteq \neq \frown \vdash

< <
3

E
i

Table 8.5: Relation symbols

\leftarrow \Leftarrow \rightarrow \Rightarrow \leftrightarrow \Leftrightarrow \mapsto \hookleftarrow \leftharpoonup \leftharpoondown

-e=

---

\longleftarrow \Longleftarrow \longrightarrow \Longrightarrow \longleftrightarrow \Longleftrightarrow \longmapsto \hookrightarrow \rightharpoonup \rightharpoondown

Table 8.6: Arrow symbols

\ldots . . . \cdots : \vdots \prime V \forall w \infty 3 \exists V \nabla J \surd 0 \Diamonda I \imath J \jmath T \top b \flat 4 \natural 1 \bot 4 \clubsuit \diamondsuit U \mhoa It \Re 9 \Im a Not predefined i n NFSS. Use the latexsym or amssymb package.

...
f

'.. \ddots
h

d
$4 V
L

\hbar \Boxa \ell \sharp \heartsuit \angle

0
A

8 '
4

\aleph \emptyset \triangle \neg \V \spadesuit \partial

Table 8.7: Miscellaneous symbols

Table 8.8: Variable-sized symbols

220

Higher Mathematics

Table 8.9: Log-like symbols

Table 8.10: Delimiters

\rmoustache

I
11

\lmoustache \Arrowvert

]
I

\rgroup \bracevert

\lgr~up

\arrowvert

Table 8.11: Large delimiters

ax abc abc
6

\widet ildejabc}

\overlef tarrow{abc} \overline{abc} &,g \overbrace{abc} \sqrt{abc}

aTc + abc

\widehat{abc} \overrightarrow{abc} \underline{abc} \underbrace{abc} \ s q r t [n] {abc) \f rac{abc){xyz)

abc

a
f'

w
abc
XYZ

abc

f'

Table 8.12: L A T E X math constructs

\digamma

\varkappa

\beth

\daleth

\gimel

Table 8.13: AMS Greek and Hebrew (available with amssymb package)

\ulcorner

'

\urcorner

\llcorner

\lrcorner

Table 8.14: AMS delimiters (available with amssymb package)

8.2 Fonts and Symbols in Formulae


\dashrightarrow \leftrightarrows \leftarrowtail \curvearrowleft \upuparrows \multimap \rightleftarrows \twoheadrightarrow \rightleftharpoons \Rsh \downharpoonright \dashleftarrow \Lleftarrow \looparrowleft \circlearrowleft \upharpoonleft \leftrightsquigarrow \rightrightarrows \rightarrowtail \curvearrowright \downdownarrows \rightsquigarrow

22 1

Table 8.15: AMS arrows (available with amssymb package)

\nleftarrow \nRightarrow

++
. c

\nrightarrow \deftrightarrow

+ +

\nLeftarrow \nLeftrightarrow

Table 8.16: AMS negated arrows (avadable with amssymb package)

\leqslant \lessapprox \111 \lesseqqgtr \fallingdotseq \subseteqq \preccurlyeq \precapprox \vDash \smallfrown ,\geqq \gtrsim \ggg \gtreqqless \triangleq \supseteqq \succcurlyeq \succapprox \Vdash \between \blacktriangleleft \blacktriangleright

Table 8.17: AMS binary relations (available with amssymb package)

222

Higher Mathematics

Table 8.18: AMS negated binary relations (available with amssymb package)

Table 8.19: AMS binary operators (available with amssymb package)

Not defined in old releases of the arnssymb package; define with the \DeclareMathSymbol command.

Table 8.20: A M S miscellaneous (available with amssymb package)

8.3 Compound Symbols, Delimiters, and Operators

223

8.3 Compound Symbols, Delirniters, and Operators


This section1presents the math commands that are available through the amstex package, which supplements LATEX in the area of compound symbols, large delimiters, etc. In the examples, amstex's alignment environments are used. In principle a detailed understanding of how they work is not necessary at this stage, but an interested reader can turn to section 8.5 for more information.

8.3.1 Multiple Integral Signs


\ i i n t , \ i i i n t , and \ i i i i n t give multiple integral signs, with the spacing between them nicely adjusted, in both text and display style. \ i d o t s i n t gives two integral signs with dots between them.

(8.2) (8.3)

r l
v

~ ( u v .. w ) du d v d w

\iiiint\limits-V \mu(t,u,v,w)\,dt\,du\,dv\,dw\\ \idotsint\limits-V \mu(u-l,\dots,u-k) \end{gather)

JJJ//.I( t , U , V , w ) d t d u d v d w

8.3.2 Over and Under Arrows


Some extra over and under arrow operations are available. (In standard W X one has \ o v e r r i g h t a r r o w and \ o v e r l e f t a r r o w . )

They all scale properly in subscript sizes.

lSome material in this and the following sections is reprinted from the electronic document
te e t ar t . t e x with permission of the American Mathematical Society.

224

Higher Mathematics

8.3.3 Dots
Ellipsis dots should almost always be typed as \ d o t s . Positioning (on the baseline or centered) is automatically selected according to whatever follows the \dots. If the next character is a plus sign, the dots will be centered; if it's a comma, they will be on the baseline. These default dot placements provided by the amstex package can be changed if different conventions are wanted. If the dots fall at the end of a math formula, the next character will be something like \end or \) or $, which does not give any information about how to place the dots. If that is the case, you must help by using \ d o t s c for "dots with commas," or \ d o t s b for "dots with binary operators/relations," or \dotsm for "multiplication dots," or \ d o t s i for "dots with integrals." In the example below, low dots are produced in the first instance and centered dots in the others, with the spacing on either side of the dots nicely adjusted.
A series H I ,H z , . .., a regional sum H I + H 2 + - . . , an orthogonal product HlH2 . . . , and an infinite integral
A series $H-1 ,H-2,\dotsc$, a regional sum $H_l+H_2+\dotsb$, an orthogonal product $H_lH-2\dotsm$, and an infinite integral \C\int-CH-l)\int-~H-2>\dotsi\l

8.3.4 Accents in Math


The following accent commands automatically position double accents correctly:

This double accent operation is complicated and tends to slow down the processing of a L Q X file. If the document contains many double accents, you can use \accentedsyrnbol in the preamble of the document to help speed thngs up. It stores the result of the double accent command in a box register for quick retrieval. \accentedsymbol is used like \newcommand:
This is a double hat 2 and this 6 a delta with a bar and a dot.
\accentedsymbolC\Ahathat)C\HatC\Hat A ) ) \accentedsymbolC\dbardot)C\DotC\Bar \delta)) This is a double hat \(\Ahathat\) and this \(\dbardot\) a delta with a bar and a dot.

8.3 Com~ound Svmbols. Delimiters, and Operators

225

8.3.5 Superscripted Accents


Some accents have a wide form: typing $\widehat (xy), \widetildeCxy)$ produces $,@. Because these wide accents have a certain maximum size, extremely long expressions are better handled by a different notation: ( A ~ B D ) ~ instead of AmBD. amstex has the following control sequences to acheve this easily:

(8.5) (8.6) (8.7) (8.8)

(AmBD)* (AmBD)(AmBD)"

(AmBD)" (AmBD)' ( A m B D ) "'

(AmBD)'

\begin{gather) (AmBD) \sphat \qquad (AmBD) \spcheck \ \ (AmBD) \ & t i l d e \&&ad ( A ~ B \&dot D) \\ (A m B D ) \spddot \qquad (A m B D ) \spdddot \\ (AmBD)\spbreve \end{gather)

8.3.6 Dot Accents


\dddot and \ddddot are available to produce tripled and quadrupled dot accents in addition to the \dot and \ddot accents already available in W X :

8.3.7 Roots
In ordinary L A T E X the placement of root indices is sometimes not good. With amstex the commands \ l e f t r o o t and \uproot allow the adjustment of the position of the root. Positive arguments to these commands will move the root index to the left and up respectively, while a negative argument will move them right and down. The units of increment are quite small, which is useful for such adjustments. In the example below, the root index fl is moved 2 units to the left and 4 units up.

8.3.8 Boxed Formulae


The command \boxed puts a box around its argument, similar to \fbox, except that the contents are in math mode:

226

Higher Mathematics

8.3.9 Extensible Arrows


@>>>and @<<<produce arrows that extend automatically to accommodate unusually wide subscripts or superscripts. The text of the subscript or superscript is typed in between the > or < symbols.

See also section 8.4.4 on commutative diagrams. For keyboards without < and > keys, @I 11 and @ ( ( ( are available as synonyms.

8.3.10 \ o v e r s e t , \ u n d e r s e t , and \ s i d e s e t

'

L A T E X provides \stackre1 for placing a superscript above a binary relation. amstex introduces somewhat more general commands, \overset and \underset. These can be used to place one symbol above or below another symbol, independently of whether it is a relation or something else. The input \oversetC*)CX) will place a superscript-size above the X; \underset performs the parallel operation that one would expect.

There is also a command called \sideset that serves a rather special purpose: it puts symbols in the subscript and superscript positions of large operator symbols such as C and A prime example is the case when you want to put a prime on a sum symbol. If there are no limits above or below the sum, you could just use \nolimits:

n.

But if you want not only the prime but also limits on the sum symbol, things are not so easy. Suppose you want to add a prime on the sum symbol in an expression, like
(8.10)

1
n < k . n odd

nEn

\beginCequation) \sum-{n<k, \ ;n\ \mathrm(odd))nE-n \end{equat ion)

8.3 Compound Symbols, Delimiters, and Operators

22 7

then you can use \sideset like this: \sidesetC)C')\sum-C. . .)nE-n. The extra pair of empty braces is explained by the fact that \sideset has the capability of putting an extra symbol or symbols at each corner of a large operator.

Orirm

\sideset{){')\sum-{0\;e

i\le m) E-i\beta x

8.3.11

The \smash Command

The plain TEX command \smash retains the contents of a box but annihilates its height and depth. The arnstex package introduces the optional arguments t and b with the \smash command. \smash Ctl C . . . 3 annihilates only the top of the box contents, retaining the bottom part, whde \smash Cbl ( . . . 3 annihilates the bottom part and keeps the top.

The previous example shows how the \smash command was used to limit the depth of the radical, which otherwise extends to encompass the depth of the subscript (right-hand side of the formula).

8.3.12 The \ t e x t Command


The main use of the \text command, which is also available separately with the amstext package, is for words or phrases in a display. It is similar to the DTEX command \mbox in its effects, but has a couple of advantages. If you would like a word or phrase of text in a subscript, you can type

...-{\text{word

or phrase))

which, apart from having a more descriptive name, is also slightly easier to enter than the equivalent \mbox,since the correct size is automatically chosen:

...-C\mbox{\scriptsize

word or phrase))

\ [ \mathbf {y)=\mathbf {y}


y =y ' if and only if yi
=

'

6kyT(k)

\text{if and only if) y '-k=\delta-k y-C\tau(k) 1

\quad \quad \I

228

Higher Mathematics

8.3.13 Operator Names


Math functions such as log, sin, and lirn are traditionally set in roman type to help avoid confusion with single math variables, set in math italic. The more common ones have predefined names: \log, \sin, \lim, and so forth (see table 8.9 on page 220). New ones, however, come up all the time in mathematical papers. The amstex package provides \operatorname and \operatornamewithlimits for producing new function names that will have the same typographcal treatment. For instance, \operatornameCxxx) produces xxx in the proper font and automatically adds proper spacing on either side when necessary, so that you get AxxxB instead of A m . If you use a particular operator name often, you X file more readable by defining an abcan save some typing and make the W breviation, for example (the \: commands add some space; see table 8.21 on page 242):
I

Input text

IlfIlm

= esssup

XER"

If(x) I

Output text

YOU can use \operatornamewithlimits just like \operatorname;the only difference is the placement of subscripts and superscripts, as seen in the example above. With amstex the following operators are predefined: \varlimsup, \varliminf,\varinjlim,and \varprojlim. Here's what they look like in use:

8.3 Compound Symbols, Delimiters, and Operators

229

8.3.14 \mod and Its Relatives


Commands \mod, \bmod, \pmod, and \pod are provided to deal with the rather special spacing conventions of "mod" notation. \bmod and \pmod are available in EQX, but with amstex the spacing of \pmod will adjust to a smaller value if it is used in a nondisplay formula. \mod and \pod are variants of \pmod preferred by some authors; \mod omits the parentheses, whereas \pod omits the "mod" and retains the parentheses.
(8.15) (8.16) (8.17) u = v + 1 (mod n2) u - v + l modn2 u - v + l (n2)

8.3.15 Fractions and Related Constructions


In addition to \ f r a c (available in JkQX), amstex provides \ d f r a c and \ t f r a c as convenient abbreviations for { \ d i s p l a y s t y l e \ f r a c . . . ) and C \ t e x t s t y l e \ f r a c . . . 3. Furthermore, the thickness of the fraction line can be varied, using an optional argument of the \f r a c command.

I \f r a c [dimension] {...)I...)I

The \ f r a c w i t h d e l i m s command allows the delimiters around the fraction to be specified.

I \f racwithdelimsCleft de1imiter)Cright delimiter) [dimension]

For binomial expressions such as ( ) amstex defines the commands \binom, \dbinom, and \tbinom. \binom is an abbreviation for \f racwithdelims 0 [Opt].

I:

230

Higher Mathematics
The commands \dbinom and \tbinom are shorthands similar to \dfrac and \ t f r a c described above.

8.3.16 Continued Fractions


A continued fraction can be obtained as follows:

Left or right positioning of any of the numerators is achieved by using


\ l c f r a c or \rcf r a c instead of \cf rac.

8.3.17 Big-g-g-gDelimiters
In order to better control the sizes of math delimiters, basic TEX introduces four commands \big, \Big, \bigg and \Bigg, which produce ever larger versions of the delimiter specified as parameter. These commands can be used with any of the delirniters that can follow the \ l e f t or \ r i g h t command (see tables 8.10, 8.11, and 8.14 on page 220). Moreover, for each of the four commands above, three variants exist for use as an opening symbol (e.g., \bigl), as a binary relation (e.g., \Bigm), or as a closing symbol (e.g., \ ~ i ~ Whereas, ~ r ) . with ~ basic
2 ~ etable e 7.13 on page 206 for a discussion o f the various math symbol types.

8.4 Matrix-Like Environments and Commutative Diagrams

231

TEX, the sizes of these delimiters are fixed, with the amstex package the sizes adapt to the size of the surrounding material.

8.4 Matrix-Like Environments and Commutative

Diagrams
8.4.1 The cases Environment
"Case" constructions can be produced using the cases environment.
(8.20)

Pr-j

i f r - jis odd, r!(-l)(r-J712 ifr-jiseven.

\begin{equation) P-Cr- j ) = \beginCcases) O& \textCif $r-j$ is odd),\\ \textCif $r-j$ is even). r!\, (-1)-C(r-j)/2)& \endCcases) \endCequation)

Notice the use of \text and the embedded math.

8.4.2 The Matrix Environments


The matrix environments are similar to L A T E E X S ' array, except they do not have an argument specifying the format of the columns. Instead, a default format is provided: up to 10 centered columns. The examples below show how to use the matrix environments matrix, pmatrix, bmatrix, m a t r i x , and Vmatrix:

232

Higher Mathematics
The maximum number of columns is determined by the counter
MaxMatrixCols, whch you can change using L A T E X S ' standard counter com-

mands. For example, suppose you have a large matrix with 19 or 20 columns, then you can do something like this:

A T E X , you might want to reset the value of As counters are global in L


MaxMatrixCols to its default value of 10 after finishing your wide matrix, since

with a high value, W X must work a lot harder to typeset a matrix. To produce a small matrix suitable for use in text, use the smallmatrix environment.
To show the effect of the matrix on surrounding lines inside a paragraph, we put it here: (: $) and follow it with enough text to ensure that there is at least one full line below the matrix.
To show t h e e f f e c t of t h e matrix on surrounding l i n e s i n s i d e a paragraph, w e put it here : \beginCmath) \ l e f t ( \begin{smallmatrix) a&b\\ c%d \end{smallmatrix) \ r i g h t ) \end{math) and follow it with enough t e x t t o ensure t h a t t h e r e i s a t l e a s t one f u l l l i n e below t h e matrix.

A row of dots in a matrix, spanning a given number of columns, can be obtained with the command:

The spacing of the dots can be varied by using the optional parameter spacing-factor,for example, \hdotsf o r [ I . 51 (3). The number in square brackets multiplies the spacing between the dots; the normal value is one.

8.4 Matrix-Like Environments and Commutative Diagrams

233

Input text

Output text

8.4.3 The Sb and Sp Environments


The Sb and Sp environments can be used to typeset several lines as a subscript or superscript, using \\ as the row delimiter. These environments can be used anywhere an ordinary subscript or superscript can be used.

Orirm O<j<n

8.4.4 Commutative Diagrams


The commutative diagram commands of A~MS-TEX are not included in the amstex package, but are available as a separate package, amscd. This conserves memory for users who do not need commutative diagrams. The picture

234

Higher Mathematics environment can be used for complex commutative diagrams, but for simple diagrams without diagonal arrows the amscd commands are more ~onvenient.~
\newcommand{\End~{\operatorname~End)) \beginCequation*) \begin{CD) S-C{\mathcal{W))-\Lambda)\otimes TO>j>>T\\ @vw @WI\End P)V\\

s Wo ~T

I
( S 8 T )/ I

IEndP

( Z @ T )/ J

(S\otimes T)/I \end{CD) \endCequation*)

O= (Z\otimes T ) / J

A similar result, which does not look quite as good, can be produced in ordinary L A T E Xby:
\[ \beginCarray){ccc)
S-{\mathcal{W)-\Lambda)\otimes \stackrelCj){\longrightarrow) T

sW~o T A (SoT)lI

End P

T &
&

(ZoT)lJ

\\

When using the amscd package, you will obtain longer horizontal arrows and improved spacing between elements of the diagram. In the CD environment the commands Q>>>, a<<<, QWV,and QAAA give (respectively) right, left, down, and up arrows. For people with keyboards lacking the angle brackets the notations Q) ) ) and Q(( ( are available as alternatives. For the horizontal arrows, material between the first and second > or < symbols will be typeset as a superscript, and material between the second and third will be typeset as a subscript. Similarly, material between the first and second, or second and third, A's or V's of vertical arrows will be typeset as left or right "sidescripts." This was used in the first example above to place the operator "End P" to the right of the arrow.
3 ~ u c more h extensive commutative diagram packages are Kristoffer Rose's XY-pic system 1731, Paul. Taylor's Commutative Diagram package [80],and the Diagram 3 system by Francis Borceux [14].

8.5 Alignment Structures for Equations

235

The final example again shows the use of \operatorname.

cov(L)

-non(K) - cftX)
add(X) nontX)

\begin{equation*)

add(L)

I - I - I

\newcommand{\add){\operatorname{add3) \newcommand{\cf~{\operatorn~cf)) \newcommand{\cov~{\operatorname{cov)) \newcommand{\non){\operatorname{non))


\begin{CD) \cov(\mathcal{L)) QWV QAAA QAAA \add(\mathcalL)) \endCCD3 \end{equation*) Q>>> \non(\mathcal{K)) a>>> \cf (\mathcal{K))

\\ \\

a>>> \add(\mathcal{K)) Q>>> \non(\mathcal{K))\\

8.5 Alignment Structures for Equations


The amstex package defines several environments for creating multiline display A T E X S ' equation and eqnarray environequations. They perform similarly to L ments. The following structures are discussed in the next sections.
align alignat xalignat equation gather multline split align* alignat* xxalignat equation* gather* multline*

alignment at a single place alignment at several places spaced-out variants of the above one-lineformula combining formula without alignment multiline equation (one equation number) splitting long formulas

Some of these multiline display environments allow you to align parts of the formula. In contrast to the original IK&X environments eqnarray and eqnarray*, the structures implemented by the amstex package use a different concept for marking the alignment points: while eqnarray is similar to an array environment with a Crcl) preamble and therefore uses two ampersand characters surrounding the part that should be aligned, in the amstex structures you should mark the alignment point (or points in alignat, for example) only with a single ampersand character, placing it to the left of the character that should be aligned with previous or following lines. The amstex structures give correct spacing around the alignment points, while the eqnarray environment produces extra spaces depending on the parameter settings for array. The difference can be seen clearly in the next example, where we typeset the same equation using the equation, align, and

236

Higher Mathematics
eqnarray environments; ideally all three should produce the same result, but the eqnarray environment comes out too wide.
\beginCequat ion) x-2+y-2 = 2-2 \endfequat ion) \beginfalip) x-3+ye3 &< 2-3 x-2+y-2 &= 2-2 \ \ \endfalip) \beginfeqnarray) xA2+y-2 &=& 2-2 \ \ x-3+y-3 &<& 2-3 \endCeqnarray)

8.5.1 The a1ign Environment


The a l i g n environment is used for two or more equations when vertical alignment is desired (usually binary relations such as equal signs are aligned). The term "equation" is used rather loosely here to mean any math formula that is intended by an author to be a self-contained subdivision of the larger display, usually, but not always, containing a binary relation.

More examples are shown in section 8.7.4 on page 248.

8.5.2 The gather Environment


Like the a l i g n environment, the gather environment is used for two or more equations, but when there is no abgnment desired among them each one is centered separately between the left and right margins.

More examples are shown in section 8.7.3 on page 248.

8.5 Alignment Structures for Equations

237

8.5.3 The a l i g n a t Environment


The align environment takes up the whole width of a display. If you want to have several "alignv-typestructures side by side, you can use an alignat environment. It has one required argument, for specifying the number of "align" structures. For an argument of n, the number of ampersand characters per line is 2n - 1 (one ampersand for alignment withn each align structure, and ampersands to separate the align structures from one another). xalignat and xxalignat are forms of the alignat environment with added space between the component align structures. If each align structure is considered to correspond to a column, then xalignat has equal spacing between columns and at the margins; xxalignat has equal spacing between columns and zero spacing at the margins.

Note that with xxalignat equation numbers do not make sense, so none are generated. More examples are shown in section 8.7.6 on page 250.

8.5.4 The mult l i n e Environment


The multline environment is a variation of the equation environment used for equations that do not fit on a single line. The first line of a multline will be at the left margin and the last line at the right margin except for an indention on both sides whose amount is equal to \multlinegap. The value of \multlinegap can be changed using L A T E X S ' \setlength and \addtolength commands. If multline contains more than two lines, any lines other than the first and last

238

Higher Mathematics will be centered individually between the margins.

(8.35) First line of equation

Middle line of equation Other middle line of equation Last line of equation

\begin{multline) \text{First line of equation) \\ \textCMiddle line of equation) \\ \textCOther middle line of equation) \ \ \textCLast line of equation) \end+,,ultline)

More examples are shown in section 8.7.2 on page 247.

8.5.5 The split Environment


Like multline, the s p l i t environment is for single equations that are too long to fit on a single line and hence must be split into multiple lines. Unlike multline, however, the s p l i t environment provides for alignment among the split lines, using an ampersand to mark alignment points, as usual. In addition (unlike the other amstex equation structures) the s p l i t environment provides no numbering because it is intended to be used only inside some other &splayed equation structure, such as equation, align, or gather. These outer environments will provide the numbering.

a4 + 4a3b + 6a2b2+ 4ab3 + b4

&= a-4+4a-3b+6a-2b-2+4ab-3+bA4\ \ \end{split) \end{equat ion)

When the ctagsplt option is specified, the equation number for the s p l i t environment will be centered vertically on the height of the s p l i t , provided there is enough room for it.

a3 + 3a2b + 3ab2 + b3

&= (a+b) (aA2+2ab+b-2) \ \ &= aA3+3a-2b+3ab-2+b-3 \ \

\end{split) \end{equat ion)

More examples are shown in section 8.7.1 on page 244.

8.5 Alignment Structures for Equations

239

8.5.6 Alignment Environments as Parts of Displays


In addition to the split environment, there are some other equation alignment environments that do not constitute an entire display. They are self-contained units that can be used inside other formulae, or set side by side. The environment names are: aligned,gathered,and alignedat. These environments take an optional argument to specify their vertical positioning with respect to the material on either side. The default alignment is centered ( [cl ), and its effect is seen in the following example.

The same mathematics can now be typeset using different vertical alignments for the environments.

8.5.7 Vertical Spacing and Page Breaks in Equation Structures


You can use the \\[dimension1 command to get extra vertical space between X . lines in all the amstex displayed equation environments, as is usual in W Unlike eqnarray, the amstex environments do not allow page breaks between lines, unless \displaybreak or \allowdisplaybreaks is used. The reason for this is that page breaks in such situations should receive individual attention from the author. \displaybreak must go before the \ \ where it is supposed to take effect. Like WX's \pagebreak, \displaybreak takes an optional argument between zero and four denoting the desirability of the page

240

Higher Mathematics
break. \displaybreak [Ol means "it is permissible to break here" without encouraging a break; \displaybreak with no optional argument is the same as \displaybreak [41 and forces a break. There is also an optional argument for \allowdisplaybreaks. T h s command obeys the usual Q X scoping rules. The normal way of limiting its scope is to put {\allowdisplaybreaks at the beginning and ) at the end of the desired range. Within the scope of an \allowdisplaybreaks command, the \\* command can be used to prohibit a page break, as usual.

8.5.8 The \ i n t e r t e x t Command


The \intertext command is used for a short interjection of one or two lines of text in the middle of a display alignment. Its salient feature is the preservation of alignment, which would not be possible if you simply ended the display and then started it up again afterwards. \intertext may only appear immediately after a \ \ or \\* command.
\begin{alip) A-1&=N-O(\lambda;\Omegal) \phi(\lambda;\Omega'), A_2&=\phi(\lambda;\Ornega') \phi (\lambda;\Omega) , \intertext{and finally) A-B&=\mathcalCN) (\lambda;\omega) . \endlalip)

\\
\\

and finally

Here the words "and finally" fall outside the display at the left margin.

8.6 Miscellaneous
This section discusses amstex commands that have not been introduced yet, and it gives a list of the document class files that come with the AMS-IPQX distribution.

8.6.1 Equation Numbers


Each environment, except for split, has both starred and unstarred forms, A T E X S ' equation where the unstarred forms have automatic numbering, using L counter. The number on any particular line can be suppressed by putting \notag before the \\. You can also override it with a tag of your own design using

8.6 Miscellaneous

241

where label can be any arbitrary text to be used to number the equation. The starred form, \tag*,causes the label to be typeset without any annotations like parentheses that might otherwise be added by the document class. \tag and \tag* can also be used in the starred versions of all the amstex alignment environments.

Notice the use of the \label and \ref commands in the previous example to allow subnumbering of equations. When the option righttag is specified, the equation number will be printed at the right side of the equation (by default, with amstex, it comes out at the left).

8.6.2 Resetting the Equation Counter


In LATEX, if you want to have equations numbered within sections-that is, have (1.2),. . . , (2.1), (2.2),. . . , in sections 1,2, and so forthequation numbers (1.1), you would probably redefine \theequation:

But now you have to reset the equation number by hand at the beginning of each new section or chapter. To make this a little more convenient, amstex provides a command \numberwithin. To have equation numbering tied to section numbering, with automatic reset of the equation counter, the command is

As the name implies, \numberwithin can be applied to other counters besides the equation counter, but the results may not be satisfactory in all cases

242

Higher Mathematics

Abb. \ \: \; Q,

Positive space ex. Spelled out


XX

xx
XX XX

\thinspace \medspace \thickspace \quad \qquad

Abb. \!

Negative space ex. Spelled out


M

Q!

w . m xx

\negthinspace \negmedspace \negthickspace

x x x x

Table 8.2 1: The mathematical spacing commands

because of potential complications. Normal I4QX methods should be used where available, for example, in \newtheorem4 To make cross-references to equations easier, an \eqref command is provided. This automatically supplies the parentheses around the equation number, and adds an italic correction before the closing parenthesis, if necessary. To refer to an equation that was labeled with the label e :baset, the usage would be
\eqref{e:baset).

8.6.3 Fine-Tuning Spacing in Math Mode


Although TEX generally does a good job of spacing elements of formulae inside mathematics, it is sometimes necessary to fine-tune the position of one or two of those elements. Therefore, the spacing commands shown in table 8.21 are provided. Both the spelled-out and abbreviated forms of these commands are robust, and they can also be used outside of math. The commands Q , and Q ! typeset one-tenth the space of \ , and \ ! respectively, for extra fine-tuning where necessary.

8.6.4 A Few Points to Note


(L151-52)
Many of the commands added by the amstex package are fragile and will need to be \protected in commands with "moving arguments." In amstex, the Q character has a special use in the extensible arrows Q>>> and a<<< and in the math microspacing commands 0, and Q ! . In order to get an ordinary printed @ character you should type @@ instead of Q. With the various alignment environments available in the amstex package, the eqnarray environment is no longer needed. Furthermore, since it does not prevent overlapping of the equation numbers with wide formulae, as most of the
4 ~ e also e the discussion of the \@addtoreset command on page 22.

8.6 Miscellaneous

243

amstex alignments do, using the amstex alignments seems better. amstex reirnplements the L A T E X e q u a t i o n environment as a one-line g a t h e r environment, and adds an unnumbered version, e q u a t i o n * , for symmetry. Note, however, that the command \ v e r b might not work in the alignment environments. \nonumber is interchangeable with \ n o t a g ; the latter seems slightly preferable, for consistency with the name \ t a g .

8.6.5 Options and Sub-packages to the amstex Package


A few options are recognized by the amstex package and the classes provided by AMS-lQX.S They affect the positioning of math operator limits or \tags. ctagsplt The text of the tags is vertically centered with respect to the height of the s p l i t environment. intlim The limits of an integral have to be placed above and below rather than on the side of the integral symbol.

nonamelm The lirmts of an "operator"name have to be placed on the side rather than above and below the operator symbol. nosumlim The h i t s of a sum have to be placed on the side rather than above and below the sum symbol. righttag T h s will output equation tags on the right rather than on the left. Also, some of the component parts of the amstex package are available in&vidually and can be used separately in a \ u s e p a c k a g e command: amsbsy defines the amstex \ b o l d s y m b o l and (poor man's bold) \pmb commands. amscd defines some commands for easing the generation of commutative diagrams.

amsfonts defines the \ f r a k and \Bbb commands and sets up the fonts msam (extra math symbols A), msbm (extra math symbols B, and blackboard bold), eufm (Euler Fraktur), extra sizes of cmmib (bold math italic and bold lowercase Greek),and cmbsy (bold math symbols and bold script), for use in mathematics.

l l the math symbols available with the A m S amssymb defines the names of a fonts collection.
amstext defines the amstex \ t e x t command.
5~~ is only true for the L ~ T E Xrelease ~~ of theseoptionsas sub-packages.

AM-~TEX. Older versions of ~ ~ S - L ~ T realize EX

244

Higher Mathematics

The amsbsy, amstext, and amsfonts packages are included automatically when you use the amstex package. The other two, amssymb and amscd, can be used together with amstex if their functionality is needed.

8.6.6 A m S --L"TEX Doccwent Classes


The ANS-LATEX package comes with a pair of document classes called amsart and amsbook, corresponding to IPQX's article and book. They are primarily designed to prepare manuscripts for submission to the AMS, but there is nothng to prohibit their use for other purposes. With these class files the amstex package is automatically included, so that you can start your document simply with
\documentclassCamsart~~r\documentclass~amsbook~.

8.7 Examples of Multiple-Line Equation Structures


On the following pages we show a lot of real-life examples of the alignment environments discussed earlier. The lines indicating the margins around the typeset examples are not part of the environments but have been added to make the marginal spacing stand out clearly.

8.7.1 The s p l i t Environment


The split environment is not an independent environment but should be used inside something else, such as equation or align. If there is not enough room for it, the equation number for a split will be shifted to the previous line when equation numbers are on the left; the number shfts down to the next line when numbers are on the right. When you do not want an equation number, use the equation* environment.

T h s was produced by the following input (the T E X command \phantom is used to leave a space equal to the width of its argument):

8.7 Exatn~les of Multi~le-Line Eauation Structures

245

\begin{equation) \begin{split) f-{h,\varepsilon)(x,y) %= \varepsilon \ m a t h b f { E ) { x , y ) \int-0-{t-\varepsilon) L-{x, y-\varepsilon(\varepsilon u) 3 \varphi(x) \ , du \\ %= h \int L { x , z ) \varphi(x) \rho-x (dz) \\ & \quad +h \biggl[ \frac{l){t-\varepsilon) \biggl( \ m a t h b f { E ) { y ) \int-0-Ct-\varepsilon) L { x , y x ( s ) ) \varphi(x)\,ds -t-\varepsilon \int L-{x,z) \varphi(x) \rho-x(dz) \biggr) \ \ % \phantom{{=)+h\biggl [ ) + \ f rac{l){t-\varepsilon) \biggl( \ m a t h b f { E ) { y ) \int-0-{t-\varepsilon) L { x , y x ( s ) ) \varphi(x) \,ds - \ m a t h b f { E ) { x , y ) \int-0-{t-\varepsilon) L~{x,y~\varepsilon(\varepsilon s ) ) \varphi (x) \ ,ds \biggr) \biggr] \\ \end{split) \endCequation)

If the option ctagsplt is included in the options list of the amstex package, the equation numbers for s p l i t environments will be centered vertically on the height of the s p l i t , as shown in the example below.

This is produced by the following input:


\begin{equation) \begin{split) 11-21 %=\left1 \ i n t { O ) T \psi(t)

\left\{ u(a,t)-\int-{\gamma(t))-a \frac{d\theta){k(\theta,t)) \int-{a)-\theta c(\xi)u-t(\xi,t)\,d\xi \right\) dt \right I \\ &\le C-6 \left 1 \left 1 f\int-\Omega \left I \widetilde{S)-{-l,O)_Ca, -1 W-2 (\Omega,\Gamma-1) \right I \right l \left I lul\overset{\circ)\to W-2-{\widetilde{A)) (\Omega;\Gamma-r,T) \right1 \right1 . \end{split) \end{equat ion)

246

Higher Mathematics

One further example involving s p l i t and align. To obtain unnumbered equations use the a l i g n * environment instead.

The input for the above formulae is:

8.7 E x m l e s of Multi~le-Line Eauation Structures

247

8.7.2

The m u l t l i n e Environment

Numbered version:
l(8.47)
=

+f ( ~ ) ~ g ( x2 )~ f (l x ) g ( x ) f g y dxl d y

la la
b b

{ ~ ( Y I ~ f2

+f ( ~ ) '

la
b

g2 - 2 f ( y ) g ( y ) f g l d y

This was obtained with the lines shown below.

An unnumbered version of the above is obtained with the same input, except the multline environment is replaced by multline*.

And now an unnumbered version numbered with a \tag* command.

This was generated with:

This is the same display, but with \multlinegap set to zero. Notice that the space on the left of the first line does not change, because of the equation number, while the second line is pushed over to the right margin.
f ( ~ ) ~ g(2 ~f ( )~ ~) l g ( x ) f ( y ) dxl g(~ d)y [a1 r a{ l a b [ f ( ~ ) 2 g+ (~ )2

248

Higher Mathematics
This was generated with:
C\setlengthC\multlinegap)C0pt) \beginCmultline*)\tag*C [a] ... \end{multline*))

8.7.3 The gather Environment


Numbered version with \notag on the second line: (8.48) (8.49) (8.50) D(a, r ) {Z E C: IZ - a1 < r}, seg(a, r ) = {z E C: 9z = Sa, lz - a1 < r},

c ( e ,8, r )

{(x,y)

C:

C ( E ,0, r )

IX

< ytan8, 0 < y < r}, U c ( e ,8,r).


- el
eeE

This was generated with:

8.7.4 The a l i g n Environment


Numbered version: (8.51) (8.52) (8.53)
0(

yx(t) = ( C O S ~ U+ s i n t x , ~ ) , yy(t) = ( U , C O S ~ sinty), V+

This was produced using the following input:


\begin{align) \gamma-x(t) &= (\cos tu + \sin tx, v), \\ \gamma-y(t) &= (u, \cos tv + \sin ty) , \\ \gamma-z(t) &= \left( \cos tu + \frac\alpha\beta \sin tv, - \frac\beta\alpha \sin tu + \cos tv \right). \endCalign)

8.7 Examples of Multiple-Line Equation Structures

249

Unnumbered versjon:

This was generated using the following construct:


\beginCalign*)

.. .

\endfalip*)

8.7.5 Using the a l i g n and s p l i t Environments within g a t h e r


When using the a l i g n environment within the gather environment, one or the other, or both, should be unnumbered (using the * form), since having numbering for both the outer and inner environment would not be meaningful. Automatically numbered gather with s p l i t and align*:

Here the s p l i t environment gets a number from the outer gather environment; numbers for individual h e s of the align* are suppressed because of the star.
\begidgather) \begin{split) \varphi (x, z) &= z - \gamma-C10) x - \sum_Cm+n\ge2) \gamma-Cmn) x-m z-n \ \ &= z M r-C-13 x - \sum_Crn+n\ge23 M r-C-(m+n)) x-m z-n \end{split) \ \ C6ptl \begin{align*I \zetaaO &= (\xiAO)-2, \\ \zetael &= \xieO \xi-1 \end{align*) \end{gather)

2 50

Higher Mathematics
Shown below, is the *-ed form of gather with the non-*-ed form of align.

The latter was produced with the following construct:

8.7.6 Using the alignat Environments


Numbered version:

(8.57) (8.58)

Vi = Vi - qivj, V j = Vj,

X i =x i - qixj, Xj= Xj,

U i= ui, for i f j; Ujuj+ qiUi. i+j

This example was obtained with the commands below:

Unnumbered version:

V i= Vi - qiVj, V j = Vj,

Xi= Xi - qiXj, Xj= Xj,

U i = Ui, for i f Ujuj + qiui.

J;

i#j

This was generated using the following construct:

8.8 Extensions to the the orem Environment

251

The most common use for alignat is for things like

This example was obtained with the commands below:


\beginCalignat)C2) x &= y && \qquad \textCby (\refCeq:A)))\labelCeq:C) && \qquad \text(by (\refCeq:B)))\labelCeq:D) xJ &= y' x + x' &= y+yJ && \qquad \textCby Axiom 1.) \endCalignat )

\\ \\

The expanded version, xalignat: by (8.59) by (8.60) by Axiom 1. This was generated using the following construct:

8.8 Extensions to the theorem Environment


The theorem package, developed by Frank Mittelbach 1541, offers an extension of the L A T E X theorem mechanism by allowing the layout of theorems to be manipulated by specifying a style. In the present context the word "theorem" is used for any kind of labeled enunciations, often set off from the main text by extra space and a font change. Theorems, corollaries, conjectures, definitions, and remarks are a l l instances of "theorems." The header of these structures is composed of a label (such as THEOREM or REMARK) and a number, which serializes an item in the sequence of items with the same label. Often it is necessary, in order to satisfy the requirements of different mathematics journals, to customize the layout of the theorem environment. Additionally, different formats may be needed to differentiate the "sort of theorem": e.g., remarks and definitions are set in roman, whde italic is employed for main theorems.
( L 58, 174)

252

Higher Mathematics

8.8.1 Defining New Theorem Environments


As in the original L A T E X version, the command \newtheorem defines a new "theorem-like structure." Two required arguments name the new environment and give the text to be typeset with each instance of the new environment, while an optional argument determines how the environment is enumerated:

The above \newtheorem command defmes the env-name environment and its printed name d l be label-text. It uses its own counter.

I \newtheorem{env2-name) [env-name] {label-text21 I


The above \newtheorem command defines the env2-name environment, and its printed name will be label-text2. It uses the same counter as theorem set env-name.
[\newtheorem{env3-nameHlabe1-text31 [section]

The above variant defines the env3-name environment and its printed name is label-text3. Its counter is enumerated within the counter section, that is, with every new \ s e c t ion the enumeration starts again with one, and the enumeration is composed from the section number and the theorem counter itself.

The \theoremstyle command can define the layout of various, or all, theorem sets. It should be noted that any theorem set defined by \newtheorem is typeset in the \theoremstyle that is current at the time of the definition. Thus, the following
\theoremstyle{break) \theoremstyle{plain) \neutheorem~Cor)~Corollary) \neutheorem{Exa){Example) [section]

leads to the result that the set Cor is formatted in the style break, while the set Exa and all the following ones are formatted in the style plain, unless another \theoremstyle follows. Since the definitions installed by \newtheorem are global, you can also limit \theoremstyle locally by grouping braces.

The choice of the font for the theorem body is completely independent of the chosen \theoremstyle; this has proven to be very advantageous. For example,

8.8 Extensions to the theorem Environment

253

Emulates the original L A T E X definition, except that additionally the parameters \theorempreskipamount and \theorempostskipamount are used. break In this style, the theorem header is followed by a line break. marginbreak The theorem number is set in the margin, and there is a line break as in break. changebreak Like break, but with header number and text interchanged. change Header number and text are interchanged, without a line break. margin The number is set in the left margin, without a line break. Table 8.22: List of existing theorem styles All styles (except plain) select \normalfont\slshape as the default for \theorembodyfont. defines a theorem set Rem, which will be set in \rmf amily in the current layout (whlch in our example is plain). As with \theoremstyle, the \theorembodyf ont chosen is that which is current at the time of \newtheorem. If \theorembodyf ont is not specified or you define \theorembodyf ontC), then the font used will be definedby\theoremstyle.

plain

It is also possible to customize the font used for the theorem headers. This is, however, a global declaration and, therefore, there should be at most one \theoremheaderf ont command in the preamble. If it is actually necessary to have different header fonts, you will have to define new theorem styles (substituting the desired font). Two additional parameters affect the vertical space around the theorem environments: \theorempreskipamount and \theorempostskipamount define, respectively, the spacing before and after such an environment. These parameters apply to all theorem sets and can be manipulated with the ordinary length macros. They are rubber lengths, and therefore can contain plus and minus parts. These parameters are set using the \setlength command. The commands to define theorem sets, as described in this section, can only be placed in the document preamble or in a package file. Theorem styles, which exist to date, are shown in table 8.22

8.8.2 Examples of the Definition and Use of Theorems


Suppose that the preamble contains the declarations:

2 54

Higher Mathematics

Then the typical examples below show the typeset output resulting from their use.
COROLLARY 1

This is a sentence typeset in the theorem environment Cor.

\begin{Cor) This is a sentence typeset in the theorem environment \ L e n v { C o r ) . \end{Cor)

EXAMPLE 8.8.1 This is a sentence typeset in the theorem environment Exa.

\beginCExa) This is a sentence typeset in the theorem environment \LenvCExa). \ e n d ( E x a )

REMARK 1 This is a sentence typeset in the theorem environment Rem.

\begin{Rem) This is a sentence typeset in the theorem L e n v { R e m ) . environment \ \end{Rem)

2 LEMMA (BENUSER)

This is a sentence typeset in the theorem environment Lem.

\begin{Lem) [Ben User] This is a sentence typeset in the theorem environment \ L e n v { L e m ) . \endCLem)

3 DEFINITION (VERY IMPRESSIVE D E F ~ N This )

is a sentence typeset in the theorem environment Def.

\begin(Def) [Very impressive Definition] This is a sentence typeset in the theorem environment \Lenv(Def) . \endCDef1

The last two examples show the effect of the optional argument to a theorem environment (it is typeset in parentheses right after the label).

8.8.3 Special Considerations


The theorem header and body are implemented as a single unit. This means that the \theoremheaderfont will inherit characteristics of the \theorembodyfont if the NFSS is being used. Thus, if, for example, \theorembodyfont is \itshape and \theoremheaderfont is \bf series the font selected for the header will have

8.9 Mathematical Style Parameters

255

the characteristics "bold extended italic." If this is not desired you should set it to something like \theoremheaderf ont{\normalf ont\bf series). That is, you should supply all the necessary font information explicitly. See chapter 7 for more details about how to do that.

8.9 Mathematical Style Parameters


This section explains how you can globally control the style of your mathematical formulae, and how you can modify the size of certain (sub)formula elements.

8.9.1 Controlling the Size of Characters


Letters and mathematical symbols sometimes get smaller when they appear in fractions, superscripts, or subscripts. In fact, TEX has eight different styles in which it can treat formulae, namely:
D , D' T , T' S , St SS, SS'
\displaystyle \textstyle \scriptstyle \scriptscriptstyle

formulae displayed on lines by themselves formulae embedded in the text formulae used as super- or subscripts second- and hgher-order super- or subscripts

The accented symbols represent the so-called cramped styles, which are similar to the normal styles except that exponents are not raised so much. TEX also uses three different type sizes for mathematics, namely: text size, script size, and scriptscript size. A formula set inside text (between a $ pair, or between \ ( . . . \)) is typeset using text style (style T). A formula on a line by itself, which is entered between \ [ . . . \ I , will be typeset in display style (style D). The size of the different parts of a formula can be determined according to the following scheme:
A symbol in style D , D', T , T' S , S' SS, SS'

will be typeset in text size script size scriptscript size

(example) (text size)


(script size)
rscriptscript size)

The kind of style used in mathematics formulae is as follows: style D D' T T' S,SS S',SS1 superscript S St S St SS SS' subscript St S' St St SS' SS' numerator T T' S St SS SS' denominator T' T' St St SS' SS'

2 56

Higher Mathematics The last two columns describe the style used in the numerator or denorninator of a fraction. An example of the various styles can be seen in the continued fraction below (see also section 8.3.16):

In the formula above the b of b0 is in style D, with the 0 in style S; the a and b of a1 and bl are in style T and T ' , respectively, with the exponent 1 in style S and the subscript 1 in style S f ;the a and b of a* and b2 are both in style S', with the exponent and subscript in style SS'; finally everything in a3 and b3 is in style SS'. You can give a nicer look to the above example by deciding whlch style is to be used in each case. Note that to save typing, we define the abbreviation \D for the \ d i s p l a y s t y l e command.

8.9.2 IF&X Math Style Parameters


(L 170) A T E X uses much of the mathematical machinery from TEX, we briefly Because L describe the mathematical style parameters that W X uses to typeset formulae. All these parameters are expressed as lengths, which you can redefine with the \ s e t l e n g t h or \addtolength commands (see section A.1.4 on page 447). Moreover, two standard options, leqno and fleqn, control the numbering and alignment of formulae. The option fleqn causes formulae to be aligned on the left, a fixed distance from the left margin (see \mathindent below), instead of being centered. The option leqno causes the formula numbers produced by the equation and eqnarray environments to appear on the left, instead of at the right. Note X puts equation numbers at the right by default, while with the amstex that W package activated, they are at the left. Therefore, with amstex you have to specify the option righttag to have them at the right (see section 8.6.5 on page 243).

(L 82)

8.9 Mathematical Style Parameters

257

In the list of mathematics style parameters below, all lengths (except


\jot and \arraycolsep) are rubber lengths. With the option fleqn, the four displayskip lengths are made equal to the list defming length \topsep, to which the value of \partopsep is added if the display starts a paragraph (see figure 3.5 on page 62). \arraycolsep This gives half the width of the horizontal space between columns in an array environment (default value 5pt, see also section 5.3.2). \jot This is the extra vertical space that is added between rows in an eqnarray or eqnarray* environment (default value 3pt). \mathindent This defines the indentation from the left margin of displayed formulae for the fleqn option (the default value is equal to the indentation of a first level list, i.e., 2.5em, and is defined by the option fleqn). \abovedisplayskip This specifies the extra space left above a long displayed formula, except with the option fleqn,where \topsep is used. A long for-

mula is one that lies closer to the left margin than does the end of the preceding line (default value 12pt plus 3pt minus 9pt). \belowdisplayskip This specifies the extra space left below a long displayed formula, except with the option fleqn,where \topsep is used (default value
12pt plus 3pt minus 9pt). \abovedisplayshortskip This specifies the extra space left above a short displayed formula, except with the option fleqn, where \topsep is used. A

short formula is one which starts to the right of where the preceding line ends (default value Opt plus 3pt). \belowdisplayshortskip This specifies the extra space left below a short displayed formula, except with the option fleqn,where \topsep is used (default value 7pt plus 3pt minus 4pt).

C H A P T E R

LATEX in a Multilingual

Environment
This chapter starts with a short introduction to the many technical problems that must be solved in order to use (LA)TEXwith a non-English language. The second section discusses the Babel system, which provides a convenient way for generating documents in different languages. Then, as an example of a more complex package, we have a look at the package french, developed by Bernard Gaulle. It goes a long way towards adapting the look and feel of documents to French typographic traditions.

9.1 T E Xand Non-English Languages


Due to its popularity in the academic world, TEX spread rapidly throughout the world and is now used, not only with the different languages based on the Latin alphabet, but also with Chinese, Japanese, Korean, Coptic, Russian, Thai, Vietnamese, several Indian languages, Persian, Arabic, and Hebrew. These develmore evident, especially opments quickly made some of the limitations of T~x2.x the 7-bit input character set and its inability to load hyphenation patterns for more than one language at the same time. Consequently, Donald Knuth announced at the 10th Annual Meeting of TUG in 1989 that a new version of T E X and METAFONT would be produced to address the problems of multilingual support. These versions, TEX3 and METAFONTZ, were officially released in March 1990. Although they were a (large) step in the right direction, by them-

260

L Q X in a Multilingual Environment

selves they do not solve all the problems associated with providing a convenient environment for using L A T E Xwith multiple or non-English languages. E X and its companion programs should be made truly To achieve this, T international, and the following points should be addressed: 1. Adjust all programs to the particular languageb): create proper fonts containing national symbols, define standard character set encodings, and generate patterns for the hyphenation algorithm.
2. Provide a translation for the document element terms, create national layouts for the standard documents, and provide TEXcode to treat the languagedependent typesetting rules automatically.

3. Support the processing of multilingual (more than one language in the same document) and international (one language only, but a choice between various possibilities) documents. For instance, the sorting of indexes and bibliographic references should be performed in accordance with a given language's alphabet or collating sequence. At the same time you should be able to conveniently edit, view, and print your documents using any given character set, and P Q X should be able to successfully process files thus created. There exist, however, almost as many different character encoding schemes as there are languages (for example, I B M PC personal computers have dozens of code pages). In addition, there exist several international standards, such as the series ISO-8859-x [33] (see below). Therefore, some thought should be given to the question of compatibility and portability. If a document is to be reproducible in multiple environments, issues of standardization become important. In particular, sending 8-bit encoded documents via electronic mail often generates problems, since some mail gateways drop the higher order bit, thus making the document unprocessable. The mail problem will probably be solved when mailers adhere to the Multipart Internet Mail Extentions (MIME)standard, where the use of a particular encoding standard (e.g., ISO-8859-x)is explicitly declared in the mail's header. Document encoding problems will, however, only be solved when new standards, like Unicode [85] or ISO-10646 [35],are adopted by everybody. The importance of these problems was realized by the TEX community, and at the TUG Portland meeting in July 1992 TUG'S Technical Council set up the "Techcal Working Group on Multiple Language Coordination" (TWGMLC), chaired by Yannis Haralambous. The goal of this group is to promote and coordinate the standardization and development of TEX related software adapted to different languages. For each language or group of languages a package has to be produced that will ease typesetting. Such a package should contain details about fonts, input conventions, hyphenation patterns, a W X option file com-

9.1 T E Xand Non-EnglishLanguages

261

Table 9.1: The extended T E X font layout accepted at Cork in 1990

patible with the babel concept (see section 9.2), possibly a preprocessor, and of course documentation in English and the target language. In section 7.5.1 we introduced the DC-EC fonts, whichuse the Cork encoding scheme, shown in table 9.1. Style files exist for mapping various input encodings to the 256-bit DC-font glyphs. For instance, the isolatinl package translates files encoded according to ISO-8859-1 (also known as Latin-1). As an example, this package translates the input code "ab (left guillemets in Latinl) into DCcode point "I3 (see table 9.1) when the D C fonts are loaded, or else into the T E X command giving an approximate representation $<<$. Similar packages can be developed for other encodings, such as for the popular IBM PC International code page 850.
"(("

9.1.1 The Virtual Font Mechanism


A convenient way of constructing new fonts is with the virtual fonts mechanism [46]. Virtual fonts provide a good solution to the problem of rearranging a font, that is, they can redefine the mapping between codes and glyphs. They also allow you to construct composite characters (for instance, characters with diacritical marks) and composite fonts (combining characters from different fonts,

262

L A T F X in a Multilingual Environment

e.g., Computer Modern Roman and lowercase Greek) without having to write special TEX macros. Virtual fonts let you use a standard input method adapted to your particular language (e.g., an ISO-8859 set, or later ISO-10646 encoding). A virtual font needs to exist only in a logical, not necessarily in a physical, sense. TEX can do its job without knowing where the actual characters come from. It is up to the device driver, using the information in the virtual font file, to collect imaging Information for the actual characters. The latter can be shifted, magnified, or combined with other characters from many different fonts. A virtual font can even make use of characters from other virtual fonts, including itself. Virtual fonts also allow convenient character substitutions for proofreading purposes when fonts designed for one output device are unavailable on another. The virtual font mechanism, thus, provides a general interface mechanism to allow switching between the myriad font layouts provided by different suppliers of typesetting equipment. There remains, however, the problem of the portability of dvi-files. A virtual font can contain a local re-encoding of some actual fonts. The result after running TEX will be a dvi-file that is not portable. To solve this problem, dvifiles containing virtual fonts can be handled in various ways: Use a dvi-driver that understands virtual fonts. Examples of such drivers are dvips and the drivers from the emTEX collection. If the dvi-driver does not support virtual fonts, then a dvi-to-dvi conversion program (dvicopyby Peter Breitenlohner or PosTeX by Vassily Malyshev) can be used to remove the references to virtual fonts from the dvi-file and replace them with references to actual fonts. This makes the dvi-file portable.

9.2 Babel-WX Speaks Multiple Languages


The L A T E X distribution contains a few standard document classes that are used by most users. These classes (article, report, book, and letter) have a certain American look and feel, which is not liked by everybody. Moreover, the names of the document elements, like "chapter" and "Table of Contents," come out in English by default. The babel package by Johannes Braams [15] provides a set of option files that allow the user to choose the language in which the document has to be typeset. It has the following characteristics: Multiple languages can be used simultaneously. The hyphenation patterns, which are loaded when INITEX is run, can be defmed dynamically via an external file. Translations for the names of document elements and commands for facilitating text input are provided for over twenty different languages.

9.2 Babel-LATEX Speaks Multiple Languages

263

The user interface of the system is simple. It consists of two user commands: one to select a language, and another to query what the current language is.

9.2.1 The User Interface


Any language that you use in your document should be declared on the \usepackage command as a language option.' Currently supported options are enumerated in table 9.3 on page 267. For example, the following declaration prepares for typesetting in the languages German (option german2) and Italian (option italian).
\usepackage [german, i t a l i a n l {babel)

The last language on the \usepackage command line will be the default language at the beginning of the document. In the above example, the names of the document elements, the hyphenation patterns (if they were loaded for the given language when the LF&Xformat was generated with INITEX; see the discussion on page 266), and possibly the interpretation of certain languagedependent commands (such as the date) will be for Italian from the beginning of the document up to the point where you choose a different language. You can change the language with the command \selectlanguage,whose syntax is:

For instance, if you want to switch to German, you would use the command
\selectlanguageCgerman). The process is the same for switching to other

languages, as long as they have been declared at the beginning of the document on a \usepackage command. When you are using more than one language, it might be necessary to know which language is active at a specific time. This can be checked by a call to the \iflanguage command, whose syntax is:

I \iflanguageClanguage~Ctrue-clause3< false-clause I
The first argument, language, is the name of a language; the second argument, true-clause, specifies whch commands should be executed if language is the currently active language; and the third argument, false-clause,specifies the commands to be executed in the opposite case.
l1n principle, since the languageb) in which a document is written is a global characteristic of the document in question, it makes good sense to declare it on the \documentclass command, e.g., \documentclass[polishl~. . .I. See section 2.1 for a detailed discussion. compatibility with the IATEX 2.09 version of babel, the option germanb is also recognized by babel.

or

264

W X in a Multilingual Environment

9.2.2 The german Option


We now discuss the german ~ p t i o nas , ~an example of the functionality offered by the babel system. Apart from translating the language dependent document element names into German, the german option provides the following:
"a is an abbreviation for \"a, which typesets a. Umlauts can be added to the other vowels through a sirmlar process (see figure 9.2 on page 268); "S for scharfes s: B, "S gives "SS" (see figure 9.2 on page 268); "ck for "ck," which will become "k-k" when hyphenated; "ff for "ff," to be hyphenated as "ff-f," and similarly for 1, m, n, p and t; ' I ' or \glqq for lower and " ' or \grqq for upper German quotation marks (,,Giinseful3chen"); \glq for lower and \grq for upper ,simple quotation marks' ; "< or \ f l q q for left and "> or \frqq for right French quotation marks (agdlemets-); \fl q for left and \f r q for right <simpleFrench quotation marks>,which are used for quotations inside quotations; I to prevent ligatures; "- to indicate a hyphenation point, just like \-, but hyphenation before and after the indicated point remains possible; I o I 1 similarly in&cates a hyphenation point, but no hyphenation sign will be printed if the word is actually split; \dq prints the " sign.

Examples of these commands are given below.


Nachfolgend sind einige Beispiele fiir die Venvendung der deutschen Befehle: Die schonste dteste Briicke DIE SCHONSTE ,%LTESTE BRUCKE StraRe oder STRASSE ,Ja, bitte!", ~Nein, danke!.: ,,Sag' imrner ,Ja, bitte! "' >Sag' immer >Ja,bitte!.~ Drucker bzw. Druk-ker Rolladen bzw. Roll-laden Auflage (statt Auflage)
Nachfolgend sind einige Beispiele f"ur die Verwendung der deutschen Befehle: \begin{flushleft) Die schUonste "alteste BrNucke \ \ DIE SCHnONSTE "ALTESTE BR1'UCKE \ \ StraUse oder STRAUSE \ \ C3ptI "'Ja, bitte! ' I ' ">Nein, danke!"< \\ "'Sag' immer \glq Ja, bitte!\grqol'\\ ">Sag1 immer \frq Ja, bitte!\flqM<\\[3ptl Drucker bzw.\ Druk-ker \\ Rolladen bzw.\ Roll-laden \\ Aufoollage(statt Auflage) \\ \end{flushleft)

3 ~ h babel e option gerrnan is based on the gerrnan package 1631, coordinated by DANTE and maintained by Bernd Raichle. Note that this package is incompatible with the babel system.

9.2 Babel-WX Speaks Multiple Languages


\selectlanguage english german austrian

265

Output of \today command 31st January 1993 31. Januar 1993 31. Janner 1993

Figure 9.1: Dates and dialects in babel Differences between "dialects" of a language are also coped with, as seen in figure 9.1, whch shows how dates are printed. Figure 9.2 on page 268 shows a source file containing a text in German, which has been input using the conventions of the babel option german. Note especially the use of the L Q X commands for creating the different tables of contents and how the figure and table caption are labeled. The result of typesetting that file is shown on the page opposite page 268, where it is seen that the names of the document elements have been translated into German ("Inhaltverzeichnis" for "Table of Contents," "Abbildung" for "Figure," etc.). You should compare these two pages with figure 9.3 on page 270 and its facing right-hand page. On those pages we show the input file and typeset result of a file equivalent to the one on page 268, but with the basic text translated into French. The same IP@X commands are used and, in this case, by merely specifying francais instead of german on the \usepackage command, all language dependent document element names come out in French.

9.2.3 The Structure of the babel Language Style Files


The language-specific files of the babel system have to conform to a number of conventions. First they must declare the new language and then supply the language-specificinformation.

The macro \addlanguage defmes the new language language.

The macro \adddialect can be used when two languages can (or have to) use the same hyphenation patterns. This can be useful when you want to use a language for which no patterns are preloaded in the format. In such a case the default behavior of the babel system is to define this language as a "dialect" of the language for which the patterns were loaded as \languageO. The language-specific information is supplied by four macros.

266

L A T E X in a Multilingual Environment

The macro \captionslang defines the command strings that hold the texts to replace the original English texts for the name of the document elements in language lang. The name of these commands strings are shown in the first columns of table 9.2 on the facing page, while the the other columns show the values of these command strings for English and Czech.

The macro \datelung defines the command \today in the language lang, including the correct format and name of the months.

The macro \extraslang contains all the extra definitions needed for the given language lang, such as typographic shortcuts for entering accents, umlauts, and making punctuation active. In some cases, there are variants between different user communities of the same basic language (for example, Portuguese in Brasil and Portugal, and German in Germany and Austria). Some languages have supplementary commands defined in the option file to ease the correct use of typographic conventions, for instance, Czech (for a few accents), Dutch (typographic shortcuts and hyphenation spelling rules), French (a lot of rules, shortcuts, and special formats for lists and bibliographies),German (typographic shortcuts and hyphenation spelling rules; see section 9.2.2 for examples) and Spanish (typographc conventions). You can add your own definitions of commands that activate when a language is selected by specifying them as the argument of the \addto command, for instance.
\addto\extrasdutch{my supplementary definitions)

All your supplementary command definitions will become active together with those already defined in babel, when, in this case, the command \selectlanguage{dutch) is encountered.

When you are finished with language lang, babel should return you to the state you were in before choosing language lang. As mentioned above, \extraslang sets all the command definitions for language lang but at the same time saves the settings of the definitions that it changes. The command \noextraslang uses these stored values to restore IFQX to the state it was in before the command \extraslang was executed. The hyphenation patterns for the different languages supported in a given babel configuration cannot be loaded when W X is run, but they must be read when the K&X format is generated with INITEX. The babel system uses an

9.2 Babel-WX Speaks Multiple Languages

267

Command
\abstractname \appendixname \bibname \ccname \chaptername \content sname \enclname \f igurename \headpagename \headt oname \indexname \ l i s t f igurename \listtablename \partname \pref acename \seename \alsoseename \ref name \tablename

English Czech Abstract Abstrakt Appendix Dodatek Bibliography Literatura cc cc Chapter Kapitola Contents Obsah encl PFiloha Figure Obrazek Page Strana To (letter) Komu Index Index List of Figures Seznam obrazkfi List of Tables Seznam tabulek cast Part Preface Eedmluva see viz see also viz tei References Reference Table Tabulka

The present version of babel recognizes the following options: american (variant of english), austrian (variant of german), brazil (variant of portuges), catalan, croatian, czech, danish, dutch, english, esperanto, finnish, french, galician, german, italian, magyar, norsk, nynorsk (variant of norsk), polish, portuges, romanian, russian, slovak, slovene, spanish, swedish, turkish. (also francais and germanb) Table 9.3: Options supported by the babel system

Table 9.2: Examples of the translation of L A T E X document element names in babel

external file, language. dat, with a one line entry for each language for which hyphenation patterns are provided, to control the loading of these patterns with INITEX. An example of a language. dat file is the following:
% Name: 1anguage.dat % Use: Correspondence language name - hyphenation patterns english ehyphen.tex % English german ghyphen3.tex % German francais fr8hyph.tex % French italian italhyph.tex % Italian spanish spanhyph.tex % Spanish

The first element on each line specifies the name of the language, followed by the name of the file containing the hyphenation patterns. For each language in the file language. dat the command \lQlang is defined, i.e., \lQenglish, and so on. When IPQX is run for a given language lung, babel checks whether the command \lalung is defined and, if so, loads the corresponding hyphenation patterns; otherwise, it loads the patterns for the default language 0 (the first one loaded by INITEX,i.e., English in the example above).

268

L A T E X in a Multilingual Environment

\documentclassCgermanl{article)% document class article and option german \usepackage{babel) % load babel package \usepackage[dvipsl{epsfig) % load epsfig package and use dvips driver code \usepackage{makeidx) % load makeidx package \newcommand{\DQ) [ I ] {\textttC\dq#l)\enspace"#l)% Print argument preceeded by " sign \makeindex \begin{document) % End of preamble and beginning of text. \begin{centerl\Large Beispiel eines Artikels in deutscher Sprache\\\today\end{center) \tableofcontents \listoffigures \listoftables \section{Eine EPS Abbildung)\indexCAbschnitt) Dieser Abschnitt zeigt, wie man eine Postscript-Abbildung\cite{bib-PSI in ein \LaTeXO Dokument einbinden kann. Abbildung-\refCFpsfig) wurde mit dem Befehl \verb!\epsfig~file=colorcir.eps,width=3cm~! in den Text aufgenommen. \index~Abbildung)\index~ostScript) \beginCfigure) [hbt] \centering \begin{tabular>{cQ{\qquad)c) \mbox~\epsfigCfile=colorcir.eps,width=3cm))& \mbox{\epsf i g { f ile=tac2dim. eps ,width=3cm)) \end{tabular) \captionCZwei EPS Bilder)\label{Fpsfig) \end{figure) \sectionCBeispiel einer Tabelle) Die Tabelle"\ref{tab:exa) auf Seite-\pagerefCtab:exa) zeigt, wie man die Umgebung \textttCtable) gebrauchen kann. \begin{table) [hbt] \centering\begin{tabular)Cccccccc) \DQCa) & \DQCAI & \DQCo) & \DQCO) & \DQ{u) & \DQCU) & \DqCs) \endCtabular) \caption{Eingabe der deutschen Zusatzzeichen~\label{tab:exa)\index~Tabelle) \end(table) \begin{thebibliography){99) \index{Literaturverzeichnis) \bibitemCbib-PSI Adobe Inc. \emph{PostScript Handbuch (2. Auflage)) Addison-Wesley (Deutschland) GmbH, Bonn, 1991 \end{thebibliography) \printindex \index{Index) \end{document) % End of document.

Figure 9.2: Example using babel's option german (output on facing page)

9.2 Babel-LATEX Speaks Multiple Languages

269

Beispiel eines Artikels in deutscher Sprache


11. Oktober 1993

Inhaltsverzeichnis
1 Eine EPS Abbildung
2 Beispiel einer Tabelle

Abbildungsverzeichnis 1 ZweiEPSBilder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Tabellenverzeichnis


1

Eingabe der deutschen Zusatzzeichen

.................................

1 Eine EPS Abbildung


Dieser Abschnitt zeigt, wie man eine PostScript-Abbildung[l] in ein 14TEX Dokument einbinden kann. Abbildung 1 wurde mit dem Befehl \epsf ig( file=colorcir eps, width=3cm) in den Text aufgenommen.

Abbildung 1: Zwei EPS Bilder

2 Beispiel einer Tabelle


Die Tabelle 1 auf Seite 1 zeigt, wie man die Umgebung table gebrauchen kann.

"a 8

"A

"o 6

,TO

Wu

ii

"U

"

"s

Tabelle 1: Eingabe der deutschen Zusatzzeichen

Literatur
[I] Adobe Inc. PostScript Handbuch (2. A u f i g e ) Addison-Wesley (Deutschland) GmbH, Bonn, 1991

Index
Abbildung. 1 Abschnitt, 1 Index, 1 Literatuwerzeichnis, 1 PostScript, 1 Tabelle, 1

2 70
\documentclass{article~

W X in a Multilingual Environment

% load babel package and initialize french \usepackage[french]{babel) \usepackage[textures]{epsfig)~ load epsfig package and use textures driver code

\usepackage{makeidx)

% load makeidx package \newcommand{\Lcs)[1]{\texttt~\symbo1{'134)#1)\enspace)%

add \ before argument \makeindex % End of preamble and beginning of text. \begin{document) \begin{center)\Large Exemple dJun article en fran\c{c)ais\\\today\endCcenter) \tableofcontents \listoffigures \listoftables \sectionCUne figure EPS) \index{section) Cette section montre comment inclure une figure PostScript\citeCbib-PS) dans un document \LaTeX. La figure"\ref{Fpsfig) est ins\'er\'ee dans le texte \ ' a lJaide de la commande
\verb+\epsfig{file=colorcir.eps,width=3cm~+. \index{figure)\index{PostScript)

\begin{f igure) [hbt] \centering


\beginCtabular){cQ{\qquad)c) \mbox{\epsfig{file=colorcir.eps,width=3cm~~& \mbox{\epsfig~file=tac2dim.eps,width=3cm~~

\endCtabular) \caption{Deux images EPS)\labelCFpsfig) \end{figure) \section{Exemple dJun tableau) ' a la page \pagereftab:exa) Le tableau-\refCtab:exa) \ montre lJutilisationde lJenvironnement \texttt{table). \begidtable) [hbtl \centering\begin~tabular){cccccc~ \Lcs{primo) \prim0 & \Lcs{secundo) \secundo & \Lcs{tertio) \tertio & \Lcs{quatro3 \quatro & 2 \ L c s { i e m e ) \ 2\ieme \end{tabular) \caption{lJuelques commandes du paquet \texttt{francais))\labelCtab:exa) \index{tableau) \endCtable)
\begin{thebibliography){99)

\bibitem{bib-PS) Adobe Inc. \emph{PostScript, manuel de r\'ef\'erence (2\ieme \'edition)) Inter\'Editions (France), 1992 \index{r\ ' ef\ ' erences) \end{thebibliography) \printindex \index{index) \end{document) % End of document.

Figure 9.3: Example using babel's option francais (output on facing page)

9.2 Babel-WX Speaks Multiple Languages

271

Exemple d'un article en fran~ais 11 octobre 1993

Table des matikes


1 UnefigureEPS 2 Exemple d'un tableau

Liste des figures


1 Deux images EPS

...

Liste des tableaux


1 Quelques commandes du style francais

..............................

1 Une figure EPS


Cette section montre comment inclure une figure PostScript[l] dans un document 19TEX. La figure 1 est instrte dans le texte I'aidede lacommande \epsfig( file=colorcir.eps, width=3cm).

Figure 1: Deux images EPS

2 Exemple d'un tableau


Le tableau 1 h la page 1 montre I'utilisationde I'environnement table.
\prim0 lo \secundo 2 O \tertio 3 O \quatro 4' 2\ieme 2e

Tableau 1: Quelques commandes du paquet francais

RCfCrences
[ I ] Adobe Inc. PostScript, manuel de rifirence (2' &didition) ~nterklitions (France). 1992

Index
figure, 1 index, 1 Postscript, 1 df6rences. 1 section, 1 tableau, 1

2 72

W&X in a Multilingual Environment

9.3 Implementing Typographic Rules


The babel system, presented in the previous section, does a good job of translating document element names and making text input somewhat more convenient. In t h s section we take a look at a second class of packages, which go one step further since they try to customize L A T E X to better reflect the typographic traditions of the target language. An example of such a package is french [21],which was developed by Bernard Gaulle. The french package does not limit itself to the translation of language dependent document element terms and the definition of abbreviations for typing accents, but it also provides several commands to more easily apply French typographical rules and adds/redefines several L A T E X commands to give documents typeset with the french package a real French "look and feel."

9.3.1 Traditional French Typographic Rules


This section summarizes the most important rules for typing French texts (see y following these rules you will benefit most the reference works [6,32,79]). B from the possibilities of the french package. However, you can force the package to try to do all the work itself-e.g., if you do not want to type the spaces before double punctuation, etc., you can specify the command \untypedspaces, whch will take the correct action. Note however that such an automatic procedure might not always have the expected result. There must be a space:

- in front of double punctuation ( ! ? : ;); - in front of closing "gulllemets" (B); - in front of % and generally before units, e.g., 10 km, 1000 francs; - following and of course ; : , . ! ?
( (

)>

The guillemets ((( and >>) are input << and >>. No other quotation marks are normally used in French (' " ' ' ' " ,, "). Ellipsis dots (points de suspension) are input as three normal dots ( . . .). Numbers have a comma between units and decimals, e.g., 3,14159. Latin expressions (quite common in French) are typeset in i t a l i c inside roman text (exception for cf., etc., and Latin words which have become part of the French vocabulary, like the word criterium). Some common abbreviations and the way they should be typed are:
c.-\'a-d. / \emph{i.e.> / p.ex. / etc. / cf. / id. / p . i . / p . 0 . chap. / part. / v o l . / paragr. / R.S.V.P. / T.S.V.P. /...

9.3 Implementing Typographic Rules

2 73

In fact, the distribution of the french package comes with a file frabbrev, containing the most important abbreviations of the French language. There should be no dots between the letters of abbreviations for trademarks, company names, etc., and they are normally set in small caps. The command \ l c s deals with this case-i.e., \lcs{RATP) and \lcs(SnCf) will typeset respectively RAP and SNCF, regardless of the case in which the arguments were entered. Capitalized vowels carry accents. Only the first letter of the first word in a title should be capitalized [4]. In a simple enumeration list, i.e., in which there is only one sentence per list element, each item should start with an en dash-and the first word should begin with a small letter and all list items, but the last one should be terminated with a semicolon. Last names are written in small capitals, while first names are in Roman, e.g., Donald KNUTH. The command \fcs is provided for this case; thus \f csCKNUTH) and \f csCknuth) will both typeset KNUTH.

9.3.2 Commands of the french Package


A few commands have been added to facilitate the generation of documents in French. Only a selection of the commands is given below. For more d e t d s consult the original documentation.

\begin{resume) teXte du resume \end{resume) \beginCorder), . . . \end(order) generates an enumerated list of the type (10 ... 2 0 ... ); \sommaire [nl for a summary; [n] indicates the nesting level for the title; \annexe or \annexes for appendices; \glossaire or \glossaires for glossaries; in the main text the following commands are available:

- \ i e r for ler (l\ierC)); \ i e r e for lre (i\iere()); \ieme for Ze


(2\iemeC)); - \prima, \secundo, \ t e r t i o , \quatro will print l o , Z0 , 3 O ,4O. You can continue with the \quando command, e.g., \quando={il) giving 110; - \f upCtext) will raise the argument text and print it in a smaller typeface, e.g., to write XVIe (XVI\f up{e));

2 74

L A T F X in a Multilineual Environment

English input
ellipsis\ldots

123,456.789
semicolon; He said: Yes My god ! Why not? "I say"

English output ellipsis . .. 123,456.789 semicolon; He said: Yes M y god! Why not? "I say"

points de suspension. . .

French input

123 456,789
point -virgule ; I1 dit : oui Mon Dieu ! Pourquoi pas ? << Je dis >>

French output points de suspension... 123 456,789 point-virgule ; I1 dit : oui Mon Dieu ! Pourquoi pas? Je &s
( (

) )

Table 9.4: Comparison of French and English typography various special commands for typesetting personal and business letters with a French "look and feel." Depending on the exact combination of option commands specified, the ' " ' > and : ; ! ?. This makes these characters equivalent to command sequences, and their occurrence will invoke the TEX macros associated with their names. This can lead to problems if you use the french package together with other packages where these characters are used. To typeset any of these characters literally inside your text, you can use the following commands:
french package makes various characters active, namely <
\inferieura \superieura \IS \rq \ISS \rqq

for < for > for ' for ' for " for "

\pointvirgule \pointexclamation \point interrogation \dittomark \deuxpoints

for ; for ! for ? for for :

9.3.3 Structure of the french Package


The french package consists of four distinct parts: typography (in the main text), page layout, translation of the document element terms, and supplementary command definitions. When loadmg the package, all four parts are activated. Each part can be turned on or off individually with the commands:
\frenchtypography \frenchlayout \frenchtranslation \frenchmacros

...

... ... ...

\nofrenchtypography \nofrenchlayout \nofrenchtranslation \nofrenchmacros

Some of the main differences between the way English and French texts are input, and their typographc result, are shown in table 9.4.

C H A P T E R

10

Portable Graphics in IFQX

TEX probably has the best algorithm for formatting paragraphs and building pages from them. But in this era of ever increasing information exchange, most publications do not limit themselves to text-the importance of graphical material has grown tremendously. TEX by itself does not address t h s issue, since it deals only with positioning (black)boxes on a page. Knuth, however, provided a hook for implementing "features" that are not available in the basic language, via the \special command. The latter command does not affect the output E X will put the material, specified as an argument in page being formatted, but T the \special command, literally at the current point in the .dvi file. It is the dvi-driver that has to interpret the received information and produce the output image accordingly. Many articles have been devoted to how best to generate graphics with TEX, and various authors have come up with solutions, which are often very userspecific and hence unusable for the general public. E X and Graphics" [67], Sebastian Rahtz In his review article, "A Survey of T discusses six distinct ways of producing graphics in TEX:~
1. ASCII drawing, such as V E X [891, which provides a complete plotting language where curves are implemented by combining a very large number of small dots. For complex plots this requires a very large internal memory for the TEX program and also a lot of computing time. 2. Picture-element fonts, such as WX's picture environment. Kristoffer Rose's XY-pic system [731 uses special fonts to typeset diagrams.
See also "Portable Graphics in TEX:" [18] by Malcolm Clark.

2 76

Portable Gra~hics in LATX


3. Picture macro packages, mainly based on the picture environment or on TEX'Sraw line-drawingcommands. Amongst others, packages exist for drawing Feynman diagrams, chemical formulae, and trees. 4. Picture fonts, where each character to be typeset is one, possibly enormous, "letter" in a font. One can use METAFONT for generating the pictures [28],or else use already existing bitmaps and transform them into a .pk file directly. Angus Duggan's pbmtopk program can transform a picture from one of the "pbm" (portable bitmap) formats into a .pk file format, and it assigns successive pictures to letters of the alphabet. BMZFONT converts different kinds of bitmap files to TEX fonts and writes an input file for integration of those graplvcs into documents [78]. 5. Halftone fonts are blocks consisting of various levels of grey, which can be combined in the normal T E X way to generate pictures [17,44]. 6. Graphics material can be included, using the \special command. This approach is by definition device dependent, since it relies on the possibilities of the dvi-driver and the output device. However tlvs approach becomes more and more popular with the spread of low-cost PostScript printers and previewers. psfrag and pstricks are examples of systems using PostScript together with W X . See also the discussion in chapter 11.

All these methods have their advantages and drawbacks. Although approaches 1 to 5 are portable, they suffer from a lack of flexibility, especially when artwork has to be scaled or rotated. The method of the \special command is only limited by the possibilities of the target language itself, and although thls approach is by definition device-dependent, it allows, in the case of PostScript, the use of all commands of this rich language and the inclusion of material produced by the many packages generating output in PostScript. Such developments will be discussed in the next chapter. A T E X S ' built-in graphics tools, which are based This chapter mainly discusses L on the picture environment, and packages that' extend this environment to generate high-quality device-independent graphics. We also look at other visual effects, such as "shadow boxes," that can be produced in a portable way. B y using portable utilities, you can be certain that the recipient of a document, who has the same IFQX environment as the originator, will obtain the same output as the sender. The first section of this chapter discusses ornaments, which can be useful to make important material stand out. The next section looks at the picture environment, and presents packages for drawing bar charts and arbitrary curves. Then we turn our attention to two packages, epic and eepic, which extend the picture environment by introducing a set of new commands. They are described in detail and examples show how they are used in practice. Finally we discuss two packages based on epic and eepic for drawing bipartite graphs and trees.

10.1 Ornaments

277

10.1 Ornaments
L Q X boxes are reviewed briefly in section A.2. Below, we present packages that provide extensions to the usual B Q X boxes.

10.1.1 Boxed Minipages


The boxedminipage environment, defined in the boxedminipage package (by Mario Wolczko),behaves like the standard minipage environment, but it is surrounded by a frame. The thickness of the rules is controlled by the \ f b o x r u l e and \fboxsep style parameters.

1
This is an example of a small boxed rninipagea which moreover has a footnote.
aVery simple example

\beginCboxedminipage) [t] C5cm) This is a n example of a small boxed minipage\footnoteCVery simple example) which moreover has a footnote. \endCboxedminipage)

10.1.2 Shadow Boxes


The shadow package (by Mauro Orlandini) defines the \shabox command, which is similar to the L A T E X command \fbox except for the fact that a "shadow" is added to the bottom and the right side of the box. Three parameters control the visual appearance of the box (defaults are given in parentheses):
\sboxrule \sboxsep \sdim

width of the lines for the frame (0.4pt); separation between the frame and the text (10pt); dimension of the shadow (4pt).

, then a

by putting it in a parbox, nested inside a

A standard framed box \f boxCf ramed text), then a shadow box \shabox{framed text with shadow). \par\bigskip \renewcommandC\sdim)C1.5\fboxsep) \shaboxC\parboxC6cm){% A complete paragraph can be highlighted by putting it in a parbox, nested inside a \textttCframebox).))

2 78

Portable Graphics in W X

10.1.3 Fancy Frames


Timothy Van Zandt, in the framework of h s seminar package for producing slides, developed the fancybox package. He introduces various new commands for framing information in L A T E X . In this section we only review a few of the more basic commands. More information can be found in the documentation accompanying the seminar package mentioned above.

Variants for \fbox


The fancybox package introduces four variants for the \fbox command. As with the \fbox command the distance between the box and the frame is given by the length parameter \fboxsep (default 3pt). Other parameters governing these boxes are described below.
\shadowbox

'

This is a shadowbox

The line thckness is defined by \fboxrule (the same parameter as for \fbox). The width of the shadow is \shadowsize (default: 4~0.

\doublebox

I This is a doublebox]
The width of the inner and outer frames are .75\fboxrule and 1.5\fboxrule,respectively. The distance between the two frames is 1.5\fboxrule plus 0.5pt.

\ovalbox

his is an ovalbox]
The width of the frame is defined by the \thinlines command, wMe the diameter of the corner arcs is set with a \cornersize command, which has one argument. The latter can have two forms, namely num, a factor whch multiplies the smaller of the height or width of the box, or din, a length specifying the diameter of the corner arcs (default is num=0.5).

\Ovalbox

( ~ h is s an ovalbox] Sirmlar to \ovalbox, but the thickness of the lmes is controlled by the \thicklines command.

Defining Boxed Environments


To help you define boxed environments fancybox defines the Sbox environment. It is similar to the \sbox command. It saves the contents of the environment in a storage bin that can be retrieved with a \TheSbox command. Using this command you can reimplement the boxedminipage environment discussed in section 10.1.1

10.1 Ornaments

2 79

An example of a boxed minipage defined using the Sbox command.

\newenvironmentCBoxedminipage)% C\beginCSbox)\beginCminipage))% (\endCminipage)\end{Sbox)\f box{\TheSbox)) \begin{Boxedminipage){5cm) An example of a boxed minipage defined using the Sbox command. \endCBoxedminipage)

The package predefines the following boxed environments.


Bcenter, B f l u s h l e f t , and B f lushright generate a boxed center, f lushlef t, and f l u s h r i g h t environment, respectively. Bitemize, Benumerate, and Bdescription generate a boxed itemize, enumerate, and description environment, respectively. Beqnarray produces a boxed environment similar to eqnarray, but the equation number will always come out on the right. Beqnarray* is like eqnarray*, but the generated box is just large enough to hold all the equa-

tions. For all these commands it is up to you to add a frame. An example is given below.

The package also defines commands for framing a whole page, and reimplements several commands to typeset verbatim texts (see also section 3.3). In particular a framed verbatim text can be defined and used as follows.

280

Portable Grauhics in LATX

10.2 The picture Environment


( L 101-11)

LATEX'S basic p i c t u r e environment can be used in many circumstances for generating simple graphics output and it is used for many line drawings in t h s book. The present section discusses various packages which have been developed to extend the p i c t u r e environment.

10.2.1 Bezier Approximations

IN EX^^ allows the construction of quite complicated mathematical curves using


the techmque of approximations with Bezier splines. Note that the Postscript language also uses (third order, or cubic) Bezier curves as the basis of its curve drawing functions.

The above command defines a quadratic Bezier curve, which is defined by its two end points, (AX,AY) and ( C X C Y ) , with (BX,BY) as the control point. The optional parameter N, if present, specifies that N + 1 points are plotted to approximate the curve.2 In the next example A and C are the end points and B is the control point; the number of plotted points is calculated automatically.

2 ~ o NTEX r 2.09 Leslie Lamport's bezier package defines the command \bezier, with the following relation: \bezierCNl(AX,AY) (BX,BY) (CX,CY)=\qbezier[N] (AX,AY) (BX,BY) (CX,CY). The main difference is that the number of points required to obtain a smooth continuous curve is calculated automatically by \qbezier, and need no longer be specified.

10.2 The picture Environment

281

Varying the number of dots and the control point has a clear effect. In the next example two curves use the default number of points the others specify the number to use.
0

..........

........ . . . . . . . . . . ............ ............

............

................ ............0

\setlength{\unitlength)C.5mm) \begin{picture)(120,100)(-5,O) \linethickness{.5pt) \qbezier [501(0,0) (0,100)(100,O) \qbezier (0,O) (30,801(100,O) \qbezier [I501 (0,O)(60,601 (100,O) \qbezier [2001(0,0) (90,401 (100,O) \qbezier (0,O) (120,201 (100,O) % mark the end points \put (0,O)C\circle*{3)) \put(lOO,O)C\circle*C3)) % mark the control points \multiput (0,100)(30,-2O)C51C\circle{21) \end{picture)

Finally, the code for one of the diagrams of figure 10.5 onpage 295 is shown:

10.2.2 Putting Multiple Boxes


The multibox package (by Brian Hamilton Kelly) defines the following two new commands for use inside the picture environment:

...(text,) \multimake(x,~)(dx,dy)(nl(w, h)[poslCtextl)textz) \multif rame(x,y)(dx,dy){n)(w,h)[poslCtextl)Ctextz)...{text,)


These commands set the n texts, text1 to text,, inside a \makebox or \framebox respectively. The first box has its lower-left corner at (x,y), and successive boxes are located at (x+dx,y+dy),to (x+(n-l)dx,y+(n-1)dy).

282

Portable Graphics in LATEX


Each box has a width and a height determined by (w,h), whde the optional box placement parameter pos is applied to all the generated texts. A simple A T E X \multiput example, in which the syntax can be compared with that of the L command, is shown below:

10.2.3 Drawing Binary or Ternary Trees


The trees package (by Peter Vamoose) is based exclusively on the picture environment. Another package for drawing trees is discussed in section 10.5.2. It defines macros that let you draw a (binary or ternary) tree of any size. For each internal node, you only have to specify the descending nodes, with a \branch (binary node) or \tbranch (ternary node) command. The tree diagrams are produced inside a picture environment, and the following commands are available with the trees package:

The command above specifies the label to be used for each of the branches.
-

\root(~-coord, y-coord) rootid. (x-coord,y-coord) are the absolute coordinates of the root, identified by rootid, in the picture. Note that the parentheses pair, the space, and the period are obligatory. \branch{steepness){ text){ branchid): childa,childb.

10.2 The ~ i c t u r e Environment The steepness parameter determines the steepness of the branches; it is an integer between 0 and 3. text specifies explanatory text written above the branch point. branchid is the identifier of the present branch, while childa and childb are the identifiers of the two children. The colon, comma, and final period are obligatory.

283

This command is the same as the preceding one, except that it allows three rather than two child identifiers.

Parameters toptext and sidetext specify, respectively, text that will be written above and to the right of the current leaf, which has identifier leafid. Trees are constructed with labels on the branches (default 0 and l),and with text (its name or value) on the nodes. An example is shown below. The (internal) identifiers (0-7), used for labeling the branches and leaves, can be replaced by anything.
\setlengthC\unitlength)C4pt) \begin(picture) (50.30) \branchlabels abc % default is 012 \root(l0,15) 0. % root label 0 % node 0 has children 1 and 2 \branch2{25) 0:1,2. \leaf C5)C$L-a$] 1. % node 1 is a leaf \branch2{20) 2:3,7. % branch to node 3 goes up % it has a label a \tbranch2(15> 3:4,5,6. \leafI7)($L_Cbaa)$)4. \leafC5)C$L_Ibab)$N. \leaf(3)($L_Cbac)$)6. \leafC5)C$L_ibb)$)7. \endIpicture)

10.2.4 Drawing Bar Charts


The bar package (by Joachim Bleser and Edmund Lang) can produce bar charts and is entirely based on the picture environment. The bar diagrams are produced with the barenv environment.

284

Portable Grauhics in LATX


Inside a barenv environment the following commands are available:

I \barCheight)Chatch-index)

[description] I

A bar is defined by giving its height and the hatch-index-a number between 1 and 8, according to the following scheme:

Imrmmllmmrrrrrrr B r n
1 2 3 4 5 6 7 8 The optional argument is a textual description of the bar, and is typeset according to the settings of \setnumberpos and \setstyle.

This command activates the background horizontal lines.

I \legend{ hatch-index)Clegend text) I


This command associates the hatch style, hatch-index, with the explanatory text, legend text.

This defines the depth for a 3-D bar chart (number 2 10).

This defines the horizontal space to be left between the bars. It is expressed as a fraction of the bar width.

This defines the style for the horizontal background lines (activated with
\hlineon). Possible values for style are solid and dotted.

This defines the positioning of the description of the bar contents. Possible values for position are: empty No description is needed. axis The description goes under or above the x-axis. down The description goes under the bars. inside The description goes inside the bars. outside The description goes outside the bars. The description goes on top of the bars. UP

10.2 The picture Environment

285

This defines the number of digits to be printed after the decimal sign.

This defines the scaling factor for the vertical dimension of the chart.

T h s defines the font characteristics.

This defines the width of the bars in points.

This defines the division of the x-axis. The three parameters specify the start and end values and the value of the step.

This defines the descriptive label for the x-axis.

This defines the way the x-axis divisions are labeled. B y default, numbers are used, but you can use the names of the days or the months. Therefore, type in the definition above can be either month or day. In this case the begin and end values for the x-axis specified with the \setxaxis command use a correspondence for the months of 1 for January, 2 for February, etc., 12 for December, 13 for January again, and so on. For the days you have the correspondence: 1 for Monday, 2 for Tuesday, etc., 7 for Sunday, 8 for Monday again, and so on. (However, in the current release of the package only the German language is supported.)

I \setyaxis [offset]Corigin)Cend){step) I
T h s command defines the division of the y-axis. The three mandatory parameters are the same as for \setxaxis, whle the optional argument, offset, specifies a value that is added to the origin and end values, but without altering the division of the axis: at the origin, at the end point, and the step size.

This defines the descriptive label for the y-axis.

286

Portable Graphics in W X

The general StmChlre of the command sequences for generating bar diagrams is the following:
\begin{barenv) Declarations \bar{height){hatch-index)

\bar{height){hatch-index) \endCbarenv) Legend

Note that, since the barenv environment uses the picture environment, all commands that are valid inside the latter are also available.

10.2.5 Examples of the barenv Environment


The first example shows a simple bar chart generated by using the default settings of the barenv environment.

Axis Information and a title can be added easily:


Number of Students
40 30 20 10 0 \begidcenter) \textbf{Number of Students)\\[5mm] \endCcenter) \begin{barenv) \setxaxis{1){4){l)\setxnam~Trimester~ \setyaxis{O~C40~ClO~\setynamdNo.~ \barClO)Cl) \barC30)C4> \barCi5)C6) \bar{5){7) \end{barenv)

No.

Trimester

Perhaps we prefer to see this information using a 3-D effect, and to make the differences more visible we stretch the y-axis. To make the trimesters more precise, we show the middle month of each.

10.2 The picture Environment

287

Number of Students

NO.
30 40 30 20 10 0 Feb Mai Aug Nov

\begin{center) \textbfCNumber of Students)\\[5mm] \endCcenter) \begin(barenv) \setdepthClO)% 3-D effect \setstretchC1.4)% stretch y-dimension \setnumberpos{up)% numbers above bars \setxvaluetyp{month)% months on x-axis \setxaxis~2~C12)~3~\setxnamdTrimesDer) \setyaxisCO)C40)C10)\setynam~No. \barClO)Cl) \barC30)C4) \barC15)C6) \barC5){7) \endCbarenv)
)

Trimester

If we want to emphasize changes in the number of students between trimesters, we can use the following representation.
Student Number Variation
\beginCcenter) \textbfCStudent Number Variation)\\[5mm] \endCcenter) \beginCbarenv) \setxaxisC1)C4)Cl~\setxname~Trimester~

-10 -20 1 2
3

Trimester

\setyaxis~-20~C30~C1O~\setynameC\%~ \sethspace~O.l)\setnumberpos~axis) \barCO)Cl) \barC20)C81 \barC-15)18) \bar{-101(8) \end(barenv)

Our final, and most complex, example shows the variation in the price of shares for company XyZ, in two different ways. First it is illustrated as a 2-D bar chart (figure 10.1 on the following page) and then as a 3-D chart (figure 10.2 on page 289).

10.2.6 Drawing Arbitrary Curves


The curves package (by I.L. Maclaine-cross) extends WX's picture environment by drawing curves that superimpose small disks, whose sizes and number are tuned to optimize visual smoothness. Segments between coordinate points are approximated as parabolas. A special sub-package, curvesls, reimplements some of the more time- and space-consuming parts of the code with \special commands defined in Eberhard Mattes's emTEX for I B M PC compatibles. The capabilities of this package include:
A compatible replacement for the bezier package. The ability to adjust curve thickness between 0.5 and 15pt (0.17 and 5.2mm).

Share price for Company XyZ


160

US Dollars
150

, 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992

Year

Yield:

Good

Moderate

Bad

\begidcenter) \Large\bfseries Share,price for Company \textsf CXyZ)\\ [6mml \beginCbarenv) \setstretch{l. 6) \setwidthC25) \sethspaceCO.l) \setstyleC\bfseries) \setwameCYear) \setynameCUS Dollars) \setstyleC\small\itshape) \setxaxisC1982)C1992)C1) \setstyle~\small\bfseries~ \setyaxisC0)C160)C1O) \setlinestyleCsolid~ \hlineon \setnumberposCup) \setstyle~\small\ttfamily~ \bar{70){5) \barC105)C4) \bar{100){4) \barC150)C6) \bar{125){6) \barC140)(6) \bar{115){4) \barC105)C4) \bar{105){4) \barC90)C5) \barC70)C5) \endCbarenv) \endCcenter) \par\vspace~2\baselineskip~ Yield: \legend6CGood) \qquad \legend4{Moderate) \qquad \legend5CBad)

Figure 10.1: Example of a bar chart-2-D option

10.2 The picture Environment

b i h
C,

k= X ad m ,

290

Portable Gra~hics in LATX

Continuously sloping curves. Control of end slopes using \tagcurve. Closed curves with continuous slope using \closecurve. Large circles with \bigcircle and circular arcs with \arc. Independent scaling of curve abscissa and ordinates to fit graphs. Affine scaling for making arcs or circles elliptical. Support for symbols and dash patterns.
Curve Drawing Commands

This section reviews the more important curve drawing commands that are used in the examples below. The curves drawn consist of parabolic arcs between coordinate points, with tangents at each point parallel to the straight line through adjacent points. Segments at a curve's end points are a parabola going through the last three points.

This command draws a circular arc centered on the current position, starting at ( x i , y l ) and proceeding counterclockwise for angle degrees. The optional argument nbsymb specifies the number of patterns or symbols to be drawn (the default is 0).

I \bigcircle Cnbsymbl {diameter) I


This command draws a circle with a diameter equal to diameter times
\unitlength. The optional argument nbsymb is as described above. \closecurve [nbsymbl ( x i , yi,xz, ~
2 . . . ~ ~n , n

This command draws a closed curve with continuous tangents at all points. At least six coordinates are required. The optional argument nbsyrnb is as described above.
\curve Cnbsymbl ( x l , y l , x z , y z ...xn,y n )

This command draws a curve through the specified coordinates. Two pairs of coordinates generate a straight line; three pairs a parabola going through the points specified. The optional argument nbsymb is as described above.

10.2 The picture Environment

291

This command places the picture object pict-object at the position (XI,y l ) . At the same time it applies an axonometric projection or rotation specified by the scale factors \xscale, \xscaley, \yscale, and \yscalex, whose initial values are 1.0, 0.0, 1.0, and 0.0, respectively.

This command draws a curve without its first and last segments. If only three coordinate pairs are specified, then it draws the last segment only. The optional argument nbsymb is as described above.
Examples

The following example shows an airfoil section that is often used in aerodynamics research. The \arc commands draw the leading and trailing radii. The coordinates quoted inside the first \curve command are input from aerodynamic tables and correspond to the top section of the airfoil; the second \curve command, containing two coordinate pairs, plots the flat chord at the bottom.

We can now rotate this foil using the scaling parameters described with the command \scaleput. In the example below, we choose a clockwise rotation over

292

Portable Gra~hics in LATX an angle of l o o ,so that the diagonal elements, \xscale and \yscale, correspond to COS( 10') whlle the off-diagonal elements correspond to k sin( 10").

Axonometric projection is another scaling application. Circles become ellipses and circular arcs become elliptical arcs. Note that the angles for the \arc in the example were found by trial and error.

It is quite easy to add symbols to your curves. The command \curvesymbol defines the symbol to be used. If the value of the optional parameter nbsymb on one of the curve commands is negative, then it fixes the number of symbols per curve segment. The TEX primitive command \phantom is used for centering the lmm circle. The example shows the (height-distance) trajectory of an object thrown into the air as a function of time.

10.3 Enhancements to the picture Environment-epic

293

.
1s , ' d
I

2s
-0..

\3, s
t
\

\thinlines \setlength{\unitlength}{Imm) \begin{picture)(80,46) (0,O) % l m m dashes interspersed with 2mm white space \curvedashes [lmm]{0,1,2) \put(lO,O){\curve(O,O, 19.6,39.2, 39.2,O)) \curvedashes{) % reset dashes \newcounter{time) \curvesymbol{\textsf {\thetime\, s) \addtocounter{time)C1)) \put(l0,4)C\curve[-21(0,0, 19.6,39.2, 39.2,O)) \curvesymbol~\phantom{\circle*~l~~\circle*{1)) \put(lO,O){\curve[-2](0,0, 19.6,39.2, 39.2,O)) \end{picture)

10.2.7 Other Packages


In theoretical physics, the Feynman package by Michael Levine [52] has become very popular. It allows the user, via a high level command language built on top of the picture commands, to draw the various particle lines and vertex groups of Feynman diagrams. Figure 10.3 on the following page shows a typical picture made with this package. A set of macros by Roswitha Haas and Kevin O'Kane [24]has been developed in the field of organic chemistry. Their ChemTEX system allows you to draw complex molecules (see figure 10.4 on page 295). A set of circuit schematic symbols for WX's picture mode has been developed by Adrian Johnstone (see figure 10.5 on page 295). The set includes all basic logic gates in four orientations, FETs, power supply pins, transmission gates, capacitors, resistors and wiring T-junctions. It uses the bezier package discussed earlier.

10.3 Enhancements to the p i c t u r e Environment-e pic


The epic [66] package (by Sunil Podar) enhances the graphc capabilities of I l Q X and provides a powerful high level user interface to the picture environment. The main aim is to reduce the amount of manual calculations required to specify the layout of objects. The additional epic commands allow the drawing of sophisticated pictures with less effort than was previously possible. Most picture drawing commands require explicit specification of coordinates for every object. Higher level commands can, however, help to reduce the amount of coordinates that need to be manually calculated. Basically, two approaches

294

Portable Graphics i n UTEX

Figure 10.3: Example of a picture generated with the Feynman package

can be taken to design such commands:


A set of objects can be selected so that the entire set can be plotted by specifying one or two coordinate pairs-the \ s h o r t s t a c k command falls into t h s category. Commands are provided that will do most of the computations internally and require only simple coordinate pairs to be specified-the \multiput command is an example of this approach.

The obvious advantage of having commands that fall into the above categories is that, not only are they easier to specify initially, but any subsequent modification to the layout requires minimal recalculations. The frequently used primitive command \ l i n e has severe limitations and drawbacks. Its arguments are very nonintuitive and require extensive calculations-often the thought process in writing a \ l i n e command involves: 1. calculating the coordinates of the two end points; 2. calculating the horizontal and vertical distance; 3. determining whether the desired slope is available and if not then repeating steps 1. and 2. until a satisfactory slope is achieved; 4. translating the above into an (x,y)pair for specifying a slope and a horizontal distance for specifying the length of the line.

10.3 Enhancements to the picture Environment-epic

295

Figure 10.4: Example of chemical formula

Figure 10.5: Electronic circuit symbols prepared with picture commands The above mechanism is very cumbersome. Moreover, the length of the shortest line at different slopes is not the same due to the way the \line command is implemented. The epic package introduces line drawing commands that overcome these drawbacks, while at the same time providing a simpler syntax. These commands take only the coordinates of the end points, thus eliminating the other steps involved in specifying a line. On top of that a few high-level new commands are also defined. Thus, the epic package will make it possible to produce sophsticated pictures with less effort than before.

10.3.1 Description of the Commands

This command is a variant of WX's \multiput command, which allows the same object to be placed at regularly spaced coordinates. The \multiputlist command is similar, but permits the objects to be different. While the \multiputlist command is executed, the objects to be put are picked up from the list of items, as the coordinates are incremented. (The first item goes in position one, the second item in position two, etc.) For example, you can plot numbers along the x-axis in a graph by specifying:

296

Portable Graphics in L A T E X The objects in the list can be virtually anything, including \makebox, \f ramebox, or math characters. T h s command enforces a certain regularity and symmetry on the layout of the various objects in a picture.

The \matrixput command is the two-dimensional equivalent of the primitive W X command \multiput. It is more efficient, however, to use \matrixput than the equivalent nl \mult iput statements. This command is especially useful for pictures where a pattern is repeated at regular intervals in two dimensions.

The \grid command makes a grid of dimensions width units by height units. Vertical lines are drawn at intervals of Awidth and horizontal lines at intervals of Aheighr. When the third (optional) argument is specified, then the borders of the grid will be labeled with numbers whose starting values are the integer numbers initial-X-int and initial-Y-int respectively. They wdl be incremented by Awidth and Aheight along the axes. The \grid command produces a box. Therefore, it must be \put at the required coordinates, for example:
\put (0,O) C\grid(50,100) (5,IO)l \put (O,O)C\tiny \grid(100,100) (5,5) [-50,OI 3 % make numbers \tiny

Drawing Different Kinds of Lines

The \dottedline command connects the specified points by drawing a dotted line between each pair of coordinates. At least two points must be defined. The dotted line is drawn with an inter-dot gap as specified in the second (first mandatory) argument dotgap (in \unitlengths). Since the number of dots to be plotted must be an integer, the inter-dot gap may not come out exactly as specified. B y default, a little square (\picsquare,described below) is used as the dot,

10.3 Enhancements to the picture Environrnent-epic

297

and can be changed by selecting another character, dotchar, using the optional argument. When the default character is used, the thickness of the dots is controlled by the currently active \thinlines, \thicklines, or \linethickness declarations. Note that some characters llke "*" in the roman font do not come out centered, although most other characters do.

\dashline [stretch1 Cdashlength) [dashdotgapl ( X I , yl)(x2, y2)...(x,, yn)

The \dashline command connects the specified points by drawing a dashed line between each pair of coordinates. At least two points must be specified. Each dash is constructed using the \dottedline command. The mandatory parameter dashlength determines the length of the dash, and the optional dashdotgap gives the gap between the dots that are used to construct the dash, both y default, a solid loolung dash is constructed. in \unitlength% B

In the definition of the \dashline command the optional stretch parameter is an integer between - 100 and oo. This indicates the percentage with which the number of dashes is "stretched" or increased (stretch> 0) or "shrunk" or reduced (stretch < 0). If stretch is zero, the minimum number of dashes compatible with an approximate equal spacing relative to the empty space between dashes is used. The idea behind the stretch percentage parameter is that if several dashed lines of different lengths are being drawn, then all dashed lines with identical stretch values wd1 have a similar visual appearance. The default settings for the stretch percentage can be changed by a \renewcommand call for the parameter
\dashlinestretch:
\renewcommandC\dashlinestretch)C-50) % Only integers permitted

298

Portable Gra~hics in LATX


The argument determines the percentage (as an integer) increase or reduction that will be applied to all subsequent \dashline commands except for those where the stretch parameter is explicitly specified as the first optional argument. \drawline [stretch] ( X I , yl)(xz, y2)...(x,, y,) The \drawline command connects the given points by drawing a line between each pair of coordinates using line segments of the closest slope available in the fonts. A minimum of two points must be specified. Since there are only a finite number of slopes avadable in the line segment fonts, some lines may appear jagged. A \drawline can generate a thick or thin line depending on the setting of the \thinlines or \thicklines parameters in effect; these are the only two thcknesses available for such lines. This command offers the most efficient way, in terms of memory and cpu usage, for drawing lines at arbitrary slopes. The optional stretch parameter is similar to the one described for the \dashline command. If stretch is zero, the result is the minimum number of dashes required to make the line appear solid with each dash "connected" at the ends. If stretch is greater than zero more dashes are used in constructing the line, giving a less jagged appearance. As with the \dashlinestretch parameter and the \dashline command, a similar parameter, \drawlinestretch, allows you to set the default value for the stretch percentage parameter of the \drawline command.
\renewcommand~\drawlinestretchlC2Ol% Only integers permitted

Commands for Drawing Multiple Curves


\ jput(x, yHobject3 \beginCdotted j oin) [dotcharl (dotgap) ..... \ jput commands connected internally with \dottedline \end{dottedj oin) \beginCdashj oin) [stretchl Cdashlength) [dashdotgap] ..... \jput commands connected internally with \dashline \end(dashj oin)

.....

\beginCdrawjoin) [stretchl \ jput commands connected internally with \drawline \end(drawj oin)

The three environments-dottedj oin, dashj oin, and drawj oincorrespond to the three line drawing commands-\dott'edline, \dashline,

10.3 Enhancements to the picture Environment-epic

299

and \drawline. The arguments have the same meaning as for the corresponding drawing commands, and the \dashlinestretch and \drawlinestretch parameters can be used to redefine the stretch globally. These environments use the new command \jput Cjoin and put), whlch is identical to the regular \put command of W&X except it is inside these three environments. All objects put using a \jput command within the scope of any of the three environments are, in addition to being plotted, joined by lines of their respective type. Note that it is up to the user to center the objects at the plotted points. An instance of any of the three join environments defines a separate "curve," hence every set of points belonging to different "curves" should be enclosed in separate join environments. The prime motivation for designing the join environments is for plotting graphs that use different types of curves and dissimilar lines. Figure 10.7 on page 305 shows an example.

The \picsquare command generates a little square dot with its center as the reference point. The size of the square is dependent on the current setting of the \thinlines, \thicklines, or \linethickness command. Most of the epic commands that plot little dots use this command, although it has been provided primarily to be used in conjunction with the \putf ile command described below.

The \putf ile command is similar to m X ' s \put command, except the x and y coordinates required by the \put command are read from an external file and the same object is plotted at each of those coordinates. This command is provided because T E X lacks the capability of doing floating point arithmetic, which is required if you wish to plot a parametric curve different from a straight line. The coordinates of points on such curves can easily be generated by a program in some computer language and subsequently read in by TEX. The external file must contain the (x, y) coordinate pairs, one pair per line, with a space between the two coordinates. The % is available as a comment character, but you should leave at least one space following the y entry if a comment is on the same line as data since a % masks the newline character. For example, to plot a smooth curve along a set of coordinates, you can use the following procedure:
1. Create a file with the (x, y ) coordinates of the data points, which you might call plot. data, for example. 2. If you wish, smooth the data.

3. Put the following inside a picture environment in your IkQX file. \putf ile(p1ot. data)(\picsquare)

300

Portable Graphics in L A T E X

10.4 Extending the epic Package


W X provides a basic but limited picture drawing capability, which is extended by commands for drawing solid lines, dotted lines, dashed lines, and new environments suitable for plotting graphs of the epic package described in the previous section. A T E Xin picture drawHowever, epic still inherits many of the limitations of L ing. As a result, some of the functions take a long time to accomplish or the output is not very h g h quality. A few years ago the pic programming language was developed to provide a "natural language" method of describing simple pictures and graphs [19]. A preprocessor, like gnu's gpic, can translate these graphics commands into output that the UNIX formatter, troff, understands. More interestingly for us, it can also generate T E X \special commands, whch many dvi-driver programs support. For instance, the dvips dvi-to-Postscript translator, described in section 11.2, can interpret these commands. The eepic [48] package, written by Conrad Kwok, is an extension of both E Q X and epic that alleviates some of the limitations in W X , epic, and gpic by generating gpic \specials using TEX commands. Because eepic is a superset of epic, you can use it to process any picture that uses epic commands and get better-looking output.

10.4.1 eepic's Extensions to L A T E X


In L A T E X ,special fonts are used to draw lines and circles. Therefore, only limited functions are provided. The extensions in eepic allow users to draw lines in any slope and to draw circles in any size. However, the limitation of slopes for vectors remains the same. This means that the only slopes that can be handled are of the form x /y, where x and y are integers in the range [-4,4].

(1:106)

The syntax of the \ l i n e command is the same as in P Q X . But now x and y can be any integers acceptable to TEX. Furthermore, there is no longer a lower limit for the length parameter (about 3.5mm in standard I Q X ) .

(1:107)

The syntax for drawing hollow and filled circles, \ c i r c l e and \circle*, is the same as that in E Q X . But now the diameter parameter can be any number acceptable to TEX and a circle with a diameter of (exactly)the specified value will be drawn.

10.4 Extending the epic Package

30 1

The \oval command has been modified so that the maximum diameter of the quarter circles at the corners can be set to any value. This can be done by setting the variable \maxovaldiam to the desired TEX dimension (default 40pt).

10.4.2 eepic's Extensions to epic


epic generates standard dvi-files and requires the presence of only the standard
E Q X fonts. eepic as an extension to epic offers better line drawing output, faster operation, and requires less memory. It reimplements the \drawline, \dashline,and \dottedline commands (see page 296) and the corresponding join environments, dashjoin, dottedjoin,and drawjoin (see page 298).

10.4.3 New Commands with eepic


eepic introduces a number of new commands. Apart from the \path command, these commands do not have equivalents in JAQX and epic. Please read section 10.4.4 for issues of compatibility.

The \allinethickness command sets the line thickness of all line drawing commands, including lines in slopes, circles, ellipses, arcs, ovals, and splines.

After issuing \Thicklines, the thickness of all subsequently drawn lines will be about 1.5 times greater than \thicklines.

The \path command is a fast version of the \drawline command. The optional stretch argument of the latter is not allowed and thus \path only draws solid lines. The \path command is mainly used for drawing complex paths.

The \spline command draws a Chaikin's curve which passes through only the first and last point. All other points are control points only.

302

Portable Graphics in LATEX

In complete analogy with the \circle and \circle* commands, the \ellipse and \ellipse* commands draw a hollow or filled ellipse using the specified x-diameter and y-diameter parameters.

The \arc command draws a circular arc. The first parameter, diameter, is given in \unitlength. Both start-angle and end-angle are in radians; start-angle 7T must lie within the interval [O, -1 and end-angle can be any value between start2 angle and start-angle + 27-r. Arcs are drawn clockwise with the angle 0 pointing to the right on the paper.

changes the interpretation of * in the two commands specified above. Possible values for area-fill-typeare: black (default), white, and shade, e.g., you can change the area fill type to white with \f illtypeCwhite3.

The \f illtype command specifies the type of area fill for the \circle* and \ellipse* commands. The instruction itself does not draw anythmg. It only

10.4.4 Compatibility
The eepic package is not necessarily available at all W X sites. In order to avoid portability problems that can arise from its use, and at the same time take advantage of eepic's more precise printout, you must take the following precautions: Do not to use \line commands, but use \drawline instead because \line in W X only supports a limited set of slopes. Do not use the \arc command. \spline should be used if a complex curve is really necessary. Avoid using solid or small inter-dot gaps in drawing long dash lines, as these need a lot of TEX memory in the original epic implementation. The \drawline command with negative stretch should be used to draw the dashed lines. If your installation does not support eepic but you have to print your document, then you should use the eepic emulation macros defined with the eepicemu package. The extended commands are emulated in the followingways: Circles larger than 40pt will be drawn using \oval. Ellipses will be drawn using \oval. Splines will be approximated with \drawline

10.5 Packages Based on epic

303

\path will be substituted by \drawline. \Thicklines will be substituted by \thicklines. \allinethickness willbe substitutedby\thicklines and \linethickness.

As the eepic package redefines several commands of the epic package the eepic package declaration must follow the epic package declaration. That is,
\documentclass[. . .I {article) \usepackage{epic)

...

\usepackageCeepic)

Although not strictly necessary, it is good practice to always include epic when using eepic commands. In any case, the eepic emulation package eepicemu will only work when both are specified.

10.4.5 Examples
Figure 10.6 on page 304 shows a series of power curves. You can see how the grid is used to set up the coordinate system, and how the different kind of line styles, discussed in the previous sections (dotted, plain, dashed) are used to differentiate the various curves. Each curve is identified by a label representing the fractional power used to calculate the points. Note also that the lines below the diagonal were drawn using the \thinlines command, while those in the upper part of the diagram were drawn with the \thicklines command. Figure 10.7 on page 305 is an example of a possible real-life application. It shows the excitation ( 0 ) and threshold ( 0 ) energies of isotopes with atomic weights around 235 (Uranium). In t h s case we constructed the horizontal and vertical axes using \multiputlist commands. The text along the vertical axis was printed using the \shortstack command. Finally the various data points were entered using epic's dottedjoin and dashjoin environments and their associated \jput commands (see page 298 and following).

10.5 Packages Based on epic


10.5.1 Drawing Bipartite Graphs
The eclbip package, written by Hideki Isozaka, uses the functionality of the epic package to generate bipartite graphs. A bipartite graph is a linear network in which the nodes can be partitioned into two groups, left and right,and the begin and end points of all the arcs start are in opposite groups.

Portable Grauhics

hrl

2*22 m 0
- 4 -

h e

E$gE52z

- o m h m m 0 m n o YNCO k O LINh m n ~n / v r Y / o r l Y ~ ~ Y C \ I C O nd' - r \ w O N O O n O -PC - 0 t 0 0 - 0 . 4 - u C V n u - n d ' X-co x o m m 0-t0 - 4 w - Q r l ...ao a 4 0 w h o

Y hn

RYn

G?

wt-

10.5 Packages Based on epic

305

h h h 0 0 0
U U U / / / Y Y Y

h h h
/ / /

x x x

U U U

x x x

Y Y Y

h h h A C V O O 0
Y U U h / / d Y Y n

h
X

. x x

.,+

.& @? g??
r

U U / / Y Y m n h OCOd

h n dOCV

.// Y Y Y
CVUV

A
X

0 CV CV T l V V

r + . m r m m
d 9 5
r

.,+ a a bo 'r,.r, a / /
/

8:

Excitation Energy

0:

Threshold Energy I

Isotope

306

Portable Graphics in LATX


A bipartite graph is drawn by using the b i p a r t i t e environment.

The b i p a r t i t e environment has five arguments:

lefhvd Maximum width of labels in the left node group. gapwd Width of gap between the left node group and the right node group. rightwd Maximum width of labels in the right node group. gaphr Minimum height of vertical gaps between node labels. labelwd Width between a node (bullet) and its label.
The commands, listed below, are available in a b i p a r t i t e environment.

I \ l e f tnode [short-label1{long-label) I
This is the label to be written on the left node. The mandatory argument, long-label, will be printed, while the short-label abbreviation can be used in the \match command.

( \rightnode [short-Iabell {long-label) (


This is the label for the right node. The arguments are the same as for
\ l e f tnode.

This connects the nodes identified by lefrnode and rightnode.

This specifies the drawing command to be used for subsequent \draw commands.
XXX

:\w
ZZZ
CCC

The use of long and short labels is shown in the next example:

10.5 Packages Based on epic

307

xxx is very

zzz

You can use epic's Line drawing commands (see page 296) to draw the match lines by specifying your choice as an argument to the \brush command.

ZZZ

\
9

is even

longer

\beginCbipartite)C2cm)C1.5cm3C2cm)C3mm)C2mm) \lef tnode [XI Cxxx is very long) \leftnodeCyyyI \leftnodeCzzz) \rightnodeCaaa) \rightnode [b] Cbbb is even longer) \rightnodeCccc) \matchCx)Cccc) \matchCyyy)(b) \endCbipartite)

\
, , B
0.'.

aaa

bbb
CCC

10.5.2 Drawing Trees


The ecltree package, also written by Hideki Isozaka, uses the functions of the epic package to draw trees. Another package for drawing binary and ternary trees is described in section 10.2.3. A tree graph can be drawn using the bundle environment.

The bundle environment has one argument, topnode, indicating the label of the top node. Inside the bundle environment, the following commands are available:

I \chunk [edge-text1 (node-text) I


The \chunk command specifies the nodes of the tree. The mandatory nodetext argument is the label that will be used for the node, while, when present, the optional edge-text argument will be used to label the edge.

This command controls the attributes of the edge lines. Its argument is one of the epic commands, whose description begins on page 296. The first example shows two nested bundle environments, while the second shows the use of the optional argument for labeling the edges.

308

Portable Graphics in

LLL RRR

LLL RRR

\begin{bundle){top) \chunk Cleftl C111) \chunk{\begin{bundle){mmm) \chunk{LLL) \chunk{RRR) \endCbundle)) \chunk [right] {rrr) \end{bundle)

.. . . .. .

yy
I
\ \

The line attributes are controlled with the \drawwith command. Note that the argument of the \drawwith command is evaluated when exiting the bundle environment at the \end{bundle) command. Therefore, i n the example, the first \drawwith command is ignored.
.
\begin{bundle){xxx) \chunk{aaa)

aaa
I

ccc
\

bbb ddd

\chunkC\begin{bundle){yyy) \drawwith{\drawline)%Ignored \chunk{bbb) \drawwithC\dashline 1501 1 3 ) ) \chunk{ddd) \end{bundle)) \drawwith{\dottedline{3)) \chunk{ccc) \end{bundle)

A sequence of attributes can be specified by nesting the \drawwith commands, which are then executed in reverse order.

aaa
bbb ddd eee

ccc fff

10.5 Style Files Based on epic

309

The spacing inside a bundle environment is controlled by three parameters, whose values should be set before entering the bundle environment.
\GapDepth \Gapwidth \EdgeLabelSep

The minimum height of gaps between adjacent nodes. The minimum width of gaps between adjacent nodes. The separation of an edge label from the lower node of the edge.

cousin

brolher nephew

h/e

grandson

sr

CHAPTER

11

Using PostScript

As mentioned in the previous chapter, complex graphics expressed in PostScript commands can be included in documents via \special commands, which are interpreted by a dvi-driver supporting the PostScript language. This chapter first presents a short introduction to the PostScript language and then introduces dvips, one of the most popular dvi-drivers supporting PostScript. The following sections deal with how to merge graphics and text, and how to manipulate (rotate, scale, shade, and apply color) document elements by exploiting the capabilities of the PostScript language and the dvips driver. In the final section another visit to the NFSS will show how, with the help of virtual fonts, native PostScript fonts can be used with I Q X .

11.1 The Postscript Language


1 1.1.1 About the Language
PostScript [l, 2,69,70,74,77] is a page description language. It provides a method for expressing the appearance of a printed page, including text, lines, and graphics. PostScript is a device- and resolution-independent programming language, which describes a complete page at a time, rather than one line at a time, like a line printer. PostScript is a high-level programming language, which is stack-oriented and uses "reverse Polish" or postfur notation. It is a flexible language, since it includes looping constructs, procedures, and comparison operators, and it supports many data types, including reals, Booleans, arrays, strings, and complex

312

Using Postscript objects such as dictionaries. PostScript is resolution- and device-independent, that is, the software is not tied to any particular piece of hardware. The same ASCII file will print on a common 300 dots per inch (dpi)laser printer and a 2,540 dpi phototypesetter. It can also be viewed on a computer display with Display PostScript or previewers, such as ghostscript/ghostview. Although it would be possible to compile PostScript for a given application, a PostScript file is normally interpreted in the printer, so that applications can be developed in a transparent way. Hence, most people will never come into direct contact with the language, but they should realize that they are using PostScript each time they print something on a PostScript printer. The PostScript language features the following possibilities, which can be used in any combination: Arbitrary shapes can be constructed from straight lines, arcs, and cubic curves. The shapes may self-intersect and contain disconnected sections and holes. The painting primitives permit shapes to be outlined with lines of any thickness, filled with any color, or used as a clipping path to crop any other graphic. Text is fully integrated with graphics. In PostScript, text characters are treated as graphcal shapes that may be operated on by any of the language's graphcs operators. Thls is true both for type 1 fonts, where character shapes are defined by using specially encoded procedures [3], and for user defined type 3 fonts, where character shapes are defined as ordinary PostScript language procedures. At present, thousands of typefaces, including those of the world's major typesetting companies, such as Linotype, Agfa-Compugraphc, Monotype, Autologic, and Varityper, are available in PostScript form. You can download these fonts, or those of your own making, to any PostScript printer from your Mac or PC, or from a mainframe. Although bitmapped fonts can be used, generally outline fonts are preferred for the following reasons:

- They are device- and resolution-independent. - They are built using a mathematical representation.
The use of Bezier curves provides a gain of accuracy and flexibility. - They are defined in a 1,000 by 1,000 coordinate system for a character 1 point in size, which can then be scaled, rotated, and skewed at will (see, e.g., figure 11.1on page 314).
-

For complex languages with many thousands of characters (e.g.,Chinese and Japanese) composite type 0 fonts can be used.

11.1 The Postscript Language

313

Images (such as photographs or synthetically generated images) can be sampled at any resolution and with a variety of dynamic ranges. PostScript provides facilities to control the rendering of images on the output device. Several color models are supported and conversion from one model to another is possible.

- RGB or the additive Red Green Blue model, used with displays and film
recorders.

- HSB or the Hue Saturation Brightness model, where hue is the amount
of red, green, and blue; saturation the amount of color and shade; and brightness the amount of light, dark to full color.

- CMYK or the subtractive Cyan Magenta Yellow Black model, used by the
printing industry.

- CIE or the international standard, used in the graphcs arts, television,


and printing industries for reference. A general coordinate system facility supports all combinations of linear transformations, including scaling, rotation, reflection, and skewing. These transformations apply uniformly to all page elements, including text, graphical images, and sampled images. You can build dictionaries for color spaces, fonts, forms, images, halftones, and patterns. There are several compression filters available , such as JPEG and LZW. Again, see figure 11.1 on the next page for an illustration of some of these properties.

1 1.1.2 What Is Encapsulated PostScript?


PostScript pictures often have to be included in text that was composed by a text formatter such as TEX. Adobe has defined the Encapsulated PostScript file format (EPS or EPSF), which complies with the PostScript Document Structuring Conventions (see appendices G and H in 121 or 1871). The EPS format defines standard rules for importing Postscript language files into different environments. EPS files should be "well behaved in their use of certain PostScript operators, manipulation of the graphcs state, interpreter stack, and global dictionaries, so that they do not interfere destructively with the page being composed by the text formatter. Most modern graphics applications generate a conventional Encapsulated PostScript file that can be used without difficulty by W X . Sometimes, however, you may be confronted with a bare PostScript file that does not contain the

314

Using Postscript

Circles wlthin circles stroked

Stroked and filled geometric objects

Y
800 750 7W 650

650

6 550 W 5W 450 4W 350 300 250 200 150 100 50

6 550 W 500

stroked circle

parttally f~lled clrcle

0
eofilied star fllled rectangle

4W
350 300 250 200

w
f'
filled star strolced rectangle

1W 150 50

rn

50 1 W 150 200 250 3 W 350 400 450 500 550

Possible operations with text

Clipping path and special effects with text

Y
800

Y
800 750

750
7W
650

3TMAdDANTE
vertical scaling 1.5
vertical scaling

MEB8l :
600 550 5~ 450 400 350 300 250 200 150 1W 50 50 1 W 150 2 W 250 300 350 400 450 5 W 5 5 0 ~

550 5~ 450 400 350 300 250

verticat scaling 1 homontalsralmg 5 horizontal scaling 1.5 hortzontal scaling 1


4-

a ,

K r c .

0 .

' "
150 100 50

alEtVJ 08 C$

oXI rotate
0
7

0,

P i (D
50 1 W 150 2 W 250 300 350 400 450 500 5 5 0 ~

Figure 11.1:Examples of the capabilities of Postscript The numbers on the axes and the dotted lines show the coordinate system used.

11.2 dvips-A dvi to Postscript Converter

315

necessary information. For use with W X , a PostScript file does not have to conform strictly to the structuring conventions mentioned previously. If the file is "well behaved" (see above) it is enough that the PostScript file contains the dimensions of the box occupied by the picture. These dimensions are provided to by using the PostScript comment line %%BoundingBox, as shown below:
%!

%%BoundingBox: LLx LLy URx URy

The first line indicates that we are dealing with a nonconforming Encapsulated PostScript file. Note that the % ! characters must occupy the first two columns of the line. The second line, which is the more important one for our purpose, specifies the size of the included picture in PostScript "big" points, of which there are 72 to an inch (see table A.l on page 449). Its four parameters are the x and y coordinates of the lower left-hand corner (LLx and LLy) and the upper right-hand corner (URx and URy) of the picture. For instance, a full A4 page (210 mrn by 297 mm) with zero at the lower left corner would need the following declaration:

If the picture starts at (100,200) and is enclosed in a square of 4 inches (288 points), the statement would be:

It is good practice to add one or two points to make sure that the complete picture will be included, because of possible roundmg errors during the computations done in the interpreter.

11.2 dvips-A d v i to PostScript Converter


Most T E X documents at a particular site are designed to use the standard paper size (for example, letter size in the United States or A4 in Europe). The dvips dvi to PostScript translator, developed by Tomas Rokicki [72],defaults to these paper sizes and can be customized for the defaults at each site or on each printer. dvips supports graphcs in a natural way, allowing PostScript graphics to be included and automatically scaled and positioned in a variety of ways. PostScript commands can be included literally in \special commands, but their use is to be discouraged.

316

Using Postscript

b #

Conserve memory, not time Page copies, e.g., for posters c # Uncollated copies d # Debugging e # Maxdrift value f* Run as filter h f Add header file i* Separate file per section k* Print crop marks 1 # Last page m* Manual feed n # Maximum number of pages o f Output file p # First page q* Run quietly r* Reverse order of pages s* Enclose output in save/restore t s Paper format x # Override dvi magnification
a*
# = number

y # A B C #

Multiply by dvi magnification Print only odd (TEX)pages Print only even (TEX)pages Collated copies D # Resolution E* Try to create EPSF F* Send control-D at end K* Pull comments from inclusions M* Don't make fonts N* No structured comments 0 c Set/change paper offset P s Load conf ig .$ s R Run securely S # Max section size in pages T c Specify desired page size U* Disable string param trick X # Horizontal resolution Y # Vertical resolution Z* Compress bitmap fonts

f = file name

s = string

* = suffix, ' 0' to turn off

c = comma-separated dimension pair (e.g., 3.2in, -32.lcm)

Table 11.1: Major options of the dvips program

Missing fonts can be generated automatically if METAFONT exists on the system. If a font cannot be generated, a scaled version of the same font at a different size will be used instead, although dvips will complain about the poor esthetics of the resulting output. One of its most important features is that dvips has virtual font support, which allows the use of native PostScript fonts with TEX (see section 11.9 for more about this). PostScript fonts are accompanied by an "Adobe font metric" ( .afm) file, such as Times-Roman.afm, which describes characteristics of a given font. To use such fonts with TEX, .tfm files should be generated, which contain information about each character. The afmtfm program, distributed with dvips, extracts the necessary information from the .afm file, and generates the .tfm and .vf files. It also allows a different encoding to be used for a Postscript font, which comes in handy in some circumstances. The dvips driver has a plethora of command line options. Table 11.1 presents a summary of those options.

11.3 Merging Text and Postscript Graphics


- -

317

Option

In dvips dvitops emtex oztex textures

Description of drivers Digital Corp. printers (e.g., LN03) Tomas Rokicki's dvips James Clark's dvitops Eberhard Mattes's emTeX Andrew Trevorrow's OzTeX Blue Sky Research's TEXTURES

epsfig X X X X X X

rotating
-

X X
-

n.a. X

changebar X X X X n.a. n.a.

Command used to specify driver: \psf igdriver \rotdriver \driver X means supported, - means not or partially supported, n.a. means not available Table 11.2: Overview of dvi-driver support for various packages

11.3 Merging Text and PostScript Graphics


In this section, a few packages, which use features of dvips and the PostScript language, will be described. In principle, some of the functions are also available with other drivers, such as dvitops, or the emTEX collections (see table 11.2). Of course, PostScript pictures will only be visible with printer drivers or previewers that support PostScript, like ghostview. Note that t h s powerful tool gives you a simple way to determine on your computer screen the bounding box of your PostScript pictures (see section 11.1.2). Table 11.2 shows which drivers are known to the packages and to what extent the functionality offered by the package can be implemented if a certain driver is used. Future releases of the packages might support additional drivers, thus you should consult the accompanying documentation for an up-to-date listing. The table also gives the specific command used by each package to specify the driver for whch W X has to generate \special commands in the d v i file. ~ E support the driver The updated version of these packages for I ~ Q X will names as options to the package, e.g., you can write something like

where epsfig and changebar will pick up the global option emtex to select the code suitable for the intended driver. Alternatively, as seen in figures 9.2 on page 268 and 9.3 on page 270 you can also specify the option on the \usepackage command itself, but since you can have only one driver processing the whole document afterwards placing the option on the \documentclass command is other E packages that also more economical. It is expected that under I ~ Q X ~ contain driver dependent implementation parts will recognize the same option names, so that the above names (and additional ones) will become standard options for packages dealing with driver dependent code.

3 18

Using Postscript

Currently, a package called graphics is under development for later inclusion This package is intended to serve as a into the standard distribution of LATEXZ~. base for other packages offering graphic facilities, by providing graphc inclusion possibilities and graphic manipulation constructs (like rotating or scaling of boxes). Look at the documentation accompanying the IK@XZE distribution once this package is available. The package epsfig (by Sebastian Rahtz, based on earlier work by Trevor Darrell) facilitates the inclusion of Encapsulated PostScript figures into T E X documents. It extracts the information about the bounding box of the figure from the file and positions it automatically, properly scaled accordmg to the user's wishes on the page, leaving the proper amount of space. You can use custom characters, such as "a"and "e" (the latter obtained with \epsf igCf ile=cm .eps ,height=3mm)), freely throughout your document.

This is the file name of the Encapsulated PostScript file (you can also use the ahas figure=). E X height This sets the desired height of the picture (in any of the accepted T units). If this parameter is not specified, then the picture will be printed with its "natural" height, i.e., the one specified on the BoundingBox line inside the PostScript file. When only the width is specified and no height, the latter is scaled in the same proportion as the width. width This sets the desired width of the picture (in any of the accepted TEX units). If this parameter is not specified, the picture will be printed with its "natural" width, i.e., the one specified on the BoundingBox line inside the PostScript file. When only the height is specified and no width, the latter is scaled in the same proportion as the height. The x-coordinate of the lower left-hand corner of the BoundingBox. bbllx The y-coordinate of the lower left-hand corner of the BoundingBox. bblly bburx The x-coordinate of the upper right-hand corner of the BoundingBox. bbury The y-coordinate of the upper right-hand corner of the BoundingBox. clip This parameter ensures that no portion of the figure will appear outside its BoundingBox. "clip=" is a switch and takes no value, but the must be present. angle T h s determines the angle of rotation (in degrees counting counterclockwise). silent This makes the \epsf ig command work silently.
file
'I="

Normally, when you are dealing with Encapsulated PostScript files, you do not have to specify the BoundingBox parameters, since they are read by \epsf ig in the file. Note that when you specify BoundingBox parameters in front of the

11.3 Merging Text and PostScript Graphics

319

\begin{center) \epsf ig{f ile=tac2dim.eps ,% height=4cm) \end{center)

Figure 11.2: A single centered figure

file= specifier on the \epsf ig command, then the ones inside the PostScript file

are ignored. T h s is useful if the BoundingBox parameters are absent from the PostScript file or are wrong. This facility should not be used to obtain specific scaling or translation effects on the page. The width or height parameters should be used for those purposes. The \epsf ig macro is not sensitive to whte space; if you get errors due to some blanks in the argument you have an obsolete release of the package.

This command specifies the driver for which \special commands must be generated. Supported values for driveroption are given in the third column of table 11.2 on page 317. The default value is dvips. As mentioned before, the LATjX2 version of the package will alternatively recognize the driver name specified as a document option.

11.3.1 Simple Figures


When including an EPS picture, you would usually specify the desired height or width on the output page (if you do not specify any dimensions, the "natural" dimensions of the picture are taken, as read on the BoundingBox line in the file, corresponding to the size shown when the picture is printed separately on a PostScript printer). The lower edge of the picture will be located at the point where the command \epsf ig is issued. The image will be scaled to the desired width (or height), using the same factor horizontally and vertically if one of the parameters (height or width) is specified. Figure 11.2 shows a picture with a desired height of 4cm. It is centered by putting it in a center environment.

320

Using Postscript

El
tac2dim.eps

% switch to draft mode \psdraft \begin{center) \epsfig{file=tac2dim.eps,height=3cm) \end{center) % switch back to full mode \psfull

Figure 11.3: A figure in draft mode

11.3.2 Draft Figures


Some Postscript figures can take quite a long time to transmit to the printer and print; for these figures a "draft" mode is available to speed printing of draft versions of the document. A figure printed in draft mode will appear as a box with the name of the figure file (figure 11.3). B y specifying the option draft all figures come out in draft mode. Full processing, which is the default, can be explicitly specified with the option final. Within the document the command \psdraft will switch into draft mode, and all subsequent \epsf i g commands will produce draft figures until reaching the macro \psfull, which switches out of draft mode. No \special commands are used in draft mode, so a draft document can be previewed using any dvi-driver.

11.3.3 More Complex Figure Arrangements


Figures 11.4 to 11.6 on the facing page show how to place various figures on a page using the minipage environment.

11.4 Rotating Material


The package rotating [68](SebastianRahtz and Leonor Barroca) defines new enviA T E X documents. The LATEX~E ronments that let you easily rotate information in L upgrade of this package will recognize the driver names given in table 11.2 on page 3 17 as options. For backward compatibility the used driver can be specified using

This command specifies the driver for which \special commands must be generated. Supported values for driveroption are given in the fourth column of table 11.2 on page 317. The default value is dvips.

11.4 Rotating Material

32 1

\noindent \beginCminipage)[blC.46\linewidth) \centering\epsfig~figure=Europe.eps,width=\linewidth) \captionCPre-1991 Europe) \labelCfig:Europe) \endCminipage)\hfill \beginCminipage)[blC.46\linewidth) \centering\epsfigCfigure=CentralAmerica.eps,width=\linewidth} \captionCCentral America) \labelCfig:CentralAmerica) \endCminipage) \centering\epsfig~figure=TheWorld.eps,width=\linewidth) \captionCA map of the world) \labelCfig:World)

Figure 11.4: Pre-1991 Europe

Figure 11.5: Central America

Figure 11.6: A map of the world

322

Using PostScri~t The r o t a t e environment provides a generalized rotation environment where the text is rotated (clockwise,as is normal in PostScript)by the number of degrees specified as a parameter to the environment. However, no special arrangement is made to find space for the result.

Start here $ n d here


7~

Start here \begin{rotate){56} LATEX \endfrotatel End here

If the user desires W X to leave space for the rotated box, the t u r n environment should be used:
4

&
End here

Start here

Start here \begin{turn){-56) LATEX \end{turn) End here

The s i d e w a y s environment is a special case, setting the rotation to -90, and leaving the correct space for the rotated box.
Start here \begin{sideways) LATEX \end{sideways) End here

Start here

5 End here

If you have to deal with whole paragraphs of text, you will soon realize that TEX boxes are not as simple as they sometimes look: they have a height and a depth. Rotations are made about the point on the left-hand edge of the box that meets the baseline. The results can be unexpected, as shown in a full set of paragraph rotations in figure 11.7 on the next page. If you really want to turn E X box, a paragraph so that it appears to rotate about the real bottom of the T you have to adjust the box by using the (optional) placement parameters with the L A T E X commands:
\newcommand{\T)CA B C D E F G H I J K L M N O P R S T U V W X Y Z l Start \begin{turn){-45) \parbox [t] {15mm){\T)\endCturn) Continue \begin{turn}{-45) \parbox [b] {15mm){\T)\end{turnI End

Continue

' C

End

11.4 Rotating Material

323

GHIJKL MNOPRS TUVWXY

-40'

-80'

-120

-160'

-200

-240'

-280'

-320'

-360'

20

60

1811H3

100

140

180

220

MNOPRS TUVWXY

260

300

340

360

Figure 11.7: Rotation of paragraphs

324

Using Postscript

1 1.4.1 Rotating Tabular Material


Tabular material can also be rotated in this way. The examples below show how the distance between the columns and the vertical placement of the table can be controlled by the use of zero width or zero height rules.
\beginCtabular)Crrr) \ruleCOpt3{15mm)% vertical placement \begin{rotate)C-45)Column l\end{rotate)& \begin(rotate)(-45)Column 2\end{rotate)& \begin{rotate)C-45)Column 3\end{rotate)\\ \hline 1& 2& 3\\ 4 8 4 5& 6\\ 7& 8& 9\\ \hline \end(tabular)

\beginCtabular)Crrr) \ruleCOpt)C15mm)% vertical placement \begidrotate){-45)Column l\endCrotate) \ r u l e C . 5 c m ) { O p t ) & \beginCrotate)C-45)Column 2\endCrotate) \ruleC.5cm)COpt)& \beginCrotate)C-45)Column 3\endCrotate) \ruleC.5cm)COpt)\\ \hline 1& 2& 3\\ 4 & 5& 6\\ 7& 8& 9\\ \hline \end{tabular)

Rotations can be nested, as shown below.


\beginCsideways) \beginCtabular)Cl@C\qquad)r) \em Word \rule<Opt)(lin) & \beginCrotate){-901% Occurrences\end{rotate) \\ [lmm] \hline hello & 33\\ goodbye & 34\\ \hline \end{tabular) \end{sideways)

1 1.4 Rotating Material

32 5

\renewcommand{\arraystretch)Il.2) \setlength{\tabcolsep~{2mm) \begin{sideways) \begin~tabul~)~~lIl*3~rQ~$\times$)l~I) \hline \multicolumnC8~~Icl){ISO paper formats (mm)) \\\hline &&\multicolumn{23Cc)CA series) &\multicolumn{2~{c){B series) &\multicolumn~2){cI){C series)\\\cline{2-8) &0&841&1189&1000&1414&917&1297 \\\cline{2-8) &1&594&841 & 707&1000&648&917 \\\cline{2-8) &2&420&594 & 500&707 &458&648 \\\cline{2-8) &3&297&420 & 353&500 &324&458 \\\clineC2-8) &4&210&297 & 250&353 &229&324 \\\cline{2-8) &5&148&210 & 176&250 &162&229 \\\cline{2-8) &6&105&148 & 125&176 &114&162 \\\clineC2-8) &7& 74&105 & 88&125 & 81&114 \\\cline{2-8) \ruleClmm)COpt) \begin{rotatelC-901% \hspace*{8mm)Format classes% \end{rotate)\rule{lmm){Opt) &8& 52&74 & 62&88 & 57&81 \\\hline \endCtabular) \end{sideways)

Table 11.3: Rotating tabular information

A more complex example is the one in table 11.3. The tabular material is rotated using the sideways environment. Note also the use of the rotate environment to generate vertically running text. As rotate generates a zero width box, it is surrounded by two "invisible rules" of lrnm each. These are added to the \tabcolsep of 2mm and give the result shown in the table. A rotated table can also be generated with the sidewaystable environment where both the table and the caption are rotated (see table 11.4 on the next page). The sidewaystable environment works on a width of \textheight so that when the float is rotated, it comes out the right height. This is not actually very satisfactory, since what you really want are rotated floats that occupy the space they actually use. But captions are a problem since they can precede the figure or table. As a result, they cannot be set in a box of the right width (i.e., the height of the forthcoming object), because it is not known yet. One possible solution is to make the sidewaystable (and its equivalent sidewaysf igure discussed in the next section) always fill a complete page. If that is not desired, you can construct a box of the right size and set the material and caption inside.

\begin{sidewaystable) \centering \beginCtabular~CIllclclclclcllI~

.....

\endCtabular) \caption C. . .IC. . . .) \label{tab:sidewaystable) \endCsidewaystable)

Study Area Total 41 Full sample Sample area 1 23 18 Sample area 2 13 Rushen 10 Arbory 10 Marown 8 Santon

UY

.s k
.A

Number of Sites In Boundary Zone Expected Obs. From To 10.3 27.0 31 16 4.3 16.7 2.8 13.7 15 9 1.2 10.4 8.8 0.6 7 0.4 8.6 8 7.3 0.0 7

Accept or Reject Null Hypoth. Reject Accept Reject Accept Accept Accept Accept

Table 11.4: Rotating tabular information with the sidewaystable environment It is seen that in this case the complete contents of the environment, including the caption, is rotated.

11.4 Rotating Material

32 7
\newcommandC\HR~C\ruleClem)C. 4 p t ) ) % \HR \epsf igCf igure=Escher .eps ,width=i.7crn) \HR

\HR\beginCturn)C240) \epsf igCf igure=Escher .eps,width=1.7cm} \endCturn)\HR

Figure 11.8: A normal, turned, and sideways picture within a figure

11.4.2 Rotating a Figure


Figures can be rotated using the same commands. Figure 11.8 shows how an EPS file using the \epsf ig command can be rotated at d l . Note the position of the baseline, shown by the em dash rule (defined with the command \HR). As with a table and its sidewaystable environment, it is possible to rotate the whole figure environment, includmg caption, by specifying a sidewaysf igure instead of a figure environment.

11.4.3 Rotated Captions Only


Sometimes it turns out that the rotation of complete figures does not give quite the right result. Therefore, it may be desirable to rotate the caption and the float contents separately within a conventional figure. The caption can be rotated separately by 90 by using the \rotcaption instead of the \caption command.

328

Using Postscript

11.5 Using Revision Bars


The changebar package, adapted to Postscript by Johannes Braams, and drawing upon the earlier work of Michael Fine and Neil Winton, implements a way of indicating modifications in a W X document by putting bars in the margin. This package works with most dvi-to-ps drivers, in particular dvips. Note that, just as with cross-references and labels, you will usually need to process a document twice (and sometimes three times) to ensure that the changebars come out correctly. A warning will be issued if another pass is required. Changebars can be nested within each other. Each nesting level can be characterized by a different thickness of the bar. They may also be nested within other environments including floats and footnotes. Changebars are applied to all the material within the "barred" environment, including floating bodies, regardless of where the floats float to. An exception to this are marginal floats. Changebars may cross page boundaries.

11.5.1 The User Interface

This command specifies the driver for which \ s p e c i a l commands must be generated. Supported values for driver are given in the fifth column of table 11.2 on page 3 17. The default value is dvips.

The \ c b s t a r t command indicates the beginning of the region, which has to be flagged with a changebar. The optional banvidth parameter specifies the width with which the changebar has to be drawn. If no width is specified, the current value of the parameter is \changebarwidth. The latter can be redefined at any point with the \ s e t l e n g t h command.

The command \cbend indicates the end of the region where a changebar is to be used. \ c b s t a r t and \cbend can be used anywhere, but they must be correctly nested with floats and footnotes. For example, you cannot have one end of the bar inside a floating insertion and the other outside.

Apart from the \ c b s t a r t and \cbend macros, a K&X environment changebar is defined, which has the same effect as the pair \ c b s t a r t and

1 1.5 Using Revision Bars


\cbend. The advantage of using the environment whenever possible is that INEX will do all the work of checking the correct nesting of different environments.

329

I \cbdelete [barwidthl I
The \cbdelete command prints a square bar in the margin to indicate that some text was removed at that point from the document. The optional argument barwidth specifies the width of the bar. When no argument is specified, the current value of the \deletebarwidth parameter will be used. The latter can be redefmed with the \setlength command.

1 ?
%

This is the text in the first paragraph. This is the text in the first paragraph. This is the text in the second paragraph. This is the text in the second paragraph. This is paragraph three. This is paragraph four.

\cbstart This is the text in the first paragraph. This is the text in the first paragraph.\cbend This is the text in the second paragraph. \cbdelete This is the text in the second paragraph. \begin{changebar) This is paragraph three.\par Thls is paragraph four. \end{changebar)

The command \nochangebars disables the changebar commands.

11.5.2 Changebar Parameters

The width of the changebars is controlled with the W X length parameter \changebarwidth. Its default value is 2pt. It can be changed with the \setlength command. Changing the value of \changebarwidth affects all subsequent changebars subject to the scoping rules of \setlength.

The width of the deletebars is controlled with the W X length parameter \deletebarwidth. Its default value is 4pt. It can be changed with the \set length command. Changing the value of \deletebarwidth affects all subsequent deletebars subject to the scoping rules of \setlength.

330

Using PostScriut

The separation between the text and the changebars is determined by the value of the W X length parameter \changebarsep. Its default value is 3 5pt.

The "blackness" of the bars can be controlled with the help of the IiQX counter changebargrey. A command like \setcounter{changebargrey3{85) changes that value. The value of the counter is a percentage, where the value 0 yields black bars, and 100 yields white bars. Its default value is 65.

El
out erbars

The changebars will be printed in the "inside" margin of the document. This means they appear on the left side of the page. When the twoside option is in effect, the bars will be printed on the right side of even pages. This behavior can be changed by including the \outerbarstrue command in the document.

11.5.3 Deficiencies and Bugs


There is a limit of twenty bars per page. This implementation has not been designed for two column printing. The algorithm may fail for footnotes split over multiple pages. The simplest way to circumvent this is to prevent footnotes from being split but this may give less satisfying page breaks. The \cbend normally gets "attached" to the token after it, rather than the one before it. T h s may lead to a longer bar than intended. For example, consider the sequence "wordl \cbend word2." If there is a line break between "wordl" and "word2" the bar will incorrectly be extended an extra line. This particular case can be fixed with the incantation "wordl\cbend{),word2."

11.6 Boxing and Gray Shading


The psboxit package (by JerBme Maillot) puts a PostScript generated box behind a TEX box, which controls its position and the size. To initialize the Postscript commands of this package, the command \PScommands should be executed at the beginning of your W X job.

11.7 Color Output

331

The \psboxit command gets the PostScript code that should be executed from its first argument, PScommands. The package defines several PostScript procedures, such as cartouche, rectcartouche, and roundedbox, for obtaining certain effects (see the examples below). The second argument, TEX material, is first typeset inside a box before being subjected to the PostScript commands of PScommands.

-m-{=]--5.<dhhXI%,C

--\psboxit(5 cartouche)CCCC)--% --\psboxit{rectcartouche)C\spbox~DDD~--% --\psboxit(box . 7 setgray fill)(\spbox(~EE))--

The additional command \spbox works like \fbox, that is, it puts a box around its argument, but it does not draw the frame itself; it just adds a supplementary space equal to \fboxsep around the natural boundaries of the box. Its main purpose is to be able to construct a gray box filling the same rectangular area as its framed \fbox equivalent. More convenient commands can be easily defmed, for example:
\newcommand~\graybox)111 C\psboxitCbox . 7 setgray fill~(\fbox(#l)))

The boxitpara environment lets you handle larger pieces of text.


\begin{boxitpara){box This is the text of This is the text of This is the text of This is the text of \end(boxitpara) a a a a
0.7 setgray fill) paragraph. paragraph. paragraph. - paragraph.

11.7 Color Output


Colors were not directly included in W X 2.09 in the past, but dvips provides support for some color models present in the Postscript language via the use of \ s p e c i a l commands and James Hafner's colordvi package. For LATEX^^ a color package is currently under development. The availability of that package will be announced via the usual channels and interested users should consult the documentation coming with it.

332

Using Postscript

11.8 Overlaying Text on the Output Page


DRAFT
dvips provides several hooks, e.g.,
s t a r t - h o o k , end-hook, bop-hook,

and eop-hook, for including user PostScript code at the beginning or the end of a document, or at the end of each page (see [72] for more details). You can use this facility, for instance, to have a word or other mark printed across each page. An example is the draftcopy package, whch prints the word "DRAFT" diagonally across each page.

11.9 The NFSS Revisited


B y combining the possibilities of the NFSS and the virtual font mechanism, it is relatively easy to use Postscript fonts with W X . dvips has the necessary machinery to permit the use of resident (in the printer) or downloadable (from disk) Postscript fonts with W X .

11.9.1 Naming Those Thousands of Fonts


A font naming scheme that can be used with TEX was proposed by Karl Berry [lo], provoking some discussion [56]. He tries to classify all font file names using eight alphanumeric characters, where case is not significant. This eight character limit guarantees that the same file names can be used across all computer platforms (something I B M mainframe and MS-DOS users vdl appreciate!). The principle of the scheme is described in table 11.5, while table 11.6 on the facing page shows the classification of the tkty-five "basic" PostScript fonts according to

F TT W V E DD Foundry Typeface name Weight Variant Expansion Design Size e.g., p=PostScript trn=Times b=Bold i=Italic c=Condensed 10=10 point

Table 11.5: Karl Berry's font file name classification scheme

11.9 The NFSS Revisited

333
External names Serif families

Family

I Series ( Shape
( T i , OT1)

pm

m
b

m
b

Pnc
pbk

m
b

m
b
( T i , OT1)

n, it Times-Roman(ptmr) , Times-Italic (ptmri) n, it Times-Bold(ptmb) , Times-~oldItalic(ptmbi) n, it palatino-Roman(pp1r) , Palatino-Italic (pplri) n, it Palatino-Bold(pp1b) , Palatino-BoldItalic(pp1bi) n,it ~ewCentur~Schlbk-Roman(pncr), ~ew~enturyschlbk-Italic(pncri) (pncbi) n, it NewCenturySchlbk-Bold(pncb) , New~entury~chlbk-~old~talic Bookman-Light (pbkl) , ~ookman-Light~talic (pbkli) n, it (pbkdi) n, it Bookman-Demi (pbkd) , Bookman-Demi~talic
Sans serif families

m
phv
b

pag

c bc m
b
( T i , OT1)

n, sl Helvetica(phvr) , Helvetica-Oblique(phvro) n, sl Helvetica-Bold(phvb) , Helvetica-BoldOblique(phvbo) n, sl Helvetica-Narrow(~hvrrn), Helvetica-Narrow-Oblique(phvron)


n,sl Helvetica-Narrow-Bold(phvbrn), Helvetica-Narrow-Bold~blique(phvbon) n,sl ~vantGarde-Book(pagk), AvantGarde-~ook~blique(pagko) (pagdo) n, sl AvantGarde-Demi (pagd) , AvantCarde-Demi~blique Non-proportional font , CourierOblique (pcrro) n, sl Courier (~crr) n, sl Courier-Bold(pcrb) , Courier -Boldoblique (pcrbo) Special display fonts n Symbol(psyr) ZapfDingbats (pzdr) n

Per

m
b (U)a

PSY Pzd Pzc

m m m

zapfChancery-~ediumItalic (pzcmi)

aExcept ZapfChancery,which is available in T1 and OT1 encoding

Table 11.6: NFSS classification of the basic Postscript fonts (in parentheses-Karl Berry's file name)

the NFSS scheme. For each font the full Adobe name and, between parentheses, the corresponding short (Karl Berry) file name is given. The scheme provides a handy way to map long typeface names onto shorter equivalents, which are handled easily by dvips on the various systems where it is installed. Most or all of the fonts in table 11.6 are present in the ROM of the common laser printers. Yet, there still are some printers (often older or cheaper models) that do not carry all of these fonts. Therefore, if portability of the printed document is important, it is wise to stick to the three basic PostScript fonts: Times-Roman, Helvetica, and Courier. The mapping between the layout in a PostScript font and the font encoding

334

Using Postscript Style file times palatino helvet avant newcent bookman garamond basker mtimes bembo lucid lucidbrb lucidbry Sans font Helvetica Helvetica Helvetica AvantGarde AvantGarde AvantGarde Optima Univers Univers Optima LucidaSans LucidaSans LucidaSans Roman font Times Palatino Typewriter font Courier Courier

NewCenturySchoolbook Bookman Garamond Baskerville Monotype Times Bembo Lucida LucidaBright LucidaBright

Courier Courier Courier Courier cmt t Courier Courier LucidaSansTypewriter LucidaSansTypewriter

Table 11.7: Fonts used by various PSNFSS packages needed by TEX is performed using the virtual font mechanism, which dvips understands. The mapping between font names used inside TEX and external (Karl Berry) file names is controlled by the file psf onts .map. dvips searches this file to see whether fonts should be included in the document, or are resident in the printer. B y simply editing this file it is, for instance, possible to use PostScript renderings of the Computer Modern family instead of the bitmap .pk images. The advantage is that your document can now be printed on any PostScript printer, independent from the resolution or the printing engine. Especially at higher resolutions, this reduces enormously the disk space needed for storing font images. The PostScript renderings of the Computer Modern fonts were produced by Blue Sky Research; Y&Y added the L A T E X ,AMS, and Euler fonts.

11.9.2 The PSNFSS System


The PSNFSS system, developed by Sebastian Rahtz, and based upon earlier work by Kresten Thorup and Timothy van Zandt, offers a set of files that provide a complete working setup of the NFSSZ for use with PostScript fonts. The PSNFSS system uses the Karl Berry naming scheme throughout. In normal use you will probably only have to include one of the packages times, newcent, helvet, palatino, etc., to change the default text fonts for one or more of the roman, sans serif, and typewriter faces. Table 11.7 lists PostScript fonts that are used for each of these three categories. In each case the font famdy chosen for the roman (the default font for the document text), sans serif, and typewriter fonts are shown, except for the packages helvet and avant, which only set the sans serif font to Helvetica and

1 1 . 9 The NFSS Revisited

335

AvantGarde, respectively. The packages in the upper part of the table only use fonts that are generally available in the ROM of the PostScript laser printers. The packages in the lower half of the table refer to fonts that you normally would have to buy (apart from Courier and cmtt). Note that the packages lucidbrb and lucidbry load the same Lucida-Bright font family, but the former uses the Karl Berry names for the font files, while the latter uses original names as defined in the distribution by Y&Y. Note that math fonts cvlll stay the same unless you have suitable fonts to load. If the Lucida Math fonts have been purchased, and appropriate metrics obtained, loading the lucmath package will remove all reference to cmr fonts in the document. Alternatively, you can purchase the Lucida Bright font set and use the lucid brb (lucidbry) package. Another interesting package is pifont, which sets up various commands for use with the so called Pi fonts, i.e., special character fonts like ZapfDingbats or Symbols (see section 11.9.3).

11.9.3 Using the Postscript Pi Fonts


Fonts containing collections of special symbols, which you normally do not find in a text font, are called Pi fonts. One such font, the Postscript font ZapfDingbats, is available if you use the pifont package. It is part of the PSNFSS system. The directly accessible characters of the PostScript ZapfDingbats font are shown in table 11.8 on the next page. A given character can be chosen via the \ding command. The parameter for the \ding command is an integer that specifies the character to be typeset according to the table. For example, \ding{38) gives (a. The dinglist environment is a special itemize list. The argument specifies the number of the character to be used as the beginning of each item.
The first item in the list. The second item in the list. The third item in the list.
\begin{dinglist){228) \item The first item in the list. \item The second item in the list. \item The third item in the list. \endCdinglist)

You can fill a complete line with a given character using the command
\dingline,the argument once more indicating the desired character. For filling the remaining part of a line, use the command \dingf ill.

text text text text

Db Db Db

Db

Db

\par\medskip text text text text \dingf ill(253)

There also exists an environment dingautolist,which allows you to build

336

Using Postscript

Table 11.8: The characters in the Postscript font ZapfDingbats

an enumerated list with a set of ZapfDingbats characters. In this case, the argument specifies the number of the first character in the list. Subsequent items will be numbered with the character following the previous one, as shown in table 11.8.

O The first item in the list. O The second item in the list.
O The third item in the list. References to list items work O, 0,O

\begin{dingautolist}{192} \item The first item in the list. \labelClst:zdl} \item The second item in the list \label{lst:zd2} \item The third item in the list. \label{lst:zd3} \endCdingautolist} References to list items work \ref{lst:zdl>, \ref{lst:zd2}, \ref{lst:zd3)

11.9 The NFSS Revisited

337

11.9.4 Generic Commands in the Style pifont


The pifont package has a general mechanism for coping with Pi fonts. It provides the following generic commands with, in each case, the first argument fontname specifying the (Karl Berry short) name of the Pi font in question (such as psy for the Symbol font, and pzd for the ZapfDingbats font; see table 11.6 on page 333).

I \Pifont C fontname) 1
This switches to the font fontname.

The symbol at decimal position numsym is typeset in font fontname (compare this with the \ding command).

This typesets a full line consisting of several copies of the symbol at decimal position numsym in font fontname (compare with the \dingline command).

The remaining part of a line is filled with several copies of the symbol at decimal position numsym in font fontname (compare with the \dingf ill command).

This defines an environment where the symbol at decimal position numsym in font fontname is used in front of each item in an itemized list (compare with the dinglist environment).

This defines an environment where a series of symbols starting with the symbol at decimal position numsym in font fontname is used to number the items in an enumerated list (compare this with the dingautolist environment).

11.9.5 The Symbol Font


Using the commands described in the previous section, it now becomes easy to access the characters in the Symbol font, shown in table 11.9 on the following page. For example, \PisymbolCpsy)C224) gives 0.

338

Using Postscript

Table 11.9: The characters in the Postscript font Symbol

Table 11.10: Accessing the Greek characters in the Postscript font Symbol

When only Greek letters are desired, you can use the \ P i f ont command and consult the correspondence in table 11.10, for example,
AAflA

o p ~ paQa.

C\PifontCpsy) ALJA\quad wmega\quad alja).

You can also make a list with characters in the Symbol font, as follows:
The first item in the list. The second item in the list.
\beginCPilist){psy)C222) \item The first item in the list. \item The second item in the list. \endCPilist)

11.9 The NFSS Revisited

339

11.9.6 Setting Up New Postscript Fonts Yourself


If you want to set up new (Postscript) fonts and ckate the necessary .f d files, you should follow the procedure explained in section 7.7. Suitable models for a large multifont installation can be found in psf onts .f dd (covering both old TEX encoding and EC encoding), but an .f d file for a single font is easy to write by hand, once you know which font encoding it uses. As an example, we shall look at the declaration file OTlppl .f d for old-style TEX-encodingPalatino (OT1):
% Primary declarations \~eclareFontFamily~OT1)Cppl)C) \~eclareFont~hape{0~1)Cppl>{m>~n>{<->pplr>{> \~eclare~ont~ha~e{0~1)Cppl>{m>{it>{<->pplri>{> \~eclareFont~hape{0~1)Cppl>{b>{n>{<->pplb>{> \~eclare~ont~hape~OTlHppl>~b>{it)C<->pplbi>{> \~eclare~ont~ha~e{0~1>{ppl>{m>{sc)C<->pplrc>~> \~eclare~ont~ha~e{~~l>{ppl>{m>{sl>{<->pplro>{> % Substitutions \~eclareFont~hape{OT1)Cppl>~b>{~~)C< *- > ppl/m/sc>{> su \~eclare~ont~hape{OTl)(ppl>{b>{sl>{<->sub * ppl/b/it>C> \~eclare~ont~hape{0~1)Cppl)(bx>{n>{<->sub * ppl/b/n>C> \~eclare~ont~hape~OTl)Cppl)Cbx)Cit)C<->sub * ppl/b/it>C> \~eclare~ont~hape{0~1)Cppl)Cbx)Csc)C<->sub * ppl/m/sc>{> \ ~ e c l a r e ~ o n t ~ h a p e { O T 1 ) C p p l ) C b ~ ) C ~ l ~ <* -> ppl/m/sl>{> ~~b \endinput

Once we declare the font family and encoding, each combination of series and style is mapped to the name of a .t f m file. In the case of Postscript, we do not have to worry about what sizes are available, because these fonts can be scaled to any size (hence the <-> declarations on the \DeclareFont Shape commands). The second part of the file sets up some substitutions for situations where there might be no font available (bold small caps, bold slanted, or bold-extended series). If you want to create your own package that can be used in the same way as the ones provided with PSNFSS, then you should simply use the standard NFSSZ constructs. Below we show the relevant part of the file times. After declaring the sans serif (Helvetica,phv), roman (Times-Roman,ptm) and teletype (Courier, pcr) fonts we make "b" the default for bold rather than "bx."
% File times.sty \renewcommand{\sfdefault>{phv>% \renewcommand{\rmdefault)Cptm)x

declare sans-serif font declare roman font \renewcommand{\ttdefault)Cpcr)'/. declare teletype font \renewcommand{\bfdefault>{b> % use bold "b" \endinput

340

Using Postscript

11.9.7 Replacing All TEX Fonts with PostScript Fonts


With the help of the PSNFSS system it becomes easy to replace all T E X fonts in a document with PostScript fonts. You can, of course, first replace the .pk versions of the Computer Modern family with their commercial type 1equivalents, which is trivial by merely editing dvips's control file psf o n t s .map. In this case, your output will be printable on all PostScript devices, without loss of quality. Another possibility is to use a font like Times-Romanfor your text (using, for example, the times package). Many people still keep the Computer Modern math family, but their documents look unbalanced, since the various typographic characteristics of Times-Roman, cmsy, and cmmi are quite &fferent (cm fonts look too light and their x-height is also different). To obtain better visual results you can try the mathtime font package of Michael Spivak [821. This family of type 1 PostScript fonts have been designed specifically to typeset mathematics that blend with Times-Roman. Alan Jeffrey has developed the pstimesm package, which together with some macros by Spivak himself replace the cm math fonts with mathtime's. E X fonts with the LucidaBright Another solution is to completely replace all T and LucidaNewMath fonts, available from Y&Y [93]. These fonts were designed by Charles Bigelow and Chris Holmes and the package consists of 22 type 1 fonts with over 4,000 different characters. It includes all of the symbols needed A T E X and A$-TEX (see tables 8.2 to 8.20 beginning on page 218), a by both L E X lot of extra fonts, like a Calligraphic and Blackletter font, plus of course T characters. The lucidbrb (or lucidbry) package provides all the definitions for typesetting your complete document with this font family. Figures 11.9 to 11.11 starting on page 342 show the same text typeset in the three setups described above.

11.10 DCPS-The Cork Encoding with PostScript Fonts


The Adobe PostScript fonts do not always contain all the characters that are needed to print documents in all Latin languages. In particular, most fonts lack some of the characters of the Cork scheme (table 9.1 on page 261). The native Adobe character encoding is also different from the one used in the Cork scheme. As an example, consider the layout for the PostScript font Helvetica (shown in table 11.11). You can see that most accented characters, such as a or ii are absent since they are not encoded in the standard Adobe encoding vector [2, page 5981. To suit the Cork layout you must reencode the PostScript fonts. This is most easily done via virtual fonts. The recent versions of afm2tfm and dvips provide reencoding facilities so you can rearrange directly all accessible characters into their positions for the extended layout. The result is shown in table 11.12.

11.10 DCPS-The Cork Encoding with PostScri~t Fonts

341

Table 11.11: Original Adobe font layout for the Helvetica font

Table 11.12: DC TEX font layout with Helvetica

342

Using Postscript

Multiple integral signs

\ i i i n t , and \ i i i i n t give triple and quadruple multiple signs with the intermef ( x ,y, z) dx dydz diate spacing nicely adjusted, in text style, for example, and

Jmf (w, x, y, z) dw dx dy dz, as well as in display style.


A
A

S o

Binomial expressions

For binomial expressions such as you have the commands \binom, \dbinom, and \tbinom. \binom is an abbreviation for \f racwithdelims 0 [Opt].

(z)

Split equations

The s p l i t environment provides no numbering because it is intended to be used only inside some other displayed equation structure, such as equation, a l i g n , or gather. These outer environments will provide the numbering.

Figure 11.9: Example of a page typeset with the Computer Modern fonts

11.10 DCPS-The Cork Encoding with Postscript Fonts

343

1 Multiple integral signs


\iiint,and \iiiint give triple and quadruple multiple signs with the interme0f ( x , y , z ) d x d y d z diate spacing nicely adjusted, in text style, for example, 1
A

and j m f ( w , x , y , z ) d w d x d y d z , as well as in display style.


A

2 Binomial expressions
For binomial expressions such as you have the commands \binom,\dbinom, and \tbinom. \binom is an abbreviation for \f racwithdelims 0 [Opt].

(3

3 Split equations
The split environment provides no numbering because it is intended to be used only inside some other displayed equation structure, such as equation, align,or gather. These outer environments will provide the numbering.

Figure 11.10: Example of a page typeset with the Mathtime fonts

344

Using Postscript

1 Multiple integral signs


\iiint, and \iiiint give triple and quadruple multiple signs with the intermediate spacing nicely adjusted, in text style, for example, 111f ( x , y, z ) dx d y d z and JJjJf ( w ,x , y , z ) d w d x d y d z , as well as in display style.
A

(1)

1 1
A

f ( x , Y , z ) dx d y d z

(2)

j - l j f i w , x , y , z )d w d x d y d z

2 Binomial expressions
For binomial expressions such as ( I:) you have the commands \binom, \dbinom, and \tbinom. \binom is an abbreviation for \f racwithdelims (1 [Opt].

(3)

2 Iy
YErc

zk +

(:)

zk-I

(:)

2k-2

. . . + ( - I ) ' ( ; ) zk-' + . . + ( - l l k

( 2 - l ) k= 1

3 Split equations
The split environment provides no numbering because it is intended to be used only inside some other displayed equation structure, such as equation, align, or gather. These outer environments will provide the numbering. (4) ( a + b14 = ( a + b 1 2 ( a+ b12 = ( a 2+ 2ab + b 2 )( a 2+ 2ab + b 2 ) = a4 + 4a3b + 6a2b2+ 4ab3 + b4 Figure 11.11: Example of a page typeset with the Lucida Math fonts

CHAPTER

12

Index Generation
To find a topic of interest in a large document, book, or reference work, you usually turn to the table of contents or, more often, to the index. Therefore, an index is a very important part of a document, and most users' entry point to a source of information is precisely through a pointer in the index. You should, therefore, plan an index and develop it along with the main text. For reasons of consistency, it is useful, with the technique discussed below, to use special commands in the text to always print a given keyword in the same way in the text and the index throughout the whole document. This chapter first reviews the basic indexing commands, and explains which tools are available to help you build a well-thought-out index. The W X book itself does not contain a lot of information about the syntax of the \index entries. There are, however, several articles in TUGboat that deal with the question of generating an index with T E X or L A T E X [7,8,20,29,83,84,94].The syntax described in section 12.1 is the one recognized by MakeIndex [16,501, the most generally used index preparation program. Its user interface is described in sections 12.2 and 12.3. Section 12.4 discusses the various steps of preparing an index for typesetting, presenting in some detail the formats for the input and output files read and written by MakeIndex. The interpretation of the input file and the format of the output file are controlled by style parameters. These parameters are described and several simple examples are given to show how changing them influences the typeset result. The final section is devoted to the subject of multiple indexes, which will be discussed with the help of an example.

(L77-79)

346
tex

Index Generation

+I
O A raw index ( .idx file) is generated by running LATEX. O The raw index, together with some optional style information ( .i s t
@

L A T E X
idx
T

file), is used as input to the index processor, Makelndex, which creates an alphabetized index (. ind file) and a transcript (. ilg file). O The index ( .ind file)is read by W X to give the final typeset result.

@
-

Makelndex
tex

ist

1
0
Q X

ind
T

ilg

Figure 12.1: The sequential flow of index processing and the various auxiliary files used by L A T E X and Makelndex The process of generating an index is schematically shown in figure 12.1. The steps for generating an index with L A T E X and Makelndex are illustrated in this figure. Figure 12.2 on the next page shows, with an example, the various steps of transforming an input file into a typeset index. It also shows, in somewhat more detail, which files are involved in the index generating process. Figure 12.2(a)shows some occurrences of index commands (\index) in the document source, with corresponding pages listed on the left. Figure 12.2(b)shows A T E X . After running through the index procesa raw index .idx file generated by L sor Makelndex, it becomes an alphabetized index .ind file with WQX commands specifying a particular output format (figure 12.2(c)). The typeset result after formatting with INEX is shown in figure 12.2(d). L A T E X and Makelndex, together, use a certain number of markup conventions to help you control the precise format of the output. In section 12.1, which describes the format of the \index command, we always use the default settings for the special characters (as described in tables 12.1 on page 358 and 12.2 on page 359) d e h n g the interface. Section 12.4.1will show how you can customize these characters and the generated output to suit your particular needs.

12.1 Syntax of the Index Entries


This section describes the default syntax used to generate index entries with I4&X and Makelndex. Different levels of complexity are introduced progressively, showing, for each case, the input file and the generated typeset output.

12.1 Syntax of the Index Entries

347

Page vi: Page 5: Page 6: Page 7: Page 11: Page 17: Page 26: Page 32:
(a) The input file
\begin{theindex) \item animal, vi, 5-7 \subitem insect, 32 \subitem mammal \subsubitem cat, 26 \item \emph{animal), 17 \item animalism, \see{animal){11) \indexspace \item mammal, \textbf{17) \end{theindex)
(c)The ind

(b)The .idx file

animal, vi, 5-7 insect, 32 mammal cat, 26 animal, 17 animalism, see animal mammal, 17
(d) The typeset output

file

Figure 12.2: Stepwise development of index processing

12.1.1 Simple Index Entries


Each \index command causes L A T E X to write an entry in the .idx file. The following example shows some simple \index commands, together with the index entries that they produce. The page number refers to the page containing the text where the \index command appears. As shown in the example below, duplicate commands on the same page (such as \indexCstylistic) on page 23) produce only one "23" in the index. style, 14 style , 16 style, iii, 1 2 style, 15 style file, 34 styles, 12 Stylist,xi stylist, 34 stylistic, 23 Page iii: Pagexi: Page 12: Page 14: Page 15: Page 16: Page 23: Page 34:
\index{style) \index{Stylist) \indexCstyle) \index{styles) \index{ style) \index{style ) \index{ style ) \index{stylistic) \index{stylistic) \index{style file) \index{stylist)

348

Index Generation

We draw your particular attention to the way spaces are handled. Spaces inside \index commands are written literally to the output . i d x file and, by default, they are treated as ordinary characters by Makelndex, which places them in front of all letters. In the example above, look at the s t y l e entries on pages 14 and 16. The leading spaces are placed at the beginning of the index and on two different lines because the trailing blank on page 16 lengthens the string by one character. We end up with four different entries for the same term, an effect whch was probably not desired. It is therefore important to eliminate such spurious spaces from the \index commands. Alternatively, you can specify the - c option when running the Makelndex program. This option suppresses the effect of leading and trailing blanks (see section 12.3). Another often occurring error is that the same word is spelled inconsistently with an initial lowercase and uppercase letter (as with S t y l i s t on page xi). Unless this is a design feature, such spurious double entries should be eliminated.

12.1.2 Generating Subentries


Up to three levels of index entries (main, sub, and subsub entries) are available with EQX-Makelndex. To produce such entries, the argument of the \index command should contain both the main and subentries, separated by a ! character. This character can be redefined in the MakeIndex style file (see table 12.1 on page 358).
box, 21 dimensions of, 3 3 parameters, 5 dimensions figure, 12 rule height, 12 width, 3 table, 9 Page3: Page 5: Page9: Page 12: Page 21: Page 33:
\index{dimensions!rule!width) \index{box!parameters) \index{dimensions!table) \index{dimensions!rule!height) \index{dimensions!figure) \indexCbox) \index{box!dimensions of)

12.1.3 Page Ranges and Cross-References


You can specify a page range by putting the command \index{. . . I 0 at the beginning of the range and \index{. . . I ) ) at the end of the range. Page ranges should span a homogeneous numbering scheme (e.g., roman and arabic page numbers cannot fall within the same range). Note that MakeIndex does the right thing when both ends of a page range fall on the same page, or when an entry falls inside an active range. You can also generate cross-reference index entries without page numbers by using the s e e encapsulator. Since the "see" entry does not print any page number, the commands \index{. . . I see{. . .)) can be placed anywhere in the

12.1 Syntax of the Index Entries

349

input file after the \begin{document) command. For practical reasons, it is convenient to group all such cross-referencing commands in one place.
fonts Computer Modern, 13-2 5 math, see math, fonts Postscript, 5 table, ii-xi, 14 Page ii: Page xi: Page 5: Page 13: Page 14: Page 17: Page 2 1: Page 25:
\index{tableI () \index{tablel)) \indexCfonts!PostScriptlO \index{fonts!PostScriptl)) \index{fonts!Computer Modern10 \indexCtable) \index{fonts!mathlsee{math, fonts)) \indexCfonts!Computer Modern) \indexCfonts!Computer Modernl))

12.1.4 Controlling the Presentation Form


Sometimes you may want to sort an entry according to a key, whle using a different visual representation for the typesetting, such as Greek letters, mathematical symbols, or specific typographc forms. This function is available with the syntax: key@visual, where key determines the alphabetical position and the string visual produces the typeset text of the entry.
delta, 14 6, 23 delta wing, 16 flower, 19 ninety, 26 xc, 28 ninety-five, 5 tabular environment, 23 Page 5: Page 14: Page 16: Page 19: Page23: Page 26: Page 28:
\index{ninety-five) \index{delta) \index{delta wing) \index{flowerO\textbf~flower)) \indexCdeltaO$\delta$) \indexCtabularQ\texttt{tabular) environment) \indexCninety) \index{ninetyOxc)

For some indexes, certain page numbers should be formatted specially, with an italic page number (for example) indicating a primary reference, and an n after a page number denoting that the item appears in a footnote on that page. Makelndex allows you to format an individual page number in any way you want by using the encapsulator syntax specified by the I character. What follows the I sign will "encapsulate" or enclose the page number associated with the index entry. For instance, the command \index{keyword l xxx) will produce a page number of the form \xxx{n), where n is the page number in question. Simdarly, the command \index{keywordl (xxx) wdl generate a page range of the form
\xxx{n-m).

Preexisting commands (like \textit in the example below) or user commands can be used to encapsulate the page numbers. As an example, a document containing the command d e h t i o n :

350

Index Generation

would yield something like:


tabular, ii, 21, 22n tabbing, 7, 34-37 Page ii: Page 7: Page 21: Page 22 Page 34: Page 37:
\index{tabular I textbf \indexCtabbing} \index{tabular(textit} \index{tabularlnn} \indexCtabbingI (textit} \index{tabbing I

The see encapsulator is a special case of this facility, where the \see command is predefined by the makeidx package.

12.1.5 Printing Those Special Characters


To typeset one of the characters having a special meaning to Makelndex (!, ", 0, or 1)l in the index, precede it with a " character. More precisely, any character is said to be quoted if it follows an unquoted " that is not part of a \ " command. The latter case is for allowing umlaut characters. Quoted !, 0,",or I characters are treated like ordinary characters, losing their special meaning. The " preceding a quoted character is deleted before the entries are alphabetized.
@ sign, 2

I , see vertical bar

Page 1: Page 2: Page 3: Page 4: Page 5:

exclamation (!), 4 Ah!, 5 Madchen, 3 quote ("), 1 " sign, 1

\index{barQ\texttt{"I}Isee{vertical \index{quote (\verb+""+)} \index{quoteQ\textttC"") sign} \index{atsign@\texttt{"Q} sign} \index{maed~henQM\~~{a}dchen) \index{exclamation ( ' I! \index{exclamation (I1 ! ) !Ah1' !}

bar}}

12.1.6 Points to Note


When an \index command is used directly in the text, its argument is only expanded when the index is typeset, not when the .idx file is written. However, when the \index command is contained in the argument of another command, characters with a special meaning to TEX, like \, must be properly protected against expansion. This is likely to be a problem when indexing items in a footnote, or in commands that put their argument in the text and enter it at the same time in the index (see the discussion in the next section). Even in this case, robust commands can be placed in the "0" part of an entry, as in \index{rose@{\it rose)), but fragile commands must be protected with the \protect command. If the index text contains commands, as in \index{\Prog), it is likely that the entry is wrongly sorted since in main text this entry is sorted under the sort
AS noted earlier, other characters can be substituted for the default ones to carry a special meaning. T h s is explained on page 360.

12.1 Syntax of the Index Entries

351

key \Prog (with the special character \ as the starting sort character) regardless of the definition of the \Prog program. On the other hand, if used in some argument of another command, \Prog will expand before it is written to the . idx file and the placement in the index will then depend on the expansion of
\Prog.

As with every argument of a command you need to have a matching number of braces. However, due to the feature of \index allowing special characters like % or \ in its argument if used in main text, the brace matching has an anomaly: braces in the commands \{ or \3 take part in the matching. Thus you cannot write \index{\{) or something similar. For sorting, MakeIndex assumes that pages numbered with roman numerals precede those numbered with arabic numerals, which in turn precede alphabetic page numbers. This precedence order can be changed (see the entry page-precedence in table 12.2 on page 359). MakeIndex will place symbols (i.e.,patterns starting with a nonalphanumeric character) before numbers, and before alphabetic entries in the output. Symbols are sorted according to their ASCII value. For word sorting, uppercase and lowercase are considered the same, but for identical words, the uppercase variant will precede the lowercase one. Numbers are sorted in numeric order. Spaces are treated as ordinary characters when alphabetizing the entries and for deciding whether two entries are the same (see also the example on page 348). Thus if LLU"denotes a space character, then the commands \index{cat), \index{,cat), and \index{cat,) produce three separate entries. All three entries look similar when printed. Similarly, \indexCa,space) and \index{a,,space) produce two different entries that look the same on output. It is thus important to check for such spurious spaces by being careful when splitting the argument of an \index command across lines in the input file. The showidx package (by Leslie Lamport) can help you improve the entries in the index and locate possible problems. It shows all \index commands in the margin of the printed page. Figures 12.3 and 12.4 on page 354 show the input and generated output of a small I Q X document, where various simple possibilities of the \index command are shown, together with the result of including the showidx package. To make the index entries consistent (see the next section), the commands \Corn and \Prog were defined and used. The index generating environment theindex has been redefined to get the output on one page (see section 12.5 to see how this can be done).

12.1.7 Consistency and Index Entries


As it was pointed out in the introduction, it is very important to use the same visual representation for identical names or commands throughout a complete document, including the index. You therefore can define user commands, which

352

Index Generation
always introduce similar constructs in the same way into the text and the index. For example, you can define the command \Index, whose argument enters its argument at the same time in the text and in the index.

As explained at the beginning of the previous section, you must be careful that the argument of such a command does not contain expandable material (typically control sequences) or spurious blanks. In general for simple terms, like single words, there is no problem and this technique can be used. You can even go one step further and give a certain visual representation to the entry, for instance, typesetting in a typewriter font.

Finally, you can group certain terms by defining commands that have a generic meaning. For instance, F&X commands and program names could be treated with special commands, like:
\newcommand{\bs~~\symbol~'134~~% print backslash \newcommandC\Com) [I] {\texttt~\bs#l)\indexC#1Q\texttt{\bs#l))) \newcommand{\Prog) [11 C\texttt{#l)\indexC#l@\texttt{#l} program))

The \Corn command adds a backslash to the command's name in both text and index, thus easing the work of the typist. At the same time, commands will be ordered in the index by their name, ignoring the \. The \Prog command, similarly, does not include the \texttt command in the alphabetization proand \indexCkey) would result cess, since entries like \index(\texttt(key)) i n different entries in the index.

12.2 Preparing the Index


12.2.1 Generating the Raw Index
After having introduced the necessary \index commands in the document, as described in the previous section, we now want to generate the index to be included back into the L A T E X document on a subsequent run. Therefore, if the main file of a document is main. tex, then the following changes should be made to that file:
(1 78)

Include the makeidx package with an \usepackage command. Put a \makeindex command in the document preamble.

12.3 Running the MakeIndex Program

353

Put a \ p r i n t i n d e x command where the index is to appear-usually at the end, right before the \end(document) command.
main. idx, which we shall call the .idx file.

You then run J$&X on the entire document, causing it to generate the file

12.2.2 Generating the Formatted Index


To generate the formatted index, you should run the Makelndex program by typing the following command (main is the name of the input file):
makeindex main.idx

T h s produces the file main. ind, which will be called the ind file. If Makelndex generated no error messages, you can now rerun W&X on the document and the index will appear. (You can remove the \makeindex command if you do not want to regenerate the index.) See page 356 if there are error messages. B y reading the index, you may discover additional mistakes. These should be corrected by changing the appropriate \index commands in the document and regenerating the . ind file. An example of running MakeIndex is shown below, where the .idx file, main. idx, is generated by a first W$X run on the input shown in figure 12.3 on the next page. You can clearly see that two files are written, namely the ordered .ind index file for use with IK&X main. ind and the index . i l g log file, main. i l g , which (in t h s case) will contain the same text as the output on the terminal. If errors are encountered then the latter file will contain the line number and error message for each error in the input stream. Figure 12.4 on the following page shows the result of the subsequent W X run.
> makeindex main This is makeindex, portable version 2.12 [26-May-19931. Scanning input file main.idx ....done (8 entries accepted, 0 rejected). Sorting entries ....done (24 comparisons). Generating output file main.ind....done (19 lines written, 0 warnings). Output written in main.ind. Transcript written in main.ilg.

12.3 Running the Makelndex Program


In the previous section we showed examples where we ran the Makelndex program using its default settings. In this section we shall first take a closer look at the Makelndex program, and then discuss ways of changing its behavior.

\documentclassCarticle~ \usepackage{makeidx,showidx) \newcommand~\bs)C\symbolC'134))% print backslash \newcommandC\Com)[1]~\textttC\bs#l~% \indexC#l@\textttC\bs#l))) \newcommandC\Prog) [ I ] C\textttC#l)% \indexC#IQ\texttt{#l) p r o g r a m ) ) \beginCdocument> \sectionCGenerating an Index) Using the \textsfCshowidx) package users can see where they define index entries. \par Entries are entered into the index by the \ComCindexl command. More precisely, the argument command is written literally into of the \Com(index) Note, however, that the auxiliary file \texttt{idx). information is actually only written into that file when the \ComCmakeindex) command was given in the document preamble. \sectionCPreparing the Index) In order to prepare the index for printing, the \textttCidx) file has to be transformed by an external program, like \ProgCmakeindex). This program writes the \textttCind) file. \beginCverbatimcmd) makeindex filename \endCverbatimcmd) \sectionCPrinting the Index) \indexCFinal production run) During the final production run of a document the index can be included by putting a \ComCprintindexl command at the position in the text where you want the index to appear (normally at the end). This command will input the \textttCind> file prepared by \Prog{makeindex) and \LaTeXC) will typeset the information. \printindex \endCdocument)

1 Generating an Index

Using t h eshowidx package u s e r sc a ns e ewheret h e yd e f i n e i n d e xe n t r i e s . E n t r i e sa r ee n t e r e di n t ot h ei n d e xb yt h e \indexcommand.More p r e c i s e l y ,t h e argumento ft h e \indexcommand is w r i t t e nl i t e r a l l yi n t ot h ea u x i l i a r yf i l e idx.Note, however.t h a ti n f o r m a t i o ni sa c t u a l l yo n l yw r i t t e ni n t ot h a t run f i l e when t h e \makeindex command was g i v e ni nt h e printindex@\printindex document preamble. makeindex@makeindex p r o g r a m

i n d e x @ \ index i n d e x @ \ index m a k e i n d e x @ \makeindex makeindex@rnakeindex I .n c l u d ei n d e x Final p r d u c t i o n

2 Preparing the Index


I no r d e rt o p r e p a r et h ei n d e xf o rp r i n t i n g ,t h e idx f i l e h a st o b et r a n s f o r m e db ya ne x t e r n a l program, l i k emakeindex. T h i s program w r i t e st h e ind f i l e . makeindex filename

3 Printing the Index


During t h ef i n a lp r o d u c t i o nr u no f a document t h ei n d e x c a n be i n c l u d e db yp u t t i n g a \printindexcommand a t t h ep o s i t i o ni nt h et e x t where you want t h ei n d e xt oa p p e a r ( n o r m a l l ya tt h ee n d ) . T h i s command w i l li n p u tt h e ind f i l ep r e p a r e db y makeindex a n dL T jw i l lt y p e s e tt h e i n f o r m a t i o n .

Index Entries
F i n a lp r o d u c t i o n run,1 i n c l u d ei n d e x ,1 \index, 1
1

\makeindex, 1 makeindex program,


1

\printindex.1

Figure 12.3: Example of \index commands and the showidx package. T h s file is run t h r o u g h w x once, then the Makelndex program is executed and W&X is run a second time.

Figure 12.4: This figure shows the index generated by the example input of figure 12.3. All index entries are shown in the margin, so that it is easy to check for errors or duplications.

12.3 Running the Makelndex Program

355

12.3.1 Detailed Options of the Makelndex Program


The syntax of the options of the Makelndex program are described below:
makeindex [-ciglqr] -c
[-o

ind] [-p no] [-s sty] [-t log] [idxO idxl

. . .I

This will enable blank compression. By default, every blank counts in the index key. The -c option ignores leading and trailing blanks and tabs and compresses intermediate ones to a single space. -i Use standard input ( s t d i n ) as the input file. When this option is specified and -0 is not, output is written to standard output ( s t d o u t , the default output stream). Employ German word ordering in the index, following the rules given -g in German standard DIN 5007. In this case the normal precedence rule of Makelndex for word ordering (symbols, numbers, uppercase letters, lowercase letters) is replaced by the German word ordering (symbols, lowercase letters, uppercase letters, numbers). Additionally, this option enables Makelndex to recognize the German TEX commands "a, "0, "u and " s (see section 9.2.2), as ae, oe, ue and ss for sorting purposes. The quote character must be redefined in a style file (see page 360); otherwise you will get an error message and Makelndex will abort. Note that not all versions of Makelndex recognize this option. -1 Use letter ordering. Default is word ordering. In word ordering, a space comes before any letter in the alphabet. In letter ordering, spaces are ignored. For example, the index terms "point in space" and "pointing" will be alphabetized differently in letter and word ordering. This is quiet mode. No messages are sent to the error output stream -q (stderr). B y default, progress and error messages are sent to s t d e r r as well as the transcript file. The - q option disables the s t d e r r messages. -r This option disables implicit page range formation. B y default, three or more successive pages are automatically abbreviated as a range (e.g., 1-5). The -r option disables it, making explicit range operators the only way to create page ranges. -0 i n d Take .i n d as the output index file. B y default, the file name base of the first input file idxO concatenated with the extension .i n d is used as the output file name. -p no Set the starting page number of the output index file to be no. This is useful when the index file is to be formatted separately. Other than pure numbers, three special cases are allowed for no: any, odd, and even. In these special cases, the starting page number is determined by retrieving the last page number from the . l o g file of the last K&X run. The . l o g file name is determined by concatenating the file name base of the first raw index file (idxO) with the extension .log. The last source page is obtained by searching backward in the log file for the first instance of a number included in square brackets. If a page number is

356

Index Generation
missing or the log file is not found, no attempt will be made to set the starting page number. The meaning of each of these cases follows. any The starting page is the last source page number plus one. odd The starting page is the first odd page following the last source page number. even The starting page is the first even page following the last source page number. -s sty Take sty as the style file. There is no default for the style file name. The environment variable INDEXSTYLE defines where the style file resides. -t log Take .log as the transcript file. B y default, the file name base of the first input file idxO concatenated with the extension .ilg is used as the transcript file name.

12.3.2 Error Messages


Makelndex types out on the terminal the number of lines read and written and how many errors were found. Messages that identify the error are written in the transcript file which, by default, has the extension ilg. Makelndex can produce error messages when it is reading the .idx file or when it is writing the .ind file. Each error message contains the nature of the error and the number of the line where the error occurs in the file. In the reading phase, the line number refers to the .idx file.

Errors in the Reading Phase


Extra ' ! ' at position ... The \index command's argument has more than two unquoted ! characters.

Perhaps some of them should be quoted.


Extra @ at position . . . The \index command argument has two or more unquoted @ characters with no intervening !. Perhaps one of the @ characters should be quoted. Extra ' 1 ' at position ... The \index command's argument has more than one unquoted I character.

Perhaps the extras should be quoted.


Illegal null field The \index command argument does not make sense because some string is null that shouldn't be. The command \index{ ! funny) will produce

this error, since it specifies a subentry "funny" with no entry. Similarly, the command \index{@f unny) is incorrect because it specifies a null string for alphabetizing.

12.4 Customizing the Index


Argument

357

... too

long (max 1024)

The document contained an \index command with a very long argument. You probably forgot the right brace that should delimit the argument.

Other errors

Makelndex can produce a variety of other error messages indicating that something is seriously wrong with the . i d x file. If you get such an error, it probably means that the .idx file was corrupted in some way. If U Q X did not generate any errors when it created the .i d x file, then it is highly unlikely to have produced a bad .i d x file. If it did, you should examine the .i d x file to establish what went wrong.

Errors in the Writing Phase


Unmatched range opening o p e r a t o r An \index. . I 0 command has no matchmg \index{. . . I 1) command following it. The ". . ." in the two commands must be completely identical.

Unmatched range c l o s i n g o p e r a t o r An \index{. . . I)) command has no matching \index{.

. . I 0 command

preceding it.
E x t r a range opening o p e r a t o r Two \index. . . I 0 commands appear in the document with no intervening command \index{. . . I 1). I n c o n s i s t e n t page encapsulator

...

w i t h i n range

Makelndex has been instructed to include a page range for an entry and a single page number within that range that is formatted differently-for example, by having an \index{cat I i v ) command between an \index{cat I 0 and an \index{cat I > ) command.
Conflicting e n t r i e s

Makelndex thinks it has been instructed to print the same page number twice in two different ways-e.g., by the command sequences \index{lion I see{. . .)I and \indexClion) appearing on the same page.

12.4 Customizing the Index


Makelndex ensures that the formats of the input and output files do not have to be fixed, but they can be adapted to the needs of a specific application. To achieve t h s format independence, the Makelndex program is driven by a style file, usually characterized with a filetype . ist (see also figure 12.1 on page 346). This file consists of a series of keyword/value pairs. These keywords can be

358
keyword default value

Index Generation

description keyword (s) "\\indexentry" command telling Makelndex that its argument is an index entrv argument opening delimiter 'C' arg-open ( c ) arg-close ( c ) argument closing delimiter '>' range-open ( c ) opening delimiter indicating beginning of explicit page range ' (' range-close ( c ) closing delimiter indicating end of explicit page range '1' 1 ! level (c) delimiter denoting new level of subitem actual ( c ) 'a' symbol indicating that the next entry is to appear in the actual index file encap ( c ) 'I' symbol indicating that rest of argument list is to be used as I I enca~sulating - command for the -age - number J quote ( c ) quote symbol escape ( c ) '\\' symbol which escapes the next letter, unless its preceding letter is escape, i.e., quote is used to escape the letter which immediately follows it. But if it is preceded by escape, it does not escape anything. The two symbols quote and escape must be distinct. page-compositor (s) I I# composite page delimiter (s) signals an attribute of type string, ( c ) of type char
J

It j

I)

I I

Table 12.1: Input style parameters for MakeIndex divided into input and output style parameters. Table 12.1 describes the various keywords and their default values for the programming of the input file. It is in this table that you can find, for instance, how to modify the index level separator (level, with ! as default character value). On the other hand, table 12.2 on the next page describes the keywords and the defaults for steering the translation of the input information into L A T E X commands. So here you will find how to define the way the various levels are formatted (using the item series of keywords). Examples will show in more detail how these various input and output keywords can be used in practice.

12.4.1 Example of Index Style Files


In the following sections we show how, by just making a few changes to the values of the default settings of the parameters controlling the index, you can customize the index.

12.4.2 A Stand-AloneIndex
The example style mybook. ist (shown below) defines a stand-alone index for a book, where stand-alone means that it can be formatted independent of the main source. This can be useful if the input text of the book is frozen (the page

xapula4ory roJ sJalarupJed al,ts tndlno :Z'ZI alqpJ .raqEnu go(u) '8urr1s ad,,b yo atnqrrltB adzb ue spu8rs(s) :qE]Epue auq.\{au e are,,1\,,pue ,,u\,,
9I
,,1\1\,,

ZL

(u) q18ue1-luepur (s) ards-tuapur (u) xeu-aur1

,,vPUtr,,

(s) acuapora:d-a8ed
(S) xrJlns-derua 1s; xt;ut-decue (s) xt;ard-derua

,, {,, ,,],,

(s J-rrrTTap

sauq padde.r.tr roJ uorletuapul go qf8ual sauq padder.nJoJspueufiuoJuor]pluapu auq lndlno ue go qfual ruilrrDruru Emddu.w. au.r1 ueruor aserraddn pue -JaMolU puE r :Juaurnu u :rpaqeqdF aserraddn '-ramol arc V ' :aruapara,rd ,raqtunu aEed eruaparald aEe4 rotelnsderuaaEede ro; pasn aq ot 4[ns .rolelnsderuaa8ed e ,ro; pesn aq ol xgu-r .rolelnsderuaaEede ;o tuorJ ur pasn aq ol xgard s.rolulnsderuaaEed a8uer aEede ,roJ,roteuErsap sJaqrunua8ed lua,ragp ueemlaqJatlurlap z Ia^al]e ollp
I p^al te olllp

(s

u-uTTap

0 Ia^aI lp ratrurlep raqunu aEBd-fulua s.rarluqlap aEe4


Arlua z IeAeI JoI oltlp
il ualrqnsqns\\

(s z-uTTap (s I - U T T A P (s 0-uTTap
(s) 7x-ue1t (s) Ix-uotr

u\,,

(s) Zl-uarr (s) Io-uo+r


(s) Z-ualr (s) T-ua+t

sraqrunu a8ed ou seq IaAaIlua.reduaq,r,r fu1ua 1 Ialal Jo luorJ uI patrasur aq ot pueuluoJ ua+rqns\\ u\r, fu]ua Z la^alror ot]Ip I Ia^a[]e Su]t.rets ,r ura+rqnsqns\\ tr\,, pueuluoJ fugua ualrqns\\ u\,, aro.Ieq 0 Ia^aI ]E 8u-rt.rels 1 Ia^aI fttua Z Ia^aI roJ ope Z < p^al te Surt.rels ,, ura+rqnsqns\\ tr\,, I < Ia^al le Sulrels drtua 1 Ia^aI roJ o]tlp ,, lra+rqns\\ u\,, Nlua 0 la^al Jo luorJ ur pauasu aq ol puErrrruoJ ,, ura+r\\u\,, s.role,rBdas rhlul

(s) o-ua+t

xt;;ns-Surpeeq Sutpuadde pue x1;a:d-Sutpeeq qll,tr paxgerd 'dnorE ,rattal Meu aql Surzr.ralre.reqr 1oqul{s aqr Jo aJuelsw (asEJJaMoDaser,raddn uE sepnl)ur (0>) O<8et; anle^ E isdno.r8 ra11al lueraJJfp aql uaamlaq Eu.nlgou suasrn g=8e1y anlel V

0
Itl

dnor8 ratlal lrau Jo SurpeaqroJ 4Hns


dnor6 rallal Mau Jo Eupeaqlot xua,rd

(u) 8e1;-s8urpeeq (s) xrJlns-SurpPoq (s) xlya:d-8urpaq (s) dpls-dnorE (s) xrJlns-aBedles
(s) xlya:d-aBedlas

dnorE .traualoJaqpauasur areds IeJItraA ,,u\osECtsxapuT \ \u\u\,, raual/dnor8 ^{aN aSedaql Equas pueuruo) aq] roJ x,rJJns ,,tr\{,, e8pd aq] Euelas puerrrruoJaqt .ro; xgard ,,)leSedlrelunortas\\u\,, oEEdEuIrrErS xaptn aqt SurmollorpueutuoJ alqurelsod ,,u\{xapuTaq+}pue\\u\u\,, xaptn aql Sulparard pueuluo) alqureard ,,u\{xopuroqt}urbaq\\,, xaluoJ uolldu)sap
anle^ l[neJap

(s) alqurexsod (s) alqueard ptoula4

6S

xepul aql Eulzr-uro1sn3 V'Zl

360

Index Generation numbers will no longer change), and you only want to reformat the index.
% MakeIndex style file mybook.ist preamble "\\documentclass[lapt] {book) \\begin{document) \\begin{theindex)\n" post amble "\n\n\\end{theindex) \\endCdocument)\nol

Assuming that the raw index commands are in the file mybook. idx then you can call Makelndex specifying the style file's name:
makeindex
- s mybook.ist -0 mybookind.tex mybook

The reason for using a non-default output file name is to avoid clobbering the source output (presumably mybook. dvi) because if the index is in file mybook. ind, its typeset output will also be in mybook. dvi, thus overwriting the original .dvi file. If, moreover, you want the page numbers for the index to come out right, then you can also specify the page number where the index has to start (e.g., 181 in the example below).
makeindex -s mybook.ist -0 mybookind.tex -p 181 mybook

Makelndex can also read the LATEX log file mybook. log to find the page number to be used for the index (see the -p option described on page 355).

12.4.3 Changing the "Special Characters"


The next example shows how you can change the interpretation of special characters in the input file. To do t h s , you must specify the new special characters in a style file (for instance, myinchar. ist shown below.) Using table 12.1 on page 358, in the following example we change the Q character (see page 349) to =, the sublevel indicator ! (see page 348) to >, and the quotation character " (see page 350) to ! (the default sublevel indicator).
% MakeIndex style file myinchar.ist actual '=' % = instead of default O
quote I ! ' level '> ' % ! % >
I@

In the example of figure 12.5 on the next page, which should be used in conjunction with the german option of the babel package, the double quote character (") is used as a shortcut for the umlaut construct \". This shows

12.4 Customizing the Index

361

" sign, 1
= sign, 2

Q sign, 2 Briicke, 5 Briicke, V Briicke, v dimensions rule

width, 3 exclamation (!), 4 Ah!, 5 Madchen, c Madchen, 3

Page 1: Page 2: Page 2: Page 3: Page c: Pagev: Page 5: Page V: Page 3: Page4: Page 5:

\indexC\te~ttt(~~) sign) \index{\texttt{Q) sign) \index{\texttt{!=) sign) \index{Maedchen=M\I1{a)dchen) \index{Maedchen=M1'adchen) \index{Bruecke=Br"ucke) \index{BrWucke) \index{Br\Igucke) \index{dimensions>rule>width) \index{exclamation ( ! !)) \index{exclamation ( ! !)>Ah!!)

Figure 12.5: Example of the use of special characters with MakeIndex another feature of the ordering of MakeIndex, namely, the constructs " and \ " are considered as different entries (BrUuckeand Br\I1ucke, M1Iadchenand M\I1adchen, although in the latter case the key entry was identical, i.e., Maedchen). Therefore, it is important to use the same input convention throughout a complete document.

12.4.4 Changing the Output Format of the Index


You can also personalize the output format of the index. The first thing that we could try is to build an index with a nice big letter between each letter group. This is acheved with the style myhead. i s t shown below (see table 12.2 on page 359 for more details) and gives the result shown in figure 12.6 on the next page.
% MakeIndex style file myhead.ist heading-prefix "{\\bfseries\\hfil ' I % Insert in front of letter heading-suffix "\\hfil)\\nopagebreak\n" % Append after letter 1 % Turn on headings (uppercase) headings-flag

You could go a bit further and right-adjust the page numbers, putting in dots between the entry and the page number to guide the eye, as shown in figure 12.7 on the following page. This can be achieved by adding the following commands.
% MakeIndex style file myright.ist
delim-0 delim-1 delim-2 "\\dotfill "\\dotf ill "\\dotfill

" "

The P Q X command \dotf ill can be replaced by fancier commands, but the principle remains the same.

362

Index Generation

Symbols 0 sign, 2

B
box, 2 1 dimensions of, 3 3 parameters, 5
D

Page 2: Page 3: Page 5: Page 9: Page 12: Page 17: Page 21: Page 33: Page 41: Page 48:

dimensions figure, 17 rule height, 12 width, 3 table, 9 F fonts Computer Modern, 2 1 Postscript, 5

{\texttt{"Q) sign) {dimensions!rule!width) {box !parameters) {fonts!PostScript) {dimensions!table) {dimensions!rule!height) {dimensions!figure) {box? {fonts!Computer Modern) Cbox!dimensions of) Crule!depth) Crule!width) {rule!depth)

R
rule depth, 3 3 , 4 8 width, 4 1

Figure 12.6: Example of how you can customize the output format of an index

Q sign ...................2 box ....................21 dimensions of .... 3 3 parameters ........ 5 dimensions figure ............. 1 7 rule height ..........12 width ............ 3 table ............... 9 fonts Computer Modern 21 Postscript ......... . 5 rule depth ......... 3 3 , 4 8 width ............ . 4 1

Page 2: Page 3: Page 5: Page 9: Page 12: Page 17: Page 2 1: Page 33: Page 41: Page 48:

{\texttt{"Q) sign) {dimensions!rule!width) {box !parameters) (fonts!PostScript) {dimensions!table) {dimensions!rule!height) Cdimensions!figure) {box? {fonts!Computer Modern) {box!dimensions of) Crule!depth) {rule!width) {rule!depth)

Figure 12.7: Adding leaders to an index

12.4 Customizing the Index

363

12.4.5 Treating Funny Page Numbers


As described earlier, Makelndex accepts five basic lunds of page numbers: digits, upper- and lowercase alphabetic, and upper- and lowercase roman numerals. You can also build composed page numbers. The separator character for composed page numbers is controlled by the MakeIndex keyword page-compositor (the default is the hyphen character (-); see table 12.1 on page 358), while the precedence of ordering the various kinds of page numbers is given by the keyword page-precedence (the default is rRnaA; see table 12.2 on page 359). Let us start with simple page numbers and assume the pages with numbers ii, iv, I, 2, 5, a, c, A, C, 11, and IV contain an \index command with the word style. This would be typeset in the index as shown below.

In this example, you can see that the c and C entries were considered as roman numerals, rather than alphabetic numbers. This order can be changed using the page-precedence keyword, as shown in the style file mypages. ist.
% MakeIndex style file mypages.ist page-precedence "rnaRA"

The result of running Makelndex on the same index entries yields:

The next step you can take is to use composed page numbers in your document. The default input separator is the hyphen. Suppose you have a reference to the word style on the following (unsorted) series of pages: C-3, 1-1,D-1-1, B-7, F-3-5,2-2,D-2-3,A-I,B-5 and A-2. After running MakeIndex, the following sorted output is obtained: style, 1-1,2-2, A-1, A-2, B-5, B-7, C-3, D-1-1, D-2-3,F-3-5 The separator can be changed to, for example, a dot, by using the page-compositor keyword, shown in the style B e mypagsep. ist.
% MakeIndex style file mypagsep.ist page-compositor " .

The result of running Makelndex on the same index entries with the "-" replaced by " ." yields: style, 1.1, 2.2,A.l,A.Z, B.5, B.7, C.3,D.l.l,D.2.3,F.3.5

364

Index Generation

12.4.6 Glossary Entries

(L79)

W X also has a \glossary command for malung a glossary. The \makeglossary

command produces a file with extension .glo, which is similar to the .idx file for the \index commands. L A T E X transforms the \glossary commands into \glossaryentry entries, just as it translates \index commands into \indexentry entries. MakeIndex can also treat these glossary commands, but you must change the value for some of the style file keywords, as shown in the style file
myglossary.ist.
% MakeIndex style file myglossary .ist keyword "\\glossaryentryN preamble "\n \\begin{theglossary}\nt' postamble "\n\n \\end{theglossary)\nl'

% keyword for glossary entry % Begin glossary entries % End glossary entries

In addition you might have to define a suitable theglossary environment.

12.5 Modifying the Layout


( L 77)

You can redefine the environment theindex,which by default is used to print the index. The layout of the theindex environment and the definition of the \item, \subitem, and \subsubitem commands are defined in the class files article, book, and report. In the book class you can find the following definitions:

You can make an index in three rather than two columns. To do this, you can use the mu lticol package and the mult icols environment.
\renewenvironment{theindex){\newpage \addcontentsline{toc)Cchapter~{Index Entries)% \pagestyle~plain)\let\item\Qidxitem \begin{multicols}{3~C{\Large\bfseries Index Entries}]

12.5 Modifying the Layout

365
definition of \beginCtheindex) definition of \endCtheindex)

\par\bigskip)% ~\end~multicols))%

First, a new page is started before the index is entered as a chapter heading into the table of contents file .toc and the page style is changed to plain. Then the \item command is redefined to cope with index entries (see above), and the entries themselves are typeset in three columns using the multicols environment.

12.5.1 Multiple Indexes


A multind package (by F.W. Long) redefines the \makeindex, \index and \printindex commands to allow multiple indexes. It achieves this by using the filename of the index as supplementary argument.

The first time the file shown in figure 12.8 on the next page is run through LATEX it generates the files A. idx and B.idx. These files have to be transformed into their respective .ind files by running both .idx files through Makelndex.
> makeindex A This is makeindex, portable version 2.12 r26-May-19931. Scanning input file A.idx ....done (5 entries accepted, 0 rejected). Sorting entries .... done (12 comparisons). Generating output file A.ind ....done (18 lines written, 0 warnings). Output written in A.ind. Transcript written in A.ilg. > makeindex B This is makeindex, portable version 2.12 [26-May-19931. Scanning input file B.idx ....done (5 entries accepted, 0 rejected). Sorting entries ....done (14 comparisons). Generating output file B.ind ....done (21 lines written, 0 warnings). Output written in B.ind. Transcript written in B.ilg .

After one more run through IPQX you will obtain the output shown in figure 12.9 on the following page. In that example we have used a redefined theindex environment similar to the one shown in section 12.5 to produce three columns instead of the standard two. The title for the indexes is generated by the second argument of the redefined \printindex command.

\documentclass[12pt]Carticle) \usepackageCmultind) \renewcommand[21C\printindex)C% Redefine \printindex \beginCcenter)textbfC\large#2)\end(center) \inputC#l.ind)) \makeindexCA) \makeindexCB> \beginCdocument) \sectionCGenerating more than one Index)

1 Generating more than one Index


Using the package multind users can enter information in more than one index. The commands \makeindex and \index have been modified to allow multiple indexes. In both cases the first parameter is the index name.

Using the package \textsfCmultind) \indexCB)Cmultind package)% users can enter information in more than one index. The commands \Com(makeindex) and \ComCindex) have been modified to allow multiple indexes. In both cases the first parameter is the index name. \indexCB)Cindex name) \sectionCNew printindex command) When you want to include the index in the document, you should run the \ProgCmakeindex) program on each file. \ i n d e x ( B ) C O n e more to B ) \beginCverbatimcmd} makeindex A makeindex B \end(verbatimcmd)
A modified \ComCprintindex) command lets you print

2 New printindex command


When you want to include the index in the document, you should run the makeindex program on each file.

makeindex A makeindex B
A modified \printindex command lets you print multiple indexes. The first parameter is the index name, the second parameter is the index title (as printed). Some more text. The final text .

Commands and programs


Final to index A, 1

\makeindex,l makeindex (program), 1 \printindex,l

\index,1
multiple indexes. The first parameter is the index name, the second parameter is the index title (as printed). ) . Some more text\indexCB)Centry index B The final text \indexCA)CFinal to index A)\indexCB)CFinal to index . ) B \printindexCA)CCommands and programs) \printindexCB>COther stuff)

Other stuff
entry index B, 1 Final to index B, 1 index name, 1 One more to B, I multind package, I

Figure 12.8: Example input file for multiple indexes

Figure 12.9: Output file showing multiple indexes

12.5 Modifying the Layout

367

12.5.2 A Reimplementation of the Index Commands


The index package (by David Jones) augments the possibilities of LATEX'Sindexing mechanism in several areas:
1. Multiple indexes are supported. 2. A two-stage process is used for creating the raw index files (such as the default .idx file) similar to that used to create the .toc file. First the index entries are written to the .aux file, and then they are copied to the . idx frle at the end of the run.In this way, if you have a large document consisting of several included files (using the \include command), you no longer lose the index if you format only part of the document with \includeonly.

3. A *variant of the \index command is introduced. In addition to entering its argument in the index, it also typesets it in the running text.
4. To simplify typing, the \shortindexingon command activates a short-

hand notation. Now you can type -Cfoo3 for \indexCfoo) and -Cfoo3 for \index*Cfoo). These shorthand notations are turned off with a \shortindexingof f command. Because the underscore and hat characters have a special meaning inside math mode, this shorthand notation is unavailable there.
5. This package includes the functionality of the showidx package. The command \proof modetrue enables the printing of index entries in the margins. You can customize the size and style of the font used in the margin with the \indexproof s t y l e command, whch takes a font definition as argument, e.g.,\renewcommandC\indexproofstyle~C\footnotesize\itshape3.

You declare new indexes with the \newindex command, while the \renewindex command is used to redefine existing indexes.

The first argument, tag, is a short identifier used to refer to the index. In particular the commands \index and \printindex are redefined to take an optional argument, namely the tag of the index you are referring to. If this optional argument is absent, the index with the tag "default" is used, which corresponds to the usual index. The second argument, raw-ext, is the extension of the raw index file where W X should write the unprocessed entries for this index (for the default index t h s is .idx). The tlwrd argument, proc-ext, is the extension of the index file where L A T E X expects to find the processed index (for the default index t h s is .ind). The fourth argument, indexname, is the title that L A T E Xwill print at the beginning of the index.

368

Index Generation

\documentclass~book) \usepackage{index) \makeindex \newindex(aut){adx3~and>{Name Index) \newindex{not){ndx){nnd){List of Notation) \shortindexingon \proofmodetrue \newcommand{\aindex) [ I ] {\index* [aut] {#l)) \begin{document) \tableofcontents \newpage \chapter{Here is a ^ [aut] {chapter) title) \section{Section header\index[aut]{section)) \par Here is some text.\index{subject) \par Here is \index [not] {notation)some more\index[notl (sin@$\sin$) text. { m o r e ) -[not]{notation) text. \par Here is some " \par Here is yet more \aindexCtext). \sectionCAnother Section header [ a u t ] { s e c t i o n Z ) ) \par And here is some math: $x-1-b$. \par Here is an " [aut] {index) entry \fbox{inside an \index [not] {min@$\min$)fbox) \par \fbox{Here is an [ a u t ] { e n t r y ) in a box.) \printindex [not] \printindex [aut] \printindex \end{document)

Figure 12.10: Multiple indexes-input file

The commands for building the multiple indexes for the input file of figure 12.10 are shown in figure 12.11 on the facing page together with the generated transcript. It is seen that Makelndex was run on each of the separate raw index files, i.e., the standard one, then on adx, which yields the and file, X is executed and finally on ndx, whch is transformed into the nnd file. Then W again and it reads these files in the order defined by the \printindex commands in the input file (figure 12.10). The result of the complete run is displayed in figure 12.12 on page 370.

> latex multindexa.tex This is TeX, C Version 3.141 (multindexa.tex LaTeX Version 2.09 <25 March 1992> (/usr/local/lib/tex/macros/book.sty Standard Document Style 'book' (14 Jan 92>. (/usr/local/lib/tex/macros/bkl0.sty)) (index.sty Style-Option: 'index' v3.01 (19 July 1993> (dmj)) index.sty> Writing index file multindexa.idx index.sty> Writing index file multindexa.adx index.sty> Writing index file multindexa.ndx No file mu1tindexa.a~~. No file multindexa.toc. C i l C 2 l Chapter 1. No file multindexa.nnd. No file multindexa.and. No file multindexa.ind. [ 3 1 (mult indexa.aux) ) Output written on multindexa.dvi (3 pages, 1556 bytes). Transcript written on multindexa.log. > makeindex multindexa This is makeindex, portable version 2.12 C26-May-19931. Scanning input file multindexa.idx....done (2 entries accepted, 0 rejected). Sorting entries....done (2 comparisons). Generating output file multindexa.ind....done (9 lines written. 0 warnings). Output written in multindexa.ind. Transcript written in multindexa.ilg. > makeindex -0 multindexa.and multindexa.a& This is makeindex, portable version 2.12 [26-May-19931. Scanning input file mu1tindexa.a&....done (6 entries accepted, 0 rejected).

Sorting entries....done (20 comparisons). Generating output file multindexa .and....done (22 lines written, 0 warnings). Output written in multindexa.and. Transcript written in multindexa.ilg. > makeindex -0 multindexa.nnd multindexa.ndx This is makeindex, portable version 2.12 C26-May-19931. Scanning input file mu1tindexa.n&....done ( 4 entries accepted, 0 rejected). Sorting entries....done (9 comparisons). Generating output file multindexa .nnd....done (13 lines written, 0 warnings). Output written in multindexa.nnd. Transcript written in multindexa.ilg. > latex multindexa This is TeX, C Version 3.141 (multindexa.tex LaTeX Version 2.09 (25 March 1992> (/usr/local/lib/tex/macros/book.sty Standard Document Style 'bookJ (14 Jan 92>. (/usr/local/lib/tex/macros/bkl0.sty)) (index.sty Style-Option: 'index' v3.01 (19 July 1993> ( d m j ) ) index.sty> Writing index file multindexa.idx index.sty> Writing index file multindexa.adx index.sty> Writing index file multindexa.ndx (multindexa.aux) (multindexa.toc) C11 C21 Chapter 1. 3 1 [ 4 ]) (multindexa.and [ 5 ]) (multindexa.nnd [ (multindexa.ind [ 6 ] ) (mu1tindexa.a~~) ) Output written on multindexa.dvi (6 pages, 2776 bytes). Transcript written on multindexa.log.

Figure 12.11:Multiple indexes-running k?&X and Makelndex

Index Generation

.9

o c

.
! .

* I

i
l E

? c

; : t E

-F
P W

L O

c! (t .=

-g ss! : .EE! .9'.2!E

tt.

O *.

;EEE EeI! -.:3 -:t

E E l i i i ' l :

? I

| ; E -;?t

tgl

X ()
E 1

eE,.= ella eElE

ah

X
d

(D

-q
t

ii g EE "' ! v 9 c

N
L

llr

. 6

r ' :
I' ! F ! v E.E: ! i ; Z Z 4 s : = . H ;

t '

t t

" ) .

: E

1 E 9 ;

i ;

O r \

-E=*

C H A P T E R

13

Bibliography Generation

While a table of contents (see section 2.4) and an index (discussed in chapter 12) make it easier to navigate through a book, the presence of bibliographic references should allow you to probe further subjects you consider interesting. To make t h s possible, the references should be precise and lead to the relevant work with a minimum of effort. There exist many ways for formatting bibliographies, and different fields of scholarly activities have developed very precise rules in this area. An interesting overview can be found in the chapter on bibliographes in The Chicago Manual of Style 1861. Normally, authors must follow the rules laid out by their publisher. Therefore, one of the more important tasks when submitting a book or an article for publication is to generate the bibliographic reference list accordmg to those rules. Traditional ways of composing such lists by hand, without the systematic help of computers, are plagued with the following problems: Citations, particularly in a document with contributions from many authors, are hard to make consistent. Difficulties arise, such as variations in the use of full forenames versus abbreviations (with or without periods), italicization or quoting of titles, spelling "ed.," "Ed.," or "Editor," and the various forms of journal volume number.
a

A bibliography laid out in one style (e.g., alphabetic by author and year) is ex-

tremely hard to convert to another (e.g., numeric citation order) if requested by a publisher.

3 72

Bibliography Generation

It is difficult to maintain one large data base of bibliographic references that can be reused in different documents. This chapter describes one solution to the bibliography problem. It is based on H@X and its companion program BETEX,written by Oren Patashnik. Over the years several dozen BETEXbibliography styles (see table 13.1 on page 3 7 7 ) have been developed, so it should not be too difficult to find or adapt a style that suits the demands of a particular publisher. The first section describes how to include citations in the text. This is followed by an overview of how L A T E X and BIBTEX work together, and a discussion of several BETEXstyles. With the help of an example, which uses in each case an identical input file and BETEX data base, it is shown how easy it is to change the appearance of the citations in the text, as well as the bibliographic references themselves. The next sections provide an updated and augmented version of appendix B in the L A T E X book, which details how to construct a BETEX data base. The final sections describe the format of BETEX'Sstyle files, giving a short overview of the commands and intrinsic functions available in them. Then the global structure of the generic style documentation file btxbst .doc will be explained. From that knowledge we will show you how to adapt an existing style file to the needs of a particular house style or foreign language.

(L140-47)

13.1 Entering the Citations


(1 73-74)

Bibliographc citations inside the text of a W&X document are flagged with the command

I \cite Ctextl cite-key-list) I


The \cite command associates the list of comma separated keywords in the cite-key-list parameter with the arguments of \bibitem commands inside a thebibliography environment, and it writes the keys into the .aux file. As with other W Q X identifiers, these keys are case-sensitive. The optional parameter text is an additional note, which will be printed together with the text generated by the \cite command. When BIBTEX is not used, the citation numbers are defined by the order in which the keys appear on the \bibitem commands inside the thebibliography environment.
\beginCthebibliography)Cwidest-entry1 \bibitem [labelll {cite-key11 bibliographic information \bibitem [label21 {cite-key21 bibliographic information

13.1 Entering the Citations

373

As stated above, the association between a \cite command and one or more bibliography entries is made via the cite-key-list argument. The citation text, which will actually appear in the typeset text, depends on the chosen bibliographic style. With BBTEX(see below) you can use a variant of the \cite command:

(L74)

This command produces no text, but writes its argument list cite-key-list in the .aux file, so that the associated bibliography information ulll appear in the references. A command \nocite*) includes all entries of a BBTEX data base into the list of references.

13.1.1 Customizing the Citations


The actual formatting of the citation is controlled by the internal L Q X command, \@cite. The definitions of possible forms are (see section A.5 in appendix A for the syntax of \ifthenelse): References enclosed in square brackets (default format),

Exponent-llke references,

To understand t h s code you should know that L A T E X sets the temporary Boolean variable \if Otempswa to the value true if you specify an optional argument on the \cite command. The cite package (by Donald Arseneau) collapses a list of three or more consecutive numbers into a range. For example, [4,5,6,7,9,8,61 is transformed into [4-7,9,8,61. An additional command, \citen, can be used to get the numbers (and write to the .aux file)without the brackets or further formatting. Therefore, "See also ref. "\citen(junk). " gives "See also ref. 9." The citesort package (by Ian Green) goes one step further and sorts the numbers before collapsing them. So the previous example would become [4-91. The overcite package (by Donald Arseneau) works like cite, but displays citations as superscript numbers with a comma and a small space between each number. Lists of three or more consecutive numbers are compressed into a number range, but it does not sort them for optimized compression. When an optional note is given, then the whole list of citations will be typeset as though cite. sty were in effect (see above). The punctuation characters (. , ; :) will be moved in front of the superscript except when the \cite immediately

3 74

Biblioma~hv Generation
follows a quotation, e.g., ' 'Transition State '\cite(Eyring). gives "Transition State."8 Many of the bibliography styles discussed in the next section define supplementary commands to control the form of the citations better. In particular, the chicago package, which implements the recommendations of The Chicago Manual of Style [861, has the list of commands shown below:
\cite(key) \citeACkey) \citeNCkey) \shortcite(key) \shortciteA(key) \shortciteN(key) \citeyearkey)

full author list and year,e.g., (Brown 1978; Jarke, Turner, Stohl, et al. 1985) only the full author list, e.g., (Brown; Jarke, Turner and Stohl) full author list and year, for use in text, e.g., Shneiderman (1978) states that ... abbreviated author list and year abbreviated author list abbreviated author list and year, for use inside text year only, within parentheses /

All these commands have a variant without parentheses (the same name with NP appended), for example, \citeNP. Patrick W. Daly, the author of the makebst program (see section 13.9), has developed the natbib BJBTEX style, which must be used together with the natbib package. It implements various forms of the "author-year" citation format, like the ones seen above, and it can be used as a unique replacement for the apalike, astron, authordate series, harvard, named, and newapa BJBTEX styles, described in table 13.1 on page 377. The punctuation used inside the citations can be customized with the \bibpunct command.

13.1.2 Customizing the Bibliography Labels


(L187)
The thebibliography environment is implemented as a general list. The label of a bibliography item has the following default definition:

(L:160)

Bibliographc styles that use the name of the author(s1 as citation keys, like the apalike and chicago styles, redefine the \@biblabel command as empty, because they construct their own more complex label. The indentation of the entries is controlled by the length \bibhang, which by default is 2em. Different blocks of information, such as the authors or the title, are separated inside one \bibitem in the bibliography by \newblock commands. Normally these groups are typeset together in one paragraph. If, however, you want your bibliography to be "open," i.e., each block starts on a new line with succeeding lines inside a block indented by a length \bibindent (default l.Sem), then the openbib package should be specified.

13.2 using =EX

with L A T E X
tex

375

O Run W X , which generates a list of \ c i t e references in its auxiliary file, .aux. Q Run BIBTEX, which reads the auxiliary file, looks up the references in a data base (one or more . b i b files),and then writes a file (the .bbl file) containing the formatted ref- Q erences according to the format specified in the style.file (the .bst file). Warning and error messages are written to the log file (the .b l g file). It 0 should be noted that BIBTEX never reads the original LATEX source file. O Run W X again, which now reads the .bbl reference file. @ @ Run LATEX a third time, resolving all references.

+I
EQX
bib

aux
C

BIBTEX

bst

tex

1
LATEX
t ex

v
bbl blg

1
LATEX

aux
T

Figure 13.1: Data flow when running BETEX and L A T E X

13.2 Using BIBTEXwith L A T E X


W X implements full cross-referencing, and a special form of this is used for bibliographical citation. The previous section showed how to specify citations in the text with the command \citeCcite-key), where key is the keyword identifying an entry in the bibliography list environment thebibliography. This latter list can be constructed by hand for a small number of references, but it is probably more practical to read the information in a bibliography data base. In this case the same key cite-key should also uniquely identify an entry in that data base, so that the citation reference can be resolved when the document is processed. The procedure for running L A T E X and BETEX is schematically shown in figure 13.1. The precise format of a BETEXentry will be described in detail in section 13.5. In order to follow the &scussion of the examples in the present section more easily, you should nonetheless know that the basic structure of a BETEX entry consists of three parts:
1. an entry type, e.g.: "book,"" a r t i c l e , ""inproceedings,"and "phdthesis"; 2. a user-chosen keyword identifying the publication. If you want to reference

3 76

Bibliography Generation

the entry in your document, then the argument cite-key of the \cite command should be identical (also in case) to this keyword. 3. a series of fields consisting of a field identifier with its data between quotes or curly braces, e.g.: "author,""journal,"and "title." Various schemes exist for conveniently associating bibliography keywords with their entries in a data base. A popular one is the so-called Harvard system, where you take the author's surname (converted to lowercase) and the year of publication, and combine them using a colon. For example, smith: 1987. Other possibilities for labeling bibliography entries are seen in figure 13.4 on page 381, whch shows an example BETEX data base. BETEX entries are read by BETEX in the bibliography data base (the .bib file), and the formatting of the entries is controlled by an associated bibliography style (the .bst file),which contains a set of instructions written in a stack-based language. The latter is interpreted by the BIBTEXprogram (see sections 13.7 and following). BETEX has knowledge of what fields are required, optional, and ignored for any given entry type (see table 13.2 on page 408). It will issue warnings like "author name required" if somethng is missing. The style file can control the typesetting of both the citation string in the main text and the actual bibliography entry inside the thebibliography environment. It is important to note that LATEX by itself can still compose a bibliography and cross-references in the text. Without BETEX, you can still produce a bibliography by providing the bibliographc entries yourself. It is also simple to manually edit the output from BJBTEX to cope with extraordinary cases. Moreover, if your document has to be self-contained, then the contents of the .bbl file can be included in the LATEX document (see the aux2bib tool described on page 392).

13.2.1 A List of BIBTEXStyle Files


Various organizations or individuals have developed style files that correspond to the house style of particular journals or editing houses. Nelson Beebe has collected a large number of BIBTEX styles (see table 13.1 on the facing page). For each style he also provides an example file, which allows you to see the effect of using the given sty1e.l Some of the BETEX styles, for instance, authordate(i),jmb, and named, must be used in conjunction with their accompanying LATEX package (as indicated in table 13.1 on the next page), to obtain the desired effect. Note that you can yourself customize a bibliography style, by making small changes to one of those in the table (see section 13.8 for a description of how thls is done), or else generate your own using the makebst program (as explained in section 13.9).
'See appendix B to find out how you can obtain these files from one of the TEX archives.

13.2 Using BIBTEX with L A T E X

377

Table 13.1: Selection of BIBTEX style files

Style name abbrv.bst abstract.bst acm.bst agsm.bst alpha.bst amsalpha.bst amsplain.bst annotate.bst annotation.bst apa.bst apalike.bst apalike.sty apalike2.bst astron.bst authordatei.bst
authordatel -4.sty bbs.bst cbe.bst

cell.bst dcu.bst harvard.sty humanbio.bst humannat.bst ieeetr.bst is-abbrv.bst is-alpha.bst is-plain.bst is-unsrt.bst jmb.bst jmb.sty jtb.bst kluwer.bst named.bst named.sty namunsrt.bst

Description Standard BIBTEX style Modified alpha style with a b s t r a c t keyword Association for Computing Machinery BIBTEX style Australian Government publications BIBTEX style Standard BIBTEX style alpha-like BIBTEX style for A ~ - T E X plain-like BIBTEX style for A+-TEX (numeric labels) Modified alpha BIBTEX style with annote keyword Modified plain BJBTEX style with annote keyword American Psychology Association Variant of apa BIBTEX style L A T E Xpackage for use with apalike.bst Variant of apalike BIBTEX style Astronomy BIBTEX style i=[1,4]. Series of BIBTEXstyles producing author-date reference list. W X package to be used together with authordatei.bst Behavioral and Brain Sciences BIBTEX style Council of Biology Editors BJBTEXstyle (includes such journals as American Naturalist, Evolution, etc.) Small modifications to j mb BETEX style Design Computing Unit (Sidney University) BETEX style L A T E X package for use with Harvard styles (agsm, dcu, kluwer) Human Biology BIBTEX style Human Nature and American Anthropologist journals Transactions of the Institute of Electrical and Electronic style Engineers BIBTEX abbrev BIBTEX style with ISSN and ISBN keyword added alpha BETEX style with ISSN and ISBN keyword added plain BIBTEX style with ISSN and ISBN keyword added unsrt BETEX style with ISSN and ISBN keyword added Journal of Molecular Biology style L A T E X package for use with jmb.bst Journal of Theoretical Biology BIBTEX style Kluwer Academic Publishers BIBTEX style BIBTEX style with [author($, year] type of citation W X package for use with named.bst Named variant of u nsrt BIBTEX style continued on next page

3 78
continued from previous page

Bibliomavhy Generation

Style name nar.bst nar.sty natbib.bst


natbib.sty nature.bst naturesty newapa.bst newapasty phaip.bst phcpc.bst phiaea.bst phjcp.bst phnf.bst phnflet.bst phpf.bst phppcf.bst phreport.bst phrmp.bst plain.bst plainyr.bst siam.bst unsrt.bst

Description Nucleic Acid Research BETEX style W X package for use with nar.bst Generic BETEX style file implementing various "authoryear" reference formats L Q X package for use with natbib.bst Nature BETEX style L A T E Xpackage for use with nature.bst Modification of apali ke.bst U Q X package for use with newapa.bst American Institute of Physics journals BJBTEX style Computer Physics Communications BETEX style Conferences of the International Atomic Energy Agency BETEX style Journal of Computational Physics BIBTEX style Nuclear Fusion BETEX style Nuclear Fusion Letters BETEX style Physics of Fluids BETEX style Physics version of apalike BETEXstyle Internal physics reports BETEX style Reviews of Modern Physics BETEX style Standard BETEX style plain BETEX style with primary sort by year Society of Industrial and Applied Mathematics BETEXstyle Standard BETEX style

13.2.2 Examples of BIBTEXStyles


The examples in t h s section show the effect of using different bibliography styles on identical input and bibliography files. Figure 13.2 on the facing page shows the input file, which contains a sample of most normally occurring reference entry types. This example uses the plain bibliography style and references the BETEX data base bsample. Figu e 13.3 on page 380 shows the whole sequence necessary to produce the final document. First L A T E X was run on this file. Next BETEXwas run on the generated .aux file; the relevant entries were read from the data base, which can be seen in extenso in figure 13.4 on page 38 1. The actual bibliography style in which the data base A T E X is specified entries are to be output to the .bbl file for later treatment by L with the command \bibliographystyle in the source. Then U Q X is run twice more to resolve all references. In this case, using the "standard" BETEXstyle plain and the input file shown in figure 13.2, you would get the output shown on the left of page 382. The five other output examples shown in figures 13.5 to 13.7, starting on the right of

(L74)

13.2 using BIBTEXwith LATEX

3 79

\documentclass~article) \pagestyleCemptyl \begin{document) \section*{Example of Citations of Kind \texttt{plain)) Citation of a normal book"\cite{Eijkhout:1991) and an edited book~\cite~Roth:postscript~. Now we cite an article written by a single-\cite{Felici:1991) and by multiple authors-\cite{Mittelbach/Schoepf:1990). A reference to an article inside proceedings"\citeCYannis:1991). We refer to a manual-\citeCDynatext) and a technical report-\cite{Knuth:WEB). A citation of an unpublished work"\citeCEVH:Office). A reference to a chapter in a book~\cite{Wood:color) and to a PhD thesis-\citeCLiang:1983). An example of multiple citations"\citeCEijkhout:1991,Roth:postscript).
\bibliographystyle{plain) \bibliographyCbsample) \endCdocument)

Figure 13.2: Example of a L A T E X file using BIBTEX page 382, correspond to the three remaining standard BBTEXbibliography styles and two variants and are produced by replacing the plain style in the example document and reprocessing it as explained above. plain unsrt alpha abbrv acm style. Entries sorted alphabeticallywith numeric labels. Standard BIBTEX Standard BBTEX style. Similar to plain, but entries are printed in order of citation, rather than sorted. Numeric labels are used. Standard BIBTEX style. Similar to plain, but the labels of the entries are formed from the author's name and the year of publication. Standard BJBTEX style. Similar to plain, but entries are more compact, since first names, month, and journal names are abbreviated. Alternative BIBTEXstyle, used for the journals of the Association for Computing Machmery. It has the author name (surname and first name) in small caps, and numbers as labels.
( L 74,75)

apalike Alternative BETEX style, used by the journals of the American Psychology Association. It should be used together with the L A T E X apalike package. The bibliography entries are formatted alphabetically, last name first, each entry having a hanging indentation and no label.

380

Bibliography Generation

$ latex bsample X X X X X X X X X X X 1st run of MI$ This is TeX, C Version 3.141 (bsample.tex LaTeX Version 2.09 (06 August 1993> with NFSS2

. 0 . ~ . 0 ~ 0 0 0 ,

(/usr/local/lib/tex/macros/article.sty

Standard Document Style 'article' (14 Jan 92>. (/usr/local/lib/tex/macros/art10.sty)) (bsamp1e.a~~) LaTeX Warning: Citation 'Eijkhout:1991J on page 1 undefined on input line 9. LaTeX Warning: Citation 'Roth:postscript' on page 1 undefined on input line 10. LaTeX Warning: Citation 'Felici:1991' on page 1 undefined on input line 11. LaTeX Warning: Citation 'Mittelbach/Schoepf:1990' on page I undefined on input line 12. LaTeX Warning: Citation 'Yannis:199IJ on page 1 undefined on input line 13. LaTeX Warning: Citation 'Dynatext' on page 1 undefined on input line 14. LaTeX Warning: Citation 'Knuth:WEB' on page 1 undefined on input line 15. LaTeX Warning: Citation 'EVH:Office' on page 1 undefined on input line 16. LaTeX Warning: Citation 'Wood:color' on page 1 undefined on input line 17. LaTeX Warning: Citation 'Liang:1983' on page 1 undefined on input line 18. LaTeX Warning: Citation 'Eijkhout:1991' on page 1 undefined on input line 19. LaTeX Warning: Citation 'Roth:postscript' on page 1 undefined on input line 19 No file bsample.bb1. [ I ] (bsamp1e.a~~) ) Output written on bsample.dvi (I page, 904 bytes). Transcript written on bsample.log.
$ bibtex bsample X X X l . X X X X l . X X BETEX run This is BibTeX, C Version 0.99~ The top-level auxiliary file: bsamp1e.a~~ The style file: plain.bst Database file #I: bsample.bib Warning--empty volume in Wood:color's crossref of Roth:postscript (There was 1 warning) $ latex bsample This is TeX, C Version 3.141 (bsample.tex (bsamp1e.a~~) ...
$ latex bsample
1 . . 1 . 1 . . . . .
1 . . 1 0 1 1 . 1 . .

l.XXl.l.l.XXl.Xl.

2nd run of MI$

.X/./.X/. . * * . Still unresolved citation references


o * e . , o * o * . I

X L L X X X X L X X I , 3rd run of W
Now all citation references are resolved

This is TeX. C Version 3.141 (bsample.tex (bsamp1e.a~~) ... /././././.


. 0

0 0 ,

Figure 13.3: Running KQX with a BETEXbibliography data base

Some BETEX styles modify the citation and bibliography list items compared to those available with standard W X . Therefore, in addition to denoting the BETEX style with a \bibliographystyle command, a corresponding L A T E Xpackage must also be specified using the \usepackage command. This is, for example, the case for the apalike style that we used in the last example.

13.2 Using BIBTFXwith LATX

381

% BiBTeX sample data base


bibtexfileC author = version = date = a * /./, filename = %% address = %% %% %% email =

%% %% %% %%

"Michel Goossens" , "1.12", "15 November 1993", "bsample. bib", "CN Division, CERN CH1211, Geneva 23 Switzerland", "<goossens at node cern.ch>" )

address ={Stanford, CA 9 4 3 0 5 ) . =ISTAN-CS-83-9803, number institution ={Department of Computer Science, Stanford University) 1 QhdthesisCLiang:1983, author ={Franklin Mark Liang), month =jun, year = 1983, school ={Stanford University), address ={Stanford, CA 943053, title = { { W o r d Hy-phen-a-tion by C o r n p u t e r ) ) , note ={Also available as Stanford University, Department of Computer Science Report No. STAN-CS-83-977)

OPreamble{{\input{bibnames .s t y ) ) # C\hyphenationCPost-Script Sprin-ger))

>

OStringIAW = {{Ad\-di\-son-Wes\-ley))) 0StringCAW:adr = {Reading, Massachusetts)) QStringIj-TUGboat = { T U G b o a t ) ) GmanualCDynatext, key ={Dynatext), title ={{Dynatext, Electronic Book Indexer/Browser)). organization={Elect+onic Book Technology I n c . ) , address ={Providence, Rhode Island), year =I991 @BookIEijkhout:1991, author ={Victor Eijkhout), title = { { \ T e X I ) by Topic, a {\TeXlnicians R e f e r e n c e ) ) , publisher =AW, address =AW:adr , year =1991, OtechreportCEVH:Office, author ={Eric van Herwijnen), title = { { F u t u r e Office Systems Requirements)), institution =KERN DD Internal N o t e ) , year =1988, month = nov OArticle{Felici:l991, author ={James Felici), title ={{PostScript versus T r u e T y p e ) ) , journal =IMacworld), volume =8,pages={195--201). month =sep, year = 1991 OtechreportCKnuth:WEB, title = { { T h e \textsfCWEB) System of Structured Documentation)), month =sep, year = 1983, author ={Donald E. Knuth),

OArticle~Mittelbach/Schoepf:1990, author ={Frank Mittelbach and Rainer SchI\"o)pf), title = { { T h e New Font Selection --- User Interface to Standard \ L a T e X ) ) , journal =j-TUGboat, volume =11, number = 2, Pages ={297--3053, year =I990 3

QInbook~Wood:color, author = { P a t W o o d ) , crossref ={Roth:postscript), booktitle = { { R e a l World PostScript)), ={Postscript Color Separation), title Pages =C201--225) OBook{Roth:postscript, editor ={Stephen E. R o t h ) , title = { { R e a l World Postscript)), publisher =AW, address =AW:adr, year =1988,

ISBN ={O-201-06663-71 3 OInproceedings{Yannis:1991, title = {C\TeX) and.those other languages), author= {Yannis Haralambous), pages = C539--548), booktitle ={1991 Annual Meeting Proceedings, Part 2, \TeXC) Users Group, Twelfth Annual Meeting, Dedham, Massachusetts, July 15--18, 1 9 9 1 ) , editor = {Hope Hamilton), organization = { { \ T e X ) Users G r o u p ) , year = { 1 9 9 1 ) , address =Providence, Rhode Island), journal =j-TUGboat, volume = 12, month = dec )

Figure 13.4: Example of a BIBTEX data base This example data base file was used in the runs with the input file shown in figure 13.2 on page 379 to generate the output files shown in figures 13.5 to 13.7 beginning on page 382.

Example of citations of kind p l a i n


Citation of a normal book [I] and an edited book 181. Now we cite an article written by a single 131 and by multiple authors 171. A reference to an article inside proceedings [4]. We refer to a manual 121 and a technical report 151. A citation of an unpublished work 191. A reference to a chapter in a book [I01 and to a PhD thesis 161. An example of multiple citations [I, 81.

Example of citations of kind u n s r t


Citation of a normal book [I] and an edited book 121. Now we cite an article written by a single (31 and by multiple authors [4]. A reference to an article inside proceedings 151. We refer to a manual [6] and a technical report 171. A citation of an unpublished work 181. A reference to a chapter in a book [9] and to a PhD thesis [lo]. An example of multiple citations [I, 21.

References
[I] Victor Eijkhout. TEX by Topic, a T~Xnicians Reference. Addison-Wesley, Reading, Massachusetts, 1991. 121 Electronic Book Technology Inc.. Providence, Rhode Island. Dynatert, Electronic Book IndexerlBrowser, 1991. [3] James Felici. PostScript versus TrueType. Marworld. 8:195-201, September 1991. [4] Yannis Haralambous. T@ and those other languages. In Hope Hamilton, editor, 1991 Annual Meeting Proceedings, Pan 2 , TEX Users Group. Twelfth Annual Meeting. Dedharn. Massachusetts.July 15-18. 1991, volume 12, pages 539-548, Providence, Rhode Island. December 1991. T@ Users Group. ,151 Donald E. Knuth. The WEB System of Structured Documentation. Technical Repon STAN-CS-83-980,Department of Computer Science, Stanford University, Stanford, CA 94305, September 1983. 161 Franklin Mark Liang. Word Hy-phen-a-tion by Corn-pu-ler. PhD thesis. Stanford University, Stanford, CA 94305, June 1983. Also available as Stanford University, Department of Computer Science Report No. STAN-CS-83-977. [7] Frank Mittelbach and Rainer Schiipf. The New Font Selection - User Interface to Standard W @ . TUCboat, 11(2):297-305,1990. I81 Stephen E. Roth, editor. Real World PostScript. Addison-Wesley, Reading. Massachusetts, 1988. 191 Eric van Herwijnen. Future Office Systems Requirements. Technical report, CERN DD Internal Note, November 1988. 1101 Pat Wood. PostScript Color Separation, pages 201-225. In Roth 181, 1988.

References
[I] Victor Eijkhout. TEX by Topic, a T~Xnicianr Reference. Addison-Wesley, Reading, Ma~sachusetts,1991. [2] Stephen E. Roth, editor. Real World PostScripl. Addison-Wesley, Reading, Massachusetts, 1988. 131 lames Felici. PostScript versus True%.
Marworld, 8: 195-201, September 1991

141 Frank Mirtelbach and Rainer Schiipf. 7he New Font Selection - User Interface to Standard LqjX. TUGboat, 11(2):297-305.1990. [5] YannisHaralambous. TEX and those other languages. In Hope Hamilton. editor, 1991 Annual Meetinn Proceedinns. Part 2 . TFX " Users Grouo. , . Twelfth , Annual Meetinn. Dedham, Marsochusetts, July 15-18.1991. volume 12. pages 539-548, Providence. @ Users Group. Rhode Island. December 1991. T 161 Electronic Book Technology Inc., Providence. Rhode Island. Dynatw. Elecrmnic Book IndererlBrowser. 1991. 171 Donald E. Knuth. The WEB System of Structured Documentation. Technical Report STAN-CS-83-980, Department of Computer Science, Stanford University, Stanford. CA 94305, September 1983. 181 Eric van Herwijnen. Future Office Systems Requirements. Technical report. CERN DD Internal Note, November 1988. 191 Pat Wood. Postscript Color Separation, pages 201-225. In Roth 121, 1988. [I01 Franklin Mark Liang. Word Hyphen-a-lion by Corn-pu-ter. PhD thesis, Stanford University, Stanford. CA 94305. June 1983. Also available as Stanford University, Department qf Computer Science Report No. STAN-CS-83-977.

Figure 13.5: Output examples of the plain and unsrt BETEX styles

Example of citations of kind a l p h a


Citation of a normal book [Eij91] and an edited book [RotSS]. Now we cite an article written by a single [Fe191] and by multiple authors [MS90]. A reference lo an article inside proceedings [Ha191]. We refer to a manual IDyn91I and a technical report IKnu83I. A citation of an unpublished work [vH88l. A reference to a chap ter in a book [Woo881 and to a PhD thesis [Lia83]. An example of multiple cilalions [EijPI, Rot88l.

Example of citations of kind a b b r v


Citation of a normal book (I1 and an edited book (81. Now we cite an article written by a single [3] and by multiple authors 171. A reference to an article inside proceedings 141. We refer to a manual [2] and a technical report [SI. A citation of an unpublished work 191. A reference to a chapter in a book [lo] and to a PhD thesis 161. An example of multiple citations [I, 81.

References
[DynPI] Electronic BookTechnology Inc., Providence,RhodeIsland. Dynatext. Electronic Book IndexerlBrou~ser,1991. IEij9 I ] [Fe191I Victor Eijkhout. TEX by Topic, a TflniciansReference. Addison-Wesley, Reading. Massachusetts, 1991. James Felici. PostScript versus TrueType. Maovorld. 8: 195-201, September 1991.

References
[I] V . Eijkhout. TEX by Topic, o TEXnicians Reference. Massachusetts. 1991. Addison-Wesley. Reading.

[2] Electronic Book Technology Inc.. Providence, Rhode Island. Dynarerf. Electronic Book IndexerlBrowser. 1991. [3] J. Felici. PostScripl versus TrueType. Mam~orld. 8: 195-201. Sept. 1991. (41 Y. Haralambous. TEX andthoseother languages. In H. Hamilton,editor. 1991 Ann~ral Meeting Proceedin~s.Part 2 . TEX Users Group. TnrelfrhAnnual Meeting. Dedharn. Massachuserts. July 15-18. 1991, volume 12, pages 539-548, Providence, Rhode Island. Dec. 1991. TEX Users Group. [5] D. E. Knuth. The WEB System of Structured Documentation. Technical Report STAN-CS-83-980. Department of Computer Science. Stanford University, Stanford, CA 94305, Sept. 1983. [6] F. M. Liang. Word Hy-phm-a-lion by Com-pu-ter. PhD thesis. Stanford University. Stanford. CA 94305. June 1983. Also available as Stanford University. Department of Computer Science Report No. STAN-CS-83-977. [7] F. Mitlelbach and R. Schiipf. The New Font Selection -User ETEX. TUGboat. 11(2):297-305.1990. Interface to Standard

[Har91] Yannis Haralambous. Tr3( and those other languages. In Hope Hamilton. editor. 1991 Annrral Meninx Proceedings, Part 2. TEX Users Group. Twelfth Annual Meeting. Dedham. Massachusetts. July 15-18.1991, volume 12, p a p s 539-548, Providence, Rhode Island, December 1991. TEX Users Group. [Knu83] Donald E. Knuth. The WEB System of Structured Documentation. Technical Report STAN-CS-83-980.Department of ComputerScience, Stanford University. Stanford. CA 94305, September 1983. [Lia83] Franklin Mark Liang. WordHy-phen-a-tion by Corn-pu-ter. PhD thesis. Stanford University.Stanford.CA94305,June 1983. Also availableas Stanford University. Department of Computer Science Report No. STAN-CS-83-977. [MS90] Frank Mittelbach and Rainer Schiipf. The New Font Selection - User Interface to Standard L m . TUGhoat. 11(2):297-305.1990. [Rot881 Stephen E. Roth. editor. Real World PostScript. Addison-Wesley. Reading, Massachusetts, 1988. [vH88] Eric van Henvijnen. Future Office Systems Requirements. Technical report. CERN DD Internal Note. November 1988.

[8] S. E. Roth, editor. Real World PosrScript. Addison-Wesley,Reading, Massachusetts, 1988. [9] E. van Hemijnen. Future Office Systems Requirements. Technical report, CERN DD Internal Note, Nov. 1988. [lo] P. Wood. PostScript Color Separation. pages 201-225. In Roth IS], 1988.

[Woo881 Pat Wood. PostScript Color Separation. pages 201-225. In Roth [Rot88], 1988.

Figure 13.6: Output examples of the alpha and abbrv BIBTEXstyles

Example of citations of kind a c m


Citation of a normal book [I] and an edited book 181. Now we cite an article written by a single [3] and by multiple authors [71. A reference to an article inside proceedings (41. We refer to a manual [2] and a technical report [5]. A citation of an unpublished work 191. A reference to a chapter in a book [lo] and to a PhD thesis 161. An example of multiple citations [I. 81.

Example of citations of kind a p a l i k e


Citation of a normal book (Eijkhout, 1991) and an edited book (Roth. 1988). Now we cite an anicle written by a single (Felici. 1991) and by multiple authors (Mittelbach and Schopf, 1990). A reference to an article inside proceedings (Haralambous, 199 1 ). We refer to a manual (Dynatext. 1991) and a technical repon (Knuth. 1983). A citation of an unpublished work (van Henvijnen, 1988). A reference to a chapter in a book (Wood. 1988) and to a PhD thesis (Liang, 1983). An example of multiple citations (Eijkhout. 1991: Roth. 1988).

References
[I] EIIKHOUT, V. TEX hy Topic, a TjXnicians Referpnce. Addison-Wesley. Reading, Massachusetts, 1991. 121 ELECIRONIC BOOK TECHNOLOGY INC. Dynafert. Elecrronic Book IndererlBron.ser. Providence. Rhode Island. 1991. [3] FELICI, J. PostScript versus True-.
Macworld 8 (Sept. 1991), 195-201.

References
Dynatext (1991). Dynafe.rt. Elecrronic BookIndexerlBron~ser.Electronic BookTechnology Inc., Providence, Rhode Island.
Reference. Addison-Wesley, Reading, Eijkhout, V. (1991). TEX hy Topic, a T~Xnicians Massachusetts. Marn,orld, 8:195-201. Felici. J. (1991). PostScript versus T~eType.

[4] HARALAMBOUS. Y. TEX and those other languages. In 1991 Annual Meeting Proceedings. Part 2. T@ Users Group. Tn~elffh Annual men in^. Dedharn. Massachusetrs. July 15-18.1991 (Providence, Rhode Island. Dec. 1991). H. Hamilton. Ed., vol. 12. TEX Users Group. pp. 539-548. 151 KNUTH, D. E. The WEB System of StructuredDocumentation. Tech. Rep. STAN-CS83-980. Department of Computer Science. Stanford University, Stanford. CA 94305, Sept. 1983. 161 LIANG. F. M. Word Hy-phen-a-lion by Corn-pu-ter. PhD thesis. Stanford University, Stanford, CA 94305. June 1983. Also available as Stanford University, Department of Computer Science Repon No. STAN-CS-83-977. 171 M I ~ L B A C F., H ,A N D SCHOPF, R. The New Font Selection - User Interface to Standard L V . TUGhoar11.2 (1990). 297-305. [U] R ~ H S.. E., Ed. R m l World PostScripf. Addison-Wesley. Reading. Massachusetts. 1988. (91 VAN HERWIJNEN, E. Future Office Systems Requirements. Tech. rep.. CERN DD Internal Note. Nov. 1988.
[ 101 WOOD.P . PostScript Color Separation. In Roth (81. 1988,pp. 201-225.

Haralambous, Y.(1991). TEX and those other languages. In Hamilton, H., editor, 1991 Annual Mening Proceedings. Par1 2. T@ Users Croup. Tndflh Annual Meeting. Dedham. Massachusetts. July 15-18. 1991. volume 12. pages 539-548. Providence, Rhode Island. TEX Users Group. Knuth. D. E. (1983). The WEB System of Structured Documentation. Technical Repon STAN-CS-83.980. Depanment of Computer Science, Stanford University. Stanford, CA 94305. Liang, F, M. (1983). Word Hy-phen-a-lion hy Corn-pu-rer. PhD thesis, Stanford University, Stanford, CA 94305. Also available as Stanford University, Department of Computer Science Repon No. STAN-CS-83-977. Mittelbach, F. and Schopf. R. (1990). The New Font Selection -User Interface toStandard LqX. TUGhoar. 11(2):297-305. R0th.S. E.. editor(l988).Real WorldPostSwipr. Addison-Wesley. Reading. Marsachusetts. van Henvijnen. E. (1988). Future Office Systems Requirements. Technical repon, CERN DD Internal Note. Wood, P. (1988). PosrScripr ColorSepararion, pages 201-225. In (Roth. 1988).

Figure 13.7: Output examples of the acm and apalike BETEX styles

13.3 Multi~le Bibliographies in One Document

385

13.3 Multiple Bibliographies in One Document


In large documents with several independent sections, in conference proceedings containing many different articles, or in a book with separate parts written by different authors, it is often necessary to have separate bibliographes for each of the units. In this section we discuss two W X packages, chapterbib and bibunits, that address this problem. Note that the latter package only works without modifications on UNIX.

13.3.1 The chapterbib Package


The chapterbib package (by Niel Kempson) allows multiple bibliographies in a L A T E X document, including the same cited items occurring in more than one bibliography. The following restrictions apply, however:
1. The \bibliography and \bibliographystyle commands may not be used in the root file, only in files that have been included with the \include command. Bibliographycommands in the root file will be ignored. Moreover, only a single \bibliography command should be present in each included Ne.

2. If you want to use \cite commands in the root file, then their keys must be resolved by providing a stand-alone thebibliography environment inside the root file, as shown on the example on page 387.

For demonstration purposes (in real life choosing such different styles would certainly be considered a heresy) the I~T'EXexample in figure 13.8 on page 387 combines two different BIBTEX styles. As the BJBTEX program only handles one style at a time (i.e., allows only one \bibliographystyle command), BmT~Xmust be run separately on each .aux file, bsl .aux and bs2. aux,to write the respective .bbl files, bsl .bbl and bs2. bbl, as shown below:
$ latex chapterbibexa
e

.. .
$ bibtex bsl

v A/././. 1st run of W


8 0

/./,/./. BIBTEX run on 1st file This is BibTeX, C Version 0 . 9 9 ~ The top-level auxiliary file: bsl.aux The style file: plain.bst Database file #I: bsample.bib * * a * $ bibtex bs2 /,/./,/. BETEX run on 2nd file This is BibTeX, C Version 0 . 9 9 ~ The top-level auxiliary file: bs2.aux The style file: alpha.bst Database file #I: bsample.bib 0 0 0 0 $ latex chapterbibexa /./././. 2nd run of W X
0 0 0 1

...

386
$ l a t e x chapterbibexa
. . 0 0

Bibliography Generation

.. .

/,/,/./, 3rd run of LQX

The final result is shown in figure 13.9 on page 388.

13.3.2 The bibunits Package


The bibunits package (by Jose Alberto Fernandez) generates separate bibliographies for different units (parts) of the text (chapters, sections, or bibunit environments). The style will separate the citations of each unit of text into a separate file to be processed by BIBTEX. The global bibliography section produced by W&X can also appear in the document, and-citations can be placed in both at the same time.

I \bibliographyunit [unit] 1
This command specifies for which document unit references must be generated, i.e., unit=\chapter (for each chapter) or unit=\section (for each section). If the optional argument is not given, the command \bibliographyunit deactivates bibliography units, and the bibliography is made global for the complete document. When \bibliographyunit is active, the \bibliographystyle and \bibliography commands specify the BIBTEXfiles and the style to be used by default in the local units. The commands \bibliography* and \bibliographystyle* specify defaults for the given bibunit only and do not affect the global bibliography.

While \bibliographyunit is not active the bibunit environment allows the creation of a bibliography unit. The optional parameter style specifies a style for the bibliography different from the default, if any.

I \putbib [bibtex-files]I
A \putbib command must be inserted before the end of each unit at the point in the text where the bibliography should be typeset. If the optional argument if any. is absent, \putbib uses the default bibtex-files, for each unit in sequence With the bibunits package, you must run BIBTEX since, for each such unit, there is now a corresponding file j obname . i .aux created, where i is the sequence number of the unit. As an example, the input file shown in figure 13.10 on page 389 plus the commands given in figure 13.11 on page 390 will produce the output shown in figure 13.12 on page 391.

13.3 Multiple Bibliographies in One Document

387

L L L L Root file bsamplemult .tex %"/."/."/."/."/."L%"/,"/,"L%"/."/."/."L \documentclass~article) \usepackage{chapterbib) \beginCdocument) \include{bsl} \includeCbs2) \section*CExample of citations in the root file) Citation of a normal book"\cite~Eijkhout:1991) in the root file. \begin{thebibliography)C1) \bibitemCEijkhout:1991) Victor Eijkhout, \emphC\TeXC) by Topic, a (\TeX}nicians Reference), Addison-Wesley (1991). \end(thebibliography) \endCdocument}
1 0 1 0 0 0 0 0 * 0 * 0 0 0 0 l 0 0 0 0 ~ 0 0 0 0 0 0 l 0 ~ ,

LLLLLLLLLLLLLLLLL

Included file bsl .tex

%"/."/."/."/."/."L%%%%%"/."/."/."L

\sectionCExample of citations in an included chapter) \subsectionCFirst in plain style) Citation of a normal book"\cite{Eijkhout:1991) and an edited book"\cite~Roth:postscript). Now we cite an article written by a single-\cite{Felici:1991) and by multiple authors~\citeCMittelbach/Schoepf:1990). A reference to an article inside proceedings-\citeCYannis:1991). We refer to a manuale\citeCDynatext) and a technical reporte\citeCKnuth:WEB). A citation of an unpublished work"\citeCEVH:Office). A reference to a chapter in a book"\cite~Wood:color) and to a PhD thesise\citeCLiang:1983). An example of multiple citations"\cite~Eijkhout:1991,Roth:postscript). \bibliographystyle{plain) \bibliography{bsample)
0 0 ~ 0 0 0 ~ 0 ~ . 1 0 0 * 0 * 0

LLLLLLLLLLLLLLLLL

Included file bs2.tex

Y/."L%"/."/."/."l/."/."/."/,"/."/."/."L

\sectionCExample of citations in an included chapter) \subsectionCThen in alpha style) ...... Same input ...... \bibliographystyle(alpha} \bibliographyCbsample)

Figure 13.8: A root file and two included files with separate bibliographies

1 Example of citations in an included chapter


1.1 F i r s t i n p l a i n style
Cimion of a normal booX I1land w edited book 181. Now we Life w anicle wiftrn by a <ln$lc Ill m d hy rnultlplc avlhon 171 A mfrrmrc a an m c l c onvdc pmaredlng~ 1 4

2 Example of citations in an included chapter


2.1
Then in a l p h a style

Example of citations in the root file


Calarson ofa normal book l l l in thc m o o file.

Cilalion o f a n o m d book IEijYll and an edited book IRot88l. Now we clle w anicle w t s n by a single lFel9l Iw d by muItiplt author* lMS90 A r e h n r r tasn a n ~ l ln.lde c Werrfnloamanusl l.'l~aamhrmrmrml~pon I51 Aclrallonolan unpuhl#<hw w r k IY poceedlng5 IHaNI I. We refer to a rnanud lDyn9ll and a eehnlcal repon IKnu83l A A rrrmrnm lo a r h m n a bwI IUl sud $0a VhD thw 16 ~n c m n l c of m ~ l t ~ n l c atason of an unpubliihed work IvH8RI. A reference lo a chapter tn a baok IWww88I and loaPhD thc~lr ILtaR3I An ciamplc ofrnull~pleo!aion. IEijYI. Rot8RI.

References
I1 I Vlclor B j k h a u l . ~ hynzpn.o T&XnicranrR~f.r.ncr. Addison-Wcrlcy (1991).

References
I1I waor Eijkhout. T@ by Topic. o T@niiinnrRefmm~ Addison-Wmley. Reading. Ma<rachuvnl 1991. 121 El-ic B m k Teclolology I = . .Raidma.Rhodc Island. Lh.mtu~. Elmrmnic

References
IDyn911 ElecmnicBookT~chnalogyInc.. Rovidmoc. Rhodcl~land.Dynorur.Elcclmnic R m t InrlnrlnrlIRmwrcr. 1991.

B o d IndunduIRmusrr. 1991.

141 Ywnir Hnmlnmbour. ' I W w d l h o r ahslangwga. In Hopc Hamiltan.ed8lor. 1991 A.WI Mrrring P m r r d m p . Pnn 2. rg urerr cmup. Twelfth A"m.71 M..,,ng, D c d h . Marrochmretu,July 15-18, 1991. r a l u m 12. page 539-548. Rondenac. Rhcde Idand. Dsembn I991.TiX UrmCmup

HaNl

Y a n m Hnmlambou5 T p % and thovothcr lanpuag~p~p In l l o m ~ a m ~ l ~ o n . c l l ~ ~ ~ ( ~ r , IWI A ~ M I I~ ~ G rnrrrJlnal ~~E ~ PO,, I 2 ICY i iw.qlh Mrnmn.l>nlNun Mucccr'hucrn. lul, I5 IA rYYl vnlvmr 12 ~ 1 ~ ~ ~ 5 1 q - 5 4 l

161 Frantlin Msrt Li.ng. W d Hypkmo-tion by Cm-pu-ter. PhD Ihniq. Stanford Unlvmity. Stanford. CA 94305. J u m 1983. Alvl availalde as Stanford Univer*i!y, apwrmt of Compum%ma Rrpon No STAN-CS-83.971. 171 Frmk Mnnclbachand R a i m W p t .' E x New Font Seleefion- US W Lq@. TUGbar. lI(2y297-305.19VO.

IKnuRll Donald F Knulh Thc WEB Sywm of Lrunurnl Docvrnntat8on Tcchnlcal R m n .VAh-CS-81-VXII,lkpanmrnl ofcomputo Socncc, Stanford Lnhml!) ?canrord.c~qdln\ scpnrmkr IVXI I1 I ~ J IFmkltn M.vk l ~ a n pWmdtl, phrn a-,,onh, Corn pu-nr PhD!h.nr. Stanford L n ~ , ~ n o t y . s u u l b m . ~ ~1~ d i IYRI ~ s A I W W ~ , ao rarstanrord~nl,mlt,. Cqmnmcnl ~uf Compvls Zclrnrr K c p m Vo STA\-CS Wl-977 IMS901 Frank Miltrlbgh and RainerSch8pf. Thc New Font Sclstionto Slandard QX. T U G k m . 11(2).291-305,1990 VET lntdace

181 Slcphm E. Roth. d i m . R-1 World msrscripr. Addim-Waly. Reading. Ma+ wchunn?. 1538. 191 Eric *an Hmijncn. Fmm Offloc Synern- R c q u i m n t r Technical DD lnlcmal Note. N m n n b n 1538. 1101 Rr Wmd. PmtSssiptColnS-rinnmm201-225. CERN

lnterfaa to

lRot88l Stephen E. Roth, editor R d World m.wS~rip#.Addiwn-Wcdg. Reading. Marszchuutn. 1988. lvH88l

InRoIh 181. 1988.

Eric ran Henrijnen Fulum Syrcms R e q u i m r n ~ ~ Technical . rrpon CERN DD lntcmal No!.. Nwcmkr 1988.

I W d 8 l Fat Wmd. Pns,ScnprCnlorSepom~iii,pagaga MI-225. In RaUl IRolRWI. 1988.

Figure 13.9: Multiple bibliographies in one file (generated output) These multiple pages are produced by running the input in figure 13.8 on the preceding page through W X and BIETEX. You can see that each included file is treated completely independently from each other included file. Having different \bibliographystyle commands in one document is perhaps not an advisable precedure, but when BJBTEX is run on each .aux file separately, different styles are possible.

13.3 Multivle Bibliogravhies in One Document

389

\documentclass{article) \usepackage{bibunits) \begin{document) \section{The bibunits package) \begidbibunit) [unsrtl........................................................ \subsection{First in bibstyle unsrt) Citation of a P M thesis-\cite{Liang:1983). Now we cite an article written by multiple authors~\cite{Mittelbach/Schoepf:1990~. A reference to an article inside proceedings-\cite{Yannis : 1 9 9 1 ) . \putbib [bsamplel \end{bibunit)

Start the first unit

\subsection{Let us continue in bibstyle abbrv) \begin{bibunit) [abbrvl%%"%%%#"/."/,%"/."/."/."/."L%"/."/."/,%"/."/."L Start the second unit We refer to a manual"\cite{Dynatext) and a technical report"\cite{Knuth:WEB). A reference to a chapter in a book-\cite{Wood: color) and to an edited book"\cite{~oth:postscript). \putbib [bsamplel \end{bibunit) \subsection{And finish in bibstyle alpha) \begin{bibunit)[alphal%%%"//."//."/."/."/."/."/."/."/."/."/."/."/."/."/,%"/, Start the third unit Citation of a normal book"\cite{~ijkhout:1991) of an article written by a single"\cite{Felici:1991) author. \putbib [bsamplel \end{bibunit) \end{document)

Figure 13.10: Example input for the bibunits package

Of the two packages chapterbib and bibunits, the former is the more intuitive. You must remember, however, that units for which a separate bibliography is desired must be put in.separate files and input with the \include command. The bibunits package is more powerful, but you must be careful not to lose control over the various bibliography units, which can be defined in various places. Moreover, since bibunits creates file names containing three elements j obname .i .aux, it will not work without modifications on non-UNIX systems, like MS-DOS, CMS, or VMS.

390

Bibliography Generation

1st run of W This is TeX, Version 3.141 (bibunitsexa.tex No file bibunitsexa.aux. ... I/ .I/.. / .Unresolved references II . No file bibunitsexa.l.bb1. ... /.A/. Unresolved citation references No file bibunitsexa.2.bbl. ... %%% ditto No file bibunitsexa.3.bbl. ... %%% ditto [ I ] (bibunitsexa.aux) ) Output written on bibunitsexa.dvi (1 page, 1032 bytes). Transcript written on bibunitsexa.log. $ bibtex bibunitsexa.1 L L L L L L L Run BJBTEX on 1st file This is BibTeX, C Version 0 . 9 9 ~ The top-level auxiliary file: bibunitsexa.l.aux The style file: unsrt.bst Database file #I: bsample.bib $ bibtex bibunitsexa.2 / . Run BJBTEX on 2nd file This is BibTeX, C Version 0 . 9 9 ~ The top-level auxiliary file: bibunitsexa.2.a~~ The style file: abbrv.bst Database file #I: bsample.bib e***..*...... $ bibtex bibunitsexa.3 / . Run BJBTEX on 3rd file This is BibTeX, C Version 0 . 9 9 ~ The top-level auxiliary file : bibunitsexa.3'. aux The style file: alpha.bst Database file #I: bsample.bib $ latex bibunitsexa L L L L L L L L L 2nd run of UQX This is TeX, C Version 3.141 (bibunitsexa.tex (bibunitsexa.aux) ... * a . (bibunitsexa.l.bbl) . . . /.A/. Still unresolved citation references (bibunitsexa.2.bbl) ... ditto (bibunitsexa.3.bbl) . . . %%% ditto [ I ] (bibunitsexa.aux) ) ~OI~O*....... $ latex bibunitsexa / . 3rd and final run of LQX This is TeX, Version 3.141 (bibunitsexa.tex
$ latex bibunitsexa
1 * * 0 * * . . * . . . .

.*.......,*,, L L L L L L L

O * ~ . . . * . . . . , ,

@ * * * . 1 * 0 1 * * . 1

%a

. ..

(bibunitsexa.aux) (bibunitsexa.l.bb1) (bibunitsexa.2.bbl) (bibunitsexa.3.bbl) [ I ] (bibunitsexa.aux) ) Output written on bibunitsexa.dvi (1 page, 3232 bytes).

Figure 13.11:Running multiple bibliographies with the bibu nits style These commands are used to run the input of figure 13.10 on the preceding page to obtain the output of figure 13.12 on the next page.

13.3 M~ltiDle Biblioma~hies in One Document

391

1 The bibunits package


1.1 First in bibstyle unsrt
Citation of a PhD thesis [I]. Now we cite an article written by multiple authors [2]. A reference to an article inside proceedings [3].

References
[I] Franklin Mark Liang. Word Hy-phen-a-rion by Corn-pu-ter. PhD thesis, Stanford University, Stanford, CA 94305, June 1983. Also available as Stanford University, Department of Computer Science Repon No. STAN-CS-83-977. [2] Frank Mittelbach and Rainer Schopf. The New Font Selection - User Interface to Standard m j . TUGboat, 11(2):297-305,1990. [3] Yannis Haralambous. T j and those other languages. In Hope Hamilton, editor, 1991 Annual Meeting Proceedings, Part 2, T g Users Group, TwelfrhAnnual Meeting. Dedharn, Massachusetrs, July 15-18, 1991, volume 12, pages 539-548, Providence. Rhode Island, December 1991. TEX Usen Group.

1.2 Let us continue in bibstyle abbrv


We refer to a manual [I] and a technical repon 121. A reference to a chapter in a book 141 and to an edited book 131.

References
[I] Electronic Book Technology Inc., Providence, Rhode Island. Dynatexr, Electronic Book lndexerlBrowser, 1991 . [2] D. E. Knuth. The WEB System of S t ~ c t u r e d Documentation. Technical Repon STAN-CS-83-980, Department of Computer Science, Stanford University, Stanford, CA 94305, Sept. 1983. [3] S. E. Roth, editor. Real World Postscript. Addison-Wesley, Reading, Massachusetts. 1988. [4] P. Wood. PostScript Color Separation, pages 201-225. In Roth [3], 1988.

1.3 And finish in bibstyle alpha


Citation of a normal book [Eij91] of an article written by a single pel911 author.

References
Fij911 Victor Eijkhout. TEX by Topic, a T~XniciansReference. Addison-Wesley, Reading, Massachusetts, 1991. pel911 James Felici. PostScript versus Tmevpe. Macworld. 8: 195-201, September 1991.

Figure 13.12: Output generated from the example of figure 13.10 on page 389

392

Biblioma~hv Generation

13.4 Bibliography Data Base Management Tools


A sorted listing of all entries in a BJBTEX data base is often useful for easy reference. Various tools, with more or less the same functionality, are available, and choosing one or the other is mostly a question of taste. First there is the P Q X package biblist by Joachim Schrod. It can create a typeset listing of a (possibly large) BIBTEX input file. With large files, especially if the cite keys are long, TEX'S string space is often exceeded and BigTEX must be run on the TEX file. With the biblist package, even small versions of T E X will do. You must prepare a W&X document using the article class and the bi blist package. Options and packages like twoside, german or a4 can be added, but neither twocolurnn nor rnulticol will work. The \bibliography command must contain the names of all BIBTEX data bases you want to print. With a \bibliographystyle command you can choose a specific bibliography style. B y default, all bibliography entries in the data base will be output. However, if you issue explicit \nocite commands, only the selected entries from the data bases will be printed. The following is the input file used for generating the output of figure 13.13 on page 395.

You must run W X , BJBTEX, and P Q X . You do not need to run JAQX twice after the BIBTEX run. A series of interesting BIBTEX tools are generally available. The first set was written (mostly) by David Kotz. These tools are available for UNLX systems, but the ideas are quite general, so the scripts can be used as a basis for porting the tools to other operating systems. aux2bib Given an .aux file, t h s per1 script creates a portable .bib file. This is useful when E Q X files need to be shipped elsewhere. bibkey This C-shell script uses the sed, egrep, and awk utilities to prepare the list of all entries having a given keyword in their keyword field. Usage:bibkey keyword f i l e Characters in the keyword parameter above that have a special meaning in regular expressions used by either sed or egrep must be escaped with a \ (e.g., \ \ for the backslash \). Case is ignored in the search. Any valid

13.4 Bibliography Data Base Management Tools

393

egrep expression is allowed, for example, a search for multiple keywords:


bibkey 'joneslsmith' foo.bib

looktex Entries containing a given keyword in a BETEXdata base are listed when this C-shell script is run. It is a generalization of the bibkey script above, and all comments about that entry also apply in t h s case. makebib T h s C-shell script makes an exportable .bib file from a given set of .bib files and an optional list of citations. Usage: makebib file.bib. . . [citekey] . . . The output is written to subset .bib. If citekey is not given, then all refs in the bibfile(s) are included. printbib This is a C-shell script that makes a .dvi file from a .bib file for handy reference. It is sorted by cite key and includes keyword and abstract fields. Usage: printbib bibfile ... The file abstract. dvi is generated and can be run through a dvi-driver to be printed. Figure 13.14 on page 396 shows the output when running this shell script on the data base bsample. bib of figure 13.4 on page 381.
A second set of tools to handle BETEX data bases were developed by Nelson Beebe (Utah University). We give a brief description of each of them.

bibclean T h s is a prettyprinter, syntax checker, and lexical analyser for BETEX bibliography data base files [91. The program, whch runs on UNM, Vax/VMS and MS-DOS platforms, has many options, but in general you can just type: bibclean < bibfilel bibfile2, ... > outfile bibextract Extracts from a list of BETEX files those bibliography entries that match a pair of specified regular expressions, sending them to stdout, together with all @Preamble and @String commands. Two regular expressions must be specified, the first one to select keyword values (if this string is empty then all entries are examined), and the second one to further select from the value part of the entries which bibliography entries must be output. For example, the following command will extract all entries containing "Postscript" in any of the fields:
bibextract "" "PostScript" bibfile(s)>new-bibfile

while the next command wdl only extract those entries containing the same string but with Adobe in the author or organization fields:
bibextract "authorlorganizationtt"Adobe" bibfile(s) >new-bibfile

citefind.sh and citetagssh Sometimesyou have to extract the entries effectively referenced in your publication from several large BETEX data bases. The Bourne shell scripts citefindsh and citetagssh use the awk and sed tools to

394

Bibliography Generation
accomplish that task. First citetags.sh extracts the BETEX citation tags from the L A T E X source or .aux files and sends them to the standard output stdout, where citefindsh picks them up and tries to find the given keys in the .bib styles specified. It then writes the resulting new bibliography file to stdout, for instance citetags.sh *.aux I citefind.sh - mybibl.bib mybib2.bib > newbib.bib
bibsortsh As citefindsh outputs the citation information in the order in which it was found in the .bib files, it might be worthwhile, for ease of reference by a human reader, to sort the entries using the bibsortsh shell script. This script uses the sort program internally, so it also will honor most command

switches of the latter utility.


bibview Those with access to an X-window graphics terminal can use the bibview program to manipulate BETEXdata bases more easily using anX-window

interface. Nelson Beebe maintains a large number of BETEX data bases related to TEX, graphics, and a series of styles, which we already mentioned in table 13.1 on page 377. His most interesting .bib data bases, as far as TEX is concerned, are texbookl .bib and texbook2.bib (books about TEX, METAFONT and friends), gut.bib (the contents of the French Cahiers Gutenberg journal), komoedie .bib (the contents of the German Die T~Xnische Komodie journal), texgraph.bib (about how to make TEX and graphics work together), texjourn.bib (a list of journals accepting TEX as input), tugboat.bib (listing all the articles in TUG boat), type.bib (containing a list of articles and book about typography), and standard. bib (listing software standards). Nelson Beebe also developed the bibmods and showtags packages. You can see how these packages are used and what kind of output they generate by looking at figure 13.15 on page 397, which corresponds to running the input file below through the LATEX-BETEXsuite of programs using the example data base of figure 13.4 on page 381.

a * a e /./././.A Using the bibmods and showtags packages %%'rLCL \usepackage{bibmods> \usepackageCbibnames) \usepackageCshowtags>

13.4 Bibliography Data Base Management Tools

395

b s a m p l e .b i b (August 22,1993)

References
D y n a t e x t ..................................................................... Electronic Book Technology Inc., Providence. Rhode Island. Dynatext. Electronic Book IndexerlBrowser. 1991. E i j k h o u t : 1 9 9 1 .............................................................. Victor Eijkhout. TEX by Topic, a Tgnicians Reference. Addison-Wesley,Reading, Massachusetts, 1991. F e l i c i : 1 9 9 1 ................................................................. James Felici. PostScript versus TmeType. Macworld. 8: 195-20 1. September 1991. Y a n n i s : 1 9 9 1 ................................................................. Yannis Haralambous. T @ and those other languages. In Hope Hamilton, editor, 1991 Annual Meeting Proceedings, Port 2 , TEX Users Group. Twelfh Annual Meeting, Dedham. Massachusetts. July 15-18, 1991, volume 12, pages 539-548, Providence. Rhode Island, December 1991. T @ Users Group. Knuth:WEB .................................................................... Donald E. Knuth. The WEB System of Structured Documentation. Technical Report STAN-CS-83-980, Department of Computer Science. Stanford University, Stanford, CA 94305. September 1983. L i a n g : 1 9 8 3 .................................................................. Franklin Mark Liang. Word Hy-phen-a-tionby Corn-pu-ter. PhD thesis, Stanford University, Stanford, CA 94305, June 1983. Also available as Stanford University, Department of Computer Science Report No. STAN-CS-83-977. M i t t e l b a c h / S c h o e p f : l 9 9 0 ....................... ... ...................... Frank Minelbach and Rainer Schopf. The New Font Selection -User Interface to Standard m X . TUGboat. 11(2):297-305.1990. R o t h : p o s t s c r i p t ........................................................... Stephen E. Roth, editor. Real World PostScript. Addison-Wesley, Reading, Massachusetts, 1988. ISBN 0-201-06663-7. EVH :Of f i c e .................................................................. Eric van Henvijnen. Future Office Systems Requirements. Technical report, CERN DD Internal Note, November 1988. Wood: c o l o r .................................................................. Pat Wood.

Figure 13.13: List of entries in bsample. b i b using biblist

396

Bibliography Generation

Bibliography files
bsample August 22, 1993

References
[Dynatext] Electronic Book Technology Inc., Providence, Rhode Island. Dynafext. Electronic Book IndexerlBrowser, 1991. [EVH:Office] Eric van Herwijnen. Future Office Systems Requirements. Technical report, CERN DD Internal Note, November 1988. [Eijkhout:19911 Victor Eijkhout. TEX by Topic, a Tgnicians Reference. Addison-Wesley, Reading, Massachusetts, 1991. [Felici:1991] James Felici. PostScript versus TrueType. Macworld, 8: 195-201, September 1991. [Knuth:WEB] Donald E. Knuth. The WEB System of Structured Documentation. Technical Repon STAN-CS-83-980,Department of Computer Science, Stanford University, Stanford. CA 94305. September 1983. [Liang:1983] Franklin Mark Liang. Word Hy-phen-a-tion by Com-pu-ter. PhD thesis. Stanford University, Stanford, CA 94305, June 1983. Also available as Stanford University, Department of Computer Science Report No. STAN-CS-83-977. [Mittelhach/Schoepf:19901 Frank Minelbach and Rainer SchGpf. The New Font Selection -User Interface to Standard Q X . TUGboat, 11(2):297-305,1990. [Roth:postscript] Stephen E. Roth, editor. Real World PostScript. Addison-Wesley,Reading, Massachusetts, 1988. [Wood:color] Pat Wood. PostScript Color Separation, pages 201-225. In Roth [?I, 1988. [Yannis:1991] Yannis Haralambous. TEX and those other languages. In Hope Hamilton, @ ' Users Group, Twelfth editor, 1991 Annual Meeting Proceedings, Part 2, T Annuol Meeting. Dedham. Massachusetts. July 15-18.1991, volume 12, pages 539-548, Providence, Rhode Island, December 1991. Q X Users Group.

Figure 13.14: List of entries in bsample . b i b using the printbib command

13.4 Biblioma~hv Data Base Management Tools

397

References
1- d

I MittelbachlSchoepf:1990 1
~ ~

-~--

[Dyn91] Electronic Book Technology Inc., Providence, Rhode Island. Dynatext, Electronic Book In-

[MS90] Frank Mittelbach and Rainer Schijpf. The New Font Selection -User Interface to Standard L T S . TUGboat, 11(2):297-305,
I

nnn

[Eij91] Victor Eijkhout. TEX by Topic, a T~xnicians Reference. AddisonWesley, Reading, Massachusetts,
lnnl
1771.

[Rot881 Stephen E. Roth, editor. Real World PostScript. AddisonWesley, Reading, Massachusetts, 1988. ISBN 0-201-06663-7.

1(

[iiEGq
[vH88] Eric van Hemihen. Future Office Systems Requirements. Technical report, CERN DD Internal Note, November 1988.

[Fe191] James Felici. Postscript versus TmeType. Macworld, 8: 195-201, September 1991.

[Har91] Yamis Haralarnbous. TEX and those other languages. ln H~~~ [Woo881 Pat Wood. PostScript ColorSepaHamilton, editor, 1991 Annual ration, pages 201-225. In Roth Meeting Proceedings, Part 2 , [Rot88], 1988. ISBN 0-201TEX Users Group, Twelfth An06663-7. nial Meeting, ~ e d h a r n , Massachusetts, July 15-18,1991, volume 12, pages 539-548, Providence, Rhode Island, December X Users Group. 1991. R

1-1

/iGzGq
[Knu83] Donald E. Knuth. The WEB System of Structured Documentation. Technical Report STAN-CS-83980, Department of Computer Science, Stanford University, Stanford, CA 94305, September 1983.

ILiang:19831
[Lia83] Franklin Mark Liang. Word Hyphen-a-tion by Corn-pu-ter. PhD thesis, Stanford University, Stanford, CA 94305, June 1983. Also available as Stanford University, Department of Computer Science Report No. STAN-(3-83-977.

Figure 13.15: List of entries in bsample . b i b using showtags and bibmods

398

Bibliography Generation

13.5 The General Format of the .b i b File


(L:140-47)
This section describes in greater detail the format of the entries in a BIBTEX data base. It updates the information in appendix B of the L A T E X book with material about version 0 . 9 9 ~ of BIBTEX [64] by Oren Patashnik, the author of the BIBTEX program.

13.5.1 The General Format of a BETEX Entry


(L:140-41)
A BETEX entry consists of three main parts: a type specifier, followed by a key,

and finally the data for the entry itself. The latter part consists of a series of field entriei, which can have one of two forms as seen in the following generic format and example:
@type-specifierCkey-identifier, f ield-name-1 = "f ield-text-1" , field-name-2 = {field-text-2),
@book{lamport86, author = "Leslie Lamport", title = "{\LaTeX{)) A Document Preparation system", publisher = {Addison-Wesley), year = 1986 1

. . .
field-name-n = {field-text-n)

The comma is the field separator. Spaces surrounding the equals sign or the comma are ignored. Inside the text part of a field (enclosed in a pair of double quotes or a pair of braces) you can have any string of characters, but braces must be matched. The quotes or braces can be omitted for text consisting entirely of numbers (like the year field in the example above). BIBTEX ignores the case of the letters for the entry type, key, and field names. You must, however, be careful with the key, since W X honors the case of the keys specified as the argument of a \ c i t e command, so the key for a given bibliographic entry must match the one specified in the IPQX file (see section 13.1).

13.5.2 The Text Part of a Field Explained


The text part of a field in a BETEXentry is enclosed in a pair of double quotes or curly braces. Part of the text itself is said to be enclosed in braces if it lies inside a matching pair of braces other than the ones enclosing the entire entry.

The Structure of a Name

(L141-42)

The author and e d i t o r fields contain a list of names. The exact format in which these names are typeset is decided by the bibliography style. The entry in the . b i b data base tells BIBTEX what the name is. You should always type names exactly as they appear in the cited work, even when they have slightly different forms in two works, for example:

13.5 The General Format of the .bib File


a u t h o r = "Donald E . Knuth" a u t h o r = "D. E. Knuth"

399

If you are sure that both authors are the same person, then you could list both in the form that the author prefers (say, Donald E. Knuth), yet you should always indicate (e.g., in our second case) that the original publication had a different form.
a u t h o r = "D [onaldl E . Knuth"

BETEX alphabetizes this as if the brackets were not there, so that no ambiguity arises as to the identity of the author. Most names can be entered in the following two equivalent forms:
"John C h r i s Smith" "Thomas von Neumann" "Smith, John C h r i s " "von Neumann, Thomas1'

The second form, with a comma, should always be used for people who have multiple last names that are capitalized, for example,
"Lopez Fernandez , Miguel"

If you enter "Miguel Lopez Fernandez," BETEX will take "Lopez" as the middle name, which is wrong in t h s case. When the other parts are not capitalized, no such problem occurs (e.g., Johann von Bergen or Pierre de la
Porte).

If several words of a name have to be grouped, they should be enclosed in braces, since BETEX treats everything inside braces as a single name, as shown below.
{{Boss and F r i e n d s , I n c . ) and {Snoozy and Boys, Ltd.))

In this case, Inc . and Ltd. are not mistakenly considered as first names. In general, BIBTEX names can have four distinct parts, denoted as First,von, Last, and Jr. Each part consists of a list of name tokens, and any list but Last can be empty. Thus, the two entries below are different:
"von d e r Schmidt, Alex" "{von d e r Schmidt), Alext1

The first has a von,Last and First part, while the second has only a First and a Last part (von der Schmidt),resulting possibly in a different sorting order. A "junior" part can pose a special problem. Most people with "Jr." in their name precede it with a comma, thus entering it as follows:
"Smith, J r . , Robert"

400

Bibliography Generation Certain people do not use the comma, and these cases are handled by considering the "Jr." as part of the last name:
"{Lincoln Jr.3, John P." "John P. {Lincoln Jr .)"

Recall that in the case of "Miguel Lopez Fernandez," you should specify:
"Lopez Fernandez, Miguel"

The F i r s t part of his name has the single token "Miguel"; the L a s t part has two tokens, "Lopez" and "Fernandez"; and the von and J r parts are empty. A complex example is:
"Johannes Martinus Albertus van de Groene Heide"

This name has three tokens in the F i r s t part, two in the von, and two in the L a s t . BETEXknows where one part ends and the other begins because the tokens in the von part begin with lowercase letters (van de in this example). In general, von tokens have the first letter at brace-level 0 in lowercase. As, technically speaking, everything in a "special character" is at brace-level 0 (see page 401), you can decide how BETEXtreats a token by inserting a dummy special character whose first letter past the TEX control sequence is in the desired case, upper or lower. For example, in
Maria {\uppercase{d)e La) Cruz

BETEX will take the uppercase "De La" as the von part, since the first character following the control sequence is in lowercase. With the abbrev style you will get the correct abbreviation M.De La Cruz, instead of the incorrect M.D. L. Cruz if you did not use t h s trick. BETEXhandles hyphenated names correctly, for example an entry like:
author = "Maria-Victoria Delgrande",

with the abbrv style, results in "M.-V. Delgrande." When multiple authors are present their names should be separated with the word "and" where the "and" must not be enclosed in braces.
author = "Frank Mittelbach and Rowley, Chris" editor = "{Lion and Noble, Ltd.)"

There are two authors, Frank Mittelbach and Chris Rowley, but only one editor, since the "and" is enclosed in braces. If the number of authors or editors is too large to be typed in extenso, then the list of names can be ended with the string

13.5 The General Format of the . b i b File

40 1

"and o t h e r s , "

which is converted by the standard styles into the familiar "et

al."
To summarize, you can specify names in BETEX using three possible forms (the double quotes and curly braces can be used in all cases):
" F i r s t von Last" "von Last, F i r s t " "von Last, J r , F i r s t " e . g . {Johan van der Winden) e . g . "von der Schmidt, Alexandero1 e . g . {de l a Porte, F i l s , {\'Emile))

The first form can almost always be used; it is however not suitable when there is a J r part, or the L a s t part has multiple tokens and there is no von part. The Format of the Title The bibliography style decides whether a title is capitalized or not. Usually titles of books are capitalized, but those for articles are not. A title should always be typed as it appears in the original work, for example
TITLE = "A Manual of Style" TITLE = "Hyphenation p a t t e r n s f o r ancient Greek and Latin"

(L142-43)

Different languages and styles have their own capitalization rules. If you want to override the decisions of the bibliography style, then you should enclose the parts which should remain unchanged inside braces. The following titles are equivalent:
TITLE = "The Towns and Villages of {Belgium)" TITLE = {The Towns and Villages of {B)elgium)

Accented and Special Characters BETEX accepts accented characters. If you have an entry with two fields
author = "Kurt G{\"o)dell', year = 1931,

then the alpha bibliography style will yield the label [God31],which is probably what you want. As shown in the example above, the entire accented character must be placed in braces; in this case either C\"o) or C\"Co)) will work. These braces must, however, not themselves be enclosed in braces (other than the ones that might delimit the entire field or the entire entry); and a backslash must be the very first character inside the braces. Thus, neither (G(\"(o))del) nor (G\"(o)del) work here. This feature handles accented characters and foreign symbols used with W X . It also allows user-defined "accents." For purposes of counting letters in labels, BETEX considers everything inside the braces as a single letter.

402

Biblioma~hv Generation To BIBTEX, an accented character is a special case of a "special character," which consists of everything from a left brace at the topmost level, immediately followed by a backslash, up through the matching right brace. For example, the field
author = {\OE{le) author = "\OE{le) {\'{E)mile) {\'{Elmile) {Ren\ ' { e l ) { R e n \ ' { e ) ) van R{\i\j)den) van R{\i\j)den"

has two special characters, "C\ ' {E)mile)" and "C\i\ j 3." In general, BETEX does not process TEX or L A T E X control sequences inside a special character, but it will process other characters. Thus, a style that converts all titles to lowercase transforms "The C\TeX BOOK\NOOP) Saga"intoUTheC\TeX book\NOOP) saga" where the article "The" remains capitalized because it is the first word in the title. The special character scheme is useful for handling accented characters; to make BIBTEX'S alphabetizing do what you want, see the discussion of the \SortNoop command on page 404. Also, since BIBTEXcounts an entire special character as just one letter, you can force extra characters inside labels.

13.5.3 Abbreviations in BIBTEX


(L143-44)
BIBTEX text fields can be abbreviated. An abbreviation is a string of characters starting with a letter and not containing a space or any of the following ten characters:

entries, but they should Abbreviations can be used in the text field of BIBTEX not be enclosed in braces or quotation marks. If cacm stands for
Communications of the ACM

then the following two ways of specifying the journal field are equivalent:
journal = "Communications of the ACM" journal = cacm

You can define your own abbreviations with the @STRINGcommand in a .bib file, as shown below.
QstringCAW QSTRING{CACM
= "Addison--Wesley Publishing Company")
=

"Communications of the ACM")

13.5 The General Format of the .bib File


@String{pub-AW @String{pub-AW: adr QStringCTUG QString{TlJG:adr
= {{Ad\-di\-son-Wes\-ley)))
=

403

"Reading, MA, USA")

= It\TeX{) Users Group") = {Providence, RI, USA))

The case of the name for an abbreviation is not important, thus CACM and cacm are considered identical, but BIBTEXproduces a warning if you mix different cases. Also the @STRING command itself can be spelled as all lowercase, all uppercase, or a mixture. The @STRING commands can appear anywhere in the .bib style, but an abbreviation must be defined before it is used. It is good practice to group all @STRING commands at the beginning of a .bib style, or place them in a dedicated .bib style containing only a list of abbreviations. The @STRING commands defined in the .bib file take precedence over definitions in the style files. You can concatenate several strings (or @STRING definitions) using the concatenation operator #. Given the following,

you can easily construct nearly identical journal fields for different entries:
@article(tub-86, journal = TUB # 1986,

. . .

@article(tub-87 journal = TUB # 1987,

Most bibliography styles contain a series of predefined abbreviations. As a convention, there should always be three-letter abbreviations for the months: j an, f eb, mar, etc. You should always use these three-letter abbreviations for the months, rather than spelling them explicitly. This assures consistency inside your bibliography. Information about the day of the month is usually best included in the month field, e.g., making use of the possibility of concatenation:
month = apr # "-1,

Names of popular journals in a given application field are also made available as abbreviations in most styles, and you should consult the documentation associated with the bibliographic style in question. You can easily define your own set of journal abbreviations by putting them in @STRING commands in their own data base file and listing this data base file as an argument to LATEX'S \bibliography command.

404

Bibliography Generation

13.5.4 A BIBTEXPreamble
BIBTEX also offers a @PREAMBLE command with a syntax similar to the one for @STRING except that there is no name or equals sign, just the string. For example:
@preamble{ "\newcommand{\SortNoop) [I] " # "\newcommand{\OneLetter) [I] {#I) # "\newcommand{\SwapArgs) [21{#2#1)

"
"

You can see how the different command definitions inside the @PREAMBLE are concatenated using the # symbol. The standard styles output the argument of the @PREAMBLE literally to the .bbl file, so that the command definitions are available when W X reads the file. For instance, the \SortNoop command defined above can be used to guide BETEX'Ssorting algorithm. The latter normally does an acceptable job, but somedecision by specifying your own sorttimes you might want to override BIBTEX'S ing key. This trick can be used with foreign languages, which have different sorting rules from English, or when you want to order the various volumes of a book in a way given by their original date of publication and independently of their re-edition dates. Suppose that the first volume of a book was originally published in 1986, with a second edition in 1991, and the second volume was published in 1990. Then you could write:
volume=l, year = "{\SortNoop{86))1991"

. . .
volume=2, year = "{\SortNoop{90))1990"

According to the definition of \SortNoop, L A T E X throws away its argument and ends up printing only the true year for these fields. For BETEX \SortNoop is an "accent" and it will sort the works according to the numbers 861991 and 901990, placing volume 1 before volume 2, just as you want.

13.5.5 Cross-References
BIBTEX entries can be cross-referenced. Suppose you specify \cite(Wood: color) in your document, and you have the following two entries in the data base file:
@Inbook{Wood: color, author = {Pat Wood), crossref={Roth:postscript) , title = {Postscript Color Separation), pages={201--225)) @Book{Roth:postscript, editor = {Stephen E. Roth), title= {{Real World Postscript)) , booktitle={{Real World ~ostscript)), publisher=AW , address=AW:adr , year=1988, ISBN={~-201-06663-7))

13.6 Detailed Description of the Entries

40 5

The special crossref field tells BIBTEX that the Wood: color entry should inherit missing fields from the entry it cross-references-Roth: postscript. BIBTEX automatically puts the Roth: postscript entry into the reference list if it is cross-referenced by two or more entries on a \cite or \nocite command, even if the Roth:postscript entry itself is never the argument of a \cite or \nocite command. So Roth:postscript will automatically appear on the reference list if one other entry besides Wood: color cross-references it. A cross-referenced entry must occur later in the data base files than every entry that cross-references it. Thus, all cross-referenced entries could be put at the end of the data base. Cross-referenced entries cannot themselves crossreference another entry. You can also use L A T E X S ' \cite command inside the fields of your BETEX entries. T h s can be useful if you want to reference some other relevant material inside a note field:
note = "See Eijkhout-\cite{Eijkhout:1991} for more details"

However, you should be aware of the fact that such usage may mean that you need additional L A T E X and BIBTEX runs to compile your document properly. This will happen if the citation put from BETEX into the .bbl file refers to a key that was not used in a citation in the main document. Thus, B Q X is unable to resolve this in the following run.

13.5.6 Some Further Remarks


Entries with identical sort keys will appear in citation order. The bibliography styles construct these sort keys, whch usually consist of the author information followed by the year and title. %X's comment character % is not a comment character inside .bib data base files. In general, if you want to keep BETEXfrom changing something to lowercase, you should enclose it in braces. Note that this will not be sufficient when the first character after the left brace is a backslash (see page 401).

13.6 Detailed Description of the Entries


As discussed in section 13.2, you must describe each bibliographic entry as belonging to a certain class, with the information itself tagged by certain fields. So the first thing you have to decide is what type of entry you are dealing with. Although no futed classification scheme can be complete, with a little creativity you can make BETEX cope reasonably well with even the more bizarre types of publications. For nonstandard types, it is probably wise not to attach too much importance to BIBTEX'S warning messages (see below).

406

Bibliography Generation Most BETEX styles have thirteen entry types, which are shown in table 13.2 on page 408. These different types of publications demand different kinds of information; a reference to a journal article might include the volume and number of the journal, which is usually not meaningful for a book. Therefore, different data base types have dflerent fields. In fact, for each type of entry, the fields are divided into three classes: required Omission of the field will produce a warning message and, possibly, a badly formatted bibliography entry. If the required information is not meaningful, you are using the wrong entry type. However, if the required information is meaningful but, say, already included in some other field, simply ignore the warning. optional The field's information will be used if present, but you can omit it without causing formatting problems. Include the optional field if it can help the reader. ignores any field that is not required or ignored The field is ignored. BIBTEX optional, so you can include any fields in a . b i b file entry. It is a good idea to put all relevant information about a reference in its . b i b file entry, even information that may never appear in the bibliography. For example, the abstract of a paper can be entered into an a b s t r a c t field in its . b i b file entry. The . b i b file is probably as good a place as any for the abstract, and there exist bibliography styles for printing selected abstracts (see the abstract bibliography style mentioned in table 13.1 on page 377). Table 13.2 on page 408 describes the standard entry types, along with their required and optional fields, as used by the standard bibliography styles. The fields w i t h each class (required or optional) are listed in order of occurrence in the output. A few entry types, however, may perturb the alphabetic ordering slightly, depending on what fields are missing. The meaning of the individual fields is explained in table 13.3 on page 409. Nonstandard bibliography styles may ignore some optional fields in creating the reference. Remember that, when used in a .bib file, the entry-type name is preceded by an Q character (see also figure 13.4 on page 381). In addition to the fields listed in table 13.2, each entry type also has an optional key field, used in some styles for alphabetizing, for cross-referencing, or for forming a \bibitem label. You should include a key field for any entry whose author information is missing. The author information is usually the author field, but some styles use the e d i t o r or organization field. A situation where a key field is useful is the following:
organization = "The Association for Computing Machinery", key = "ACM"

(L144-46)

13.7 Understanding BBTEX Styles


Without the key field, the alpha style would construct a label from the first three letters of the Information in the organization field; and although the style file will strip off the article "The,"you would still get a rather uninformative label like "[Ass86]." The key field above yields a more acceptable "[ACM86]." We now turn our attention to the fields recognized by the standard bibliography styles. These "standard" fields are shown in table 13.3 on page 409. Other fields, like abstract, can be required if you use one of the extended nonstandard styles shown in table 13.1 on page 377. As nonrecognized fields are styles, you can use this feature to include "comments" ignored by the BIBTEX inside an entry: it is enough to put the information to be ignored inside brackets style. following a field that is not recognized by the BIBTEX As with the names of the entry types in table 13.2 on the following page, the names of the fields should be interpreted in their widest sense to make them applicable in a maximum of situations. And you should never forget that a judicious use of the note field can solve even the more complicated cases.

407

( L 146-47)

13..7 Understanding BJBTEXStyles


This section presents a condensed introduction to the language used in BIBTEX style files. The information should suffice if you want to slightly modify an existing style file. For more details you should consult Oren Patashk's original Styles" [6 51. article: "Designing BIBTEX

13.7.1 A General Description of a BIBTEX Style File


BIBTEX styles use a postfix stack language (like Postscript) to tell BIBTEX how to format the entries to go into the reference list. The language has ten commands, described in Table 13.4 on page 412, to manipulate the language's objects: constants, variables, functions, the stack, and the entry list. BIBTEX knows two types of functions: built-in functions, provided by BIBTEX itself (see table 13.5 on page 413), and user functions, which are defined using either the MACRO or FUNCTION command. You can use all printing characters inside the pair of double quotes delimin general, ignores case differences, it iting string constants. Although BIBTEX, honors the case inside a string. Spaces are significant inside string constants, and a string constant cannot be split across lines. Variable and function names cannot begin with a numeral and may not ignores contain any of the ten restricted characters shown on page 402. BIBTEX case differences in the names of variables, functions, and macros. Constants and variables can only be of type integers or string (Boolean true and false are represented by the integers 1 and 0 respectively).

408
article

Bibliography Generation
An article from a journal or magazine. Required: author,title,journal, year. Optional: volume,number,pages,month,note. A book with an explicit publisher. Required author or editor,title,publisher,year. Optional: volume or number,series,address,edition,month,note.

book

A work that is printed and bound, but without a named publisher or sponsoring institution. Required title. Optional: author,howpublished,address,month,year,note. inbook A part of a book, e.g., a chapter, section or whatever and/or a range of pages. Required author or editor,title,chapter and/or pages,publisher,year. Optional: volume or number,series,type,address,edition,month,note. incollection A part of a book having its own title. Required author,title,booktitle,publisher,year. Optional: editor,volume or number, series,type, chapter,pages, address,edition, month,note. inproceedings An article in a conference proceedings. Required: author,title,booktitle,year. Optional: editor, volume or number, series, pages, address, month, organization, publisher,note. manual Technical documentation. Required title. Optional: author,organization,address,edition,month,year,note. mastersthesis A master's thesis. Required: author,title,school,year. Optional: type,address,month,note. misc Use this type when nothing else fits. A warning will only be issued if all optional fields are empty (i.e., the entire field is empty). Required none. Optional: author,title,howpublished,month,year,note. phdthesis A PhD thesis. Required author,title,school,year. Optional: type,address,month,note. Conference proceedings. proceedings Required title,year. Optional: editor, volume or number, series, address, publisher, note, month, organization. A report published by a school or other institution, usually numbered within a series. techreport Required author,title,institution,year. Optional: type,number,address,month,note. unpublished A document having an author and title, but not formally published. Required author,title,note. Optional: month,year.

booklet

Table 13.2: List of BBTEX'Sentry types as defined in most styles

13.7 Understanding B n f l ~ X Styles


address

409

annot e

author booktitle chapter crossref edit ion

editor howpublished institution journal key

month

note number

organization Pages publisher school series

title type

volume year

Usually the address of the publisher or other institution. For major publishing houses, just give the city. For small publishers, specifying the complete address might help the reader. An annotation. Not used by the standard bibliography styles, but used by others that produce an annotated bibliography (e.g., annote). The field starts a new sentence and hence the first word should be capitalized. The name(s) of the author(s),in BIBTEX name format (section 13.5.2). Title of a book, part of which is being cited (section 13.5.2). For book entries use the title field. A chapter (or section or whatever) number. The data base key of the entry being cross-referenced (section 13.5.5). The edition of a book, e.g., "Second." This should be an ordinal, and should have the first letter capitalized, as shown above; the standard styles convert to lowercase when necessary. Name(s) of editor(s), in BIBTEX name format. If there is also an author field, then the editor field gives the editor of the book or collection in which the reference appears. How something strange has been published. Institution sponsoring a technical report. Journal name. Abbreviations are provided for many journals (section 13.5.3). Used for alphabetizing, cross-referencing, and creating a label when the author and editor information are missing. This field should not be confused with the key that appears in the \cite command and at the beginning of the data base entry. The month in which the work was published or, for an unpublished work, in which it was written. For reasons of consistency the standard three-letter abbreviations jan, f eb, mar, etc. should be used (section 13.5.3). Any additional information that can help the reader. The number of a journal, magazine, technical report, or work in a series. An issue of a journal or magazine is usually identified by its volume and number; a technical report normally has a number; and sometimes books in a named series also carry numbers. The organization that sponsors a conference or that publishes a manual. One or more page numbers or range of numbers, e.g., 42--111 or 7.41,73--97 or 43+ (here the '+' indicates pages that do not form a simple range). The publisher's name. The name of the school where the thesis was written. The name of a series or set of books. When citing an entire book, the title field gives its title and an optional series field gives the name of a series or multivolume set in which the book is published. The work's title, typed as explained in section 13.5.2. The type of a technical report, e.g., "Research Note." This name is used instead of the default "Technical Report." For the type phdthesis you could use the term "Ph.D. dissertation" by specifying: type = "CPh.D. 1 dissertation. Similarly, for the inbook and incollection entry types you can get "section 1.2" instead of the default "chapter 1.2" with chapter = "1.2." type = "Section." The volume of a journal or multivolume book. The year of publication or, for an unpublished work, the year it was written. Generally it should consist of four numerals, such as 1984, although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as "about 1984."

Table 13.3: List of BIBTEX'S standard entry fields

410

Bibliography Generation
There are three kinds of variables:

Global variables These are either integer- or string-valued, and are declared using an INTEGERS or STRINGS command.
Entry variables These are integer- or string-valued variables, which are declared using the ENTRY command. Each of these variables will have a value for each entry on the list read in a BETEX data base.

Fields These are string-valued, read-only variables that store the information from the data base file. Their values are set by the READ command. As with entry variables there is a value for each entry.

Style File Commands 13.7.2 The BIBTEX


Table 13.4 on page 412 gives a short description of the ten BETEX commands. Although the command names appear in uppercase, BETEX ignores case differences. It is recommended (but not essential) to leave at least one blank line between commands and to leave no blank lines within a command. T h s helps BETEX recover from syntax errors.

13.7.3 The Built-In Functions


Table 13.5 on page 413 gives a short overview of BETEX'S 37 built-in functions (for more details, see [65]).You can see that every built-in function with a letter in its name ends with a $.

13.7.4 The Documentation Style btxbst .doc


Oren Patashnik based the standard BETEX style files abbrv, alpha, plain, and unsrt on a generic file, btxbst .doc, which is well documented and should be consulted for gaining a detailed insight into the worlungs of BETEX styles. In the standard styles, labels have two basic formatting modes, alphabetic, like [Lam84], and Numeric, like 1341. References can be ordered in three ways.

Sorted, alphabetic labels Alphabetically ordered, first by citation label, then by author(s) (or its replacement field), then by year and title. Sorted, numeric labels Alphabetically ordered, first by author(s) (or its replacement field), then by year and title. Unsorted Printed in the order in which they are cited in the text.

13.7 Understanding BIBTEX Styles

41 1

The basic flow of a style file is controlled by the following command lines, which are found at the end of the b t x b s t .doc file:
EXECUTE EXECUTE ITERATE EXECUTE {begin.bib) {init.state.consts) {call. type$) {end.bib)

% % % %

Preamble and \begin{thebibliography} Initialize the state constants Loop over entries producing output Write \end{thebibliography) command

The meaning of these commands should be clear from tables 13.4 on the next page and 13.5 on page 4 13. The code of a style file starts with the declaration af the available fields with the ENTRY declaration and the string variables to be used for the construction of the citation label. Each entry function starts by calling o u t p u t . b i b i t e m to write the \ b i b i t e m and its arguments to the .b b l file. Then the various fields are formatted and printed by function o u t p u t or o u t p u t . check, which handles the writing of separators (commas, periods, \newblock's) as needed. Finally, f i n . e n t r y is called to add the final period and finish the entry. Then follow some functions for formatting chunks of an entry. And there are functions for each of the basic fields, such as f o r m a t . names, which separates names into their "First Von Last, Junior" and separates them by commas and with an "and" before the last (but ending with "et al." if the last of multiple authors is " o t h e r s " ) . There is f o r m a t . a u t h o r s for authors, and f o r m a t . e d i t o r s for editors (it appends the appropriate title: ", editor9'or ", editors") and others. The next part of the file contains all the functions defming the different types accepted in a . b i b file, i.e., functions like a r t i c l e and book. These functions actually generate the output written to the . b b l file for a given entry. They must precede the READ command. In addition, a style designer should provide a function d e f a u l t . t y p e for unknown types. The next section of the b t x b s t .doc file contains definitions for the names of the months and for certain common journals. Depending on the style, the full or abbreviated names are used. It is followed by the READ command, which inputs the entries in the . b i b file. Then the labels for the bibliographic entries are constructed. Exactly which fields are used for the primary part of the label depends on the entry type. The labels are next prepared for sorting. When sorting, the sort key is computed by executing the p r e s o r t function on each entry. For alphabetic labels you might have to append additional "ans, "bns, and so forth to create a unique sorting order, whch requires two more sorting passes. For numeric labels, either the sorted or original order can be used. In both cases, you need to keep track of the longest label for use with the t h e b i b l i o g r a p h y environment. Finally, the .b b l file is written by looping over the entries and executing the c a l l . t y p e $ function for each one.

412

Bibliography Generation

ENTRY {field-list) {integer-variable-list) {string-variable-list) Declares the fields and entry variables. BETEX declares automatically one supplementary field crossref, used for cross-referencing, and an additional string entry variable s o r t . key$, used by the SORT command. There should only be one ENTRY command per style file. For instance, for the styles alpha and plain you have respectively: ENTRY { address author b o o k t i t l e ENTRY { address author b o o k t i t l e EXECUTE Cfunction-name) Executes a single function. EXECUTE {begin.bib) FUNCTION I function-name) {definition) Defines a new function. You cannot change the definition of a FUNCTION outside a style file. FUNCTION {end.bib)
{ newline$

...

...

) {) { l a b e l extra.labe1 s o r t . l a b e 1 ) {) { l a b e l )

"\end{thebibliography)"

write$ newline$ )

MACRO {macro-name) {definition) Defines a string macro. You can change the definition of a MACRO outside a style file. MACRO {f eb) {"February") INTEGERS {global-integer-variable-list) Declares global integer variables. INTEGERS { 1ongest.label.width 1ast.extra.num ) STRINGS {global-string-variable-list) Declares global string variables. STRINGS { longest.labe1 l a s t . s o r t . l a b e 1 n e x t . e x t r a ) ITERATE {function-name) Executes a single function, once for each entry in the list, in the list's current order. ITERATE (1ongest.label.pass) REVERSE {function-name) Executes a single function, once for each entry in the list, in reverse order. REVERSE {reverse.pass) READ Extracts from the data base file the field values for each entry in the list. There should only be one READ command per style file. The ENTRY and MACRO commands must precede READ. SORT Sorts the entry list using the values of the string entry variable sort .key$.

Table 13.4: List of BIBTEX style file commands

13.7 Understanding BIBTEXStyles


31 31 Z1 S1 31 31 22 > 32 <
=

413

S2 = 32 + 22 -

s 1 s 2

(2) (2) (2) (2) (11+32) (31-12) (S1S2) (S.)

L ?I := S add.period$

call. type$ S "tl1 change.case$ (S) S "1" change.case$ (S) S l'ul' change.case$ (S) S chr to.int$ (2) cite$ (cite-string) L duplicate$ (L L) L empty$ (2) S1 2 S2 format .name$ (S) 7 7 1 7 2 if$ 2 int .to.chr$ (S) 3 int .to.str$ (S) L missing$ (2) newline$ S num .names$ (3) L POP$ preamble$ (S) (S) S purify$ quote$ (S) skip$ stack$ S l1 y 2 substring$ (S) 1 1 L2 swap$ (L2 L1) S text.length$ (3) S 3 text .prefix$ (S) L top$ (S) type$ S warning$ 3 1 y2 3 while$ S width$ (3) S write$

1 (if 11>32) or 0 (otherwise) 1 (if 31<32)or 0 (otherwise) 1 (if 21=12) or 0 (otherwise) 1 (if Sl=S2) or 0 (otherwise) add two integers subtract two integers concatenate two strings assign to 1 . 'the value of L adds dot to string if not before '. ', or ' ! ' execute function whose name is the type of an entry, e.g., book convert S to lowercase except at beginning convert S completely to lowercase convert S completely to uppercase . translate single string character to ASCII equivalent push \cite command argument duplicate entry 1 (if L missing field or blank string) or 0 (otherwise) format 3 names S1 according to name specifications S2 execute _T1 if 3>O,else execute 7 2 translate integer into one ASCII character table push string equivalent of integer 1 (if L missing field) or 0 (otherwise) start a new line in the .bbl file number of names in S throw away top element on stack push concatenation of all @PREAMBLE strings read in data base files remove non-alphanumeric characters push double-quote character string do nothing pop and print whole stack substring of S starting at 31 and with a length of 22 swap the literals number of "text" characters front 1 characters of S pop and print top of stack push current entry's type, e.g., book or 1 1 1 1 if unknown pop and print top (string) literal and a warning message execute 3 ' 2 while function value 2 of _T1 has 3>0 push width of S (TEX units) write S to output buffer
I?',

Table 13.5: List of BIBTEX style file built-in functions The built-in functions are preceded by the variable they consume on the stack. If they leave a result on the stack it is shown in parentheses. A "literal" L is an element on the stack. It can be an integer I , a string S, a variable ?I, a function 7, or a special value complains and denoting a missing field. If the popped literal has an incorrect type, BIBTEX pushes the integer 0 or the null string, depending on the function's resulting type.

414

Bibliography Generation

13.8 Introducing Small Changes in a Style File


Often it is necessary to make slight changes to an existing style file to suit the particular needs of a publisher. As a first example, we show you how to eliminate the (sometimes unpleasant) standard BIBTEX style feature that transforms titles to lowercase. In most cases, you will want the titles to remain in the same case as they are typed. Therefore, a variant of style unsrt can be made, and we shall call it myunsrt, since it is different from the original style. Similar methods can be used for other styles. From table 13.5 on the page before you will probably have guessed that function change. case$ is responsible for case changes. Therefore, with the help of an editor and looking for the above string, you will find that it is function format. t i t l e that must be changed. Below we show that function before and after the modification:
FUNCTION {format.title) { title empty$
{
{

"" 1

FUNCTION {format.title) { title empty$


{

""

title "t" change.case$ 1

>

{ title ) % <== modified

if$

if$

1 Before modification

I
After modification With the help of table 13.5 on the preceding page you can follow the logic of the function and the substitution performed. Another function that must be changed in a similar way is format. edition:

FUNCTION {format.edition) { edition empty$


{

"" 1

FUNCTION {format. edition) { edition empty$


{

"" 3

{ output.state mid.sentence = { edition "1" change.case$ { edition "t" change. case$

"
lo

edition" edition"

) )

{ output.state mid.sentence = { edition " edition" I%<== changed { edition l o edition" I%<== changed

* *

>
if$

if$

if$

I
if$

1 Before modification

1 After modification In format. chapter .pages, format. t h e s i s . type and format. t r .number similar changes must be made.

13.8.1 Adding a New Field


Sometimes you may want to add a new field to those already existing. As an example we could add an annotation field. Two approaches can be taken: either the one adopted in style annotate or the one in style annotation. Let us

13.8 Introducing Small Changes in a Stvle File

415

look at the simpler solution first. The style annotation, based on plain, first adds the field annote to the ENTRY definition list, and then the fin.entry function is changed to treat the supplementary field. As seen in the example of the function book, the function fin.entry is called at the end of each function defining an entry type.
F'UNCTION {fin.entry) { add.period$ write$ newline$ F U N C T I O N {fin.entry) { add.period$ write$ newline$ "\begin{quotation)\noindent{\sc Key:\ )" cite$ * write$ annote missing$ ' skip$ { "\\{\sc Annotation:\ 3" write$ annote write$ 3 if$ "\end{quotation~" write$ newline$ 3

Before modification

After modification

You see that after outputting the citation string inside a quotation environment, the annotation text is written following the text "Annotation," which starts a separate line. If the field is absent, nothng is written (the test, annote missing$, takes the skip$ branch of the if$ command). The other style, annotate, based on alpha, takes a more complicated approach. After adding the element annotate to the ENTRY definition list, the function format.annotate is created to format that supplementary field. The function has a decision flow similar to the code shown above.
FUNCTION { f ormat.annotate) { annotate empty$
{ {

"" 3

" \begin{quotation)\noindent annot ate * ' I \end{quotation) *

"

3
if$

1
Then, the formatting routine for each of the entry types of table 13.2 on page 408 has a supplementary line format.annotate write$ just following the call to
fin.entry.

Various style files have added other fields, like the isbn and issn number of a publication (is-abbrv,is-alpha, is-plain,and is-unsrt). The abstract style has three supplementary fields: abstract,keyword,and comment. They are treated in a way similar to annotate above.

416
FUNCTION Cfomat.editors3 C editor empty$
(

Biblioma~hy Generation
FUNCTION Cformat.editors) editor empty$
(

"" 3

"" 3

editor format.names editor num.names$ #I > C " (eds)" * 3 C " (ed.)" * 3 if$

{ editor format.names ", redactie" *

3
if$ 3

3
if$

3
Before modification After modification

Figure 13.16: Adapting a BIBTEX style to Dutch

We can now turn our attention to the custornization of the entries themselves. An interesting example is the chicago style, whch was already mentioned in section 13.1.1. This style is used with various new citation commands, and the bibliography style was adapted to use the recommendations of The Chicago Manual of Style [86]. Another interesting series of styles are authordatel through authordate4 by David Rhead. They implement many of the recommendations of British Standards B S 1629 and B S 5605, Cambridge and Oxford University Press, as well as of The Chicago Manual of Style. The files show clearly where changes have been introduced, so they are worth studying to see how stylistic modifications are made in general.

13.8.2 Foreign Language Support


If you want to adapt a BIBTEX style to languages other than English, you will, at the very least, have to translate the hard-coded English strings in the BBTEXstyle files, like "edition" in the example at the beginning of this section. First you should edit a style file and introduce the new terms in the necessary places. As you are worlung with only one language, it is possible to introduce the proper language-specifictypographic conventions at the same time. An example of this approach is the nederlands style by Werenfried Spit. It is a hatvard based style adapted to Dutch following the recommendations of Van Dale (1982). We shall now look at a couple of examples of functions that were adapted. As you can see in figure 13.16 in Dutch one does not make the distinction between one or more.edit0r.s. The generic Dutch word r e d a c t i e replaces the two possibilities. Figure 13.17 on the next page shows how, for one particular language, you can go rather far in the customization (in form and translation) of an entry, in this case the format of the edition field. In this example, up to the third edition, Dutch specific strings are used. Starting with the fourth edition the generic string ieis used, where i is the number of the edition. You can also see

13.8 Introducing Small Changes in a Style File

417

FUNCTION {format.edition) { edition empty$


{

FUNCTION {format.edition) { edition empty$


{

"" 3
output.state mid.sentence = { edition "1" change.case$ " edition" { edition "too change.case$ " edition" if$

"" 1

)
)

1
if$ 3

edition "1" = { "Eerste" ) { edition "2" = { "Tweede" ) { edition "3" = { "Derde" ) { edition " $ { \ m a t h r m { e ) ) $ if$

"

3
if$ 3 if$ output.state mid.sentence = { "1" change.case$ " druk" { "t" change.case$ " druk" if$ 3 if$

* *

3 3

Before modification

After modification

Figure 13.17: Customizing a BETEX style file for a different language the nesting of the i f $ statements and the use of the case changing command
change. case$.

Of course, the strings for the names of the months should be changed and some other language specific strings can be defined.
MACRO {ja n ) C"januari"3 MACRO { f eb3 { " f ebruari") MACRO { m a r ) {"maart")

.. .

MACRO MACRO MACRO MACRO

...

{ U v A ) { R U G ) { R U L ) {TUD)

{"Universiteit van Amsterdam") {"Rijksuniversiteit te Groningen") {"Ri jksuniversiteit te Leiden") {"Technische Universiteit Delft") {'4Nederlands tijdschrift voor natuurkunde")

MACRO { N T N )

Then, of course, the sorting routine for the names, s o r t . format. names, must know about the specific language dependent rules for showing names in the right order. Also, most languages have articles or other short words which should be ignored for sorting titles.

418
FUNCTION {sort. f ormat.title)

Bibliography Generation
FUNCTION Csort.format.title) C 't := I ' D e ll #3 "Een lo #4 t chop.word chop.word sortify #1 global.max$ substring$ 3

't := "A " #2

#3 "The " #4 t chop.word chop.word chop.word sortify

ttAn

I1

Before modification

After modification

Figure 13.18: Ignoring articles in BETEX sorting Variables


ENGLISH FRENCH GERMAN ABBRV ALPHA PLAIN UNSRT

abbrv fabbrv gab brv

alpha falpha galpha

plain fplain gplain

unsrt funsrt gunsrt

Table 13.6: The BETEX style files of the Delphi system As seen in figure 13.18 it is the chop.word function that chops the word specified from the string presented on the stack-in this case the definite (De) and indefinite (Een) articles. A more general approach was taken by the Delphi Group Worg Heitkoetter and colleagues) of the University of Dortmund (Germany). For their Delphi Bibstyles collection, they have added in the generic b t x b s t .doc file conditional code, which is activated by supplementary preprocessor variables. They have versions for English, French, and German, from which they can generate the style files shown in table 13.6. If you want to add more languages to this system, then the b t x b s t .doc file must be augmented with the necessary control variables and language-specific strings. With h s BETEX "adaptable" family, Hans-Hermann Bode of the University of Osnabriick has taken a road somewhat slmilar to the Babel system discussed in section 9.2. In h s adaptation, he parameterizes the language dependent strings, so that the language dependent data can be kept in a file separate from the BETEX style [13]. He also takes the file b t x b s t .doc as a basis, and replaces the fixed English text strings by control sequences. The values for these command sequences can be defined for each supported language. Currently, only English and German are supported. Switching languages is not the same as with the Babel system, but it should not be difficult to provide such an interface. Although both these systems do good jobs for specifying the language dependent strings, they do not go as far as the style nederlands, discussed above.

13.9 makebst-Customizing Bibliographic Style Files

419

In particular, they do not pay any attention to problems of punctuation or to sorting specificities, but they do provide an automatic translation for foreign language terms.

13.9 makebst -Customizing Bibliographic Style Files


The makebst T E X program, written by Patrick W. Daly, together with a generic bibliographc style file, can produce custom-made .bst BETEX files. The precise format of the bibliographc entities can be specified interactively, and the resulting output file can be processed by DOCSTRIPto generate the desired BETEX style file (see section 14.3 for a description of the DOCSTR~ program). Technically spealung, a BETEXbibliographic style file master contains alternative coding that y choosing a given entry from the interactive depends on DOCSTRIP options. B menu (see the example below), some of this code is activated, thus providing the necessary customization.

13.9.1 Running makebst


The example shows the beginning and final part of a TEX run with the makebst system. After the DOCSTRIP run at the end you will obtain a BETEX style file (mytest.bst in the example) that implements the style parameters you specified for your bibliography.
tex makebst This is TeX, C Version 3.141 (makebst .tex

................................... * This is Make Bibliography ...................................

Style

It makes up a docstrip batch job to produce a customized .bst file for running with BibTeX Do you want a description of the usage? (NO)

Enter the FULL name of the MASTER file (def=genbst.mbs)

Name of the final OUTPUT .bst file? \ofile=mytest.bst Give a comment line to include in the style file. Something like for which journals it is applicable.

420

Bibliography Generation
\ans=Test of the generic bst making program makebst (genbst.mbs STYLE OF CITATIONS: (*) Numerical as in standard LaTeX (a) Author-year with some non-standard interface ( c ) Cite key (special for listing contents of bib file) Select : \ans=a YOU-have selected: Author-year AUTHOR-YEAR SUPPORT SYSTEM: (*) Natbib for use with natbib.sty (1) Apalike for use with apalike.sty (h) Harvard system with harvard.sty (a) Astronomy system with astron.sty (c) Chicago system with chicago.sty (d) Author-date system with authordatel-4.sty Select : \ans=h YOU-have selected: Harvard ORDERING OF REFERENCES: (*) Alphabetical by all authors (1) By label (Jones before Jones and James before Jones et all Select :

.....

Many more q u e s t i o n s and answers

....

Finished!! Batch job written to file 'mytest.drv' Shall I now run this batch job? (NO)

\P=Y (a.drv (/usr/local/lib/tex/macros/docstrip.tex Utility: 'docstrip' 2.0r <92/08/17> English documentation <92/08/17>

.......................................................... * This program converts documented macro-files into fast * * loadable files by stripping off (nearly) all comments! * ..........................................................
Generating file ./mytest.bst Processing File genbst.mbs (ay,har,seq-lab,nm-rev,nmlm,x3,m3,nmft-sc, dt-beg,yr-par,tit-it,atit-u,volp-com,edby,blk-com,pp) -> mytest.bst

CHAPTER

14

L A T E X Package File

Documentation Tools
In this chapter we describe the doc package, which allows you to maintain your L A T E Xpackages in an easy way. The principle is that W X code and comments are mixed in the same file and that the documentation or the stripped package file(s) are obtained from the latter in a standard way. We shall explain the structure that these files should have, and show how, together with the program DOCSTRIP, you can build self-installing procedures for distributing your WQX package(s) and generating the associated documentation.

14.1 Documenting Package Files


The idea of integrated documentation was employed by Donald Knuth when he developed the TEX program using the WEB system, which combines Pascal-like meta source code and documentation. Thanks to t h s , it was particularly easy to port TEX and its companion programs to practically every computer platform in the world. More recently, the authors of W&X packages have also started to realize the importance of documenting their W X code, and many are now distributing their J4TpX macros using the framework defined with the doc package (by Frank Mittelbach) and its associated DOCSTRIP utility (by Johannes Braams, Denys Duchier, and Frank Mittelbach). This system allows L A T E X code and documentation to be held in one and the same TEX source file. The obvious advantage is that a sequence of complex TEX

422

UTFX Package File Documentation Tools

instructions become easier to understand with the help of comments inside the file. In addition, updates are more straightforward as only a single source file needs to be changed. All you have to do is to run an "installation file" through IK&X and all the necessary files will be automatically generated and ready to use, including the documentation. By understanding the basics of the doc system, it will also be possible for you to collect all files relating to one of your packages in a single file, including its documentation. This packaged file, together with an accompanying installation file, can then be sent easily to any destination.

14.2 The User Interface for the doc Package


14.2.1 General Conventions
A IK@X file to be used with the doc system consists of documentation parts

intermixed with definition parts. Every line of a documentation part starts with a percent sign (%) in the first column. It can contain arbitrary TEX or W X commands except that the % character cannot be used as a comment character. User comments are possible by using the --A character. Longer text blocks can also be turned into comments by surrounding them with %,\iff alse ... % \f i. All other parts of the file are called definition parts. They contain (sections of) the macros described in the documentation parts. When reading the package file, W X bypasses the documentation parts at hlgh speed, pasting the macro definitions together, even if they are split into several definition parts. On the other hand, if you want to produce the documentation of the macros, then the definition parts should be typeset verbatim. This is achieved by surrounding these parts by the macrocode environment. More exactly, before a definition part there should be a line containing:

and after this part a line

It is mandatory that you put exactly four spaces between the % and
\endCmacrocode).

Inside a definition part all TEX commands are allowed; even the percent sign can be used to suppress unwanted spaces at the end of lines.

14.2 The User Interface for the doc Package

423

Instead of the macrocode environment you can also use the macrocode* environment, which produces the same results except that spaces are printed as characters when the documentation is printed.

14.2.2 Describing New Macros and Environments


If you want to indicate at a given point in your document that you are explaining a new macro, you should use the command \DescribeMacro.

I \DescribeMacro{macro

name)

It takes one argument, which will be printed in the margin and which will also produce a special index entry, e.g.,:
% \DescribeMacro~\DocInput~\DescribeMacro{\IndexInput) % Finally the \meta{input commands) part ...

A sirmlar macro, \DescribeEnv, can be used to indicate that a L A T E X environment


is being explained. To describe the definition of a new macro, you use the macro environment.

It has one argument: the name of the new macro. This argument is also used to print the name in the margin and to produce an index entry. Actually, the index entries for usage and definition are different to allow for easy reference.
% \begin{macro){\MacroTopsep) Here is the default value for the \verb+\MacroTopsep+ % % parameter used above. % \begin{macrocode)
\newlength{\MacroTopsep) \setlength{\MacroTopsep>{7pt % \end{macrocode) % \end{macro)
plus 2pt minus 2pt)

For documenting environments that are defined with \newenvironment the environment environment can be used. This works like macro but expects the name of an environment as its argument.

424

W X Package File Documentation Tools

14.2.3 Cross-ReferencingAll Macros Used


Inside a macrocode or macrocode* environment, index entries are produced for every command name. In this way you can easily find out where a specific macro is used. Since TEX is considerably slower when it has to produce such a bulk of index entries you can turn off this feature by using \Disablecrossrefs in the driver file. To turn it on again, just use \Enablecrossrefs. Production (or not) of the index (via the Makelndex program) is controlled by using or omitting the following declarations in the driver file preamble (if neither is used, no index is produced). Using \PageIndex makes a l l index entries refer to their page number; with \CodelineIndex,index entries produced by \DescribeMacro and \DescribeEnv refer to page number, but those produced by the macro and macrocode environments refer to the code lines, whch will be numbered automatically.

14.2.4 Producing the Actual Index Entries


Several of the macros mentioned above will produce index entries. These entries have to be sorted by an external program, such as Makelndex (see chapter 12). You need to run Makelndex and specify its -s switch (see section 12.4.1 on page 358) with a suitable style, like gind. ist,which comes with the doc system. To read and print the sorted index, you must put the \PrintIndex command at the end of your documented package file, possibly preceded by bibliography commands, as needed for your citations.

14.2.5 Additional Bells and Whistles


You can divide the documented file with your package into two parts, one containing a general description and a second giving a detailed description of the implementation of the macros. In general, you might want to give the user the ability to suppress this latter part.

This is achieved by placing the command \StopEventually at the division point between the two parts discussed above. T h s macro has one argument in which you put all the information you want to see printed if your document ends at this point (for example, a bibliography which is normally printed at the very end). When the \OnlyDescription declaration is given in the driver file, L A T E X will process the argument and then stop reading the file. Otherwise the \StopEventually macro saves its argument in a macro called \Finale,which can afterwards be used to get things back (usually at the very end). Using this scheme makes changes in two places unnecessary.

14.2 The User Interface for the doc Package

To document the change history, the \changes command can be placed amongst the description part of the changed code.

The information in the \changes command may be used to produce an a m iliary file (LATEX'S\glossary mechanism is used for this), whch can be printed after suitable formatting. To cause the change information to be written, include \Recordchanges in the driver file. To read and print the sorted change history, just put the \Printchanges command at a suitable point in your package file. To generate the sorted file containing the changes, you should run the raw glossary file through MakeIndex using an adequate style (Ilke gglo .ist, supplied with the doc distribution; see section 12.4.6 on page 364 for more information about how MakeIndex treats glossaries).

When you have to quote a lot of material verbatim, such as command names, it is awkward to always have to type \verb+. . . +. Therefore, the doc package provides an abbreviation mechanism that allows you to pick a character c,which you plan to use only very rarely inside your document, and use it to delimit your verbatim text (the character " is often chosen, but if that character is already used for another purpose, like for generating umlauts, then you may prefer "I"). Then, after including the command \MakeShortVerbC\c), the sequence ctext c becomes the equivalent of \verbc text C. If you later want to use c with its original meaning, just type \Deleteshortverb \el. You can repeat this sequence using c as a shorthand for \verb and reverting to its original meaning as many times as needed. Note that the abbreviated cform, just like \verb itself, cannot appear in the argument of another command, but it may freely be used inside verbatim and macrocode environments. Table 14.1 on page 429 gives an overview of all doc user commands.

14.2.6 The Driver File


To get the documentation for a set of macros with the doc system you have to prepare a driver file with the following characteristics:
\documentclass [options I {document-class } \usepackage{doc) preamb be \begin{document) input commands \end{document)

426

I4-X

Package File Documentation Tools

\documentclassCarticle) \usepackage(doc> \Enablecrossrefs \CodelineIndex \Recordchanges \setlength{\parindent>{Opt) \begin<document> \DocInput{docexam.dtx) \endCdocument)

% % % % %

Include doc package full index by line numbers make change history no indents \Printchanges

\PrintIndex

Figure 14.1: doc driver file example

The document class may be any legal class, e.g., article. In the preamble, you should place declarations that manipulate the behavior of the doc system like
\DisableCrossrefs,\OnlyDescription,\CodelineIndex,andsoon.

Finally, the input c o m m a n d s part should contain one or more \DocInput {file name) and/or \IndexInput(file name) commands. The \DocInput command is used for files prepared for the doc system, whereas \IndexInput can be used for all kinds of macro files. It takes a file name as argument and produces a verbatim listing of the file, indexing every command as it goes along. This might be handy if you want to learn something about macros without enough documentation. When used to cross-referencethe file latex. tex,which contains the basic command definitions for W X ,you will get a verbatim copy of the approximately 8800 lines of code and comments, plus an index of about 15 pages. It is also possible to use \PrintIndex and \Printchanges (if the changes are recorded by \RecordChanges) commands. But they may also have already been issued in the file being processed.

14.2.7 A Simple Example of a File Documented with doc


To illustrate the use of the commands discussed in the previous sections, a driver file docexam. drv (figure 14.1) for generating the documentation of an input file docexam.doc (figure 14.2 on the next page), which is documented using the doc system, is shown. You should run the driver file thought W X once, then generate the index and glossary with Makelndex before running the file once more through W&X, to obtain the documentation shown in figure 14.3 on page 428.
latex docexam.drv makeindex -s gind.ist docexam makeindex -s gglo.ist -0 docexam.gls docexam.glo latex docexam.drv

14.2 The User Interface for the doc Package

B 2

; ;. *
W

- 9 D r

z x fp

3
0
Y

WNX d r .d v .d m Yrl U dUJZ .d L . .rl

"
w
.A

' m
.d my, w r

: : r "$
K

e
h

Z
w a r m

a3

w .d r'
Y /
.rl

. r l

5 $,?
W

s e w 01' r

- 0 d Ti Y .d d

!2 3 ii: *

a m m

d m .d

>.4 WLI 5 p
;;$;

w o " d

z<

B S > a
w m

2 v
w

gz
d h MU

-.

32

5
o

sa ?Po
O d

2% f5
r d d.4

ka
d m w9 r l w
>.A

&$
a m 9 h 0 0 0 W A U O X a Y

j 5:

.dAU 0 O h r r o p o w S a g a . 4 )r W d 0 .rl v ~ m a m m.4

0 w e d .d r .d v wmw

5: z

* p

* PBJBiAS
. r l

Q,:

,,.ass8 m
M Y

I ! : k

2.29 $ $ 5 w w z r RR

M d w r r d

i
.A

* d . m 1 1 0 * 8 .d rEW.rlU0 2"El'2$5.2

;sGs e
rl 3

9 9 % 2'
SSSS3

d.d 0 w . 4 r d w h > K WY wa.d/a w / a w > o r d

w r

5 98

a a .d.d

m a

SSSS?

References

Illustrating doc with docexam


All of us November 28, 1993
Abstract This ts an example of a package documented using BTS's doc system [I].

[I1 M.Goossens, F. Mittelbach. and A. Samarin TheBT$Componion. Wesley.

1994. Addison-

Index
The italic numbers denote the pages where the corresponding entry is described. numbers underlined point to the definition, all others indicate the places where it is used.

1 Introduction
This package does nothing useful, but serves as a simple example of how to document your packages using 14TS's d o c system.

\docdate . . . . . . . . . 2 \docsamplecmd . . . 1.2 docsampleenv (envi-

ronment) . . . . 1.9

E
\end

.............

2 The user interface


This section defines everything an average user should know. Note the use of the " I " character as shonhand for \verb,and how we switch back and fonh between its two possible meanings. The command \ d o c s a m p l e c m d will print the text specified as argument in a small caps typeface, prepended by the string "doc :". The environment d o c s a m p l e e n v will print the text bracketed inside the environment as quoted and italicized text, preceded by a line containing Nice, you are using doc.

environments:
docsampleenv

.1 . 4

Change History
v1.0 "General": First release . . . . . . . I "2.0 "General": humentation added . I

\docsamplecmd docsampleenv

v2.1
"General": Minor corrections and

additions

.................

3 The code
We begin by identifying the version of this file on the terminal and in the transcript file.
I\typeout(Package 'docexam' \fileversion\space<\filedate>) 2\typeout(English dacumentation\space\space\~pace<\docdate>] \docsamplecmd

We prepend the text d o c and switch to a small caps font.


3\newcommand~\docaamplecmd) [ll(\texttt(doc)\textsc(#l)l

docsampleenv

We print a line in bold, then specify a q u o t e environment.


4\newenvironmentldocsampleenvl~\begin~guote]\item 5 \textbf(Nice, you are using doc!l\par\itshape)(\end(quotell

Figure 14.3: Documentation generated for the example showing the use of the doc system

14.2 The User Interface for the doc Package

429

Table 14.1: Overview of doc package commands

Preamble and input commands


\CharacterTable{character table) User interface to character table checking. See example in figure 14.6 on page 437. \CheckSumCchecksum) User interface to set the checksum of the document (number of backslashes in the code). \CheckModules Format module directives of DOCSTRIP specially (default). \CodelineIndex Index commands using code line numbers. \CodelineNumbered Number code lines but don't index commands. \Disablecrossrefs Don't produce index entries for commands within the code. \ ~ o c I n p u{file) t Read in file assuming doc conventions. \DontCheckModules Don't format module directives of DOCSTRIP specially. \Enablecrossrefs Produce index entries for commands within the code. \IndexInput {file) Read in file, print it verbatim and produce a command cross-reference index. \OnlyDescription Don't format code; stop at \StopEventually. \PageIndex Index commands using page numbers. \Recordchanges Produce a history listing.

Document structure and validation support


\bslash Command to print a backslash (\). \Deleteshortverb Undoes the previous definition of \Makeshortverb. \DescribeEnv{env) Flags point in text where environment env is described. \DescribeMacro{cmd) Flags point in text where macro cmd is described. \begin{environment)hnv) (environment) Environment surrounding description of environment env.

continued on next page

430

W X Package File Documentation Tools


continued from previous page \Finale Command executed at very end of document (see also \StopEventually). \beginCmacro)Ccmd) (environment) Environment surrounding description of macro cmd. \begin{macrocode) (environment) Environment surrounding the TEX code. \begin{macrocode*) (environment) Same as the macrocode environment, but spaces are printed as characters. \MakeShortVerbCchar) Defines abbreviation character char for \verb. \met aCarg) Prints its argument as a meta sentence (default ( a r g )). \Printchanges Print the history listing here. \PrintIndex Print the index listing here. \SpecialEscapecharCchav) Specifies new single escape character to be used instead of \. \ S t opEventually{cmds) The argument cmds specifies which commands should be executed at the end of the document (they are stored in \Finale). \begin{verbat i m ) (environment) Slightly altered version of BTEX'S standard verbatim environment to surround verbatim text ignoring percent characters in column one. \begin{verbat im*) (environment) Same as the verbatim environment, but spaces are printed as characters.

Index commands
\actualchar Character used to separate "key" and actual index in an index entry (default =). \DoNotIndex{cmdl,. . .,cmd,,) Names of commands which should not show up in the index. \encapchar Character used to separate the actual index and the command to format the page number in an index entry (default I). \IndexMin Length parameter (default 80pt) defining the minimal amount of space that should be left on a page to start an index. \IndexParms Macro controlling the formatting of the index columns. \IndexPrologueCtext) Overwrites default text to be placed on top of index. continued on next page

14.2 The User Interface for the doc Package


continued from previous page \levelchar Character used to separate different index levels in an index entry (default >). \main{ number) Defines formatting style for page numbers or code line number of index entries for major references (default underlined digits). \quotechar Character used to suppress the special meaning of the following character in an index entry (default *). \Sort Index{ key3Centry) Produce index entry for entry, sorting it using key. \SpecialEnvIndex{entry) Produce index entry for environment entry. \SpecialIndex{cmd) Produce a command index (printing the argument verbatim in the index). \SpecialMainIndex{cmd) Produce a command index with \main page encapsulator. \SpecialUsageIndex{cmd) Produce a command index with \usage page encapsulator. \usageCnumber) Defines formatting style for page numbers of index entries for usage descriptions (default italic digits). \verbat imchar Character used to delimit \verb constructs within an index entry (default +).

43 1

History information \changesCversion)Cdate)Creason)


Records history information for use in a history listing. \docdat e By convention holds the date of the most recent documentation update. \f i l e d a t e By convention holds the date of the most recent code update. \filename By convention holds the name of the source file. \fileversion By convention holds the version number of the source file. \GlossaryMin Length parameter (default 80pt) defining the minimal amount of space that should be left on a page to start the change history. \GlossaryParms Macro controlling the formatting of the change history columns. \GlossaryPrologue{text) Overwrites default text placed on top of history listing. continued on next page

432
continued from previous page

LATX Package File Documentation Tools

Layout and typesetting parameters


\*
Symbol used in index entries to refer to a higher level entry (default \@idxitern Macro specifying how index items should be typeset (by default they are set as a paragraph with a hanging indentation of 30pt for items requiring more than one line). \AltMacroFont Font used to typeset DOCSTW module code (default with NFSS is \small\sl\tt). \DocstyleParms Macro controlling the formatting of the TEX code. \MacroFont Font used to typeset the main part of the code (default \small\tt). \MacroIndent Width of the indentation for every code line. \MacroTopsep Vertical space above and below each macro environment. \MacrocodeTopsep Vertical space above and below each macrocode environment. \MakeprivateLettem Macro specifying symbols to be considered as letters (default only 0). \Module Macro with one argument defining the formatting of DOCSTRIP module directives. \PrintDescribeEnv Macro with one argument defining the formatting of \DescribeEnv. \PrintDescribeMacro Macro with one argument defining the formatting of \DescribeMacro. \PrintMacroName Like \PrintDescribeMacro but for the argument of the macro environments. \ps@titlepage Macro specifying page style for the title page of articles bundled in a journal (default \ps@plain). StandardModuleDepth Counter holding the highest level of DOCSTW directives which are still formatted using \MacroFont. Deeper nested directives are formatted using \AltMacroFont. \theCodelineNo Controls the typesetting of the line numbers (default script-size arabic numerals).
I-').

14.3 The DOCSTRIP Utility


Basically the DOCSTRIP utility removes nearly all lines that begin with a percent sign, and supports conditional processing of code by including parts of the file only when some condition is true. It also lets you produce a single IPQX macro

14.3 The DOCSTRIP Utilitv

433

file from several files or split the source file into several smaller files. can be run interactively by processing docstrip. tex with B&X:
latex docstrip.tex

DOCSTRIP

W X will ask a few questions about how to process a given file. When the user has answered these questions, DOCSTRP does its job and strips the comments from the source. However, it is more convenient to create a "batch file," which contains all necessary instructions for the DOCSTRIP run. The default name for such a file is docstrip. cmd. If a file with such a name exists in the current directory, DOCSTRIP will process it; otherwise it starts an interactive session. An even more user-friendly way is to prepare a driver file, which can be processed directly by W X . In this case the user simply has to say:
latex batch-file

and then this automatically produces all "executables" from some source distribution. The so-called Mainz distributions, i.e., files maintained by Frank Mittelbach and Rainer Schopf, like doc itself, array, ftnright, multicol, theorem, and the NFSSZ system, are distributed in this form. An example of an installation procedure using a simple driver file is discussed in section 14.4. In the next section we discuss input commands that can be used in such a DOCSTRIP batch file. We then explain how to make code fragments in a doc source that can be conditionally included.

14.3.1 Batch File Commands


It is possible to prefix the output of the DOCSTRIP program with some fmed text, such as a copyright notice or your standard disclaimer. The information you want to add to the start of DOCSTRP'S output file should be listed between the \preamble and \endpreamble commands. Lines that you want to add at the end should be listed between the \postamble and \endpostamble commands. Everything that DOCSTRIP finds for both the pre- and postamble is written to the output file, but preceded with two % characters. If you include a --J character in one of these lines, everything that follows it on the same line is written to a new line in the output file without percent signs in front. This feature can be used to add a \typeout or \message to the file stripped by DOCSTRP.

The macro \generateFile instructs DOCSTRIP what to do. The arguments output and input are normal file specifications appropriate for your computer system. The optionlist parameter is a comma separated list of options, specifying

434

m X Package File Documentation Tools

which optional code fragments in the input file should be included in the file output. The argument ask instructs TEX either to silently overwrite a previously existing file (value f ) or to issue a warning and ask if it should overwrite the existing file (value t). It is possible to specify multiple \from commands, i.e., multiple input files, each with its own optionlist. To make a DOCSTRIP driver file that can be directly processed by W&X, you should start it with the following two lines:
\def \batchf ileC<batch-file-name>) \input docstrip. t e x

\batchfile Batch file commands can be put into several batch files. The latter are then executed from a master driver file. This practice is useful, for example, when a distribution consists of several distinct parts that are kept in individual files. A master file then simply calls the batch files for the parts using the command \batchinput. You cannot use the command \input because the latter is reserved to call the DOCSTRIP utility only. If you want to communicate with the receiver of your package the commands \Msg and \Ask can be used. \Msg will display its argument on the terminal. Using \keepsilent in the installation file will suppress most of the output generated by DOCSTRIP during processing, while \showprogress turns it on again. There are a few other commands available-look at the DOCSTRIP documentation for further details. It is in principle possible to write installation files that communicate with the user and do arbitrary complex tasks; however they also might get arbitrarily difficult to write due to the way DOCSTRIP reads a batch file. Look at the installation files of larger packages if you are curious.

14.3.2 Conditional Inclusion of Code


Code fragments for conditional inclusion are marked in the source fde with "tags." The simplest format is a <*tag> and </tag> pair surrounding the piece of the file to be included in output when option tag is present in the optionlist of the \generateFile command. Note that these tags must be preceded by a % at the beginning of the line, e.g.,
%<*style> t e x t or code %</style>

When a block of code is not included, all tags that occur within that block are not evaluated. In general these tags can be any combination or Boolean expression of the options. The I symbol is used for logical or, & for logical and, and ! for negation. An option is considered true if and only if it occurs in the optionlist.

14.4 An Example of an Installation Procedure

435

\def\batchfile{fileerr.ins) \input docstrip.tex \preamble File to exit 'missing file name1 loop in TeX. \endpreamble \generateFileCx.tex) Ct)C\fromCfileerr.dtx)Cexit)) \generateFileCe.tex) Ct){\fromCfileerr.dtx)Cedit)) \generateFileCh.tex) {t){\from(fileerr.dtx)Chelp)) \generateFileCs.tex) ~t~~\fromCfileerr.dtx)Cscroll)) \Msg{**************************************************) \MsgC* I'm now trying to generate a file called '.texl) \Msg{* This may fail on some operating systems) \Msg{**************************************************) \generateFileC.tex) Ct)C\from(fileerr.dtx)Creturn))

Figure 14.4: The batch file for the "file-error" system

14.4 An Example of an Installation Procedure


Many of the larger packages described in this book come in the form of an "installation lut" consisting of an installation batch file and one or more .dtx or .doc files that contain the code for all files and do~umentation.~ Such an installation kit enables you to run the batch file through L A T E X so that the system will automatically unpack a l l the files needed without further intervention. Installation procedures can easily be constructed to generate the needed files and documentation. We shall now show the principle of how this works using a simple example, called the ''file-error" system. It consists of the batch file f ileerr.ins and the .dtx file f ileerr .dtx. Using LATEX and DOCSTRIP, the .dtx is read and several small files are generated. The presence of these little files on your system could prove useful in situations where your users are confused about how to exit the TEXloop when TEXkeeps asking about a file it cannot find, etc. See the description of the file in figure 14.7 on page 438 for additional explanation. First, in figure 14.4 we show the batch file f ileerr .ins,whch first inputs the file docstrip.tex and then generates the needed output file(s)from the file f ileerr .dtx using the command \generateFile. The only thing you have to do is run the above file through U Q X and watch how L A T E X reads the .dtx file f ileerr .dtx and extracts from it all needed files. This sequence of events is shown in figure 14.5 on the next page. The input file itself (f ileerr .dtx)is shown in figure 14.6 on page 437. Finally, to obtain the documentation shown in figure 14.7 on page 438 one has to run f ileerr .dtx through PQX.

.dtx; those that need a driver file have the extension

'BY convention, documentation files that can be directly processed by IATEX have the extension
.doc.

This is TeX, Version 3.141 (C version d) (fileerr.ins LaTeX2e <1994/03/06> PRELIMINARY TEST RELEASE
(/usr2/users/latex3/distrib/inputs/docstrip.tex

Utility: 'docstrip' 2.2f <1994/02/26> English documentation <1994/02/26>

.......................................................... * This program converts documented macro-files into fast * * loadable files by stripping off (nearly) all comments! * ..........................................................
Generating file ./x.tex

File fileerr.dtx ended by \endinput Lines processed: 86 Comments removed: 71 Comments passed: 0 Codelines passed: 6

Generating file ./s.tex Processing File fileerr.dtx (scroll) -> s.tex


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

....
Processing File fileerr.dtx (exit) -> x.tex

% % <+scrolllreturn . > <+scroll . > % % % % % % % % % % % <+editlexit % > % % % % % . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . by \endinput. < * d r i v e r % % % > % % % % % % % % % % % % < * h e l p % % % % % %File % >fileerr.dtx % % % % ended % % % Lines processed: 86 . > % % % % <+scrolllreturn % > <+scroll % > % % % % % % % % % % % <+editlexit Comments removed: 71 % % % Comments passed: 0 File fileerr.dtx ended by \endinput. Codelines passed: 2 Lines processed: 86 Comments removed: 71 . Comments passed: 0 .................................................. Codelines passed: 1 * I'm now trying to generate a file called '.texl t This may fail on some operating systems

< * d r i v e r % % % > % % % % % % % % % % % % < * h e l p % % % % % % % > % % % %

..........................................
Generating file ./.tex

Generating file ./e.tex Processing File fileerr.dtx (edit) -> e.tex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . <*&iver%%%>%%%%%%%%%%%%<*help%%%%%%%>%%%%%%% % % <+scrolllreturn % > <+scroll % > % % % % % % % % % % % <+editlexit % % % File fileerr.dtx ended by \endinput. Lines processed: 86 Comments removed: 71 Comments passed: 0 Codelines passed: 1

. .>
% %

Processing File fileerr.dtx (return) -> .tex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ~*&iver%%%>%%%%%%%%%%%%<+help%%%%%%%>%%%%%%% % % <+scrolllreturn . > <+scroll % > % % % % % % % % % % % <+editlexit % > % % % % % File fileerr.dtx ended by \endinput. Lines processed: 86 Comments removed: 71 Comments passed: 0 Codelines passed: I

...

..
Generating file ./h.tex

....
Processing File fileerr.dtx (help) -> h.tex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
<*driver%%%>%%%%%%%%%%%% . .< .* h . e. l> p% % % .% % % % % % % <+scrolllreturn % > <+scroll % > % % % % % % % % % % % <+editlexit % > % % % % %

Overall statistics: Files processed: 5 Lines processed: 430 Comments removed: 355 Comments passed: 0 Codelines passed: 11
)

No pages of output. Transcript written on fileerr.log.

Figure 14.5: The transcript file when installing the "file-error" system

% % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
%

\def\fileversionCvl.Oc) \def\filedateC1994/04/06) \CheckSumC14) \iffalse This is a METACOMMENT Doc-Source file to use with LaTeX2e Copyright (C) 1993-94 Frank Mittelbach, all rights reserved. \fi \titleCFile not found error\thanks{This file has version \fileversion\ last revised \filedate)) \authorCFrank Mittelbach) \maketitle \sectionCIntroduction) When \LaTeXeO is unable to find a file it will ask for an alternative file name. However, sometimes the problem is only noticed by \TeXC), and in that case \TeXO insists on getting a valid file name; any other attempt to leave this error loop will fail.\footnoteCOn some systems, \TeXC) accepts a special character denoting the end of file to return from this loop, e.g.\ Control-D on UNIX or Control-Z on DOS.) Many users try to respond in the same way as to normal error messages, e.g.\ by typing \meta(return), or Isl or 1x1, but \TeXC) will interpret this as a file name and will ask again. \par To provide a graceful exit out of this loop, we define a number of files which emulate the normal behavior of \TeXC) in the error loop as far as possible. \par After installing these files the user can respond with lhl, Isl, lel, 1x1, and on some systems also with \meta{return) to \TeX's missing file name question. \StopEventuallyC)

\message{!The file name provided could not be found.--J% Use '<enter>' to continue processing,-"JX 'SJ to scroll further errors--J% or ' X ' to terminate TeX) \errmessage{) %</help> % \endCmacrocode) 1 % \subsectionCScrolling this and further errors with C\tt ) s % For the response Isl we put a message into the file Is.texl % and start I\scrollmodel to scroll further error messages in % this run. On systems that allow I.texl as a file name we % can also trap a single \metaCreturn) from the user. % \beginCmacrocode) %<+scrolllreturn> \messageCFile ignored) %<+scroll> \scrollmode % \endimacrocode)
%

\sectionCThe documentation driver) This code will generate the documentation. Since it is the % first piece of code in the file, the documentation can be % obtained by simply processing this file with \LaTeXe. % % \beginCmacrocode) %<*driver> \documentclass{ltxdoc) \begin{document) \DocInputCfileerr.dtx) \end{document) %</driver> % \end{macrocode> % \sectionCThe files) % % \subsectionCAsking for help with C\tt ) ) h % When the user types Ihl in the file error loop \TeXC) will % look for the file Ih.texl. In this file we put a message informing the user about the situation (we use I^-JI to % start new lines in the message) and then finish with a % % normal I\errmessagel command thereby bringing up \TeX's % normal error mechanism. % \beginCmacrocode) %<*help> \newlinechar='\"-J

% \subsection{Exiting the run with {\tt x ) or {\tt e l ) % If the user enters 1x1 or lel to stop \ T e X C ) , we need to put something into the corresponding file which will force % \ T e X { ) to give up. We achieve this by turning off terminal % output and then asking \ T e X { ) to stop: first by using the % % internal \LaTeXC) name I\OQendl, and if that doesn't work because something other than \LaTeXC) is used, by trying the % % \TeX) primitive I\endl. % \beginCmacrocode> %<+editlexit> \batchmode \amend \end % \endmacrocode) We end every file with an explicit I\endinputl which prevents % the docstrip program from putting the character table into % % the generated files. % \begin{macrocode) \endinput % \endCmacrocode) %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z 1% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \ ! Double quote \ " Hash (number) \ # %% Dollar \$ Percent \% Ampersand \& %% Acute accent \ ' Left paren \ Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \Point \ Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \a Left bracket \ C Backslash \\ ./.% Right bracket \I Circumflex \ Underscore \%% Grave accent \ ' Left brace \C Vertical bar \ I %% Right brace \ Tilde \-3 %% % \Finale

Figure 14.6: The source of the doc file for the "file-error" system

%<*help>

6 \newlinechar= ' \^^J

File not found error*


Frank Mittelbach
April 7, 1994

7\message( !The file name provided could not be found.^*J% 8Use '<enter>' to continue processing,^^J% 9 'S' to scroll further errorsA^J% loor 'X' to terminate TeX) I 1 \errmessage() I 2 %</help>

3.2 Scrolling this and further errors with s


For the response s we put a message into the file s . t e x and start \scrollmode to scroll further error messages in this run. On systems that allow .t e x a s a file name we can also trap a single (return) from the user.
13%<+scrolllreturn> \messagelFile ignored) la%<tscroll> \scrollmode

1 Introduction
When !4TjjZc is unable to find a file it will ask for an alternative file name. However, sometimes the problem is only noticed by Td(, and in that case Td( insists on getting a valid file name; any other attempt to leave this error loop will fail? Many users try to respond in the same way as to normal error messages, e.g. by typing (return),or s or x, but T& will interpret this as a file name and will ask again. To provide a graceful exit out of this loop, we define a number of files which emulate the normal behavior of Td( in the error loop as far as possible. After installing these files the user can respond with h, s, e,x, and on some systems also with (mturn) to T&'s missing file name question.

3 3 Exiting the run with x or e


If the user enters x or e to stop we need to put something into the corresponding file which will f o r c e T j to giveup. We achieve this by turning off terminal output and then asking T# to stop: first by using the internal LT@ name \@@end, and if that doesn't work because is used, by trying the T j primitive \end. something other than L ~ E X
15%<+edit l exit>

w,

\batchmode \@@end \end

2 The documentation driver


This code will generate the documentation. Since it is the first piece of code in the file, the documentation can be obtained by simply processing this file with L W Z e .
I %<'driver> 2\documentclass(ltxdoc) 3\begin(document) \DocInputifileerr.dtxl \endldocument) 4 %</driver>

We end every file with an explicit \endinput which prevents the docstrip program from putting the character table into the generated files.
16 \endinput

3 The files
3.1 Asking for help with h
When the user types h in the file error loop T# will look for the file h. t ex. In this file we put a message informing the user about the situation (we use ^"J to start new lines in the message) and then finish with anormal \errmessage command thereby bringingupTH's normal error mechanism.
'This file has venion vl .Oc l a s t revised 1994/M/06 O n some systems.'QX accepts a special characterdenotingthe end of file m rerum fmm this loop. e.g. Control-D on UNIX or Control-2 on DOS.

Figure 14.7: Output generated by running the file f ileerr .dtx through L A T E X

Appendix

A kY&X Overview for

Package and Class Writers

This appendix gives an overview of the basic programming concepts underlying the L A T E X formatter. We explain how to define new commands and environments, including those with an optional argument. We discuss how L A T E Xhandles counters and their representation and introduce horizontal and vertical space parameters and how they are handled. The second section reviews the imporboxes and their use. A good understanding of this topic is tant subject of (LA)TEX very important to fully appreciate and exploit the information presented in this interface that allows you to define book. We then describe in detail the LATEXZ~ your own options for packages and class files. The two package files calc and ifthen make calculations and building control structures with L A T E X easier. They are described in the last two sections and have been used in many examples of L A T E X code throughout this book.

A.l Linking Markup and Formatting


This section reviews the syntax for defining commands and environments with L A T E X . It is important that you exclusively use the W X constructs described below, rather than the lower level TEX commands. Then, not only will you be able to take advantage of WX's consistency checking, but your commands will be portable, (probably)without modification, to future versions of L A T E X .

440

AL A T E X Overview for Package and Class Writers

A. 1.1 Defining New Commands


It is often advantageous to define new commands (e.g., for representing repetitive input strings or recurring combinations of commands). A new command is defined using the \newcommand command sequence, which can have one optional argument, defining the number of arguments of the new command.

( L 55,173)

I \new command{\ name) [nargl (command definition) I


The number of arguments is in the range 0snargs9. If your new command has no arguments, then the [Ol can be omitted. Inside the command definition part, the arguments are referenced as #1 to #narg.
PostScript and its variant Encapsulated PostScript are often used for including graphics information in L A T E X documents . . .
\newcommandC\Ps)CPost\-Script) \newcommand{\EPs)~Encapsulated \PSI \ P s O and its variant \EPs{) are often used for including graphics information in \LaTeXC) documents \ldots

We can generalize the previous example and at the same time enter the relevant information in a consistent way into the index Me.

If a command should work both in math and in text mode, special care should be taken in its definition. For example:
The series of X I , . .. ,x, or x l , . . . , x,

.. .

\newcommand~\xvec)~\rnbox{$xXl, \ldots ,x-n$)) The series of \xvec\ or $\xvec$ \ldots

This is better supported in LATEXZ~, which offers the following command:

I \ensuremath{rnath

code) 1

As the name implies \ensuremath ensures that its argument is always typeset in math mode by surrounding it if necessary with $ signs. Thus, the above example could be shortened to
The series of
XI,.

. . ,x,

or X I , . . . , x,

+ G , ,,.,,,, ,

\newcommand~\xvec){\ensuremath~x~l, \ldots ,x-n)) The series of \xvec\ or $\xvec+G-{\xvec)$

As you can see, this has the additional advantage of producing correctly sized symbols in subscript or superscripts, which is not the case if an \mbox is used in the definition.

A.l Linkhe Marku~ and Formattinrr

441

A command like \xvec could also be defined with an argument:


The series of y l , . .. ,y, or z l , . .. ,z,

.. .

\newcommand{\avec)[1]{% argl: vector name \ensuremath{#l~l,\ldots,#l~n)) The series of \avec{y) or $\avec{z)$ \ldots

The more complete example below defines commands implementing typesetting rules that state that elementary particle name abbreviations should always be in roman type.
The masses of the W-, W+ and Z0 particles are mw and mzo respectively. In general one has m~ > mzo.
\newcommand~\PWm3~\ensuremath~\mathrmCW)-3) \newcommand{\PWp){\ensuremath~\mathrm{W)~+)) \newcommand{\PZz~{\ensuremathC\mathrmCZ)~O~) \newcommand~\PMW~~\ensuremath~m~~\mathrm{W))~~ \newcommand{\PMZ){\ensuremath~m~{\mathrm{Z)~O))) The masses of the \PWm, \PWp\ and \PZz\ particles are \PMW\ and \PMZ\ respectively. \par In general one has \(\PMW > \PMZ\).

Existing commands must be redefined with the command \renewcommand. Note that you can redefine a command with a different number of arguments as the original one. Therefore, you could redefine the \PMW command of the above example, so that it now takes one argument:
In general one has mw+ = mw-.

(L5 7,173)

\renewcommand{\PMW) [I] {% \ensuremath~m~{\mathrm{W)~{#l)))) In general one has \(\PMW{+) = \PMW{-I\).

When redefining a command (or an environment, see below) you must, of course, be cautious since commands which you are planning to redefine might be used in the class or packages you have loaded (try redefining \uppercase in a document that is formatted with the class book). In INEXZ~, you can also define commands so that their first argument is optional. The syntax is:

I \newcommand{\mycom)

[nargl [default] {command definition)

Examples of such command definitions are:

The default for the optional argument is given between the second pair of square brackets, "3"in the first case and "0" in the second. Inside the command definition, the optional argument has the number #I, while the mandatory arguments (when present) are addressed #2 to #narg. Thus, typing \LB is a short

442

A I4&X Overview for Package and Class Writers

way of saying \linebreakC31,whle \LB [21 uses the actual specified value. That is, you will obtain the same effect as when typing \linebreakC21. The second command, \PK,is used in the example below.
Three K particles, KO,K+ and K-.
Three K particles, \PK, \PK [+I and \ p [-] ~ .

In general, it is most practical to associate the case that occurs most often with the form of the command without parameters and to represent the cases used less often with longer command strings with an optional argument. Another somewhat more complex example, with an optional and a mandatory argument, is the definition of a rule with a default width of 0.4pt and a height specified by the mandatory argument. Note the two uses of the \Rule command where the widths are specified explicitly. In the latter case an "invisible rule" (strut) makes the framed box hgher than the natural height of its contents.
text text text text

and

M.

\newcommand{\Rule) [2] [ .4pt]{\rule{#1){#2)) text text \Rule{4mm) text \Rule [lmm] I4mm) text \fbox{xxx) and \fbox{\Rule[Omm]{4mm)xxx).

m X z E offers you another possibility to define commands:

I \providecommand~\mycom~ Cnargl [default](command definition) I


This works exactly like \newcommand,except that it is ignored if the command already exists. Such a feature is useful in sources that may get used in several documents, e.g., bibliography entries. For example, instead of using \newcommand in the @PREAMBLE of BIBTEX for logos and other constructs used in the BIBTEX entries, you can use \providecommand to avoid error messages in the case that such commands are already defined in the document.

A. 1 . 2 Defining New Environments


( L 57,173)

You can define or redefine an environment with the \newenvironment and \renewenvironment commands, respectively. You must specify, in each case, whch actions should take place when you enter and leave an environment. For an environment called "myenv"t h s is signaled by the commands \begin(myenv) and \endCmyenv) inside your document.
\newenvironmentCname) Cnargl Cbegdef3Cenddef3 \renewenvironmentCname3 [nargl Cbegdef3Cenddef)

As with \newcommand,the number of arguments is in the range Osnargs9; and, in the case of no parameters, you can omit COI. Inside the definition

A. 1 Linking Markup and Formatting

44 3

part, begdef, these parameters are referenced as #I to #narg. If arguments are present, then they are defined when entering the environment by specifying them on the command \begin{myenv) as shown below.

When exiting an environment with the command \end{myenv) no parameters can be specified. Moreover, the parameters specified with the \begin{myenv) command when entering the environment (see above) are no longer available in the definition part enddef where you define the actions which should take place when leaving the myenv environment. This means that it is your responsibility to store information needed at the end of an environment (see the Citation environment defined below). Our first example defines an environment of type "Abstract," which is often used to give a short summary of the contents of an article or a book. It starts by typesetting a boldfaced and centered title, followed by the text of the abstract inside a quote environment.
Abstract This abstract explains the approach used to develop the necessary tools to solve the problems at hand.
\newenvironment{Abstract) {\begin{center)\textbfCAbstract)% \endCcenter> \begidquote)) C\endCquote)) \beginCAbstract) This abstract explains the approach used to develop the necessary tools to solve the problems at hand. \end{Abstract)

Our second example is somewhat more complex. It shows you how a


Citation environment can be defined for quoting citations by famous people.

The L A T E X code shown above defines the counter Citctr, for numbering the citations, and a box \Citname to store the name of the person whom we are citing so that we can typeset it at the end of the citation, when the \end{Citation) command is encountered (remember that the value of the argument specified on the \begin{Citation) command is no longer available at that stage). When entering the environment, we increment our counter and save the value of the

444

AL A T E X Overview for Package and Class Writers

argument, typeset in italic, in the box \Citname. We then start a description environment. This environment will have a single \item containing the counter value preceded by the word "Citation." When exiting the Citation environment, we first twice issue a stretchable horizontal space separated by an allowed but discouraged line break. Then we typeset the contents of our box \Citname before leaving the description environment. This will put the author's name flush right and, if there is not enough space to place it on the same line as the citation, put the last line of the citation flush left, as you can see in the next example. Without this adjustment the text of the citation would always be fully justified, often with a lot of white space between the words.
Citation 1 Necessity is the plea for every infringement of human freedom. William Pitt
\beginCCitation)CWilliam Pitt) Necessity is the plea for every infringement of human freedom. \endCCitation) This is some regular text in between two Citation environments. \beginCCitation)CProtagoras) Man is the measure of all things. \end{Citation) More regular text \ldots \beginCCitation){Blaise Pascal) On mourra seul. \end{Citation)

This is some regular text in between two Citation environments.


Citation 2 Man is the measure of all things. Protagoras

More regular text ..


Citation 3 On mourra seul.

Blaise Pascal

For a discussion of the counter and box commands used in t h s example see section A.1.3 and section A.2. As with \newcommand w X 2 lets ~ you make the first argument of an environment optional, as follows:

I \newenvironmentCmyenv)

[nargl [default] Cbegdef ICenddef)

The default for the optional argument is given between the second pair of square brackets [default]. Inside the begdef part, which is executed when the environment myenv is entered, the optional argument can be accessed with #I, while the mandatory arguments (when present) are addressed as #2 to #narg. When the myenv environment is used without an optional parameter, #I will contain the string specified as [default]. As an example, we implement a variant called def l i s t [go] of the Ventry description list environment discussed in section 3.2.2. The def l i s t environment behaves like a standard description environment if it is specified without an optional argument. If an optional argument is specified, then the width of the description label will be put equal to the width of the argument. Thus, by specifying the widest entry as an optional argument, you will make sure that the description parts of all your entries line up nicely.

A.l Linking Markup and Formatting

44 5

The example below first shows the (default)behavior of the def list list and then what it looks like when using the optional argument.
First This i s a short term. Long term This i s a long term. Even longer term A very long term. First
\settowidth{\labelwidth)C\textbf~#l))% \setlength~\leftmargin)C\labelwidth+\labelsep}}}

\newenvironmentCdeflist} [l] [\quad]%

This i s a short term. This i s a long term.

Long term

Even longer term A very long term.

C\endClist)l \beginCdeflist) \item[Firstl This is a short term. \item[Long term] This is a long term. \item[Even longer term] A very long term. \endCdeflist) \beginCdeflistl[Even longer term] \item[First] This is a short term. \item[Long term] This is a long term. \item[Even longer term] A very long term. \end(def list)

A. 1.3 Defining and Changing Counters


Every number generated by LATEX has a counter associated with it. The name of the counter is usually identical to the name of the environment or command where it is used except for the \. The following is the list of all counters used in WX's standard document classes:
Part chapter section subsection subsubsection paragraph subparagraph Page equation figure table footnote mpfootnote enumi enumii enumiii enumiv

(L:91)

An environment declared by \newtheorem can also have a counter with the same name associated with it, unless the optional argument indicates that it is to be numbered together with another environment. The value of a counter is a single integer. Several counters can be combined into a number, as is usually the case for numbering section headings. For example, in the book or report classes, 7.4.5 identifies the fifth subsection of the fourth section in the seventh chapter.

Manipulating W X Counters Below we list all the basic L A T E X commands that define and modify counters.

(L:92,175)

446

A UTFX Overview for Package and Class Writers

These commands are much more powerful if used in conjunction with the calc package, discussed in section A.4.

This globally defines a new counter, newctr, and initializes it to zero. If a counter with the name newctr is already defined, an error message is printed. When you specify the name of another counter as the optional argument, oldctr, then the newly defined newctr is reset when counter oldctr is incremented with the \stepcounter or \ref stepcounter commands.

I \setcounter{ctr){val) I
The value of counter ctr is globally set equal to the value val.

I \addtocounter{ctr){val) I
This command globally increments the value of counter ctr by val.

For use mainly in the val argument of the \setcounter or \addtocounter commands, this command produces the value of counter ctr.

This globally increments the counter ctr and resets a l l subsidiary counters, i.e., those declared with the optional argument oldctr on the \newcounter command or with the first argument of \@addtoreset (see section 2.3.1).

This is the same as \stepcounter, but it also defines the current \ref value to be the text generated by the command \thectr. The visual representation of a counter is controlled by the following commands:
\arabicCctr) \romanCctr) \RomanCctr) \alphCctr)

Represent counter ctr as an arabic numeral. Represent counter ctr as a lowercase roman numeral. Represent counter ctr as an uppercase roman numeral. Represent counter ctr as a lowercase letter: a, b,. .., z. The value of ctr must not be greater than 26.

A.l Linking Markur, and Formatting

447

\AlphCctr) \fnsymbolCctr) \thectr

Represent counter ctr as an uppercase letter: A, B,. . . , Z. The value of ctr must not be greater than 26. Represent counter ctr as a footnote symbol: t,. .. T h s command can only be used in math mode. Command to print a representation of the value associated with counter ctr.

*,

As an example, we shall look at the way counters are defined inside the standard class files. For the sectioning commands we find definitions equivalent to the following:

You see how lower level counters are reset when upper level counters are stepped, as well as how the representation of the counters (the \the. . . commands) are constructed from the current counter and the counters at a higher level. It is also seen that the part counter does not influence any of the lower levels. Table 3.2 on page 57 shows the structure of the enumeration list counters. In fact, these counters are defined inside the file l a t e x . t e x , containing the basic code for W X . Only the representation and label field commands are defined in the standard class files as follows:

A.1.4 Defining and Changing Space Parameters


As in TEX, basically two kinds of space parameters (lengths) exist, namely "rigid" lengths (called <dimen> in the T E X book), which are fixed, and "rubber" lengths

448

A BTFX Overview for Package and Class Writers

(L149-205) (L95,193)

(called <skip>in the T E Xbook), whch have a natural length and a degree of positive and negative elasticity. New lengths in L A T E X are allocated as type <skip>, so that you always have the choice of initializing them as rigid or rubber lengths (by specifying plus and minus parts). All standard lengths in W&X are of type A T E X book to be rubber. rigid, unless specifically declared in appendix C of the L L A T E X defines the following commands for lengths.

This is a rubber length with a natural length of zero. It can stretch to any positive value. Do not change its value!

This is perhaps a more useful rubber length. \ f i l l is equivalent to \stretch.Cl). More generally, \stretchdec-num) has a stretchability of dec-num times \ f i l l . It can be used to fine-tune the positioning of text horizontally or vertically.

This defines a new length and associates the command name cmd with it. If a command cmd already exists, you will get an error message. The new length is preset to Opt. This is a rubber length. In the examples below, the T E X command \the is used to show the actual contents of the length variable.
Mylen = O.Opt
\newlength{\Mylen) % Declare new length \Mylen Mylen = \the\Mylen % Show current value

This sets the value of the length command cmd equal to the length Zen.
Mylen = 28.45274pt Mylen = 14.22636pt plus 2.84526pt minus 1.42262pt
\setlength{\Mylen){lOd % Set length to 1 0 m Mylen = \the\Mylen % Use a rubber length \setlengthC\Mylen){5mm plus lmm minus .5m) \par Mylen = \the\Mylen

Lengths can be specified in various units, as shown in table A.l on the next page. Notice the difference between the typographc point (pt) whch is normally used in T E X and the (big) point used by Postscript, for example. Thus, when reserving space for a Postscript picture you need to specify the bounding box dimension in bp to get the correct space.

A. 1 Linking Markup and Formatting

449

sp pt bp dd mm pc cc cm in ex em mu

Scaled point (65536 sp = 1pt) TEX'S smallest unit. Point= m1i n = 0 . 3 5 1 m m Big point (72 bp = 1 in), also Postscript point DidBt point = of a French inch, = 0.376 mm Millimeter = 2.845 pt Pica = 12 pt = 4.218 mm Cicero = 12 dd = 4.531 mm Centimeter = 10 mm = 2.371 pc Inch = 25.4 mm = 72.27 pt = 6.022 pc Height of a small "x" for the current font Width of capital "M" in current font Math unit (18 mu = 1 em) for positioning in math mode

units of length Table A.l: (I4)T~x's

This adds length len to the current value of the length command cmd.
Mylen = 8.19003pt Mylen = 20.19003pt
\setlengthC\Mylen)Clern) Mylen = \the\Mylen \addtolength(\Mylen)Clpc) \par Mylen = \the\Mylen

% Add a pica

The value of the length command cmd is set equal to the natural width of the typeset version of text. This command is very useful for defining lengths that vary with the string contents or the type size.
Mylen = 23.0631pt Mylen = 29.73709pt % \Mylen is width of ABCD in current font
\settowidthC\Mylen){ABCD) Mylen = \the\Mylen % Go to larger font and recalculate width \settowidthC\Mylen3~\1arge ABCDI \par Mylen = \the\Mylen

In w X 2 two ~ additional commands have been added. They work like


\settowidth but measure the height and the depth rather than the width of

the typeset text.

450
\enspace \quad \qquad \hf ill \hrulef ill \dotf ill

A LATX Overview for Package and Class Writers

yields a space equal to half a quad yields a space equal to the em value of the font twice a \quad horizontal rubber length whch can stretch between 0 and similar to \hf ill,but draws a horizontal line similar to \hf ill,but draws a dotted line Table A.2: Predefined horizontal spaces

oo

Horizontal Space (L 95,96,193)


A horizontal space is produced by the \hspace command. The command
\hspace* is the same as \hspace, but the space is never removed, not even at a line boundary. Table A.2 shows horizontal space commands known to

m x .
This is a This is a This is a

A space in front of or following the \hspace command is significant, as the following example shows:
0.5 in wide space. 0.5 in wide space. 0.5 in wide space.
\par This is a\hspace{0.5in)0.5-in wide space. \par This is a \hspace{0.5in)O.5"in wide space. \par This is a \hspace{O.Sin) 0.5-in wide space.

The following example shows how the "rubber lengths" can be used to finetune the positioning of information on a line. Note that the \hf ill command is in fact an abbreviation for \hspace{\f ill). To save typing, we also defined a command with an optional argument, \HS,which behaves like \hf ill when used without an argument, but can be made to be less or more flexible than that command by specifying the stretchability (a value of one has the same effect as \hf ill).
left left left left left left left left

right right ....................................... right ............... ............... right ............. ............. right ......... ......... right

M IzI

right right -

middle middle

\newcommand{\HS) [I] [I.1 {\hspace{\stretch{#l))} \begin{center) left \hf ill ill left \HS [ .5]\fbox{$\f rac{1){3>$)\hf left \HS middle \hfill left \hrulefill\ middle \hrulefill\ left \dotfill\ left \dotfill\ \HS [.51 \dotf ill\ \dotfill\ left \dotfill\ \HS left \dotfill\ \HS L2.1 \dotfill\ right \end{center)

Vertical Space (L 95,96,193)


A vertical space is produced with the \vspace command, which works similarly

to \hspace. In particular, a \vspace* command will generate vertical space that will never be eliminated, even when it falls on a page break where a \vspace

A.2 Page Markup-Several Kinds of Boxes


\smallskip \medskip \bigskip \vf ill

451

Vertical s h p of \smallskipamount (default about one quarter of \baselineskip). Vertical skip of \medskipamount (default about one half of \baselineskip). Vertical skip of \bigskipamount (default about one \baselineskip). Vertical rubber length which can stretch between 0 and co. Table A.3: Predefined vertical spaces

command will be ignored. Table A.3 shows vertical space commands known to L A T E X that are common to all standard classes. INEX users are often confused about the behavior of the \vspace command. When used inside a paragraph, the vertical space is added after the end of the line with the \vspace, while between paragraphs it behaves as you would expect.
The use of a \vspace command inside a paragraph is considered somewhat odd. It could perhaps be used with a negative space value to get rid of redundant space. Between paragraphs, adjusting the spacing is somewhat more useful, and it allows control of the white space before and after displayed material.
The \vspace{5mm)use of a \verb!\vspace! command inside a paragraph is considered somewhat odd. It could perhaps be used with a negative space value to get rid of redundant space.

Between paragraphs, adjusting the spacing is somewhat more useful, and it allows control of the white space before and after displayed material.

Stretchable space can also be used for vertical material. The \vf ill command is, in fact, an abbreviation for a blank line followed by \vspace{\f ill). More generally, you can use the \ s t r e t c h command in combination with \vspace to control the layout of a complete page. This could be useful for designing a title page, like the one shown in figure A.l on the next page, where we put the author and title about one-third down the page with the place and time of publication at the bottom.

A.2 Page Markup-Several Kinds of Boxes


The theory of composing pages out of boxes lies at the very heart of TEX and many L A T E X constructs are available to take advantage of this method of composition. A box is an object that is treated by T E X as a single character. A box cannot be split and broken across lines or pages. Boxes can be moved up, down, left, and right. E Q X has three types of boxes:
LR (left-right) The contents of this box are typeset from left to right.

( L 97,98)

452

A MTFX Overview for Package and Class Writers

Geoffrey Chaucer The Canterbury Tales

LONWN 1400

\documentclass~article) \usepackage{times) \thispagestyle{empty) \newcommand{\HRule)C\rule~\linewidth)(l~) \setlength{\parindent){Omm) \setlength{\parskip}{Omm) \begin{document) \vspace*{\stretch{l)) \HRule \begin{flushright) \Huge Geoffrey Chaucer\\ [5mml The Canterbury Tales \end{flushright) \HRule \vspace*{\stretch{2H \begin{center) \Large\textsc{London 1400) \end{center) \end{document)

Figure A. 1: A title page example

(L 98-100)

Par (paragraphs)This kind of box can contain several lines, which will be typeset in paragraph mode just like normal text. Paragraphs are put one on top of the other. Their widths are controlled by a user specified value.
Rule A (thin or thick) line that is often used to separate various logical elements on the output page, such as between table rows and columns and between running titles and the main text.

(L100)

A.2.1 LR Boxes
\mboxItext) \makebox Cwidthl Cposl {text) \f boxCtext) \f ramebox [width] Cposl (text)

(L 97,194)

. 1-

The first line considers the text inside the curly braces as a box, without or with a frame drawn around it. For example, \fbox(some words) gives The two commands on the second line are a generalization of these commands. They allow the user to specify the width of the box and the positioning of the text inside.

some words some words

\makebox [5cml {some words) \framebox [5cml [rl {some words)

\par

A.2 Page Markup-Several Kinds of Boxes

453

In addition to centering the text with positional argument [cl (the default), you can position the text flush left ( [11 ) or flush right ( [r] ). L A T E X & also offers you an [sl specifier that will stretch your text from the left margin to the right margin of the box provided it contains some stretchable space, e.g., some \hspace or the predefined spaces given in table A.2 on page 450. The interword spaces are also stretchable (and shrinkable to a certain extent) as explained on page 201. the above box commands with arguments for specifying the With @TEX~E, dimension of the box allow you to make use of four special length parameters: \width, \height, \depth, and \totalheight. They specify the natural size of the text, where \totalheight is the sum of \height and \depth.
A few words of advice
A few words of advice \framebox{A$ew words of advice) \par \framebox [\width + 4mml [sl { A few words of advice) \par \framebox [l .5\widthl { A few words of advice)

Zero width boxes are very handy if you want to put a marker on the page (e.g., for placement of figures) or to allow text to be put into the margins. The principle of operation is shown below, where a zero width box is used to tag text, without influencing the centering. Note that the optional parameter [ll ( [rl ) makes the material stick out to the right (left).
A centered sentence.lZ3 Some more text in the middle. 321Acentered sentence.
\begidcenter) A centered sentence. \makebox [Ocml [I] {$-{123)$)\\ Some more text in the middle. \\ \makebox [Ocml [r] {$-{321)$)A centered sentence. \ \ \end{center)

-As

seen in the margin of the current line, boxes with a vanishing width can also be used to make text stick out in the margin. Thls effect was produced by beginning the paragraph as follows
\noindent\makebox [Ocm] [rl {\ (\Longleftrightarrow\) 1% As seen in the margin ...

These zero width boxes also come in handy for hiding material inside a
tabular environment to allow placement across rows (see also the discussion of the \raisebox command below).

The appearance of frameboxes can be controlled by two style parameters:


\fboxrule The width of the lines comprising the box produced with the command \fbox or \framebox. The default value in all standard classes \fboxsep

( L 195-6)

is 0.4pt. The space left between the edge of the box and its contents by \fbox or \f ramebox. The default value in all standard classes is 3pt.

454

A WQX Overview for Package and Class Writers

\fboxCText in a box) \setlength~\fboxrule~~2pt)\setlength~\fboxsep)C2m) \fbox{Text in a box)

( L 100,195)

An interesting possibility is to raise or lower boxes. This can be achieved by the very powerful \raisebox command, which has two obligatory and two optional parameters, defined as follows:

I \raisebox{lift)

Idepthl [height] Iconrents1

In thls example, L A T E X takes the added height and depth into account when calculating the distance between the lines. This distance can be manipulated by specifying a height and depth that the user wants L A T E X to actually use when placing its material on the page. The second pair of lines below shows that W X does not realize that text has been moved upward and downward, and it composes the lines as though all the text was on the baseline.
\beginCflushleft) xlllx \raisebox(-1ex)Cdownward) x222x \\ x333x \raiseboxClex)Cupward) x444x \ \ [4ml xlllx \raisebox{-lex) [Ocm] [Ocml Cdownward) x222x\\ x333x \raiseboxClex) [Ocm] {upward) x444x \endCflushleft)

xlllx x222x x333x @3@+f@;d444x

Somewhat more useful applications are discussed in chapter 5 where the subject of tabular material is treated. As with \makebox and \f ramebox the m X 2 ~ implementation of \raisebox offers you the use of the lengths \height, \depth, \totalheight, and \width in the first three arguments. Thus, to pretend that a box extends only 90%of its actual height above the baseline you could write

or to rotate a box around its lower left corner (instead of its reference point lying on the baseline), you could raise it by its \depth first, e.g.:
\newcommandC\DoT)[11C\beginCturn)C-45)#l\end~turn)) xl \DoTC\fboxCBad Thing)) x2 \DoT{\raiseboxC\depth){\f boxCGood Thing))) x3 \DoTC\raiseboxC-\height)C\fboxCBad Thing))) x4

xl

x2

x4

A.2 Page Markuv-Several Kinds of Boxes

455

A.2.2 Paragraph Boxes


Paragraph boxes are constructed using the \parbox command or minipage environment. The text material is typeset in paragraph mode inside a box of width width. The vertical positioning of the box with respect to the text baseline is controlled by the one-letter optional parameter pos ( [cl , [tl , and [bl ).
\parbox [posl CwidthHtext) \ b e g i d m i n i p a g e ) Cposl {width) text \endCminipage)

(L98,99,195)

The center position is the default as shown by the next example. You can also observe that L A T E X might produce wide interword spaces if the measure is incredibly small.
This is the rightmost parbox. Note that the typeset text looks sloppy because LATEX cannot nicely balance the material in these narrow columns.
\parbox{.3\1inewidth){This contents of the left-most \hfill CURRENT LINE \hfill \parbox{.3\1inewidth){This right-most parbox. Note that the typeset text looks sloppy because cannot nicelv balance the in these narrow columns.)

is the parbox.) is the

This is the contents of the leftmost parbox.

CURRENT LINE

\LaTeX{) material

The minipage environment is very useful for the placement of material on the page. In effect, it is a complete miniversion of a page and can contain its own footnotes, paragraphs, and a r r a y , t a b u l a r , and m u l t i c o l s environments. Note, however, that it cannot contain floats or \marginpar's, but it can appear inside f i g u r e or t a b l e environments where it is often used for constructing a pleasing layout of the material inside the float. A simple example of a minipage environment at work is given below. The baseline is shown with an en dash generated by the command \HR. Note the use of the pos placement parameter ( [ c l , [ t l , and [bl).
AAAA A A A A BBBBB AAAABBBBB A A A -BBBBB-C C C CBBBBB C C C BBBB
\HR A A A A A A A A A A A A A A A \beginCminipage)[b]C12mm> \end{minipage>\HR \beginCminipage) [c] Cl2mm) B B B B B B B B B B B B B B B B B B B B B B B B \end{minipage)\HR \begin{minipage)[t]{12mm) C C C C C C C \end{minipage)\HR

456

AL A T E X Overview for Package and Class Writers

If you desire more complicated alignments, then you might have to stack the different minipage environments. Compare the behavior of the following examples. Below, we try to align the two leftmost blocks at their top and aligning the resulting block at the bottom with a t h r d block by adding another level of minipages.

cccc
4A A A xx B B B B B -C C C
AAAA AAAA AAA BBBBB BBBBB BBBBB BBBB
-

\HR \beginCminipage) [bl C30mm) \beginCminipage) [tl C12mm)

A A A A A A A A A A A A A A A
\endCminipage) xx \beginCminipage) [tl Cl2mm)

B B B B B B B B B B B B B B B B B B B B B B B B
\endCminipage) \endCminipage)\HR \begidminipage) [b]Cl2mm)

C C C C C C

C \endCminipage)\HR

However, we do not get the expected result. The reason is the following: the two top-aligned minipages inside the bottom-aligned minipage form a paragraph with a single line (the minipages are considered to be large units in the line containing xx). Thus, the bottom line of the outer minipage is still the one containing the xx characters. To prevent this we need to add some invisible space after the paragraph.
AAAAxxBBBBB AAAA BBBBB AAAA BBBBB AAA BBBBB C C C C BBBB -CCC \HR \beginhinipage) [bl C30mm) \beginCminipage) [tl(l2mm)
A A A A A A A A A A A A A A A

\endCminipage) xx \beginCminipage) [tl C12mm)

B B B B B B B B B B B B B B B B B B B B B B B B
\end{minipage) \par\vspace*COmm) \end{minipage)\HR \beginCminipage)[blCl2mm)

C C C C C C C \endCminipage)\HR

In the case below, the two rightmost environments are aligned at their top inside another enclosing environment, which is aligned at its bottom with the first one. If you compare it with the previous case, then you see that you obtain a quite different result, although the sequence of alignment parameters is the same. Only the stacking order of the minipage environments is different.

A.2 Page Markup-Several Kinds of Boxes


BBBBBxxC C C C AAAABBBBB CCC A A A A BBBBB A A A A BBBBB A A A ABBB -

457

\HR \begidminipage) [bl Cl2mm)

A A A A A A A A A A A A A A A
\endCminipage)\HR \begin(minipage) [bl C3Omm) \begidminipage) [t] C12mm)
B B B B B B B B B B B B B B B B B B B B B B B B

\endCminipage) xx \beginCminipage)[tlC12mm) \par\vspace*COmm) \end(minipage)\HR

C C C C C C

\endCminipage)

Again we had to add some vertical space to achieve alignment. This does, however, not always produce the desired result. If, for instance, there is a letter with a descender in the last line of the stacked minipage, as in the example below, then the alignment of the baselines is not perfect.
BBBBxxCCCC BBBBB CCC AAAA'BBBBB AAAABBBBB AAAABBBBB A A A -ggJJ \HR \begin{minipage) Cb] Cl2mm)

A A A A A A A A A A A A A A A
\endCminipage)\HR \beginCminipage) [b] C3Omm) \beginCminipage) [tl Cl2mm)
B B B B B B B B B B B B B B B B B B B B B B B B g g j j

\endCminipage) xx \beginCminipage)[tl{l2mm~ \par\vspace*COmm) \endCminipage)\HR

C C C C C C C

\endCminipage)

To correct this, you have to add (negative)vertical space that compensates for the depth of the letters. In the next example this is achieved by explicitly measuring the depth of the letters in question using the \sett odepth command provided by ItQX 2 E .
B B B BxxC C C C BBBBB CCC A BBBBB A BBBBB A BBBBB -ggjj \settodepth\Mylen)(gj) \HR \begidminipage) [bl C12mm)

A A A A A A A A A A A A

A A A A A A A A A A A A A A A
\end{minipage)\HR \beginCminipage) [b] C3Omm) \beginCminipage) [t] C12mm)
B B B B B B B B B B B B B B B B B B B B B B B B g g j j

\endCminipage) xx \beginCminipage)[tl{12mm) \par\vspace*C-\Mylen) \end(minipage)\HR

C C C C C C C

\endCminipage)

458

A WQX Overview for Package and Class Writers

Sometimes it is helpful to predefine the vertical lmension of a paragraph box. For t h s w X 2 offers ~ you additional optional arguments for minipage and \parbox.
\parbox [posl Cheightl [inner-posl {width){text) \beginCminipage) [posl Cheightl [inner-posl {width) text \end{minipage)

The inner-pos determines the position of text within the box. It can be t , c , b, or s . If not specified, the value of pos will be used. You can think of height and inner-pos as the vertical equivalent of the width and pos arguments of a \makebox. If you use the s position the text will be vertically stretched to fdl the given height. Thus, in this case you are responsible for providing vertically stretchable space if necessary using, for example, the \vspace command. As with the other box commands you can use \height, \totalheight, and so on to refer to the natural dimensions of the box when specifying the optional argument.
xx \fboxC\parbox [b] [\height+\baselineskip] [s] C2OmmlCSome text on top. \par\vfill And a few lines on the bottom of the box.)) \fboxC\parbox [b] [\height+\baselineskip] [s] C2Omm)CThis time a few lines on the top of the box. But only one line \par\vfill down here.)) xx

few lines on the top of the bottom of the

A.2.3 Rule Boxes (L100,195)


Rule boxes are drawn with the \rule command, whose syntax is:

If we write \rule{2cm)C2mm) then we get a 2cm long rule that is 2mm thick The \rule command can also be used to construct rule boxes with zero width, i.e., invisible rules (also called struts). The latter are useful if you need to control the height or width of a given box (for example, to increase the height of a framed box with \fbox or \f ramebox, or to adjust locally the distance between rows in a table). Compare the following:

xlllx

1-

x222x

x333x

xlllx \fboxCsome text) x222x \fbox~\rule[-5mml~Ocm~~l5mm~more text) x333x

A.2

Page Markup-Several Kinds of Boxes

459

A.2.4 Manipulating Boxed Material


Material can be typeset once and then stored inside a named box, so that its contents can later be retrieved.
\sboxCcmd)Ctext) \saveboxCcmd) [width] Cposl {text)

(L101,194)

fill box fill box

The \sbox and \savebox commands are similar to \mbox and \makebox. The command \newsavebox globally declares a command cmd, for example, \boxname, which can be thought of as a named bin, where typeset material can be stored for later (multiple) retrieval. Be careful not to use the command name \boxname directly, since it only contains the TEX number of the box in question, i.e., \boxname will merely typeset the character at the position correspondng to the box number in the current font. Thus, you should manipulate boxes exclusively using the commands described above. The \usebox command allows the nondestructive use of the material stored inside box \boxname. You can reuse the same bin (\boxname) several times within the scope of the current environment or brace group. It will always contain what was last stored in it.
x l 1lx inside box a x222x inside box b x l l l x inside box a x222x inside box b
\newsavebox(\myboxa)\newsavebox(\myboxb) \sbox(\myboxa)~inside box a) \savebox{\myboxb) [2cml [l] {inside box b) xlllx \usebox(\myboxa) x222x \usebox(\myboxb} \par xlllx \usebox(\myboxa) \savebox(\myboxb) [2cm1 [rl (inside box b) x222x \usebox(\myboxb)

In addition to the above commands BTEXZE also offers the environment


lrbox with the following syntax: \begin{lrbox)cmd) text \end{lrbox)

cmd should be a box register previously allocated with \newsavebox. The environment lrbox will save text in this box for later use with \usebox. Leading and trailing spaces are ignored. Thus, lrbox is basically the environment form of \sbox. You can make good use of t h s environment if you want to save the body of some environment in a box for further processing. For example, the following code defines the environment fminipage that works like a minipage but surrounds its body with a frame.

460

A L Q X Overview for Package and Class Writers

The above definition is interesting in several aspects. The environment is defined with one optional argument denoting the width of the resulting box (default is \linewidth). On the next line we calculate (using the calc package) the internal line length that we have to pass to the minipage environment. Here we have to subtract the extra space added by the \fbox command on both sides. Then the lrbox and minipage environments are started to typeset the body of the f minipage environment into the box \f minibox. When the end of the environment is reached those environments are closed. Then the \fminibox is typeset inside an \fbox command. The \noindent in front suppresses any indentation in case the environment is used at the beginning of a paragraph or forms a paragraph by itself.
In this environment verbatim text like \ f minibox can be used.
\beginCfminipage) In t h i s environment verbatim t e x t l i k e \verb=\fminibox= can be used. \end{fminipage)

A.3 Package and Class File Structure


As described in section 2.1 the structure and handling of package and class files are enhanced and extended in the LATEXZ~ release. In this section we discuss what commands are available for the authors of package or class files who want to make use of the new features. Even if you do not intend to write your own package, t h s section will help you understand the structure and content of class and package files like book or varioref, and thus help you to make better use of them. The general structure for class and package files is the same and consists of the following parts:
( identification) ( initial code)

(declaration of options) o f options) (package loading) ( main code)


( execution

All these parts are optional. We discuss the commands available in each of the individual parts below. Table A.4 on the next page gives a short overview.

A.3 Package and Class File Structure

Identification part \NeedsTeXFormat(format) [releasel Needs to run under format (LaTeX2e)with a release date not older than release \ProvidesClass( name) [release infol \ProvidesPackageCname) [release infol Identifies class or package name and specifies release information \ProvidesFile( name) [release infol Identifies other file name (with extension) and specifies release information Declaration of options

\DeclareOptionCoption~Ccode~ Declares code to be executed for option \PassOptionsToPackageCoption-1ist)Cpackage-name) Passes option-list to package-name \DeclareOption*Ccode) Declares code to be executed for any unknown option \Currentoption Refers to current option for use in \DeclareOption* Execution of options \Executeopt ionsCoption-list) Executes code for every option listed in option-list \ProcessOptions \ProcessOptions* Processes specified options for current class or package; star form obeys the specified order Package loading \Requirepackage [option-list1 {package) [release] Loads package with given option-list and a release date not older than release Special commands for package a n d class files \AtEndOfPackage(code) \AtEndOfClass(code) Defers execution of code to end of current package or class \AtBeginDocument{code) \AtEndDocument{code) Executes code at \begin{document) or \endCdocument)
\ I f FileExistsCfi1e)Cthen-code3Celse-code) Executes then-code if file exists, else-code otherwise

\ I n p u t I f FileExists{file)C then-codeHelse-code) Executes then-code if file exists and input it, otherwise execute else-code Special class file commands \Loadclass [option-list1 (class) [release] Like \Requirepackage for class files, but does not see global options if not explicitly passed to it \Passopt ionsToClassCoy?tion-1ist)Cclass) Passes option-list to class \OptionNotUsed For use in \Declareoption* if necessary

Table A.4: Commands describing the structure of package and class files

462

AL A T E X Overview for Package and Class Writers

A.3.1 The Identification Part


This part of a class or package file is used to define the nature of the file and also states the first m X 2 distribution ~ release for whch the file was written.

I \ ~ m v i d e s C l a s s n a m e )[release informationl 1
A class file identifies itself with a \ProvidesClass command. The argument name corresponds to the name of the class as it will be used in the mandatory argument of the \documentclass command, i.e., the file name without extension. The optional argument release information should begin with a date in the form YYYY/MM/DD, followed by a string describing the release. For example, the class report contains somethmg like
\ProvidesClass~report~~1994/01/01 LaTeX2e standard class]

In a document you can make use of the release information by specifying the date as a second optional argument to the \documentclass command in the following way:
\documentclass [twocolumn] {report) [1994/06/01]

This enables W X to check that the report class used has at least a release date of 1994/06/01 or is newer. If the class file is older, a warning is issued. Thus, if you make use of a new release of a class file and send your document to another site, the people there will be informed if their W&X distribution is out of date.

I \ProvidesPackage{name)

[release informationl

This command identifies a package file. The structure is the same as for the
\ProvidesClass command. Again, the date in the release information can be used in a second optional argument to \usepackage to ensure that an up-to-date

version of the package file is loaded, e.g., with


\usepackage [german]Cvarioref1 [1994/01/011

\providesFile{fi!ename) [release informationl

This command identifies any other type of file. For t h s reason filename must contain the full file name includmg extension. In addition to one of the above commands the (identification) part usually also contains a \NeedsTeXFormat command, as already mentioned in section 2.1.1, for example \NeedsTeXFormat{LaTeX2e) C1993/11/111. All four declarations are optional. Nevertheless, their use in lstributed class and package files will ease the maintenance of these files.

A.3 Package and Class File Structure

463

A.3.2

The Initial Code Part

You can specify any valid L Q X code in the (initial code) part. This includes loading of packages with the \Requirepackage command (see section A.3.5) if their code is required in one of the option declarations later on. For example, you might want to load the calc package at this point, if you want to use it later on. However, normally this part is empty.

A.3.3

The Declaration of Options

In t h s part all options known to the package or class are declared using the \DeclareOption command. It is forbidden to load packages in t h s part.

The argument option is the name of the option being declared and code is the code to execute if this option is requested. For example, the paper size option a4paper normally has a definition of the form:

In principle any action from setting a flag to some complex typesetting instruction is possible in the code argument of \Declareoption. An important function for use in \Declareoption is the command \PassOptionsToPackage. It can be used to pass one or more options to some other package that is loaded later on.

The argument option-list is a comma-separated list of options that should be passed to the package with name package-name when it is loaded in the (package loading) part.l Suppose, for example, that you want to defme a class file that makes use of two packages, say, A and 6, both supporting the option infoshow. To support such an option in the class file as well, you could declare:
\DeclareOption~infoshow)C% \PassOptionsToPackagefinfoshow)CA)% \PassOpt ionsToPackagefinf oshow)o% (code to support infoshow if1 the class)3

If a package or class file is loaded with an option that it does not recognize, it will issue a warning (in case of a package file) or silently ignore the option (in case
'1t is the responsibility of the package writer to actually load such packages. H&X does not check that packages receiving options via \PassOptionsToPackage are actually loaded later on.

464

A LATEX Overview for Package and Class Writers

of a class file), assuming that it is a global option to be passed to other packages loaded with \usepackage later on. However, this behavior is not hard-wired and can be modified using a \Declareoption* declaration.

The argument code specifies the action to take if an unknown option is specified. Withn this argument \Currentoption refers to the name of the option in question. For example, to write a package that extends the functionality of some other package, you could declare:

This would pass all options not declared by your package to package A. If no \Declareoption* declaration is given, the default action, as described above, will be used. Combining \DeclareOption* with \InputIfFileExists (seebelow) you can even implement conditional option handling. For example, the following code tries to find files whose names are built up from the option name.

If the file g-option.xyz can be found it will be loaded; otherwise the option is ignored.

A.3.4 The Execution of Options


Two types of actions are normally carried out after all options are declared. You might want to set some defaults, e.g., defining the default paper size. Then the list of options specified needs to be examined and the code for each such option needs to be executed.

\Executeoptions executes the code for every option listed in option-listin the order specified. This is just a convenient shorthand to set up defaults by executing code specified earlier with a \Declareoption command. For example, the standard class book issues something similar to

to set up the defaults. You can also use \Executeoptions when declaring other options, e.g., to define an option that automatically implies others. The \Executeoptions command can only be used prior to executing the

A.3 Package and Class File Structure


\ProcessOptions command because, as one of its last actions, the latter reclaims all the memory taken up by the code for all the declared options.

465

When the \ProcessOptions command is encountered it examines the list of options specified for t h s class or package and executes the corresponding code. More exactly, when dealing with a package the global options (as specified on the \document class command) and the directly specified options (the optional argument to the \usepackage or \Requirepackage command) are tested. For every option declared by the package, the corresponding code is executed. T h s is done in the order in which the options were specified by the \Declareoption declarations in the package, not in the order in whlch they appear on the \usepackage command. Global options which are not recognized are ignored. For all other unrecognized options the code specified by \Declareoption* is executed, or, if t h s declaration is missing, an error is issued. In the case of a class file, the action of \ProcessOptions is the same without the added complexity of the global options.

For some packages it might be more appropriate that they process their options in the order specified on the \usepackage command rather than using the order given through the sequence of \Declareoption commands. For example, in the babel package, the last language option specified is supposed to determine the main document language. Such a package can execute the options in the order specified by using \ProcessOptions* instead of \ProcessOptions.

A.3.5 The Package Loading Part


Once the options are dealt with, it might be time to load some additional packages, for example, those to whom you have passed some options using
\PassOptionsToPackage.

I \Requirepackage [option-list1Cpackage) [releasel I


T h s command is the package/class counterpart to the document command \usepackage. If package was not loaded before, it will be loaded now with the options specified in option-list, the global options from the \documentclass command, as well as all options passed to this package via
\PassOptionsToPackage.

W X 2 loads any package only once because in many cases it is dangerous to execute the code of a package several times. Thus, if you require a package with a certain set of options but this package was already loaded with a different

466

AL A T E X Overview for Package and Class Writers

set not including all options requested this time, then the user of your package has a problem. In this case L A T E X issues an error message informing the users of your package about the conflict and suggesting to them to load the package with a \usepackage command and all the necessary options. The optional release argument can be used to request a package version not older than a certain date as described above. For t h s to work, the required package must contain a \ProvidesPackagedeclaration specifying a release date.

A.3.6 The Main Code Part


This final part of the file defines the characteristics and implements the funcA T E X contions provided by the given class or package. It can contain any valid L struct and usually defines new commands and structures. It is good style to use standard L A T E X commands, as described in this appendix, such as \newlength, \newcommand, and so on, rather than relying on primitive T E X commands since the latter do not test for possible conflicts with other packages.

A.3.7 Special Commands for Package and Class Files

Sometimes it is necessary to defer the execution of some code to the end of the current package or class file. The above declarations save their code argument and execute it when the end of the package or class is reached. If there is more than one such declaration present in a file the code is accumulated and finally executed in the order in which the declarations were given.
\AtBeginDocumentCcode) \AtEndDocument{code)

Other important points at whch you might want to execute deferred code are the beginning or the end of the document, or more exactly the points where the \begin{document) and \end{document) are processed. The above commands allow packages to add code to this environment without getting into conflicts with other packages trying to do the same.

If your package or class tries to \input a file which does not exist, the user ends up in TEX'Sfile-error loop that can only be exited by supplying a valid file name. B y using \IfFileExists your package or class can avoid this problem. The argument file is the file whose existence you want to check. If this file is found by L A T E X the commands in then-codeare executed; otherwise those in else-codeare executed. The command \InputIfFileExists does not only test

A.3 Package and Class File Structure

467

whether file exists but additionally inputs it immediately after executing thencode. It also adds the name file to the list of files to be displayed by \listf iles.

A.3.8 Special Commands for Class Files


It is sometimes helpful to build a class file as a customization of a given general class. To support this concept two commands are provided.

I \Loadclass [option-list1Cclass) [release] I


The \Loadclass command works like the \Requirepackage command with the following three exceptions: The command can only be used in class files. There can be at most one \Loadclass command per class. The global options are not seen by the class unless explicitly passed to it via \PassOptionsToClass or specified in the option-list.

The command \PassOptionsToClass can be used to pass options to such a general class. An example of such a class file augmentation is shown in figure A.2 on the next page. It defines a class file myart accepting two extra options, cropmarks (making crop marks for trimming the pages) and bind (to shift the printed pages slightly to the outside to get a larger binding margin), as well as one additional environment, Notes. The cropmarks option is implemented by setting a Boolean switch and red e h g various \pagest yles if this switch is true. The bind option mochfies the values of \oddsidemargin and \evensidemargin. However, since these length registers do not have their final value at the time the bind option is encountered (they are set later when the article class is loaded by \Loadclass), the modification is deferred until the end of the myart class file using the \AtEndOf Class command.

If your code for \Declareoption* inside a class file is more complex-e.g., trying to handle some options but rejecting others-you might need to explicitly inform I A T E X ~that ~ the option was not accepted using the \OptionNotUsed command. Otherwise, will think that the option was used and will not produce a warning if the option was not picked up by a later package.

468

AL A T E X Overview for Package and Class Writers

% ................................
\NeedsTeXFormatf.LaTeX2e) \ProvidesClassCmyart)[1994/01/011

identification

...........................

% ................................

initial code

............................

\RequirePackageCifthen) \newboolean~cropmarks) % ........................... declaration of options -\DeclareOption~cropmarks~~\setbooleanCcropmarks)Ctrue)) \DeclareOption{bind) C\AtEndOfClassC\addtolength\oddsidemargin~.5in~% \addtolength\evensidemarginC-.5in))%

1
\DeclareOption*~\PassOptionsToClassC\CurrentOption){article)~ % ............................ execution of options ........................ \ProcessOptions % ................................ package loading ........................... \LoadClassCarticle) % the real code % ................................ main code ............................... \newenvironmentCNotesH... ) C ... ) % the new environment \ifthenelseC\boolean~cropmarks)) % support for cropmarks

C%

.. .. )I

\renewcommandC\psQplainH.... )%

Figure A.2: An example of a class file extending article

A.4 calc-Arithmetic Calculations


The package calc (by Kresten K. Thorup and Frank Jensen) contains a set of E X is done by simmacros for enhanced arithmetic in HQX. Usual arithmetic in T ple low-level operations like \advance and \multiply. This package defines an infix notation arithmetic for L A T E X . It, in fact, reimplements the IPQX commands \setcounter, \addtocounter, \setlength, and \addtolength so that they can accept integer and length expressions rather than simple numbers and lengths. An integer expression can contain integer numbers, TEXSinteger registers, ~ X counters s (e.g., \valueCctr)), parentheses, and binary operators (-, +, *, /). For instance, to increment a counter:
\newcounter{local)\setcounter~ocal)C2) \setcounterClocal){\value~local)+l) The value is "\thelocal".

(L175,193)

The value is "3".

A.4 calc-Arithmetic Calculations

469

An example is the definition of a command to print the time (note that the TEX register \time contains the number of minutes since midnight):
The time is 21h 29min.
\newcounter{hours~\newcounter{minutes) \newcommand{\printtime){% \setcounter{hours){\time/60)% \setcounter{minutes){\time-\value{hours~*60~% \thehours h \theminutes min) The t i m e i s \printtime.

When dealing with lengths, the subexpressions that are added or subtracted must be of the same type. That is, you cannot have "2cm+4,"but an expression llke "2cm+4pt"is legal since both subexpressions have dimensions. You can only divide or multiply by integers, therefore "2cm*4" is a legal subexpression but "2cm*4pt1'is forbidden. Also, the length part must come first in an expression, thus "4*2cm" is not allowed. The commands described above allow you to calculate the width of one column in an n-column layout using the following single command (supposing that the variable n is stored as the first argument of a BTEX macro):

The restriction that you can only multiply and divide by integers has been relaxed for calculations on lengths (dimensions), where those operations are allowed with real numbers. A real number can be represented in two forms: \realCdecimal constant) \ratioClength expression)Clength expression)

The first form just converts the text into a real value, and the second form denotes the number obtained by dividing the value of the first expression by the value of the second. As an example, assume you want to scale a figure so that it occupies the full width of the page (\textwidth). If the original dimensions of the figure are given by the length variables \Xsize and \Ysize, then the height of the figure after scaling will be:

The calc package is used in many examples in this book. If you do not want to apply it, you need to express the code given in the examples in the form of primitive (B)TEXconstructs. For example, the setting of \fminilength on page 460 has to be translated from

4 70

A LATX Overview for Package and Class Writers

to the following statements:

Besides the fact that the infix notation provided by the calc package is certainly more readable (and much easier to modify), it contains constructs for division and multiplication that cannot be expressed with standard L A T E X constructs. For example, to express the \topmargin calculation from page 88 the following code is necessary:
\setlength{\topmargin){297mm) \addtolength{\topmargin)C-\textheight) \divide\topmargin by 3 \addtolength{\topmarginH-lin) \addtolength{\topmargin){-\headheight) \addtolength{\topmargin)C-\headsep)

% TeX calculation

A.5 i ft he n-Advanced Control Structures


Sometimes you may want to typeset different material depending upon the value of a logical expression. This is possible with the standard package ifthen (by X 2 ~ by David Carlisle), which defines Leslie Lamport, reimplemented for w commands for building control structures with W X .

If the condition test is true, the commands in the then-code part are executed, otherwise the commands in the else-code part are executed. A simple form of a condition is the comparison of two numbers (real or integer). For example, if you want to translate the chapter counter into English (not more that twenty chapters!):
This is the 1 St appendix.

This is the \toEng{chapter)

appendix.

The following example defines a command to print the time in short form. It shows how complex operations (using the calc package) can be combined with

A.5 ift hen-Advanced Control Structures

471

conditional control statements.


The current time is "21:29."
\newcommand~\Printtime)C\setcounter~hours>{\time/60>~ \setcounterCminutes)C\time-\value~hours>*60>% \ifthenelseC\value{hours><l0>~O>C>\thehours:% \ifthenelse~\valueCminutes><l0>~O>~>\theminutes> The current time is "\Printtime."

The \equal command evaluates to true if the two strings string1 and string2 are equal after they have been completely expanded. You should be careful when using fragile commands in one of the strings; they need protection with the \ p r o t e c t command.
False. True. True.

One application could be in the definition of a command for printing an item and for entering it in the index. In the case where it is defined, the index entry will be typeset in boldface; otherwise in a normal face. We use an optional argument for the least frequently occurring situation of the definition.
we define item AAAA item AAAA

. .. we reference

\newcommandC\IX>[21 [R]C\textttC#2>% \ifthenelse{\equalC#l>CD>>% {\indexC#2ltextbf)>C\indexC#2))) we define item \IX [Dl CAAAA) \ldots{> we reference item \IX{AAAA}

This gives the required visual representation in the .i d x file by specifying entries of the type:

A more complicated example, where you have complete control of what goes or does not go into the index or in the text, is the extended index command \IXE, defined as follows:

472

A W X Overview for Package and Class Writers

Its default optional argument " !* ! , ! " contains a string which you probably never want to use in the text. If you use the command \IXE with only one (normal) argument, then you will enter the same information into the index and the text. B y specifying an optional argument, you can enter something in the index that is different from what is printed in the text. All possible combinations are shown below. The en dashes show that no unwanted spaces are generated.
Identical in text and index AAAA!bothDifferent in text and index textentryOnly to index -In text only -textonlyNothing in text or index --.
-

\par Identical in text and index --\IXECAAAA!both)-\par Different in text and index --\IXE[AAAA!indexentry]{textentryb\par Only to index --\IXE[AAAA!indexonly]C)-\par In text only --\IXE[lCtextonly)-\par Nothing in text or index --\IXE[I{)--.

The .idx file contains only three entries, since the case with the empty optional argument " [I " does not generate an index entry.

Look in the index of this book and you will find the index entries generated by the last two examples. For the IAQXZE release a few more tests have been added to the ifthen package, as suggested by Alexander Samarin.

Basic TEXknows about some switches that can have the value true or fa l ~ e . ~ To define your own switch use \newboolean with string being a sequence of letters. This switch is initially set to false. To change its value use \setboolean with the value argument being either the string true or false. You can then test the value by using \boolean in the first argument of \ifthenelse. It is also possible to test all such internal flags of W&Xwith this command (the most common ones are shown in table A.5 on the next page). An example could be a test to see whether a document is using a one- or two-sided layout.
Two-sided printing.
\ifthenelse{\boolean{Qtwoside)){T~o-sided)COne-sided) printing.
2 ~ h e are y normally built using the \newif command.

A.5 ifthen-Advanced Control Structures

473

hmode mode mmode @twoside @twocolumn


@f irstcolumn

@newlist

Qinlabel anoskipsec

TEX switches true, if typesetting is done in a horizontal direction, e.g., inside a paragraph or an LR box. true, if typesetting is done vertically, e.g., if TEX is between paragraphs. true, if TEX is typesetting a formula. K&Xswitches true, if L A T E Xis typesetting for double-sided printing. true, if L A T E Xis typesetting in standard two-column mode (false inside multicols environments). is true and W X is typesetting the first true, if @twocolumn column. true, if L A T E X is at the beginning of a list environment (will be set to false when text after the first \item command is encountered). true, after an \item command until the text following it is encountered. true, after a run-in heading until the text following it is encountered.

Table A.5: The important internal \boolean switches

To compare dimensions use \lengthtest. In its test argument you can compare two dimensions (either explicit values like 20cm or names defined by \newlength) using one of the operators <, =, or >. As an example, let us consider a figure characterized by its dimensions \Xsize and \Ysize, and which should be made to fit into a rectangular area with dimensions \Xarea and \Yarea, but without changing the aspect ratio of the figure. The following code calculates the new sizes of the figure (\newX and \newY). The trick is to first calculate and compare the aspect ratios of both rectangle and figure, and from there obtain the magnification factor.

474

A U'QX Overview for Package and Class Writers

With the \isodd command you can test if a given number is odd. If, for example, the string generated by a \pageref command is a vahd number (as it normally is), then you can use the command in the following way:
This is an even numbered page.
This\label{testref) is an \ifthenelseC\isodd{\pageref{testref)))Codd>{even) numbered page.

\isodd is specially tailored to support the above application even though X run. the \pageref might be undefined in the first W

The \whiledo command is valuable for executing certain repetitive command sequences. The following simple example (using a counter from the examples above) shows how the command works:
The time is 1h. The time is 2h. The time is 3h. The time is 4h.
\setcounter{hours)Ci) \whiledo{\value~hours)<5){% The time is \thehours h.\\% \stepcounterChours))

Multiple conditions can be combined into logical expressions via the logical operators (\or,\and,and \not), using the commands \ ( and \ ) as parentheses. A simple example is seen below.
You agree "OK" or don't "not OK. D'accord "OK ou pas "not OK"?
\newcommandC\QUlC21 C% \ifthenelse{% \(\equalI#llCENG> \and \equalC#2){yesl\) \or \(\equalC#i){FRE) \and \equal{#2){oui)\))% {"OKJ')C"not OKH)%

>

You agree \QUCENG){yes) \par\bigskip D'accord \QU{FRE){oui)

or don't \QUCENG)Cno). ou pas \QUCFRE){non)?

Appendix

TEX Archive Sites

If, after reading this book, you still have not found the file you need, you can consult the TeX-index file [36] maintained by David Jones (MIT).It is a catalogue of macros for TEX, EQX, and others. Its scope includes a l l macros that are available via anonymous ftp or mail server on all sites mentioned below. The file TeX-index itself, like all packages and files described in this book, is available via anonymous ftp on the Internet or through a mail server.

B . l The Main T E XInternet Sites


Presently, various TEXuser communities are coordinating their efforts to provide E X users as possible. A recent easy access to TEX-relatedmaterial for as many T development is the "Comprehensive TEX Archive Network" (CTAN), which has been set up [23]. At present, it includes the Aston, Sam Houston State University, and Dante Internet sites. These sites provide essentially the same TEX-related software by mirroring each other. Please bear in mind the geographical location of the site to whch you intend to ftp. Choose a site as close to you as possible. Also, transfer rate will be drastically improved if you transfer large files outside normal (local!) worlung hours. The short list below shows the main T E X archives in Europe and the United States of America. The directory where Jones' TeX-index can be found is shown right-adjusted on the first line of each applicable ftp address. The CTAN archives are marked with an asterisk (*).

476

TFX Archive Sites

America
ftp.shsu.edu*

/tex-archive/help/TeX-index
/pub/tex/tex-index

A CTAN site.
ftp.math.utah.edu

Nelson Beebe's server, which contains a lot of BETEX-related styles and data bases, especially in the field of text processing and mathematics. It has, for example, tugboat.bib, which lists all the articles published in TUGBoat.
1abrea.stanford.edu

The official repository for TEX, METAFONT, dvips, and related files.

Europe
ftp.dante .de* /pub/tex/help/TeX-index

A CTAN site. Also the primary source for emTeX, publicTeX, pubIicMF, and the "Mainz" packages by Frank Mittelbach and Rainer Schopf (multicol, verbatim, theorem, NFSS, ftnright, and array).
ftp.tex.ac.uk* ftp.cs.ruu.nl

/pub/archive/help/TeX-index

A CTAN site. Home of the UKTeX electronic newsletter.


/pub/TEX/DOC/TeX-index.gz

For the location of one of the more well-known packages, you can search archie for an archve site that carries the file. You can also find a lot of information using the gopher, www, or wais service. Further information about (LA)TEX is also contained in the frequently asked questions file tex.f aq, maintained by Bobby Bodenheimer (Caltech, USA) (available from all archives mentioned above and from the reference site pit-manager .mit .edu as /pub/usenet/news .answers/tex-f aq) and the "Supplementary TeX Information" file, maintained by Guoying Chen (NYU, USA) (reference site cs .nyu .edu in the directory f tp/pub/tex).

Getting Files from an Archive


Figures B.l and B.2 on pages 477-478 show an ftp session to the Aston CTAN archive. The first command cd ctan: sets us in the top directory of the "CTAN" tree. Then we issue the command quote site index xspace.sty, which locates the file xspace. sty and shows its full file name in the CTAN file hierarchy. We go to the directory where that file resides with the command cd macros/latex/contrib/misc and get the file in question using get xspace. sty. We repeat the procedure for Jones's TeX-index file, going to the relevant directory and retrieving it. In t h s case we specify the command get TeX-index.gz, which compresses the file on the fly using the gzip utility (which we chose by specifying the extension gz). These compressed files must be

B.l

The Main TEX Internet Sites

477

transferred in binary mode, hence the command binary before the get. At any moment, you can issue the command dir or 1s to see what is availab6or pwd to see i n which directory you are. As see= theexample, the CTAN archivesupport dynamic compression and uncompression of data sets, so that large files can be conveniently transferred (for instance, in the case of the TeX-index file, the compressed file is four times smaller-86,168 instead of 367,136 bytes-so the transfer time is reduced drastically). If your machine does not have uncompression tools, a compressed file can be uncompressed on the fly. The exact procedure of how these facilities work is explained in the online documentation at the CTAN sites. You can also get the listing of the contents of a (tar, zip, zoo) archive by appending the suffix -1st to the name of the archve, as shown in the command get morebin.zip-1st below. The command !more shows the contents of the morebin zoo archive on our local node.

$ ftp ftp.tex.ac.uk Connected to ftp.tex.ac.uk. 220 ftp.tex.ac.uk FTP server (Version 2.OWU(ll) Wed Apr 28 22:25:23 GMT 1993) ready. Name (ftp.tex.ac.uk:goossens): anonymous 331 Guest login ok, send e-mail address as password. Password: goossensQmysystem.cern.ch (use your email address) 230-Welcome, archive user! This is an FTP server for the UK TeX Archive. .... several lines of information not shown .... 230 Guest login ok, access restrictions apply. ftp> cd ctan: 250 CWD command successful. ftp> quote site index xspace.sty 200-index xspace.sty 200-NOTE. This index shows at most 20 lines. for a full list of files, 200-retrieve /pub/archive/FILES.byname 200-1992/09/21 1 5494 1 macros/latex/contrib/misc/xspace.sty 200 (end of 'index xspace.styl) ftp> cd macros/latex/contrib/misc 200 CWD command successful. ftp> get xspace.sty 200 PORT command successful. 150 Opening ASCII mode data connection for xspace.sty (5494 bytes). 226 Transfer complete. 5645 bytes received in 3.67 seconds (1.50 Kbytes/s)

Figure B.l: An example ftp session to the Aston CTAN TEX archive (part 1)

4 78

TEX Archive Sites

ftp> quote site index TeX-index 200-index tex-styles 200-NOTE. This index shows at most 20 lines. for a full list of files, 200-retrieve /pub/archive/FILES.byname 200-1993/01/04 1 367136 1 help/TeX-index 200 (end of 'index tex-styles') ftp> cd ctan: 250 CWD command successful. ftp> cd help 250 CWD command successful. ftp> binary 200 Type set to I. ftp> get TeX-index.gz 200 PORT command successful. 150 Opening BINARY mode data connection for /bin/gzip. 226 Transfer complete. 86168 bytes received in 17.61 seconds (4.78 Kbytes/s) ftp> cd ctan: 250 CWD command successful. ftp> cd systems/msdos/emtex-contrib/bonus 250 CWD command successful. ftp> get morebin.zip-1st 200 PORT command successful. 150 Opening BINARY mode data connection for /bin/LIST. 226 Transfer complete. 1595 bytes received in 0.68 seconds (2.28 Kbytes/s) ftp> !more morebin.zip-1st Listing of ./morebin.zip Length Method Size Ratio Date Time CRC-32 Name (I1^" ==> case ------ ------ ---- ----- ----- - - - - - - - ---conversion) 36000 Implode 17648 51% 01-27-92 16:34 7a371924 -emtex/wp2latex.exe 23535 Implode 14583 38% 11-25-91 17:31 8dff2c94 -emtex/dvi2tty.exe 50422 Implode 27970 45% 12-12-91 21:04 7e2ac940 ^emtex/dviselec.exe 26897 Implode 12942 52% 12-12-91 09:54 6f3a375e -emtex/dvidvi.exe 48608 Implode 27219 4 4 % 12-12-91 21:29 fd19e62a -emtex/dviconca.exe .... several lines of information not shown ....
------------ -- - - - --

407402 ftp> quit 221 Goodbye.

203175 50%

16

Figure B.2: An example f t p session to the Aston CTAN TEX archive (part 2)

B.2 Mail Servers

479

B.2 Mail Servers


Those who cannot connect directly to the Internet but who have access to electronic mad can also retrieve files and information by using mail servers, which have been set up by many sites carrying TEX-related information. Note, however, that each server tends to have its own syntax, which in each case must be carefully followed. More information can be found in the TEX supplementary information list maintained by Guoying Chen. Examples of mail servers and commands of how to contact them are shown in figure B.3. address: message: address: message: address: message:
ftpmailadante.de help f ileservashsu.edu help mail-serveracs .ruu.nl begin path useramachine.site (your email address) send help

address: listserv0hearn.bitnet message: get tex f ilelist to get a list of files available address: 1istservQvm.urz.uni-heide1berg.de message: help get readme first tex eet tex filelist

Figure B.3: Example of TEX mail servers

B.3 TEX User Groups


TEX users in several countries have set up TEX user groups, mostly based on language affinities. If you need help, you are advised to contact your local user group first, since they might be able to come up with an answer that is most suited to your language-dependent working environment. Below we give the addresses of the groups known to us (fall 1993). Often they can help you obtain TEX-relatedmaterial on diskettes or offer a mail service for those without access to the Internet.
TEX Users Group

(International) T E X Users Group P.O. BOX 869 Santa Barbara, CA 93102-0869 USA

Tel: 805-963-1338 Fax: 805-963-8358 Email: tugatug.org

480
CsTUG (Czech and Slovak Republics) Dr. Karel Her*, President ~eskoslovenskC sdruieni uiivatelfi TEXU CSTEXUsers Group, c/o @ UK Sokolovska 83 CS-186 00 Praha 8, Czechoslovakia Email: horakkQearn.cvut.cz C y T U G (Russia) Irina Makhovaya, Executive Director Associaciia Pol'zovatelei Kirillicheskogo TEX'a Mir Publishers 2, Pervyi RizhskiT Pereulok Moscow 129820, Russia Tel: 095 286-0622, 286-1777 Fax: 095 288-9522 Email: cyrtugQmir .msk .su DANTE e.V. (German-speaking) Joachirn Lamrnarsch, President Deutschsprachige Anwendervereinigung TEX e.V. Postfach 101840 D-69008 Heidelberg, Germany Tel: 06221/29766 Fax: 06221/167906 Email: danteadante .de Estonian User Group Enn Saar, Tartu Astrophysical Observatory, Tdravere ~ ~ 2 4 Estonia 44 Email: saarQaai .ee GUST (Poland) Hanna Kolodziejska, President Polska Grupa Uzytkownikow Systemu TEX Instytut Bad& Systemowych PAN ul. Newelska 6 PL-01-447Warszawa, Poland Email: gust0camk.edu .pl GUTenberg (French-speaking) Alain Cousquer, President Groupe francophone des Utilisateurs de TEX GUTenberg, c/o IRISA Campus de Beaulieu F-35042 Rennes cedex, France Email: gut0irisa.fr

TFX Archive Sites

ITALIC Irish TEX And L Q X Interest Community (informal) Discussions on mailing list ITALIC-L hosted on the list server
1istservQirlearn.ucd.ie

(open for public subscription).


Japan TUG (Japan) Nobuo Saitoh, Chairman Japan TEX Users' Group Faculty of Environmental Information Keio University 5322 Endo, Fujisawa-shi JP-252 Japan Tel: +81466 47 5111 Email: ns0keio .ac . i~
A , .

Nordic TEX Group (Scandinavia) Roswitha Graham KTH (Royal Institute of Technology) TS DATA S-lOO 44 Stockholm, Sweden Email: roswithaQadmin.kth. se NTG (Dutch-speaking) Kees van der Laan, Chair Nederlandstalige TEX Gebruikersgroep Postbus 394 NL-1740 AJ Schagen The Netherlands Email: ntg0nic.surfnet.nl Spanish TUG (no formal group) Electronic mail discussion list
spanish-tex0eunet.e~

Send subscription requests to Email: 1istservQeunet .es Julio Sanchez G M V SA Isaac Newton 11 PTM Tres Cantos E-28760 Madrid, Spain Email: j sanchezQgmv .es UK TUG (United Kingdom) Chris Rowley, Chair UK TEX Users' Group c/o Peter Abbott 1 Eymore Close Selly Oak Birmingham B29 4LB, United Kingdom Email: uktug-enquiriesQtex.ac.uk

Bibliography

[I] Adobe Systems Incorporated. PostScript Language Tutorial and Cookbook. Addison-Wesley, Reading, 1985.
This so-called "blue book" is the most common tutorial book on PostScript. It consists of two parts, an easy-to-follow tutorial introduction to the language and its graphics prirnitives and a cookbook, consisting of 21 programs that show how PostScript is used in real applications. The code of the examples covers most of the common applications that you will encounter and can be readily included in your own packages. The main drawback of this book is that it only describes PostScript Level 1. A more recent and very good introduction to PostScript Level 2 for PostScript users at all levels is PostScript by Example, by Henry McGilton and Mary Campione, Addison Wesley, 1992. The book also starts at novice level, but in later chapters it covers Level 2 features, such as composite fonts, patterns, forms, color and halftones. It has over 500 fragments of PostScript code and 750 illustrations.

[2] Adobe Systems Incorporated. PostScript Language Reference Manual. Addison-Wesley,Reading, second edition, 1990.
This so-called "red book" contains the complete definition of the PostScript language. It describes all PostScript Level 1 and Level 2 operators as well as the Display PostScript extensions. Appendices define the Document Structuring Conventions and the Encapsulated PostScript File Fonnat.

[31 Adobe Systems Incorporated. Adobe Type 1 Font Fonnat. Addison-Wesley, Reading, 1990.
This so-called "black book" contains the specifications for Adobe's Type 1 font format. It includes information on the structure of font programs, explains how computer outlines are specified and gives the contents of the various font dictionaries. It also covers encryption, subroutines, hints, and compatibility issues in the use of Adobe Type Manager.

[4] Jacques Andre and Jeanine Grimault. Emploi des capitales (premiere partie). Cahiers GUTenberg, 6:42-50, July 1990.
On the use of capitals in French.

482

Bibliography
[5] Jacques Andre and Philippe Louarn. Notes en bas de pages : comment les faire en L A T E X ? Cahiers GUTenberg, 1257-70, December 1991.
Several special cases of using footnotes with BTEX are discussed, for example, how to generate a foomote referring to information inside a tabular or rninipage environment or how to reference the same footnote more than once.

[6] Guide du typographe romand. Association suisse des compositeurs a la machine, 4e edition, 1982.
Typographic rules for French as used by the Roman Swiss typesetters.

[7] Richard Aurbach. 1dxT~X and GloT~x-indexes and glossaries. TUGboat, 7(3):187, October 1986.
A short description of two VAX/VMS specific processors for BTEX indexes and glossaries.

[8] Richard Aurbach. Automated index generation for W X . TUGboat, 8(2):201, July 1987.
After a short introduction to the 1dxT~X project, Richard Aurbach describes how the VAX/VMS program 1dxT~X provides a full range of services for index generation. The input syntax is presented, and the internal data structures and various parts of the program are reviewed.

[9] Nelson H. F. Beebe. Bibliography Prettyprinting and Syntax Checking. TUGboat, 14(4):395-419, December 1993.
Three software tools for BIBTEX support are described. The first, bibclean, is a prettyprinter, syntax checker, and lexical analyzer for BIBTEX files. The second is biblex, a lexical analyzer capable of tokenizing a B I B T E X file. The third is bibparse, a parser that analyzes a lexical token stream from bibclean and biblex. bibclean is extensively customizable using initialization files, and run-time definable patterns for checking BIBTEX value strings. A pattern-matching language is provided for this purpose.

[lo] Karl Berry. Filenames for fonts. TUGboat, 11(4):517-520, November 1990.
A consistent, rational naming scheme for font file names is proposed. Each name consists of up to eight characters that should identify each font file in a unique way.

[ l l ] Neenie Billawala. Metarnarks: Preliminary studies for a Pandora's Box of shapes. Technical Report STAN-CS-89-1256,Stanford University, Department of Computer Science, May 1989.
A pleasing booklet describing studies of shapes for font production, like serifs, arches, bowls, etc. These studies eventually led to a typeface called Pandora.

[12] Neenie Billawala. Opening Pandora's Box. TUGboat, 10(4):481-489, December 1989.
When creating the Pandora type family the author tried to use METAFONT as a design tool rather than a production tool. General descriptions of visual relationships between parts of characters, characters in a font, and fonts in a typeface were developed, so that one obtains the various fonts by changing the parameter settings of a single framework. This allows the designer to quickly study various possibilities.

[13] Hans-Hermann Bode. Neue BETEX-Style-Files:Die adaptable family. Die T~Xnische Komodie, 4(2):31-41, August 1992.
A new family of BIBTEX style files is introduced, in which the user can change the layout (fonts used for specific fields) and some words or phrases used by the style (such as the names

Bibliography
of months, edition, chapter, articles, and conjunctions). These strings are parameterized inside the BBTEX styles and are resolved when T~Xing a document by reading a languagedependent external file that defines these terms for the chosen language.

483

[14] Francis Borceux. User's guide for the Diagram Macros. Electronic document distributed with the package, February 1993.
Commutative diagram package. Especially useful for the construction of diagrams in category theory. Uses IiQX picture mode as the underlying drawing mechanism.

[15] Johannes Braams. Babel, a multilingual style-option system for use with INEX'S standard document styles. TUGboat, 12(2):291-301,June 1991.
A description of a way to make UTEX adaptable to more than one language via the use of language-specific style options. An update was published in TUGboat, 14(1):60-62, April 1993.

[16] Pehong Chen and Michael A. Harrison. Index preparation and processing. Software-Practice and Experience, 19(9):897-915,September 1988. The L A T E X text of this paper is included in the makeindex software distribution.
This paper shows how the tedious and time-consuming task of preparing an index can be automated in a way largely independent of the typesetting system and the specific format used. The ideas are illustrated with the help of the Makelndex system, which transforms raw index data into an alphabetized version. A comparison of that system with other indexing facilities is made.

[17] Adrian F. Clark. Practical halftoning with TEX. TUGboat, 12(1):157-165,March 1991.
Reviews practical problems encountered when using TEX for typesetting halftone pictures and compares other techniques to include graphics material. Advantages and disadvantages of the various approaches are described and some attempts at producing color separations are discussed.

[18] Malcolm Clark. Portable graphcs in TEX. TUGboat, 13(3):253-260, October 1992, and Chapter 17 of A Plain T~XPrimer, by Malcolm Clark, Oxford University Press, 1992.
Discusses three major ways to include line graphics in TEX documents: special fonts, the \special command, and in-between solutions. Other reviews are TEX and Graphics: The State o f the Problem, by Nelson Beebe, in: Cahiers GUTenberg, 2:13-53, May 1989, and Including Pictures in TEX,by Alois Heinz, in: T~Xapplications, uses, methods, Malcolm Clark (ed.), Ellis Horwood Publishers, Chichester, England, pp. 141-151, 1990.

[19] Dale Dougherty and Tim O'Reilly. UhllX Text Processing. Howard W . Sarns & Company, Hayden Books, Indianapolis, 1988.
This book provides a complete description of UNIX's text processing tools. In particular, chapter 10, "Drawing Pictures," explains the syntax of the pic processor language with a lot of examples. Information about that language is also available in the UNM man pages for the pic and gpic (GNU) processors.

[20] Lincoln Durst. Some tools for making indexes: Part I. TUGboat, 12(2):248-252,June 1991.
Reviews basic TEX coding tricks to generate indexes. You can also have a look at David Salomon's article Macros for indexing and table-of-contents in: TIIGboat, 10(3):394-400, November 1989.

[211 Bernard Gaulle. Notice d'utilisation du style french (Version 3,25). Electronic document distributed with the package, November 1993.
A user guide to the french package (in French).

[221 Ronald L. Graham, Donald E. Knuth, and Oren Patashnik. Concrete Mathematics: A Foundation for Computer Science. Addison-Wesley, Reading, 1989.
A well typeset mathematics textbook, prepared with TEX, where the Concrete Roman typeface is used as main text font; see also [45].

[23] George D. Greenwade. The Comprehensive T E X Archive Network (CTAN). TUGboat, 14(3):342-351, October 1993.
An outline of the concept, development, and use of the CTAN archive, which makes all TEX-related files available on the network. CTAN relies on the close collaboration of the major T E X archives on various continents, which run synchronized mirror images of each other. CTAN provides a consistent way for identifying files and for retrieving them and thus should contribute to a reduction of overall network traffic and an increase of retrieval speed.

[241 Roswitha T. Haas and Kevin C. O'Kane. Typesetting Chemical Structure Formulas with the Text Formatter TEX/IN&X. Computers and Chemistry, 11(4):25 1-271, 1987.
The article gives an overview of the possibilities of the ChemTEX package. More information can be found in the various chapters of Haas's Ph.D. thesis that are distributed with the package. Other tools for typesetting chemical formulae are discussed in Electronic Publishing and Chemical Text Processing, by A.C. Norris and A.L. Oakley, in: TEX applications, uses, methods, Malcolm Clark (ed.), Ellis Honvood Publishers, Chichester, England, pp. 207-225, 1990, and in Chemical Structure Formulae and x/y Diagrams with TEX by Michael Ramek, ibidem, pp. 227-258.

[25] Yannis Haralambous. Typesetting old german: Fraktur, Schwabacher, Gotisch and initials. TUGboat, 12(1):129-138,March 1991.
Shows how METAFONT can be used to recreate faithful copies of old style typefaces, which can be used with TEX. Rules for typesetting in the types are given and example output pages are shown.

[261 Doug Henderson. Outline fonts with METAFONT. TUGboat, 10(1):36-38,April 1989.
A description of the METAFONT code used to generate outlines from existing character descriptions.

[271 Eric van Herwijnen. Practical SGML. Wolters-Kluwer Academic Publishers, Boston, second edition, 1994.
An introduction to the use of SGML in real-life applications. Contains a lot of examples of areas where SGML has been successfully used and discusses various SGML implementations.

[28] Alan Hoenig. When T E X and Metafont Work Together. In Proceedings of the 7th European TEX Conference, Prague, pp. 1-19, September 1992.
A description of how TEX and METAFONT can communicate data to allow you to prepare diagrams and figures with METAFONT and labels with TEX. Conversely, METAFONT can generate special purpose fonts that can, for instance, be used to typeset text along a c w e d baseline.

Bibliography
[29] Thomas Hofmann. A W X addition for formatting indexes. TUGboat, 7(3):186, October 1986.
The description of a Bourne Shell script, latexindex, to handle W X indexes.

485

1301 IBM, International Business Machines Corporation. Font Object Content Architecture: Reference, New York, December 1988.
This manual describes the concepts of IBM digital font resources and their application. It gives general information on font storage, accessing, and referencing, and it explains concepts of character shape information. It gives a full reference of the font parameters used in IBM fonts including font-descriptiveparameters, font-metric parameters, charactershape parameters, and code page parameters.

[31 1 IBM, International Business Machines Corporation. Document Composition Facility-General Information Release 4.0 for DCF (GH20-9158-09),Boulder, 1990.
This manual contains general information about IBM's Document Composition Facility, which provides a text formatter, called SCRIPTflS. It can process documents marked up with its own control words as well as documents marked up in the GML-Generalized Markup Language-a precursor of SGML. The system also has an (optional) Script Mathematical Formula Formatter-SMFF.

[32] Lexique des regles typographiques en usage a I'Imprimerie nationale. Imprirnerie nationale, 3e edition, 1990.
Typographic rules for French as used by the "Imprimerie nationale," in Paris, the printing house that is responsible for printing all official government documents and all books edited by the French state.

[33] International Organization for Standardization. 8-bit single-byte coded graphics character sets, parts 1 to 10. IS0 8859, IS0 Geneva, 1986-92.
A description of various alphabetic character sets. Parts 1 to 4, 9, and 10 correspond to character sets needed to encode different groups of languages using the Latin alphabet, while part 5 corresponds to Cyrillic, part 6 to Arabic, part 7 to Greek, and part 8 to Hebrew.

[34] International Organization for Standardization. Standard Generalised Markup Language (SGML). IS0 8879, IS0 Geneva, 1986.
The-not always easy to read-IS0 standard describing the SGML language in glorious technical detail. An easier to read review article, describing the role of SGML as first element in a chain of text processing standards, comprising also DSSSL (document formatting), SPDL (document presentation), and Unicode/ISO 10646 (character codes), is Scientific Text Processing, by Michel Goossens and Eric van Herwijnen, in International Joumal of Modem Physics C, 3(3):479-546, June 1992.

[35] International Organization for Standardization. Universal Coded Character Set. ISO/IEC 10646, IS0 Geneva, 1993.
This standard specifies the structure and defines the Universal Multiple-Octet Coded Character Set (UCS). It is a 32-bit character encoding standard, which can be used to encode all possible writing systems in the world. At present only the 16-bit base plane has been defined, and it is identical to the Unicode standard; see [85]. A short overview of this standard and its history can be found in Untying tongues, by Michael Y . Ksar, in iso bulletin, 24(6):2-8, June 1993.

486

Bibliography
I361 David M. Jones. A TEX macro index. TUGboat, 13(2):188-189,July 1992.
In this article David Jones officially announces his catalogue of TEXmacros that are available via anonymous ftp or mailserver. A summary of archive locations where this catalogue is stored was published in T ~ X a n d TUG NEWS, Z(2):lZ-13, April 1993.

[37] Donald E. Knuth. T ~ X a n d Metafont, New Directions in Typesetting. The American Mathematical Society and Digital Press, Bedford, MA, 1979.
The first part of this book contains the reprint of an article by Donald Knuth called "Mathematical Typography," where the author discusses his motivation for starting to work on TEX and traces the early history of computer typesetting. The second and third parts of this book describe early (and now obsolete) versions of TEX and METAFONT, but they remain interesting reading for T E X historians.

[381 Donald E. Knuth. Remarks to Celebrate the Publication of Computers & Typesetting. TUGboat, 7(2):95-98, June 1986.
On May 21, 1986, the Computer Museum in Boston hosted a celebration in honor of the completion of TEX, Donald Knuth's computer typesetting system. This article summarizes the text of Knuth's speech on that occasion in which he retraced his nine years of work on the T E X and METRFONT systems.

[391 Donald E. Knuth. The T~Xbook, volume A of Computers and Typesetting. Addison-Wesley, Reading, 1986.
The definitive user's guide and complete reference manual for TEX.

[40] Donald E. Knuth. TEX The Program, volume B of Computers and Typesetting. Addison-Wesley, Reading, 1986.
The well typeset complete source code listing for the TEX program. The TEX program is written in the WEB language and the book is a (slightly edited) version of the source after running WEAVE and T~Xing the output.

[411 Donald E. Knuth. The METAFONTbook, volume C of Computers and Typesetting. Addison-Wesley, Reading, 1986.
The user's guide and reference manual for M ETAFONT, the companion program to TEX for designing fonts.

1421 Donald E. Knuth. METAFONT: The Program, volume D of Computers and Typesetting. Addison-Wesley,Reading, 1986.
The complete source code listing of the METAFONT program.

[43] Donald E. Knuth. Computer Modem Typefaces,volume E of Computers and Typesetting. Addison-Wesley,Reading, 1986.
Over 500 Greek and Roman letterforms, together with punctuation marks, numerals, and many mathematical symbols, are graphically depicted. The METAFONT code to generate each glyph is given and it is explained how, by changing the parameters in the METAFONT code, all characters in the Computer Modern family of typefaces can be obtained.

[44] Donald E. Knuth. Fonts for digital halftones. TUGboat, 8(2):135-160, July 1987.
A discussion of some experiments in which METRFONT was used to create fonts to generate halftones on laser printers.

[45] Donald E. Knuth. Typesetting Concrete Mathematics. TUGboat, 10(1):31-36,April 1989.


Donald Knuth explains how he typeset the textbook Concrete Mathematics.

[46] Donald E. Knuth. Virtual Fonts: More Fun for Grand Wizards. TUGboat, 11(1):13-23,April 1990.
An explanation of what virtual fonts are and why they are needed. This information is followed by technical details of how these ideas are implemented.

[47] Donald E. Knuth. The Future of TEX and Metafont. TUGboat, 11(4):489,November 1990.
My work on developing TEX, METAFONT, and Computer Modem has come to an end. I will make no further changes except to correct extremely serious bugs. In the article starting with these words Donald Knuth announces that he wants to freeze the programs of the TEX system at their present versions.

[48] Conrad Kwok. EEPIC: Extensions to EPIC and IPQX picture environment. Unpublished machine-readable document, 1988.
The user guide to the eepic package, which is distributed together with the software. Eepic is an extension of both UTEX and epic.

[49] Leslie Lamport. UTEX-A Document Preparation System-User's Guide and Reference Manual. Addison-Wesley, Reading, 1985.
The ultimate reference on UTEX 2.09 by its author. A new edition covering UTEXzE is in preparation. It nicely complements the material presented in the present work.

[SO] Leslie Larnport. Makelndex, An Index Processor For L A T E X . Electronic document coming with the Makelndex distribution, 1987.
This document explains the syntax that can be used inside BTEEX'S\index command when using Makehdex to generate your index. It also gives a list of the possible error messages.

[51 1 John Lavagnino and Dominik Wujastyk. An Overview of EDMAC : A plain TEX format for critical editions. TUGboat, 11(4):623-643, November 1990.
EDMAC lets you typeset critical editions of texts in a traditional way, i.e., similar to the Oxford

Classical Texts, Shakespeare, and other series. The package adds marginal line numbering and multiple series of footnotes and endnotes keyed to line numbers. Users can control the exact format of their editions in a simple way.

[52] Micheal J. S. Levine. A W X Graphics Routine for drawing Feynman Diagrams. Computer Physics Communications, 58:181-198, 1990.
A description of the Feynman package for drawing Feynman diagrams. More details can be

found in Levine's Ph.D. thesis, which is distributed as a UTEX file with the package.

[53] Franklin Mark Liang. Word Hy-phen-a-tionby Com-pu-ter. Ph.D. thesis, Stanford University, Stanford, CA 94305, June 1983. Also available as Technical Report No. STAN-CS-83-977,Stanford University, Department of Computer Science.
A detailed description of the word hyphenation algorithm used in TEX.

Bibliography
[54] Frank Mittelbach. An extension of the F&X theorem environment. TUGboat, 10(3):416-426, November 1989.
The different mathematics journals often require different layouts for their theorems. When using the theorem package this layout can be customized with the help of a "style." The article describes the user interface and implementation.

[55] Frank Mittelbach. E-TEX: Guidelines for future TEX extensions. TUGboat, 11(3):337-345, September 1990.
TEX started out originally as a system to typeset Donald Knuth's books. Nowadays it is used by tens of thousands of users. Is TEX still the right tool to address the typesetting requirements of the nineties? To answer this question, the output of TEX is compared with that of hand-typeset documents. Areas where TEX'Salgorithms are too limited in scope are discussed. It is shown that many important concepts of high quality typesetting are not supported and that further research to design a "successor" typesetting system to TEX should be undertaken.

[56] Frank Mittelbach. Comments on "Filenames for Fonts" (TUGboat 11#4). TUGboat, 13(1):51-53, April 1992.
Some problems with K. Berry's naming scheme are discussed, especially from the point of view of defining certain font characteristics independently and the use of the scheme with NFSS.

[57] Frank Mittelbach and Chris Rowley. P Q X 2.09

TUGboat, 13(1):96-101,April 1992.

mX3.

A brief sketch of the m X 3 Project, retracing its history and describing the structure of the system. An update appeared in TUGboat, 13(3):390-391, October 1992. A call for volunteers to help in the development of m X 3 and a list of the various tasks appeared in TUGboat, 13(4):510-515, December 1992. The article also describes how you can obtain the current task list as well as various mT~x3 working group documents via email or ftp and explains how you can subscribe to the ~ T E X discussion ~ list.

[58] Frank Mittelbach and Rainer Schopf. A new font selection scheme for TEX macro packages - the basic macros. TUGboat, 10(2):222-238, July 1989.
A description of the basic macros used to implement the first version of UTEEX'SNew Font Selection Scheme.

[59] Frank Mittelbach and Rainer Schopf. With W&X into the Nineties. TUGboat, 10(4):681-690, December 1989.
As N T E X has spread into many different fields, many local changes and enhancements threaten the possibility of exchanging documents. Therefore this article proposes a reimplementation of L Q X that preserves the essential features of the current interface while taking into account the increasing needs of the various user communities. It also formulates some ideas for further developments.

[60] Frank Mittelbach and Rainer Schopf. Reprint: The new font family selection -User interface to standard L A T E X . TUGboat, 11(2):297-305, June 1990.
A complete description of the user interface of the first version of UTEX'SNew Font Selection Scheme.

[61] Frank Mittelbach and Rainer Schopf. Towards IkQX3.0. TUGboat, 12(1):74-79, March 1991.

Bibliography
The objectives of the m X 3 project are described. The authors examine enhancements to KQEX's user and style file interfaces that are necessary to keep pace with modern developments, such as SGML. They also review some internal concepts that need revision.

489

Olivier Nicole, Jacques Andre, and Bernard Gaulle. Notes en bas de pages : comrnentaires. Cahiers GUTenberg, 15:46-52, April 1993.
Comments, clarifications, and additions to article [5].

Hubert Partl. German TEX. TUGboat, 9(1):70-72, April 1988.


An early example of an attempt to use UTEX with a language other than English, in this case German, and the problems that were encountered.

Oren Patashmk. BIBTEXing. Documentation for general BIBTEX users, 8 February 1988. Electronic document coming with the BIBTEX distribution.
This article describes, together with appendix B in Lamport's UTEX manual, the user interface to BBTEX. It updates section B.2 in the manual and provides many useful hints for controlling the behavior of BIBTEX.

Oren Patashnik. Designing BIBTEX styles. The part of BETEX'S documentation that's not meant for general users, 8 February 1988. distribution. Electronic document coming with the BIBTEX
A detailed description for BBTEX style designers of the postfix stack language used inside BBTEX style files. After a general description of the language, all commands and built-in functions are reviewed. Finally BBTEXname formatting is explained in detail.

Sunil Podar. Enhancements to the picture environment of MQX. (Version 1.2) Technical Report 86-17, Department of Computer Science, S.U.N.Y, 1986.
This document describes some new commands for the picture environment of UTEX, especially higher-level commands that enhance its graphic capabilities by providing a friendlier and more powerful user interface. This should make it easier to create more sophisticated pictures with less effort than in basic UTEX.

Sebastian Rahtz. A survey of T E X and graphics. Technical Report CSTR 89-7, University of Southampton, Department of Electronics and Computer Science, Southampton SO9 5NH, England, October 1989.
A detailed review of various ways to include graphics material in UTEX documents

Sebastian Rahtz and Leonor Barroca. A style option for rotated objects in W X . TUGboat, 13(2):156-180,July 1992.
A detailed description of the user interface and the implementation of the rotating package, which allows you to perform all the different sorts of rotation you might like, including complete figures, within the context of a whole series of Postscript drivers.

Glenn C. Reid. Postscript Language Program Design. Addison-Wesley, Reading, 1988.


This so-called "green book" teaches you the programming fundamentals for designing efficient PostScript code, which is easy to understand and maintain. Some of the tasks discussed in the book are: setting text, dealing with graphics, and error-handling and debuggmg techniques.

490

Bibliography [701 G l e C. ~ Reid. Thinking in PostScript. Addison-Wesley,Reading, 1990.


This book's aim is to teach you how to develop your PostScript programming skills by introducing you to some useful, though simple and elegant, programming techniques. Subject areas that are hardly covered anywhere else are discussed, for instance, how to optimize your loops, conditionals, and input/output, and how to deal with files, strings, and dictionaries.

[71] Thomas J. Reid. Floating figures at the right-and-Some testing. TUGboat, 8(3):315,November 1987.

random text for

A description of the techniques used to implement the figure placements.

[72] Tomas Rokicki. DVIPS: A TEX Driver. Electronic document coming with the dvips distribution, January 1993.
The user guide to dvips and its accompanying programs and packages, in particular afm2tfm for generating tfm files from Adobe's afm font metrics and colordvi for using color.

[73] Kristoffer H. Rose. Typesetting Diagrams with XY-pic: User's Manual. In Proceedings o f the 7th European TEX Conference,Prague, pp. 273-292, September 1992.
A detailed overview of the possibilities of the XY-pic package for drawing diagrams with TEX.

[741 Stephen E. Roth, editor. Real World PostScript. Techniques from PostScript Professionals. Addison-Wesley,Reading, 1988.
This so-called "orange book" contains a collection of articles written by professionals who have developed or used PostScript applications in their work. Subjects dealt with include sophisticated ways to use fonts and dictionaries, color issues, halftoning, precise kerning, tracking, and letterspacing.

[751 Richard Rubinstein. Digital Typography-An Introduction to Type and Composition for Computer System Design. Addson-Wesley, Reading, November 1988. Reprinted with corrections.
This book describes a technological approach to typography. It shows how computers can be used to design, create, and position the graphical elements used to present documents on a computer.

[761 Joachm Schrod. The Components of TEX. T'Xliine, 14:7-11, February 1992.
A short description of the supplementary programs and files, which, together with TEX, constitute a complete typesetting and authoring system.

[77] Ross Smith. Learning PostScript-A Visual Approach. Peachpit Press, 1085 Keith Avenue, Berkeley, C A 94708, 1990.
A very gradual and "visual" tutorial on the PostScript language. It introduces the main elements of the language with the help of examples, whose code is shown together with a short explanation on the left-hand pages, with the facing pages showing the resulting output.

[781 Friedhelm Sowa. Bitmaps and halftones with BMZFONT. TUGboat, 12(4):534-538,November 1991.

BM2FONT converts different kinds of bitmap files into TEX fonts and writes an input file for integrating these graphics into documents.

Code typographique. Syndicat national des cadres et maitrise du livre, de la presse et des industries graphiques, 13e edition, 1954.
Typographic rules for French as used by the French printing industry.

Paul Taylor. Commutative Diagrams in TEX (version 4). Electronic document distributed with the package, January 1993.
A Commutative diagram package. Compatible with most TEX formats. It uses the BTEX line fonts for diagonal arrows, or optionally can use PostScript specials to produce rotated arrows.

Philip Taylor. The future of TEX. In Proceedings o f the 7th European TEX Conference,Prague, pp. 235-254, September 1992.
A discussion of options on how to perpetuate the TEX philosophy, after Donald Knuth decided to freeze the current implementation.

T~Xplorators Corporation, 1572 West Gray, #377, Houston, TX 77019-4948 Mathtime, PostScript fonts for typesem'ng mathematics with TEX,1993.
Auser's guide, distributed with the fonts, that explains how to install and use the Mathtime fonts.

Harold Thunbleby. "See also" indexing with Makeindex. TUGboat, 12(2):290,June 1991.
Discusses how to code a "see also" entry for your indexes.

Harold Thimbleby. Erratum: "See also" indexing with Makeindex, TUGboat 12, no. 2, p. 290. TUGboat, 13(1):95,April 1992.
An erratum and some comments on [83].

The Unicode Consortium. Unicode 1.0-Draft Standard. Technical report, The Unicode Consortium, 1990.
A description of the 16-bit encoding standard adopted by most computer manufacturers. Unicode version 1.1 is identical to the 16-bit base plane of ISO-10646, see 1351.

The Chicago Manual o f Style. University of Chicago Press, thirteenth edition, 1982.
Since 1906 the University of Chicago Press Manual of Style has been the standard reference tool for authors, editors, and proofreaders in the United States and elsewhere. Thanks to its clear presentation, its many examples, its extensive index, and its detailed treatment of its various subject areas, the Chicago Manual provides easy-to-understand and straightforward guidelines for preparing your texts for the great majority of American publishers.

Peter Vollenrneider. Encapsulated Postscript: Applications for the Macintosh and PC. Prentice-Hall and Carl Hanser, Hertfordshxe, 1990.
This book focuses on how you can easily m i x text, graphics, and images at the Postscript level by using the Encapsulated PostScript format as an interchange standard. It emphasizes practical issues such as how to import graphics produced by desktop publishing tools in your documents on personal computers, UNIX workstations, or mainframes.

492

Bibliography
[88] Michael Vulis. VTEX enhancements to the TEX language. TUGboat, 11(3):429-434, September 1990.
The author describes his commercial VQX system, which supports its own scalable font format. More details are given in Michael Vulis's book Modem T ~ X a n d Its Application, CRC Press, Ann Arbor, 1993

[89] Michael J. Wichura. W'X: Macros for drawing Wtures. TUGboat, 9(2):193-197, August 1988.
F~CTEX is a collection of TEXmacros that make it easy to typeset complex pictures, especially mathematical figures. The F~CTEX manual is available from TEX Users Group.

[go] Relnhard Wonneberger. W X Kompaktfiihrer. Addson-Wesley Verlag, Bonn, Germany, thwd edition, April 1993.
A handy overview (in German) of all aspects of J A T E X that average users need in their daily work.

[91 1 Reinhard Wonneberger and Frank Mittelbach. BJBTEX reconsidered. TUGboat, 12(1):111-124,March 1991.
After a general discussion of BIBTEX, several proposals for enhancements and changes are discussed.

[92] Haviland Wright. SGML frees information. Byte, 17(6):279-286,June 1992.


Describes how SGML can help you avoid being overwhelmed by your data by emphasizing the definition of access structures for your information.

[93] Y&Y, 106 Indian Hill, Carlisle, MA 01741. LucidaBright + LucidaNewMath, 1992.
A user's guide, distributed with the fonts, that explains how to install and use the LucidaBright + LucidaNewMath fonts.

1941 Maurizio Zocchi. L A T E X S ' Index Processing. TUGboat, 8(1):62,April 1987.


The description of INDTEX, a BTEXindex processor running on VAX/VMS and on MS-DOS.

[added in the second printing] [95] George Gratzer. Math into TEX: A Simple Introduction to A + Birkhauser, Boston, 1993.
-BTEX.

The first part of the book provides the novice user of A&-BTEX with a simple approach, based on many examples, a formula gallery, sample files, and templates. The second part contains a systematic discussion with detailed examples and rules of all aspects of AML~TEX, while the final part looks at more advanced custornization issues.

Index
Bold face page numbers are used to indicate pages with important information about the entry, e.g., the precise definition of a command or a detailed explanation, while page numbers in normal type indicate a textual reference.

\', 103 \(, 474 \), 474 \*, 432 \,, 242 \-, 103,264 in ulem, 49 \/, 168 \ :,228,242 \;, 242 \=, 103 \!, 242 \a, so \@cite,373 \@addtoreset,15,22,72,242,446 \Qdotsep, 33 \@dottedtocline,32,33,34 \@evenfoot, 93 \@evenhead,9 3 \@idxitern,432 \@makecaption,154,155 \Qmakefigcaption, 155 \Qmakefnmark,71, 72 \Qmakefntext, 71, 73 \Qmkboth,95 \Qoddf oot, 92 \@oddhead,92 \Qpnumwidth rigid length, 33, 34

\aptsize, 8 9 \@rightskiprubber length, 51 \Qseccntf ormat, 23,24 \@startsection,24,25, 26-28,144 \Qstarttoc, 36 \Qthefnmark, 72 \Qtocmarg, 33,34 a!, 242 Q (((, 226,234 Q ) ) ) ,226, 234 Q,,242 a<<<,226,234 a>>>,226,234 QQ, 242 QAAA,234 QVVV,234
@ character

in command names, 15 made active, xii

\', 103 \, 220 \\, 28, 51, 104, 108, 111, 114, 119, 233,
239,240

within header or footer, 97

\\*, 240 \I, 220 \, 220 1 1 pt option, 12,13,170

494

7-bit input
7-bit input, 260 8-bit input, 260

amssymb package

Index

\ a ' , 103 a0paper option, 86 A4, see Paper size a4 package, 88, 392 a4dutch package, 89,90 a4paper option, 12,86,463 a4wide package, 89 AS, see Paper size a5 package, 89 a5comb package, 89 aspaper option, 86 \a=, 103 \ a f , 103 AAAA, 471,471 both, 472 indexentry, 472 indexonly, 472 abbrev BIBTEX style, 377,400 Abbreviation, 2 72 in BIBTEX, 402 space after -s, 50 abbrv BETEX style, 377, 379, 383, 400, 410,418 \abovedisplayshortskip rubber length, 257 \abovedisplayskip rubber length, 257 abstract BIBTEX style, 377, 406, 415 abstract environment, 30, 31 \abstractname, 31,267 Accent -s in BIBTEX, 402 in tabbing, 103 \accent, 203 \accentedsymbol, 224 acm BJBTEX style, 377, 379, 384 \acro, 169 Acronvm definition for, 169 Active character, xi, 274 \actualchar, 430 \acute, 218 Adaptable family BIBTEX multi-language system, 418 \addcontentdine, 29, 30,35,36 \adddialect, 265 \addlanguage, 265

\addtocounter, 21,446,468 \addtolength, 61,72,87,110,237,256, 449,468 \advance, 468 \AE, 172 .afm file, 316 afm2tfm program, 316, 340 afterpage package, 145, 150 \afterpage, 145, 146,150 agsm BIBTEX style, 377 \aleph, 219 align environment, 177,235,236-238, 244,246,249,250,344 align* environment, 235, 246,249 alignat environment, 235,237, 250, 251 alignat* environment, 235, 251 aligned environment, 239 alignedat environment, 239 \allinethickness, 301, 303 \allowdisplaybreaks, 239, 240 alltt package, 66 a l l t t environment, 66,67,68 Almost Computer Modern fonts, 157 Alph page number style, 92 \Alph, 22,29, 57,58,447 \alph, 57, 58,446 alph page number style, 92 alpha BIBTEX style, 377, 379, 383, 401, 407,410,412,415,418 \alpha, 2 18 \alsoseename, 267 \AltMacroFont, 432 \amalg, 218 american option, 267 AMS font package, 185, 205 AMS symbols, 220-222 amsalpha BIBTEX style, 377 amsart document class, 244 amsbook document class, 244 amsbsy package, 243,244 amscd package, 233, 234,243,244 amsfonts package, 184, 217,243, 244 amsplain BIBTEX style, 377 amssymb package, 184, 217-222, 243, 244

Index

amstex package

\batchf ile

495

arnstex package, vii, viii,x i i ,215, 216,


217-251,256 amstext package, 178,227,243,244 \and, 474 \angle, 219,222 annotate BBTEX style, 377,414,415 annotation BBTEX style, 377, 414, 415 annote BBTEX style, 409 apa BBTEXstyle, 377 apalike BBTEX style, 374, 377-380, 384 apalike package, 377,379 apalike2 BIBTEX style, 377 \Appendix, 29 \appendix, 29, 30 \appendixname, 3 1 , 2 6 7 \approx, 219 \approxeq, 221 \arabic, 22, 23, 57, 58,446 a r a b i c page number style, 92 \arc, 290,291,292,302 \arccos, 220 archie program, 476 \ a r c s i n , 220 \arctan, 220 \arg, 220 array package, 101,105-113,117,433, 476 a r r a y environment, viii, 51, 101, 102, 104, 107, 108, 110, 112, 114, 117, 129, 132, 135, 231, 235, 257,455 style parameters, 110 \arraybackslash, 114 \arraycolsep rigid length, 1 0 7 , 1 1 0 , 2 5 7 \arrayrulewidth rigid length, 110,131 \arraystretch, 106,110 Arrow commands, 219,242 as delirniters, 220 extensible, 2 26 in AMS fonts, 221 in commutative diagrams, 2 3 3 over symbols, 220, 223 \Arrowvert, 220 \arrowvert, 220 Arseneau, Donald, 49, 54, 133, 151, 373 a r t l l . c l o , 13

article document class, x, 3, 13, 15, 18,


20, 22, 30, 71, 87, 96, 244, 262, 364, 392,426,467 \Ask, 434 \ a s t , 59,218

astron BBTEX style, 374, 377 \asymp, 219 \AtBeginDocument, 461,466 \AtEndDocument, 4 6 1 , 4 6 6 \AtEndOfClass, 4 6 1 , 4 6 6 , 4 6 7 , 4 6 8 \AtEndOfPackage, 461,466 austrian option, 267 Author multiple -s (BBTEX),400 authordatel BBTEX style, 376, 377, 416 authordatel -4 package, 377 authordate2 BIBTEX style, 376, 377 authordate3 BIBTEX style, 376, 377 authordate4 BETEX style, 376, 377,416 .aux file, 4, 5, 16, 122, 367, 372, 373, 375,
378, 385,388, 392, 394

aux2bib program, 376, 392 avant package, 334 awk program, 392,393 Axonometric projection, 292 b5paper option, 8 6 babel package, viii, 12,261,262,
263-268,270, 272, 355, 360, 465 \backepsilon, 221 \backprime, 222 \backsim, 221 \backsimeq, 221 \backslash, 220 bar package, 283 \bar, 218,284 Bar chart, 283-287 barenv environment, 283-287 style parameters, 284-286 Barroca, Leonor, 320 \barwedge, 222

Baseline skip setting the -, 190-192 \baselineskip rubber length, 52, 53, 72, 87, 88, 99, 100, 106, 181, 451
\ b a s e l i n e s t r e t c h , 52, 53 basker package, 334 \batchf i l e , 434,435

496

\bat chinput

BJBTEXstyle

Index

\batchinput, 434 \Bbb, 217,218,243 \Bbbk, 222 .bbl file, 4, 5, 375, 376, 378, 385, 404,

\bibliographystyle, 378,379, 380,385,

386,388,392
\bibliographyunit, 386

405,411,413 style, 377 bbs BIBTEX Bcenter environment, 279 Bdescription environment, 279 \because, 221 Beebe, Nelson, 376, 393, 394, 476 Bellantoni, Stephen, 82 \belowdisplayshortskip rubber length, 257 \belowdisplayskip rubber length, 257 bernbo package, 334 Benumerate environment, 279 Beqnarray environment, 279 Beqnarray* environment, 279 Berry, Karl, 332-335, 337 \beta,218 \beth, 220 beton package, 181 \between, 221 bezier package, 280,287,293 \bezier,280 Bezier approximations, 280-281 \bf, 158,174 used in math, 176,186 \bf def ault, 173,174 Bf lushleft environment, 279 Bf lushright environment, 279 \bfseries, 25,49, 59,105,167,170,171, 173, 174, 175, 183, 185, 254, 255 used in math, 175, 176 .bib file, 4,5,375,376,392-394,398, 402,403,405,406,411 bibclean program, 393 bibextract program, 393 \bibhang rigid length, 374 \bibindent rigid length, 374 \bibitem, 372,374,406,411 bibkey program, 392,393 Bibliography, 40, 371-420 .bbl file, 5 style parameters, 373, 374 styles for -, 6,377-385 \bibliography, 379,385,386, 392,403

biblist package, 392, 395 bibrnods package, 394, 397 \bibname, 31,267 \bibpunct, 374 bibsort.sh program, 394 BIBTEX, 5, 371-420 abbreviation, 402 accented characters, 402 adaptable style family, 4 18 built-in function, 407 case sensitivity, 407,410 comments, 407 data base, 375, 376 Delphi system, 418 entry, 398 function name, 407 Harvard system (keyword), 376 hyphenated name, 400 keyword, 376 multiple authors, 400 name format, 400 special character, 402 string constant, 407 style file, 375,376 types of variables, 410 variable name, 407 BIBTEX style, 377-378 abbrev, 377,400 abbw, 377,379,383,400,410,418 abstract, 377, 406, 415 acrn, 377,379,384 agsrn, 377 alpha, 377, 379, 383,401,407, 410, 412,415,418 arnsalpha, 377 arnsplain, 377 annotate, 377, 414,415 annotation, 377, 414,415 annote, 409 apalike2, 377 apalike, 374, 377-380, 384 apa, 377 astron, 374, 377 authordatel , 376, 377,416 authordate2, 376, 377

Index

BIBTEX style (continued)

Bleser, Joachim

497

authordate3, 376, 377 authordate4, 376, 377,416 bbs, 377 cbe, 377 cell, 377 chicago, 374, 416 dcu, 377 fabbrv, 418 falpha, 418 fplain, 418 funsrt, 418 gabbrv, 418 galpha, 418 gplain, 418 gunsrt, 418 harvard, 374,416 humanbio, 377 hurnannat, 377 ieeetr, 377 is-abbrv, 377, 415 is-alpha, 377, 415 is-plain, 377, 415 is-unsrt, 377, 415 jmb, 376,377 jtb, 377 kluwer, 377 myunsrt, 414 named, 374, 376, 377 namunsrt, 377 nar, 378 natbib, 374, 378 nature, 378 nederlands, 416,418 newapa, 374,378 phaip, 378 phcpc, 378 phiaea, 378 phjcp, 378 phnflet, 378 phnf, 378 phpf, 378 phppcf, 378 phreport, 378 phrmp, 378 plainyr, 378 plain, 377-379, 382, 410, 412,415, 418 siarn, 378

unsrt, 377-379,382,410,414,418 bibunit environment, 386,389 bibunits package, 385-386, 389-391 bibview program, 394 \Big, 230 \big, 230 Big point, see bp \bigcap, 219 \bigcirc, 218 \bigcircle, 290 \bigcup, 219 Bigelow, Charles, 340 \Bigg, 230 \bigg, 230 \biggl, 245, 247 \Biggr, 230 \biggr, 245,247 \bigl, 230 \Bigm, 230 \bigodot, 219 \bigoplus, 219 \bigotimes, 219 \bigskip, 451 \bigskipamount rubber length, 124,451 \bigsqcup, 219 \bigstar, 222 \ b i g s t r u t j o t rigid length, 135 \bigtriangledown, 218 \bigtriangleup, 218 \biguplus, 219 \bigvee, 219 \bigwedge, 219 Billawala, Nazeen N., 182 bind option, 467 \binom, 229,344 b i p a r t i t e environment, 306 Bitemize environment, 279 Bitmap fonts, see .pk file portable format, 276 b k l l . clo, 13 \blacklozenge, 222 \blacksquare, 222 \blacktriangle, 222 \blacktriangledown, 222 \blacktrianglelef t , 221 \blacktriangleright, 221 Bleser, Joachim, 283

498

.blg file

changebar environment

Index

.blg file, 4 , 6 , 375


BMZFONT program, 276 bmatrix environment, 23 1 \bmod, 229 Bode, Hans-Hermann,418 Bodenheimer, Bobby, 476 Body of page, 83 \boldmath, 179,217 \boldsymbol, 179,216,218,243 book document class, 3, 13, 20, 22, 24, 36, 72, 87, 94, 96, 147, 244, 262,364,441,445,460,464 bookman package, 334 \boolean, 468,472 Borceux, Francis, 234 \bot, 219 \botf igrule, 143 \bottomcaption, 119 \bottomfraction, 142,144,145 bottomnumber counter, 142 \bowtie, 219 Box double -s, 278 fancy -s, 278 multiple -es, 281 oval -s, 278 shadow -s, 277,278 style parameters, 277, 453 \Box, 184,219 Box commands, 45 1-460 \boxdot, 222 \boxed, 225 Boxed environments, 68,277-280,331, 459 boxedminipage package, 277 boxedminipage environment, 277,278 boxedverbatim environment, 68 boxitpara environment, 331 \boxminus, 222 \boxplus, 222 \boxtimes, 222 bp (Big point), 449 Braams, Johannes, 89, 119, 262, 328,421 Braces in index entries, 3 51 \bracevert, 220 \branch, 282 \branchlabels, 282 brazil option, 267

Breitenlohner,Peter, 262 \breve, 218 \brush, 306,307 \bslash, 429 . b s t file, 4 , 6 , 375,376,419 \bullet, 59,218 \Bumpeq, 221 \bumpeq, 221 bundle environment, 307,308,309 \bye, 187

Cahiers Gutenberg, 394 calc package, ix, 58, 63, 88, 111, 439,
446,460,463,468,469,470 \Cap, 222 \cap, 218

Capitalization rules, 273


\caption, 31, 32, 35, 40,41, 50, 122, 124,125,148,154,155,327 \caption*, 124,125 \captions tang, 266 \captionwidth rigid length, 155 Carlisle, David, 28,45, 50, 58, 91, 105, 113, 116, 117, 122, 129, 130, 145,149,470
X,

Case sensitivity in BIBTEX, 407,410 inindex, 348, 351,355 cases environment, 231 catalan option, 267
\catcode, 171 \cbdelete, 329

cbe BIBTEXstyle, 377 \cbend, 328,329,330 \cbstart, 328 cc (Cicero),449 \ccname, 267 CD environment, 234 \cdot, 59,129,218 \cdots, 219 cell B m T E X style, 377 center environment, 40,51,61,279,319 \centerdot, 222 \centering, 27,51,114,136 Centimeter, see c m \cf oot, 96 \cf rac, 230 changebar package, 317,328,328-330 changebar environment, 328

Index

changebargrey counter

comment environment

499

changebargrey counter, 330 \changebarsep, 330 \changebarwidth,328,329 \changes, 425,431 \chapter,18,20,21,22,28,30,37,40, 92,94,96,97,386 chapter counter, 21,94,445,470 numbered within parts, 22 \chapter*,95 chapterbib package, 385-389 \chaptermark, 93,94,95,99 \chaptername, 31,267 Character accessing -s in fonts, 172-173 hyphen -, 200 position in encoding, 200 Character table program for generating -s, 187 \CharacterTable, 429 \chead,9 6 \check,218 \CheckModules, 429 \Checksum,429 Chemical formula, 276,293,295 Chen, Guoying, 476,479 Chen, Pehong, 5 \chi,218 chicago BIBTEX style, 374,416 chicago package, 374 \chunk,307 Cicero, see cc CIE color standard, 313 \circ,218 \circeq,221 \circle,280,281,300,302 \circle*,280,281,293,300,302 \circlearrowleft,221 \circlearrowright, 221 \circledast, 222 \circledcirc, 222 \circleddash, 222 \circledS,222 Citation, 40, 371-420 Citation environment, 443,444 cite package, 373 \cite,372,373,374,375,376, 379,385, 398,405,409,413 \citeA,374

citefind.sh program, 393,394 \citeN,374 \citen,373 \citeNP,374 citesort package, 373 citetags.sh program, 393,394 \citeyear,374 Clark, James, 317 Clark, Malcolm, 275 Class, see Document class \cleardoublepage,9 2 \clearemptydoublepage,92,93 \clearpage,91,92,99,122,141,145, 146,150 \cline,110 .clo file, 4, 12 \closecurve,290 .cls file, 3,4, 12 \clubsuit,219 cm (Centimeter), 4 4 9 CMYK color model, 313 Cochran, Steven, 152 \CodelineFont,192,193 \CodelineIndex,424,426,429 \CodelineNumbered,429 Codepage, see Font encoding Collating sequence, 260 collectmore counter, 78, 7 9 Color CIE standard, 313 CMYK Model, 313 HSB Model, 313 RGB Model, 313 color package, 331 colordvi package, 331 columnbadness counter, 78,7 9 \columnsep rigid length, 77, 7 8 , 84, 87, 152 \columnseprule rigid length, 78,84,87 \columnwidth rigid length, 73,84 Command argument, 441 definition, 440-442 f r a d e , 350 optional argument, 441,442 redefinition, 441 robust, 350 comment environment, 66,80,82

500

Comments

\DeclareErrorFont

Index

Comments entries, 407 in BIBTEX commutative diagram, 226 \complement, 222 Composite font, see Virtual font Compound word hyphenating -s, 201,264 Comprehensive TEXArchive Network (CTAN),475 Compression of files, 476 Computer Modern fonts, 157-158, 161, 168 NFSS classification, 181 concrete package, 179, 181 Concrete Roman fonts, 161, 181-182 NFSS classification, 182 \cong, 219 Contents list style parameters, 32-35, 37 \contentsline, 32, 34, 35 \contentsname, 31,267 \coprod, 219 Cor environment, 2 54 Cork encoding, 172, 174, 180, 181, 195, 200,202,261 \cornersize rigid length, 278 \cos, 220 \cosh, 220 \cot, 220 \coth, 220 Counter commands, 44 5-447 croatian option, 267 cropmarks option, 467 Cross-reference, 40-45 .toc file, 5 in index, 348 key, 40 style parameters, 44 to external documents, 45 \csc, 220 \csname, 23 CSTEXUsers Group, 480 ctagsplt option, 238, 243, 245 CTAN (Comprehensive TEX Archive Network), 475 \Cup, 222 \cup, 218 \curlyeqprec, 221

\curlyeqsucc, 221 \curlyvee, 222 \curlywedge, 222 \Currentoption, 461,464,468 Curve arbitrary, 287 \curve, 290,291,293 \curvearrowlef t , 221 \curvearrowright, 22 1 \curvedashes, 293 curves package, 287 c u ~ e s l package, s 287 \curvesymbol, 292, 293 CyrTjX Users Group, 480 czech option, 267 \dagger, 218 \daleth, 220 Daly, Patrick W., 374, 419 danish option, 267 DANTE e.V., 3, 264,480 Darrell, Trevor, 3 18 dashj oin environment, 298, 301, 303, 305 \dashlef tarrow, 221 \dashline, 297,298,301,304 \dashlinestretch, 297, 298,299 \dashrightarrow, 221 \dashv, 219 375, 376 Data base (BIBTEX), \date 2 ang, 266 \dbinom, 229,230, 344 \dblf igrule, 143 \dblfloatpagefraction, 142 \dblf loatsep rubber length, 143 \dbltextf loatsep rubber length, 143 \dbltopfraction, 142 dbltopnumber counter, 142 DC fonts, 180, 261 dcolumn package, 101,129 dcu BIBTEX style, 377 dd (DiGt point), 449 \ddagger, 218 \ddddot, 225 \dddot, 225 \ddot, 218,225 \ddots, 219 debugshow option, 187 \DeclareErrorFont, 211,214

EII' lgI's9I'ruo; ]uatun)ocl 't 'n^'saprls s8I

z g v ' s bv g ' t'z9z /. 'vr'96 ' /8


' z/ - '9 E 'V E 9 ' Z ' V ZZ ' Z-OZ'g'uoda.r , , r a l l a l zgz'BI 'tB'z/-'98'VZ'zZ'0 ' t2I ' t ' ) o o q

6IZ

'Jectpuouerp\ ss gIZ'puoureTp\ 't8I 'puourerc\

s9z']ralerc

vqv'oqv'svv 'rw 'vgE 'z9z'wz ' / _ v'r 96'v6

777'dn8erpl 777'uuopSetpl t9z')rlrJJerc }Ez'6zz'f,rlp\ alg T^p' aas'aru]uapuadapur aJrAaC .+eP\ 677 'TaqETuorldt:osaPl 09
'09'gS'2y'luatuuol,rua

vvv'6tz
uor+dr:csap

LqV'qZV ' 2 6 ' 1 9 ' z 9 z ' v v z ' 9 6 ' / . 8 'rt ' o E' z z ' 0 ' B ' s ' ' ' x ' a z I i I lrlue ttz'looqsuP WZ'ueswe 'E 'uorldo 71 zqv'* Jo uorlErurtuapr l gt',{r{euoprun; Surpualxa ' 'sselJ luarunJofl ZI ggt '- ]e patn)axaapor

'0 ggv'rqv's r z

6ZV'VZV'Zt'oDEl^laqrrcsa(\ 6Zb'VZV'Zt'^ugaqrJ'sa(\ VSV'ESV'q$ua1 PI8lr q1deP1 8IZ'elTap\ 8IZ'lTaC\ 8I? '(uals^s a8enSuel-p1ntu X[fug) r-qdpq 6ZV'SZV'qro^+roqsa+eIe0\ 6Z'rllpTllreqalaTap\ LII'I0I'a8e4red lerre;ep

0zz'3aP\ lsTTlsp svv'wv'luauruorl^ua


002'rEr{ruaqddqllneyapy ']uauruoJr^ua Joc tSZ
'gg7'+eoeqdTv+uocToqur,{So.reI3ac\

Erz'rrz-602

'I6 '06 'tT rI 'luauuorrlua +uaurnoop 'srurdeT.(1sco6y Z? St't'xe1.dtr1srop t,puc.dt:1scop .dnrJsJoo vEv_zEv.6It ,gZV ,lndulooqy 6ZV 'o+prop\ It r a l u3 o p ' st 'sralauered a1.{rs Zt ' x I ' a 8 e 4 r e dr o p EEV'SZV-IZV'Z6I ZZZ'saurluoapT^Tp\ 0lt'apT^Tp\

vrz

8rz'^Tp\

'602'802' l-oz'soz'1uog1oqur.(garproac\ 8 g V 'l g V ' S g V ' V g b ' I g t ' * u o r t d g a r e T t a c \ 8gt'Sg?'VgV'EgV'19y'uorldgareTraC\ VIZ' 60Z'802'uorsra^r{+phtareTOaO\ '0IZ'802-g0Z'221'loqufgqlpt^terETro(\

' S S Z' 9 6 7 ' a 1 . ( l s d e T d s T p \ 9SZ rpl OVZ'6EZ'4earq,te1ds 'qreur ur alfs Leldsrq SSZ Supeag aas 'Eupeaq Leldsrq rslarssorcorqEsrc\ 6ZV'qZV'tzt l'S'tuauruorrlua 1st13utp 'au'r18urpy /'St

zzz'/rz'vu'Zft

'^ ul s{uElq / ' S ' 8 S ' l u a u r u o ru r 3 lsrloxne8urp 96I 's'8uTp\ '602'VjZ l 6EE'VrZ-ZrZ ' 0zz'uTp\ Z O Z 'O O Z ' l 6 I - S 6 I ' e d e q g l u o g a : E T r a C \ 's3uru311e-uou lI zrz'602 ' 16IC VOZ' ZOZ' OOZ'V6l'.(ltuegluogareTraO\ 977'eurure81p1 zrz'602 'turod ' pp g0Z' aas ]gprc 1 EOZ' 6 1'SurpocugtuogareTraq\ ,+rnsPuoureTP\ 617 Z6I'+uolpaxrCarEToa(\

/'s'Trr]8uTp\

s0z'I6I'sazrsq+hlarPT3a(\ tIz'IIZ-602 ' 8OZ' OgI- t il' laqeqdlyqlel^la.rItaC\ tI Z'uortn+r +sqns+uoJorI3aC\

r0s

luoJ ]uarun)oc

luocpoxrJorTDeo\

xapul

502

Document font (continued)


changing the -, 173 Document preamble, 13, 87 Documentation, 42 1-438 \documentclass, vii, 9, 12-14, 17, 80,

endfloat package

Index

180, 182, 185, 186, 204, 244, 263,317,462,465 \documentstyle, vii, 13,185 \dominitoc, 37 \DoNotIndex, 430 \DontCheckModules, 429 \dot, 218,225 \doteq, 219 \doteqdot, 221 \dotf i l l , 361,450 \dotplus, 222 \dots, 224 \dotsb, 224 \dotsc, 224 \dotsi, 224 \dotsm, 224 dottedjoin environment, 298, 301,303, 305 \dottedline, 296,297,298,301,304 \doublebarwedge, 222 \doublebox, 278 \doublerulesep rigid length, 110 doublespace package, 52 \Downarrow, 219,220 \downarrow, 219,220 \downdownarrows, 221 Downes, Michael, 2 16 \downharpoonlef t , 221 \downharpoonright, 221 \dq, 264 draft option, 320 draftcopy package, 332 \draw, 306 drawj oin environment, 298, 301 \drawline, 298,299,301-304 \drawlinestretch, 298,299 \drawwith, 307,308 \driver, 317,328 Drucbert, Jean-Pierre, 36, 45 .dtx file, 4, 426, 435,436, 437, 438 Duchier, Denys, 421 Duggan, Angus, 66,276 dutch option, 267

.dvi file, 4, 5, 6, 94, 131, 157, 275, 360, 393 dvi driver, 5, 131, 276 margin, 86,88 dvicopy program, 262 dvips option, 317 dvips program, 91,262,300,311, 315-317,328,331-334,340, 476,490,529 dvitops option, 317 dvitops program, 317

EC fonts, 180, 261 \ecaption, 36 eclbip package, 303 ecltree package, 307 \EdgeLabelSep, 309 eepic package, vi, viii, 276, 300-303, 304, 305 eepicemu package, 302, 303 egrep program, 392,393 \ e l l , 219 \ e l l i p s e , 301,302 \ellipse*, 301,302 e m (em-space),449 \em, 169,171 producing underline, 49 \emergencystretch rigid length, 51, 52 \emph, 49,169,171 producing underline, 49 Emphasis, see commands \em and \emph, 169

"empty", see Size function empty pagestyle, 91,92


\emptyset, 219

emtex option, 317 emTeX program, 3 17,476


\Enablecrossref s, 424,429 \encapchar, 430

Encapsulated Postscript, xi, 140, 313,


315,318 \enclname, 267

Encoding of fonts, see Font encoding Encoding table program for generating -s, 187
\encodingdefault, 173,174,192,193 \endcsname, 23 \endf irsthead, 124 endfloat package, 154

Index

\endf o o t

fancyheadings package

503

\endfoot,124 \endhead,124 \endlastfoot,124 Endnote 4 footnotes as -s, 7 \endnote,75 endnotes package, 7 4 \endpostamble, 433 \endpreamble, 433,435 english option, 267 \enlargethispage, 99,100 \enlargethispage*,99,100 \enotesize,75 \enspace,450 \ensuremath, 4 4 0 .ent file, 74 entry environment, 61,63,64,65 \entrylabel,63,64,65 enumerate package, 58 56-59, enumerate environment, x, 40,47, 9 27 style parameters, 57 enumi counter, 57,445 enumii counter, 57,445 enumiii counter, 57,445 enumiv counter, 57,445 Environment definition, 442-445 optional argument, 444 redefinition, 442 environment environment, 423,429 epic package, vi, viii, 276,293-300, 300-305,307 epsfig package, 317,318,318-320 \epsfig,318,319,320,327 \epsilon,218 \eqcirc,221 eqnarray environment, 235,236,239, 242,256,257,279 eqnarray* environment, 235,257,279 \eqref,242 \eqslantgtr,221 \eqslantless, 221 \equal,471 Equation boxed, 279 numbers, 240-242 split over lines, 237,238,244-248

verticd space in -s, 239 vertically aligned -s, 236,237,246, 248-251 equation counter, 445 237, equation environment, 40,235, 238,240,243-246,256,344 equation* environment, 235,243,244 \equiv,219 Error message in transcript file, 5 errorshow option, 186 esperanto option, 267 Estonian TEX Users Group, 4 8 0 \eta,218 \eth,222 \EuFrak,184 eufrak package, 184 euler package, 183,184,206 Euler fonts, 183-184 NFSS classification, 184 Euler, Leonhard, 183 \EuScript,184 euscript package, 184 \evensidemargin rigid length, 84,86,87, 90,467 ex, see x-height Exa environment, 254 \excludeversion,82 Excluding material, 82 \ExecuteOptions,461,464 executivepaper option, 8 6 \exists,219 \exp,220 exscale package, 185 \externaldocument,45 \extral ang, 266 \extracolsep,113,126,133 \extrarowheight rigid length, 106,111 \extratabsurround rigid length, 137 fabbrv BIBTEX style, 418 \faketableofcontents,37 \fallingdotseq,221 falpha BIBTEX style, 418 Family of fonts, see Font family \familydefault,173,174,192 fancy pagestyle, 96, 97 fancybox package, 278 fancyheadings package, 9 6 9 8

504

fancyheadings package (continued)

Font classification

Index

style parameters, 97 fancyplain pagestyle, 97 \f ancyplain, 97,99 \fbox, 225,277,278,331,452,453,458, 460 \fboxrule rigid length, 277,278,453 \f boxsep rigid length, 277, 278, 331,453 . f d file, 4, 5,202,204,206,214 Fernandez, Jose Alberto, 386 Feynman diagram, 276, 293,294 . f f f file, 154 Figure floating object, 141-155 in multicols, 79 labels in -s, 41 figure counter, 445 figure environment, 35,40, 53, 76,125, 141, 145, 147, 149, 150, 154, 155,327,455 labels in -, 41 style parameters, 142-143 \f igurename, 267 \figureplace, 154 f igwindow environment, 53, 54 File compression, 476 f ilecontents environment, 1 7 \f iledate, 431 \filename, 431 Files, produced by W X ,5 \f ileversion, 431 \fillrubber length, 124, 126,443,448, 450,451 \f i l l t y p e , 302 final option, 320 f inalcolumnbadness counter, 78, 79 \Finale, 424,430 Fine, Michael, 328 finnish option, 267 \Finv, 222 \f i r s t h l i n e , 137 fixed, see Size function flafter package, 42, 144 \ f l a t , 219 fleqn option, 256,257 Float, 141-155 in multicols, 79 labels in -s, 41 style parameters, 142-143, 147-148

float package, 146,148,149 floatfig package, 150 f loatingf igure environment, 150,151 \f loatname, 147,148 \floatpagefraction, 142,143 \f loatplacement, 147 \f loatsep rubber length, 142,143 \ f l o a t s t y l e , 147,148 \f lq, 264 \f lqq, 264 \f lushbottom, 100 \f lushcolumns, 78 f lushlef t environment, 50, 51,61,279 f lushright environment, 51,61, 279 \fminilength rigid length, 469 fminipage environment, 459,460 .fmt file, 4, 5 fnpara package, 73 \f nsymbol, 447 Font, see also Character composite, 3 12 declaring encodings, 204 declaring new -s, 194-210 monospaced, 159 PostScript type 0, 312 PostScript type 1, 312 PostScript type 3, 312 proportionally spaced, 159 roman, 160 sans serif, 160 serifed, 160 special, 275 style parameters, 173 testing, 187 text commands in math, 175, 176 typographical, 159 use in math, 174-180,205-209 virtual, see Virtual font weight, 162 width, 162 wrong selected, 174 \font, 200,201 Font attribute, 159-165 combining -s, 168-170 setting -s, 188-189 Font classification Common PostScript fonts, 333 Computer Modern fonts, 181

Index

Font classification (continued)

\footnotetext

505

Concrete Roman fonts, 182 Euler fonts, 184 Old German fonts, 183 Pandora fonts, 182 Font commands with arguments, 171-172 default settings, 173-174 as environments, 166 low-level, 187-194 Font definition file, see .f d file Font encoding, 164-165,172-174,178, 180-184,188,191,193-195,
198,200, 202-204,207-212, 214,260 classification of -s, 192 declaring new -s, 202-203 default -, 174, 180 mixing -s, 203 naming conventions, 203 obsolete -s, 192

classification, 191 default in encoding, 193 italic, 161, 162, 168, 169, 171, 173,

191

oblique, 161, 191 slanted, 161, 168, 169, 171, 173,


177,191

sloped, 161 small capitals, 161, 162, 168, 169,


171,173,191

upright, 161, 162, 167, 169, 171,


173,177,191,193

Font shape group, 175, 177,195,


198-204,206,210-213

declaring new -s, 194-202 modifying -s, 202 Font size, 162,163-164,169-170,188, 190-191,193-195,197,198,
200, 211-213

Font encoding table program for generating -s, 187 Font family, 160-165, 166-167, 168, 170,
171, 173, 178, 180, 188, 189, 193-195,197,198,200,203, 204,209,210,212,214 declaring new -s, 194-195, 200-201,204,209 default in encoding, 193 modifying -s, 202 Font info, 196

commands for changing the -, 170 in math, 191, 205, 255-256 relative changes, 170 Font substitution, 193 defaults, 169, 170, 173, 188, 193,
199,203,210,211,214

Font x-height, see X-height


f ontdef .l t x , 204 \f ontdimen, 27,33,201,202,209 \fontencoding, 188,191,203,212 \f ontf amily, 188,189,194 \f ontseries, 167,188-190 \f ontshape, 188,190,191 \f ontsize, 188,190,192,211 Footer of page, 83

Font inter-word space, see Space Font loading dynamical -, 203 options, 200-202 problems when changing the -,
202

Foomote in longtable, 124

Font metric file, 5, see .tfm file Font selection, see NFSS Font series, 167, 169-171, 174, 178, 180, 183,188,189,193-195,198,
203,210

in minipage, 70-71 i n multicols, 79 i n tabular, 132-133


in two-column format, 80 \footnote, 40, 50, 70-72, 73 style parameters, 70-73 footnote counter, 70,71,445 \footnotemark, 71, 73,132 \f ootnoterule, 71, 72,143 \f ootnotesep rigid length, 71, 72 \f ootnotesize, 72,170 \f ootnotetext, 71, 73

classification, 190 default in encoding, 193 Font shape, 161-162,167-169,171,174,

178, 180, 183, 188, 190, 193-195,198,199,202,203, 210,212

506

footnpag package

\gtrless

Index

footnpag package, 72 \f ootrule, 96 \f ootrulewidth rigid length, 96 \f ootskip rubber length, 84,87,97 \f o r a l l , 219 Format (TEX) file, 5 identification of -, 15,462 .f ot file, 72 fplain BIBTEX style, 418 \f rac, 220,229 \fracwithdelims, 229,344 Fragile command, 3 50 \f rak, 21 7,218,243 \frakf amily, 182 Frame, 278 \framebox, 281,296,452,453,454,458 francais option, 265, 267, 270 french option, 12,267 french package, xi, 259,272-274 \from, 433,435 \frown, 219 \f rq, 264 \f rqq, 264 ftnright package, 75, 80, 81,433, 476 ftp (file transfer protocol), 476 \ f u l l r e f , 41,45 Function names in BIBTEX style file, 407 built-in -s (BIBTEX), 407 funsrt BIBTEX style, 418 \fussy, 52

gabbrv B~TEX style, 418 galician option, 267 galpha BIBTEX style, 418 \Game, 222 \Gamma, 218 \gamma, 218 \GapDepth, 309 \Gapwidth, 309 garamond package, 334 gather environment, 235,236,238,243, 248-250,344 gather* environment, 235 gathered environment, 239 Gaulle, Bernard, 259,272 \gcd, 220 gen, see Size function

\generateFile, 433,434,435 Generic markup, 8 \geq, 219 \geqq, 221 \geqslant, 22 1 german option, 12,14,263-265,267, 268,355,360,392 german package, 264, 355 gerrnanb option, 263,267 \gg, 219 \ggg, 221 ghostscript program, 312 ghostview program, 312,317 Gildea, Stephen, 86 \gimel, 220 .glo file, 364 Glossary, 364 \glossary, 364,425 \glossaryentry, 364 \GlossaryMin rigid length, 431 \GlossaryParms, 431 \GlossaryPrologue, 431 \glq, 264 \glqq, 264 \gnapprox, 222 \gneq, 222 \gneqq, 222 \gnsim, 222 Goldfarb, Charles, 7 gopher program, 476 \gothf amily, 182 gpic program, 300 gplain B m T E X style, 418 Graph bipartite, 303 Graphics portable, 275-309 graphics package, 318 \grave, 218 Green, Ian, 373 \grid, 296 \grq, 264 \grqq, 264 \gtrapprox, 221 \gtrdot, 221 \gtreqless, 221 \gtreqqless, 221 \gtrless, 221

Index
\gtrsim, 221 Guillemet, 264, 272 gunsrt BIBTEX style, 418 GUST, 480 GUTenberg, 480 \gvertneqq, 222 gzip program, 476

\gtrsim

. ind file

507

Haas, Roswitha, 293 hackalloc package, xi Hafner, James, 331 Halftone font, 2 76 Hamilton Kelly, Brian, 281 hangcaption package, 155 Haralambous, Yannis, 182,183,187,260 Harrison, Michael, 5 harvard BIBTEX style, 374,416 harvard package, 377 Harvard system keyword (BIBTEX), 376 \hat, 218 \hbar, 219,222 \hdotsf or, 232 Header of page, 83 \headheight rigid length, 84,87,88,97 Heading display, 24, 25, 27 run-in, 24,26,27,473 style parameters, 24-28 headings pagestyle, 91,95 \headpagename, 267 \headrule, 96 \headrulewidth rigid length, 96 \headsep rigid length, 84, 87, 88 \headtoname, 267 \headwidth rigid length, 96, 99 \heartpar, 55 \heartsuit, 219 \height rigid length, 453,454,458 Heitkoetter, Jorg, 418 \help, 187 helvet package, 334 here package, 150 \hf i l l , 450 hhline package, 101, 130 \hhline, 130,131 \hline, 110,119,130,131,137 \hlineon, 284 Hoenig, Alan, 53

\hof f s e t rigid length, 86, 90 Holmes, Chris, 340 \horn, 220 \hooklef tarrow, 219 \hookrightarrow, 219 \hrule, 27,131 \hrulef i l l , 450 HSB color model, 3 13 \hslash, 222 \hspace, 65,74,132,450,453 \hspace*, 450 \Huge, 170 \huge, 170 hurnanbio BIBTEX style, 377 humannat BIBTEX style, 377 Hyphenation, 5, 65, 108, 132, 260, 262, 263,265,266 of names (BIBTEX), 400 in marginal notes, 74 in narrow columns, 132 of compounds, 201,264 \hyphenchar, 200 \ i d o t s i n t , 223 .idx file, 4 , 5 , 3 4 6 - 3 4 8 , 3 5 0 , 3 5 1 , 3 5 3 , 356, 357, 364, 365, 367, 471, 472, 529 ieeetr BETEX style, 377 \IfFileExists, 461,466 \ i f language, 263 ifthen package, ix, 439, 470, 472 \ifthenelse, 373,468,470,472 \ignorespaces, 61 \ i i i i n t , 223, 344 \ i i i n t , 223,344 \ i i n t , 223 .i l g file, 4,5,346,353,356 \Im, 219 \imath, 219 i n (Inch),449 \in, 219 Inch, see i n \include, 16,17,367,385,389 \includeonly, 16,367 \includeversion, 82 Including material, 82 .ind file, 4, 5, 346, 347, 353, 355, 356, 360,365,367

indentfirst package

j mb BBTEX style

Index

indentfirst package, 28 Index, 40,345-370 .idx file, 5 .ind file, 5 case sensitivity, 348, 351, 355 cross-references, 348 entry, 348 main -, 348 "see" -, 349 simple -, 347 sub-, 348 subsub-, 348 errors reading phase, 3 56 writing phase, 357 generated by commands, 440,471 INDEXSTYLE system variable, 356 level, 348 numbers, 351 page number sorting, 351 page range, 348 spaces in entries, 348, 351 style parameters, 358, 359 symbols, 351 ! (level),348, 350, 356, 358 " (quote), 350, 358 @ (sortkey), 349, 350, 356, 358 I (encap), 349, 350, 356, 357, 358 I( (range start), 348-350, 357, 358 I) (range end), 348-350, 357, 358 use of braces in entries, 351 index package, 367-370 \index, 345-348,350-354,356,357,363, 364,365,367 \indexentry, 347,358, 364 \IndexInput, 426,429 \IndexMin, 430 \indexname, 31,267 \IndexParms, 430 \IndexPrologue, 430 \indexproof style, 367 INDEXSTYLE system variable, 356 \inf, 220 infoshow option, 187,463 \infty, 219 \ i n i t , 187 \ i n i t f loatingf igs, 151 Inner margin, 83,90

\input, 204,466 in a DOCSTRIP file, 434 \InputIfFileExists, 461,464,466 \ i n t , 219 Inter-letter space, see Space Inter-word space, see Space \intercal, 222 Internationalization, 260 Internet, 475 \ i n t e r t e x t , 240 \intextsep rubber length, 143,152 intlim option, 243 \iota, 218 is-abbrv BIBTEX style, 377, 415 is-alpha BIBTEX style, 377, 415 is-plain BIBTEX style, 377,415 is-unsrt BIBTEX style, 377, 415 ISO-8859 standard, 260-262 ISO-8879 standard, 8 ISO-10646 standard, 260,262 \isodd, 474 isolatinl package, 261 Isozaka, Hideki, 303, 307 .i s t file, 4, 5, 346, 357 \isucaption, 155 \ i t , 174, 186 used in math, 176, 186 italian option, 263, 267 ITALIC, 480 Italic correction, 168 with \em command, 169 automatical supply of -, 171-172 \itdef a u l t , 173 \item, 59-63,365,444,473 in theindex, 364 \itemindent rigid length, 62 itemize environment, 47, 56, 59,279, 335 style parameters, 59 \itemsep rubber length, 62 \itshape, 49,168,169,171,173,183, 186,254 used in math, 175, 176

Japan TEX Users Group, 480 Jeffrey, Alan, 340 Jensen, Frank, 181,468 \jmath, 219 jmb BIBTEX style, 376,377

Index
jmb package, 377 Johnstone, Adrian, 293
\Join, 184,219 Jones, David, 155, 367,475 \ j o t rigid length, 135, 257 \jput, 298,299,303,305 jtb BETEX style, 377 Jurafsky, Dan, 36 Jurriens, Theo, 119 \kappa, 218 \keepsilent, 434 Kempson, Niel, 385 \ker, 220 Keyword (BETEX), 376

jmb package

\leftrightsquigarrow

509

Lamport, Leslie, v, x, 2, 3, 66, 86, 98, 118,


280, 351,470

Lamy, Jean-Fran~ois, 89
\landscape, 9 1 landscape environment, 91 Landscape orientation, 90 Lang, Edmund, 283 \langle, 220

Language changing the -, 191 multi-language, 262 support in Makelndex, 3 55 support in BIBTEX, 4 18
\LARGE, 170 \Large, 25, 52,170 \large, 170 \lasthline, 137 W X symbols, 218-220 l a t e x . tex file, 426,447 latexsym package, 184, 218, 219 Latin-1, see ISO-8859 standard Lavagnino, John, 74 layout package, 85 \layout, 85 Layout markup, 9

Harvard system, 376


\ k i l l , 124

kluwer B l B T E X style, 377 Knuth, Donald, 1, 2, 157, 161, 181, 187,


192,259,421

Kotz, David, 392 Kuhlmann, Volker, 89 Kwok, Conrad, 300


\lachapter, 34 \laexample, 36 \1Qf igure, 34 \laparagraph, 34 \lapart, 34 \lasection, 34 \lasubparagraph, 34 \l@subsection,34 \lQsubsubsection, 34 \latable, 34 \label, 23, 40,41, 45, 59, 73, 125, 153, 241 \labelenmi, 57 \ l a b e l e n m i i , 57 \ l a b e l e n m i i i , 57 \labelenumiv, 57 \labelitemi, 59 \labelitemii, 59 \ l a b e l i t e m i i i , 59 \labelitemiv, 59 \labelsep rigid length, 60,62,103 \labelwidth rigid length, 62, 63-65 \Lambda, 218 \lambda, 218

Layout parameters, see Style parameters


\ l c e i l , 220 \lcf rac, 230 \ldots, 219,274 \ l e , 219

Leading, see Space, see Baseline skip


\leadsto, 184 \leaf, 283 \ l e f t , 117,230,246,249 \Leftarrow, 219 \leftarrow, 219 \lef tarrowtail, 221 \lef tharpoondown, 219 \lef tharpoonup, 219 \lef t l e f tarrows, 221 \lef tmargin rigid length, 62,63 \lef tmark, 94,98,99 \lef tnode, 306 \Lef trightarrow, 219 \lef trightarrow, 219 \leftrightarrows, 221 \lef trightharpoons, 221 \lef trightsquigarrow, 221

\lef t r o o t

l o n g t a b l e environment

Index

\leftroot,225 \leftthreetimes, 222 legalpaper option, 8 6 \legend,284 Lem environment, 254 Length commands, 447-451 rigid, 4 4 7 rubber, 447 \lengthtest, 473 Lentry environment, 64 \Lentrylabel, 64 \leq,219 leqno option, 256 \leqq,221 \leqslant,221 \lessapprox,221 \lessdot,221 \lesseqgtr, 221 \lesseqqgtr, 221 \lessgtr,221 \lesssim,221 letter document class, 3,18,262 letterpaper option, 86.87 letterspace package, 48 \letterspace, 48 Level in index, see Index, level \levelchar, 431 Levine, Michael, 293 \Ifloor,220 \Ifoot,9 6 \lg,220 \lgroup,220 \lhd,184,218 \lhead,96,97,99 \lim,220,228 \liminf,220 \limsup,220 \line,280-282,292,294,295,300,302 Line break, 9 \linebreak,442 \linethickness, 280-282,292,297,299, 303,305 \linewidth rigid length, 34,77, 84, 111, 460 Lingnau, Anselrn, 146 .lis file, 4, 5 .list file, 4

list environment, 47,50,51,60,61, 65, 73,152 style parameters, 62 List environments, 56-66,335,443-444 boxed, 279 \listfigurename,31,267 \listfiles,17,467 9 listing environment, 6 listing* environment, 69 listingcont environment, 69, 7 0 listingcont* environment, 6 9 \listinginput,7 0 \listof,36,148 \listofexamples,36 \listoffigures,18,32,36,95,148,150 \listoftables,18,32, 36,95, 122,148 \listparindent rigid length, 6 2 \listtablename, 31,267 \11,219 \llcorner,220 \Lleftarrow,221 \Ill,221 \lmoustache,220 In option, 317 \In,220 \lnapprox, 222 \lneq,222 \lneqq,222 \lnsim,222 \Loadclass, 461,467,468 loading option, 187 .lor file, 4, 5,31,35 \log,220,228 .log file, 4, 5,355,356 Long, F.W., 365 \Longleftarrow, 219 \longleftarrow,219 \Longleftrightarrow,219 \longleftrightarrow,219 \longmapsto,219 \longpage,100 \Longrightarrow,219 \longrightarrow,219 longtable package, 119,122,123 longtable environment, viii, 101,102, 122,123-126,128,132,145, 146 style parameters, 124

Index

looktex promam

Math symbol font

511

looktex program, 393 \looparrowleft, 221 \looparrowright, 221 . l o t file, 4, 5, 31, 35 \lowercase, 169 \lozenge, 222 lrbox environment, 459,460 \lrcorner, 220 lscape package, 91 \Lsh, 221 \LTcapwidth rigid length, 124,125 \LTchunksize, 124,125 \ltimes, 222 \LTlef t rubber length, 124,126 \LTpost mbber length, 124 \LTpre rubber length, 124 \LTright rubber length, 124,126 .l t x file, 4 lucid package, 334 LucidaBright, 340 LucidaNewrnath, 340 lucidbrb package, 167, 334,335, 340 lucidbry package, 334, 335, 340 lucmath package, 335 \lvertneqq, 222 \math, 59 Maclaine-cross,I.L., 287 macro environment, 423,424,430,432 macrocode environment, 422,423-425, 430,432 macrocode* environment, 423,424,430 \MacrocodeTopsep rubber length, 432 \MacroFont, 432 \MacroIndent rigid length, 432 \MacroTopsep rubber length, 432 magyar option, 267 Mail server, 479 Maillot, Jkrcme, 330 \main, 431 Main document font, see Document font \makeatletter, 15,16,22 \makeatother, 15,16,22 makebib program, 393 \makebox, 280,281,296,452,454,458, 459 makebst program, 374, 376,419 \makeglossary, 364

makeidx package, 350, 352, 354 Makelndex, vi, ix, 4, 5, 345, 346, 348-351, 353-361,363-365,424-426, 483,487,529 \makeindex, 352, 353,365 \makelabel, 63 \MakeprivateLettem, 432 \Makeshortverb, 425,430 \maketitle, 17,92 Malyshev, Vassily, 262 \mapsto, 219 Margin inner, 83,90 outer, 83 \marginlabel, 74 \marginpar, 52,74,455 in multicols, 79 style parameters, 74 \marginparpush rigid length, 74,84,87 \marginparsep rigid length, 74,84,87, 96,99 \marginparwidth rigid length, 74,84,87, 96,99 \markboth, 94,95,96 \markright, 94,95,96 Markup generic -, 8 layout -, 9 \match, 306 Math alphabet, 175 character, 175 default -, 177 Math alphabet character, 206 Math alphabet identifier, 175 declaring new -s, 177-178 in math versions, 179-180 predefined -s, 176, 176-177 Math extension font, 185 Math style parameters, 256 Math symbol font, 175, 202,205, 206-214 changing the setup for -s, 208-209 declaring new -, 205-208 default -s for math version, 205, 206 internal name for -, 205 largesyrnbols, 202,208, 209 l e t t e r s , 208

512

Math symbol font (continued)

\multimap

Index

operators, 208,209 symbols, 202, 208,209 u Math unit, see m Math version, 178-180, 181, 205, 206, 208-210,212-214 bold, 179,206,208 changed by package, 184 declaring new -s, 208 euler, 179 limit of fonts within -, 208 normal, 179,184,208 \mathalpha, 206 \mathbf, 176,179,216 \mathbin, 206 \mathcal, 176,217 \mathclose, 206 \mathindent rigid length, 2 56, 257 \mathit, 176 \mathnormal, 176,177 \mathop, 206, 217 \mathopen, 206 \mathord, 206 \mathpun&, 206 \mathrel, 206 \mathrm, 176,177, 217 \mathsf, 176,178,179 \mathsf s l , 177 \mathsurround rigid length, 59 Mathtime fonts, 340, 343 \mathtt, 176 \mathversion, 178,179, 213 \matrix, 215 matrix environment, 231 \matrixput, 296 Mattes, Eberhard, 287, 317 \max, 220 MaxMatrixCols counter, 232 \maxovaldiam, 301 \mbox, 49, 74,104,227,440,452,459 McCauley, James Darrell, 154 McPherson, Kent, 85 \mddef a u l t , 173 \mdseries, 167,171,173 Measure, 449 \measuredangle, 222 \medskip, 27,451 \medskipamount rubber length, 45 1 \medspace, 242

\Mentry, 65 \Mentrylabel, 65 \message, 433 \meta, 430 METAFONT, 6 .m f file, 4 , 6 \mho, 184,219,222 \mid, 219 Millimeter, see mm MIME, 260 \min, 220 minipage environment, 50, 51, 70, 71, 76, 100, 132, 133, 277, 320, 455,456,457,458,459,460 nested, 456 minitoc package, 36-38 \minitoc, 37, 38 minitocdepth counter, 37, 38 minitocoff package, 37 Mittelbach, Frank, 3, 41, 75, 80, 105, 144, 158,216,251,421,433,476 mm (Millimeter),449 \mod, 229 \models, 219 \Module, 432 Monospaced fonts, 159 moreverb package, 66 \mp, 218 mpf ootnote counter, 71,445 \Msg, 434,435 .mtc<N>file, 37 \mtcf ont, 37, 38 \mtcindent rigid length, 37, 38 mtimes package, 334 m u (math unit), 33,449 \mu, 218 multibox package, 281 multicol package, 12, 75, 76, 79, 364, 392,433,476 multicols environment, 75, 76, 77-79, 364,365,455,473 style parameters, 77-79 \multicolsep rubber length, 77, 78 \multicolumn, 115,125,132 \multiframe, 281, 282 Multilanguage, 260 \multimake, 281, 282 \multimap, 221

Index
multind package, 365-366 Multiple authors (BEITEX), 400

multind package

\noindent

513

\multiply, 468 \multiput, 282,292,294, 295,296, 305 \multiputlist, 295,303,305 multirow package, 135, 139 \multirow, 135,136,139 \multirowsetup, 135 multline environment, 235,237,238, 247 multline* environment, 235,247,248 \multlinegap rigid length, 237,247,248 myheadings pagestyle, 91,95 myunsrt BIBTEX style, 414 \nabla, 2 19

Name format (BIBTEX),400 named BIBTEX style, 374, 376, 377 named package, 377
\names, 168 namunsrt BEITEX style, 377 nar BEITEX style, 378 nar package, 378 natbib BIBTEX style, 374, 378 natbi b package, 374, 378 \natural, 219 \naturalwidth rigid length, 48 nature BEITEX style, 378 nature package, 378 \ncong, 222 \nearrow, 219 nederlands BEITEX style, 416,418 \NeedsTeXFormat, 15,461,462 \neg, 219 Negated symbol, 2 17 \negmedspace, 242 \negthickspace, 242 \negthinspace, 242 \neq, 219 New Font Selection Scheme, see NFSS newapa BEITEX style, 374,378 newapa package, 378 \newblock, 374,411 \newboolean, 468,472 newcent package, 334 \newcolumntype, 112,113,114,129 \newcommand, 29,112,224,440,441,442, 444,466 \newcounter, 446

\newenvironment, 423,442,444 \newfloat, 146,147,148 using H in, 146 \newf ont, 158 \newif, 472 \newindex, 367 \newlength, 448,466,473 newlfont package, 186 \newpage, 27, 77,99 in longtable, 124 \newsavebox, 459 \newtheorem, 242,252,253,254,445 style parameters, 253 \newX, 473 \newY, 473 \nexists, 222 NFSS, 157-214

customizing and maintaining,


186-187

nf ssf ont .tex, 172 \ngeq, 222 \ngeqq, 222 \ngeqslant, 222 \ngtr, 222 \ni, 219 \ n i n t t , 186 \nLeftarrow, 221 \nlef tarrow, 221 \nLef trightarrow, 221 \nlef trightarrow, 221 \nleq, 222 \nleqq, 222 \nleqslant, 222 \nless, 222 \ m i d , 222 \nobreak, 99 \nochangebars, 329 \nocite, 373,392,405 \nocorr, 172 \nocorrlist, 171 \noextras 1 ang, 266 \nof i g l i s t , 154 \nohyphens, 28,30 \noindent, 460

detecting problems in -, 186-187 error messages, 2 10-2 14 release 1 error, 213 tracing font changes, 186-187

514

\nolimits

Option (class or package)

Index

\nolimits,226 \nomarkersintext,154 nonamelm option, 243 \nonfrenchspacing,201 \nonumber,243 \nopagebreak, 9 9 Nordic TEXGroup, 4 8 0 Normal font, see Document font \normalem, 4 9 \normalfont, 26,27,166,171,253,255 \normalmarginpar, 7 4 \normalsize,87,170 norsk option, 267 nosumlim option, 243 \not,217,474 \notablist,154 \notag,240,243,248 Notes environment, 65 notes counter, 65,66 \nparallel,222 \nprec,222 \npreceq,222 \nRightarrow, 221 \mightarrow,221 \nshortmid,222 \nshortparallel,222 \nsim,222 \nsubseteq, 222 \nsucc,222 \nsucceq,222 \nsupseteq,222 \nsupseteqq,222 NTG, 4 8 0 \ntriangleleft,222 \ntrianglelefteq,222 \ntriangleright,222 \ntrianglerighteq,222 \nu,218 \numberline,30,32,33, 35,36 \numberwithin,241 \nVDash,222 \nvDash,222 \nvdash,222 \nwarrow,219 nynorsk option, 267
O'Kane, Kevin, 293 \oddsidemargin rigid length, 84,86,87, 90,467

\odot,218 \oint,219 Old documents processing with W X Z E ,185-186 Old German fonts, 182-183 NFSS classification, 183 Old style numerals, 173 oldgerrn package, 182 oldlfont package, 176,185 \oldstylenuus,173 \Omega,218 \omega,218 \ominus,218 One-sided printing, 83 \onecolumn,76 \OnlyDescription, 424,426,429 openbib package, 374 \openin,204 \operatorname,228,235,248 \operatornamewithlimits, 228 \oplus,218 Option (class or package) declaration of -, 463-465 passed on to other package, 463 1 1 pt, 12,13,170 aopaper, 8 6 a4paper, 12,86,463 a5 paper, 8 6 american, 267 austrian, 267 bspaper, 8 6 bind, 467 brazil, 267 catalan, 267 croatian, 267 croprnarks, 467 ctagsplt, 238,243,245 czech, 267 danish, 267 debugshow, 187 draft, 320 dutch, 267 dvips, 317 dvitops, 317 emtex, 317 english, 267 errorshow, 186 esperanto, 267

Index

Option (class or package) (continued)


portrait, 90 Orlandini, Mauro, 277 Ornament, 277-280

Package

515

executivepaper, 86 final, 320 finnish, 267 fleqn, 256,257 francais, 265, 267, 270 french, 12, 267 galician, 267 german, 12,14,263-265,267,268,

\oslash, 218 \otimes, 218


Outer margin, 83 \outerbarstrue, 330 \oval, 301,302 \Ovalbox, 278 \ovalbox, 278 \overbrace, 220 overcite package, 373 Overhead slide producing -s, 185

355,360,392
germanb, 263,267 infoshow, 187,463 intlim, 243 italian, 263, 267 legalpaper, 86 leqno, 256 letterpaper, 86, 87 In, 317 loading, 187 magyar, 267 nonamelm, 243 norsk, 267 nosumlim, 243 nynorsk, 267 oztex, 317 pausing, 187 polish, 267 portuges, 267 righttag, 241, 243, 256 romanian, 267 russian, 267 slovak, 267 slovene, 267 spanish, 267 swedish, 267 textures, 317 turkish, 267 twocolumn, 12, 75, 76, 80, 146, 150,

\overlef tarrow, 220,223 \overline, 220 \overrightarrow, 220,223 \overset, 226,246 oztex option, 317 OzTeX program, 3 17 \pQenumi, 56, 57 \pQenumii, 56, 57 \pOenumiii, 57 \pQenumiv, 57 Package, 5

152,392
twoside, 90, 330, 392 warningshow, 187 Optional argument of command, 441 o f environment, 444

\OptionNotUsed, 461,467 \or, 474 order environment, 273


Orientation landscape, 90

-, 462 a4,88,392 a4dutch, 89,90 a4wide, 89 a5,89 ascomb, 89 afterpage, 145, 150 alltt, 66 amsbsy, 243,244 amscd, 233,234,243,244 amsfonts, 184, 217, 243, 244 amssymb, 184, 217-222, 243,244 amstex, vii, viii, x i i ,215, 216, 217-251,256 amstext, 178, 227, 243, 244 apalike, 377, 379 array, 101, 105-113, 117,433,476 authordatel -4, 377 avant, 334 babel, viii, 12, 261, 262, 263-268, 270,272,355,360,465 bar, 283 basker, 334
identification o f

516

Package (continued)

Package

Index

bembo, 334 beton, 181 bezier, 280, 287, 293 biblist, 392, 395 bibmods, 394, 397 bibunits, 385-386, 389-391 bookman, 334 boxedminipage, 277 calc, ix, 58, 63, 88, 111, 439,446, 460,463,468,469,470 changebar, 317,328,328-330 chapterbib, 385-389 chicago, 374 cite, 373 citesort, 373 color, 331 colordvi, 331 concrete, 179, 181 curves, 287 curvesls, 287 dcolumn, 101, 129 delarray, 101, 117 doc, i ~ 192,421-428,433 , doublespace, 52 draftcopy, 332 eclbip, 303 ecltree, 307 eepic, vi, viii, 276,300-303,304, 305 eepicemu, 302, 303 endfloat, 154 endnotes, 74 enumerate, 58 epic, vi, viii, 276, 293-300, 300-305, 307 epsfig, 317,318,318-320 eufrak, 184 euler, 183, 184, 206 euscript, 184 exscale, 185 fancybox, 278 fancyheadings, 96-98 flafter, 42, 144 float, 146, 148, 149 floatfig, 150 fnpara, 73 footnpag, 72 french, xi, 259,272-274

ftnright, 75, 80, 81,433,476 garamond, 334 german, 264,355 graphics, 318 hackalloc, xi hangcaption, 155 haward, 377 helvet, 334 here, 150 hhline, 101, 130 ifthen, ix, 439,470,472 indentfirst, 28 index, 367-370 isolatinl , 261 jmb, 377 latexsym, 184, 218, 219 layout, 85 letterspace, 48 longtable, 119, 122, 123 Iscape, 91 lucid, 334 lucidbrb, 167, 334, 335, 340 lucidbry, 334. 335, 340 lucmath, 335 makeidx, 350, 352, 354 minitoc, 36-38 minitocoff, 37 moreverb, 66 mtimes, 334 multibox, 281 multicol, 12, 75, 76, 79, 364, 392, 433,476 multind, 365-366 multirow, 135, 139 named, 377 nar, 378 natbib, 374, 378 nature, 378 newapa, 378 newcent, 334 newlfont, 186 oldgerm, 182 oldlfont, 176, 185 openbib, 374 overcite, 373 palatino, 334 pandora, 182 picinpar, 53

Index

Package (continued)

\phantom

517

pifont, 58, 335, 337 portland, 90 program, xi, 104 psboxit, 330 pstimesm, 340 rotate, 9 1 rotating, 317, 320, 320-327 seminar, 278 shadow, 277 shapepar, 54 showidx, 351, 354, 367 showtags, 394,397 subfigure, 152 supertab, 119 syntonly, 186 tl enc, 180 tabularx, 101, 113-117, 139 theorem, 251,433,476 threeparttable, 133 times, 148, 334, 339, 340 tracefnt, 186, 187, 211 trees, 282 ulem, 49 varioref, 41, 44,460 verbatim, 66, 80,476 version, 82 vpage, 89 wrapfig, 151 xr, 45 xspace, 50 Packed character file, see .pk file page counter, 92,445 Page body, 83 Page break, 9 in equation, 239 Page description language, 3 11 Page footer, 83 Page header, 83 Page layout, 83 style parameters, 83-88 Page number style Alph, 92 alph, 92 arabic, 92 Roman, 92 roman, 92 Page range in index, 348

Page style empty, 91, 92 fancy, 96, 97 fancyplain, 97 headings, 91,95 myheadings, 91, 95 plain, 91.92, 93, 97, 365 Page, Stephen, 52 \pagebreak, 79,99, 239 \PageIndex, 424,429 \pagenunbering, 42,92 \pageref, 40,41-43,45,474 \pagestyle, 91,92,96,467 palatino package, 334 pandora package, 182 Pandora fonts, 178, 182 NFSS classification, 182 Paper size, 86, 89 \paperheight rigid length, 84,91 \paperwidth rigid length, 8 4 , 9 1 Paragraph narrow -s, 132 style parameters, 50-52 \paragraph, 9,20 paragraph counter, 21,445 \parallel, 219 \parbox, 50, 73,105,114,455,458 \parindent rigid length, 106 \parsep rubber length, 62 \parskip rubber length, 25 \part, 18,20, 22, 24, 28, 29, 92 part counter, 21, 22,445,447 \part*, 29 \ p a r t i a l , 219 Partl, Hubert, 90 \partname, 31,267 \partopsep rubber length, 62, 257 \PassOptionsToClass, 461,467,468 \PassDptionsToPackage, 461,463,465 Patashnik, Oren, 5, 372, 398,407,410 \path, 301,303,304 pausing option, 187 pbmtopk program, 276 pc (Pica),449 per1 program, 392 \perp, 219 phaip BIBTEX style, 378 \phantom, 244,245,292

518

phcpc BIBTEX style

\prod

Index

phcpc BmTEX style, 378 \Phi,218 \phi,218 phiaea BIBTEX style, 378 phjcp BETEX style, 378 phnf BIBTEX style, 378 phnflet BIBTEX style, 378 phpf BETEX style, 378 phppcf BBTEX style, 378 phreport BIBTEX style, 378 phrmp BIBTEX style, 378 \Pi, 218 \pi, 218 Pi font, 335
Piautolist environment, 337 Pica, see pc

picinpar package, 53
\picsquare,297,299 W E X , 275 picture environment, vi, viii, 233, 275,

276, 280-293,295,299, 304, 305 \Pif ill, 337 \Pif ont, 337, 338 pifont package, 58, 335, 337 \Piline,337 Pilist environment, 337 \Pisymbol,337 \pitchfork,221 .pk file, 4,6, 157,180,276,334,340 plain BETEX style, 377-379, 382, 410, 412,415,418 plain pagestyle, 91, 92, 93, 97, 365 \plainfootrulewidth rigid length, 97 \plainheadrulewidthrigid length, 97 plainyr BETEX style, 378 \pm,218 pmatrix environment, 231 \pmb,216,217,218,243 \pmod,229 \pod,229 Podar, Sunil, 293 Point, see pt .pol file, 4 polish option, 267 .poo file, 4 .pool file, 4 Poppelier, Nico, 89

Portable bitrnap format, 276 Portable graphics, 275-309 portland package, 90 \portrait,9 1 portrait environment, 91 Portrait orientation, 90 portuges option, 267 \postamble,433 PosTeX program, 262 \postmulticols rigid length, 77, 78 PostScript,vi, ix, 5, 6, 102, 157, 158, 174, 180, 185, 190, 194, 195, 276, 280,300,311-315,316-345, 407,448 composite font, 312 type 0 font, 312 type 1 font, 312 type 3 font, 312 Postscript point, see bp \Pr,220 Preamble, see Document preamble \preamble,433,435 \prec,219 \precapprox,221 \preccurlyeq,221 \preceq,219 \precnapprox,222 \precnsim,222 \precsim,221 \pref acename,267 \premulticols rigid length, 77, 78 \preparefootins,80 \PreserveBackslash, 51,108,111,114 \prime,219 printbib program, 393, 396 \PrintChanges,425,426,430 \PrintDescribeEnv,432 \PrintDescribeMacro,432 \PrintIndex,424,426,430 \printindex,353,365,367,368 Printing one-sided, 83 recto-verso, 83 two-sided, 83 \PrintMacroName,432 \ProcessOptions,461,465,468 \ProcessOptions*,461,465 \prod,219

Index

Program

\rcf rac

519

Program afmztfm, 316, 340 archie, 476 auxzbib, 376, 392 awk, 392,393 bibclean, 393 bibextract, 393 bibkey, 392, 393 bibsort.sh, 394 bibview, 394 BM2FONT, 276 citefind.sh, 393, 394 citetags.sh, 393, 394 dvicopy, 262 dvips, 91,262,300,311,315-317, 328,331-334,340,476,490, 529 dvitops, 317 egrep, 392, 393 emTeX, 3 17,476 ghostscript, 312 ghostview, 312, 317 gopher, 476 gpic, 300 gzip, 476 looktex, 393 makebib, 393 makebst, 374, 376,419 OzTeX, 3 17 pbmtopk, 276 perl, 392 PosTeX, 262 printbib, 393, 396 psfrag, 276 pstricks, 276 publicMF, 476 publicTeX, 476 sed, 392,393 sort, 394 troff, 300 wais, 476 www, 476 program package, xi, 104 program environment, 104 programbox environment, 104 \proofmodetrue, 367,368 Proportionally spaced fonts, 159 \propto, 219

\protect, 35,242, 350,471 \providecommand, 442 \ProvidesClass, 461,462,468 \ProvidesFile, 461,462 \ProvidesPackage, 461,462,466 \psQ. . ., 9 2 \ps@plain, 468 \ps@titlepage,432 psboxit package, 330 \psboxit, 331 \PScommands, 330 \psdraf t, 320 \psf igdriver, 317,319 psfrag program, 276 \psfull, 320 \Psi, 218 \psi, 218 PSNFSS, 334-345 pstimesm package, 340 pstricks program, 276 pt (Point), 163,449 publicMF program, 476 publicTeX program, 476 F'unctuation, 272 Purtill, Mark, 158 \put, 280-282,292, 293,296,299 \putbib, 386,389 \putf i l e , 299 \qbezier, 280,281 \qquad, 242,450 m Quad, see e \quad, 242,450 quotation environment, 61,415 Quotation character, 264 Quote environment, 61 quote environment, 61,443 \quotechar, 431 \raggedcolumns, 78 \raggedleft, 27, 51,114 \raggedright, 25,27,51,108,114,135 Rahtz, Sebastian, 158,275,318, 320, 334 Raichle, Bernd, 264 \raisebox, 135,453,454 \rangle, 220 \ r a t i o , 469 \ r c e i l , 220 \rcf rac, 230

520

\rcomment

Rigid length

Index

\rcomment,104 \Re,219 6 9 \real,4 \RecordChanges, 425,426,429 Recto-verso printing, 83 \ref,23,40,41,42,44,45, 58,59,73, 241,446 Reference, see Citation, see Cross-reference, see Index bibliographic -s, 371 to footnote, 73 \refname,267 \refstepcounter,29,30,446 \reftextafter, 43,44 \reftextbefore,43,44 \reftextcurrent,42,44 \reftextfaceafter,43,44 \reftextfacebefore,43,44 \reftextfaraway,43,44 \reftextvario,43,44 Reid, Brian, 7 Reid, Thomas J., 150 Rem environment, 254 \renewcommand,27,33,43,110,135,142, 154,297,441 \renewenvironment,442 \renewindex,367 report document class, 3,20-22,24,26, 34,36,72,87,96, 147,262, 364,445,462 \Requirepackage,461,463,465,467,468 \restylefloat,147,150 resume environment, 273 \reversemarginpar,7 4 \rfloor,220 \rfoot,9 6 RGB color model, 313 \rgroup,220 \rhd,184,218 \rhead,96,99 Rhead, David, 416 \rho,218 \right,117,230,246,249 \Rightarrow,219 \rightarrow,219 \rightarrowtail, 221 \rightharpoondown, 219 \rightharpoonup, 219

\rightleftarrows, 221 \rightleftharpoons,221 \rightmarginrigid length, 6 2 \rightmark, 94,98,99 \rightnode,306 \rightrightarrows,221 \rightskip rubber length, 50. 51 \rightsquigarrow,221 righttag option, 241,243,256 \rightthreetimes, 222 Rigid length, 447 \Opnumwidth,33,34 \arraycolsep,107,110,257 \arrayrulewidth,110,131 \bibhang,374 \bibindent,374 \bigstrutjot,135 \captionwidth,155 \columnsep,77, 78,84,87,152 \columnseprule, 78,84,87 \columnwidth,73,84 \cornersize,278 \depth,453,454 \doublerulesep,110 \emergencystretch,51,52 \evensidemargin,84,86,87,90,467 \extrarowheight,106,111 \extratabsurround,137 \fboxrule,277,278,453 \fboxsep,277,278, 331,453 \fminilength,469 \footnotesep,71.72 \footrulewidth,9 6 \GlossaryMin, 431 \headheight,84,87,88,97 \headrulewidth, 9 6 \headsep, 84,87,88 \headwidth,96,99 \height,453,454,458 \hoffset,86,90 \itemindent,6 2 \jot,135,257 \labelsep,60,62,103 \labelwidth,62,63-65 \leftmargin,62,63 \linewidth,34,77,84,111,460 \listparindent,6 2 \LTcapwidth,124,125

Index

Rigid length (continued)

Rule

52 1

\MacroIndent, 432 Rose, Kristoffer, 234,275 \marginparpush,74,84,87 rotate package, 91 \marginparsep,74,84,87,96, 99 rotate environment, 322,325 \marginparwidth,74,84,87,96,99 rotating package, 317,320,320-327 \mathindent,256,257 \rotcaption,327 \mathsurround,59 \rotdriver,317,320 \mtcindent,37,38 Rowley, Chris, vii, 3,73 \multlinegap,237,247,248 \Rsh,221 \naturalwidth,4 8 \rtimes,222 \oddsidemargin,84,86,87,90,467 Rubber length, 447 \paperheight,84,91 \@rightskip,51 \paperwidth,84,91 \abovedisplayshortskip, 257 \parindent, 106 \abovedisplayskip,257 \plainfootrulewidth,97 \baselineskip,52,53,72,87,88, \plainheadrulewidth, 97 99,100,106,181,451 \postmulticols,77,7 8 \belowdisplayshortskip,257 \premulticols,77,78 \belowdisplayskip,257 \rightmargin,6 2 \bigskipamount,124,451 \sboxrule,277 \dblfloatsep,143 \sboxsep,277 \dbltextfloatsep,143 \sdim,277 \fill,124,126,443,448,450,451 \shadowsize,278 \floatsep,142,143 \tabbingsep, 103 \footskip,84,87,97 \tabcolsep,107,110,134,325 \intextsep,143,152 \textheight,80,84,86,87,89,99, \itemsep,6 2 100,119,145,325 \LTleft,124,126 \textwidth,84,87,90,96,120,469 \LTpost,124 \topmargin,84,86-88,470 \LTpre,124 \totalheight,453,454,458 \LTright,124,126 \unitlength,290,296,297,302 \MacrocodeTopsep,432 \voffset,8 6 \MacroTopsep,432 \width,453,454 \medskipamount,451 \risingdotseq,221 \multicolsep,77, 7 8 \rm,174,176 \parsep,62 used in math, 176,186 \parskip,25 \rmdefault,173,174 \partopsep,62,257 \rmfamily, 167,171,173,178, 253 \rightskip,50,51 used i n math, 175,176 \skip\footins,72 \rmoustache,220 \smallskipamount,451 Robust command, 350 \subfigcapskip,153 Rokicki, Tomas, 91,315,317 \subfigtopskip,153 Roman page number style, 9 2 \textfloatsep,142,143,144 \Roman,58,446 \theorempostskipamount,253 \roman,57,58,446 \theorempreskipamount,253 roman page number style, 9 2 \topsep,62,257 Roman fonts, 160 \topskip,88,89 romanian option, 267 Rule, 458 \root,282 invisible, 442

522

\rule

\shortciteN

Index

\rule, 107,458

Run-in heading, see Heading russian option, 267


s, see Size function

Samarin, Alexander, 472


\samepage, 99

Sans serif fonts, 160 \sAppendix, 29,30 \savebox, 459 Sb environment, 233 Sbox environment, 278 \sbox, 278,443,459 \sboxrule rigid length, 277 \sboxsep rigid length, 277 \sc, 174 used in math, 186 \scaleput, 290, 292 \scdef a u l t , 173 Schrod, Joachim, 3, 72, 392 Schwarz, Norbert, 180 Schopf, Rainer, vii, 3, 66, 67, 86, 158, 216,433,476 Script style in math, 255 Scriptscript style in math, 255 \ s c r i p t s c r i p t s t y l e , 205,255 \scriptsize, 170 \ s c r i p t s t y l e , 205,255 \scshape, 168,169,171,173 used in math, 175, 176 \sdim rigid length, 277 \searrow, 219 \sec, 220 \secdef, 24,28,29 secnumdepth counter, 20,24,27, 30 \section, 17, 18, 20, 21, 22, 24, 26, 29, 30,40, 94, 96, 165, 252, 386 section counter, 21,29,94,445 \section*, 20 \sectionmark, 30,93,94, 99 sed program, 392, 393 \see, 350 \seename, 267 \selectf ont, 188,192,194 \selectlanguage, 263,265, 266 seminar package, 278 \seriesdef a u l t , 173,192 Serifed fonts, 160 \setboolean, 468,472

\setlength, 61, 72,87,96,106,110,125, 142, 143, 237, 253, 256, 328, 329,448,468 \ s e t l i n e s t y l e , 284 \setlongtables, 122,123,124,125 \setmargins, 89 \setmarginsrb, 89 \SetMathAlphabet, 179,180,210, 211, 213 \setminus, 218 \setnumberpos, 284 \setpapersize, 89 \setprecision, 285 \setstretch, 285 \ s e t s t y l e , 284,285 \SetSymbolFont, 205,207,209,213 \settodepth, 449,457 \settoheight, 449 \settowidth, 139,449 \setwidth, 285 \setxaxis, 285 \setxname, 285 \setxvaluetyp, 285 \setyaxis, 285 \setyname, 285 \ s f , 158,174,186 used in math, 176, 186 \sfdefault, 173 \sffamily, 167,169-171,173,186 used i n math, 175, 176 sf ixed, see Size function sgen, see Size function SGML, 7, 8 \shabox, 277 shadow package, 277 \shadowbox, 278 \shadowsize rigid length, 278

Shape of fonts, see Font shape


\shapedef a u l t , 173,192 shapepar package, 54 \shapepar, 54 \sharp, 219 \shortcite, 374 \shortciteA, 374 \shortciteN, 374

Index

\shortindexingoff

\SpecialIndex

523

\shortindexingoff, 367 \shortindexingon, 367, 368 \shortmid, 221 \shortpage, 100 \shortparallel, 221 \shortstack, 54,282,294,303 \showcols, 113 showidx package, 351,354,367 \showprogress, 434 showtags package, 394,397 siam BETEX style, 378 \sideset, 226,227 sideways environment, 322,325 sidewaysfigure environment, 325, 327 sidewaystable environment, 325,326, 327 \Sigma, 218 \sigma, 218 \sim, 219 \simeq, 219 Simple size, 196 \sin, 220,228 \sinh, 220 Size function, 196, 196-200 "empty", 196-197,198,199 fixed, 199, 212 gen, 198 s, 198 sf ixed, 200 sgen, 198 ssub, 199,213 ssubf, 199 sub, 193,198-199,212,213 subf, 199,212 Size info, 196 structure, 196

\slshape, 168,169,171,173,253 used in math, 175, 176 \small, 52,170 \smallf rown, 221 smallmatrix environment, 232 \smallsetminus, 222 \smallskip, 45 1 \smallskipamount rubber length, 451 \smallsmile, 221 \smash, 227 \smile, 219 sort program, 394 \SortIndex, 431 Sorting the index, 5, 353 \SortNoop, 402,404 \sout, 50 Sowa, Friedhelm, 53 Sp environment, 233 sp (Scaled point), 449

Space

after abbreviation, -s in index entries, in formulas, inter-letter - (tracking), inter-line - (leading),


242

50 348, 351

48 52 inter-word N , 48,200, 201, 202,453 changing the -, 201-202

wrong after font change, see Italic correction


\space

use in .f d file, 204 use in \DeclareFontEncoding, 203 use in \DeclareFontShape, 196 spacing environment, 52

\spadesuit, 219

Size of fonts, see Font size Size range, 196 \skip\f ootins rubber length, 72
\ s l , 174

used in math, 186


\sldef a u l t , 173

Slide, see Overhead slide slides document class, vii, 3, 185 SLITEX,vi, vii, 185
\sloppy, 52

Slovak option, 267 Slovene option, 267

Spanish option, 267 \spbox, 331 \spbreve, 225 \spcheck, 225 \spdddot, 225 \spddot, 225 \spdot, 225 \special, 91,275,276,287, 300,311, 315,317,319,320,328,331 Special character (BIBTEX), 402 \SpecialEnvIndex, 431 \SpecialEscapechar, 430 \SpecialIndex, 431

524

\S~ecialMainIndex

\su~ertabular

Index

\SpecialMainIndex, 431 \SpecialUsageIndex,431 \sphat,225 \sphericalangle,222 Spit, Werenfried, 416 Spivak, Michael, 340 \spline,301,302 split environment, 235, 238-240, 243-246,249, 344 \sptilde,225 \sqcap,218 \sqcup,218 \sqrt,220 \sqsubset,184,219,221 \sqsubseteq,219 \sqsupset,184,219,221 \sqsupseteq,219 \square,222 \squarepar,55 \ss, 172 ssub,see Size function ssubf,see Size function \stackrel,226, 234 StandardModuleDepthcounter, 432 \star,218 \stepcounter,446 \stop,187 \StopEventually,424,430 \stretch,448,451 String constant in BIBTEX style file, 407 Strut, 442,458 \strut,135 .styfile, 3,4, 12, 13, 15,44 Style file BIBTEX, 375,376 Makelndex, 3 58 Style parameters array & tabular,110 barenv,284-286 bibliography, 373, 374 boxes, 277,453 change bars, 329-330 contents lists, 32-35, 37 cross-references, 44 doc, 432 enumerate,57 fancyheadings, 97

figure & table,142-143 fonts, 173 \footnote,70-73 formulae, 255-257 headings, 24-28 index, 358, 359 itemize,59 list,62 longtable,124 \marginpar,74 mathematics, 255-257 multicols,77-79 pages, 83-88 paragraph, 50-52 theorems, 2 53 sub,see Size function subf,see Size function \subfigcapskip rubber length, 153 \subfigtopskip rubber length, 153 subfigure package, 152 \subfigure,153 subfigure counter, 153 \subitem,364 \subparagraph,20, 2 1 subparagraph counter, 21,445 \subsection, 17,20,21,96 subsection counter, 21, 22,445 \Subset,221 \subset,219 \subseteq,219 \subseteqq,221 \subsetneq,222 \subsetneqq,222 \subsubitem,364 \subsubsection,20 subsubsection counter, 21,445 \succ,219 \succapprox,221 \succcurlyeq,221 \succeq,219 \succnapprox,222 \succnsim,222 \succsim,221 \sum,219 \sup,220 supertab package, 119 \supertabular, 119

Index

supertabular environment

\textrm

525

supertabular environment, viii, 101, 102,119,120,122-126,128 supertabular* environment, 120,121 \suppressfloats, 144,145 \Supset, 221 \supset, 219 \supseteq, 219 \supseteqq, 221 \supsetneq, 222 \supsetneqq, 222 \surd, 219 \swabf amily, 183 \swamow, 219 swedish option, 267 Symbol AMS -s, 220-222 ~ " & X - S184,218-220 , negated -s, 2 17 \symbol, 172 Symbol fonts, see Math symbol fonts Syntax check, 186 \syntaxonly, 186 syntonly package, 186
t l enc package, 180

tabbing environment, 101,102,103,104 \tabbingsep rigid length, 103 \tabcolsep rigid length, 107, 110, 134, 325 Table floating object, 141-1 55 in multicols, 79 labels in -s, 41 \table, 187 t a b l e counter, 445 t a b l e environment, 40,102,122,125, 133,141,145-147,149,154, 455 labels in -, 41 style parameters, 142-143 \tablecaption, 119 \tablef irsthead, 119,124 \tablehead, 119,124 \ t a b l e l a s t t a i l , 119,125 \tablename, 267 \tableof contents, 18,32, 36, 37,95 \tableplace, 154 \ t a b l e t a i l , 119,125

tabular environment, viii, x, 9, 50, 51, 52, 101, 102, 104, 105, 107-110,112,114, 115,118, 119, 129, 132, 136, 140, 153, 453,455 style parameters, 110 tabular* environment, 104,113,115, 119,134 TabularC environment, 111,115,116 tabularx package, 101, 113-117, 139 tabularx environment, 112, 113, 114-117,132,139 \tabularxcolumn, 114 tabwindow environment, 53, 54 \tag, 240,241,243 \tag*, 240,241,247, 248 \tagcurve, 290,291 \tan,220 \tanh, 220 tar archive format, 477 \tau, 218 Taylor, Paul, 234 Taylor, Philip, 48 \tbinom, 229,230,344 \tbranch, 282,283 Testing fonts, 187 testpage. tex, 86 TEX user groups, 479-48 1 .tex file, 3,4,129 TeX-index file, 475,476 .texlog file, 4 Die T~Xnische Komodie, 394 \text, 178,215,218,227,231,243, 251 Text style in math, 2 55 \textbf, 167,171,173 used in math, 178 \textf loatsep rubber length, 142,143, 144 \textfraction, 142,145 \textfrak, 183 \textgoth, 183 \textheight rigid length, 80, 84, 86, 87, 89,99,100,119,145,325 \ t e x t i t , 168,171,173,349 used in math, 178 \textmd, 167,171,173 \textnormal, 166,171 \textrm, 166,167,171,173,178

526

\textrm (continued)

Trevorrow, Andrew

Index

used in math, 178 \textsc, 168,171,173 used in math, 178 \textsf, 166,171,173,193 used in math, 178 \text& 168,171,173 used in math, 178 \textstyle, 205,255 \textswab, 183 \ t e x t t t , 167,171,173,352 used in math, 178 \textup, 167,171,173 T m s program, 3 17 textures option, 317 \textwidth rigid length, 84, 87, 90, 96, 120,469 .tfm file, 4, 5, 157, 168, 170, 180, 188, 194, 195, 197, 201, 202, 316, 339 \ t f rac, 229,230 \the, 447,448 thebibliography environment, 17,18, 95,372,374-376,385,411 \thechapter, 22 \theCodelineNo, 432 \theendnotes, 75 \theenmi, 56, 57 \theenumii, 56, 57 \theenumiii, 57 \theenumiv, 57 \theequation, 241 \thef ootnote, 71, 72,132 theglossary environment, 364 theindex environment, 18,95, 351, 364, 365 \thempfootnote, 71 theorem package, 251,433,476 theorem environment, 251 \theorembodyfont, 252,253,254 \theoremheaderf ont, 253,254,255 \theorempostskipamount rubber length, 253 \theorempreskipamount rubber length, 253 \theoremstyle, 252,253 \thepage, 92,98,99 \theref ore, 221 \TheSbox, 278

\thesection, 22,23 \thesubf igure, 153 \thesubsection, 22 \Theta, 218 \theta, 218 \thickapprox, 221 \Thicklines, 301,303 \thicklines, 278,292,297-299,301, 303,305 \thicksim, 221 \thickspace, 242 \thinlines, 278,280,297-299,303-305 \thinspace, 242 \thispagestyle, 29,91,92,97,148 Thorup, Kresten K., 468 threeparttable package, 133 threeparttable environment, 133 \ t i l d e , 218 \time, 469 times package, 148,334,339,340 \times, 218 \tiny, 170 .toc file, 4, 5, 19, 20, 29, 31, 35, 36, 365, 367 tocdepth counter, 24,33,35,37,38 \today, 265,266 \tolerance, 51, 52 \top, 219 \topcaption, 119 \topf igrule, 143 \topfraction, 142,144 \topmargin rigid length, 84,86-88,470 topnumber counter, 142 \topsep rubber length, 62,257 \topskip rubber length, 88,89 \totalheight rigid length, 453,454,458 totalnumber counter, 142 tracefnt package, 186, 187, 211 \tracingf onts, 211 tracingmulticols counter, 78, 79 \tracingtabularx, 117 Tracking, see Space Tree binary, 282 drawing -s, 307 ternary, 282 trees package, 282 Trevorrow, Andrew, 317

Index

\triangle

\varphi

527

\triangle, 219 \triangledown, 222 \ t r i a n g l e l e f t , 218 \trianglelefteq, 221 \triangleq, 221 \triangleright, 218 \trianglerighteq, 221 troff program, 300 \ t t , 174 used in math, 176, 186 \ttdef a u l t , 167,173 \ t t f amily, 167,171,173 used in math, 175,176 .ttt file, 154 TEX Users Group, 479 TUGboat, 394 turkish option, 267 t u r n environment, 140,322 TWGMLC, 260 \twlrm, 186 Two-sided printing, 83 twocolumn option, 12, 75, 76, 80, 146, 150,152,392 \twocolumn, 76 \twoheadlef tarrow, 221 \twoheadrightarrow, 221 twoside option, 90, 330, 392 \typeout, 204,433 Typographic measure, 449 Typographical fonts, 159

\unlhd, 184,218 \unrhd, 184,218 \unskip, 61

unsrt BIBTEX style, 377-379,382,410,


414,418 \Uparrow, 219,220 \uparrow, 219,220 \updef a u l t , 173 \Updownarrow, 219,220 \updownarrow, 219,220 \upharpoonlef t , 221 \upharpoonright, 22 1 \uplus, 218 \uproot, 225 \upshape, 167,169,171,173 \Upsilon, 218 \upsilon, 218 \upuparrows, 221 \urcorner, 220

U S executive, see Paper size U S legal, see Paper size U S letter, see Paper size
\usage, 431 \usebox, 443,459 \usecounter, 65 \usef ont, 192 \usepackage, xii, 9,12-15,37,38,43, 148, 151, 216, 243, 263, 265, 317,352,380,462,464-466

User groups, see TEX user groups


\uwave, 50 \vadjust, 54 \value, 446,468

UKTEX Users Group, 480


\ulcorner, 220

ulem package, 49 \ULf orem, 49 \uline, 50 Umlaut, 264 unbalance counter, 78, 79 \unboldmath, 179 \underbrace, 220 \underleftarrow, 223 \underlef trightarrow, 223 \underline, 220 \underrightarrow, 223 \underset, 226 Unicode, 260 \unitlength, 304, 305 \unitlength rigid length, 290, 296, 297, 302

van Oostrum, Piet, 96 Van Zandt, Timothy, 278 Vamoose, Peter, 282
\varepsilon, 218

Variable names in BJBTEXstyle file, 407 types of -s in BIBTEX style file, 410

\varinjlim, 228

varioref package, 41,44,460


\varkappa, 220 \varliminf, 228 \varlimsup, 228 \varnothing, 222 \varphi, 218

528

\varpi

zoo archive format

Index

\varpi, 218 \varprojlim, 228 \varpropto, 221 \varrho, 218 \varsigma, 218 \varsubsetneq, 222 \varsubsetneqq, 222 \varsupsetneq, 222 \varsupsetneqq, 222 \vartheta, 218 \vartriangle, 222 \vartrianglelef t , 221 \vartriangleright, 221 \Vdash, 221 \vDash, 221 \vdash, 219 \vdots, 219 \vec, 218 \vector, 292,305 \vee, 218 \veebar, 222 Ventry environment, 63,64,444 \verb, 66,115,243,425 \verb*, 115 verbatim package, 66, 80,476 verbatim environment, 66,69,425,430 verbatim* environment, 66,430 \verbat imchar, 43 1 verbatimcmd environment, 68 \verbatiminput, 68 verbatimtab environment, 67,68 \verbat i m t abinput, 68 verbatimwrite environment, 67, 70 version package, 82 Version control, 82 .vf file, 316 \vf i l l , 451 Virtual font, 261-262, 316, 334 \vline, 110,131 Vmatrix environment, 23 1 m a t r i x environment, 231 \vof f s e t rigid length, 86 vpage package, 89 \vpageref, 42,43 \vref, 41,42,43,44 \vrule, 107 \vspace, 54,97,450,451,458

wais program, 476 Ward, Martin, 104 Ward, Nigel, 36 warningshow option, 187 \wedge, 218 Weight of fonts, 162 \whiledo, 474 \widehat, 220, 225 \WideMargins, 90 \widetilde, 220,225,246 \width rigid length, 453,454 Width of fonts, 162 window environment, 53 Winton, Neil, 328 \wlog, 204 Wolczko, Mario, 89, 277 \up,219 \wr, 218 wrapfig package, 151 wrapf igure environment, 53,151,152 Wrong font selected, 174, 194 Wujastyk, Dominik, 73 www program, 476 X-height, 162, 163, 201, see also em, 449 xalignat environment, 235, 237,25 1 \Xarea, 473 \Xi, 218 \xi, 218 .xmp file, 36 \xout, 50 xr package, 45 \Xsize, 473 xspace package, 50 \xspace, 50 xxalignat environment, 235, 237 XY-pic, 275

Zapf, Hermann, 181,183 ZapfDingbats Postscript font, 335 \zeta, 218 zip archive format, 477 zoo archive format, 477

Production Notes
This book was typeset by the authors on a Hewlett-Packard and a Sun workstation at CERN in Geneva and on a DEC Station in Mainz using an early version of LATEXZE. Files were exchanged back and forth between the two sites via Internet electronic mail. Typeset chapters where translated into Postscript using dvips; proofs were printed on an Apple Laserwriter Pro and a Xerox Docutech. For copyediting and proofreading, Postscript files were also copied via ftp to Addison-Wesley's Sun computer in Reading, so that the chapters could be printed locally and the turn-around time for introducing changes was minimized. The final version of the book-from front to back-was produced with a single huge I4QX job. The index was generated from the L Q X .i d x file using Makelndex; the bibliography was prepared with BETEX. Four L A T E X runs were necessary to correctly resolve all references. The resulting Postscript file, 9.5 Mbytes in size, was then copied, in pieces, by ftp to Reading where camera-ready copy was produced on a Varityper 4300P at 1200 dpi. The cover art of the Companion was rendered by Toni Saint-Regis, and the designer of the interior was Mark Ong of Side-by-Side Studios. Frank translated the designer's specifications into a m X z E class file. The typeface used for the main text is Lucida Bright 9.5/12pt designed by Bigelow & Holmes, the sans serif font is Lucida Sans also by Bigelow & Holmes, and the typewriter font is Computer Modern Typewriter 10/12pt by Donald Knuth. Chapter heads are set in Lucida Bright bold 36/38pt; section heads in 14/15pt in the same typeface. The production of the Companion was a challenge-both for the authors and for L A T E X . Indeed, several bugs were found in the packages when we tried to A T E Xjob. use them all together in a single L In this book we advocate the separation of structure and form and suggest that you avoid visual markup whenever possible. Thus, after typesetting this book it is perhaps time to ask "How well does H&X do its job if it is given a design (a class file) and a document file?". For those of you who like data, here

are some statistics using the Companion as a real-life example: the table below shows the amount of hand-formatting we found necessary to produce the final copy of this book. To flag all visual formatting clearly (so that it can easily be identified and removed in case the text needs changing), we never used the standard L Q X commands directly. Instead we defined our own set of commands, often simply by saying, for instance, \newcommand{\f inalpagebreak){\pagebreak). The table divides the commands used into three groups. The first deals with changes to the page length: \f inallongpage and \finalshortpage run a page long or short, respectively, by one \baselineskip. The command \f inalforcedpage is an application of \enlargethispage* and is therefore always followed by an explicit page break in the source. The techniques for defining such commands are explained in section 4.4. The second group contains the commands for "correcting" IK&EX's decision about when to start a new page, and the final group contains a single command for adding or substracting tiny bits of vertical space to improve the visual appearance. The average number of corrections made with commands from the first group is slightly over 20%, or one out of five double spreads, since we applied such a change always to pairs of pages. If you look at the chapters with a large percentage of corrections, you will find that they contain either very large in-line examples or large tables that should stay within their sections. Hard page breaks were inserted, on average, every tenth page, often in conjunction with a command from the first group. In most cases this was used to decrease the number of lines printed on the page. Most uses of \f inalfixedskip can be classified as "correcting shortcomings in the implementation of the design." With an average of about 16%this may seem high. But in fact such micro adjustments usually come in pairs, so this corresponds to approximately one correction every 1 2 pages. As a conclusion, we think that EYQX did a good job given the complex content. Even without any hand-formatting most pages were acceptable. It is for you to judge whether the addtional effort was worth the trouble.
Chapter Numberofpages
\finallongpage \finalshortpage \finalforcedpage

2 36 0 0 1
1

3 36 3 5 0 8 .22 5 1 6 .17 3 .08 17 .47

4 18 1 4 0 5 .29 2 0 2 .ll

5 40 0 4 2 6 .I5 4 0 4 .1

6 16 3 0 2 5 .33 3 0 3 .19 0 0 8 .5 1 2

7 58 0 1

8 44 4 0

9 1 0 1 1 1 2 1 3 1 4 A l 16 36 36 26 50 18 36 2 0 0 2 .13 2 1 0 1 .06 2 .13 5 .31 0 0 0 0 3 .08 0 0 6 .17 3 0


1 9 .25

0 8

4 6 0 10 .38

Pagelengthchange Average per page


\finalpagebreak \f inalnewpage

.03 4 0 4 .ll 4 .I1 9 .25

0 12 .08 7 0 7 .12 8 .14 27 .47 1

1 15 .34
0 12 .27 2 .05 29 .66

9 0 1 10 .2 5 1 6 .12

7 0 0 7 .39 3 0 3 .17 7 .38 17 .94

4 2 0 6 .17 6 0 6 .17 3 .08 15 .42

6 0 4 .15

Pagebreakchange Averageperpage
\finalfixedskip

Average per pnge Sum Average per page

4 1 1 .22 .28 11 21 .61 .53

0 1 4 .39 0 29 3 .81 .08

6 1 0 .23 .2 26 20 .77 .52

iputer Ty pesettin!

Michel Goossens

Ibach, and Alt

r Sama

UTEX is an accessible and effective tool for typesetting written docu~nents.Users a t all levels of experience, however, sometimes require help not readily available: techniques for defining new commands, styles for producing tables or graphics, explariations for changing fonts. This book, The DTEX Companzon,, is packed with information needed to use UTEX even more productively. It is a true companion to Leslie Lamport's original user's guide, also published by Addison-Wesley, and indeed, it is a valuable complement to any BTEX introduction. It is designed to enhance, not to replace, your basic documentation. Coinciding with the publication of The DTEX Companion is the availability of a revised UTEX standard-UTEX 2,c. This new release incorporates important BTEX developments over the past several years and provides a common basis for all UTEX enhancements. Some new styles, improved font handling, and a facility to produce Postscript graphics are included in the release. As part of the broad and unique coverage of this book, you will find complete documentation for all these added features.

1 I
I

HIGHLIGHTS Covers a11 versions of BTEX now in use, including UTEX 2E Describes over 150 convenient styles for floats, graphics, tables, and much more Shows how to define new conln~ands and environments Explains the use of Postscript Covers the latest extensions and programs for prodncing pictures, indexes, bibliographies, and advanced mathematics Includes techniques for multi-language support Describes tlle New Font Selection Scherne
All three authors have for years been involved in the support and develop~nentof UTEX applications. Michel Goossens and Alexander Samarin drveloped ideas for The DTEX Compnn~on while supporting hnndreds of BTEX users at CERN, and Frank Mittelbach, at the University of hlainz and Electronic Data Systems. The questions most freq~~ently posed to them became the questions answered in this book. Mittelbach is partly responsible for the current maintenance of BTEX and is the author or coauthor of many widespread UTEX extension packages, such as AMS-UTEX, doc, multicol, and the New Font Selection Scheme. HP is also the manager and principal architect of the longer-term UTEX3 project, to which half the royalties from this book are paid.

b \',
'
' :
I.,-

*,,'T.

ISBN 0-20 1-54 199-8

You might also like