close

Вход

Забыли?

вход по аккаунту

?

Digital Typography Using Latex. 2003

код для вставкиСкачать
Apostolos Syropoulos, Antonis Tsolomitis, Nick Sofroniou
DIGITAL TYPOGRAPHY USING LaTeX
Apostolos Syropoulos Antonis Tsolomitis Nick Sofroniou
Springer
D igital Typogr aphy Using WKX.
Springer
New York
Berlin
Heidelberg
Hong Kong
London
Milan
Paris
Tokyo
Apostolos Syropoulos Antonis Tsolomitis Nick Sofroniou
D igital Typogr aphy Using WTeX
With 68 Illustrations
Includes a CD-ROM J
Springer
Apostolos Syropoulos 366, 28th October St.
GR-671 00 Xanthi GREECE
apostolo@oceanl.ee.duth.gr
Nick Sofroniou Educational Research Centre St. Patrick's College Drumcondra, Dublin 9 IRELAND
nick.sofroniou@erc.ie
Antonis Tsolomitis Dept, of Mathematics University of the Aegean GR-832 00 Karlobasi, Samos GREECE
atsol@iris.math.aegean.gr
Library of Congress Cataloging-in-Publication Data Syropoulos, Apostolos.
Digital typography using LaTeX / Apostolos Syropoulos, Antonis Tsolomitis, Nick Sofroniou. p. cm.
Includes bibliographical references and indexes.
ISBN 0-387-95217-9 (acid-free paper)
1. LaTeX (Computer file) 2. Computerized typesetting. I. Tsolomitis, Antonis. Π.
Sofroniou, Nick. III. Title.
Z253.4.L38 S97 2002
686.2'2544—dc21 2002070557
ACM Computing Classification (1998): H.5.2,1.7.2,1.7.4, K.8.1 ISBN 0-387-95217-9 (alk. paper) Printed on acid-free paper.
Printed on acid-free paper.----------------------------------------------------------------------------------------------------------------------
© 2003 Springer-Verlag New York, Inc.
All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY 10010, USA), except for brief excerpts in connection with reviews or scholarly analysis. Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar
or dissimilar methodology now known or hereafter developed is forbidden.-----------------------------------------
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they
are not identified as such, is not to be taken as an expression of opinion as to whether they are subject
to proprietary rights.
Printed in the United States of America.
9876 5 4321 __________ SPTN 10791970___________________________________________________________
Typesetting: Pages created by the authors using I^TgX www. springer-ny. com
Springer-Verlag New York Berlin Heidelberg
A member of BertelsmannSpringer Science+Business Media GmbH____________________________________________
Dedicated to the fond memory of Mikhail Syropoulos, my beloved brother; io my parents,
Georgios and Vassiliki, and to my son, Demetrios-Georgios.
— AS.
♦
To my parents,
Panagiotis and Evangelia, and to my wife,
Angeliki.
— A.T.
♦
To my father,
Andreas Sofroniou, who introduced me to computers when they were few and far between.
— N.S.
C o n t e n t s
Foreword by Yannis Haralambous xv
Preface xxv
1 Introduction 1
1.1 What Is Te*? ............................................................................................................ 1
1.2 Logical versus Visual D e s i g n............................................................................... 3
1.3 Preparing a Document with I^TgX...................................................................... 4
1.4 How Does T^X Typeset?......................................................................................... 10
1.5 More Information and Resources......................................................................... 11
2 The File Structure 13
2.1 The Characters We Type......................................................................................... 13
2.2 Document Classes and Packages......................................................................... 17
2.3 Sectioning Commands............................................................................................ 20
2.4 The Document Title ................................................................................................ 26
2.5 Basic L o g o s................................................................................................................ 28
2.6 Article Preparation................................................................................................... 29
2.7 Letter Preparation................................................................................................... 31
2.8 Producing Proceedings Articles ......................................................................... 33
2.9 Combining Individual 1?TeX Files ...................................................................... 34
3 Fonts and Their Use 39
3.1 Classification of F o n t s............................................................................................ 39
3.2 Accessing more G l y p h s......................................................................................... 46
3.2.1 Euro F o n t...................................................................................................... 50
3.2.2 Hie wasysym F o n t s..................................................................................... 50
3.2.3 Phonetic Fonts ............................................................................................ 52
3.3 Automated Special Glyphs Selection.................................................................. 53
3.4 Size-Changing Commands.................................................................................. 56
ν ι π -φ- Con ten ts
3.5 Advanced A c c e n t s................................................................................................... 59
4 Lists and Catalogs 61
4.1 Units oi Measure...................................................................................................... 61
4.2 Typesetting P o e t r y................................................................................................... 63
4.3 L i s t s............................................................................................................................. 64
4.3.1 Customizing the Standard Lists............................................................... 66
4.4 Qgotations ................................................................................................................ 68
4.5 F o o t n o t e s................................................................................................................... 69
4.5.1 Customizing Footnotes ............................................................................ 71
4.5.2 Endnotes......................................................................................................... 73
4.6 Simulating Typed Text............................................................................................. 74
4.6.1 Advanced Typed Text Simulation ........................................................ 75
4.7 Centering and Flushing T e x t................................................................................ 77
4.8 Alignment................................................................................................................... 78
4.8.1 The tabbing Environment......................................................................... 79
4.8.2 The tabular Environment......................................................................... 80
4.9 More on Alignment ................................................................................................ 84
5 Typesetting Mathematics 93
5.1 The Mathematics M o d e........................................................................................ 93
5.2 Font Selection in Mathematics Mode.................................................................. 94
5.3 Symbols for the Mathematics M o d e................................................................... 95
5.3.1 Special Latin A l p h a b e t s............................................................................ 95
5.3.2 The Greek Letters........................................................................................... 96
5.3.3 Accents in Math M o d e................................................................................. 97
5.3.4 Binary Operators.........................................................................................— 98
5.3.5 Variable-Size Operators............................................................................ 99
5.3.6 Delimiters...................................................................................................... 99
5.3.7 Arrows............................................................................................................ 99
5.3.8 Relational Operators......................................................................................100
5.3.9 Miscellaneous Symbols ...............................................................................102
5.3.10 More Math S y m b o l s......................................................................................103
5.3.11 Other Mathematics Font Families...............................................................107
5.4 The Art of Typesetting Mathematical Text............................................................107
5.4.1 Exponents, Indices, Fractions, and Roots ...............................................107
5.4.2 Functions .........................................................................................................109
5.4.3 One Above the Other......................................................................................l li r
5.4.4 Horizontal S p a c e............................................................................................113
5.4.5 Integrals and Series.........................................................................................113
5.4.6 Matrices, Arrays, and Nonanalytically Defined Functions .... 115
5.4.7 Theorems .........................................................................................................117
5.4.8 Customizing the t heorem Environme n t.............................................. 119
C on ten ts ·φ· ιχ
5.4.9 Eq uati ons.......................................................................................................124
5.4.10 Size Selection in Math M o d e s...................................................................126
5.4.11 Commutative Diagrams.............................................................................126
5.5 The Am.S Classes and Packages................................................................................128
5.5.1 Additional Symbols ....................................................................................129
5.5.2 Accents in Math.............................................................................................129
5.5.3 Dots .................................................................................................................130
5.5.4 Nonbreaking Da s he s....................................................................................130
5.5.5 Over and Under Arrows.............................................................................131
5.5.6 Multiple Integral Signs................................................................................131
5.5.7 Ra d i c a l s..........................................................................................................131
5.5.8 Extensible A r r o w s.......................................................................................132
5.5.9 Affixing Symbols to Other S y m b o l s......................................................132
5.5.10 Fractions and Related Constructs.............................................................132
5.5.11 The \smash Command................................................................................133
5.5.12 Operator N a m e s..........................................................................................133
5.5.13 The \mod Command and its R e l a t i v e s...................................................134
5.5.14 The \t e x t Command....................................................................................134
5.5.15 Integrals and S u m s.......................................................................................134
5.5.16 Commutative Diagrams.............................................................................135
5.5.17 Displayed Equations and Aligned Structures......................................135
5.5.18 Numbering Equations and Referencing................................................138
5.5.19 Matrices..........................................................................................................140
5.5.20 Boxed Formulas.............................................................................................140
5.5.21 Customizing Theorems .............................................................................141
5.5.22 Options of the amsmath Package.............................................................142
5.5.23 Converting from Standard I^rgX to the A ^\S Packages ...................143
5.5.24 The amsart Top Matter Commands..........................................................143
5.6 From A to Ma t h M L...................................................................................................144
5.7 Generating OMDoc Files ..........................................................................................148
6 More on the Core 151
6.1 Labels and References................................................................................................151
6.2 Hyper-references..........................................................................................................155
6.3 Horizontal and Vertical Space ................................................................................163
6.3.1 Length Variables..........................................................................................163
6.3.2 Horizontal S p a c e..........................................................................................164
6.3.3 Vertical S p a c e.................................................................................................166
6.4 Counters..........................................................................................................................168
6.5 Floating Objects.............................................................................................................170
6.6 Marginal N o t e s.............................................................................................................178
6.7 Page Layout...................................................................................................................179
χ -φ- Con ten ts
6.8 Page Styles .................................................................................................................182
6.9 The Preparation oi S l i d e s.......................................................................................185
6.9.1 Advanced Slide Preparation.........................................................................187
6.10 Boxes..............................................................................................................................196
6.10.1 Fancy B o x e s.....................................................................................................199
6.11 New Commands.......................................................................................................203
6.12 New Environments .................................................................................................207
6.13 New L i s t s....................................................................................................................208
6.14 File I n p u t....................................................................................................................211
6.15 LT^X a l'interactive....................................................................................................213
7 Miscellaneous Packages 215
7.1 The calc P a c k a g e.......................................................................................................215
7.2 The ifthen P ack a ge....................................................................................................216
7.3 Syntax Checki ng.......................................................................................................217
7.4 Typesetting CD Covers ..........................................................................................218
7.5 Drop Capitals..............................................................................................................220
7.6 Preparing a Curriculum Vitae .............................................................................222
7.7 Multicolumn Typesetting.......................................................................................225
7.8 Hyphenatable Letter Spacing.................................................................................225
8 Bibliography and Index 229
8.1 Preparing the Bibliography....................................................................................229
8.2 Using BibT^X ..............................................................................................................231
8.2.1 The BibTeX F i e l d s............................................................................................236
8.2.2 Typesetting a Bibliographic D a t a b a s e.....................................................237
8.2.3 Multiple Bibliographies in One Document ............................................237
8.2.4 Bibliography in a Multilingual Environment........................................238
8.3 Preparing the I n d e x.................................................................................................241
8.4 ma KEiNDExin a Multilingual Environment.......................................................244
8.5 Customizing the Index..............................................................................................245
8.6 Glossary Preparation.................................................................................................247
Graphics 253
9.1 Drawing with the picture Environment..........................................................253
9.1.1 Invisible and Framed B o x e s.........................................................................254
9.1.2 Lines and Arrows............................................................................................255
9.1.3 Circles and Curved Shapes.........................................................................256
9.1.4 The Construction of Patterns .....................................................................256
9.1.5 An Example of the Calculation of the Area of a S q u a r e.....................257
9.1.6 A Diagram for the Calculation of the Area of a C i r c l e........................258
9.1.7 Box-and-Whisker Plots in the Style of John W. T u k e y........................259
9.1.8 A Scatter Plot of Temperature.....................................................................261
C on ten ts <>- x i
9.1.9 picture-Related Packages and S ys t em s................................................264
9.2 The Gnuplot S y s t e m.................................................................................................266
9.3 The graphicx Package.................................................................................................266
9.3.1 Playing with Words ....................................................................................268
9.4 Images that Can Be Loaded to a Ι^ΤβΧ File..........................................................270
9.5 Image Inclusion with pdfl^T^X..............................................................................271
9.6 Images in the Background........................................................................................271
9.7 The rotating Package.................................................................................................272
9.8 Mathematics Drawing..............................................................................................274
9.9 The PiCT^X Package.....................................................................................................275
9.9.1 The PPCHjex Package....................................................................................285
9.9.2 The PSTricks Packages................................................................................286
9.10 Graphs with METRPOST ........................................................................................289
9.11 Color Information.....................................................................................................293
9.11.1 Color in our Documents.............................................................................293
9.11.2 Coloring Tables.............................................................................................295
9.11.3 Color and the Printing Industry .............................................................299
9.12 Printing in Landscape M o d e.................................................................................299
10 Multilingual Typesetting 301
10.1 The babel Package .....................................................................................................302
10.2 The Ω Typesetting Engine........................................................................................304
10.3 The ε-Τ^Χ Typesetting Engine.................................................................................314
10.4 The Greek Language.................................................................................................315
10.4.1 Writing Greek Philological T e x t s.............................................................317
10.4.2 Working with Thesaurus Linguae Grecae.............................................318
10.5 The Latin Language.................................................................................................319
10.6 The Dutch Language.................................................................................................319
10.7 The Esperanto Language ........................................................................................320
10.8 The Italian Language.................................................................................................321
10.9 The Irish and "British" Languages........................................................................321
10.10 The German Language..............................................................................................321
10.11 The French L a n g u a g e..............................................................................................322
10.12 The Breton Language ..............................................................................................323
10.13 The Nordic Languages..............................................................................................323
10.14 The Thai Language.....................................................................................................324
10.15 The Bahasa Indonesia Language...........................................................................326
10.16 The Slovenian Language...........................................................................................326
10.17 The Romanian L a n g u a g e........................................................................................327
10.18 The Slovak Language ..............................................................................................327
10.19 The Czech Language.................................................................................................327
10.20 The Tibetan Language..............................................................................................327
x n -Φ- C o n t e n t s
10.21 The Japanese L a n gua ge...........................................................................................329
10.22 The Spanish Language..............................................................................................332
10.23 Other Iberian L a n g u a g e s........................................................................................333
10.24 The Estonian L a n g u a g e...........................................................................................334
10.25 The Korean Language..............................................................................................334
10.26 The Hebrew Language..............................................................................................336
10.27 The Cyrillic Script .....................................................................................................338
10.28 The Armenian Language ........................................................................................340
10.29 The Polish Language.................................................................................................342
10.30 The Georgian Language...........................................................................................343
10.31 The Ethiopian Language...........................................................................................344
10.32 The Serbian Language..............................................................................................346
10.33 The Sorbian L a n g u a g e s...........................................................................................347
10.34 The Croatian L a n g u a g e...........................................................................................347
10.35 The Perso-Arabic La n guages.................................................................................348
10.36 India's L an g ua g e s.....................................................................................................351
10.37 The Cherokee Language...........................................................................................355
10.38 The Hungarian Language........................................................................................357
10.39 The Turkish Language..............................................................................................358
10.40 The Mongolian Language........................................................................................358
10.40.1 Modem Mongolian—C y r i l l i c.................................................................359
10.40.2 Classical Mongolian —U i g h u r..............................................................360
10.40.3 Classical Mongolian —Horizontal Square Writing..........................362
10.40.4 Classical Mongolian - Soyombo ..............................................................363
10.41 The Vietnamese Language........................................................................................365
10.42 The Manchu Language..............................................................................................366
10.43 The Inuktitut Lan guag e...........................................................................................367
10.44 Archaic Writing Systems...........................................................................................368
11 To Err Is Human 375
11.1 I^TeX's Error Locator.................................................................................................377
11.2 Error Messages...........................................................................................................378
11.2.1 Errors found by I^TeX ................................................................................381
11.2.2 Errors in LT^X Packages.............................................................................384
11.2.3 Errors Found by TgX...................................................................................384
11.3 Warnings .....................................................................................................................387
11.3.1 Warnings Generated by I4TeX....................................................................387
11.3.2 Warnings Generated by T^X........................................................................390
11.4 The Last S t r a w...........................................................................................................390
C o n t e n t s -φ- x m
12 Installing New Type 393
12.1 Installing METRFONT Fonts...................................................................................393
12.2 Installing Type 1 Text Fonts in Έ^Τ^Χ...................................................................394
12.2.1 Extracting Metric Information....................................................................394
12.2.2 Encoding Vectors...........................................................................................395
12.2.3 Creating Virtual Fonts and Metric F i l e s.................................................398
12.2.4 Creating More Fonts from a Type 1 Font.................................................400
12.3 Virtual Property List F i l e s......................................................................................400
12.3.1 Two Applications...........................................................................................405
12.4 Creating Support Packages and Font Definition F i l e s..................................408
12.5 Systemwide Installation of Prepared F o n t s......................................................411
12.6 Installing Scalable Fonts for pdfI£[£X...............................................................411
12.7 Installing Scalable Fonts for Λ............................................................................413
12.8 OpenType F o n t s......................................................................................................415
12.9 Installing Math Fonts for LT^X............................................................................415
12.10 Installing Math Fonts for A....................................................................................420
Appendix A Using dvips 425
Appendix B Visual Editing 433
Appendix C Typesetting XML 439
Appendix D Web Publishing 445
D.l LTeX2HTML .............................................................................................................445
D.2 t e x 4 h t..........................................................................................................................447
Appendix E N e w Features Introduced to Ω 1.23 451
Appendix F Solutions to All Exercises 455
Bibliography 469
Name Index 471
Subject Index 475
Fo r e w o r d
This book explores a great number of concepts, methods, technologies, and tools-in one word resources-that apply to various domains of typesetting. These resources have been developed and are used by the members of a very special community of people, which is also a community of very special people: the T^X community. To understand the motivation that led these special people to develop and use these resources, I believe it is necessary to make a short flashback. Since it is true that the past (uniquely?) determines the present and the future, I decided to divide this foreword into three parts: The Past, The Present, and The Future.
At this point, I am asking the readers to excuse my tendency of sometimes becoming autobiographic. This is very hard to avoid when talking about people and events important to one's life, and, after all, avoiding it could mean betraying the subject I would like to talk about.
The Past
Back in the 1980s, when I started working on my Ph.D. thesis, people in my department at the time (the Math Department, University of Lille, Northern France) were using a piece of software called "ChiWriter." This DOS program produced a very ugly low- resolution output of text and mathematical formulas. Others preferred to use IBM's Selectric II typewriter machines, spending hours and hours switching balls between Roman, Italic, and Symbol characters. Then came the day when the department finally bought a Macintosh Plus (with 1 MB of RAM and a 20 MB external hard drive!) and we installed Textures (a Macintosh implementation of TgX) on it. That day, my thesis advisor gave me a photocopy of the TfcXbook, which I spent the whole night reading.
The last appendix chapter of that book was called "Joining the TgX community" and talked about TUG (the T^X Users Group), TUGboat (the newsletter of TUG) and so on. But the reader must realize that at that time things were quite different from today: computers were of course unfriendly, expensive, and slow, but the main difference was that there was as yet no Internet. Without the Internet, distances were more real than today, and for people like me who had not yet traveled to the States, places such as
χ ν ι -φ F oreword
"Stanford" or "Princeton" were infinitely far away and seemed to exist only for the privileged few. This is probably hard to understand today, but at that time, imagining the "T^X community" for me was like seeing a Star Trek episode or an old Hollywood movie: it was about people knowing and communicating with each other and acting together, but in a totally different place, time, and context—there could de facto be no interaction between them and myself.
That was in 1986, and then came the day when, during a stay at the Freie Universitat Berlin, two things happened: I met and became friends with Klaus Thull (one of the European T^X veterans), and I opened my first TUGboat. By a coincidence so strong that one would be tempted to consider it as paranormal, the first TUGboat page I read was exactly page 22 of volume 9 (1), namely the one containing Silvio Levy's examples of Kazantzaki's text typeset in Silvio's Computer Modern Greek. Here is a translation of that text, reminiscent of the storm in Beethoven's sixth symphony:
"At this moment I understand how heavy the mystery of confession is. Until now no one knows how I spent my two years at Mount Athos. My friends think I went there to see Byzantine icons, or because of a secret longing to live a bygone era. And now, look, I feel embarrassed to speak.
How shall I put it? I remember a late afternoon in the spring, when a storm overtook me as I was coming down Mount Taygetos, near Pentavli. The whirlwind was so fierce I fell flat on the ground so I wouldn't be blown off the mountain. Lightning encircled me from everywhere and I closed my eyes to keep from being blinded and waited, face down, on the bare earth. The whole towering mountain shook and two fir trees next to me snapped in the middle and crashed to the ground. I felt the thunderbolt's brimstone in the air, and suddenly the deluge broke, the wind died down, and thick warm drops of rain struck the trees and soil. It pelted the thyme, oregano, and sage, and they shook off their odors and scented the whole earth."
Goethe (and Beethoven) wanted to communicate "von Herzen zu Herzen"; well, this is exactly what happened to me: altogether, the marvelous inebriating contents of this text which I had not read before, its appearance (which at that time I also found marvelous), and its context were quite a shock. That same day, I was able to communicate with Silvio (at that time still at Princeton) through e-mail. A few days later, Klaus and I had written our first joint TUGboat paper and submitted it to Barbara Beeton, again through e-mail. Suddenly, there were no frontiers anymore: the ΤβΧ community was quite real, and a new world opened in front of me. It is obvious that without traveling to Freie Universitat Berlin, without Klaus, without e-mail, without TUGboat, none of these would happen.
In the summer of 1990, just a month after I defended my Ph.D. thesis, Tereza (who later became my wife) and I went to the TgX Users Group meeting in Cork, Ireland, and we had the chance to meet there all those mythical people who made T^X-the pioneers of the TgX community-except Donald Knuth himself, whom I met two years later, in Stockholm, in the pure Bergmanian atmosphere of the late Roswitha Graham's house. The occasion was the ceremony where Donald Knuth was conferred
F o r e w o r d -φ- χ ν π
an honorary doctor's degree at the Kungl Tekniska Hogskolan. Roswitha cashed in on that opportunity and organized a small but very interesting Nordic TUG meeting.
In the late 1980s and early 1990s many wonderful things happened (to name only one: the fall of the Berlin wall while Klaus spent the whole night cycling from East to West Berlin and back). At the same time, using communication tools such as mailing lists and ftp, the Tp;X community was able to communicate more and more and became wider and more powerful.
But who were these people and where did they come from? The twenty-first century reader should realize that in the 1980s and early 1990s, when Linux was in the mind of its creator and GNU software was not widely known, public domain software did not have the same degree of popularity and reputation as it has today. Qn the other hand, computers and commercial software were horribly expensive. The psychology of computer users was different as well: there was a tremendous psychological gap between "users" and "programmers"; especially, Macintosh and Windows users would be shocked if they had to type something that even vaguely looked like programming code, and writing T^X was indeed "programming," even if learning ΤβΧ was far more pleasant than learning, for example, Fortran IV or 8086 Assembler-not to mention the frightening task of implementing TgX on different platforms, which was, at that time, sometimes still unavoidable for people who simply wanted to use T^X for their documents. In France, in the early 1980s, there were Ph.D.s written on the process of implementing ΤβΧ on specific platforms.
It is not surprising that most members of the T^X community were students or scientists from computer science, mathematics, or physics departments. Because they had a reason to use TgX (writing their reports and publications), and because they had the means to communicate with each other, many of them contributed to T^X by writing code, and surprisingly enough, the T^X code that they wrote was very often not connected to the subject of their studies and research. Some projects were linguis­
tic (extending T^X's capabilities to other languages and scripts), others typographical (facing the challenges of book typesetting), others artistic, ludic, or educational. In fact, what happened was, on a smaller scale, the same phenomenon as with Web pages some years later: students and scientists suddenly had the possibility to include their private life and hobbies in their work context and to share them with the community. The human dimension of ΤβΧ (and later of the Web) was flexible enough to allow input from various areas of human activities and interests. TUGboat was a wonderful mirror of that activity.
There were also the human needs of creativity and commitment: many TgX users wrote some code for their own needs, realized then that such code could be useful to others, extended it and wrapped it into a package with documentation and examples, and finally committed themselves to supporting it. By doing that, others became inter­
ested and communicated with them to express gratitude and suggestions for further development, which in turn resulted in reinforcing that commitment even more, and so on. Years before the widespread use of the Internet, the TgX community was already
χ ν ι π -φ- F oreword
what we now call a virtual community, providing a positive and creative identity to people.
That identity was—and still i s —one of the most charming aspects of T ^X.
The Present
In the years that followed, the emergence of the Web brought big changes to the TgX community and to the perception of TgX by computer users in general. Thanks to HTML, it is quite natural today for everybody to be able to read and write "code." On the other hand, Adobe's PDF file format has bridged the gap between TgX output and electronic documents (and there is indeed a version of TgX producing PDF output directly). DVI was defined as a "device independent" and "typographically correct" file format: it was abstract enough to be usable on any platform and at the same time precise enough to be able to describe a printed page without loss of information. This was, more or less, also the case for the PDF format, which has the enormous advantage of being self-contained in the sense that it contains all resources (images, fonts, etc.) necessary for displaying and printing the document.
Finally, thanks to Linux and GNU, public domain software is nowadays very well- reputed, and, quite naturally, TgX is still part of every public domain operating system. That is why it gained popularity among computer gurus who used it to prepare their documents with other tools.
For every new T^X user, the contact with the TgX community (which has been such a big deal for me) has become instantaneous, since nowadays almost everybody is connected to the Web. ΤβΧ code can be distributed to the whole community—and this includes people in places unimaginable ten years ago—in a few minutes or hours. Even better, collaborative development tools such as sourcef o r g e. n e t allow people to work simultaneously on an arbitrary number of different versions of the same software, however extensive and complicated this software may be.
The Web was very profitable for TgX for a number of reasons. Besides providing the T^X community with the means to be a true virtual community, it also made the principle of the dual nature of a document (source code versus compiled result) to become completely natural: when you write HTML code and preview it in your browser, you see two different representations of the same document. In other words, the "WYSIWYG" principle (which in the 1980s was quite an annoyance to ΤβΧ) has, at last, lost its supremacy.
Also, thanks to the Web and to political changes, there are no frontiers anymore,
and standards such as Unicode have emerged to allow communication in all languages. T]hX has always been a pioneer in multilingual typesetting, a feature that becomes more and more important today. As we will see in a while, a successor to T^X is one of the few (if not the only) software packages nowadays allowing true multilingual typesetting.
But are all things really well in the best of all possible worlds?
Talking of free software, let us return to one of the biggest achievements in the public domain, namely the Linux operating system, developed by hundreds of people
Fo rew o rd <>- χ ι χ
all around the world. The obvious question to ask is: can T^X be compared to Linux? Unfortunately not, for several reasons.
First of all, is the absence of a Linus Torvalds for T^X: in fact, the author of ΤβΧ, Donald Knuth, one of the biggest computer scientists of the twentieth century and indeed a fabulous person with interests far beyond computer science, unfortunately decided to stop working on ΤβΧ once a certain number of goals were achieved. This happened in 1992, when version 3 of TgX was released. New versions after that were just bug fix releases. There are some small groups of people working on specific TgX- related projects (such as the LT^X group, the Ω group, the Λf'f S group, etc.) and some institutions maintaining specific TgX packages (such as the A^[S). But outside of these, there is no coordination of the individual programming efforts.
Secondly, the goal to be reached in further developing TgX is not quite clear. ΤβΧ is a program dedicated to typography, a craft that very few people actually have studied, some people have learned by themselves^nainly by actually making books—and most people are generally unaware of. To continue our comparison with Linux, the latter is an operating system and hence deals with the global use of the computer: it is easy to imagine improvements, and if you lack imagination, you can always look into commercial operating systems to get ideas. ΤβΧ is the only piece of software dedicated to typography, and it does a very good job. Some people even believe that T^X is already perfect and hence there is no need for further improvement. But what is the ultimate goal of ΤβΧ, its raison d'etre?
For years now, pessimists have been predicting T^X's extinction, but T^X is still alive and kicking! Maybe the most important reason for that is that T^X bridges the gap between the cultural heritage of the precomputer era and us today. Typography is both a craft and an art 500 years old, and Donald Knuth actually learned it and encoded his knowledge to TgX so that ΤβΧ is a "typographer-in-your-machine." Using just standard T4Tp<, people unaware of typography can produce decent documents by including in their text some markup reminiscent of XML. With a little more effort, and using a little more than standard LT^X, people aware of typography can produce brilliant documents. This degree of proficiency at attaining the sublime is cruelly missing from contemporary commercial software where the goal is not really commitment to our cultural heritage. TgX is a craftsman's tool like in the good old days: using such a tool, a novice can produce decent results and a master can make works of art. And, as always with Donald Knuth, a work of art in the context of TgX is both beautiful typesetting and efficient programming.
This book presents some of the achievements of the ΤβΧ community in the last two decades. For reasons inherent to the T^X users community, the tools presented are of various degrees of quality, efficiency and compatibility. There are so many tools (or packages, in LTgX parlance) available from the Comprehensive TgX Archive Network that there are strong chances you will find a package for any of your potential needs.
χ χ -φ F oreword
But how efficient will that package be, or how compatible with other packages written by other authors? This is an important question because improvements or resolutions of conflicts require a good knowledge of Ι^ΤβΧ. Often, there is a high level of support by the author of the package. But what happens when the author is hard to reach, or even unknown? Others in the T^X community may help you, but, as always in the public domain, there is no guarantee that you will get the help you need precisely when you need it.
This situation may seem frightening to people who expect absolute efficiency and immediate compatibility from software they use. There is a working scheme that is better fit to TgX and I5TeX, namely that of small groups of people sharing the same computer resources and being assisted by a "system administrator" (or "guru"). The "guru" is supposed to know ΤβΧ and Ι^ΤβΧ sufficiently well and to have the necessary time and energy to solve problems for the rest of the group, which can then smoothly use the software. Unfortunately, this organizational scheme does not fit individual personal computer users, who have to be simultaneously users and administrators.
So, how does one deal with problems in L5TgX packages? Well, experience shows that if you are a convinced Ι^ΤβΧ/Τ^Χ user, then you always manage to get by the problems, either by searching in literature (and books such as this one are very important for that very reason) by diving into the code and trying to "make it work," or, finally, by contacting other members in the community, even if the developers of the package are unreachable. A combination of these three methods actually works best. What is important is to realize that you are extremely lucky to be able to do all three: you have valuable books (such as this one and others), you can indeed dive into the code since it is open and freely distributed, and you can indeed contact others since there is a virtual—and furthermore friendly and united—community. Commercial software does not offer these opportunities.
The reader may have noticed that this book often mentions Ω and A. Where do these mysterious names come from and how do they fit in the "T^X and friends" context?
Ω, one of the major current TgX projects, is an effort by two people (John Plaice and myself) to develop a successor to ΤβΧ. It started two years after Donald Knuth's decision to freeze TgX. The philosophy of Ω is to take TgX as a starting point and to progressively add techniques and tools allowing the resolution of specific typesetting problems one at a time. The first major goal was to achieve typesetting in all languages of the world in the most natural and efficient way. In particular, one of the tasks that Ω seeks to accomplish is Unicode compliance (as explained in the book, Unicode is a standard 21-bit encoding for information interchange).
But Ω has other goals as well and is in fact an open platform for enhancements and additions to TgX. The name Ω has been chosen because traditionally the last letter of the Greek alphabet stands for ultimacy, "the ultimate tool," and also probably because 50% of Ω'β development team is Greek. Finally, because choosing a Greek letter as the
Fo rew o rd <> χχι
invariable and nontranslatable name and logo of a program is an additional argument for using the Unicode encoding (just as the fact of lowering the letter Έ' in the TgX logo was a very clever way to show the absolute need of using T^X to typeset even its own name).
Contrarily to Ω, which is existing, and quite extensive software, A is just a nickname, a kind of parody of the T^TgX name: In fact, the "La" in Ι^ΤβΧ comes from "Lamport", as in Leslie Lamport, the author of pre-1992 T£T]hX. The word "Lambda" also starts with "La", but has no relationship whatsoever with "Lamport" and is a Greek letter just like "Omega." A stands (as explained in this book) for the current DT^X (an achievement of the LT^X team, headed by Frank Mittelbach) when used in conjunction with the Ω engine.
It is quite probable that future versions of I^TeX (for instance, version 3) will either be entirely written for Ω or at least have parts dedicated to Ω, in which case the Λ nickname will be useless. Also, due to the fact that the greatest part of Ω resources has not yet been released publicly, and that the Ω team still has to make a certain number of important global decisions, some information on Ω contained in this book may undergo minor changes in the future. In particular, there is (at the time this text is being written in March 2002) still no standard user-level I£TeX interface for Ω.
Nevertheless, the basics of Ω will not change, and this book has the merit of being the first one to describe some of the very fundamental aspects of Ω, such as Ω translation processes, Ω virtual property lists, and so on and to illustrate them by examples.
The Future
The "future of TgX" (including the question of whether there is a future for it at all) has been a popular discussion subject for years in the ΤβΧ community. In fact, TgX is the sum of a big variety of different things, and for each one of them one can more or less predict its destiny, but one can hardly do this for the sum of them.
For example, TgX is both a programming language and a program (a "compiler" for that language): one could imagine that the program survives (for example as a typesetting or "rendering" engine inside a bigger system, and rumors circulate that
this is already the case in Adobe InDesign); on the other hand, one could imagine Ω or some other successor to TgX becoming more and more different from TgX but^or reasons of upward compatibility—keeping the same programming language for input.
Besides being a programming language and a program, T^X is also a popular no­
tation for mathematical formulas: mathematicians worldwide use T^X notation when
writing formulas in, for example, e-mail messages: x~2 + y~2 < 1 with or without dollars is a natural choice for expressing the formula x 2 + y 2 < 1 in a text-only context. For writing mathematical formulas, ΤβΧ is exhaustive, clear, unambiguous, and short enough-all of the qualities of a good notation.
In recent years, the computer industry has become more and more involved in type­
setting engine projects: the context in which source code of some kind has to produce more or less rigid formatted output becomes more and more important. After the first
χ χ ι ι -φ F oreword
enthusiastic years of explosion of the Web, people realized that HTML (even combined with CCS) was definitely not sufficient for formatting documents. XML provided the necessary standard for structuring documents in an arbitrarily fine way, but still there was no "standard" way to represent an XML document. In October 2001, a new stan­
dard filled that gap: XSL-FO. The tools provided by XSL-FO for formatting documents are a quite serious challenge, and a new generation of XSL-FO-compliant typesetting engines is slowly emerging.
More generally, the current trend is to use XML as the basis of every kind of file format. For example, the SVG standard is, in some sense, an "XML-ized version of PostScript." One could very well imagine all file formats involved in ΤβΧ becoming XML-compliant: the input file could be pure XML "processing instructions" for in­
cluding code in the TgX language the DVI file format could be replaced by SVG, the font metrics could be expressed in XML, illustrations could be in SVG instead of EPS, and so on. In that case, ΤβΧ (or Ω, or some other successor to ΤβΧ) would simply transform one XML document into another one. The fact that XML document transfor­
mation is nowadays an increasingly popular and important concept is by no means a coincidence.
Another area where Ω can be applied to revolutionize the electronic document is that of adaptive documents. A research project in that area deals with vario-documents, namely documents that contain a big number of page descriptions and display the right one according to context parameters, just as HTML browsers reflow text when their display window is resized. Only here each page description of the document has been compiled in advance by a "super-Ω," always with the same high typesetting quality standards.
Yet another area of drastic improvement of Ω'β capabilities would be an on-the-fly interaction between typesetting and dynamic fonts. Already, in Vector TjiX (a commer- cial ΤβΧ for Windows platform), Dimitri Vulis has included METRFONT capabilities into TgX. By using more modern font formats, such as OpenType, one could obtain a dialog between the font and T^X's typesetting engine so that each one instructs the other on constraints and context parameters and so that the final result is optimal for both.
There is also the more global, operating system-oriented point of view: Ω could very well become a server, and arbitrary client applications could send requests with text extracts and macros or parameters and receive in return small parts of page descriptions.
All of these "mutation" scenarios could be compared with the common skeleton of many science-fiction stories, where humans mutate to become less and less organic. Usually sci-fi authors want to express the fact that despite and beyond the changes of the human body (including an artificial brain), a core of humanity will always emerge as a fundamental quality of mankind. This is exactly the case for ΤβΧ: I am convinced that however drastically TgX (and its successors) will change in the future, its fundamental quality, which is the love of one man—and not just any man! -^or good typography and good programming will always prevail and will always be the ultimate guarantee for the survival of this magnificent tool.
F o r e w o r d -φ- χ χ ι π
Ii this book succeeds in transmitting the fundamentally human quality of T^X and its successors, due to the love, sweat, and tears of Don Knuth and the hundreds of members of the active T^X community, then it will have reached its goal. I sincerely hope it does.
Yannis Haralambous Brest, France
March, 2002
P r e f a c e
What Is This Book About?
Our era is characterized as the "information era" mainly because computers (i.e., machines that manipulate information) are used in virtually all aspects of human life. One particularly interesting aspect of this phenomenon is that computers are used in areas where people traditionally thought that these machines had no use. One such area is fine arts (music, typography, painting, etc.).
Strictly speaking, typography is both an art and a craft. Typography is an art because it exists to honor content, and consequently, it can be deliberately misused. On the other hand, it is a craft, by which the meaning of a text (or its absence of meaning) can be clarified, honored, and shared, or knowingly disguised.
Many computer programs provide the means by which one is able to produce printed matter (books, leaflets, etc.). Most of them strive to provide a user-friendly interface that sometimes tries to guess the writer's intentions. However, it is a fact that all of these systems fail to produce the result that a traditional typographer would produce. There are many reasons for this serious drawback. For example, when the writer uses a friendly user interface, he or she is provided with a quite limited set of formatting tools that cannot handle all possible cases. This is quite evident when it comes to the typesetting of mathematical text, which is very demanding.
However, if one is provided with a programming notation specifically designed for typesetting purposes, then one loses the friendly user interface, but this is usually compensated by the output quality. In this book we make every possible effort to show that it is worthwhile to go to the trouble of learning such a programming notation. The programming notations we present are I^TpX (and its variant, pdfLM^X) and A. They are markup languages specifically designed to ease the creation of scientific and
nonscientific documents alike. Currently, the only evident difference between I5T^X and Λ is the fact that I^TpX operates on top of the TpX typesetting engine and Λ on top of the Π typesetting engine. Otherwise, there is no obvious difference between the two notations. Virtually any document produced with ΙίΤβΧ can be produced with Λ.
χχν ι <> P r e f a c e
Reading the Book Who Should Read It?
T^X in general and in particular are programming notations, and many newcomers wonder whether they can master the basics of the systems easily. Regarding LMgX, the answer is yes! I^TgX has been designed so that even uninitiated people can produce excellent documents with the least possible effort, and this is exactly one of the goals of this book: to teach the novice all that is necessary so that he or she can be able to create high quality documents quickly with the tools described in this book.
A
This book contains many text blocks that are marked with the symbol that marks this paragraph and are narrower than the usual text. These text blocks go into the details of the various typesetting tools and describe ways that allow users to customize them. Consequently, they should be read only by readers who have a good understanding of IATgX basics. Naturally, all novice readers will reach this level of understanding once they carefully study the rest of the text and try to do all the exercises (solutions to all exercises are provided at the end of the book).
So, this book is for novice as well as advanced IiT^X users. Therefore, the book is suitable for everyone who wants to learn to use the system and its variations. Although L?TeX and A are excellent typesetting tools for all sorts of documents, many people still think that they are the tools of choice only for mathematical typesetting. By presenting the multilingual capabilities and the other capabilities of these systems, we hope to make clear that these tools are just the best typesetting tools for all kinds of documents and all kinds of users!
The Book in Detail
Let us now describe the contents of each chapter.
The first chapter explains what I^TgX/A is in general. We discuss the advantages
of the logical document preparation versus the visual document preparation. Next, we provide information regarding the document preparation cycle and the various tools that are involved. The chapter concludes with general information regarding the programming notation.
In the second chapter we discuss various things that are essential for the preparation of even the simplest document. More specifically, we present the various characters that have a predefined meaning and the sectioning commands. We also discuss how one can prepare the title or the title page of a document. Next, we explain how one produces the various logos (e.g., how one can get the L?TeX logo). Then, we discuss the preparation of articles, letters, and proceedings articles. We conclude by presenting a tool that allows us to combine many different documents into a single one.
P r e f a c e -φ χ χ ν π
In the third chapter we discuss various issues related to fonts, such as font shapes, series, and families. We continue with the presentation of the various font selection commands as well as the various symbol access commands. Also, we present ways that one can get important symbols such as the € symbol, the letters of the phonetic alphabets, astronomical symbols, and more, and since accented letters are found in most languages, we conclude the chapter by presenting tools that facilitate the placement of accents over letters.
The fourth chapter presents tools that can be used to typeset lists and catalogs, as well as poems, quotations, and more. In addition, we give all of the details that are necessary for the customization of these tools.
In chapter five we describe how one can typeset mathematical content using I^TeX. We present the available symbols and the symbol access commands. In addition, we present the necessary tools that the creation of complete mathematical texts. The last two-thirds of this chapter are for those who will use this chapter for reference for demanding mathematical text, and it can safely be skipped on first reading. The chapter concludes with a presentation of how one can generate M a t h M L content from Λ sources. In addition, we discuss how it is possible to generate hypertext content from Λ sources.
Chapter six presents all of the core ΐ£ΓβΧ features that have not been described in the previous five chapters. Topics covered in this chapter include references and hyperreferences, commands that generate white space, floats, page styles, and layout, slide preparation, and the definition of new commands and environments.
The seventh chapter presents a number of very useful packages (i.e., "systems" that extend the functionality of Ι^ΤβΧ) and do not comfortably fit in any other place.
Chapter eight shows how we can prepare the bibliography and the index of a document. We also show how we can prepare multilingual bibliographies and how we can create a simple package that can assist us in the generation of glossaries.
In chapter nine, we present a number of tools that allow I^T^X users to create simple drawings. These tools include the picture environment, the PiCT^X package, and METRPOST. We also discuss ways to include images in Ι^Τ^Χ and pdfETEX files, and since color and graphics are two closely related issues, we also discuss how we can create colorful documents.
_______________
Not many years ago, the English language dominated scientific writing, and this was reflected in most books on ^Τ^Χ; these books assumed that their readers would typeset their documents in English. However, this situation has changed, and nowadays most people prefer to use their mother tongue in their writings. Naturally, all of these people need typesetting tools to prepare their documents in their native languages. The tenth chapter describes all of the currently available tools for typesetting documents in a variety of languages. The first part of the chapter is devoted to the description of the typesetting tools, while the second part presents the typesetting facilities that are available for around forty languages or groups of languages.
χ χ ν ι ι ι -φ P r e f a c e
To err is human, and this is the subject of the eleventh chapter, where we present common errors and error recovery strategies.
Chapter twelve is devoted to a description of the steps necessary for successfully installing new fonts (particularly scalable fonts) in an existing TgX installation.
The book concludes with five appendices that describe the generation of PostScript files from I^TfiX files, visual editing with x d v i and e m a c $ the typesetting of XML files with I^T]hX, the transformation of LT^X files to HTML files, and the new features that will be introduced to the the Ω typesetting engine.
The bibliography mentions only material published in some journal, periodical, or newsletter or as a book. Program manuals and "system" documentation usually accompany the corresponding software and in general are available from the CTAN (see page 12). There are two indexes: a name index and a subject index. In the subject index, a boldfaced page number denotes the page where the subject is discussed in detail (or defined). If for some subject there is no such page number, this means that the subject is considered well-known stuff.
The T^XLive CD-ROM that is included with this book offers a complete T^X system for Linux, Solaris 8 x86/SPARC, and Win32 platforms. This encompasses programs for typesetting and printing of Μ^Χ/Λ documents, all of the packages described in this book, plus many other useful packages and extensive font libraries. The CD-ROM includes a large amount of general documentation about T^X, as well as the documents that accompany specific software packages. In addition, the CD-ROM contains all the book examples plus a number of selected exercises in the directory omegabook. The CD-ROM was compiled by Sebastian Rahtz.
Typographic Conventions
For most programs we use their respective logos when we are referring to them in the text. In case there is no such logo, we use small caps to write the program name (e.g., d v i p s ). But the reader is warned to enter the program name with lowercase letters when attempting to use them. So, for example, the reader must type l a t e x and dvips in order to use LTgX and d v i p s.
Acknowledgments
In this book, we present formatting tools for very many languages, and naturally we do not speak most of them. So we had to ask for help from native speakers (or flu­
ent speakers, in the worst case) to verify the linguistic accuracy of the corresponding sections. We thank the following people for providing us with comments and sug­
gestions that substantially improved the corresponding language sections: Takanori
P r e f a c e -φ- χ χ ι χ
Uchiyama (Japanese language), Jazier Bezos (Spanish language), Jin-Hwan Cho (Ko­
rean language), Serguei Dachian (Armenian language), Oliver Corff (Mongolian lan­
guage), and Chakkapas Visavakul (Thai language).
We also would like to thank the following people for their help, suggestions, and constructive comments: Ichiro Matsuda, Norbert Preining, Koaunghi Un, Nguyen Due Kinh, Olaf Kummer, Denis Girou, Andrea Tomkins, Sivan Toledo, Georgios Tsapogas, Vassilis Metaftsis, Harald H. Soleng, and Sebastian Rahtz for his excellent work on the TgXLive CD-ROM.
Special thanks go to the Data Analysis Lab of the Department of Electrical Engi­
neering of the Democritus University of Thrace and to the Department of Mathematics of the University of the /Egaean for providing the necessary resources for the creation of this book. Also, the first author of this book wishes to thank Sotirios Kontogiannis, Osman Osmanoglou, Georgios Toptsidis, and Kostantinos Sotiriadis for many stimulat­
ing and thought-provoking late-night discussions! The third author wishes to thank the Educational Research Centre at Saint Patrick's College for enabling him to contribute to this project. We also thank the anonymous reviewers who helped us to substantially improve the text of the book; and John Plaice for sharing with us his vision for Ω. Last but not least, we thank Wayne Yuhasz, executive editor of Springer-Verlag N.Y.; his assistant, Wayne Wheeler; Frank Ganz, the Springer T^X evaluations manager for his help with some PostScript Type 1 fonts; Hal Henglein, the copyeditor; and Lesley Poliner the Spinger production editor.
The writing of a book is not an easy task at all, and of course this book is no exception. But in certain cases it is far easier if there is a starting point. For this book we used many ideas and the presentation style of [23]. The present book contains references to many web sites, but since it is a fact that web sites change web hosts rather frequently, we provide a web page with all the Web links of this book. The page also contains some other information regarding this book and it is located at h t t p: //oceanl. e e. duth. g r/ LaTeXBook/ and mirrored at http: //i r i s .math. aegean.gr/LaTeXBook/.
Apostolos Syropoulos Xanthi, Greece
Antonis Tsolomitis Samos, Greece
Nick Sofroniou Dublin, Ireland
I n t r o d u c t i o n
1 -----
Computer Science is a fast growing discipline that rapidly engulfs exciting new disci­
plines such as Digital Typography and Mathematical Typesetting. Indeed, today Digital Typography is an active research field of Computer Science. In this chapter we introduce the fundamental concepts related to digital typesetting with T^X. We briefly present all of the relevant ideas that are necessary for the rest of this book.
1.1 W h a t I s T E X?
The term "Digital Typography" refers to the preparation of printed matter by using only electronic computers and electronic printing devices, such as laser-jet printers. Since electronic printing devices are widely available, one often needs a digital typesetting system. ΤβΧ is a digital typesetting system designed by Donald E. Knuth. He designed TeX [19] mainly because, as he was struggling to finish the books of The Art of Computer Programming, he became disappointed with the computer technology available at the time.
According to its creator, the idea for TgX was actually bom on February 1,1977, when Knuth accidentally saw the output of a high-resolution typesetting machine [16] (this
article has been reprinted in [17]). He was told that this fine typography was produced by entirely digital methods (unfortunately, we are not aware of these methods), yet he could see no difference between the digital type and "real" type. At that moment he realized that the central aspect of printing had been reduced to bit manipulation. By February 13, he had changed his plan to spend the next year in South America; instead
of traveling to some exotic place and working on Volume 4 of The Art of Computer Programming, he decided to stay at Stanford and work on digital typography. It is interesting to note that the 4th Volume of The Art of Computer Programming has not been published yet. By August 14,1979, Knuth felt that T^X was essentially complete and fairly stable. In the meantime, he worked also on METRFONT [18], the companion program of TgX that he used to create the Computer Modem typefaces [15] that are now the standard font for T^X. Later on, he rewrote both T^X and METRFONT using
2 i I n t r o d u c t i o n
the literate programming methodology that he also developed [17]. The product of this work was a system that is now known as TgX82. Knuth further developed his systems, and both of them are now frozen, in the sense that no further improvements will be done by him apart from some bug fixes. Since Knuth wants people to help him to find all possible remaining errors in his programs, he is offering the amount $327.68 to anyone who finds a bug. For more information on this offer, we suggest you to read the first few lines of the files t e x. web1 and mf. web2 that contain the source code of both systems. The present version of ΤβΧ is 3.14159 and that of METRFONT is 2.718. Readers with a mathematical background will realize that the version numbers are identical to the first few digits of the numbers π (i.e., the circumference of a circle whose diameter is one) and e (i.e., the base of the natural logarithms). It is Knuth's wish to name the final version of TgX the version n and the final version of METRFONT version e by the day he dies. Although TgX and METRFONT are free software, they are trademarks of the American Mathematical Society (or ΑχψS for short) and of Addison-Wesley Publishing Company, respectively.
Since Tj?X and METRFONT are frozen, one is not allowed to extend these systems and call them T^X and METRFONT, respectively. However, Knuth has encouraged researchers to extend his systems and to produce new systems. So, we now have many systems that have evolved from the original work by Knuth. The most notable T|hX extensions are Ω, pdfTgX, ε-TgX, and N j'S (A'T' <S stands for New Typesetting System). Ω is a Unicode version of TgX that provides all of the necessary tools for real multilingual typesetting and has been developed by Yannis Haralambous and John Plaice. The program pd fTgX [26], a version of ΤβΧ capable of directly producing PDF
f
output, originally developed by Han The Thanh, is currently being further developed by its original developer, Hans Hagen and Sebastian Rahtz. ε-Τ^Χ [25], a T^X extension that can handle languages written from left to right and languages written from right to left, has been developed by the team that now develops Afq~S, a ΤβΧ extension currently written in Java that will one day replace ΤβΧ (at least that is what the designers hope) and is being developed by Karel Skoupy with assistance by Phil Taylor. Qn the other hand, METRPOST by John Hobby is a reimplementation of METRFONT that produces PostScript output instead of bitmaps, which METRFONT produces.
TgX is a typesetting language (i.e., a programming language specifically designed to ease the generation of beautiful documents). The language has a wide range of commands that allow users to take into account every possible detail of the generated document. However, even expert computer programmers would have a really hard time if they were to produce even a simple document without additional help. Since TpX is a programming language, it offers the ability to define macros (i.e., to define new keywords that will have the combined effect of primitive commands when used). Moreover, T^X is designed in such a way that one can create a collection of macros designed to facilitate the document preparation process. Such macro collections are
1. Available from ftp: //
ftp.dante
.de/pub/tex/systems/knuth/tex.
2. Available from ftp: //
ftp.dante
.de/pub/tex/systems/knuth/mf._______________________________
i.2 L o g i c a l v e r s u s V i s u a l D e s i g n -Φ- 3
known as formats. Knuth himself has designed the plain format, which was quite popular for some time.
Although the plain format is quite useful, there are many things that the casual user has to master in order to write even simple documents. This remark and the fact that the casual user wants to write a letter, a simple article or report, or even a simple book led Leslie Lamport to create the LT^X format. I^TgX allows its user to write very quickly a letter, an article, a report, or even a book. Moreover, when compared to usual word-processing systems, L'TgX has many other advantages, which are the subject of the next section. The present version of LT^X is called LTeX 2g and it is the one that we will present in this book. LT^X 2ε has been developed by a team lead by Frank Mittelbach. When one uses Ω, LTjnX becomes Λ (pronounced lambda), while when one uses pdfTgX it becomes pdfLTEX. Unlike ΤβΧ, L'TgX is not frozen and is the subject of continuous development. The next version of W]hX will be called 1?T]hX3 and will be a substantial improvement of the current version. The main advantages over its predecessor include the unified approach to multilingual typesetting, the simplification of the font access process, and more. For more information regarding the LT^X3 project, the interested reader should consult the LTjiX project Web page at h t t p: //www. l a t ex-pro j e c t. org.
The reader may wonder why the name of the TgX system is written in this way and, moreover, how one should pronounce the name of the system. First of all the system's name is written this way to avoid confusion with TEX, an editor that was very popular by the time ΤβΧ was developed. Second, the letters that make up the TgX logo are the first three letters of the common root of the Greek words τέχνη (art, craft) and τεχνολογία (technology). Consequently, TgX should be pronounced "tekh," where the "kh" is pronounced as in the name Mikhail, and Ι^ΤβΧ might be pronounced "latekh." The letter ε in the Ι^Τ^Χ 2g logo comes from the word έκδοση (edition), so the logo actually means Ι^ΤβΧ second edition. The "La" part in the Ι^ΤβΧ logo comes from the last name of its creator: La(mport)TE>(.
1.2 Logical versus Visual Design
Contrary to common belief, the preparation of a good document is a difficult task. By using an ordinary document preparation system, one is forced to make important decisions about the layout and the structure of the document. Thus, one has to decide on the page format and its general appearance and, at the same time, the text must be organized so that readers will not have any difficulty understanding it. Most common
systems force their users to work on both aspects of the docu- ment preparation process. Certainly, this is not a severe restriction when it comes to the preparation of a nondemanding text. But, if someone has to prepare either a long document or a really demanding document, then this document preparation process may become a nightmare! Hence, it is extremely important for a document prepara­
tion system to assist its users in at least the visual design of their documents. In this
4 ^ 1 In t r o d u c t i o n
way, the writer will concentrate on the logical design of the document and will let the document preparation system do the visual design. The advantage of this approach is that the visual design reflects the logical structure of the document. Systems that have this property are called markup languages. LTgX is a system that pays more attention to the logical design than to the visual design, so it is a markup language. We will now give a simple example by which we hope things will become clearer.
Suppose that Michael wants to write an article about mathematics that will contain formulas and proofs based on these formulas. It is common practice in mathematical text to put a unique number at the end of each equation and to refer to it by this number. If Michael uses an ordinary document preparation system, then he has to manually enter the number for each equation since these systems treat equation numbers as an ordinary piece of text and nothing more. On the other hand, LJTfiX assigns to each equation a number by incrementing the value of a counter (i.e., a computer storage location). Moreover, it provides a facility by which one can easily refer to any number that has been assigned to an equation, a page, and so forth. So, if Michael has the following equation in his article
ein + 1 = 0 (1.1)
and for some reason he decides to insert another equation before it, LT^X will auto­
matically renumber all equations and, more importantly, it will produce the correct references in his text. Of course, if he had opted to use an ordinary document prepara­
tion system, he would have to manually change all references, something that is really error-prone. But things can get even worse. Suppose that Michael submits his article for publication to some journal and they accept it but want him to number equations with Latin numerals. Then he would have to manually change everything, and it is obvious what that means. But if he had opted to use LT^X, he could have made the change by adding just a couple of lines of code.
By emphasizing the logical design of the document preparation process, I^TeX makes its users more productive and, consequently, allows them to concentrate on their real work (i.e., the writing of their text). Moreover, since T^X, as well as all typesetting engines based on TgX, is free software and available for virtually any computing system, ϊ£ΓεΧ gives its users the rare chance to be able to switch between computing systems without any problem.
Readers who want to learn more on the subject of this section should consult the
Web page h t t p: //r i c a r d o. ec n. wf u. e d u/“ c o t t r e l l/w p. html. This Web page is main­
tained by Allin Cottrell.
1.3 Preparing a Document with MgX
The preparation of a document with I^TeX is usually done in two steps. The first involves the use of a text editor by which the user types a manuscript. This usually disappoints newcomers, who are accustomed to the so-called WYSIWYG (What You See Is What
1.3 P r e p a r i n g a D o c u m e n t w i t h -Φ- 5
Y o u G e t ) d o c u m e n t p r e p a r a t i o n s y s t e m s ( i.e., s y s t e m s w h e r e t h e u s e r d i r e c t l y t y p e s t h e t e x t i n t o a s o - c a l l e d g r a p h i c a l u s e r i n t e r f a c e, o r G U I f o r s h o r t ). B u t, a s w e h a v e a l r e a d y e x p l a i n e d, t h i s h a s t h e b i g d r a w b a c k t h a t i t d o e s n o t a l l o w t h e u s e r s t o e a s i l y d o w h a t t h e y r e a l l y w a n t t o d o. H o w e v e r, l e t u s c o n t i n u e w i t h t h e d e s c r i p t i o n o f t h e d o c u m e n t p r e p a r a t i o n p r o c e s s w i t h ETeX. Since ETgX is a markup language, one has to type not only text but also commands, or "tags," that will assist I^TgX in the formatting process. It is important to note that our text must be saved in a plain text file; in other words, the resulting file must contain only the characters that we have typed and nothing more. Thus, users can use even a fancy word processing system to type their text and not just a simple text editor, perhaps because they want to use its spell-checking capabilities, but they must always remember to save their text in a plain text file. Once we have created a text file that contains the ΕΤβΧ source of our document, we are ready to feed it to the ΤβΧ typesetting engine with the I^T]hX format preloaded. If there are no errors in our input file, then ΤβΧ will generate a DVI (DeVice Independent) file, which will contain all of the information that is necessary to either print or view, on our computer screen, the resulting formatted document. However, since this file does not contain the fonts necessary to print or view the document, one has to use a driver program. This program will automatically use the font information contained in the DVI file to correctly produce the formatted output. The viewing program is not standard and depends on the particular ΤβΧ installation. For example, on Unix, people usually view DVI files with a program called x d v i, originally developed by Eric Cooper and modified for X by Bob Scheifler, for XI1 by Mark Eichin, and currently being maintained by Paul Vojta. On the other hand, many TgX installations provide their users with a printing program, but it is common practice to transform the DVI file into PostScript, by using the program d v i p s by Tomas Rokicki, and to print it either on a PostScript printer or on any printer using a PostScript driver such as Ghostscript by L. Peter Deutsch. The following diagram presents the basic document preparation cycle with IATjhX:
The diagram above omits various aspects of the document preparation cycle. For exam­
ple, it does not present the bibliography generation as well as the index and glossary generation. Moreover, it does not present the generation of the various font-associated files. TgX uses the so-called TgX Metric Files (or TFM for short), files that contain the dimensions of each glyph as well as kerning and ligature information for a font, in order to correctly typeset a TgX source file. On the other hand, when one wants to view or print a file, the driver must either generate the so-called packed bitmap files (or PK for short), which contain resolution-dependent bitmaps of each glyph, or include the font outlines. (There will be more on fonts in the relevant chapters.)
6 -φ- ί I n t r o d u c t i o n
In the case where the typesetting engine is pdfETEX, the output file can be either a DVI or a PDF file. If it is a PDF file, this means that we can print or view it directly with Acrobat Reader by Adobe, Inc. Moreover, one can also use Ghostscript since this program can handle PDF files as well. But, now it is time to pass from theory into practice.
On most computing systems, a filename consists of two parts ^the main filename and the filename extension. Usually, these two parts are separated by a period (for ex­
ample, t e x t. doc or t e x t. txt). When one creates a text file that contains L?TeX markup, it is customary to have tex as the filename extension. This way, the user does not have to type the complete filename when the file is fed to TeX. N o w, we are ready to create our first ETeX file.
Using your favorite text editor, create a text file that will contain the following four lines:
\documentc l a s s { a r t i c l e }
\begin{document}- Hello from \LaTeXe!
\end{document}
For the moment, you should not pay any attention to what you have typed. Now, suppose that the resulting text file is called example. tex. If we enter the following command at the prompt (e.g., an MS-DOS prompt of Microsoft Windows or a Unix xterm), ETeX will process our file and it will generate, among others, a DVI file:
$ l a t e x example
This i s TeX, Version 3.14159 (Web2C 7.3.1 )
(example.t e x LaTeX2e <2000/06/01>
Babel <v3.6k> and hyphenation p a t t e r n s f o r american, e n g l i s h, greek, loaded.
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s Document Cl ass: a r t i c l e 2000/05/19 v l.4 b Standard LaTeX document c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e 1 0.c l o ) )
(example.aux)
[1] (example.aux) )
Output w r i t t e n on example.dvi (1 page, 368 b y t e s ).
T r a n s c r i p t w r i t t e n on example.log.
Note that the $ sign indicates the system prompt; for example, in MicroSoft Windows this might be C: \. So what follows this sign, on the same line, is what the user enters. Moreover, the program output has been slightly modified so that it can fit the page, and this applies to all of the program output that follows. In the program output above, we can easily identify the versions of both TeX and ETeX that we are using. Furthermore, the system lets us know that it has created three files with main filename example and
1.3 P r e p a r i n g a D o c u m e n t w i t h -Φ- 7
f i l e n a m e e x t e n s i o n s a u x, d v i, a n d l o g. T h e a u x f i l e c o n t a i n s a u x i l i a r y i n f o r m a t i o n t h a t c a n b e u s e d f o r t h e c r e a t i o n o f t h e t a b l e o f c o n t e n t s, a m o n g o t h e r t h i n g s. T h e d v i f i l e i s t h e D V I f i l e t h a t T g X h a s j u s t g e n e r a t e d, a n d t h e l o g f i l e c o n t a i n s l o g i n f o r m a t i o n t h a t i s u s e f u l f o r d e b u g g i n g p u r p o s e s i n c a s e t h e r e i s a n e r r o r i n o u r ETeX source file. TgX indicates its progress by printing a left square bracket and the number of the page that it will start to process. When the page is shipped out to the DVI file, it prints a right square bracket. The total number of pages successfully processed as well as the total size of the DVI file appear at the end.
Since we have managed to successfully generate the DVI file, it is now possible to create a PostScript file from it by using the d v i p s driver:
$ dvips example
This i s dvips(k) 5.86 Copyright 1999 Radical Eye Software (
www.r a d i c a l e y e.com
)
’ TeX output 2000.10.08:0100’ -> example.ps <texc.pro>. [ 1]
In cases where the d v i p s driver cannot find the necessary PK files, it will try to generate them:
$ dvips example
This i s dvips(k) 5.86 Copyright 1999 Radical Eye Software (
www.r a d i c a l e y e.com
)
’ TeX output 2000.10.10:1241’ -> example.ps kpathsea: Running mktexpk —mfmode l j f o u r —bdpi 600 —mag 1+0/600 —dpi 600 cmrlO
mktexpk: Running mf \mode:= l j f o u r; mag:=1+0/600; nonstopmode; i nput cmrlO
This i s METAFONT, Version 2.7182 (Web2C 7.3.1 )
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/c m r l O.m f (/u s r/l o c a l/te T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/c m b a s e.m f ) (/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/r o m a n.m f (/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/r o m a n u.m f [65] [66] [67] [68] [69] [70] [71] [72] [73] [74] [75] [76] [77] [78]
[79] [80] [81] [82] [83] [84] [85] [86] [87] [88] [89] [90])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/r o m a n l.m f [97] [98] [99] [100] [101] [102] [103] [104] [105] [106] [107] [108] [109]
[110] [111] [112] [113] [114] [115] [116] [117] [118] [119] [120]
[121] [122])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/g r e e k u.m f [ 0 ]
[1] [2])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/r o m a n d.m f [ 4 8 ] [ 4 9 ] [ 5 0 ] [ 5 1 ] [ 5 2 ] [ 5 3 ] [ 5 4 ] [ 5 5 ] [ 5 6 ] [ 5 7 ] )
8 -φ- ί I n t r o d u c t i o n
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/fo n t s/s o u r c e/p u b l i c/c m/r o m a n p.m f [36] [38] [63] [62])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/r o m s p l.m f [16] [17] [25] [26] [27] [28])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/r o m s p u.m f [29] [30] [31])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/p u n c t.m f
[33] [60] [35] [37] [39] [40] [41] [42] [43] [44] [46] [47] [58] [59]
[61] [64] [91] [93] [96])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/a c c e n t.m f [18] [19] [20] [21] [22] [23] [24] [32] [94] [95] [125] [126] [127])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/r o m l i g.m f [11] [12] [13] [14] [15])
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/f o n t s/s o u r c e/p u b l i c/c m/c o m l i g.m f
[34] [45] [92] [123] [124]) ) )
Font m e t r ic s w r i t t e n on cmrlO.tfm.
Output w r i t t e n on cmrl0.600gf (128 c h a r a c t e r s, 24244 b y t e s ), mktexpk: /v a r/t m p/t e x f o n t s/p k/l j f o u r/p u b l i c/c m/c m r l O.600pk: s u c c e s s f u l l y gen erat ed.
<texc.pro>. [ 1]
As we see from the program screen output, d v i p s could not find the PK at the re­
quested resolution for the font cmrlO. So, d v i p s calls METflFONT to generate the missing font. Once the PK file is successfully generated, d v i p s resumes and generates the final PostScript file. In case we want to generate a resolution-independent PostScript file, we have to configure the file psf ont s. map so that the d v i p s will embed the outline font files into the final PostScript file (details will be discussed later);
$ dvips example
This i s dvi ps(k) 5.86 Copyright 1999 Radical Eye Software (
www.r a d i c a l e y e.com
)
’ TeX output 2000.10.10:1241’ -> example.ps
<texc .p r o X t exps . p r o>. <cmmilO. pfb><cmr7 .pf b X cmrlO. pf b> [1]
The PFB file is a binary PostScript outline font file. The corresponding nonbinary or
ASCII files are called PFA files. Sometimes, the driver fails to embed the outline font files, although it has been configured to do so and the files are part of our T^X installation. In this case, the - j 0 switch for d v i p s usually resolves the problem. If we want to view a DVI file that uses PostScript fonts, then x d v i calls g s f t o p k by Paul Vojta to generate PK files from the font outlines since x d v i can handle only PK files. Note that the latest versions of x d v i are capable of rendering PostScript fonts directly without using
GSFTOPK.
1.3 P r e p a r i n g a D o c u m e n t w i t h -Φ- 9
I i w e h a d o p t e d t o u s e 6- T £ TeX, t h e r e s u l t i n g D V I f i l e w o u l d h a v e b e e n i d e n t i c a l t o t h e o n e p r o d u c e d b y I^T^X since ε-ΤβΧ operates identically to TgX if we do not use its extended capabilities:
$ e l a t e x example.tex
This i s e-TeX, Version 3.14159-2.1 (Web2C 7.3.1 )
(example.tex LaTeX2e <2000/06/01>
Babel <v3.6k> and hyphenation p a t t e r n s f o r american, e n g l i s h, greek, loaded.
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s Document Class: a r t i c l e 2000/05/19 v l.4 b Standard LaTeX document c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e l O.c l o ) )
No f i l e example.aux.
[1] (example.aux) )
Output w r i t t e n on example.dvi (1 page, 368 b y t e s ).
T r a n s c r i p t w r i t t e n on example.log.
If we had opted to use pd ίΙ^ΤβΧ, the output would be a PDF file:
$ p d f l a t e x example
This i s pdfTeX, Version 3.14159-13d (Web2C 7.3.1 )
(example.t e x
[/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/p d f t e x/b a s e/p d f t e x.c f g ]
LaTeX2e <2000/06/01>
Babel <v3.6k> and hyphenation p a t t e r n s f o r american, e n g l i s h, greek, loaded.
Configured f o r p d f t e x use [1997/11/26]
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s Document Class: a r t i c l e 2000/05/19 v l.4 a Standard LaTeX document c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e l O.c l o ) )
(example.aux)
[ 1 [/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/p d f t e x/b a s e/s t a n d a r d.m a p ] ]
(example . aux) ) CcmmilO .pfb><cmr7 .pfbXcmrlO .pfb>
Output w r i t t e n on example.pdf (1 page, 15680 b y t e s ).
T r a n s c r i p t w r i t t e n on example.log.
Since pd ίΙ^ΤβΧ embeds the necessary fonts into the resulting PDF file, the screen output lets us know which fonts pd fl^T^X has embedded into the PDF file. Of course, it is possible to create PDF files from PostScript files directly by using the program p s 2 p d f. This program is actually an application of Ghostscript and can only be used on a command line.
ίο ·φ· ί I n t r o d u c t i o n
In the case where we are using A, the source file can be a Unicode file and not just an extended ASCII file. In any extended ASCII file, we are allowed to type up to 256 different characters, while in a Unicode file we are allowed to type up to 65,536 different characters. So, we can directly type text in any possible language. We will elaborate on this subject in Chapter 10, which presents the multilingual capabilities of l^T^X/A. Let us see now what the screen output will be when we use A:
$ lambda example
This i s Omega, Version 3.14159—1.8 (Web2C 7.3.1 )
Copyright (c) 1994—1999 John P l a i c e and Yannis Haralambous (example.t e x LaTeX2e <2000/06/01>
Hyphenation p a t t e r n s f o r american, e n g l i s h, greek, loaded. (/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s Document Cl ass: a r t i c l e 2000/05/19 v l.4 b Standard LaTeX document c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e 10.c l o ) )
(example.aux)
[1] (example.aux) )
Output w r i t t e n on example.dvi (1 page, 392 b y t e s ).
T r a n s c r i p t w r i t t e n on example.log.
Although the output file is called example. dvi, it is not a DVI file but rather an QDVI file. This new file format is actually an extended DVI file in which Ω can store infor­
mation regarding Unicode fonts, writing directions, and so on. Because of this fact, one needs special drivers to handle the resulting HDVI files. To generate a PostScript file, one has to use the o d v i p s driver:
$ odvips example
This i s (Omega) odvips(k) 5.86 Copyright 1999 Radical Eye Software (
www.r a d i c a l e y e.com
)
JOmega o u t p u t, Version 3.14159—1.8, 2000.10.08:1227’ -> example.ps <texc.pro>. [ 1]
On the other hand, if we want to view an HDVI file we have to use the o x d v i driver.
1.4 How Does T^X Typeset?
A typesetting system has to perform many operations in order to yield excellent output. One of its chief duties is to take a long sequence of words and break it up into individual lines of the appropriate size. In order to do this successfully, the system has to find the best breakpoints. TgX initially takes a paragraph and tries to find these breakpoints without employing the hyphenation mechanism that is available. If this is not possible,
1.5 M ore In f o r m a t i o n a n d Re s o u r c e s -Φ- 1 1
then it hyphenates all words according to the hyphenation patterns that are built into a particular format file and then tries to find the breakpoints, which of course in some cases will be in the middle of a word. Of course, we can instruct TgX to avoid breaking a line at specific points. In certain situations, T]hX fails to produce a line of the appropriate size. If the line is longer than this size, we have an overfull box. On the other hand, if the line is shorter, we have an underfull box.
Things are even more difficult for page breaks. TgX usually guesses what would be the ideal breakpoint. This is mainly related to the fact that when TgX was designed, computer memory was an expensive resource and of very limited size. Most certainly, new typesetting systems could deal with this drawback, but since TgX decides page breakpoints in a very reasonable way, there has not been any significant progress on the matter.
Another interesting aspect of TgX's functionality is that it treats each character as a little box that can be virtually placed everywhere on the page (see page 39). This way, one can achieve interesting results such as the following alternative dollar symbol $, which is not usually available in most widely available fonts.
1.5 More Information and Resources
T]hX is a typesetting system that has attracted the attention of many people. Moreover, since it is an extremely flexible system, many people work on the creation of TgX ex­
t
ensions and the development of new macros or formats that aim at facilitating the document preparation process. This fact had led a group of people to create the TgX Users Group (TUG for short), a nonprofit organization dedicated to the promotion and further development of T^X and its descendants. TUG publishes the quarterly newsletter TUGboat, which features refereed articles on various aspects of digital ty­
pography with T]hX. More information on TUG can be found at their Internet site: h t t p: //www. t u g. org. Since ΤβΧ is also heavily used by non-English-speaking people, there are many LUGs (i.e., local TgX users groups) that are dedicated to the promotion of digital typography with TgX in their respective countries and the development of tools that facilitate the preparation of documents in their respective languages. More
information on these groups can be found at h t t p: //www. t u g. o r g/l u g s. html. Most of these groups publish newsletters similar to TUGboat; for example the Greek TgX Friends publish the semi-annual newsletter Εντυπον, NTG, the Dutch group, pub­
lishes the semiannual newsletters MAPS, and GUST, the Polish group, publishes a
of your local
TeX users group and/or of TUG.
Apart from these resources, one can download T^X installations for virtually
any computing system, TpX packages, and fonts from either f t p://f t p.d a n t e.d e/
t e x - a r c h i v e (maintained by DANTE, the German group), f t p://f t p.t e x.a c.u k/
t e x - a r c h i v e (maintained by UKTUG, the UK group), or f t p://c t a n.t u g.o r g/
12 ·& i I n t r o d u c t i o n
tex-archive (maintained by TUG). These three sites constitute what is commonly known as the "Comprehensive TgX Archive Network," or CTAN, for short. Moreover, most T^X groups have mailing lists where people can ask questions regarding any­
thing related to TgX. The Usenet newsgroup comp, t e x t .t e x is the official ΤβΧ forum for advanced and novice users. However, before sending any question to this group, you are strongly advised to consult the ΤβΧ Frequently Asked Questions Web page at h t t p: //www. t e x. a c. u k/c g i - b i n/t e x f aq2html. Finally, we suggest that you might like to have a look at the I^T^X Navigator site at h t t p: //t e x. l o r i a. f r/t e x.
2 ------------
T h e Fi l e St r u c t u r e
In this chapter, we describe the general structure of a Ι5ΓεΧ/Λ file. Since a Ι^Τ^Χ/Α file is composed of characters, we elaborate on the characters that one is allowed to type into a valid file and present some special characters with a predefined meaning. Next, we present the concept of a document class, the standard IiT^X classes, and the classes provided by the American Mathematical Society. Furthermore, we discuss how one can create the title of a document and a title page. Next, we present how one can get some of the standard logos that are frequently used in the T^X world. We continue by presenting a real-world I^T^X file and conclude with the presentation of a package that allows the combination of several I^TgX files into a single document.
2.1 The Characters We Type
A user communicates with a computer by either typing in letters, digits, or symbols or by using some pointing device (e.g., a mouse). In the first case, these letters, digits, and symbols are collectively called characters. Each character is internally encoded as a sequence of binary digits (i.e., the digits "0" and "1") of a fixed length. This means that each character is equal to some number and, consequently, one can compare characters. Early computing systems provided only uppercase English letters, digits, a few sym­
bols, and some special characters, such as the newline character, the end of file character, and so on. This limitation was imposed mainly because computers at that time had lim­
ited memory. Soon, people realized that they could not type in an ordinary English text with this limited character set, so, as computer technology advanced, computer manu­
facturers proposed new, larger character sets. The ASCTI (American Standard Code for Information Interchange) character set was the one adopted by most computer manu­
facturers. ASCII contains 128 characters and includes all English letters in both cases, the ten digits, all symbols that are on a common keyboard, and 32 control characters. However, as computers became available to non-English-speaking people, there was a need to provide extended character sets so that non-English-speaking people could
1 4 ^ 2 T h e F i l e S t r u c t u r e
type in texts in their own languages. This fact led the various national standards or­
ganizations to define extensions of ASCII that contained at most 256 characters. These extended ASCII character sets were approved by the International Standards Organi­
zation, and now each of them has a unique name. For example, ISO-8859-7 is the name of the extended ASCII used in Greece. Similarly, ISO-8859-9 is the one used in Turkey, ISO-8859-1 the one used in Western Europe, and ISO-8859-5 is the default character set in countries that use the Cyrillic alphabet. Although people can write texts in their own language, it is still difficult to exchange files containing characters belonging to some extended ASCII. The main reason is that characters above 127 (i.e., the numbers that represent these characters are greater than 127) are not the same in two different extended ASCIIs, so it was necessary to define a new character set that would contain all possible letters, symbols, ideograms, and so on, in order to allow data exchanges without any problem. This necessity led to the definition of the Unicode character set. Unicode does contain all of the necessary characters to correctly type in a text in any lan­
guage currently in use but also many mathematical symbols, characters not presently in use, such as the accented vowels of polytonic Greek, and many symbols that are in common use such as the symbol ®. Of course, one is also allowed to have characters from different languages in the same file (e.g., it is possible to have Japanese, Greek and Arabic text in the same file). Unicode provides for two encoding forms: a default 16-bit form called UCS-2 and a byte-oriented form called UTF-8. The Unicode standard ver­
sion 3.1 is code-for-code identical with International Standard ISO/IEC10646. If we use the 16-bit form, we can encode more than 65000 characters, while if we use the UTF-16 extension mechanism, we can encode as many as 1 million additional characters. The reader interested in learning more about Unicode may consult the relevant Web page at h t t p://www.Unicode.org
.
TgX is a typesetting engine that can handle only files that contain characters be- longing to some extended ASCII character set. For this reason, it is not particularly well-suited for multilingual document preparation, especially when it comes to lan­
guages that do not use the Latin alphabet. On the other hand, Ω is a typesetting engine that can handle Unicode files, so it is particularly well-suited for multilingual document preparation.
Although a LTgX
file can contain ASCII characters and a A file can contain Unicode
characters, there are a few characters that cannot be typed in directly as they have a predefined meaning. These characters are the following ones:
#$%&"_ ~ \ { >
Let us now explain the special meaning of each of these characters. The character # (called sharp) is used to name the parameters of a parametric macro. However, this mechanism is primarily used in plain TgX and by people who create new formats and packages. The character $ (called dollar) is used to designate that one wants to write mathematical formulas. The same symbol is used to designate the end of mathematical text. The character % (called percent) is used to write comments (i.e., a sequence of characters that is completely ignored by Ι^ΤβΚ). When we place the % character in a line,
2.1 T he C h a r a ct e r s W e T y pe -φ 1 5
ΐ^ΤβΧ ignores this character and everything to the right up to the end of the current line. Moreover, in certain cases, it prevents the typesetting engine from putting in some unwanted white space. The character & (called ampersand) is used in the construction of tables. The character ~ (called tilde) usually stands for an unbreakable space; that is, if we put it between two character sequences without any space before or after it (e.g., Figure" 1) ΤβΧ will not attempt to put these two sequences on different lines or pages. However, in certain cases, it does not act like an unbreakable space. Such a case occurs when one prepares a manuscript in polytonic Greek. The characters _ (called underscore) and ~ (called circumflex) are used to enter subscripts and superscripts in mathematical formulas, respectively. The characters { (called left brace) and > (called right brace) are used to define what is called in Computer Science a local scope (i.e., a place where all changes are local and do not affect the rest of the code). Readers familiar with C, Java, or Perl programming will identify this mechanism with the block structure provided by these languages. The character \ (called backslash) is the escape character (i.e., a character that makes special characters nonspecial and vice versa). For example, when it is in front of a word, the word is treated as a command. Certainly, there are some things that may not be clear at the moment, but they will become clear as we proceed. Now, since these characters are special and one is not allowed to type them in directly, the question is: "How can we type in these characters in a I^TgX file"? The answer is given by the following table:
Symbol
Command
Symbol
Command
#
%
Λ
\#
\%
\t e x t a s c i i c i r c u m
\t e x t a s c i i t i l d e
$
&
\
\$
\&
\_
\t e x t b a c k s l a s h
{
U
}
\>
Thus, in order to get 40% off, we have to type in the characters 40\% off.
>· Exercise 2.1 What are the characters that one has to type in to get the following sentence:
You have a 30% discount and so the price is $13.
□
In any ordinary text, one has to be able to write paragraphs. In l^T^X, paragraphs are really easy: we just put a blank line between the two paragraphs. In other words, at the end of a paragraph, we simply press the enter key two times.
>- Exercise 2.2 Now that you know how to create paragraphs, create a complete 15ΓεΧ file that will typeset the following text:
The characters { and } are special. They are used to create a local scope.
ι 6 ·φ· 2 T he F ile S t ruc ture
Comments are introduced with the character % and extend to the end of the line.
□
On rare occasions where one cannot type in a blank line, an alternative solution is to type in the command \par.
>- Exercise 2.3 Redo the previous exercise using \par. □
The discussion that follows may be skipped on first reading.
From the discussion above one may conclude that the characters above are like the reserved words of usual programming languages; that is, symbols or keywords that have a predefined meaning that cannot be changed in any way. Fortunately, this is not the case. TgX assigns to each character a category code (i.e., a number that characterizes its functionality) but this is something that can be changed either locally or globally. T^X provides the primitive command \c a t code that allows its users to change the category code of any character. If we want to change the category code of, say, the character %, then we have to enter the command
\c a t c o d e f\%=n
where n is a number from 1 to 15 representing a particular category code. Note that the construct ‘ \% is one of the ways to refer to a particular character. Alternatively, we can use its code point expressed in decimal, hexadecimal (prefixed by "), or octal (prefixed by ’). It is even possible to refer to a particular character with the construct {~ ~hh (or < ~hhhh if we are using Ω), where hh (or hhhh) is the character's code point
expressed in (lowercase) hexadecimal. Moreover, if we omit the ‘ symbol, we get a method to refer to any character of the character set we use. The complete list of the available category codes follows.
Category
Description
Category
Description
0
2
4
6
Escape character End of group Alignment tab Parameter
1
3
5
7
Beginning of group Math shift End of file Superscript
8
Subscript
9
Ignored character
10
Space
11
Letter
12
Other character
13
Active character
14
Comment character
15
Invalid character
Some explanations are in order. When we start using any format, all characters that are not assigned a particular category code will become other characters. For example, the character 0 has no particular usefulness so it becomes an other character. An ac­
tive character is one that can be used as a macro (i.e., one can instruct TgX to perform certain operations whenever the next input character is that particular active charac- ter). Initially, the term letter refers only to all of the uppercase and lowercase letters.
2.2 D o c u m e n t C l a s ses a n d P a c k a gesO- 1 7
Now, ii one wants to make the character * the comment character, then the command \ cat code ‘ \*=14 achieves the desired effect. However, one must be very careful when changing category codes, as this may have unpredictable effects. Moreover, if one wishes to change the category codes of the characters { and }, we strongly advise the use of a local scope defined by the commands \begingroup and \endgroup. These commands define a local scope exactly like the two braces do. For example, the follow­
ing code fragment makes the characters { and }- behave like letters and assigns to the character [ the category code 1 and to the character ] the category code 2 in a safe way:
\begingroup
\c a t c o d e ‘\{ =1 1 \c a t c o d e *\} =11 \c a t c o d e ‘\ [=1 \c a t c o d e *\] =2
\endgroup
2.2 Document Classes and Packages
A document class specifies the general layout of our document as wel l as the various sectioning commands that are available for the particular document that one is prepar­
ing. For example, the book document class must provide commands for chapters, while for the a r t i c l e document class this is meaningless. comes with a number of
standard classes available for general use, which are shown in the following table.
Document Class
Description
a r t i c l e
An article, useful for the preparation of papers
D O O K
r e p o r t
l e t t e r
s l i d e s
pr oc
r U I U U U K p i t:p d.I c l l l U I l
For report preparation
For letter preparation
For slide preparation
An article in conference proceedings
Apart from these document classes, there are a few more standard document classes wi th a special usage:
l t x d o c Used only for the typesetting of the ΕΤ^Χ kernel and ET^X packages, ltxguide Used for the typesetting of the various documents that accompany each
release of TffTjgX2g, such as WTjXfor Authors, and so on.__________________________
ltnews Used for the typesetting of the WTfcX News, a leaflet that briefly describes what is new to each IATgX 2g release, minimal A minimal document class that is mostly used for debugging purposes.
But how can we tell T^T^X which document class we want to use? Since LTgX is a markup language, there must be a command by which one specifies the document class
ι 8 ·φ· 2 T he F ile S t ruc ture
to be used. Not surprisingly, this command is called \documentc la s s. This command takes at least one argument (i.e., the name of a valid document class and some optional arguments). The general form of this command is shown below.
\documentclass [optional args~\{doc class'}
Of course, one may choose not to specify any optional argument. In this case, the user can either omit the square brackets altogether or just leave them without specifying anything in between them.
With the optional arguments, one can specify the default paper size on which the document will be printed, whether the document will be printed two-sided. The supported paper sizes are shown in the following table:
Paper Size
Page Dimensions
l e t t e r p a p e r
l e g a l p a p e r
executivepaper
a4paper
a5paper
b5paper
8.5 in x 11 inf 8.5in x 14 in 7.25 in x 10.5 in 210 mm x 297 mm 148 mm x 210 mm 176 mm x 250 mm
+ 1 in = 72.27 pt and 1 in = 2.54 cm.
The default paper size is l e t t e r p a p e r. Note that the text width and the text length are both predefined for each particular paper size. Certainly, one can easily change the paper size and the text dimensions, but we will come back to this issue in Chapter 6. The other available optional document parameters are shown in the following table.
Parameter
Brief description
lOpt
l l p t
12p t
Normal letter size at 10 pt Normal letter size at 11 pt Normal letter size at 12 pt Two-^iHpH T'>T,infi'ni'r
oneside twocolumn landscape t i t l e p a g e
A VV J I V l v V l Ι·1·-Ι~1. I l l
One-sided printing
Document is typeset in two columns
Document is typeset in landscape mode
Forces ETeX to generate a separate page for the document
header and abstract
leqno f leqn d r a f t
Equation numbers appear at the left end of the page Equations are being typeset at the left margin of the page Forces ΕΤβΧ to print a line overflow indicator at the end of a line that is longer than the predefined size and does not include external graphics files
2.2 D o c u m e n t C l a s ses a n d P a c k a gesO- 19
The default font size is 10 pt (i.e., by omitting this option we inform IAT^X that we want to typeset our document in 10 pt). If the d r a f t parameter is in use, then TgX prints the symbol I at the end of each line that is longer than the predefined line length. Moreover, it prints a rectangle in the case where we are including some graphics file prepared, for instance, with a drawing tool. If we want to specify two or more optional arguments, we separate them with commas (e.g., d r a f t, lOpt). Note that the optional arguments can be specified in any order.
> Exercise 2.4 Suppose now that one wants to prepare an article at 11 pt for two- sided printing. Write down the corresponding \documentclass command. □
The American Mathematical Society has created a number of classes suitable for their publications. These classes provide additional functionality and are particularly well-suited for mathematical text. The complete list of these classes is shown in the following table.
Document Class
Description
amsart
amsbook
amsproc
amsdtx
amsldoc
The article class of the AMS
The book class of the AMS
For proceedings preparation
Used to typeset the source code of packages
Used to typeset documentation
More information on these classes is provided in Section 5.5.
A package is a I^T^X file that provides additional functionality to the functionality already provided by the ETgX kernel. Nowadays, packages are written in a form of literate programming suitable for ETeX. Any package comes with at least one . d tx file and one . i n s file. The . dtx file(s) contain the documentation as well as the source code of the package. One can directly typeset each .d t x file by feeding it to ΕΤβΧ. On the other hand, a user can extract the source code of the package by feeding the .i n s file to ETgX. This procedure will yield one or more .s t y files. Each . s t y file contains the source code of a ETgX package. After generating the .s t y files, one has to install them (i.e., to put them in a directory directly searchable by the TgX typesetting engine). The exact location where we put the resulting files is system-dependent. Note that all of the packages described in this book are part of any modern T^X installation. Yet how can we inform ETgX that we want to use a particular package? Before answering this question, we have to present the general structure of a ET^X file:
Preamble
\beg in{document}
Text
\end{do cument}-
20 ·φ· 2 T he F ile S t ruc ture
The preamble is the place where we put the necessary commands to use any packages that we choose. Moreover, this is the place where we put any user-defined macro definitions. The text area is the place where we actually write our text. In order to use a package, we have to add the \usepackage command. Since many packages provide options, one can specify which options one wants to use with a particular package. On the other hand, if one or more packages do not provide any options, one can directly specify all of the required packages as arguments of the \usepackage command. So, there are two forms of the \usepackage command,
where op t i on ( s ) and package( s) is either the name of one option, a package, or a list of comma-separated options and package names, respectively. For instance, if one wants to use the graphicx package with the dvips option, then the appropriate package inclusion command is
\usepackage [dvips] {graphicx}·
On the other hand, if one wants to use the packages ulem and letterspace, then the correct package inclusion command is
2.3 Sectioning Commands
Even the simplest document is partitioned into text chunks for at least two reasons. The first reason is that the document can be created more easily. The second reason is that the reader can be guided through the text by consulting the table of contents, which, in turn, is based on the title of each text chunk. Every L5TgX class provides a number of sectioning commands that are suitable for that particular document class. For example, the book document class provides, among other things, sectioning commands for parts and chapters. The general format of the ET^X sectioning commands is as follows:
Here, \S e c t i o n is the name of the particular sectioning command, and, of course, what goes inside the curly brackets is the actual title of the \Sect ion. ET^iX uses the arguments of the various sectioning commands to construct the table of contents, if we ask ETeX to generate it. Sectioning commands that have a trailing asterisk are not included in the table of contents and also generate headings without numbers. This is very useful since, for example, it may make no sense to put an acknowledgment section into the table of contents. ETgX provides its users with a plethora of sectioning commands:
\usepackage [ option(s)~\ {package} \usepackage{pacfcage(s) }
\usepackage{ulem, l et t er s p a ce } ·
\S e c t i o n { 5 e c t i o n t i t l e } o r\Se c t i on *{ Se c t i on t i t l e }
\p a r t
\s u b s e c t i o n
\c h a p t e r \s e c t i o n
\s u b s u b s e c t i o n \p a r a g r a p h
2.3 S e c t i o n i n g C o m m a n d s O- 21
The command \part is used to partition a book or report into parts. The command \chapter is used to partition a document into chapters, but it can be used only when preparing a book or a report. The other commands can be used in any document class and are suitable for sections, subsections, and so on.
>- Exercise 2.5 Write the command that is necessary to create the section heading of th is section. _
The argument of a sectioning command is also used to typeset the so-called running heads (i.e., the text we see at the top of the page). In many cases, this argument can be quite long so the running head does not fit well into the page. The obvious solution is to have a shorter text as a running head. For this reason, every sectioning command can have an optional argument, which must be enclosed in square brackets and is placed just after the name of the sectioning command; for example
\s e c t i o n [Short t i t l e ] { L o n g t i t l e }
so the Short t i t l e will be used as a running head. Moreover, ΙίΤβΧ will insert this title into the table of contents, if we ask it to generate it. Of course, in the case where we have a starred sectioning command, for example
\s e c t i o n * [Short t i t l e ] { L o n g t i t l e >
the Short t i t l e will be used to typeset the running head. It is important to note that the sectioning commands are commands where one has to omit the square brackets altogether when it is not necessary to specify an optional argument.
Δ
Ιί one is not satisfied with the predefined sectioning command, it is easy to define one's own commands in a separate package file. In order to do this, be aware of the fact that most sectioning commands are defined in terms of the command \Qstartsection, while the sectioning commands for parts and chapters are de­
fined in terms of the command \secdef. The command \<3startsection has six required arguments, optionally followed by a *, an optional argument, and a required argument:
\@startsection{name H level >{i ndent }{beforeskip >
{afterskip }{style >
optional* [altheading~\ {heading}
The meani ngs of t he vari ous ar gument s are expl ai ned below:
name The name of the user-level command (e.g., section).
level A number denoting the depth of the section (e.g., chapter has level equal to one, and so on),
indent The indentation of the heading from the left margin (see Figure 2.1).
beforeskip The white space that is left above the heading (see Figure 2.1). This argument is actually what we call a glue (i.e., a length that can shrink
22 Ο- 2 T h e F i l e S t r u c t u r e
and stretch). In general, a glue is a length followed by the keyword plus and the maximum length that the glue can stretch and/or the keyword minus and the maximum length that the glue can shrink.
afterskip The glue that is left after the heading (see Figure 2.1). In case it is a negative glue, it just leaves a horizontal space.
style Command to set the appearance of the heading.
altheading An alternative heading to use in the table of contents and in the running heads.
heading The heading used in the table of contents and in the running heads.
Figure 2.1: Graphical representation of the arguments indent, beforeskip, and afterskip of the VSstartsection command.
A typical example definition is
\newcommand{\section}{\<3start sect ion {section}{l}{Opt}%
{-3.5ex plus -lex minus -.2ex}*/(
{2,3e x plus . 2ex}%
{\norraalfont\Large\bf s e r i e s »
The command \secdef can be used to define (demanding) sectioning commands. It has two arguments
\secdef{unstarcmds }{starcmd>
where unstarcmds
is used for the normal form of the sectioning command and starcmds for the starred form of the sectioning command. Here is how one can use this command:
\newcommand{\f irstarg>{>
\newcommand{\chapter}{...\s e c d e f {\cmda}{\cmdb}} \newcommand{\crada} [2] [] {\renewcomraand{\f i r s t a r g } {#!}'/♦
2.3 S e c t i o n i n g C o m m a n d s O- 23
\ifx\firstarg\empty Yrelax ...
\else ... \f i >
\newcommand{\cmdbJ - [1] {. . . }
The \i f x construct is used to check whether the first argument is empty or not. In case it is, we put the code that processes the second argument after the command \relax, otherwise we put the code that processes both arguments after the com­
mand \else. The \relax command prevents T^X from consuming more tokens than is necessary, and it actually does nothing.
In case one wants to change the appearance of the sectioning commands, the command can be redefineed \Qseccntformat can be redefineed. For example, if we would like old style numerals, then the following redefinition achieves the desired effect:
\renewcommand{\®seccntf ormat [1] }{*/.
\oldstylenums{\csname the#l\endcsname}\quad}
The command \oldstylenums should be used to typeset a number using old style numerals. The construct \csname st ri ng \endcsname makes up a command of the s t r i ng. To turn a command into a string, use the \s t r i n g command.
The table of contents of a document can be constructed by issuing the command \t a - bleof content s. This command can be put in any place that the user feels is appropriate. However, it is common practice to have the table of contents in either the beginning of the document, usually after the title or title page, or at the end, just before the index and the bibliography.
In some cases, one may want to be able to manually add something to the table of contents. In cases such as this, one can use the command
\a d d c o n t e n t s l i n e { tab l ey- i t ypey- i ent r y}
where t abl e is the file that contains the table of contents, t ype is the type of the sectioning unit, and ent r y is the actual text that will be written to the table of contents. For example, the command
\addcontent sl ine{toc}{chapter>{Preface}
adds to the .t o e file (i.e., the table of contents) the chapter entry Preface. In case we want to add an entry to the list of tables or figures, the table is called l o t or l o f, respectively (see Section 6.5).
Δ
ΊΙιθ command \addcontentsline is defined in terms of the commands \addcon- tents and \contentsline. The first command has two arguments: the table and a t ext; this command adds the t ext to the table file, with no page number. The second command has three arguments: the type, the ent ry, and the page, which can be either a number or a command that yields the current page number; the
24 ·φ· 2 T he F ile S t ruc ture
command produces a type entry in the t able. For example, the entry for Section
2,5 of this book in the table of contents is produced by the command
\contentsline{section}{\numberline{2.5}Basic Logos}-[26]-
The command \numberline puts its argument flush left in a box whose width is stored in the internal length variable \<§tempdima, Now, we give the definition of \addcontentsline:
\newconunand\addcontentsline [3]
\addtocontents{#l}{%
\protect\contentsline{#2]-{#3]"C\thepage]-)-3-
>■ Exercise 2.6 Create a new sectioning command that will behave like the \s ect ion command and in addition will put an asterisk in front of the section number in the table of contents. [Hint: Use the \l e t command (see Section 4.5.1)] □
Every document class defines for each sectioning command an \T©type com­
mand. The general form of this command is
\1 ©type {ent ry} {page }
These commands are needed for making an entry of type type in a table of contents, or elsewhere. Most of the \T©type commands are applications of the command
\@dottedtocline{level }{i ndent } { numwi d t ht i t l e}{page}
wher e indent is the total indentation from the left margin, numwidth the width of the box that contains the section number if the t i t l e (i.e., the contents of the entry) has a \numberline command, and page the page number. Here is an example:
\newcommand*\l@section-C\@dottedtocline-[l]"Cl. 5em}{2. 6em}}
Note that the \@dottedtocline produces a dotted line. If we do not like this effect, then a good solution is to try to delete the part that produces the leaders.
When creating a large document, one may need to have appendices. l^T^X provides the command \appendix, which resets the numbering of the various sectioning com­
mands and, depending on the document class, forces the top sectioning command to produce alphabetic numbers instead of Arabic numbers. So, if we are preparing a book, the chapter numbers in the appendix appear as letters.
If we are preparing a book, we usually want to have a preface and/or a prologue. Moreover, it is customary for the page numbers of this part of our document to be typeset using the Roman numbering system (i.e., i, ii, iii, etc.). The book document class provides the commands \f rontmatter, \mainmatter, and \backmatter, which can be used to divide a book into three (logical) sections. The effect of the first command is to start Roman page numbering and to turn off chapter numbering. The second
2.3 S e c t i o n i n g C o m m a n d s O- 25
\docuraentclass{book}
Vusepackage-f }
\begin{docvunent}
\f r o n t m a t t e r \chapter{Preface}
\t a b l e o f c o n t e n t s \mainmatter \c h a p t e r {History}
\chapter{The Language}
\a p p e n d i x
\chapter{More on Nothing}
Ybackmatter \c h a p t e r {Solutions }
^Bibliography ft Index \end{document}
Figure 2.2: A skeleton file suitable for book preparation.
command resets the page numbering, starts Arabic page numbers, and turns on chapter numbering. The third command just turns off the chapter numbering. Tn Figure 2.2, we give a skeleton I5TeX file that can be used in the preparation of a complete book. The bibliography and index parts are commented out since we have not yet discussed the creation of these particular parts.
A
The appendix package by Peter Wilson provides some commands that can be used in addition to the \appendix command. It also provides a new environment that can be used instead of the \appendix command. The \appendixpage command will typeset a heading in the style of a \p a r t heading for the document class. The name of the heading is given by the value of \appendixpagenarae. The \add- appheadtotoc command inserts an entry into the table of contents. The text to be inserted is stored in the variable \appendixtocname. These commands can be used in conjunction with the \appendix command. We can change the predefined value of the commands \appendixtocname, \appendixpagename, and \appendixname by a simple redefinition, such as
\renewcoramand{\appendixtocname}{List of Appendices}
The appendices environment can be used instead of the \appendix command. It provides more functionality than is possible by the commands listed above. This additional functionality is accessible through options that the package provides:
toe Puts a header (e.g., "Appendices") into the table of contents before listing the appendices. The header used is stored in \addappheadtotoc.
page Puts a title (e.g., "Appendices") into the document at the point where the environment begins. The title used is stored in \appendixpagename.
t i t l e Puts a name (e.g., "Appendix”) before each appendix title in the body of the document. The name used is stored in \appendixname.
t i t l e t o c Puts a name (e.g., "Appendix") before each appendix listed in the table of contents. The name used is stored in \appendixname.
26 ·φ· 2 T he F ile S t ruc ture
header Puts a name (e.g., “Appendix") before each appendix in the page head­
ers. The name used is stored in \appendixname. This is default behavior for document classes that have chapters.
The subappendices environment can be used to add appendices at the end of a main document division as an integral part of the division. This environment recognizes only the t i t l e and t i t l e t o c options.
2.4 The Document Title
In any document, we want to have either a compact title part or a separate title page. In any case, we want to include the title of the document, the list of authors, and their affiliations. In addition, we often need to include an abstract, which will briefly describe the contents of the document. Another important piece of information that one may want to include is the time stamp of the document. This time stamp can be either the date that the document was processed by ETgX or any other date (e.g., in the case where it is a program manual, the time stamp may be the actual date when the program was released). There are two ways to construct the title of a document prepared with I^TeX: either by using the command \maketitle and its associated commands or by using the titlepage environment. An environment creates a local scope with a predefined functionality. The local scope is delimited by \begin{environment} and \end{environment}. An environment involves the execution of the command \environment, the typesetting of the body of the environment according to the rules set by the command \environment, and the execution of the command \endenvironment. If there is no command \endenvironment, l^TgX simply ends the local scope. We now present in turn the two ways that one can prepare the title of a document.
The title of a document must be specified with the \t i t l e command:
\title{Title}
The argument of the command is the actual title of the document. The authors, their respective affiliations, and the date of the document can be specified as follows:
\author{
First & Last name\\
OrganizationW Street address\\
Postal Code City, CountryW
\and
First & Last name\thanks{...}
>
2.4 T he D o c u m e n t T itle -Φ 2 7
\date{Date}-
\maketitle
As is obvious, the details of each author are separated by the command \\, which forces T^TgX to change lines. The command \and is used when a document has more than one author. In the example above, we specified two authors. However, if we want to specify one more author, we have to write one more \and command after the details of the second author. The command \thanks is used when an author wants to express gratitude to people or organizations that have provided assistance in the course of the preparation of the work presented in the document. The argument of the \date command will be used to typeset the time stamp of the document. If the argument is empty (i.e., \da te{ >) ΐ^ΤβΧ will not typeset a time stamp. However, if we want I^TgX to use the current date as the document's time stamp, we simply do not specify the \date command. In this case, ETeX prints the date using the \today command. Once we have finished with the author information, we include the \maketitle command to force ΕΤβΧ to typeset the title. This means that if we do not write down the \maketitle command, Ι^ΤβΧ will not produce the title of the document. In Figure 2.3, you can see an example of a typical article title.
T r u e T y p e F o n t s a n d E T ^X
Apostolos Syropoulos Antonis Tsolomitis Department of Civil Engineering, Department of Mathematics Democritus University of Thrace, University of the Aegean GR-671 00 Xanthi GREECE Karlovasi
E-mail: apostolo@obelix. ee. duth. gr GR-832 00 Samos, GREECE
E-mail: atsol@iris. math. aegean. gr
November 1, 2000
Figure 2.3: A typical article title.
In a typical scientific document, there is usually an abstract that contains a brief description of the text that follows. One can put the abstract just before or after the \maketitle command. The environment abstract is used to write down the abstract of a document.
\begin-Cabstract}
Text of the abstract.
\end{abstract}
28 ·φ· 2 T he F ile S t ruc ture
Note that a book is not allowed to have an abstract, as this makes no sense.
>- Exercise 2.7 Write a small document and write the abstract before and after the command \maketitle. What's the difference? □
Since what ET^X provides to its users may not satisfy everybody, the system allows its users to reprogram the \maketitle command and its associated commands or just use the titlepage. This environment generates a new page where the author is free to put whatever suits the needs of the particular document being prepared. Of course, at this moment, our knowledge of DT^X is too limited so there are only a few things we can do. As the reader proceeds with this the book, new commands to create an excellent title page will be discovered.
2.5 Basic Logos
A logo is a name, symbol, or trademark designed for easy and definite recognitionm, so the word ΤβΧ is a logo. The natural question is: "How can one produce this and the other TgX-related logos?" The answer is in the following table.
Logo
Command
ΤβΧ
l t ex
LTgX2g
\TeX
\LaTeX
\LaTeXe
All of these commands have a peculiar behavior, which is demonstrated by the follow- ing example (note that the character u is a visual representation of the space character):
Plain TgXis easy Plainu\TeXuuuuuisueasy
but T^TgX is easier! butu\LaTeX\uisueasier!
It is obvious that in the first example, regardless of the number of spaces that follow the command \TeX, ΤβΧ is setting no space between the logo and the next word. This happens simply because these commands consume all of the white space that follows them. However, in the second example, we see that the use of the command \u produces the intended result. The effect of this command is to force TgX to produce a reasonable interword space.
>- Exercise 2.8 According to the regulations set by the Greek Postal Services, when one affixes a printed address label on a postal object, the first three digits of the postal code must be separated by a single space from the remaining two digits. Moreover, we have to add two spaces between the postal code and the name of the town that immediately follows. Write down the necessary commands to typeset the following address according to the regulations of the Greek Postal Services:
2.6 A r t i c l e P r e p a r a t i o n -Φ 29
Basil Papadopoulos 33, Andrianoupoleos Str.
671 00 Xanthi
(Hint: use the command \\ to force ΐ^ΤβΧ to change lines.) □
The package mflogo by Ulrik Vieth provides two commands that generate the fol­
lowing logos:
Logo
Command
METflFONT
METRP05T
\MF
\MP
In addition, there are many other TgX-related logos that we will encounter in subsequent chapters.
2.6 Article Preparation
We are now in a position to write a complete real I^TeX document. Using your favorite text editor, type the following I^T^X code into a file.1 Save the file and call it article. tex.
\documentclass[a4paper,llpt]{article}
\begin{document}
\title{Ways to the Moon?}
\author{R. BiesbroekW
JAQAR Space EngineeringW
Den HaagW
The Netherlands
\and
G. Janin\\
Mission Analysis SectionW__________________________
ESOCW
DarmstadtW
Germany}
\date{August 2000}
\maketitle \begin{abstract}
ESA has conducted several studies on missions to the Moon
in recent years\ldots
\end{abstract}
1. This is part of an article published in the ESA Bulletin, number 103, August 2000, pp. 92-99.
30 ·φ· 2 T he F ile S t ruc ture
\tableof contents
\section{Previous lunar missions}
Lunar exploration began on 1 February 1959 when the Soviet satellite Luna-1 flew past the Moon.\ldots
\section{Going to the Moon now}
The Moon is the Earth’s only known natural satellite\ldots
\subsection{The direct way: fast but expensive}
The c{classical’’ lunar mission begins from a so-called f‘parking orbit’’ around the Earth\ldots
\section*{Acknowledgments}
The support received from Dr. W. Ockels in the preparation of this article is gratefully acknowledged.
\end{do cument}
Before you feed the file to LT^X, we must explain what the command \l d o t s is doing. This command simply produces an ellipsis (i.e., three spaced-out dots) since the file contains part of the complete document. Now, we feed the file to T^X or to any of the related typesetting engines:
$latex article
This is TeX, Version 3.14159 (Web2C 7.3.1)
(article.tex LaTeX2e <2000/06/01>
Babel <v3.6k> and hyphenation patterns for american, english, greek, loaded.
(/usr/local/teTeX/share/texmf/tex/latex/base/article.els Document Class: article 2000/05/19 vl.4b Standard LaTeX document class
(/usr/local/teTeX/share/texmf/tex/latex/base/size11.clo))
No file article.aux.
No file article.toe.
[1] (article.aux) )
Output written on article.dvi (1 page, 1604 bytes).
Transcript written on article.log.
As is obvious from the program output, there are two missing files called article. toe and article.aux. The first file is supposed to contain the table of contents of the
document, while the second file contains auxiliary data useful for the correct label
2.7 L etter P r e p a r a t i o n -Φ 3 1
resolution, among other things. When the \table of contents is used, TATgX searches for a file that has the same name as the input file but with file extension is .toe. This file is used to store the generated table of contents while processing the input file. The file is (re-)generated every time our file is processed by I^TgX, just in case the contents of the file have changed. Now, we have to reprocess our file with LT^X to get the table of contents:
$ latex article.tex
This is TeX, Version 3.14159 (Web2C 7.3.1)
(article.tex LaTeX2e <2000/06/01>
Babel <v3.6k> and hyphenation patterns for american, english, greek, loaded.
(/usr/local/teTeX/share/texmf/tex/latex/base/article. els Document Class: article 2000/05/19 vl.4b Standard LaTeX document class
(/usr/local/teTeX/share/texmf/tex/latex/base/sizell.clo))
(article.aux)
(article.toe) [1] (article.aux) )
Output written on article.dvi (1 page, 1984 bytes).
Transcript written on article.log.
Finally, we can view the resulting output file. In Figure 2.4, the reader can see the formatted output.
It is interesting to note that the first word of the first paragraph of each new section is not indented, whereas in all subsequent paragraphs the first word is indented. This is common practice in American typography, but in many continental European countries, the typographic style demands that even the first paragraph must be indented. This effect can be achieved in two ways. The most simple one is to use the package indentfirst. Alternatively, one can put the command \ indent just before the first word of the paragraph. However, the drawback of this approach is that it is not an efficient solution for a large document. Note that there is also a command that has the opposite effect of the \indent command; this is the \noindent command.
_____________________________
2.7 Letter Preparation
The letter document class offers a special environment for writing letters. A LTjgX file that uses this document class can contain an arbitrary number of such environments so one can create many letters with a single LT^X file. Initially, one has to specify the sender's address with the \address command. Moreover, one has to specify the name of the sender with the \signature command. Once we have specified this information, we can start writing our letters. The text of each letter is actually written in the body
32 -φ- 2 T he F ile S t ruc ture
Ways to the Moon?
R, Biesbroek G. Janin
JAQAR Space Engineering Mission Analysis Section Den Haag ESOC
The Netherlands Darmstadt
Germany
August 2000
A bs t r a c t
ESA has conducted several studies on missions to the Moon in recent years...
Contents
1 Previous lunar missions 1
2 Going to the Moon now 1
2.1 The direct way: fast but expensive............................................... 1
1 Previou s lunar missions
Lunar exploration began on 1 February 1959 when the Soviet satellite Luna-
1 flew past the Moon....
2 Going t o t h e Moon now
The Moon is the Earth’s only known natural satellite...
2.1 The direct way: fast but expensive
The ‘classical’ lunar mission begins from a so-called ‘parking orbit’ around
the E a r th...__________________________________________________________
Acknowledgments
The support received from Dr. W. Ockels in the preparation of this article is gratefully acknowledged.
1
Figure 2.4: The formatted output of the lAT^X file on page 29.
2.8 P r o d u c i n g P r o c e e d i n g s A r t i c l e s -Φ 33
of the l e t t e r. The environment has one argument, which is the recipient address. Inside the l e t t e r environment, we can specify how the letter will open and how it will close by giving the appropriate text as arguments to the commands \opening and \c l o s i n g. The \c c command can be used after the closing command to list the names of people to whom we are sending copies. There is a similar \e n c l command for the list of enclosures. A postscript can be generated with the \ps command. Note that this command does not generate any text; consequently, one has to type the "PS" oneself. Here is the code of a complete example:
\documentclass [a4paper, 12pt] -{letter}
\address{%
DigiSetter Inc.\\
1, \TeX\ DriveW Sparta}
\signature{%
Apostolos SyropoulosW Sales Manager}
\begin{document}
\begin{letter}{%
Dr. Mikolaos Sofroniou \\
Department of Digital TypographyW 3, \LaTeX\ Str.\\
Thebes}
\opening{Dear Sir,}
Please find enclosed the information you have requested regarding our digital setter.
\closing{Yours very truly,}
\ps{PS. All prices are in Spartan Talanta.}
\cc{Dr. Antonis Tsolomitis}
\encl{A prospectus of DSET-100.}
\end{letter}
\end{document}
The output of this example can be seen in Figure 2.5.
2.8 Producing Proceedings Articles
Proceedings articles are typeset in two columns, and actually any article can be immedi­
ately converted into a proceedings article. The corresponding document class provides the command \copyrightspace, which is used to produce blank space in the first col­
umn, where a copyright notice belongs. Note that this command should appear after any footnotes (see Section 4.5).
34 ^ 2 T h e F i l e S t r u c t u r e
DigiSetter Inc. 1, T[hX Drive Sparta
December 4, 2007
Dr. Nikolaos Sofroniou Department of Digital Typography 3, LATEX Str.
Thebes
Dear Sir,
Please find enclosed the information you have requested regarding our dig­
ital setter.
Yours very truly,
Apostolos Syropoulos Sales manager
PS. All prices are in Spartan Talanta cc: Dr. Antonis Tsolomitis end: A prospectus of DSET-100.
Figure 2.5: A complete letter.
2.9 Combining Individual Files
The problem oi combining a set of individual LT^X files into a single I^T^X file occurs very frequently. For example, one faces this problem in the preparation of the proceedings of a workshop or conference. The combine document class, by Peter Wilson, provides a
solution for this problem. A master file that uses the combine document class imports a set of individual Ι^ΤβΧ files, which use the same document class, and when fed to ΤΤβΧ generates a single DVI file. Sectioning, cross-referencing, bibliographies, and so on, are local to each imported file. Here is a simple example file that might be used to typeset conference proceedings, among other things:
2.9 C o m b i n i n g In d i v i d u a l ETjiX F iles -Φ 35
\documentclass [colclass=hms,packages] {combine}
\begin{document}
\title{Proceedings of the...}
\author{George Taylor\thanks{Support...}}
\maketitle \tableofcontents \section*{Preface}
This is ...
In the paper by Chris Andersson...
\begin{papers}
\coltoctitle{On the use of the hms class}
\coltocauthor{John Smith}
\import{hms}
\newpage \end{papers}
\begin{papers}
\coltoctitle{On the use of the combine class}
\coltocauthor{Peter Wilson}
\import{combine}
\end{papers}
\section*{Acknowledgment}
We would like to thank...
\end{do cument}
The combine class offers many options apart from providing all of the class options appropriate for the class of the individual documents. Here, we present the most important options.
book, report, and l e t t e r By default, the a r t i c l e document class is assumed for both the main and the imported files. These options change the class to book, report, or l e t t e r, respectively.
colclass=SomeClass This option makes SomeClass the class that is used to typeset the
whole document.
packages By default, all \usepackage commands in imported files are ignored. If this option is specified, the use of all \usepackage commands will be enabled. However, we must stress that only the first occurrence of a package is actually used, and it is not available to any file imported later,
c l a s s e s This option enables the imported documents to be of different classes. How- ever, this option is error-prone and best avoided, layout This option enables the imported documents to have their own page layouts. We feel that this option is redundant since it makes no sense to have a document with parts that have different page layouts, f o l i o s The page numbers are sequential throughout the document. It is a good idea
to avoid using this option with the plai n page style.
36 2 T he F ile S tr u c t u r e
notoc Disables the inclusion of the table of contents in any imported document, nolof Disables the inclusion of the list of figures in any imported document, nolot Disables the inclusion of the list of tables in any imported document, maintoc Adds the table of contents, list of figures, and list of tables of all imported documents to the corresponding table and lists of the main document, n o t i t l e Disables title printing by any \maketitle in any imported document, noauthor Disables author printing by any \maketitle in any imported document, date This option allows dates generated by \maketitle commands to be printed, nomaketitle Disables all output generated by \maketitle.
nopubindoc Disables the printing of the \p u b l i s h e d information within an imported document.
nopubintoc Disables the printing of the \p u b l i s h e d information with the main table of contents.
The combine document class provides a few additional commands and environ­
ments that facilitate the creation of the single document. The environment papers provides a wrapper around imported file(s). This environment may have an optional argument that can be specified in square brackets immediately after the beginning of the environment, that is executed immediately at the start of the environment, and its default action is to force 7£X to skip the current page and to start its typesetting business at the next odd-numbered page. To avoid the default action, one must specify an empty option argument (i.e., \begin{papers> []).
The command \import{Te Xf i l e } is used to import the individual IiT^X files and should be used only within a papers environment. TeXf i l e is the name of a L?T^X file without the default .t e x filename extension. Moreover, the Te Xf i l e must be a complete LiTpX file.
A
The commands \maintitlef ont, \postmaintitle, \mainauthorf ont, \postmain- author, \maindatefont, and \postraaindate control the typesetting of the main document's \raaketitle command. Each part of the main title is typeset as if the corresponding main and post commands surround this particular element, for example
{\maintitlefont \title \postmaintitle}
Here is a simple example:
\renewcommand-[\maintitlef ont}{\hrule\begin{center]-%
\Large\bfseries} \reneucoramand{\postraaintitleH\end{center}\hrule'/,
\vspace-[0. 5em}>
\renewcommand-[\mainauthorf ont}{\begin{center}\large*/0 \begin{tabular>[t]{c}} \renewcommand-C\postmainauthor}{\end{tabular}\paLr'/,
\end{ c ent e r }}
2.9 C o m b i n i n g In d i v i d u a l ETjiX F iles -Φ 3 7
The \t i t l e and \author commands in each individual file are typeset by \maketitle commands in the imported files. Their typesetting is controlled by the commands \im p o r t ti t le f ont, \postimporttitle, \ import author f ont, \post import author, \importdatef ont, and \postimportdate. These commands are used by the combine document class exactly like the \main and \post com­
mands. Here is a real-world example that the first author has used in the prepara­
tion of a mathematics journal:
\renewcommand-C\importtitlef ont}-C\vspace*-[0.75in}\begin{center} M a r g e\b f s e r i e s \a r t T i t l e }
\makeatother
\renewcommand-[\postimporttitle]"C\par\end-[center]-\vskip 3. Oem} \renewcommand-[\importauthorf ont}{\begin{center}
\l a r g e\s c s h a p e \l i n e s k i p . 5em%
\b e g i n { t a b u l a r } [ t ] {ο}}
\m a k e a t l e t t e r
\renewcommand{\post import author }{\end-[tabular}\par\vskiplem% {\@received \@revised}\end{center)-]-
The \bodytitle [short t i t l e ] { l ong t i t l e } command is similar to a \chapter or a \ sect ion command, depending on the document class of the document. It may be used to enter a numbered title heading into the main document or table of contents for the following imported file. The starred version produces an unnumbered title heading and makes no entry in the table of contents. The commands \coltoctitle and \coltocauthor have one argument, the title and the author(s) of an imported file. The command \published [short ] { long} can be used to put the long text into the body of the main document. If the optional argument is not used, then long is also added in the main table of contents. The command \pubf ont controls the appearance of the text of a \published command.
Fo n ts a n d Tttftr U se
A very common complaint from beginners to the TgX system and its derivatives is “where are the fonts?” or "am 1 restricted to the default font?". Tn this chapter we will see first how to access different font families and within them special symbols. Moreover, we will see size-changing commands and also deal with typographical issues, which the wealth of fonts available to TgX makes necessary.
However, what is a font? Looking it up in a dictionary, you will find something like this "a complete assortment of types of one sort, with all that is necessary for printing in that kind of letter." We will use the word glyph to talk about the shape of each letter or character. A font is a file that contains the description of glyphs, usually-for example, PostScript Type 1 fonts or METRFONT fonts-in a mathematical manner; that is, the curves that make up the glyph's design are described as the graphs of functions with certain characteristics. For each glyph, the font file sets up a name for it and then the mathematical description is given, the same for the next glyph, and so on. We will come back to this internal structure of the font files when we deal with the procedure for installing new fonts.
3.1 Classification of Fonts
Generally speaking, there are two main categories of fonts: serifed and sans serif (also known as gothic). The serifed fonts are those that have serifs, or little decorative lines at the end of their strokes, like the default font of this text. The second category is the sans serif font, which does not have these decorations. The following example makes things clear:
Computer Modern serifed type Computer Modern sans serif type
Lucida Serifed type Lucida sans serif type
Lucida Seri fed Ελ λ η ν ι κ ά σ τ ο ι - Lucida sans seri f Ελληνικά στοι ­
χεία (greek) χεία (greek)
40 ·φ· 3 Fon t s a nd Their U se
The serifs are useful because they serve as a guide to the eye, making reading more comfortable. That is why they are usually preferred for text work.
Another parameter that categorizes fonts is whether they are of variable widths or fixed widths. Fixed-width fonts are fonts where each glyph has the same width as all others, that is, the letter i, for example, has the same width as the letter m. These fonts often remind us of the typewriter and are usually used for computer program listings:
radii in variable-width serifed font
radi i in fixed-width font
rad i i in variable-width sans serif font
These categories ^the serifed, the sans serif, and the typewriter fonts—usually provide a full set of glyphs—enough to typeset most articles or books. In LATgX, we call them families, and in order to use them, we use the commands
{\rmfamily text}· {\sffamily text} {\ttfamily text}
or alternatively
\textrm{text} \textsf{text} \texttt{text}
for serifed (also called "Roman"), sans serif and typewriter, respectively.
Inside each of these families, other parameters lead to further classification. Each of these families is now divided into series. Series have different weights. Weight is the width of the curves that draw each glyph. Let us first note that the width of these lines is usually modulated. In some fonts, the modulation is heavy, resulting in high-contrast fonts, whereas for others the modulation is moderate or sometimes nonexistent.
/w/y /strs/f/Sfrf/c/t, moderate modulation and no modulation
However, font families are usually accompanied by a set of glyphs that have overall heavier lines and are the bold series of the font. The bold series are used for empha­
sis, but their use must be kept to a minimum, as they make the “page color" look unbalanced. We make use of the bold series with the commands
\textbf{text} or {\bfseries text}
Now, inside each series, we have different shapes, such as the italic shape. In ty­
pography, it is very common to want to emphasize something. It may be a single word or even a full paragraph (such as the statement of a theorem in mathematics). For this task, we use the italic shape of the type. This is done with the commands
\textit{text} or {\itshape text}
For example, this is written in italic shape. No font family can be considered complete if it does not come with a companion italic shape. Another way to emphasize, which is also popular, is with the slanted shape. Ί his is the slanted shape, and it becomes available with the commands
3· ΐ C l a s s i f i c a t i o n o f F o n t s -Φ 41
\t e x t s l { t e x t } or -{\slshape t e x t }
Note that the slanted shape is the same as normal upright shape but is printed with a slope other than 90 degrees. The italic shape is essentially a different design. Slanted printing is a simple mathematical transformation. That is why one should not really pay for slanted type, as T^X can easily print with slope from the upright version of the font. This will be explained in Chapter 12, where we will discuss techniques of font installation. The italic shape is something to look for in a (modem) font family. It is something to help you check how much the designer really thought about typographical perfection for his font creations. Bold series usually have their own italic shape, but it is rarely used. We must add here that all of the preceding commands of series and shape changes can be combined as in
{\b f s e r i e s\i t s h a p e t e x t } producing text.
Table 3.1: Family series and shape-changing commands.
Command
Corresponds to ...
E x a m p l e T e x t
\t e x t r m {...} \t e x t s f {...} \t e x t t t {...}
\t e x t m d {...} \t e x t b f {...}
\t e x t u p {...} \t e x t i t {...} \t e x t s l {...}
{\r m f a m i l y ...} {\s f f a m i l y ...} {\t t f a m i l y ...}
{\m d s e r i e s ...} {\b f s e r i e s ...}
{\u p s h a p e ...} {\i t s h a p e ...} {\s l s h a p e ...}
R o m a n F a m i l y S a n s S e r i f F a mi l y T y p e w r i t e r F a m i l y
Medium Series Bol d Seri es
Upr i ght Shape Italic Shape S l a n t e d S h a p e
\t e x t s c {.,,} \e m p h {,..} \t e x t n o r m a l {.,,}
{\s c s h a p e ..,} {\e m ...}
{\n o r m a l f o n t ..,}
Sm a l lCa p s Sh a p e Emphas i z e d
N o r m a l d o c u m e n t f o n t
T h e c o m m a n d s i n t h e s e c o n d c o l u m n a r e a c t u a l l y d e c l a r a t i o n s. A n y d e c l a r a t i o n s h o u l d b e u s e d i n a l o c a l s c o p e u n l e s s w e w a n t i t t o g l o b a l l y a f f e c t t h e t y p e s e t t i n g o f o u r d o c u m e n t. G i v e n a \d e c l a r a t i o n, w e c a n c r e a t e a l o c a l s c o p e i n t h e f o l l o w i n g w a y:
\b e g i n { d e c l a r a t i o n }
\e n d { d e c l a r a t i o n }
t h a t i s, w e c a n t u r n i t i n t o a n e n v i r o n m e n t.
We w i l l p a u s e f o r a m o m e n t t o t a l k a b o u t a t e c h n i q u e o f e m p h a s i z i n g t h a t i s c o n - s i d e r e d p o o r p r a c t i c e. B e c a u s e o f t y p e w r i t e r s a n d t h e u s u a l l y i n c o m p l e t e f o n t s t h a t
42 -φ- 3 F o n t s a n d T h e i r U s e
come with word processors, many people have learned to emphasize by underlining the text. That is really poor, as it disturbs the balance of the page color and makes it look unprofessional. Even worse, word processors underline without any regard to letters such as p, q, and others that extend below the writing line (also called "baseline"). For example, many times you can hardly distinguish an underlined j from an underlined i. Although L5TgX can produce better underlining if instructed properly, this is not a good technique for emphasizing. If the user insists on using underline, either the command \underline or the package ulem by Donald Arseneau may be used. The following ex­
ample shows both ways. Note that the ulem package provides additional commands such as the \uwave command.
A very special shape inside a series is the Sma l l Ca p i t a l s Sha E-mail capitals are capitals of reduced size usually around the size of the lowercase type. They are a sign of typographical perfection for the following reasons. First, capitals are hard to read, and that is why they are avoided (Figure 3.1). The second reason is technical. When we say reduced size we do not mean plain scaling. Plain scaling will reduce the width of the lines that make up the glyphs. Thus, the result will have color problems (see Figure 3.2). True small capitals are scaled in width and height, but the line width is not scaled by the same factor as the other dimensions. This is why the small capitals must come as an additional shape of a well-designed font, since the user cannot create them with simple scaling. Small capitals are used exclusively when we want to set capitals inside text. For example, we write: s p a mand Gr e e c e are both members of e u.
Many commercial fonts come with other shapes as well, such as swash capitals or other ornamental shapes:
THIS BOOK IS THE FIRST BOOK This Book Is The First Book That THAT PROVIDES A DETAILED DE- Provides A Detailed Description SCRIPTION OF MULTILINGUAL O
f
M
ultilingual
I
ssues
A
nd
U
seful
ISSUES AND USEFUL INFOR- Informa tion About The Omega And MATION ABOUT THE OMEGA La mbda Typesetting Engines.
AND LAMBDA TYPESETTING EN­
GINES.
This is a test of the package ulem. Although underlining is not^suggested for emphasizing, the user may find this useful in certain applications.
This is a \uline{test of the package \textsf{ulem}. Although underlining is} \uwave{not} \underline{suggested} for emphasizing, the user may find this \uuline{useful} in certain applications.
TX'ES'E A fJ?E SWAS?{ C&(PI(T&LS
Figure 3-i: All capitals is hard to read
3 · ΐ C l a s s i f i c a t i o n of Fo n t s 43
T r ue S ma ll C a pita ls F ake S ma ll C apitals
Figure 3.2: True and fake small capitals.
Thus, in order to instruct LiT^X to use a specific type, it is imperative to tell the program exactly what you want. A command with the following arguments must be available:
ifami Iy >{s e r i e s >{shape}
Such a command of course exi st s, and it has one more argument that w e wi l l di s cus s now. This argument i s cal l ed encodi ng. TgX const ruct s t he page that out put s by choos i ng t he gl yphs from a 16 x 16 matri x, s o whe n you t ype on your keyboard t he l etter A, TgX cons ul t s a speci f i c ent ry of t hi s matri x for i nf ormat i on about the l etter A. The f ont i t sel f cont ai ns onl y t he i nf ormat i on about gl yphs i n a nonmat ri x manner. Thus, a matri x from t he s et of the g l yphs of the f ont i s const ruct ed duri ng the f ont i ns t al l at i on procedure. The way t he gl yphs are l ai d out i n t hi s mat ri x i s cal l ed t he encodi ng vector, or encodi ng for short. Thi s i s a powerf ul t echni que that gi ve s us t he opport uni t y t o us e any number of gl yphs. We onl y have to swi t ch e ncodi ng and a ful l 16 x 16 matri x o f ne w gl yphs be c ome s avai l abl e. The most st andard e nc odi ng vect or i s cal l ed OT1. In Fi gure 3.3 we
Ό
Ί
'2
'3
4
'5
6
■?
W i
Γ
Δ
e
Λ
π
Σ
T
"Ok
01x
Φ
Φ
Ω
f f
i i
l i
I i i
i l l
m
1
“
iJ
■'Ijc
W x
,
β
Ά
c e
0
E
< E
i i
04x
-
1
■■■
#
ί
%
k
5
'2x
'05x
(
j
-
7
-
/
W i
0
1
•2
3
4
5
<i
7
'3 x
07x
8
9
ί
i
—
i
?
1 Ox
®
Λ
Β
C
υ
E
F
G
"4 x
"Hx
Η
I
Ι
κ
L
M
N
0
Ί 2 χ
Ρ
(3
R
s
T
U
V
w
"hK
Ί 3 χ
X
Υ
7
1
ii
J
Ί 4 χ
4
a
b
c
d
ij
f
■'6x
Ί5χ
h
ϊ
j
k
1
m
n
0
16χ
Ρ
q
r
d
t.
u
V
w
"7x
Ί7χ
X
y
Υ.
-
—
j
'
'■8
■'9
Ίί
"B
■c
■'D
"E
F
Figure 3-3: Computer Modern in 0Τ1 encoding.
44 ^ 3 F o n t s a n d T h e i r U s e
see the matrix for the Computer Modern font. We printed the matrix in eight columns in order to fit the page. This font has no glyphs (in this encoding) after the 128th entry of the matrix. Now, we present the font selection command. Suppose that we know that the Palatino font is named "ppl." Then, to select Palatino in medium (not bold) series in italic shape with the OT1 encoding vector, we issue the command
\us e f ont {OT1 }"Cppl i t }
This command can be broken into simpler commands, each of them setting the value for encoding, family, and so forth separately. This enables us to change only one of the characteristics of the type that we want to use. The commands are
\f ontencodingiOTl}, \f ontf amily-Cppl}-, \f ontseries-Cm}-, \f ont shape-fit)·.
These commands must be followed by the \s elect font command in order to take effect. Of course, if, for example, one sets the font family by, say, \f ontf amily-fppl}, then to select the italic shape one can just use the \itshape or \textit commands discussed earlier. These commands are considered the low-level interface for selecting fonts and font attributes, as opposed to the high-level commands such as \textit. Most of the time, the user just needs to load the appropriate package and can forget about these commands. They are necessary though for difficult tasks when we need several fonts (such as for the creation of this book). Font packages that are usually available in a modern installation are described in the table 3.2.
Table 3.2: Standard font packages in modern installations.
Package
Serif Font
Sans Serif Font
Typewriter Font
avant
Default (cmr)
AvantGarde, pag
Default (cmtt)
d V d l l l g d l
bookman
chancery
charter
concrete
A V d l l l v j d l C l t:, yc
i g
Bookman, pbk Zapf Chancery, pzc Charter, bch Concrete, ccr + EulerMath
L/t:l d U.l l ^ L l l l b a ^
AvantGarde, pag Default (cmss) Default (cmss) Default (cmss)
L/f c:l d U l l ^ L l l l l l J
Courier, per Default (cmtt) Default (cmtt) Default (cmtt)
courier
helvet
ncntrsbk
Default (cmr) Default (cmr)
New Century
Schoolbook-Roman,
pnc
Default (cmss) Helvetica, phv Default (cmss)
Courier, per Default (cmtt) Default (cmtt)
p c l l c l l C l l l
palatino
pandora
times
utopia
1 d i d I I I I U, iJy
1
+ cmr-Math Palatino, ppl
Pandora, panr
Times, ptm
Utopia, put
L/f c l d U l l
Helvetica, phv Pandora Sans, pss Helvetica, phv Default (cmss)
L/t;I d U.l l ^ C l I L l l J
Courier, per Default (cmtt) Courier, per Default (cmtt)
3 · ΐ C l a s s i f i c a t i o n of F o n t s -φ- 45
Although these packages provide a wealth of fonts, more fonts are available for special purposes and are usually installed by default. One such case is the fonts pro­
vided by the oldgerm package. This package provides the commands \gothf amily, \frakf amily, and \swabfamily that give access to the old German fonts Φΰφίίφ, aKo calico UTtuttir (Gothisch, also called Textur), ftraftur (Fraktur), and θφα>αί>αφεΓ (Schwabacher) designed by Yannis Haralambous. For using the fonts locally (such as here), it also provides the commands \textgoth, \textfrak, and \t ext swab. If any of the fonts above are not available in your installation, you can find them in the CTAN or in many Internet mirrors around the globe. If we really need the low-level interface, then it is useful to know the parameters necessary, given in Table 3.3. Note that not all series or shapes are always available for every font. Moreover, some fonts have extra shapes (such as swash), in which case we need to customize our installation (see Chapter 12). Note also that some font designers consider outline not just a shape but a family.
>* Exercise 3.1 Typeset the following paragraph:
Because of typewriters and the usually incomplete fonts that come with w o r d p r o c e s s o r s, many people have learned to emphasize by underlining the text. That is really poor as it disturbs the balance of the "page color" and makes it look unprofessional.
□
>■ Exercise 3.2 An old technique of emphasizing is by spacing out the text to be emphasized. In older times or in countries where italic shapes were not available, the typographer still preferred to avoid underlining and preferred to space out the text. This is still in use, but mainly for stylistic reasons. Since it obviously affects the page color, it should be used with caution. Probably the easiest way of doing this is by using the letterspace package by Phil Taylor. The package provides the command
\l e t t e r s p a c e to size {text to be spaced out by size>
Table 3.3: Font attribute parameters.
Parameter
Possible Values
\fontencoding
OT1 (standard Latin), TI (extended Latin), OT2 (Cyril­
lic), "custom" (such as LGR that selects Greek, LHE that selects Hebrew, and others)
\fontseries \fontshape
ul (ultra light), el (extra light) 1 (light), si (semi light), m (medium=normal), sb (semi bold), b or bx (bold), eb (extra bold), ub (ultrabold)
n (upright=normal), it (italic), si (slanted), sc (small caps), ui (upright italic), ol (outline shape, e.g., 1 H)
46 -φ- 3 F o n t s a n d T h e i r U s e
where size is a length followed by a length unit (see Section 4.1). Use this package to typeset the following:
Theorem 1 Every natural number bigger than 1 has a prime divisor.
Sketch of Proof: We use induction. For the number 2, the result is correct since 2 is a prime itself. Let n be a natural number. If n is prime, then we are done. If not, then assume that k is a divisor different from 1 and n. Then, k is less than n and consequently (by induction) it has a prime divisor, say p. Then, p is a divisor of n as well.
[Hint: The \l e t t e r s p a c e command and the text to be spaced out must be in a box (put the whole thing in a \mboxO, see Section 6.10); otherwise, you will get a new line after the end of the spaced-out text.] The letterspace package can also be used for big type sizes. If setting in big sizes, then spacing out the text a little bit makes it more readable. Let us close this exercise by mentioning that the letterspace package defines the parameters \naturalwidth and \linewidth, which are the natural width of the text to be spaced out and the width of the line, respectively. These parameters make possible commands such as
\letterspace to 1.7\naturalwidth {Sketch of Proof:}
□
>· Exercise 3.3 Typeset the next paragraph. Select fonts according to the following phrases (consult Table 3.2).
This is Avant Garde, Bookman Old Style, Chancery itdic. Also available in modern installations are the Charter font, the Concrete font, t h e Couri er f ont, the Helvetica font, the New Century Schoolbook Roman font, the Palatino font, the Pandora font, the Times font, and the Utopia font. If the oldgerm package is available, then you can write with $caituc, ^atitd), or θφα><ϊί>.
□
3.2 Accessing more Glyphs
As we discussed in the previous section, the standard way of accessing more glyphs
is to change the encoding vector. With this technique, it would seem that Unicode is irrelevant to TgX since one may argue that if we need additional glyphs, we change the encoding and that is all. Unfortunately, this is not true. It would be true if we always needed less than 256 glyphs for the typesetting of, say, a paragraph, as we cannot expect the user to switch encodings all the time within sentences. This problem appears with languages such as Arabic, Ethiopian, or even Chinese, where we need to access many glyphs simultaneously. But TjgX cannot use bigger font matrices, and this need led to
3-2 A c c e s s i n g mo r e G l y ph s -Φ- 4 7
the birth of Ω. Both Ω and Λ can access Unicode fonts, making the need for encodings obsolete. For this reason, they also greatly simplify the writing even of languages that use the Latin script. Since these tools are not yet widely used, we will continue with the discussion of common encoding vectors.
To access glyphs as in "Holder's role in Espana" one has two possible ways. Either use commands such as V'o, Vo, and \~n and let the encoding switching be done automatically by the command or switch the encoding to TI (by issuing, for example, \f ontencoding{Tl}\selectf ont ) and have a way through the keyboard to type char­
acters such as these directly. The latter is the preferred way when the main typesetting language has such special letters as those found in Spanish, German, or French. Of course, we cannot expect a user from these countries to type commands for accessing simple characters such as o. For this reason, keyboard drivers exist in these countries that are used so that people directly punch the appropriate keys on their keyboards. Consequently, the right approach for them is the TI encoding.
In the English literature, however, such characters are not accessed very frequently, and the mechanism of access through commands is the preferred one. Table 3.4 contains the most common special commands for accessing these glyphs.
Table 3.4: Examples of special characters. The characters of the last two rows of the first table and all of the characters of the second table are available in the TI encoding. All other characters are available in the OT 1 encoding. The \k command adds the character ogonek to its argument.
V e
\
e
\’ e
/
e
V o
A
O
V'e
e
\~n
ή
\=o
0
\.o
ό
\u{o>
0
\v{o>
ό
\H{o>
rr
O
\t { o o >
do
\c{c >
ς
\d{o}
ο
\b{o>
O
\r { a >
0
a
\i
1
\i
1
\AE
/F,
\a e
ap
\s s
β
\0E
CE
\o e
oe
\o
0
\o
0
\L
L
\1
I
i
7 {
I
\DH
D
\dh
δ
\DJ
D
\dJ
d
\NG
n
\ng
9
\TH
P
\t h
\guillemotleft «
\guillemotright »
\guilsinglleft <
\guilsinglright >
\quotedblbase „
\quotesinglbase ,
\textquotedbl
\textsterling £
\textsection §
\k{a> ^
Apart from the special letters that we saw, there are some special symbols that we usually want to access. The commands given in Table 3.5 work with the standard 0T1 encoding and do not work with the TI encoding. However, the symbols may be accessible in both encodings with different commands. For example, in the TI encoding,
48 -φ- 3 F o n t s a n d T h e i r U s e
we use \t e x t s t e r l i n g in order to get £, but in 0T1 encoding we use the \pounds command.
Table 3.5: Additional symbols for the 0 T1 encoding.
\dag
+
\ddag
t
\s
§
\P
1
\copyright
©
\pounds
£
Ytextregistered
®
\SS
ss
\i q
/
Ytexttrademark
TM
\aa
a
\AA
A
Ytextvisiblespace
\te x tcircled { s}
©
\rq
/
LTpX also provides the command \symbol for accessing a symbol from the font matrix using not a name but its position. The syntax of this command is \symbol{nit/)?- ber}·, where number is a decimal number, an octal number, or a hexadecimal number denoting a glyph position. Octal numbers are prefixed by ’ (e.g.,1143) and hexadecimal numbers are prefixed by " (e.g., " 1A and not "la).
If we have a font, for example, pzdr, and we want to see the glyphs it contains so that we can also see their position in the matrix, we use the command
$ l a t e x n f s s f o n t.t e x
The program will ask which font we want to see and then, in order to obtain the matrix, we will write \t a b l e and \bye at the next prompts (the program will guide us through these steps, see Section 12.2.2). The result for the pzdr font is given in Figure 3.4. Now, if we want to produce Ai, we can use the command \symbol{"F7} or the command \symbol{ ’ 367} (since the octal 367 is the same with F7 in the hexadecimal system) after we select the pzd family. Note that this font is encoded in the U encoding vector, so the font encoding must also be set to U.
Less frequently used symbols are provided by the package textcomp. This package provides access to symbols such as those in the following table:
Symbol
Command
15
\textmho
0
\t e x t l e a f
■h
\t e x t m u s i c a l n o t e
¥
\t e x t y e n
The glyphs in standard installations are provided by the font term. Readers may see the full list of symbols available by running l a t e x nf s s f o n t. tex for the font term 1000 and find the commands for each glyph by looking in the file textcomp.sty of their installation.
3-2 A ccessing more G lyphs -Φ- 49
Ό
Ί
'2
'3
4
'5
'6
Ί
'04X
3«-
V-
$€
■Β
©
®
"2χ
O5x
+
W
I®1
Μ,
gx
θ»
O6x
&
ο»
·»
/
X
X
X
"3χ
O7x
X
*
*
+
■l·
t
t
ΊΟχ
*
Φ
*
*
<S>
"4χ
'Hx
Ο
~k
•k
'12x
Λ
*
Φ
*
*
*
*
*
"5χ
Ί3χ
*
#
JiL·
*
Φ
*
Ϋ
*
Ί4χ
*
Φ
©
*
Φ
$
Φ
*
"6χ
Ί5χ
*
*
%
*
•
Ο
□
Ί6χ
□
□
□
A
♦
»
"7χ
Ί7χ
1
I
1
i
»
m
»
'24χ
ί
*
•
*
•
*
*■
**
"Αχ
'25χ
*
*
Φ
®
©
'26χ
©
©
©
©
®
0
©
"Βχ
'27χ
©
ο
Θ
©
θ
θ
©
'30χ
Φ
©
©
0
©
©
©
©
''Cx
'Six
Φ
0
θ
©
Θ
©
©
'32χ
Ο
©
©
Φ
-
I
"Dx
'33χ
\
-*·
-*
-►
-*■
'34χ
ιιιιφ
-
>
>-
>
*-
m-
"Ex
'35χ
m-
ο
α»
ί>
0
ο
'36χ
ο
ζ>
Α.
»-·
**
"Fx
'37χ
> >
·►
*»
=s>
"8
"9
"Α
"Β
"C
"D
"Ε
"F
Figure 3-4: Standard output of nfssfont.tex.
>- Exercise 3.4 Use commands to access accented letters, and typeset the following list of names or phrases:
Han The Thanh, Latala, Livshic, Godel, Geometriae Dedicata, Naive
. o
Set Theory, Ake Lundgrem ar fodd 1951 i byn kusmark utanfor Skelle- flea, How many € rs is a U5$, The University of the JEgean, ^©1998 TV Espana!?, Grofien Planeten, a des societes, Hiseyn agabeyi ile birlilcte hala gali§iyor.
Note that the Euro (€) is available in (at least) the LGR encoding (see also Section 3.2.1). If you have access to a European keyboard, try typing the paragraph above directly after you switch the encoding to TI. We should point out that double accents as in "Han The Thanh" can be typeset using the math mode that will be discussed in chapter 5. This is because fonts do not contain such complex characters, so we have to construct them. However, these difficult cases can be handled in a much better way, discussed in Section 3.5. □
50 -φ- 3 Fon t s a nd Their U se
3.2.1 Euro Font
There are special packages for the Euro font. One is the eurosym package by Henrik Theiling. The package provides the official Euro symbol, following the specifications of the European Union, in METRFONT with the commands \o f f i c i a l e u r o and \euro. It also provides the command \EUR{> for writing an amount of money. For example, \EUR{321{,}5> gives 321,5€. (Note that we have to write the comma between curly brackets to make TgX realize that this symbol is not a punctuation mark.) The position of the € defaults to the right of the number but can be changed to the left of the number if the package is loaded with the option left (e.g., € 321,5). Note that the \EUR command inserts a small space between the number and the Euro symbol.
For creating PDF files, the preferred way is to use the package europs by Joem Clausen. This package uses the Type 1 fonts created for the Euro symbol by Adobe and distributed for free on their Internet site (
http://www.adobe.com
). The package provides access to the official design with the command \EURofc. It also provides access to (nonofficial) designs that fit with bold series and families such as serifed, sans serif, and typewriter. Italics are also included. The serifed family is accessed with the \EURtmcommand, the sans serif with the \EURhv command, and the typewriter with the \EURcr command. Table 3.6 shows all of the symbols privided.
Table 3.6: The Euro symbol (europs package).
Official
EuroSerif
EuroSans
EuroMono
Normal
€
€
€
€
Oblique
€
€
€
€
Bold
€
€
-------€ -------
€
Bold-oblique
€
€
€
€
3.2.2 The wasysym Fonts
Another package with interesting symbols is the wasysym package by Alex Kielhom. Since the package provides many conceptually unrelated symbols, we present the symbols in groups. First, we provide the command that can be used to access the symbol and next to the command the actual symbol.
\AC ~
\HF ^
\gluon /'SMiKTN
\photon
\VHF %
3-2 A ccessing more G lyphs -Φ- 51
Mathematics:
\a p p r le
<
\apprge
>
\Box
□
\Diamond
O
\i i n t
jj
\i i i n t
.III'
\invneg
1—
\J o i n
\l e a d s t o
\LHD
<
\l h d
<
\l o g o f
©
\o c i r c l e
O
\o i i n t
§
\RHD
►
\rhd
>
\s q s u b s e t
□
\s q s u p s e t
□
\v a r i n t
I
\v a r o i n t
\unlhd <
\unrhd j>
\wasypropto
oc
General symbols:
\agemO
U
\a t a r i b o x
V
Λ
\b e l l
*
\Bowtie
X
\b l a c k sm i l e y
e
\brokenvert
1
1
\c e n t
\checked
/
\c l o c k
Θ
\currency
Π
\diameter
0
\D0WNarrow
T
\frownie
©
\female
9
\invdiameter
\kreuz
*
\LEFTarrow
\l i g h t n i n g
\male
tf
\permil
% 0
\phone
"St
\pointer
Φ
\recorder
0
\RIGHTarrow
►
\smiley
©
\sun
*
\UParrow
A
\varangle
4
\wasylozenge
n
\wasytherefore
Various circles:
\CIRCLE · \LEFTcircle © \RTfiHTCTRCTF fc
\Circle O \L eftcircle Q \RT(iHTri rrl <=
\LEFTCIRCLE 4 \l e f t t u r n ύ
\r i g h t t u r n ( j
\iVXVJll 1 s_> J.L s_>X“
\1VJ. K ίί L> L> J.X s_> _LC [y
Astronomical symbols:
\ascnode Q
\astrosun 0
\descnode ?'?
\earth Λ
\fullmoon O \mercury ^ \rightmoon D \uranus 5
\jupiter % \neptune $ \ saturn
\l eftm oon (I \newmoon · \venus 9
\mars tf \p l u t o E \v e r n a l T
Phonetic signs:
\dh δ
\DH D
\inve d
\openo 0
\thorn
\Thorn
52 -φ- 3 F o n t s a n d T h e i r U s e
Astrological symbols and the zodiacal symbols:
\a r i e s
T
\ta u r u s
tf
\gemini
I
\cancer
€3
\l e o
Ω
\v i r g o
ττρ
\l i b r a
=Ω=
\s c o r p i o
TH
\s a g i t t a r i u s
X*
\capricornus
\aquarius
\p i s c e s
K
\c o n ju n c t i o n
d
\o p p o s i t i o n
Musical notes:
\e i g h t h n o t e J' \twonotes «0
\f u l l n o t e
\h a l f n o t e J
\quarter note J
APL symbols (Le, symbols used in APL programs):
\APLbox
□
\APLcirc{*}
\APLcomment
P
\APLdown
V
\APLdownarrowbox
\APLinput
□
\APLinv
a
\APLleftarrowbox
0
\APLlog
©
\APLminus
—
\APLnot{*}
φ
\APLrightarrowbox
B
\APLstar
*
\APLup
Δ
\APLuparrowbox
□
\APLvert{*>
4
\n otb ack s lash
\n o t s l a s h
+
Note that \APLcirc, \APLnot, and \APLvert have a required argument. Polygons and stars:
\CheckedBox
CZ]
\d a v i d s s t a r
$
\hexagon O
\h e x s t a r *
\octagon
O
\pentagon
O
\Square □
\varhexagon 0
\v a r h e x st a r
*
\XBox
IX
3.2.3 Phonetic Fonts
For linguistic purposes, a special phonetic font is available using the package phonetic by Emma Pease. Table 3.7 gives the commands provided by the package. Note that the
oblique glyphs can be accessed by feeding the corresponding command as argument to the \t e x t i t command. The following example shows the phonetic transcriptions of Navaho (native USA) words:
dloo? (prairie dog) tj'ah (hat)
f r
litsx'o (yellow-orange) tsirt (haste)
Tak'os (neck) xaih (winter)
People interested in linguistics and TgX may find more information at the following URL: h t t p: //www. i f i. u i o.no/~dag/l in g-tex .html.
3.3 A u t o m a t e d S p e c i a l G l y p h s S e l e c t i o n -Φ 53
\schwa
9
9
\thorn
b
b
\g l o t t a l
?
?
\es h
J
I
\yogh
3
3
\e t h
d
d
\ enigma
m
n)
\engma
ΰ
V
\enya
ji
β
\f lap
c
r
\voicedh
fi
β
\hookd
cf
d
\rotvara
D
υ
\e p s i
ε
ε
ρ \u t { o }
ilTri \labvel-[mn}
o \h i l l { o >
0 \o h i l l { o >
\hausab
β
\hausad
cf
d
\hausak
fi
R
\varg
9
\udesc
U
V
\pwedge
Λ
\varomega
O
0
\revD
a
a
\f j
f]
β
\openo
0
3
\varopeno
D
\vara
a
\r o t r
a
Ju
\barlambda
X
X
0 \t d { o } a'b a\upbar b o \od{o}
5 \a cb ar{V}{o}
\hausaB
Έ
Έ
\hausaD
Ό
D
\hausaK
K
K
\planck
li
\r o t y
X
fi
\rotm
U I
w
\i b a r
i
\vod
Y
\ubar
H
\rotOmega
15
u
\v a r i
I
1
\bar j
;
J
\rotw
iW
\r i o t a
1
1
9 \s y l { o > ς \r c { c ) mh m\uplett{h }
0 \a c a r c {\’>{o>
Table 3.7: Symbols available in the phonetic package.
3.3 Automated Special Glyphs Selection
This section provides information on certain features but not "how-to" knowledge. T^X has the ability to select special glyphs automatically when there is a typographical need for them. The most standard is the automatic selection of the glyphs fi fl ffi and ffL whenever TgX meets the sequences f i, f 1, f f i, and f f 1 in the text (see Figure 3.5). Without these combined glyphs, the letter f extends so much to the right that it gets into the space of the next letter. Especially if it is followed by the letter i, the result looks poor (see Figure 3.5 again). These special combined glyphs are called ligatures. As we said above, the ligatures of f with i or 1 are the most common ones. Some font families, though, provide additional ligatures such as f with h, b, or j. For example, the kerkis font family, freely distributed by the Department of Mathematics of the University of the Aegean, Greece (see h t t p://i r i s.i n a t h.a e g e a i i.g r/s o f t w a r e/k e r k i s
), provides the additional ligatures: fiji and fjord. Other kinds of ligatures exist, but they are usually more ornamental in design and are used only when we want to create a special feeling with our text. Such ligatures are ligatures between s and t, c and t, and so on.
Another very common ligature is related to dashes. ETeX provides three dashes. The (simple) dash -, the en dash -, and the em dash —. These are produced with the ligature mechanism and were typed as -, —, a n d , respectively. Note that IftTpX
54 ^ 3 F o n t s a n d T h e i r U s e
fitness fitness
fitness fitness
Figure 3-5: Fitness without and with ligatures.
provides the commands \textendash and \textemdash, which produce an en dash or an em dash, respectively.
The plain dash, or hyphen, is the "joining" dash as in "David Ben-Gurion Airport." The en dash is used for ranges: "the information is on pages 17- 58" and to join two proper names such as "Heine-Borel" to avoid confusion with single persons with a hyphenated surname (e.g., Ben-Gurion). The em dash is the dash used for parenthetical purposes: "she was angry —please believe me—and this is why she did not talk to us."
Ligatures have another use also. Some languages (or for ornamental reasons in Latin-derived languages) require many accents or letters to change form depending on their location in the text. This is very common in Arabic, for example. Polytonic writing is needed to typeset classical Greek texts. For example, we write θα>ρ<ρ~ων, and the ligature mechanism combines the special characters with the following letter to produce θαρρών. The following text is from Μ ο ν ω,δ ι α ε π ι Ι ο τ λ ι λ ν ω, of Λ ι β α ν ι ο ς.
Ώ r o m o L, ή μέγα πένθος ούκ1 Αχαιίδα γην μόνον, αλλά καί πάσαν όπόσην ό 'Ρωμαίων κοσμεί θεσμός, κατείληφε- μάλλον μέν γάρ ίσως ήν Έλληνες οίκοΰσιν, άτε και μάλλον αίσθανομένην τού κακοΰ, διήκει δ’ ούν καί διά πάσης γης, ώς έφην, ή πληγή τύπτουσά τε καί κατατέμνουσα τάς ψυχάς, ώς ούκέτ1 όν βιωτόν άνδρί βελτίστψ τε καί ότω τοΰ εύ ζην επιθυμία.
To get this text, we have typed
>*Ω πόποι, >~η μέγα πένθος ο>υκ,> >Αχαιίδα γ~ην μόνον,
>αλλ*α κα* ι π~ασαν <οπόσην <ο <Ρωμαίων κόσμε"ι θεσμός, κατείληφε; μ~αλλον μ‘εν γ*αρ >ίσως <£ην <Έλληνες ο>ι- κο~υσιν, <άτε και μ~αλλον α>ισθανομένην το~υ κακο~υ, διήκει δ ’ 1 ο>~υν κα( ι δ ι {α πάσης γ"ης, <ως >έφην, <η πληγ'η τύπτουσά τε κα( ι κατατέμνουσα τ'ας ψυχάς, <ως ο>υκέτ} ’ >(ον βιωτ{ον >ανδρ{ ι βελτίστωΙ τε κα( ι <ότω| το“υ ε>~υ ζ~ην >επιθυμία.
Many commercial font families provide special letters for the English alphabet for ending or beginning a word. This practice used to be very common with Greek, and it is a necessity for some other languages. That is why D.E. Knuth created the "vargreek" letters such as ϋ, θ, φ, <p, and so on, but he made them available only in math mode
3.3 A u t o m a t e d S p e c i a l G l y p h s S e l e c t i o n -Φ 55
(Knuth did not provide text fonts for Greek in his fonts). These letters had a special use in the past, and it was common practice to use the second form of the letter at the beginning of words. The most complete set of alternatives is provided by the kerkis font family, ββ, ζζ, 0Θ, on, ρρ, σς, and φφ are provided. For example, the word ζιζάνιο will be typeset as ζιζάνιο. It is clear from the above that the ligature mechanism is quite powerful. We will learn how to setup ligatures when we discuss font installation in Chapter 12.
Although this ligature mechanism will suffice for many tasks in English, this is not the case for languages such as Arabic, Persian, Khmer, and others. For example, Arabic needs something much more powerful since the shape of the letters changes depending on the position of the letter inside a word or in abbreviations. Although special systems have been developed (for example, ArabTgX), the correct approach seems to be Ω and, in particular, A. This is mainly because systems that are specially designed for one language have serious compatibility problems with other languages and with the standard ΕΤβΧ packages. For example, a scholar writing an article or book about Arabic in a non-Latin and non-Arabic language would be out of luck with such systems. Ω loads the text as it reads the file in its buffer and, before the construction of the DVI file, it applies several filters, called Omega Translation Processes (ΩΤΡ for short), that the user chooses to load. These procedures take place in the background. The user does not deal with them directly, but they manage to make the correct substitutions, performing contextual analysis on the text. This allows one to use even the most difficult languages written with the Arabic alphabet, such as Pashto and Sindhi (of course, other languages, such as Arabic, Berber, Farsi, or Urdu, are also supported). We thoroughly discuss OTPs in Section 10.2.
The user has the choice of typing in Latin letters (using a transliteration table) or, if an Arabic keyboard is available, directly in Arabic, informing the system of what keyboard is in use through encoding related commands. A transliteration table is a correspondence between the Latin alphabet and the letters of the language that we want to typeset. This is how one can manage to write a text, say, in Greek, without having a Greek keyboard available. The user can look up the documentation at h t t p: //o m e g a.c s e.u n sw.e d u.au:8080/index.html. We shall show an example in Sindhi. Since we have no access to a Sindhi keyboard, we will use the transliteration table found in the link above. Our input here is entered in the Latin alphabet, but we shall inform
the program that we want to typeset Sindhi so the program looks up the transliteration table and typesets correctly. Our input is the following text.
tn-hn kry AsAn khy pn-hnjy =z-hnn khy sjA=g rkh nU pUndU I IeN pn-hnjy jdUj-hd meN.=dA-hp pydA kr ny. AhU b/ m lUm kr nU pUndU t/ sndh meN hr A yy wqt chA chA thy r-hyU Ahy I|eN dshmn AsAn j y I |eN AsAn j y jdUj-hd j y khlAf k-h.rA k-h.rA g-hA.t g - h.r y r-hyU Ahy.
Now, we pass this file through A and then either preview the resulting DVI file on screen with o x d v i or pass the DVI file through o d v i p s to produce PostScript. The result follows.
56 -φ- 3 F o n t s a n d T h e i r U s e
l O V 1.! ί <_s^ c r?^ i l t * ΰ * - “ Ι < 4 ^
^· \J^ -J-4 ft ■^u-u ^ -5*Ηλί f^L*-0 ri J-Λΐ ■J-‘j^ > ^ ft
\j ^ > ^ ί t > - ^ J ξ L f -f i l J ^ j 4"
• l t4 ^ J f A j b f ^
There may be cases where a user wants to avoid a ligature. The easiest way is to put a space of zero width between the two letters that TgX automatically substitutes with the ligature glyph. For example, the word fitness used in Figure 3.5 without the ligature fi was produced by the input text f { } i t ness. We will get the same effect with f { i > t n e s s or { f } i t n e s s.
3.4 Size-Changing Commands
In this section, we show how to change the size of fonts. The \document c l a s s command accepts three size-relative options. These are lOpt (default), l l p t, and 12pt (see Sec­
tion 4.1). One may ask "why not accept any size?" or "how can I produce a document at 18 pt?". The answer to this is simple. The three sizes above are the usual sizes that peo­
ple use to typeset their documents. Also, MgX must load information about the relative sizes of math operators, and this restricts us to supporting the standard text sizes. For example, books are usually set at 10 or 11 pt. However, for special situations, one may want to change this. This is why Ι£ΓεΧ provides commands such as \Large or \small. These commands are declarations and change the font size relatively to the predefined document font size. Table 3.8 shows the size-changing commands at the type size of this book. Note that these commands do not provide a fixed size but a size proportional to your basic document font size chosen at the \document c l a s s command. Sometimes, one may need more sizes. For example, you may be preparing a poster and then need some type at 72 pt. For such a specific task, one usually looks for a special package. For this task, the aOposter document class by Gerlinde Kettl and Matthias Weiser provides additional functionality that makes it easy to typeset a poster with ΜΓβΧ and to print it on a DIN AO printer using d v i p s. Furthermore, if one wants to typeset a document in either 8 pt, 9 pt, 14 pt, 17 pt, or 20 pt, then a reasonable solution is to use one of the "extsizes" document classes, listed below, by James Kilfiger:
Name
Corresponds to
e x t a r t i c l e
extbook
a r t i c l e
book
e x t l e t t e r
extproc
extreport
l e t t e r
proc
report
These document classes can have, in addition to the usual optional arguments, the following arguments:
3.4 S i z e - C h a n g i n g Comma n d s -Φ 5 7
Table 3.8: Size-changing commands.
Visual Result
Input Command
tiny size
script size footnote size small size normal size
large size Large size
L A R G E s i z e h u g e s i z e
H u g e s i z e
{\t i n y t i n y s i z e }
{\s c r i p t s i z e s c r i p t s i z e }
{\f o o t n o t e s i z e f oot not e s i z e } {\s mal l small s i z e } {\normal size normal s i z e } {\l a r g e l arge s i z e }
{\L a r g e La r g e s i z e }
{\LARGE LARGE s i z e }
{\huge huge s i z e }
{\H u g e Huge s i z e }
Parameter
Brief Description
8pt
Normal font size at 8 pt
9pt
Normal font size at 9 pt
14pt
Normal font size at 14 pt
17pt
Normal font size at 17 pt
20pt
Normal font size at 20 pt
>- Exercise 3.5 Suppose that one wants to prepare a book at 8 pt and an article at 14 pt. Write down the corresponding \documentc l a s s command. □
Now, suppose that for some reason you want to typeset a document at 16.35 pt and you do not want to go to the trouble of creating a new document class. Then, you have to go to the l ow-level interface commands. I^T^X provides the command
\f ont s i z e {.s i z e Msfcip)-
where s i z e is the size of the font and s k i p is the size of the baseline skip. By "baseline skip" we mean the distance between two consecutive lines of text. Note that if we require really big sizes we must change the baseline skip so that the lines are nicely spaced apart. Sizes can be followed by units such as centimeters (cm) or inches (in). If we do not write a unit, I5Tp;X will assume units of points. Of course, such a low-level command must be followed by the \s e l e c t f ont command:
{\f o n t s i z e {. 5cm}-Cl6pt}\selectf ont type at 0.5cm}
{\f o n t s i z e {.5 i n } { 2 0 p t }\s e l e c t f o n t type at 0.5 i n }
However, even in this case, the user may not be happy. This is because ETeX will choose a size close to what has been requested, but not exactly this size. As we run it
will warn us with a message such as
58 ·<>· 3 F o n t s a n d T h e i r U s e
LaTeX Font Warning: Si z e s u b s t i t u t i o n s with d i f f e r e n c e s (Font) up t o 11.25499pt have occurred.
The reason is that it does not know whether or not you will request sizes for subscripts or superscripts (for example, for math formulas), and then it has to compute the relative sizes to the size asked. This makes things difficult, and that is why will usually
make a choice close to, but not exactly, the size that you request.
In order to force a certain size, you have to use primitive commands of TgX. To do this, you also need to know the font that will be used. For example, if one wants to use cmr at 16.35 pt and Times at 14.2 pt, the commands \mycmr and \mytimes must be defined by
\font\mycmr=cmrlO at 16.35pt \font\mytimes=ptmr7t at 14.2pt
where \f ont is TgX's primitive font-selection command. Note that one needs to know the internal name of the font in order to call it properly. Now, it is possible to write
{\mycmr The cmr-font at 1 6.35points}- and -CVnytimes The Times-font at 14.2points)-
and get
The cmr-font at 16.35points The Times-font at 14.2points.
What you pay for this is that you should not expect the regular size-changing commands to cooperate with the commands that you defined above. But this may be irrelevant to your application. It is also possible to refine the DT^X sizes so that its choices are even better. However, this means that you have to define new math sizes as well. This is done using the \DeclareMathSizes command. We will see how to use this command in Chapter 12.
V Exercise 3.6 Typeset the following:
Starting with large typewriter typeface GOING ON WITH LARGE SMALL CAPITALS
and ending with small sans serif bold typeface. □
>· Exercise 3.7 Typeset the following:
This is the Pandora font family at
13.3pt 2 1.5 p t 34.8pt
□
3-5 A d v a n c e d A cce nt s 59
3.5 Advanced Accents
a T^X's primitive command \accent is used to place accents over letters. The syntax
of the command is as follows:
• \ \a c c e n t n u m b e r l e t t e r
where n u m b e r is a decimal number, an octal number, or a hexadecimal number denoting the position of an accent in a font that will be placed on the l e t t e r (possibly in some other font!). However, this command has several weak points that the package accentbx by A.S. Berdnikov attempts to overcome by defining new macros similar to the \accent command. Several languages, for example the Nivh or the Saam (Lappish) languages, need multiple accents on a letter. They can be above, below or in the middle of the glyph to be accented. There are also cases where accents must be placed between letters, as in the German abbreviation for the ending -burg. Here are some examples:
E C X OA X St. PetersHg
Even more impressive is the fact that a standard font change, such as switching to italics, preserves the position of the accents. Here is the example above after issuing \itshape:
έ ( X OA X St. Petersbg
This means that the package is capable of doing arithmetic and calculating the proper position of the accents after a slope change.
Let us see how the package is used. TTie first command that one wants to know
i s
\u p a c c e n t { a c c e n £ M c h a r a c t e r >
This command places the a c c e n t's box above the box of the c h a r a c t e r. Most of the time, we need to separate these two boxes by some vertical space. This is achieved with the command \aboxsplit{accen£ > (see in Figure 3.6 the letter T). Qn the other hand, the accent may already be raised in its box. This additional vertical space must be eliminated; this can be done with the command \abox-
shif t{accent > (see in Figure 3.6 the letter E). We may also have an accent that
extends below the baseline (has depth), such as the comma character; these need additional shift. The command \a b o x b a s e
{ a c c e n t
> shifts the accent so that it is
entirely above the baseline (see in Figure 3.6 the letter X).
Middle accents, as in the -burg abbreviation, are produced by inserting a zero- width rule of height equal to the height of the letter x and accenting this rule. The rule is produced by the command \markchar. Thus, the code for the -burg abbreviation is
S t. ~ P e t e r s b\u p a c c e n t {\a b o x s h i f t {\s y m b o l { ’ 1 0 » H\m a r k c h a r } g
6ο -φ- 3 F o n t s a n d T h e i r U s e
\f ont encoding{Tl}-\selec t font T \u p a c c e n t {. }{T}
T \u p a c c e n t {\a b o x s p l i t {.}}{T}
E \upaccent-[\symbol-[ ’ 001}M\"E}
E \u p a c c e n t{\a b o x s h i f t {\s y m b o l { J 001}}}-[\"Ε}
^ \u p a c c e n t - [\a b o x s p l i t {, }MX)-
J
X \u p a c c e n t {\a b o x s p l i t {\a b o x b a s e {, }}}{X}
Figure 3.6: Code of the examples.
Of course, one may define shorter forms of these long commands with the defini­
tion of a new command, for example
\newcommand-C\burg}-T/0
b\upaccent{\aboxshif t{\symbol{ ’ 10}}}{\markchar}g}
and then type S t. Peters\burg. If we want to use the same construction for capitals, then the invisible rule of height equal to the height of x must now have the height of X. The corresponding command is \MARKCHAR:
\newcommand-[\BURG}{%
\upaccent{\aboxshif t{\symbol{ ’ 10}]-]-{\MARKCHAR]-G]·
It is useful to substitute the \aboxshif t by its robust version \Aboxshift, espe­
cially when we change the case of the words with the commands \MakeUppercase and \MakeLowercase (for example, in running heads). Then, the commands
\MakeUppercase{st. peters\burg} and \MakeLowerc as e{ST. PETERSBURG}
will give the correct output.
Putting accents on letters may break other properties of a font. One of them is kerning information. The package also provides the means to correct this by the command \akern. The following example shows its use:
w a
AW
\u p a c c e n t {\a b o x s p l i t {\t i n y w}}-{A3-0/o
\u p a c c e n t {\a b o x s p l i t {\t i n y a}MW}
AW
\u p a c c e n t {\a b o x s p l i t {\t i n y w}}{A}\akern AW%
\u p a c c e n t {\a b o x s p l i t {\t i n y a}}{W}
Several commands are available with the package for fine-tuning accents. We refer the interested user to the package's documentation or to the article by the author of the package in [2] (available online from http: //obelix. e e. duth. gr/ eft).
> Exercise 3.8 Write down the commands that created the phonetic tran­
scriptions of Navaho words in Section 3.2.3. □
Lists a n d C atalogs
In many cases, one may want to write a series of names, words, or other items one after the other. This is commonly known as a list. Moreover, in many cases, users want to be able to write an itemized display (e.g., titles, course offerings, or articles for exhibition or sale) usually including descriptive information or illustrations. This is commonly known as a catalog. Since lists and catalogs are very frequently used in printed text, LM£X offers a variety of environments that can be used to produce any possible list or catalog. Furthermore, it provides environments suitable for the typesetting of poetry and quotations, among others. Tn this chapter, we present these environments and their uses. Although alignment is a subject that does not comfortably fit in this chapter, we include the relevant discussion here as we think this is the most appropriate place for this material.
4.1 Units of Measure
Donald Knuth designed ΤβΧ so that one can fully use the metric system of units. Since most English-speaking countries still use the imperial system of units (contrary to their legislation most of the time), TgX was designed to be able to work with this system, too. Moreover, since the English-speaking world uses the period to separate the integer part of a number from the decimal part while the rest of the world uses the comma, Tfy< recognizes both forms of number writing to facilitate its use all over the world. The
various units of measure that T^X understands are presented in Table 4.1. Note that T^X cannot handle any length whose absolute value is greater than or equal to 230 sp; that is approximately, 575.83 cm. Now that we know all of the units of length that T^X understands, it is important to say how we can write a particular length. Any valid TgX length consists of an optional sign, followed by an optional decimal or integer, followed by a unit of length. The unit of length can be separated from the number by one or more spaces. As we mentioned above, when we have a decimal number, the integer part can be separated from the decimal part by a comma or a period. Here are a few examples of valid TgX lengths:
62 <>- 4 L ists a nd Ca t a logs
Table 4.i: Units of measure and their relationships.
Symbol
Unit Name
Equivalence
pt
point
l p t = 0.013837 in
pc
pica
1 pc = 12 pt
in
inch
1 i n - 72.27pt
bp
big point
72 bp = l i n
cm
centimeter
1 in = 2.54 cm
mm
millimeter
1 mm = 0.1 cm
dd
didot point
1157 dd = 1238 pt
cc
cicero
1 cc = 12 dd
sp
scaled point
65536 sp = 1 pt
3 in
-.5 cm
+3,14 dd -,p t
Although the fourth length looks quite peculiar, it is actually equal to 0 pt!
Apart from the absolute units above, ΤβΧ supports two more relative units, which depend on the font that is currently in use. This means that their actual length depends on which font we use. These units are the em and the ex. One em is a distance equal to the type size. In 6 point type, an em is 6 pt; in 12 pt type, it is 12 points, and so on. Thus, a one-em space is proportionately the same in any size.
□ □ U I_____
\t i n y em \normalsize em \Large em \huge em
One ex is a distance equal to the "x-height" of the current font. This particular unit of measure is not widely used outside of the ΤβΧ world. If we are using the Computer Modern fonts by Knuth, one ex is equal to the height of the small letter x.
□ □ □
\t i n y e x \normalsize ex \Large ex \huge ex
In general, the em is used for horizontal spacing and the ex for vertical spacing.
>- Exercise 4.1 Put the following lengths in ascending order:
123456789 sp 101.7 dd 2.5 in
33 pc 45 mm 0.89 cm
1.9 cc 536bp 674 pt
□
>- Exercise 4.2 How many points are in 254 cm? □
4-2 Typesetting P oetry -φ- 63
4.2 Typesetting Poetry
Although Ι^ΤβΧ is a typesetting system particularly well-suited for the preparation of manuscripts containing a lot of mathematics, it can be used to typeset poems by using the verse environment, which has been designed to facilitate the typesetting of poems. Here is a simple example that demonstrates the environment:
To a Young Poet
Time cannot break the bird's wing from the bird.
Bird and wing together Go down, one feather.
No thing that ever flew,
Not the lark, not you,
Can die as others do.
\b e g i n { v e r s e }
\emph{To a Young Poet}
Time cannot break the b i r d's wing from the b i r d.\\
Bird and wing t o g e t h e r\\
Go down, one f e a t h e r.
No t h in g t h a t ever f l e w,\\
Not the l a r k, not y o u,\\
Can d i e as others do.
\e n d { v e r s e }
The poem above is by Edna St Vincent Millay, 1892-1950.
While in the verse environment, verses are separated by the command \\ and stanzas by a blank line. Note that one must not put the command \\ at the end of a stanza. Moreover, the title of the poem is separated from the poem itself by a blank line. Certainly, one can use other environments to produce fancy results, but we have not introduced them yet, so we skip this issue. We have already used the \\ command, bnt here we present all three forms of this command as well as the functionality of each form:
\\ This command simply forces TgX to prematurely break a line at the point where the command is placed.
\\* In case we just want to break a line and prevent a possible page break, we use this form of the command.
\\ [length] When TgX breaks a line, usually it does not add any additional vertical space between the two consecutive lines. However, if for some reason we want to put some additional vertical space, we use this form. The l e n g th is just a valid TgX length (e.g., 1 cm, 0.5 in, etc.).
Note that it is possible to use a combination of the second and third cases. However, there is a special case that we must be able to deal with. Suppose that we want to force to break a line at some point and then we want to write something enclosed in square brackets, for example,
\\ [yeah!]
64 ^ 4 L i s t s a n d C a t a l o g s
The code above will make WgX complain that a number is missing. It is important to note that the space between the \\ command and the character [ is actually ignored by Ι^ΤβΧ so it assumes that the user wanted to specify a length. The solution to this unusual problem is to enclose the left square bracket in curly brackets, that is,
• · · \\ { [ } y e a h!] .. .
Admittedly, using Ι^ΤβΚ can be quite tricky sometimes!
>- Exercise 4.3 Typeset the following poem such that the line space between verses is exactly 3.5 pt.
Autumn Song
Soon we will plunge ourselves into cold shadows,
And all of summer's stunning afternoons will be gone.
I already hear the dead thuds of logs below Falling on the cobblestones and the lawn.
All of winter will return to me:
derision, Hate, shuddering, horror, drudgery and vice,
And exiled, like the sun, to a polar prison,
My soul will harden into a block of red ice.
I shiver as I listen to each log crash and slam:
The echoes are as dull as executioners' drums.
My mind is like a tower that slowly succumbs To the blows of a relentless battering ram.
It seems to me, swaying to these shocks, that someone Is nailing down a coffin in a hurry somewhere.
For whom? -It was summer yesterday; now it's autumn.
Echoes of departure keep resounding in the air.
--Charles Baudelaire
(translated from French by Steven Monte)
The poem was originally published in the Boston Reviews and is reproduced with kind permission from the translator. □
4.3 Lists
Ι£ΓβΧ provides three different environments that can be used to typeset lists and cata- logs.The environment enumerate can be used to typeset numbered lists such as those usually found in the exercise sections of a textbook. Here is a simple example:
4-3 L i s t s 65
1. Write the missing dates in words:
(a) (17/5) I Norge liras...
(b) (14/7) Fransmanne firas...
2. Answer the following questions using dit/dar/hit/har:
(a) Var ar du? (here)
(b) Var ligger staden? (there)
\be gi n- [ enumer at e}- \i t e m W r i t e t h e m i s s i n g d a t e s...: \begi n- Ce nume r a t e }
\i t e m ( 1 7/5 ) I Norge f i r a s\l d o t s \i t e m ( 1 4/7 ) F r a n s m V'a n n e... \e n d { e n u m e r a t e }
\i t e m Answer t h e f o l l o w i n g...
\t e x t b f { d i t /d\ " a r/h i t/h\ " ar }-: \begi n- [ e nume r a t e } - \i t e m Var \"a r d u?(\t e x t i t { h e r e } ) \i t e m Var l i g g e r s t a d e n?...
\ end{enume r a t e }- \e nd{enumer at e}-
As is evident, each list item starts with the command \i t e m. Note that if the first thing that you type in the body of the environment is not a \i t e m command, Ι^ΤβΧ will not be able to process your file. This holds for all environments presented in this section. Moreover, it is possible to have nested environments, such as those in the example above. LTgX supports up to four levels of nesting. In order to avoid confusion, the numbering in each nested environment changes so that each item is uniquely numbered. However, there are cases where we are not interested in numbering the items of a list; that is, we want to create an unnumbered list. In this case, we have to use the i t e m i z e environment:
The 1/0 system consists of
• A buffer-caching system
• A general device-driver interface
• Drivers for specific hardware de­
The \t e x t s c { i/o } system c o n s i s t s of \begin-[itemize}- \i t e m A b u f f e r - c a c h i n g system \i t e m A g e n e r a l d e v i c e - d r i v e r i n t e r f a c e
vices
\i t e m D r i v e r s f o r s p e c i f i c hardware d e v i c e s \end{itemize}-
The last supported list environment is the description environment, which can be used to create simple glossaries, among other things. Here is a simple example:
0
Angstrom A unit of measure corre­
sponding to one ten-billionth of a meter.
Amino acid Basic building blocks of
\b e g i n { d e s c r i p t i o n }
\item[\AA ngstrom] A u n i t o f... \i t e m [Amino a c i d ] Basic b u i l d i n g... \i t e m [ A r t i c u l a t i o n ] Movements o f...
p r o t e i n s.
A r t i c u l a t i o n M o v e m e n t s o f t h e v o c a l t r a c t t o p r o d u c e s p e e c h s o u n d s.
\e n d { d e s c r i p t i o n } -
T h e o n l y t h i n g t h a t w e m u s t n o t e i s t h a t e a c h t e r m m u s t f o l l o w t h e c o m m a n d \i t e m i n s q u a r e b r a c k e t s.
6 6 4 L i s t s a n d C a t a l o g s
>- Exercise 4.4 Explain how one might typeset a dictionary using LMeX. □
The enumerate package by David Carlisle redefines the enumerate environment and gives it an optional argument that determines the style in which the label is printed.
An occurrence of one of the characters A, a, I, i, or 1 causes the environment to
produce labels that are either uppercase or lowercase alphabetic or Roman numerals or numbers, respectively. These letters may be surrounded by any string involving other KT^X expressions; however, in this case, the letters A, a, I, i, and 1 must be enclosed in curly brackets if we do not want them to be taken as special. Figure 4.1 shows a usage example of the environment provided by the enumerate package.
\begin{enumerate}[EX i.]
\it e m one one one one
\it em two two two two
\b egin{enumerate}[ {exampl e} a ) ]
\itera one of two \item two of two \end{enumerate}
\ en d { enuia e r at e }
\b e g i n { e n u m e r a t e } [ { A } - 1 ]
\item one \item two \end{enumerate}
Figure 4.1: A usage example of the enhanced enumerate environment.
4.3.1 Customizing the Standard Lists
A
lt is relatively easy to customize the three standard IAT^X list environments, and in this section vve describe how we can modify these environments to suit our needs. The changes can be either local or global (i.e., we can modify the environments so that the changes are visible only at certain parts of our document or throughout the whole document).
C u s t o m i z i n g t h e enumerate e n v i r o n m e n t
The enumeration labels depend on the value of the counters enumi, enumii, enumiii, and enumiv. Counter enumN controls the numbering of the Nth-level enumeration. The label for each level of enumeration is generated by the corre­
sponding \labelenumN command, which is usually defined by the document class
EX i. one one one one EX ii. two two two two
example a) one of two example b) two of two
A-l. one A-2. two
4-3 L i s t s 67
in use. The output of a \r e f command is a sequence of characters (also called a string) generated by the \p@enumN\theenumN commands. The command \p@enumN is provided by the document class in use. For instance, the following definitions appear in the a r t i c l e document class:
\renewcommand\theenumii{\alph{enumii}} \newcommand\labelenumii{(\theenumii)}
\renewcommand\p@enumii{\theenumi}
Note that the command \p@enumN actually prints the prefix of the reference. For example, when referring to the second item of the third sublist, the actual label will be "3(b),” and the "3" is printed by the \p@enumN command. If we want to redefine any of the pOenumN commands in our document's preamble, we first have to type the command \raakeatlett er, then the redefinition, and then the command \makeatother. Since in any lAT^X document the symbol @ has a category code equal to 12, we use the first command to make Φ a letter (category code 11) and the second to switch back to the original category code.
>■ Exercise 4.5 Provide definitions for the command Vnakeatletter and \makeatother. dl
We now give a complete example to demonstrate how one can modify enu­
merations. Suppose that we want the labels in the first enumeration level to appear as capital Roman numerals prefixed by the paragraph symbol (§) while we want to have a hyphen between the paragraph symbol and the Roman numeral in the labels generated by the \r e f command. Here is how this can be done:
§1 First item §11 Second item §111 Third item
V n a k e a t l e t t e r
\renewcommand{\theenumi}{\Roman{enumi}} \renewcommand-[\labelenumi )"C\S\theenumi } \renewcommand{\p@enumi}{\S-}
\makeatother
label wl=§-I,
\begin{enumerate}
label w2=§-II
\i t e m\l a b e l { w l } F i r s t item
\i t e m\l a b e l { w 2 } Second item
\i t e m\l a b e l { w 3 } Third item
\end-Cenumerate}
l a b e l w l =\r e f { w l }, l a b e l w2=\ref{w2}
C u s t o m i z i n g t h e i t e m i z e e n v i r o n m e n t
The itemization within an itemize environment is controlled by four commands:
second-level list use an em dash as its label, we use the following command:
\renewcommand{\labelitemii}{\normalfont ----- }
If we want to use any of the dingbat symbols on page 49, we have to use the pifont package by Sebastian Rahtz. This package provides the command \Pisym- bol, which must be supplied with two arguments: the name of the font and a slot
6 8 <>- 4 L i s t s a n d Ca t a l o g s
number (corresponding to the symbol that we want to access). Usually the font is pzd (PostScript Zapf-Dingbats), and the slot number (in octal) can be determined from the table on page 49. Here is a simple example:
© First item \renewcommand-[\labelitemi}-[\Pisymbol-Cpzd}-C ’ 112}}
O Second item \begin{itemize}
\item First item
© Third item © Fourth item
\item Fourth item \end{itemize}
C u s t o m i z i n g t h e d e s c r i p t i o n e n v i r o n m e n t
The appearance of the labels used in a description environment is controlled by the \descriptionlabel command. The standard definition is as
\newcommand{\descriptionlabel}[1]
\hspace{\labelsep}\normalfont\bfseries #1}
where \l a b e l s ep is the space between the end of the label box and the text of the item. In the following example, the description label is in boldface sans serif.
Perl A program­
ming language
Java Another pro­
gramming lan­
guage
T^X A typesetting system
>■ Exercise 4.6 For each list level lATgX defines the length \l e f tmarginN, which controls the amount of white space that it leaves before it typesets the
\renewcommand{\descriptionlabel}[1]
\hspace{\labelsep}\textsf{\textbf{#1}}} \begin{description}
\item[Perl] A programming language
\end{descript ion}
label of a particular item. Produce the enumeration of page 66 by changing the value of the length \l e f tmarginii. □
4.4 Quotations
A quotation is an explicit reference or allusion in an artistic work to a passage or element from another, usually well-known work. Since the use of quotations is very frequent
in all kinds of scientific and scholarly writings, LTjiX provides two environments for the correct typesetting of quotations. The environment quote is used mainly for short quotations. Qn the other hand, the environment quotation is used mainly for multi­
paragraph quotations. Certainly, one can also use the quote environment for multi­
paragraph quotations, but then does not do proper paragraph indentation (i.e.,
the first word of a new paragraph is not indented). This difference is evident in the following example:
4-5 Footnotes 69
Before the quote environment.
This is a quote. This is a quote.
This is a quote. This is a quote.
This is a quote. This is a quote.
This is a quote.
After the quote environment and be­
fore the quotation environment.
This is a quotation. This is a quotation. This is a quotation.
This is a quotation.
This is a quotation. This is a quotation.
After the quotation environment.
Before t h e q u o t e... \b e g i n { q u o t e }
This i s a q u o t e.
This i s a q u o t e...
This i s a q u o t e... \e n d { q u o t e }
A f t e r t h e q u o t e... \b e g i n { q u o t a t i o n }
This i s a q u o t a t i o n. This i s a q u o t a t i o n...
This i s a q u o t a t i o n... \e n d { q u o t a t i o n }
A f t e r t h e q u o t a t i o n...
As is obvious from this simple, yet complete example, both environments leave some extra vertical space before and after the quotations. Moreover, special care is taken so that the quotation text appears centered on the page.
4.5 Footnotes
A footnote is a note placed at the bottom of a page of a book or manuscript that comments on or cites a reference for a designated part of the text. However, it is assumed to be a bad practice to use footnotes in a text, mainly because they do not allow the reader to focus on the main text. Despite this, IftTpX does provide the command \f ootnote to facilitate the creation of footnotes in a text:
Text1 with footnotes5.
1A footnote
5Another footnote
T e x t\f o o t n o t e { A f o o t n o t e } w i t h f o o t n o t e s\f o o t n o t e [ 5 ] {Another f o o t n o t e }.
From the example above, one can easily deduce that all one has to do in order to create a footnote is to write the command \f ootnote next to the word where the footnote mark is to appear. The text of the footnote follows the command and must be enclosed in curly brackets. A \f ootnote command can have an optional argument, enclosed in square brackets, which, when present, will be used to typeset the footnote mark.
Suppose that in one document we have a complicated enumerated list with very many footnotes. In addition, suppose that we want to have the text of all footnotes placed at the end of this enumerated list. In order to provide a solution to problems such as these, Ι^ΤβΧ provides the following commands:
\footnotemark[number]
70 <>- 4 L i s t s a n d Ca t a l o g s
The \f ootnotemark command produces just the footnote mark in the text, but not the footnote text. The optional argument is present and it is used to create the footnote mark. Otherwise, I^TgX increments the footnote counter before generating the actual text. The \f ootnote t e x t command produces the actual footnote text. If the optional argument is present, it is used to produce the footnote mark inside the footnote.
text text text66 text text t e x t t e x t t e x t\f ootnotemark [66]
text t e x t t e x t t e x t
«footnote footnote foot- M ° ° t n o t e t e x t [66] { f o o t n o t e. . . >
note
In many instances, people want to be able to use footnotes even in section headers, as in the following example:
\documentclass-C a r t i c l e }
\begin{document}
\s e c t i o n { T e x t\f o o t n o t e { f o o t n o t e } } t e x t t e x t t e x t.
\end{do cument}
If we feed this file to L?TeX, we get the following error message:
! Argument of \@sect has an e x t r a }. c i n s e r t e d t e x t >
\p a r
1.3 \s e c t i o n { T e x t\f o o t n o t e { f o o t n o t e } }
7
Admittedly, this error message is not helpful at all. But, LTjnX complains with this weird error message simply because we are not allowed to use the \f ootnote command as an argument of the \s e c t i o n command. (If you have actually tried this example, press x after the ? to force ΗΓβΧ to abandon the processing of your file.) So, is it impossible to have a footnote in a sectioning command or is there something else we can do? Actually, we can have a footnote in a sectioning command, but we must protect it since the \f oot- note command is a fragile command. Any command that accepts an optional argument (i.e., an argument in square brackets) is a fragile command. Non-fragile commands are called robust. So, how do we protect a fragile command when it happens to be the argument of another command? We put the \p r o t ec t command just before the
command that we want to protect. Let us now correct the file above:
\s e c t i o n { T e x t\p r o t e c t\f o o t n o t e { f o o t n o t e } }
Suppose now that we want to generate the table of contents for this document. If we inspect the resulting DVI file, we will notice that the footnote mark is included in the table of contents. The solution to this problem is as follows:
4 5 Footnotes 7 1
\s e c t i o n [ T e x t ] { T e x t\p r o t e c t\f o o t n o t e { f o o t n o t e } } That is, we simply use the optional argument of the sectioning command.
4.5.1 Customizing Footnotes
Δ
Until now, we have seen how to use the various footnote-related commands, but it is possible to customize the appearance of footnotes (i.e., we can change the appearance of the footnote mark, the footnote text, and the footnote rule). By default, the \f ootnote command uses the \f ootnotesize font size to typeset the body of a footnote. However, one can easily change this behavior. Let us suppose that we want the footnote text to be typeset in \normalfont size. Before we go on with the solution to this problem, we must explain the functionality of the \l e t command. Tf \a and \b are two commands, the command \l e t\a\b makes command \a behave exactly like command \b. Now, we give the command that achieves the desired functionality:
\let\footnotesize\normalsize
>■ Exercise 4.7 The solution above permanently alters the meaning of the command \footnote so one cannot typeset text in \footnotesize. Can you devise a solution that remedies this drawback? □
\let\myfootnotesize\footnotesize \l e t\f ootnotesize\normalfont
Now, a footnote can appear in the original size if we type it as follows:
\footnote{\myfootnotesize footnote}
The space between the main text and the footnotes is equal to the length stored in the length variable \skip\footins. Moreover, the space between footnotes is equal to the length stored in the length variable \f ootnotesep. The \f ootnotesep is actually a strut that is placed at the beginning of each footnote. The height of the footnote rule is roughly equal to
\s k i p\f ootins - \f ootnotesep = 3pt
The values of these lengths can be altered with the commands \setlength and \addt a length.
If we want to change the appearance of the footnote rule we must redefine the \f o ot n ot e r u l e command. The following definition is equivalent to the definition provided by the TAT^X kernel:
\newcoimnand{\f ootnoterule}-C\vspace*{-3pt}
\noindent\rule{2in}{0.4pt}\vspace*{2.6pt}}
72 <>- 4 L i s t s a n d Ca t a l o g s
The interesting thing with the command above is that it makes TgX believe that the footnote rule has height equal to zero! So, suppose now that we want a footnote rule with width equal to 5 in and height equal to 1.5 pt; then, if we put the following redefinition in the preamble of our ΐΑΤ|ϊΧ document
\renewcommand{\footnoterule}{\vspace*{-3pt} \noindent\rule{5in}{l.5pt}\vspace*{l.5pt}}
we will get the desired effect. Note that if we want to have a footnote rule with a height greater than 3 pt, we have to modify the first vertical spacing command accordingly and the values of the variables \skip\f ootins and \f ootnotesep.
>■ Exercise 4.8 How can we instruct LiT'gX to draw a footnote rule with length equal to the text line length and height equal to 4 pt? □
The appearance of the footnote mark is controlled by the command \@make- f nmark. The following definition is equivalent to the standard one:
\newcommand{\<@makef nmark}
\mbox{\textsuperscript{\normalfont\@thefnamrk}}}
The counter VDthef nmark is used to number footnotes. If we want to redefine the command above in our document's preamble, we first have to type the command \make at letter, then the redefinition, and then the command \makeatother. The following code sets the footnote number in boldface, surrounded by parentheses:
\renewcommand{\@makefnmark}{\mbox-[%
\textsuperscript{\normalfont ({\bf s e r i e s \<§thef nmark})}}}
Note that the character % is used to avoid unwanted space.
The appearance of the text of a footnote is controlled by the command \@make- fntext, whose definition, in the case of the article document class, is equivalent to the following:
\newcommand\@makefntext[1]{%
\s e t l e n g t h\p a r indent {lem}0/,
\noindent
\makebox[l.8em][r]{\@makef nmark}#1}
Ihe control sequence \par indent is a predefined length whose value is used for paragraph indentation (i.e., the amount of space that TgX leaves at the beginning of a new paragraph). So, if we want the text of footnotes to appear in italics, and
the footnote mark to be just the footnote number followed by a period, we can use the following redefinition:
\renewcommand\@makefntext [1] {7,
\setlength\parindent{lem}%
\noindent
\makebox[1.8em][r]{\@thefnmarkΛ }{\itshape#!}}
4 5 Footnotes 73
4.5.2 Endnotes
In scholarly work, it is common practice to have all footnotes at the end of a chapter or section, or even at the end of a document. Since such a facility is not provided by Ι^Τ^Χ, one has to use the endnotes package, originally developed by John Lavagnino. The package has been further modified by Jorg Knappen and Dominik Wujastyk. The package provides the following commands:
\endnote{M?te} This is the user command to produce an endnote, and Not e is the text of the endnote.
\endnote [Num] { No t e } A command to produce an endnote numbered Num. \endnotemark [Num] A command to produce just the endnote mark in the text but not the endnote. With no argument, it steps (increases by one) the endnote counter before generating the mark.
\endnotetext [Num] { T e x t } A command to produce the endnote but no mark. The command \endnote is equivalent to
\endnotemark \e n d n o t e t e x t
\a d d t oendnot es{ Text > A command to add text or commands to the current endnotes file and used for inserting headings, page breaks, and so on The Text must be \p r o t e c t e d.
From the preceding description of the user commands, one can conclude that the package writes all endnotes in a separate file that is included in the document after all of the input files have been processed.
Δ
Endnotes can be customized exactly like footnotes. Here, we present only the com­
mands that affect the appearance of endnotes. Readers interested in experimenting with these commands should read the corresponding discussion for footnotes in Section 4.5.1.
\e n o t e s i z e With this command, we can change the font size used for end­
notes.
\theendnote This command is used to produce the endnote number. \<5theenmark This holds the current endnote's mark.
\@raakeenmark A macro to generate the endnote marker from XQtheenmark.
\Oraakeentext{Note> Produces the actual endnote using VStheenmark as the mark of the endnote and Note as the text.
74 & 4 L i s t s a n d C a t a l o g s
4.6 Simulating Typed Text
If you browse a computer program manual, you will notice that it contains simulated typed text, which shows what the user types to achieve a particular effect. For example, a Unix manual may contain simulated typed text to demonstrate the use of the various commands. The \t t f amily declaration produces a typewriter text style, but it does not stop TgX from breaking the text into lines as it sees fit. For this reason, I^TfiX provides two environments and two commands that perform no formatting upon their arguments (i.e., they allow you to type the text exactly the way you want it to appear in the document). The commands are used for short pieces of text that can fit on one line, whereas the environments are used for longer pieces of text. The two environments are called v e r b a t i m and verbatim*. Their only difference is that the second makes spaces visible by substituting each space character with the symbol u- Below, we give a simple example to demonstrate the use of these two environments:
A little Perl program:
p r i n t "Hello World!\n" i f 1;
Another little Perl program:
print_"Hello_World ! \n"_while_l;
A l i t t l e P e r l program:
\b e g i n { v e r b a t im}
print "Hello World!\n" if 1;
\end{verbatim>
Another l i t t l e P e r l program:
\b e g i n { v e r b a t i m * }
p r i n t "Hello World!" while 1;
\e n d {ver batim*}
The two commands are \v e r b and \v e r b *. They do exactly what the corresponding environments do. Their argument is delimited by a single character. However, one must be careful to choose as a delimiter a character that does not occur in the text:
S p e c i a l c h a r a c t e r s: $*/,“&_ S p e c i a l u c h a r a c t e r s:□$%"&_
\v e r b | S p e c i a l c h a r a c t e r s: $*/,“&_! \v e r b * + S p e c i a l c h a r a c t e r s:
From the example above it is evident that the special characters described in Section 2.1 are not "special" when used as arguments of either the commands or the environments. When using these commands or the environments, one must:
• Avoid using them as arguments of other commands and
• Keep in mind that there should be no space(s) between either the command \v e r b and the delimiting character or the tokens \e n d and {verbatim}.
Δ
There are two things that one can do to customize either the environments or the commands presented so far in this section. First, we can tell TATgX to use a different fixed-width font and second to prepend white space to each line. The IATgX kernel defines the command \verbatim<5f ont that defines the font to be used to typeset the text of the verbatim commands and environments. The standard definition of this command is
4-6 Si m u l a t i n g Typed T ext -φ- 75
\newcoimnand{\verbatim@f ont}{\normalf o n t\t t f amily}
For instance, if you want to use the Courier font instead of the default Computer Modern typewriter font as the verbatim font, then the following command will do the job:
\renewcoramand{\verbatim@font}{\usefont{OTl}{pcr}{m}{n}}
Prepending white space to each line of a verbatim environment means that we first define a new length and then change the definition of the command \verbatira accordingly. In the example that follows, we tell LM^X to prepend each line with 1 cm of white space:
\newlength\verbatimindent
\setlength{\verbatimindent}-[lcra}
\r enewcommand-C\verbat im} {%
\addtolength-C\@totalleftmargin}-[\verbatimindent}
\@verbatim \frenchspacing\@vobeyspaces \@xverbatim}
It is important to stress that one must copy verbatim (!) the code fragment above into a Ii^TjhX file and change only the length of the white space. Anything else may have unpredictable consequences.
4.6.1 Advanced Typed Text Simulation
Although the various commands and environments presented above are adequate for most cases, still there are many situations where a user might want additional functionality. For example, in a book on computer programming, it is convenient to prepend a line number to each line of a program listing. Here. we briefly present three packages that provide new environments and additional functionality to the commands presented above.
A n e w i m p l e m e n t a t i o n o f t h e v e r b a t i m e n v i r o n m e n t s
Rainer Schopf, Bemd Raichle, and Chris Rowley have designed the verbatim package that reimplements the v e r b a t i m I and the verbatim* environments. This reimplemen­
tation solves a few problems of the original implementation. In particular, they can better handle very long texts that are supposed to be output verbatim. In addition, the package provides a comment environment that skips any commands or text between \b e g i n { comment} and \end{comment}. Til is command is useful when one wants to comment out certain parts of a Ι^ΤβΧ file and, naturally, has no effect if used inside a v e r b a t i m environment. The package also defines the command \v e r b a t i m i n p u t, which can be used to input a whole file verbatim. The command has one argument, which is the name of a file that inputs verbatim; that is, the command \v e r b a t i m i n p u t { x x.yy}
has the same effect as
76 -φ- 4 L ists a nd C a t a logs
Xbegin-Cverbatim} Cont ent s o f f i l e xx.yy \end-Cverbatim}-
T h e moreverb p a c k a g e
The moreverb package designed by Robin Fairbaims, Angus Duggan, Rainer Schopf, and Victor Eijkhout provides things in three broad areas:
• Tab expansion and related stuff.
• Line numbering.
• Miscellaneous: writing verbatim to a file and “boxed" verbatim.
When using a verbatim environment, DTgX treats tabs as single-space characters. However, there are many instances where we want each tab to expand to a specific number of spaces. This functionality is provided by the verbatimtab environment. By default, the tab width is equal to eight space characters. Certainly, one can change this behavior easily by simply specifying the tab width as an optional argument. Here is a simple example:
t e x t t e x t t e x t t e x t t e x t t e x t
t e x t t e x t t e x t t e x t
t e x t
t e x t
\begin{verbatimtab)· t ex t o t e x t o t e x t
o tex t o t exto
0 0 t exto
t e x t t e x t t ex t o t e x t \end{verbatimtab}
t e x t
t e x t
In the previous example, the symbol 0 denotes the tab key. When using this environ- ment, one must have in mind that the size of the tabs persists between uses of the environment; that is, an optional argument to one of them applies to all subsequent ones.
The l i s t i n g environment numbers the lines of its body. The user must specify the start line and can also specify the number of lines between numbered lines. If the start
line is a number other than one, then the environment makes the assumption that the first line of its body has a line number equal to a start line.
\b e g i n { l i s t i n g > [ 2 ] { 4 }
4 l i n e one
l i n e two 6 l i n e t h r ee
l i n e one
l i n e two l i n e t h r ee
l i n e f our l i n e four
8 l i n e f i v e l i n e f i v e
\e n d { l i s t i n g }
The environment l i s t i n g c o n t continues from the place where the last listing left off. Both environments also expand tabs. Starred versions of both listing environments are
4-7 C entering a nd Flushing Text -φ- 7 7
provided; these print visual spaces (i.e., u) instead of ordinary spaces, and they do not expand tabs. The command \l i s t i n g i n p u t is a file input version of listing, and there is no starred version. So, if the text in the previous example is stored in a file, say t e x t. t x t, then the following command achieves the same visual effect with the command of this example:
\l i s t i n g i n p u t [ 2 ] { 4 } { t e x t.t x t }
The environment verbatimwrite takes one argument, the name of a file, and writes all text in its body to this file. The boxedverbat im puts its body in a framing box, but it makes no sense to use this environment in a naive way (i.e., outside any environment that reduces the line width).
T h e alltt p a c k a g e
The package alltt was designed by Leslie Lamport and has been adapted to LTeX2£ by Johannes Braams. The package provides the a l l t t environment, which is like the v e r b a t i m environment except that \, {, and } have their usual meanings. Thus, other commands and environments can appear in the body of an a l l t t environment. So, one can change fonts (e.g., by typing {\emph t e x t } ), include files, and insert a math­
ematical formula (see the next chapter). In particular, math mode can be started with either \ ( or \ [. Naturally, one ends math mode with a \) or \] correspondingly. More­
over, superscripts and subscripts can be produced with the commands \s p and \s b, respectively, so the simple formula x1· will be produced by the code
\( x\s p { i }\s b { j }\)
4.7 Centering and Flushing Text
When we say that a piece of text, a paragraph, and so on is flushed either left or right, this means that the text is aligned either to the left or the right edge of the page. Moreover, when we say that a piece of text is horizontally centered, this means that each line of the text is centered on the page. Naturally, the term page does not include the margins of the paper but only the area that is reserved by the typesetting system, ΐ^ΤβΚ in our case, for the text body. Since these features are extremely useful, provides three environments that allow its users to produced flushed or centered text. In Figure 4.2, we give examples of the environments f l u s h l e f t, f lushright, and center that are used to typeset text flushed left, flushed right, and centered, respectively. Note that LTgX inserts some space before and after each environment. It is possible to produce either a flushed left or flushed right document by using the declarations \raggedright or \ragged- l e f t, respectively. Moreover, a completely centered document can be produced with the declaration \centering. If we want to affect the typesetting part of a document,
we have to use these commands in a local scope. If we want to produce only one line
y 8 ^ 4 L i s t s a n d Ca t a l o g s
Lars Valerian Ahlfors was born in Helsingfors, Finland, on April 18, 1907. He studied mathematics with Ernst Lindelof at Helsingfors University and earned his doctorate in 1928.
Lars Valerian Ahlfors was born in Helsingfors, Finland, on April 18, 1907. He studied mathematics with Ernst Lindelof at Helsingfors University and earned his doctorate
in 1928.
Lars Valerian Ahlfors was born in Helsingfors, Finland, on April 18, 1907. He studied mathematics with Ernst Lindelof at Helsingfors University and earned his doctorate in 1928.
\b e g i n { f l u s h l e f t }
Lars Valerian Ahlfors was born in H e l s i n g f o r s, Finland, on April 18, 1907. He studied
\e n d { f l u s h l e f t }
\b e g i n { f l u s h r i g h t }
Lars Valerian Ahlfors was born in H e l s i n g f o r s, Finland, on April 18, 1907. He studied
\e n d { f l u s h r i g h t }
\b e g i n { c e n t e r }
Lars Valerian Ahlfors was born in H e l s i n g f o r s, Finland, on April 18, 1907. He studied
\e n d { c e n t e r }
Figure 4.2: Examples of the f lu s h l e f t, f l u s h r i g h t, and c e n t e r environments.
that is either centered or flushed left or right, we can use the corresponding commands \c e n t e r l i n e, \l e f t l i n e, or \r i g h t l i n e, as the following example demonstrates:
A centered line. A flushed left line.
\c e n t e r l i n e { A c e n t e r e d l i n e.} \l e f t l i n e { A f l u s h e d l e f t l i n e.}
A flushed right line.
\r i g h t l i n e { A f l u s h e d r i g h t l i n e.}
Note that these commands should not be used in the middle of a paragraph, as they generate a horizontal box with width equal to \li n ewid th (for more information on boxes, see Section 6.10).
4.8 Alignment
When we speak about alignment, we speak about the arrangement or position of words, numbers, and so on, in a straight line or in parallel lines. provides two basic
environments that can perform alignment: the tabular and the tabbing environments. In this section, we present the basic functionality of these two environments.
4-8 A l ign m e n t -φ- 79
4.8.1 The tabbing Environment
The tabbing environment can be used to align text in columns by setting tab stops and tabbing to them, just like people do when using an ordinary typewriter. Let us see a simple example:
The command \= defines a tab position. Tab positions are usually defined on the first line of a table, but as the example demonstrates, it is possible to define new tab positions in subsequent lines. The command \\ is used to change lines. However, if one uses the
within the t a b b i n g environment, one can use the command \ t a b u l a r newline. The command \> is used to jump to the next tab stop. Suppose that we want to define tab stops on a line that will only serve as the tab stops definition line (i.e., we do not want this line to appear in the final manuscript). Then we can prevent LTgX from including this line in the DVI file by appending the \k i l l command to this particular line, as the following example demonstrates:
The command \+ makes all following lines start from the second tab stop so that one has to specify one less \>. On the other hand, the command \- cancels the effect of the previous \+ for the following lines, while the command \< cancels the effect of the previous \+ command only for the current line. Note that this command can be used only at the beginning of a line. The command V causes the text preceding the command to be aligned to the right (the space between columns can be defined by the \t a b b i n g s e p, which is a predefined length variable). The corresponding command V moves the rest of the current line to the right. The line must be ended with \\. One can create a local scope for defining new tab stops with the command \p u s h t a b s. The command \p o p t a b s closes the local scope opened with the last \p u s h t a b s command.
If today is Sunday
\b e g i n { t a b b i n g }
I f t o d a y \= i s Sunday \\
then I will go to the beach, else I must go to the office
\> t h e n I \= w i l l go t o\\ \> \> t h e b e a c h,\\
\> e l s e I must go t o\\
\> \> t h e o f f i c e\\
Boy, I love Sundays!
Boy, I lo v e Sundays! \e n d { t a b b i n g }
tabbing environment within another environment and would like to break a line only
\begin-f t a b b i n g }
a b
c d
e
1 2 3 4\= 1 2 3 4\= 1 2 3 4\=\k i l l a \> b \\
\> c \> d \\
\>\> e
\e n d { t a b b i n g }
that are used less commonly.
8ο -φ- 4 L i s t s a n d C a t a l o g s
Since the tabbing environment redefines the meaning of the commands \=, \ *, and \ ‘, it provides the commands \a=, \a ’, and \a ‘, respectively, whose functionality is the same as that of the original commands. We conclude the section with an example that demonstrates the use of the commands just described:
1 2 3
a b b c ό e a
1 2 3 4
1 2 a b b c
\b e g i n { t a b b i n g }
12 \= 123 \= 1234 \= \k i l l 1 \> 2 \> 3 \> 4 \\ a \> b \+ \\ b\> c\> \- \\
\a>{o} \> \a ‘ {e> \> \a = { a >\\[ 1 2 p t ] \p u s h t a b s
1 2 3 4\= 1 2 3\= 1 2\=\k i l l 1 \> 2 \> 3 \> 4\\
\p o p t a b s 1 \> 2 \\ a V b \\ b \> c V a \end{tabbing)-
4.8.2 The tabular Environment
The tabular environment can be used to typeset tables with optional horizontal and vertical lines that separate rows and columns, respectively. Since Ii'TgX is a markup language, it automatically determines the width of the columns. As usual, we start with a simple example:
7d2
3722
11111010010
Hexadecimal
Octal
Binary
2002
Decimal
\b e g i n { t a b u l a r } { I r | 1 | } \h l i n e
7d2 & HexadecimalW
3722 & OctalW
11111010010 & BinaryW \h l i n e \h l i n e
2002 & \h l i n e
\e n d { t a b u l a r }
Decimal \\
The t a b l e s pe c of the command
\b e g i n { t a b u l a r } - Ct a b l e s p e c }
defines the format of the table. We use the letter 1 for a column of left-aligned text, the letter r for a column of right-aligned text, and the letter c for a column of centered text. The I symbol denotes that a vertical line will be drawn on the left-hand and/or the right-hand side of a column. In the body of the t a b u l a r environment, the character
4-8 A l ign m e n t -φ- 8 ι
& is used to separate the elements of each row, the command \\ starts a new line, and the command \h l i n e draws a horizontal line between rows of the table. Note that the \h l i n e command must be specified immediately after the \\ command. The t a b l e s pec allows the use of the p {.wi dt h} construct for a column containing justified text with line breaks; the text will be typeset on lines with length equal to wi dt h. For example,
\begin-[tabular }-{ | p-flOOpt}-1 }
\h l i n e
Here i s how one can c r e a t e a boxed p a r a g r a p h.\\
\h l i n e
\e n d { t a b u l a r } -
With the @{...} construct, it is possible to specify a column separator. This column specifier ignores the intercolumn space and replaces it with whatever is specified inside the curly brackets. If we want to suppress leading space in a table, we can use the ®{> column specifier:
no leading space
\begin{tabular}--[@Oc@-C}-]-
\h l i n e
no l e a d i n g s p a c e\\
\h l i n e
\e n d { t a b u l a r }
\b e g i n { t a b u l a r } { c >
\h l i n e
leading and trailing space
l e a d i n g and t r a i l i n g s p a c e\\
\h l i n e
\e n d { t a b u l a r j -
We will come back to this column specifier later in this section. The column specifier * { n u m} { c o l s }
is equivalent to num
copies of c o l s,
where num
is any positive integer
and c o l s is any list of column specifiers, including the * column specifier. In the following example, we show how one can draw a poor man's commutative diagram1 using the column specifier that we just described. The example uses the command \v l i n e to draw the vertical lines. This command, when used within an r, 1, or c item, produces a vertical line extending the full height (and depth) of its row. Note also that we use negative vertical spacing to bring the arrowhead closer to the arrow body.
Here is how one can create a boxed para­
graph.
1. Of course, we can produce much nicer diagrams using special IATjiX packages (see Section 5.4.11).
82 <>- 4 L i s t s a n d Ca t a l o g s
\b e g i n { t a b u l a r }
{c*-[4}-[@-(-----}}@{\texttt-C>}}c}
A & B \\ \b e g i n { t a b u l a r } [ b ] { c } {\L a r g e\t e x t a s c i i c i r c u m }\\[ - l l p t ]
\v l i n e\\ [lOpt] C \e n d { t a b u l a r } & \b e g i n { t a b u l a r } [b] {c} - C\L a r g e\t e x t a s c i i c i r c u m }\\ [ - l l p t ]
\v l i n e\\ [lOpt] D \e n d { t a b u l a r } \e n d { t a b u l a r }
The \multicoluim{niin?}{coI } · {.i t em} makes i t e m the text of a single column that temporally replaces num columns and is positioned as specified by c o l. In case num is equal to one, the command serves simply to override the item positioning specified by the environment argument. The c o l argument must contain exactly one of r, 1, or c and may contain one or more ..} column specifiers. The \cl ine{coij4-coi5}- command draws a horizontal line across columns c o l A through col B. Two or more \c l i n e commands draw their lines in the same vertical position. The following example demonstrates the use of these commands:
\begin{tabular}-C I r | | r@{—}-l | }
\h l i n e
\multicolumn-C33~C I c | }
{SUN Microsystems Stock}
\\ \h l i n e\h l i n e
& \m u l t i c o l u m n { 2 } { c | } { P r i c e } \\ \c l i n e { 2 - 3 }
\multicolumn-Cl}{ I c | |}{Month} &
\multicolumn{l}-Cr@{\vline}}{low}
& h i g h\\ \h l i n e
Jan 2001 & 25.438 & 3 4.8 7 5\\
\h l i n e
Dec 2000 & 26.938 & 4 5.8 7 5\\
\h1 irifi
(The data have been collected from h t t The following exercise assumes fa
Nov 2000 & 39.875 & 56.532W \h l i n e
\e n d { t a b u l a r }
;p: //www. n a s d a q. com.)
miliaritv with TkX math mode. Do it after vou
have read enough on the subject.
>- Exercise 4.9 Draw the following proof-net [7]:
SUN Microsystems Stock
Month
Price
low high
Jan 2001
25.438-34.875
Dec 2000
26.938-45.875
Nov 2000
39.875-56.532
A
A
> B
A
> D
4-8 A l i g n m e n t 83
Λ
y l 1 Β
A 1 © β
[Hint: Use the \phantom command to fool I^TpjX (see page 186). | □
The array environment is the math mode equivalent of the tabular environment. As such, it can be used only in math mode. Both environments can take an optional argument that specifies the vertical positioning: the default is alignment on the center of the environment. Letters t and b (i.e., the possible optional arguments) denote alignment on the top and bottom rows, respectively. The following example clearly shows the difference:
\b e g i n { t a b u l a r > [ b ] { c >
1 \\ 1 \\ 1 \\ 1 \\ 1
2
\e n d { t a b u l a r }
2
\b e g i n { t a b u l a r } { c } ·
2 3
2 \\ 2 \\ 2 \\ 2 \\ 2
2 3
\e n d { t a b u l a r }
2 3
\b e g i n { t a b u l a r } [ t ] {c}-
3
3 \\ 3 \\ 3 \\ 3 \\ 3
3
\e n d { t a b u l a r >
Note that each t a b u l a r environment is treated by TgX as a box (see Section 6.10). There is also a starred version of the t a b u l a r environment, which has the following general form:
\begin{tabular*3-{ u/idi/i} [pos] { t a b l e s p e c } rows \e n d { t a b u l a r * } where wi dt h is the width of the table.
A
The following parameters can be changed anywhere outside an a r r a y or t a b u l a r environment. They can be changed locally within an item, but the changes must be delimited by braces or an environment. By changing these parameters, one affects how the a r r a y and t a b u l a r environments create tables.
\arraycolsep One-half of the width separating columns in an a r r a y envi­
ronment. This parameter can be set with
\s e t l e n g t h\a r r a y c o l s e p {\t e x t i t { l e n } }
The same applies to all other lengths presented in this paragraph.
84 ·Φ· 4 L i s t s a n d C a t a l o g s
\tabcolsep One-half of the width separating columns in a tabular environ­
ment.
\arrayrulewidth The width of rules.
\doublerulesep The space between adjacent rules in array or tabular envi­
ronments,
\arraystretch Line spacing in array and tabular is done by placing the strut
\arraystretch x \strut in every row. The default definition of this parameter is as follows: \newcomraand{\arraystretchM 1}
Consequently, its value can be changed with a redefinition.
Nextrasep-Cmdtft. > This parameter is for use inside an ®{.. . > column spec­
ifier. It causes wi dt h space to be added between columns for the rest of the columns.
4.9 More on Alignment
A
The array package by Frank Mittelbach and David Carlisle provides an extended reimplementation of the L'TgX array and tabular environments. Based on the extended functionality provided by this package, David Carlisle has created the packages dcolumn, delarray, hhline, and tabularx. In this section, we will describe all of these packages and two other packages that are equally important: the package supertabular by Theo Jurriens and lohannes Braams, and the package longtable by David Carlisle.
7he dcolumn package
This package provi des a mechani sm for def i ni ng col umn entri es in an array or t abul ar envi ronment that are to be al i gned on a "deci mal poi nt." The package defi nes D to be a col umn specifi er wi t h three arguments:
D{.s e p - t e x } { s e p - d v i } { deci mal pl ac e s >
sep-tex will usually be' / or'but, in general, it can be any single character. The argument s e p- dv i is used as the separator in the output file. It should be noted that the package always uses math mode for the digits and the separator.The maximum number of decimal places in the column is specified by deci mal p l a c e s. One may not want to use all three arguments in the t abl e spec of an array or a tabular environment. Tn this case, one can create a column specifier using the command Xnewcolujnntype:
4.9 M o r e o n A l i g n m e n t -φ- 85
\newcolumntype{d} [1] {D{. } {\c d o t } {#l } } Here is a simple demonstration:
Pi expression Value
π 3.1416
36.46 80662.7
7Γ
n\n
{ π η )
The delarray package
\b e g i n { t a b u l a r } { c D {.} {. } { 4 } }
Pi e x p r e s s i o n ft \mb o x { Va l ue }\\ $\p i $ & 3.1416W
$\p i ~ {\p i } $ & 3 6.46W
$ (\p i ~ {\p i } ) ~ {\p i } $ & 8 0 6 6 2.7 \e n d { t a b u l a r }
This package al l ows the construction of arrays surrounded by deli miters wi t hout the need to expli citl y us e the commands \l e f t and \r i g h t. One has to put the left and the right deli miters before and after the col umn specifier, respectively:
a b \b e g i n { a r r a y }\l f l o o r { c c }\r f l o o r
c d a & b\\
c & d \e n d { a r r a y }
As one wo ul d expect, a nul l deli miter i s denoted by ".". In case one wants to provi de a function definiti on, it is possi bl e to write a construct such as the f ol l owi ng one:
\ne wc ol umnt ype { L} { >{ $} l <{ $} } \c h i _ { A } ( x ) =
\b e g i n { a r r a y }\{ { l L }.
1 fc i f $ x\i n A $\\
0 fc o t h e r wi s e \e n d { a r r a y }
(See the di scussi on on the array package for an explanation of the >{$} 1<{ $} col umn specifier.) In the case where we want to use the optional b and t placement specifiers, this package takes special care that the brackets have the expected hei ght and depth.
Xa (x ) =
1 if x G A 0 otherwise
The hhline package
This package provi des the command \h h l i n e, whi ch produces a li ne li ke the command \h l i n e, but it takes special care of intersections wi t h vertical li nes. The arguments to \h h l i n e are similar to the col umn spec of an array or a t a b u l a r environment. It consi sts of a l i st of symbol s wi t h the f ol l owi ng meanings:
= A doubl e \h l i n e the wi dt h of a column.
- A s i ngl e \h l i n e the wi dt h of a column.
A col umn wi t h no \h l i n e.
I A \v l i n e that "cuts" through a doubl e (or single) \h l i n e.
: A \v l i n e that i s broken by a doubl e \h l i n e.
8 6 -φ- 4 L i s t s a n d Ca t a l o g s
• A double \hline segment between two \vlines. t The top half of a double hline segment.
b The bottom half of a double hline segment.
• *{3}{==#} expands to ==#==#==#, as in the *-form for the column specifica­
tion.
If a double vertical line is specified, then the horizontal lines produced by \hhline are broken. To obtain the effect of a horizontal line "cutting through” the double line, one has to use a # or omit the vertical line specifiers. An example using most of the features of the \hhline command is
\begin{tabular}{I IccI IcIcI I}
\h h l i n e { I t:= =:t:= =:t I } a&b&c&d\\
\h h l i n e { | :==: Γ Γ Ι | >
1&2&3&4W \h h l i n e {#= =#~ | =#> i &j &k &l\\
\h h l i n e { | I — | | —1|>
w&x&y&z\\
\h h l i n e { | b:= =:b:= =:b | }
\e n d { t a b u l a r }
The array package
This package provides a new implementation of the tabular and array envi­
ronments. It introduces a number of new column specifiers, which are shown in Table 4.2. The new parameter \extrarowheight can be used to enlarge the normal height of every row of a table. This parameter is a length variable so it can be set with \s e t length. We will now briefly discuss a few examples that can be done using the new column specifiers.
• If one wants to use a special font in a left-justified column, one can use the >{f o n t } l column specifiers, where font is any font selection command.
• One can change the paragraph indentation in any column generated with
the p, in, or b column specifiers with the command \s e t l e n g t h. Remember that the paragraph indentation is stored in parameter \parindent.
• If one uses the idiom >{$}c<{$} as a column specifier in an array environ­
ment, then a centered column in text mode is produced.
In the case where one wants to create a shorthand for a long column specifier, one can use a \newcolumntype. For example, the command
\newcolumntype{L}{>-C$}l<{$}}
is used to define a new column specifier, namely L, that can be used in an array environment to get left-justified columns in text mode. A list of all current active \newcolumntype definitions is sent to the terminal and the log file if the \showcols
a
b
c
d
1
2
3
4
i
j
k
1
w
X
y
z
4.9 M o r e o n A l i g n m e n t -φ- 87
Table 4.2: New column specifiers introduced by the array package.
New Column Specifiers
miwidth}
Defines a column of width width. Every entry will be cen­
tered in proportion to the rest of the line. It is somewhat like \parbox{width}.
b-Cwidth}
Coincides with \parbox [b] {width}.
>{decl.}
Can be used before an 1, r, c, p, m, or a b option. It inserts de c l. directly in front of the entry of the column.
<{decl.>
Can be used after an 1, r, c, p {..}, m {.o r a b{. .} option. It inserts d e c l. right after the entry of the column.
1
Inserts a vertical line. The distance between two columns will be enlarged by the width of the line, in contrast to the original definition of I^TeX.
!{decl.}
Can be used anywhere and corresponds to the 1 option. The difference is that decl. is inserted instead of a vertical line, so this option does not suppress the space normally inserted between columns, in contrast to @{...}.
c o mma n d i s g i v e n. I f a t a b u l a r e n v i r o n me n t o c c u r s i n s i d e a n o t he r a n d s t a r t s w i t h a \h l i n e a n d e n d s w i t h t h e s a me c o mma n d, t h e n i t i s a g o o d pr a c t i c e t o r e p l a c e t h e f i r s t \h l i n e w i t h t h e c o mma n d \f i r s t h l i n e a n d t h e l a s t o n e w i t h t h e c o mma n d \l a s t h l i n e.
The tabularx package
This package defines a new environment, tabularx, which takes the same ar­
guments as the tabular* environment. The column specifiers of tabularx are essentially the same as those of the standard tabular* environment. Their real difference lies in the fact that tabular* adds space between columns to achieve the desired width and tabularx adjusts the width of some of the columns, which are specified with the column specifier X. If one tabularx environment occurs inside another, the inner one must be enclosed in curly brackets. Since the body of the environment is actually the argument of a command, one must avoid certain constructs that cannot be command arguments (e.g., \verb).
By default, the X column specifier is turned into p{.. .Since such columns often require a special format, this may be achieved using the >{...}
column
specifier provided by the array package (e.g., >{\small}X). A format that is useful in cases such as this is ragged right. But, the declaration \raggedright redefines \\ in a way that conflicts with its use in a tabular environment. For this reason, the package introduces the command \arraybackslash, which may be used after a \raggedright. If you want to see all of the computations performed by the package, try the declaration \tracingtabularx.
8 8 <>- 4 L i s t s a n d Ca t a l o g s
The supertabular package
This package defines the supertabular environment. The environment is an exten­
sion of the tabular environment that solves one major drawback of this environ­
ment: a tabular environment must fit on one page. If the environment becomes too large, the text overwrites the page's bottom margin and one gets an Overfull vbox message. The new environment accepts the same column specifiers as the tabular environment, but one must be careful to end each line with a \\.
The package also defines the following environments: supertabular*, mp- supertabular and mpsupertabular*. The environment supertabular* works much like the tabular* environment, whereas the two other environments are for use within a minipage environment.
The supertabular package allows the use of three options that control the amount of information written in the log file:
err or show It is the default option that does not actually write any extra infor-
pageshow When the environment decides to break a page if this option is active, then the environment explains where and why it actually breaks a
debugshow This option also shows information regarding each line that is added to the tabular arrangement.
The package introduces a few new commands, which are explained below:
\t a b l e f i rsthead This command takes a single argument and defines the contents of the first occurrence of the tabular head.
\tabl ehead This command takes one argument and defines the contents of all subsequent occurrences of the tabular head.
\t abl et a i l It takes one argument and defines something that will be ap- pended to tabular just before a page break occurs.
\t a b l e l a s t t a i l This command takes a single argument and defines some­
thing that will be appended at the end of the table.
The package provides three commands to introduce captions in a table: \topcap- ti on, \bottomcaption, and \t abl ecapt i on. The command \shri nkhei ght can be used to adjust the allowed maximum and minimum height of a part of the supertabular on a page. It has one argument, the length that will shrink (positive value) or grow (negative value) the allowed height. Here is a rather complete usage example:
\h l i n e
\multicolumn{4}{c]-{Perl ’ s Op e r a t o r }\\ \h l i n e
\mul t i column{l }{c I }{Associativity]-& \mul t i col umn{l ]"[l I MAr i t y} ft \multicolumn-CHKl I MPrecedence Class}&
mation.
page.
4.9 M ore o n A l ign m e n t -φ- 89
\multicolumn-Cl}{l}{Precedence}\\
\hline}
1
\tablehead{%
\h l i n e
\multicolumn{4}{c}-C\small\slshape continued from previous page}\\ \h l i n e
\multicolumn{l}{cI}{Associativity}&
\multicolumn-[l3"Cl I }{Arity} &
\multicolumn-Cl}-[l I }{Precedence Class} fc \imilticolumn-Cl}-[l}{Precedence}\\ \h lin e}
%
\tabletail{%
\h l i n e
\multicolumn-C4}{c}-[\small\slshape continued on next page}\\
\hline}
%
\t a b l e l a s t t a i l {\h l i n e }
%
\bottomcaption{Perl’s Operator}
%
\begin{supertabular}{c11 11 11}
None ft 0 fc terms and l i s t oper. (leftward) fc 0\\
Left & 2 & \v e r b | - > | & 1 \\
\end{supertabular}
The output of this example is shown rotated in Figure 4,3 (page 91).
The longtable package
This package defines the environment l o n g t a b l e. The functionality of this envi­
ronment is similar to that of the s u p e r t a b u l a r environment. It is possible to have a table caption generated by a \c a p t i o n command that can appear in the list of tables (generated by a \l i s t o f t a b l e s command). The value of the counter \LT- chunksize is used to break the table into chunks that contain a number of rows equal to this value. This way, T^X is not forced to keep the whole table in its mem­
ory and therefore makes it possible to handle large tables in TgX installations with limited memory. The default value of this counter is 20. At the start of the table, one may specify lines that are to appear at the top or bottom of every page. The lines are entered as normal, but the last \\ is replaced by the appropriate command: \endhead (for each table head), \endf i r s t h e a d (for the first table head), \endf oot (for each table foot), and \e n d l a s t f oot (for the last table foot). It is possible to have an effect similar to that achieved by the \k i l l command of the t abbi ng en­
vironment by using a reimplementation of the \k i l l command, provided by the l o n g t a b l e package.
Here is the example table of the previous section coded using longtable:
\b e g i n { l o n g t a b l e } { c 11 11 11}----------------------------------------------------------------
90 -φ- 4 L ists a nd C a t a logs
\h l i n e
\multicoluran{4]"[c}{Perl ’ s Operator}\\
\h l i n e
Associativity & Arity fc Precedence Class & PrecedenceW \h l i n e
\endfirsthead \h l i n e
\multicoluran{4]-{c}{\small\slshape continued from previous page}\\ \h l i n e
Associativity fc Arity fc Precedence Class fc PrecedenceW
\h l i n e
\endhead
\h l i n e
\multicolumn-C4]"Cc}-C\small\slshape continued on next page}\\
\h l i n e \endfoot \h l i n e
\e n d l a s t f oot
None & 0 & terms and l i s t oper. (leftward) & 0\\
Left & 2 & \v e r b I- > I fc 1 \\
The output of this example is shown rotated in Figure 4.3 (page 91).
sociativity
Right
Right
Right
Right
Right
Right
Right
Right
Lett
Lett
Right
Right
Left
Left
Left
c ontinued f r i m priivi'i Ar ity Precedence ( Ί ι
L is t ope r a tor s
n o t
and
Table 1 Per l’s Oper
r ightward)
Associativity
:i)ntinu«:d fraru prev i o u s pfl£t: A r i t y Precedence Class
None
None
Non?
None
None
None
None
None
None
None
Left
Left
Left
Left
Left
None
None
Right
Right
Right
Right
Right
Right
Right
Right
Right
I t -
co n tin u ed on n e x t pngr
Associativity
None
Left
None
None
Right
Ei g h t
Right
Bight
Right
Bight
Left
Left
Left
Left
Left
Left
Left
Left
Left
Left
Left
Right
None
None
None
None
Arity
1 1 2 1 1 1 1 1 2 2 2 2 2 2 2
2 2 2 2 0, 1
Pe r l’s Ope r a tor Precedence Class
te r ms a nd li s t ope r (leftward)
\
u n a r y + u n a r y -
na me d u n a r y oper a tor s
c ontinued on n e x t ptigv
c ciit inued fr o m p r ev
c ontinued f ront prcviouh pa ge
c c iativity
l i i g h t
Iiight
Right
Iiight
Left
Left
Right
Iiight
Left
Left
Left
Arity
Precedence Class
List op e r a t o r s fri n o t and o r xor
Table 1 Pe r l’s Ope
ghtward)
Associativity
None
None
None
None
None
None
None
None
Left
Left
Left
Left
Left
None
None
Right
Right
Right
Right
Right
Right
Right
Right
Right
Right
Right
Right
Right
Ar i t y
Precedence Class
<=>
eq
A-
Δίρ-
/- -
h
11-
Precedence
liΪ 1(1 11 11 11 11 11 11 12 13
13
14
15 IS IS 17 IS IS IS
is
IS
IS
IS
IS
is
IS
IS
is
A s s o c i a t i v i t y
N o n e
L e f t
N o n e
N o n e
R i g h t
R i g h t
R i g h t
R i g h t
R i g h t
R i g h t
L e f t
L e f t
L e f t
L e f t
L e f t
L e f t
L e f t
L e f t
L e f t
L e f t
L e f t
R i g h t
N o n e
N o n e
N o n e
N o n e
N o n e
N o n e
A r i t y
1)
1
2
1
1
1
1
1
2
2
2
2
2
2
2
2
2
2
2
0. 1
2
2
2
2
2
P e r l ’s O p e r a t o r
P r e c e d e n c e C l a s s
t e r m s a n d l i s t o p e r ( l e f t w a r d )
\
u n a r y + u n a r y -
n a m e d u n a r y o p e r a t o r s
P r e c e d e n c e
1)
1
2
2
3
4 4 4 4
c i i i t i n u c d o n n e x t p i j o c
c o n t i n u e d o n n e x t p n g c
Figure 4.3: The seme table typeset with s u p e r t a b u l a r (left column) and l o n g t a b l e (right column).
4.9 More on Alignment -φ- 91
Typesetting M athematic s
One of the most demanding jobs in the typesetting business is the typesetting of math­
ematical text. Here, really excels. Its output is incomparable to the output of any other document preparation system. ΙίΓρΧ, as usual, adds an easier interface to the T^X typesetting engine, making the writing of even the most demanding mathematical text straightforward.
The American Mathematical Society has made an enormous effort to create Ι^ΤβΧ document classes and packages that deal even better with several issues compared to the usual a r t i c l e and book document classes. They have created the amsart and amsbook classes, and packages that provide the basic functionality of these classes and work with any document class. The advantages are really important for mathematicians or others who use mathematics in their work, so we thoroughly discuss these classes and packages.
5.1 The Mathematics Mode
When we want to write mathematical text, we must inform Ι^ΤβΧ of our intentions. This is done by surrounding the mathematical text with the dollar character: $. l?T^X takes special care about spacing in math mode even if we write something simple, leading to professional mathematical typesetting. Take a look at the following:
10/5=2 and 7-3=4 10/5 = 2 and 7 - 3 = 4.
T h e s e c o n d l i n e l o o k s m u c h b e t t e r, a n d i t w a s p r o d u c e d b y t h e i n p u t
$ 1 0/5 = 2 $ a n d $ 7 - 3 = 4 $.
W h e n w e t a l k a b o u t t h e "m a t h e m a t i c s m o d e/' w e m u s t b e a r i n m i n d t h a t T ^ X t y p e s e t s i n s i x d i f f e r e n t m o d e s. A "m o d e" i s t h e w a y T ^ X r e a d s i t s i n p u t t e x t. T h e r e a r e a c t u a l l y t w o m a t h e m a t i c a l m o d e s. W e h a v e a l r e a d y s h o w n t h e f i r s t o f t h e s e —t h a t i s, t e x t s u r r o u n d e d b y s i n g l e d o l l a r c h a r a c t e r s. T h e o t h e r m o d e i s w h e n w e w a n t t o t y p e s e t m a t h e m a t i c s i n
94 ^ 5 Typesetting Ma thema tics
a "display" (that is, outside the text paragraph) surrounded by (vertical) white space, like this:
1 + 2 + 3 + · · · + μ = n(n + 1) /2.
This is achieved by using double dollar characters instead of single ones. The display above was produced by
$ $ l + 2 + 3 +\c d o t s + n = n (n + l )/2.$$
The commands \ ( and \) can be used to enter and leave the math mode. In addition, these commands check that we are not actually in math mode, so they prevent possible errors. Of course, if we are already in math mode, they cause I^TjiX to stop and print an error message (see Table 11.1). If you do not feel comfortable with these commands, then you can use the math environment. Similarly, the commands \ [ and \] enter and leave the display math mode and do similar checks. The corresponding environment is the d i s p l a y m a t h environment.
5.2 Font Selection in Mathematics Mode
Selecting shape in math mode is achieved by the commands \mathrm, \m a t h i t, and \m a t h c a l, and it affects only text (not symbols). These commands work like \t e x t r m or \t e x t i t but in math mode. In addition, spaces are not observed, and no hyphenation is applied. Thus, $\mathrin{of f e r i t } $ will produce offerit and $\mathcal-COFFER IT}$ will give O f f £ 1 l X T.
The selection of series such as bold is not always supported. The default (Computer Modem) fonts do provide bold series for many mathematical symbols, but this may
not be available for other fonts. The way to write mathematics in bold is to switch to bold before entering the math mode with the command \mathversion-Cbold}. This changes to bold for all mathematics (including symbols) until it is disabled with \math- versi on{normal }. If inside normal math we would like to enter text in bold, then the easiest way is to switch to text mode locally using an escape or to use the \mathbf command. Here is an example that uses all of the above:
Vx € A we have x2 = 1 V;t G Λ we have x2 = 1
$ $\f or a l l \mathbf {xJAinVnathcal-CAj- Xtextrmi we have }- \mathbf{ x
}-~2
=
1
$$
\mat hversi on{bol d}
$ $\f o r a l l x\in\mathcal {A)- \t.f i v t i h f - f t.t( =! h a v f i > x'"?. = 1 $ $
Vx e A we have x2 = 1
\mathver s ion-Cnormal}- $ $\f o r a l l \mathbf{ x }\i n \mathcal{A}- \textrm{ we have }\ \mathbf {x}- "2=1$$
5-3 S y m b o l s f o r t h e Ma t h e m a t i c s M o d e -φ- 95
Note that the commands \boldmath and \unboldmath are shorthands for the b o l d and the normal \m a t h v e rs i o n s.
The selection of sans serif and typewriter fonts in math mode is done with the commands \mathsf and \mathtt, respectively. Thus,
$\m ath sf ■CA}'-i _ {\m a t h s f {j}}· =\mathtt{W}- (\m a t h t t {\a l p h a ) - ) $
will be set as Aj = W(a). The commands \textrm, \t e x t i t, and so forth work fine in math mode, and they observe spaces. They also observe language, so
$x~2=-l \t e x t b f { and t h u s }- x=\pm i $
$x~2=-l \t e x t r m { \t e x t g r e e k { > ’ a r a } }- x=\pm i $
$f_n \s t a c k r e l {\t e x t r m {\t e x t g r e e k - { ^ } - } } - C\l o n g r i g h t a r r o w } f$.
produces
x2 — — 1 and thus x — ± i x2 — —1 άρα x — ± i
r c
We should also add here that if the family has been chosen, the commands \mathrm, \t ext rm, and so on, will observe this. Therefore,
\s f f a m i l y We g e t $ x"2 = - l \t e x t b f { and t h u s }- x=\pm i $
wil l be set as
We get x2 — - 1 and thus x — ± i that is, the “and thus" phrase was set in sans serif family and bold series.
5.3 Symbols for the Mathematics Mode
One of the most difficult parts of typesetting mathematics is the wealth of mathematical symbols needed even for simple texts. By "symbols" we mean glyphs such as V, 3, — and so on. In addition to symbols, mathematicians need different alphabets, as it is customary to use different fonts for certain tasks such as script capitals A, B, C, V or Greek letters a, 3, e, ε.
5.3.1 Special Latin Alphabets
In Section 5.2, we saw a calligraphic alphabet provided by the \m a t h c a l command. Sometimes, though, one needs an even more scripted font. Such a font is provided by the mathrsfs package (by Jorg Knappen). The package provides the command \m a t h s c r, which gives access to script capitals. For example, $\m a t h s c r {MATHEMATICS}$ produces .J { 9 ’. A similar option is to use the eucal package of the Aj\yjS. If
96 -φ- 5 Typesetting Μα thema tics
the package is used, the option maths c r provides both the standard \m a t h c a l and the \m a t h s c r commands, producing a different script font: JyLATIHgJyLATJCS.
Another commonly used font is the blackboard bold font:
ABCBEFGHIJKLMNOPQMSTUYWXYZ
which is available with the amsfonts or amssymb package and can be accessed with the \mathbb command. Notice that this command will not work for Greek or lowercase letters. If one has such a need, one can use the package mathbbol by Jorg Knappen. The package provides lowercase and Greek blackboard bold. One should use the package as follows:
\use p a c k a g e [ b b g reekl] {mathbbol}-
We should also note that this package uses a different font for the \mathbb command. Here is an example:
ABCDEFGDHDJIKLM
\b e g i n { c e n t e r >
IKIOPQIRSTUVWXYZ
$\mathbb{ABCDEFGHIJKLM}$\\
ofocdeffglhDjjlkOim
$\mathbb{NOPQRSTUVWXYZ}$\\
nopqirsltttjw^yz
$\m a t h b b { a b c d e f g h i j k l m } $\\
©123456/8©
$\mathbb{nopqrstuvwxyz}$\\
ΓΑΘΛΞΠΣΦΊΏ
$$\mathbb{0123456789}$\\
©[βφδειζιηθαικΙμ
$\mathbb{\Gamma\Delta\Theta
\L a m b d a\X i\P i\S i g m a\P h i\P s i
\0mega}$\\
$\b b a l p h a\b b b e t a
\bbgamma\bbdeI t a\b b e s p i I o n
\bbkappa\bblambda\bbmu$\\
$\bbnu\bbxi\mathbb{o)-\bbpi
\b b r h o\b b s igma\bbt au
\bbup s i 1o n\b b p h i\b b c h i
\b b p s i\bbome era$
' Γ ' O T
\e n d { c e n t e r }
Note that the command \b b e s p i l o n is misspelled in the current version of the mathbbol package (\b b e s p i l o n instead of \b b e p s i l o n ).
5.3.2 The Greek Letters
The Greek letters are shown in Table 5.1. The rest of the capital Greek letters are in common (in design) with the Latin letters. For example, it would make no sense to provide a command such as \Alpha, as in Greek this letter is identical to the Latin A.
5-3 S ym b o l s f o r t h e Ma t h e m a t i c s M o d e -φ- οη
Table 5·ΐ: The Greek letters in math mode.
a
\alpha
β
\beta
7
\garoma
δ
\delta
€
\epsilon
ε
\varepsilon
ξ
\zeta
η
\eta
Θ
\theta
ϋ
\vartheta
ι
\iota
Κ
\kappa
λ
\lambda
μ
\mu
V
\nu
ξ
\xi
0
0
π
\pi
ω
\varpi
Ρ
\rho
Q
\varrho
σ
\sigma
S
\varsigraa
τ
\tau
V
\upsilon
Φ
\phi
φ
\varphi
X
\chi
Φ
Ypsi
ω
\oraega
Γ
\Gamma
Δ
\Delta
Θ
\Theta
Λ
\Lambda
Ξ
\Xi
Π
\Pi
Σ
\Sigma
Υ
\Upsilon
Φ
\Phi
Υ
\Psi
Π
\0mega
Table 5.2: A\4 $ Greek and Hebrew (amssymb package).
Γ \digamma κ \varkappa Π \b e t h “I \d a l e t h 3 \gimel
The amssymb package provides two additional Greek letters and three Hebrew letters (in math mode). These are shown in Table 5.2. One more Hebrew letter is available in the standard T4TjiX fonts. This is which is accessed with the command \aleph.
5.3.3 Accents in Math Mode
When we want to put an accent above a letter in math mode, we use special commands such as \vec{a> in order to get U. This practice is also used for “usual" accents such as the acute. We write \ a c u t e {a} to get ά. One may think that these commands are not needed for standard accents if one has a keyboard that can access these glyphs. This is wrong, and the reason is that these commands work even if you want to put an accent above a glyph that the fonts do not provide accented. For example, we can write y or a+b. Moreover, the commands can be combined to give multiaccented letters. Here is an example:
Han Th§ Than | Han Th$\acute-C\hat{\textrm{e}-3-)-$ Than Table 5.3 gives all of the relevant commands.
A better ring accent is provided by the yhmath package (by Yannis Haralambous). The command is \r i n g, and the output of, say, \ring{B>, is B. This package provides additional functionality that we will discuss later on.
Some accents have a wide form that is useful for more than one letter. These are \w i d e h a t and \wide t i l d e, giving xy and xy, respectively.
98 -φ- 5 Typesetting Μα thema tics
Table 5.3: Accents in math mode.
a \hat{a} ά \acute{a} a \bar-Ca} a \dot{a}
a \breve{a} a \check{a} a \grave{a} a \vec{a}
a \ddot{a} a \t i l d e { a } a \mathring{a]-
5.3.4 Binary Operators
Binary operators are symbols such as + or — that are used between two operands, which, in turn, are numbers, letters, or formulas. The predefined binary operators that IATgK provides are shown in Table 5.4. Note that the commands marked with M are only available if we use the latexsym package. In particular, one can get the symbols ·, · and * in ordinary text mode by using the commands \t e x t b u l l e t, \textperiodcentered, and \t ex t ast e ri sk ce nt e re d, respectively.
Additional binary operators are provided by the packages amssymb and amsfonts. These are given in Table 5.5.
Table 5.4: Binary operators.
±
\pm
n
\cap
0
\diamond
Θ
\oplus
=F
\mp
u
\cup
Δ
\bigtriangleup
θ
\orainus
X
\times
ΰ
\uplus
V
\b i g t r iangledown
\otimes
\div
π
\sqcap
<
\t r i a n g l e l e f t
0
\oslash
*
\a s t
u
\sqcup
>
\t r i a n g l e r i g h t
Θ
\odot
\s t a r
V
\vee
0
\lhd(*)
0
\b i g c i r c
0
\c i r c
Λ
\wedge
>
\rhd(*>
i — — ■ 1 'U l
t
\dagger
•
\bullet
\
\setminus
<
\unlhd1· '
i
\ddagger
\cdot
I
\wr
t>
\unrhdW
π
\amalg
Table 5-5: Aj\4$ binary operators
+ \dotplus \
W \Cup A
Λ \doublebarwedge B
□ \boxdot EB
\ltimes -------------
IX
X \rightthreetimes Θ \circleddash
\centerdot
λ
\smallsetrainus
\barwedge
\boxminus
\boxplus
\rtimes
ini \Cap V \veebar IE \boxtimes
\divideontimes - 7\\l e f tthreetimes^
\curlywedge
\c i r c l e d a s t
\i n t e r c a l
T \curlyvee ® \c i r c l e d c i r c
5-3 S ym b o l s f o r t h e Ma t h e m a t i c s M o d e -φ- 99
5.3.5 Variable-Size Operators
Variable-size operators are operators whose size changes according to the math mode in which they are used. Both
S a n d Σ
are produced by the \sum command, but the first one is in text math mode and the second one is in display math mode. The available symbols that behave this way are shown in Table 5.6
Table 5-6: Symbols of variable size.
Σ
\sum
Π
\p r o d
u
\c o p r o d
n
\b i g c a p
u
\b i g c u p
u
\b i g s q c u p
o
\b i g o d o t
<8>
\b i g o t i m e s
0
\b i g o p l u s
f
\i n t
V
\b i g v e e
l±J
\b i g u p l u s
f
\o i n t
Λ
\bigwedge
5.3.6 Delimiters
Delimiters are symbols that are used mainly for grouping. These are shown in Tables 5.7, 5.8, and 5.9.
Table 5.7: Delimiters.
r
\uparrow
ft
\Uparrow
1
\downarrow
4
\Downarrow
{
\{
}
\>
I
\updownarrow
ft
\Updownarrow
L
\l f l o o r
J
\r f l o o r
Γ
\l c e i l
1
\r c e i l
(
\l a n g l e
)
\r a n g l e
/
/
\
\b a c k s l a s h
\l
Table 5-8: A\i$ delimiters (amssymb package). r \u l c o r n e r n \u r c o r n e r l \l l c o r n e r _i \l r c o r n e r
5.3.7 Arrows
The available arrow symbols are shown in Tables 5.10, 5.11, and 5.12.
ίο ο -φ- 5 Typesetting Μ α thema tics
\rmoustache
\arrowvert
Table 5.9: Large delimiters. \lmoustache \Arrowvert
J
\rgroup \bracevert
\lgroup
Table 5.10: Arrow symbols (starred symbols are available with the latexsym package).
>(*)
\l e f t a r r o w \L e f t a r r o w \r i g h t a r r o w or \t o \R i g h t a r r o w \l e f t r i g h t a r r o w \L e f t r i g h t a r r o w \mapsto
\h o o k l e f t a r r o w \l e f t h a r p o o n u p \l e f t h a r p o o n d o w n \l e a d s t o
\l o n g l e f t a r r o w \L o n g l e f t a r r o w \l o n g r i g h t a r r o w \L o n g r i g h t a r r o w \l o n g l e f t r i g h t a r r o w \L o n g l e f t r i g h t a r r o w \longmapsto \h o o k r i g h t a r r o w \r i g h t h a r p o o n u p \ri g htharpoondown
T
\uparrow
1\
\Uparrow
i
\downarrow
\Downarrow
I
\updownarrow
t
\Updownarrow
/
\n e a r ro w
\
\s e a r r o w
/
\swarrow
\
\nwarrow
Table 5.11: Afi/{S arrows (amssymb package).
\dashrightarrow
\d a s h l e f tarrow
i=
\l e f t l e f t a r r o w s
\l e f t r i g h t a r r o w s
\L l e f tarrow
«—
\twoheadleftarrow
<—<
\l e f t a r r o w t a i l
\looparrowleft
\l e ft r ightharpoons
■Τλ
\curvearrowleft
0
\c i r c l e a r r o w l e f t
\Lsh
π
\upuparrows
1
\upharpoonleft
J
\downharpoonleft
—0
\multimap
\l eftrig h tsq u ig arro w
\looparrowright
\r i g h t l e f t a r r o w s
=t
\r i g h t r ightarrows
0
\c i rc le a rr o w r ig h t
—»
Ytwoheadrightarrow
r\
\curvearrowright
r
\upharpoonr ight
\r i g h t l e f tharpoons
\downdownarrows
\Rrightarrow
\Rsh
\rightsquigarrow
L
\downharpoonright
\r i g h t a r r o w t a i l
Table 5-i2: Aj\4$ negated arrows (amssymb package).
w- \n l e f t a r r o w \n r i g h t a r r o w -Φ \n L e f t a r r o w
Φ-
\n R i g h t a r ro w \n l e f t r i g h t a r r o w \n L e f t r i g h t a r r o w
5.3.8 Relational Operators
Again, there are two sets of such operators: the standard ones (Table 5.13) and the ones provided by the amssymb package (Table 5.14).
5-3 Symbols for the M a t h e m a t i c s M o d e <>- i o i
Table 5.13: Relation operators (starred symbols are available with the latexsym package).
<
\l e q o r \l e
>
\geq
—
\e q u i v
h
\models
\p r e c
y
\s u c c
\s i m
_L
\p e r p
\p r e c e q
>Z
\s u c c e q
r
\s i m e q
|
\mid
<
\11
»
\gg
X
\asymp
|
\p a r a l l e l
c
\s u b s e t
D
\s u p s e t
r v
\a p p r o x
1X1
\b o w t i e
c
\s u b s e t e q
D
\s u p s e t e q
\cong
\J o i n
IZ
\s q s u b s e t
Ώ
\s q s u p s e t
Φ
\n e q
\s m i l e
c
\s q s u b s e t e q
□
\s q s u p s e t e q
=
\d o t e q
\frown
€
\i n
3
\n i
c x
\p r o p t o
=
=
h
\v d a s h
H
\d a s h v
<
<
>
>
Table 5-14:
Am S relational operators (amssymb package).
<
\leqq
<
\l e q s l a n t
\e q s l a n t l e s s
<
\lesssim
<
.-ό
\lessapprox
1—^
\approxeq
<
\l e s s d o t
«ε:
\111
£
Messgtr
<
>
\l e s s e q g t r
<
>
\le ss e q q g tr
=
\doteqdot
=
\ri s i n g d o t se q
·—
\f a l l i n g d o t s e q
'•«■'Λ
\backsim
\backsimeq
c
\subseteqq
\Subset
c
\sqsubset
\preccurlyeq
\curlyeqprec
\precsim
\precapprox
<]
\v a r t r i a n g l e l e f t
<
Ytria ngle le fteq
N
\vDash
III·
Wvdash
\smallsmile
\sm a l l f rown
\bumpeq
Λ
\Bumpeq
>
\geqq
>
\geqslant
\e q s l a n t g t r
>
r^i
\gtrsim
>
\gtrapprox
>
\g t r d o t
\g g g
%
\g t r l e s s
>
<
\g t r e q l e s s
>
\gtreqqless
Ί Ε
\e q c i r c
O
\c i r c e q
_Δ
Ytriangleq
rsj·
\thicksim
l—W1
\thickapprox
D
\supseteqq
3)
\Supset
□
\sqsupset
>
\succcurlyeq
\curlyeqsucc
\succsim
fc
\succapprox
l>
\v a r t r i a n g l e r i g h t
>
\t r i a n g l e r i g h t e q
II·
Wdash
1
\shortmid
11
\s h o r t p a r a l l e l
\between
rti
\p i t c h f ork
a
\varpropto
<
\b l a c k t r i a n g l e l e f t
Ytherefore
9
\backepsilon
►
\b l a c k t r i a n g l e r i g h t
\because
ίο 2 -φ- 5 Typesetting Μ α thema tics
The negated form of a relational operator (i.e., is obtained by prepending the command \n o t to the relational operator. For instance, the code x\n o t\l e q y is being typeset as λ: ^ y. However, the provides special fonts and commands to access negated relational operators, which are shown in Table 5.15.
Table 5.15: AjviS negated relational operators (amssymb package).
<
\n l e s s
\n l e q
4*
\n l e q s l a n t
$
\n l e q q
<
\l n e q
έ
\l n e q q
%
\l v e r t n e q q
%
\l n s i m
§
\l n a p p r o x
\n p r e c
\n p r e c e q
\p r e c n s i m
\p r e c n a p p r o x
\nsim
t
\n s h o r t m i d
\
\nmid
Y-
\nvdash
\nvDash
\n t r i a n g l e l e f t
ί
\n t r i a n g l e l e f t e q
£
\n s u b s e t e q
c
\s u b s e t n e q
ί
\v a r s u b s e t n e q
c
\s u b s e t n e q q
g
\v a r s u b s e t n e q q
>
\n g t r
t
\n g e q
>
\n g e q s l a n t
£
\ngeqq
>
\g n e q
>
\gneqq
έ
\g v e r t n e q q
ί
\gnsim
§
\gnapprox
y-
\n s u c c
t
\n s u c c e q
&
\su c c n si m
&
\su c c n a p p ro x
¥
\ncong
H
\n s h o r t p a r a l l e l
x
\n p a r a l l e l
\nvDash
¥
\nVDash
c*
\n t r i a n g l e r i g h t
ί
\n t r i a n g l e r i g h t e q
\n s u p s e t e q
1
\n s u p s e t e q q
D
\s u p s e t n e q
2
\v a r s u p s e t n e q
D
\s u p s e t n e q q
g
\v a r s u p s e t n e q q
5.3.9 Miscellaneous Symbols
There are also some symbols that do not fit into any of the categories above, so we collectively present them in Tables 5.16 and 5.17. It is rather important to stress that the symbol U presented in Table 5.16 is the archaic term for the unit of electrical conductance. The modem name of this unit is siemens (symbolized S).
5-3 S ymb o l s f o r t h e Ma t h e m a t i c s M o d e <>· 10 3
Table 5.16: Miscellaneous (starred symbols are available with the latexsym package; double-starred symbols are available with the yhmath package.
. . .
\l d o t s
\cdots
\vdots
\ddots
N
\aleph
/
\prime
V
\f o r a l l
CO
\i n f t y
h
\hbar
0
\emptyset
3
\e x i s t s
V
\nabla
V
\surd
□
\BoxW
Δ
\t r i a n g l e
O
\Diamond(*)
1
\imath
;
\jmath
I
\e l l
—1
\neg
T
Ytop
b
\f l a t
ti
\natural
\sharp
P
\wp
_L
\bot
*
\c l u b s u i t
\diamondsuit
9
\h e a r t s u i t
*
\spadesuit
15
VnhoW
5ft
\Re
θ
\Im
Z
\angle
a
\p a r t i a l
\adots^**^
Table 5.17: Am $ miscellaneous symbols (amssymb package; starred symbols not defined in old releases of the package).
n
\h s l a s h
Δ
\v a r t r i a n g l e
V
\t r i a n g l e d o w n
0
\l o z e n g e
(D
\c i r c l e d S
z
\a n g l e
ί
\n e x i s t s
J
\F i W * )
\Game(*)
\
\backprime
0
\v a r n o t h i n g
▲
\b l a c k t r i a n g l e
■
\b l a c k s q u a r e
♦
\b l a c k l o z e n g e
\b i g s t a r
c
\complement
d
\e t h
/
\d i a g u p ^
□
\s q u a r e
Z
\measuredangle
k
\BbbkW
▼
\b l a c k t r i a n g l e d o w n
<
\s p h e r i c a l an g l e
\
\diagdown(*)
5.3.10 More Math Symbols
More symbols for mathematics exist in add-on packages. For example the txfonts pack­
age by Young Ryu provides additional symbols for the Times font family One might keep an eye on CTAN for other math fonts, as the collection there gets richer every day. In tables 5.18-5.23 we show the math symbols provided by the txfonts package.
Table 5.18: Delimiters provided by the txfonts package.
\llbracket J \rrbracket ^ \lbag ^ \rbag
Table 5.19: Math alphabets provided by the txfonts package. g \varg v \varv w \varw y \vary
ί ο 4 ^ 5 T y p e s e t t i n g Μ α t h e m a t i c s
Table 5.20: Binary operators provided by the txfonts package.
Ο
\m e d c i r c
• \m e d b u l l e t
\invamp
©
\c i r c l e d w e d g e
© \c i r c l e d v e e
CD
\c i r c l e d b a r
<s>
\c i r c l e d b s l a s h
(+i \n p l u s
E
\b o x a s t
□
\b o x b s l a s h
m \b o x b a r
a
\b o x s l a s h
8
\Wr
l±l \s q c u p p l u s
Fl
\s q c a p p l u s
>
\r h d
< \l h d
>
\u n r h d
<
\u n l h d
Table 5.21: Ordinary symbols provided by the txfonts package.
a \a l p h a u p
β \b e t a u p
γ \gammaup
δ \d e l t a u p
e \e p s i l o n u p
ε \v a r e p s i l o n u p
ζ \z e t a u p
η \e t a u p
θ \t h e t a u p
θ \v a r t h e t a u p
ι \i o t a u p
κ \kappaup
λ \lambdaup
μ \muup
ν \nuup
ξ \x i u p
π \p i u p
CD \v a r p i u p
ρ \r h o u p
ρ \v a r r h o u p
σ \sigmaup
ς \v arsig mau p
τ \t a u u p
υ \u p s i l o n u p
φ \p h i u p
φ \v a r p h i u p
χ \c h i u p
ψ \p s i u p
ω \omegaup
0 \Diamond
<·> \Diamonddot
♦ \Diamondblack
Λ \l a m b d a s l a s h
Λ \l ambdabar
Φ \v a r c l u b s u i t
♦ \v a r d i a m o n d s u i t
Ψ \v a r h e a r t s u i t
6 \v a r s p a d e s u i t
ΤΓ \Τορ
ϋ \Bots
5-3 S ymb o l s f o r t h e Ma t h e m a t i c s M o d e <>· 10 5
Table 5.22: Large operators provided by the txfonts package.
R
\bignplus
l±l
\bigsqcupplus
R
Ybigsqcapplus
Π
\bigsqcap
U
\bigsqcup
X
\varprod
§
\oiint
rrr
(try
jJJ
\oiiint
f
\ointctrclockwise
i f
\ointclockwise
ί
\varointctrclockwise
f
\varointclockwise
\sqint
#
\sqiintop
f f f
\sqiiintop
f
\f int
I f
\i i n t
I f f
\i i i n t
f f f f
\i i i i n t
I f
\idotsint
§
\oiintctrclockwise
§
\oiintclockwise
§
\vaxoiintctrclockwise
§
\varoiintclockwise
rrr
(ΓΠ>
jJJ
\o ii i n tc t r clockwise
rrr
i n
j JJ
\oiiintclockwise
rrr
fm)
■jJJ
\varoiiintctrclockwise
rrr
(ftjy
\varoiiintclockwise
Table 5.23: Binary relations provided by the txfonts package (part 1).
£
\n s q s u b s e t
£
\n s q s u p s e t
\d a s h l e f t a r r o w
\d a s h r i g h t a r r o w
\d a s h l e f t r i g h t a r r o w
4-/V*
\l e f t s q u i g a r r o w
-m
\ntwohe a d r i g h t arrow
«h
\n t w o h e a d l e f t a r r o w
\Nearrow
%
\Searrow
\
\Nwarrow
\Swarrow
JL
\P e r p
\l e a d s t o e x t
\l e a d s t o
CM
\b o x r i g h t
<τ-Π
\b o x l e f t
E M
\b o x d o t r i g h t
«-Ε1
\b o x d o t l e f t
0->
\Diamondright
\Dia mo n d le ft
\Diamonddotright
\Diamo n d d o tleft
d=3>
\boxRight
^=d
\boxLeft
□=>
\b o x d o t R i g h t
\b o x d o t L e f t
0=>
\DiamondRight
<=C>
\DiamondLeft
\DiamonddotRight
<i=S>
\DiamonddotLeft
0 -»
\c i r c l e r i g h t
«-Ο
\c i r c l e l e f t
o->
\c i r c l e d d o t r i g h t
<-o
\c i r c l e d d o t l e f t
ϊ
\m u l t i m apbothvert
I
\m u l t im a p d o t b o t h v e rt
I
\multimapdotbothAvert
I
\m u l t imapdotbothBv<
ίο 6 -φ- 5 Typesetting Μ α thema tics
Table
5.23: Continued (part 2).
i—1
\mappedfrom
<-■
\longmappedfrom
1=^
\Mapsto
1=^
\Longmapsto
<=l
\Mappedfrom
<^=1
\Longmappedfrom
II—»
\mmapsto
\longmmapsto
<—11
\mmappedf rom
<—1
\longmmappedfrom
Ι=Φ
\Mmapsto
ii=>
\Longmmapsto
Φ=ΙΙ
\Mmappedfrom
<=ll
\Longmmappedfrom
//
\v a r p a r a l l e l
\\
\v a r p a r a l l e l i n v
H
\n v a r p a r a l l e l
\n v a r p a r a l l e l i n v
‘•"•ν'
\c o l o n a p p r o x
\c o l o n s i m
\Colonapprox
\Colonsim
—
\d o t e q
0—
\m u l timapinv
0—0
\m u l t imapboth
-
\m u l t imapdot
· -
\m u l t imapdot i n v
· —·
\m u l t imapdotboth
o—·
\m u l t imapdotbothA
• —0
\mul t imapdotbothB
11=
WDash
111=
WvDash
ξ
\cong
\p r e c e q q
>
\s u c c e q q
\n p r e c s i m
t
\n su c c si m
\n l e s s s i m
ft
\n g t r s i m
έ
\n l e s s a p p r o x
\n g t r a p p r o x
*
\n p r e c c u r l y e q
'Ψ
\n s u c c c u r l y e q
*
\n g t r l e s s
\n l e s s g t r
Φ
\nbumpeq
Φ
\nBumpeq
'-l·
\nbacksim
Φ
\nbacksimeq
Φ
\neq, \n e
*
\nasymp
Φ
\n e q u i v
Φ
\n si m
\n a p p r o x
€
\n s u b s e t
\n s u p s e t
\n l l
\ n rfn'
\ irHrn /'ΐΓ'ίττην'Λν
\ η ο τ τ η ν Ά ν Λ η
'Κ
\ngg
'P
\ii Ull J. LrJ^aUUx UA
\iiauui uacu
ύ
\n p r e c a p p r o x
t
\n s u c c a p p ro x
ύ
\n p r e c e q q
t
\n s u c c e q q
Φ
\n sime q
i
\n o t i n
$
\n o t n i, \notowns
Φ
\n S u b s e t
Φ
\n S u p s e t
£
\n s q s u b s e t e q
ί
\n s q s u p s e t e q
:=
\c o l o n e q q
=:
\e q q c o l o n
\c o l o n e q
\e q c o l o n
\Coloneqq
\Eqqcolon
\Coloneq
\Eqcolon
-3
\s t r i c t i f
8-
\s t r i c t f i
£-3
\s t r i c t i f f
©
\c i r c l e d l e s s
©
\c i r c l e d g t r
IX
\l J o i n
X
\r J o i n
XI
\J o i n, \l r J o i n
X
\o p e n J o i n
M
\l r t i m e s
X
\o p e n t i m e s
5 4 T he A r t o f T y p e s e t t i n g Ma t h e m a t i c a l ΤεχγΦ· i o 7
The txfonts package provides variable blackboard bold and fraktur letters accessed by the commands \varmathbb and \mathf rak. Moreover, the \mathbb command pro­
vides a different shape according to the next table.
AJBCD \varmathbb{ABCD} ABCB \mathbb{ABCD)-
k \varBbbk 5t23(££>at)cb \mathf rak{ABCDabcd}
5.3.11 Other Mathematics Font Families
Several other mathematics font families exist, some more complete than others. The free families, apart from the standard ones, are the families provided by the mathptm and txfonts packages for the Times family, the mathpazo package for the Palatino family, the cmbright package, which uses a sans serif math font family, and the euler package by Herman Zapf, which gives a handwritten accent to mathematics. Other free mathe­
matics fonts exist in development, such as the kerkis fonts that we saw in Section 3.3, and thus one should check periodically in CTAN for updates.
There are also some commercial ones such as the lucida and mathtime font families by Y&Y Inc.
5.4 The Art of Typesetting Mathematical Text
In this section, we present how one can use all of these symbols to produce, in a simple yet efficient way, masterpieces of the art of typesetting mathematical text.
Exponents, indices, fractions, and roots are probably the most common nontext objects that one wants to be able to typeset. I^TgX provides an easy way to do it. Exponents are written using the ~ character. One writes $x~y$ in order to get xv. Similarly, one writes $x_n$ in order to get xn. In order to write something more complex such as xy+z, a local scope must be used: $x~{y+z}$. Naturally, we can create both indices and exponents the expected way (i.e., $x_{i+j}~{2+3}$ will be typeset as Furthermore, these
operators can be nested: $2~{2''n}$ and $x~{y''z}_{k_n}$ will be typeset as
2
2" and xl .
Kn
There is also the possibility of creating an exponent outside math mode with the com­
mand \t e x t s u p e r s c r i p t. The code m a t h\t e x t s u p e r s c r i p t { m o d e } wi ll be typeset as mathmode.
Fractions are produced with the \f r a c command. This command has two argu- ments: the numerator and the denominator of the fraction. For example, the code
ίο 8 -φ- 5 Typesetting Μ α thema tics
χ + 1
$\frac {xHy}$ will be typeset as The reader may note that this use is not really proper. As is evident here, the fraction extends too much towards the lower line and consequently it looks poor. That is why it is better to use this command in display math mode, and in text mode it is better to write x/y (i.e., $x/y$).
One can simplify writing the commands if the numerator and/or the denomina­
tor is a single digit. For example, the code fragments $\f r a c 2 3 $, $\f r a c 2 { x } $, and $\f rac{x}2$, will be typeset as
2 2 3 x
3' x- and 2
respectively.
\f rac commands can be nested. Here is an example:
\b e g i n { d i s p l a y m a t h }
\f r a c { x +\f racl{x}-}"Cy+\f racl-Cy}}
\end-[di splaymath}-
In this example, one may want to increase the width of the main fraction line in order to make such a complex fraction more readable. Unfortunately, we cannot get the desired effect with the \f rac command. For such a task, we have to use the \above command:
\b e g i n { d i s p l a y m a t h }
{ x +\f r a c l - f x } \a b o v e l p t y+\fracl-Cy}}- \end-[di splaymath}-
Note that after \above, we specify the width of the fraction line and the denominator, whereas the numerator is specified before the command. Moreover, the code for the whole fraction must be enclosed in a local scope since \ above is a primitive TgX infix operator.
In the example above one may note that the numerators and the denominators are set in small size when the \f r a c command is used. A simple way out is to use the \d i s p l a y s t y l e which fools I^TgX and sets the fraction parts as if the whole fraction was the only object of a math display.
\begin-Cdi splaymath}
T I I x +\f r a c { a H\d i s p l a y s t y l e x +
* + ; V + V
X +
X +
\f r a c { a ) - {\d i s p l a y s t y l e x + \f r a c { a } {\d i s p l a y s t y l e x + \f rac-faMXddots}-)-}-}
\e n d { d i splaymath}-
x H -----
T^X provides three more commands that can be used in situations such as this:
\t e x t s t y l e This command sets math formulas in text math mode.
\s c r i p t s t y l e This command sets math formulas in script style (i.e., x+s). \s c r i p t s c r i p t s t y l e This command sets math formulas in script-script style (i.e., x+s).
Roots are produced with the command \s q r t. This command has one argument and possibly an optional argument to denote a root other than a square root.
5-4 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l ΤεχτΦ- i o 9
Vx
$\s q r t [ n ] { x > $
$\s q r t { x } $
A
Sometimes the roots will not look uniform in height. The \vphantom command helps by inserting a zero-width line with height equal to the height of the box of its argument. Thus, $\sqrt{a}+\sqrt{b}$ will be typeset as \/a + Vb, but $\sqrt{\vphantom{b}a}+\sqrt{b}$ will be typeset as v a -I- Vb.
For roots and fract i ons, the A ^ S document classes and packages provide better control. We will present these in the relevant sections later.
5.4.2 Functions
The names of functions in math mode must appear in Roman face: compare log* to logx. That is why a command is provided for each of several function names. Table 5.24 shows these commands.
Table 5.24: Commands for accessing functions.
\a r c c o s
\a r c s i n
Varctan
\a x g
\cOE
\cosh
\c o t
\o o th
\c a c
\deg
\d e t
\dim
\exp
\gcd
\hora
\i n f
\k e r
Mg
\li m
\l i m i n f
\1imsup
\l n
\l o g
\max
\min
\P r
\s e c
\s i n
\s i n h
\sup
\t a n
\ta n h
There are two more such commands: the \bmod and \pmod. The first is used as an infix operator, and the second has two arguments. Their use is made clear in the following example1:
gcd(m,tt) = a mod b x — y (mod a \ b)
$\g c d ( m,n ) = a \bmod b$ $ x\e q u i v y \pmod{a+b)-$
Δ
There are many cases where one wants to define another function name. For example, the inverse of the hyperbolic sine, arcsinh, is not listed in Table 5.24. The way to define such a new function name in a document's preamble is presented below;
\newcommand{\arcsinhH\mathop{\mathrm{arcsinh}}}
After this definition, the code fragment f ( x ) =\ar c s i nh x will be typeset as f ( x) = arcsinh x. The same trick can be used to define an operator using a math symbol and not necessarily text. For example, the definition
n o -φ- 5 T y p e s e t t i n g Ma t h e m a t i c s
\newcommand{\doubleint}-C\mathop-C\int\! \! \int}]·
can be used to create the formula
{xeX: ||χ||<1}
> Exercise 5.1 Write down the code that is necessary to typeset the formula above. □
Usually, function names are pretty much standardized. However, these names are not in common use all over the world. For example, in Greece, students learn to write ημ2 χ + συν2 x = 1 instead of sin2 x + cos2 x = 1. Here comes the slightly modified recipe—you declare the fonts for the operator names, writing in the preamble as follows:
\DeclareSymbolFont{groperators]-{LGR]-{cmr3-{in]-{n]-
This way, we declare a new symbol font, groperators, with encoding LGR, name cmr, medium weight, and normal shape. Now, it is easy to define new function names that make use of the new symbol font:
\newcommand{\grsin}{\mathop{7,
\mathgroup\symgroperators hm}\nolimitsJ-
The \mathop command has one argument and makes its argument a unary math operator, so TgX leaves the necessary space on both sides. Similar commands are:
\mathord This command makes its argument an ordinary mathematical object (e.g., a letter).
\mathbin Makes TgX treat its argument as a binary operator.
\mathrel Makes TgX treat its argument as a relational operator (e.g., the ex­
pression x R y is produced by the code $x\mathrel{R}y$).
\mathopen With this command, we can create opening symbols such as left parentheses, and others. The various \b i g l commands are defined as an application of this command.
\mathclose This command is used to create closing symbols such as right parentheses, and others. The various \bigr commands are defined as an application of this command.
\mathpunct Makes TgX treat its argument as a mathematics punctuation char­
acter.
The \mathgroup command is used to select a font family. The \nolimits command
does not allow the setting of limits above and below variable-size operators and other operators. On the other hand, the \l i m i t s command has the opposite effect. We note that this solution also works with the greek option of the babel package, as it regards the name of the function. Actually, the first author has created the grmath package, which redefines most function name commands so that their names appear in Greek. With Λ, things are quite the same; you have to write the name of the function using a Latin transcription.
5-4 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ τ Φ - i n
> Exercise 5.2 Define a new function name for the Greek version of cos (use the "w o r d" sun for the name of the function).
5.4.3 One Above the Other
There are cases where we want to p u t one o r more objects above one another. I f there is a "m a i n" object and a secondary one that needs to be p u t above the main object in order to characterize it, then we use \s t a c k r e l, which has t w o arguments:
\b e g i n { d i s p l a y m a t h }
f ( x )\s t a c k r e l {\m a t h r m { d e f } } { = }\c o s x \e n d { d i s p l a y m a t h >
I f we look carefully at the equation above, we w i l l notice that the first argument of the \s t a c k r e l command is set using a smaller type size and the second argument is set at the baseline (or as i t w oul d be p u t i f i t wTas set alone).
C f \
f(x) = COS X
A
There are cases wher e one want s t o t ypeset obj ect s one above t he ot her, t r eat i ng t hem i n t he same way; her e i s an exampl e:
\b e g i n { d i s p l a y m a t h }
\s u m _ { { I\s u b s e t e q \{ 1,2,\l d o t s,n\} } \a t o p { | I |\g e q k » a _ I \e n d { d i s p l a y m a t h }
As i s evi dent, we use \a t o p t o achi eve t he desi r ed ef f ect. Thi s command i s a p r i m i t i v e T^X i n f i x oper at or and mus t be used i n a l ocal scope.
>· Exer ci se 5.3 Wr i t e t he code t hat set s t he f o l l o w i n g di spl ay:
1 = ( 1,n} |F
0<
■ '· : ι
□
A n o t h e r n e e d t h a t o f t e n a r i s e s i s t o g e t t h e r e s u l t o f t h e \s t a c k r e l c o m m a n d b u t w i t h t h e f i r s t a r g u m e n t below the second argument. For instance, one may want to write
an —* 0.
fl foo
In order to achieve this effect, we can define a new command:
\newcoramand{\abottora>[ 2 ] {\m a t h r e l {\r a a t h o p {#2 }\l i m i t s _ {#l } »
Here is the code that has been used to typeset the display above:
112 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
\b e g in { d i splaymath}
a_n\abottom-Cn\to\infty}{\longr i g h t arrow} 0 \end{di splaymath}
Sometimes, there is a need to p u t one object above the other and to surround the whole construction w i t h special delimiters. We can get this effect b y using the p r i m i t i v e T^X command \a t o p w i t h d e l i m s. The syntax is shown i n the next example. Here are a couple of examples that demonstrate the use of this command:
a
β
$\a l p h a \a t o p w i t h d e l i m s < > \b e t a $
$\a l p h a \a t o p w i t h d e l i m s\l f l o o r\r f l o o r \b e t a $
A n alternative way to w r i t e Q is $a\choose b$. The command \choose is provided b y p la i n TjnX and remains v a li d i n I^TgX,
Similar commands f o r setting fractions w i t h delimiters are the \o v e r w i t h d e l i m s command, w hi c h has the same syntax as the \a t o p w i t h d e l i m s, and the \a b o v e w i t h - d e li m s command, whi ch has a t h i r d argument that specifies the w i d t h of the fraction line. Both are p r i m i t i v e TgX commands. Here is an example:
$a \o v e r w i t h d e l i m s ( ) b$
$a \a b o v e w i t h d e l i m s ( ) I p t b$
Other stacking operations are those of u n d e r l in i n g and ove rli n in g as w e l l as those that p u t another symbol (e.g., a brace) above or below a collection of objects. I n order to set such constructs, we have to use the commands \u n d e r l i n e, \o v e r l i n e, and some others that are shown below:
r 2
$\n v ^ r 1 i n « {\n v « r 1 i η ^ { χ } Λ2}$
x + y
$\u n d e r l i n e - C\u n d e r l i n e { x } +\u n d e r l i n e - C y } } $
xyz
$\w i d e t i l d e { x y z } $
xyz
$\w i d e h a t { x y z } $
xyz
$\o v e r l e f t a r r o w { x y z } $
xyz $\o v e r r i g h t a r r o w { x y z } $
'a,.T., 2 $\o v e r b r a c e { a,\l d °'t s j Z } $
i t,..., ω $\u n d e r b r a c e {\a l p h a,\l d o't s ,\oniega}$
I n particular, f o r the commands \u n d e rb r a c e and \o v e r b r a c e, we should add that they can have an index, as the f o l l o w i n g example shows:
$\o v e r b r a c e { a,\l d o t s,z } ~ { 2 6 } $
$\underbrace-C\alpha, \l d o t s ,\° mega} - {2 4 } $
24
54 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ γ Φ · 113
One should avoid using the over- or under-bracing except i n display mode, as this construction takes a l o t o f vertical space. Also, one should notice the difference between xn and (which were produced w i t h $\o v e r l i n e { x } _ n $ and $\o v e r l i n e { x _ n } $, respectively). Finally, notice that there is often a problem w i t h the "o v e r a r r o w s." They w i l l usually touch (or even cross) the letter 2 i n the example above i f special care is not taken. This problem is even worse w i t h capital letters. I t is a font design issue and is corrected f o r the default fonts i f the package lamsarrow b y Michael Spivak is used (as we d i d here).
5.4.4 H o r i z o n t a l S p a c e
When we w r i t e mathematical text, I^TgX makes decisions about the spacing of the several mathematical symbols. However, there are cases where one wants to change the default behavior. The f o l l o w i n g display shows the common commands f o r changing the spacing i n math m a n ua l ly
Ύ ύ
Λ Λ
$χ \qquad χ$
Λ Λ
$χ \quad χ$
γ γ
Λ Λ
$χ \; χ$
γ γ
Λ Λ
$χ \: χ$
y γ
Λ Λ
$χ \, χ$
A - A -
$χ χ$
XX
$χ \! χ$
π
$x \!\! χ $
The command \! stands fo r a negative length and can be used repeatedly, as the last example demonstrates. Of course, we are allowed to use other 15ΓβΧ space-changing commands (see Section 6.3.2).
5.4.5 I n t e g r a l s a n d S e r i e s
Integrals are produced b y the command \i n t and sums b y the command \sum. The end points o f integration or summation are declared by p r o v i d i n g indices and exponents to these commands. Here are t w o examples:
Jq00 ε~χ1 dx = \/Ση $\i n t _ 0''\i n f t y e ~ { - x ~ 2 } -\,d x =\s q r t { 2\p i } - $
^2 = $\s u m _ - [ n = l }"\i n f t y \f r a c l { n'"2 } - =\f r a c - C\p i''2 } 6 $
The position o f the range o f the sum index is not always as we described above. These are p u t above and below the sum only when we are i n display mode. When we are i n the f i r s t math mode, these are p u t as indices and exponents l ike this: 1/» 2 = tt2/6.
The purpose of this is to avoid forcing the spreading o f the text i n order to accommodate the summation indices and should not be bypassed. However, i f we insist, we may do i t using the \l i m i t s command. Once again, let us stress that this is poor practice, as i t a ffects, i n a bad way, t h e color balance o f t h e page. Take a look at th e f o l l o w i n g example:
ι ΐ 4 ^ 5 T y p e s e t t i n g Μ λ τ η ε μ λ t i c s
This is an example o f the
T h i s i s an example o f the sum g i v e n above, t h a t i s, $\s u m\l i m i t s _ { n = l ) -''\i n f t y
sum given above, Lhal is,
Jl 1 j n 1 — 7T2/6, where
H=1
the default behavior of set-
l/n ~ 2 =\p i ~ 2 /6 $, where t h e d e f a u l t b e h a v i o r o f s e t t i n g t h e sum i n d i c e s i s bypassed.
ting the sum indices is b y ­
passed.
There are cases where one wants to reverse the behavior for the display math mode. For this, we must tell IATgX that we do not want limits by using the \n o l i m i t s command. The display
is produced by $$\sum\noliraits~\prime a_n$$.
As far as integrals are concerned, we note here that the integration range can be set under the integral using the \l i m i t s command. This is useful when we try to save space or improve the appearance when we integrate on a set whose description requires a lot of horizontal space. This behavior and the default one are compared in the next example:
The first one was produced by
$ $\i n t _ { \{ x\i n A\,:\, x\geq 0\> > f ( x )\,d x $ $
and the si’ cond one by
$ $\i n t\l i m i t s _ { \{ x\i n A\,:\, x\geq 0\} } f ( x )\,d x.$ $.
We also note here that i t is a good practice to add a little space before our first differential using the \, command. This is especially good i f big parentheses are closing in front of the differential:
(the default)
and
{ i t Λ: .r>0}
looks better balanced than
The discussion above applies in the same way to all of the symbols of variable size, such as f j, U> so on.
54 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ τ Φ · 115
However, there are cases where one wants to use another symbol that is not of variable size and pretend i t is. For example, one may want to use a symbol such as
n
* /<■
for the convolution of functions. For such a task, we need to define a new operator (such as the \sum operator), but since the asterisk that we used above is not of variable size, we must decide what size we want. Therefore, the example above was typeset using
\newcommand{\astop}{\mathop{\LARGE\mathrra{\ast}}}
5.4.6 M a t r i c e s, A r r a y s, a n d N o n a n a l y t i c a l l y D e f i n e d F u n c t i o n s
The way to w r i t e a m a tri x i n L^TgX is to use the a r r a y environment. This environment arranges the elements of the m a tri x i n rows and columns w i t h o u t taking care o f the delimiters. I f we w ant to use, say the symbols [ ] f o r the matri x delimiters, T^IgX must be informed that the size of these delimiters must be adjusted to f i t nicely w i t h the matrix they enclose. This is done b y the \l e f t and \r i g h t commands. These commands take care o f the automatic size adjustment of the delimiters. Here is the syntax f o r a matrix:
χ — λ 1 0
$ $\l e f t [
\b e g i n { a r r a y } ~ [ l c r ) -
x -\l a m b d a & 1 & 0 \\
0 X — A 1
0 0 χ — X
0 & x -\l a m b d a & 1 \\ 0 & 0 & x -\l a m b d a \e n d { a r r a y } - \r i g h t ] $ $
Ther e ar e cases w h e r e w e w a n t o n l y o n e o f t h e t w o d e l i m i t e r s, a n d t h i s i s t h e case f o r t h e n o n a n a l y t i c a l l y d e f i n e d f u n c t i o n s. I f w e j u s t o m i t o n e o f t h e t w o d e l i m i t e r s, I i T ^ K w i l l c o m p l a i n a b o u t i m p r o p e r g r o u p i n g. T h a t i s w h y t h e \l e f t a n d \r i g h t c o m m a n d s a c c e p t t h e d o t as a s p e c i a l d e l i m i t e r t h a t p r o d u c e s n o t h i n g i n t h e o u t p u t b u t s at i s f i e s ET^ K's f u s s i n e s s a b o u t p r o p e r g r o u p i n g. H e r e i s a n e x a mp l e:
, χ ί 1 i f X € A Xa {%) — | q otherwise
$$\c h i_ A ( x ) = \l e f t\{
\b e g i n { a r r a y } - C l l }
1 & \m a t h r m { i f }\ x\i n A \\ 0 & \m a t h r m { o t h e r w i s e } \e n d { a r r a y } -
\r i g h t.$ $
n 6 ^ 5 T y p e s e t t i n g Μ λ t h e m a t i c s
There are cases where this simple construction is not satisfactory. Here is an exam­
ple:
1 + 2 + 3 Η V n, i f n is even
0, otherwise.
It would look much better i f most of the white space of the second line of the array was not there. For instance,
f 1 -I- 2 -f 3 4 - n, i f κ is even
u': ~ { 0, otherwise
was produced by putting a \quad after the comma and placing everything from the comma to the end of the line in a \mbox. In addition, the array now has only one left-justified column.
Sometimes, we need to w r i t e a matrix w i t h rows and columns being labeled w i t h the number of the r o w or column. This is done w i t h the command \b o r d e r m a t r i x. Here is an example:
1 2 3
1 / 411 fl ]2 #13 \
2 f #21 (*22 β23 I
3 '■ ilii %2 <*33/
$ $\b o r d e r m a t r i x { & 1 & 2 & 3 \c r
1 & a _ { l l > & a_{12> & a_{13> \c r
2 & a_{21> & a_{22> & a_{23> \c r
3 & a_{31> & a_{32> & a _ { 3 3 » $ $
The \b o r d e r m a t r i x command is n o t a command, b u t i t comes fro m p l a i n T^ (. That is w h y its syntax is not similar to the way that we created matrices and i t uses the \c r command to denote the end o f the line instead of the double backslash. Plain TgX provides also a \m a t r i x command ( w i t h similar syntax) fo r matrices, b u t its use is obsolete in Ι£ΓβΧ. I t can be used, b u t often i t creates problems that cannot be overcome and that is w h y we do not describe it. Similarly, plain T^X provides the command \ca se s fo r w r i t i n g nonanalytically defined functions and many mathematicians use it. Once again, the behavior o f this command in I^TgX is unpredictable and very often does nol work.
The a r r a y environment takes an optional argument that can be either t or b. These options align the top or the bottom of the array block to the baseline instead o f centering i t, whi ch is the default. For example, the matrices
χ - Λ 1 C)
0 χ — A 1 0 O x - A
were produced by using the l c r t abl e specs and the t and b optional arguments, respectively. Notice that the parentheses are more cursive than the standard ones of
54 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ γ Φ · 117
because we use the yhmath package, w hi c h provides this feature. For better control o f the optional arguments, we suggest that the reader check out the array package (see Section 4.9).
5.4.7 T h e o r e m s
L>TgX provides an easy interface to create the environments fo r a theorem, a propo­
sition, a lemma, and so on. The preamble of a document must contain the command \newtheoremto define such an environment. The general f o r m o f this command is
\n e w t h e o r e m { n a/n e } { o it t ^ ii t name} [ count er]
or
\newtheorem{na/j?e} [ count er] { out put name}
where name is the name of the new environment, out put name is the name that w i l l be prin t ed i n the output, and count er is the counter w i t h respect to w h i c h this envi­
ronment w i l l be numbered. Counters are special LMgX variables that h o ld numerical values (see Section 6.4). Note that the tw o forms above are different.
For example, i n a mathematics book or article, one can p u t (in the preamble) the f o l l o w i n g definitions:
\newtheorem{thm}{Theorem} [ s e c t i o n ]
\newtheorem{lemma} [thm] {Lemma}
\newtheorem{prop} [thm] { P r o p o s i t i o n }
\newtheorem{cor}- [thm] { C o r o l l a r y }
\newtheorem{def} [ t h m ] { D e f i n i t i o n }
\newtheorem{remark}[thm]{Remark}
\newtheorem{axiom } [ t hm]{Axiom}
\n e w t h e o r e m { e x e r c i s e } [ t h m ] { E x e r c i s e }
Now, one can w r i t e
\b e g i n { t h m } T h e r e are i n f i n i t e l y many p r i m e s.\e n d { t h m }
We f i r s t prove t h e f o l l o w i n g:
\b e g in {l e mma}
Every i n t e g e r has a t l e a s t one prime d i v i s o r.
\end{lemma}
i n order to get
Theorem 5.4.1 There are infinitely many primes.
We f i r s t p r o v e t h e f o l l o w i n g:
L e m m a 5.4.2 Every integer has at least one prime divisor.
n 8 ^ 5 T y p e s e t t i n g Μ λ t h e m a t i c s
Note that the frame i n all examples o f this section is not produced by the code presented. We see that the defaults for the theorem environments are as follows. The out put name is w r it te n in bold, then the number follows, whi ch is the section's number, followed by the theorem's counter. Tine alternate position of the optional argument [count er] f o r the lemmata, corollaries, and so on, says that the counters for these are the same as the theorem's counter, which, in turn, is defined from the section's number followed by the theorem counter. If, for example, we had set \newtheorem{lemma}{Lemma} [thm], the number of our lemma above w o u l d not be 5.4.2 b u t 5.4.1.1. I n other words, the theorem's number is followed by the theorem's counter. A f t e r that, the theorem's text is set i n italics.
There is one optional argument fo r all of the theorem environments that is used to typeset the name o f the people w ho proved the theorem or a theorem's name, i f such a name exists. For example, we could w r i t e
\b e g i n { t h m } [ E u c l i d ]
There are i n f i n i t e l y many primes.
\e n d { th m }
lo get
Theorem 5.4.3 (Euclid) 7here are infinitely many primes.
o r, i f w e ar e i n a m u l t i l i n g u a l e n v i r o n m e n t w e can set t h e l a n g u a g e w i t h t h e r e l a t i v e c o m m a n d. F o r e x a mp l e, t h e c o d e
\b e g i n { t h m } [\t e x t g r e e k { E u c X e ί δ η ς } ]
T h e r e a r e i n f i n i t e l y many p r i m e s.
\e n d { t h m }
c a n be used t o g e t
T h e o r e m 5.4.4 ( Ε υ κ λ ε ί δ η ς ) There are infinitely many primes.
Δ
Somet i mes, i t happens t hat i mmedi at el y af t er t he t heor em header, we need a l i ne br eak. Thi s happens when t he t heor em's des c r i pt i on i s l ong and t he f i r s t w o r d of i t s st at ement does no t f i t on t he l i n e and cannot be hyphenat ed ( i t may be one syl l abl e). Thi s pr obl em appear s agai n when we t ypeset w i t h a smal l er t e x t wi d t h, as i n a mu l t i c o l u mn envi r onment. The way t o achi eve t hi s l i n e br eak i s t o use an \h f i l l command af t er t he \ beg i n { t h e o r era} and l eave a bl ank l i ne af t er t hat, l i k e t h i s:
54 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ γ Φ · 119
\begin{thm}\hf i l l
There are i n f i n i t e l y many primes.\end{thm}
Note that the \h f i l l command puts an infinite glue (see page 21).
Since the theorem environments use a counter, we can label them so that we can refer to them later on. For example, we w r i t e
\begin{lemma}- \l a b e l { p r i m e D i v i s o r s - l e m m a }
Every i n t e g e r has a t l e a s t one prime d i v i s o r.
\end{lemma]-
Using Lemma \r e f { p r i m e D i v i s o r s - l e m m a } we can now prove \b e g i n { t h m } [ E u c l i d ]
There are i n f i n i t e l y many p rim e s.
\end{thm)-
i n order to get
Lemma 5.4.6 Every integer has at least one prime divisor. Using Lemma 5.4.6 we can now prove
Theorem 5.4.7 (Euclid) There are infinitely many primes.
5.4.8 C u s t o m i z i n g t h e t h e o r e m E n v i r o n m e n t
F o r a l o n g t i m e n o w, t h e t h e o r e m p a c k a g e b y F r a n k M i t t e l b a c h has b e e n t h e s t a n d a r d w a y f o r c r e a t i n g c u s t o m t h e o r e m e n v i r o n m e n t s. Rec e n t l y, a n e x t e n s i o n o f t h i s p a c k ag e w i t h t h e n a me n t h e o r e m has a p p e a r e d. I t w a s w r i t t e n b y W o l f g a n g M a y a n d A n d r e a s S c h l ec h t e, a n d i t i n c o r p o r a t e s m a n y a d d i t i o n a l f ea t u r es w h i l e r em a i n i n g c o m p a t i b l e w i t h t h e t h e o r e m p a c k a g e. Si nce i t w i l l t a k e s ome t i m e f o r t h i s p a c k a g e t o m a k e i t i n t o t h e s t a n d a r d d i s t r i b u t i o n s o f L5T^(, w e w i l l m a r k w i t h a + t h e c o m m a n d s t h a t a r e i n c o m m o n w i t h t h e s t a n d a r d t h e o r e m s t y l e. The p a c k a g e i n c l u d e s a s t a n d a r d f i l e w i t h d e f i n i t i o n s f o r t h e o r e ms. T h i s c a n b e u s e d as a n e x a m p l e o f h o w t o set u p y o u r t h e o r e m e n v i r o n m e n t s.
The f i r s t c u s t o m i z a t i o n p o i n t t o n o t e i s t h a t f o r e v e r y t h e o r e m d e f i n e d w i t h \n e w t h e o r e m { n a/)?e } {#a m e } a s t a r r e d v e r s i o n i s ma d e a v a i l a b l e t h a t i m p l e m e n t s t h e u n n u m b e r e d v e r s i o n o f t h e e n v i r o n m e n t name. The package provides the f o l l o w i n g options:
Theorem 5.4.5
There are infinitely many primes.
120 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
s ta n d a rd I t loads the standard definitions f o r theorem environments (contained i n file ntheorem. sdt). I t is good i f you are using English or German, b u t f o r other languages you must define them yourself, n o c o n f i g I t does not load the ntheorem. s t d file b u t the ntheorem. c f g file that you must create w i t h y o u r preferences and language settings, amsmath I t provides a co mp at ib i li ty layer w i t h the theorem commands o f the amsthm package.
thmmarks Enables automatic placement of QED1 symbols, t h r e f Extended theorem referencing.
h y p e r r e f Provides a co m p at ib i li t y layer w i t h the h y p e r r e f package (see Section 6.2).
The ntheorem package uses the \newtheorem command as described i n the previous section. However, the f o l l o w i n g customization commands are also defined:
\theorempreskipamountf This is the amount of vertical space before the theorem starts.
I t can be positive or negative.
\t h e o r e m p o s t skipamount+ This is the amount o f vertical space after the theorem starts.
I t can be positive or negative.
\t h e o r e m s t y l e { s i i/l e } t This defines a style fo r theorems. We w i l l see h o w to define our own style b u t the package has several predefined styles. These are: p l a i n This is l ike I^Te X's default b u t uses \t heorempreskipamount and \t h e o r e m - postskipamount. break This produces a line break after the theorem's header, change The number is set first, and then the theorem's name follows, changebreak The same as change b u t w i t h a line break after the theorem's header, margin The number is set i n the l ef t margin.
marginbreak The same as margin b u t w i t h a line break after the theorem's header, nonumberplain Like p la i n w i t h o u t number (e.g., fo r proofs), nonumberbreak The same as nonumber b u t w i t h a line break after the theorem's header.
empty N o number and no name; only the optional argument is printed. \t he o re mh ea d e rf ont{_ font-commands}·* Specifies the font to be used for the header. \t heorembodyf ont-jf o nt-commandsy* Specif i es t h e fon t to b e u sed fo r t he b ody of t h e theorem.
\theoremseparator{sy/)?boi> The theorem separator can be "".", or anything you like.
\t h e o r e m i n d e n t { d i m e n s i o n } Indentation f o r the theorem w i t h respect to the sur­
ro u nd i n g text (no plus or minus here).
\theoremnumbering{s t y l e } Here, ag ai n,there are several styles: a r a b i c (the default), alph, Alph, roman, Roman, greek, Greek, and f nsymbol.
1. QED is an acronym of the Latin phrase Quod Erat Demonstrandum, which means which was to be demonstrated. The Latin phrase is a translation of the Greek phrase όττερ εδει δεΐξαι.
54 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ τ Φ · i2i
\theoremsymbol{s?/mbo I > Theorem symbol to be set at the end o f the statement only i f the package is used w i t h the thmmarks option.
\t h e o r e m c l a s s { £ i/^ e } A l l parameters are set to values that were used when \new- theorem was issued. I f t y p e is set to LaTeX, the standard l ayout is chosen.
A l l o f these must be set before we call \newtheorem. I f none o f the above are set, then the default scheme is the same as I^Te X's default. That is,
\t h e o r e m s t y l e { p l a i n }
\t h e o r e m h e a d e r f o n t {\n o r m a l f o n t\b f s e r i e s }
\t h e o r e m b o d y f o n t {\i t s h a p e }
\t h e o r e m s e p a r a t o r { }
\t h e oremindent{Ocm}
\t h e o r e m n u m b e r i n g { a r a b i c }
\t h e o r e m s y m b o l { }
Another interesting feature o f the package is its a b i l i t y to create a l ist o f theorems similar to the l is t of figures. This is done using the command \l i s t o f theorems{ l i s t }, where l i s t is a comma-separated l is t o f the theorem environments to be listed. For example, \l i s t o f theorems{theorem, c o n j e c t u r e } w i l l produce a l i s t o f the theorems and conjectures. Notice that i f a theorem is created w i t h its starred version, i t w i l l not be listed. The appearance and selection of w ha t theorems w i l l appear i n the l ist can be fu rt h e r customized w i t h the \t h e o r e m l i s t t y p e { t i/j?e } command. The t ype can be one o f the f ol lowi ng:
a l l L is t all theorems of the specified l i s t b y number, the optional name, i f i t exists, and the page number, allname L ike a l l b u t w i t h the theorem name at the beginning, o p t Like a l l, b u t only the theorems that have an optional name w i l l be listed, optname L ike o p t w i t h the theorem name at the beginning.
Similar to \a d d c o n t e n t s l i n e f o r the contents file, the package provides a w ay to add i nf ormat ion to the l ist o f theorems b y the command
\a d d th e ore ml in e {n a me } { t e x t }
where name
is the name of a va li d theorem and t e x t
is the text that should appear i n the list. For example, the line
\a d d t h e o r e m l i n e { C o n j e c t u r e } { T h e h y perpl ane c o n j e c t u r e }
has t h e same ef f ect as i f w e had w r i t t en i n our documen t t h e en v ir o n m en t
\b e g i n { C o n j e c t u r e } [The h y perpl ane c o n j e c t u r e ] \e n d { C o n j e c t u r e }
Note that the counter w i l l not advance f o r such a command. The starred version \a d d - t h e o r e m l i n e * is being set like the unstarred version b u t w i t h o u t the theorem number.
122 -φ- 5 T y p e s e t t i n g Μ λ τ η ε μ λ t i c s
The \add th e ore mf i l e [name] { t e x t } command adds the t e xt int o the theorem file. The optional argument controls to whi ch theorem lists the t e xt w i l l be added, and i f i t is omitted i t is added to all o f them.
The QED symbol is set automatically. I f one w oul d l ike to replace the stan­
dard symbol i n an environment, then one can redefine the \qedsymbol by using \q e d s y m b o l {symbo i > and then call this symbol by the \qed command. The \qedsymbol can be reset anywhere in the document. This feature is useful fo r closing lemmata or corollaries that are easy and where no proof follows. On the other hand, i n order to avoid setting the QED symbol, one can use the \NoEndMark command to tu rn o ff the automatic setting of the symbol. I t can now be set manually w i t h the command \nameSymbol l ike \theoremSymbol.
Δ
Extended reference features are activated when tlie package is used with the thraref option. The Mabel command is extended to use an optional argument \
l a b e l { label > [ fct/pe ], which characterizes the label as belonging to a spe­
cific theorem environment. This additional information is used by the command \t h r e f { label > as follows. If, for example, the type in the Mabel command is "Lemma" and the number of this environment is 4.3.7, then i f we refer to that label with \t h r e f { label 1, it w i l l produce "Lemma 4.3.7" instead of "4.3.7" as the \r e f command produces. The optional argument is set automatically when the label is inside an environment. Thus, the labeling command Mabel{na/»e} [Lemma] has the same effect as the label in
\begin{Lemma}Mabel{name }
Notes on compatibility:
• The babel package must be loaded before the theorem package.
• I f you want to use the amsmath package with the ntheorem package, use
\usepackage{amsmath}
\usepackage[amsmath,thmmarks]{ntheorem}
in that order.
• I f you want to use the features of the amsthm package, then instead of loading amsthm one should use the amsthm option of the ntheorem package. This option covers the theorem styles plain, d e f i n i t i o n, and remark as well as the proof environment. The \swapnumbers is not supported (see Section 5.5.21).
• When using the hyperref package, load the ntheorem package with the hyperref option to ensure compatibility.
New theorem styles can be defined by the command \newtheoremstyle{na- me }{head } {optional -head }, The head must contain instructions on how to type­
set the theorem's header and should use two parameters, the ##1 and ##2. The commands used to typeset ##1 are the commands that w il l be used to typeset the header of the theorem (theorem, lemma, and so on) and the commands used to
54 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ γ Φ · 123
typeset ##2 are the commands that w i l l be used to typeset the number of the envi­
ronment in the header. The optional-head has three arguments, and the commands for the third argument ##3 are used to typeset the optional theorem argument. Both header declarations must be of the form \i t e m [. . . \theorem@headerfont ... ] .. ., where the user must insert the dotted parts. Implicit spaces must be taken care of in the case where there are statements producing output after the \itera [...]. Here is an example of a new theorem style defined in the preamble of a document that would have been suitable for the days when people could be satisfied with just one text font:
\usepackage{letterspace,ntheorem}
Vnakeatletter °/„°/„ needed since the special character <§ i s used below \newtheoremstyle{oldstyle}%
{\i t e m [\hskip\labelsep%
\upshape ##2\ \, \mbox-[0/0
\upshape\letterspace t o 1.5\naturalwidt h{##l:}} % \theorem@separator]\upshape}%
{\i t e m [\hskip\labelsep%
\upshape ##2\ \,\mbox-[\upshape\letterspace t o 1.5%
\naturalwidth{##3’ s\ ##1:}}%
\theorem@separator]\upshape}
\makeatother
Ytheoremstyle-Coldstyle}
\newtheorem{thm}-[ Theorem}
Now, the code
\begin{thm}[Cauchy-Goursat]
I f a f u n cti o n $f$ i s a n a l y t i c i n the i n t e r i o r of a simple curve $C$ as w e l l as on the curve, then $\int_C f ( z )\,d z = 0 $. \end{thm}
w i l l produce:
1 C a u c h y - G o u r s a t ’s T h e o r e m: If a f u n c t i o n / i s a n a l y t i c i n t h e i n t e r i o r o f a s i m p l e c u r v e C a s w e l l a s o n t h e c u r v e, t h e n j c f ( z ) d z — 0.
Similarly, one can define new theorem list environments with the command
\newtheoremlisttype{na/»e } { s i a r i } { line } { e n d }
where name is the list's name, st art refers to the commands to be executed at the beginning of the list, end refers to the commands to be executed at the end of the list and I ine is the part to be called for every list entry. The completed command must be a statement wit h four arguments: ##1 w i l l be replaced by the theorem's name, ##2 with the number, ##3 with the theorem's optional name and ##4 with the page number. Defining new lists may break compatibility with the hyperref package. Finally, let us note that the theorem lists can be redefined with the command \renewtheoremlisttype with the same arguments as \newtheoremlisttype.
124 ^ 5 T y p e s e t t i n g M a t h e m a t i c s
5.4.9 E q u a t i o n s
One of the most important advantages o f I^TgX over p la i n TgX is the easy interface that i t provides f o r typesetting equations plus the automatic numbering, labeling, and referencing fo r them. The easier way to produce a math display is w i t h the double dollars, as i n p la i n TgX. However, this does not p rovide automatic numbering, so ΐίΤβΧ provides the environment e q ua t io n. Here is an example:
Do you k n o w this identity?
a2 = b2 + c2
(5.1)
This is the Pythagorean the­
orem i f a, b, c are the three sides of a r i g h t triangle.
Do you know t h i s i d e n t i t y? \b e g i n { e q u a t i o n } - a~2=b~2+c~2 \e n d { e q u a t i o n } - T h i s i s t h e Pythagorean theorem i f $a$, $b$, $c$ are t h e t h r e e s i d e s o f a r i g h t t r i a n g l e.
The equation above has (by default) the numbering at the r i g h t of the equation, and the equation is centered. The document class options leqno and f l e q n change these two defaults. The f i r s t puts the equation number at the lef t o f the equation, and the second one sets the equations flush left.
I n some cases, we want to substitute the equation number w i t h a word. For this, we use the \eqno command as i n the f o l l o w i n g example:
Γ h B T,\A h B
( w e a k e n i n g )
$ $\f r ac- [\Gamma \v d a s h B } {\Gamma, !A \v d a s h B } \e q n o\m a t h r m { ( w e a k e n i n g ) } $ $
V e r y o f t e n, w e w a n t t o w r i t e s e v e r a l e q u a t i o n s i n o n e d i s p l a y a l i g n e d a t s ome s y m b o l. F o r t h i s, I ^Te X p r o v i d e s t h e e q n a r r a y a n d t h e e q n a r r a y * e n v i r o n m e n t s. The f i r s t n u m b e r s each e q u a t i o n, w h e r e a s t h e s ec ond do es n o t p u t n u m b e r s. H e r e ar e s ome e x a mp l e s:
Some f a m o u s e q u a t i o n s: Some f a mo u s e q u a t i o n s:
\b e g i n { e q n a r r a y }--------------------
E &=& \h b a r \c d o t \n u \\ E &=& m \c d o t ο Λ2 \\ \o i n t \v e c { B } \c d o t
d\v e c { S } &=& 0 \\ \v e c { S > &;=& \f r a c l {\m u _ 0 >
E = %■ v E — m · c2
B ■ dS =
0
(5.2)
(5.3)
(5.4)
X
(5.5)
\v e c { E } \t i m e s \v e c { B } \e n d { e q n a r r a y }
Do you r e c o g n i z e them?
Do you recognize them?
Notice that the double backslash denotes the end of a line, and the character & controls alignment. M oreover, notice that Ί^Τε Χ p u t s some w hite space around the symbol.
5-4 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ τ Φ - 125
Δ
Naturally, we can customize the amount of white space that IAT^X puts around the aligned symbol. To do this, we simply set the length variable \arraycolsep in a local scope that encloses the eqnarray environment, which is what we did in the next example. Of course, i f we set this variable in our document's preamble, then the effect is global.
Sometimes, we want to w r i t e such an equation array bu t do not want to number all o f the equations. This can be done w i t h the \nonumber command:
\b e g i n { e q n a r r a y }
rn {2
A
sin xdx = - cos .V
n/2
(5.6)
π
— - cos — - ( - cos 0)
= —0 — ( —1 )
= 1
\i n t _ 0 ~ {\p i/2 } \s i n x \,d x &=& -\c o s x\b i g g m | _ C r {\p i/2 }\\ &=& -\c o s\f r a c {\p i } 2
- ( -\c o s 0) \nonumber \\
&=& - 0 - ( - l ) \nonumber \\
&=& 1 \nonumber \e n d { e q n a r r a y }
However, we should use the e q n a r r a y * environment i f we want no numbers at all. One may note that the command \biggm above is not yet discussed. This is the subject of the next section.
Now, we w i l l see h o w to typeset logic proofs since these require more attention. We need the proof package (by Makoto Tatsuta). The package provides the command \i n f e r [ l ab e l ] { l ower } { upper }, whi ch draws an inference labeled w i t h label. I f we p u t an asterisk after the command (\i n f e r * [. . . ] ), i t draws a many-step deduction. I f the star is changed to the = sign, i t draws a double-ruled deduction. I t also provides the command \deduce [proof] { l ower} { upper}, whi ch draws an inference w i t h o u t a rule w i t h a proof name. g g
Thus, \i n f e r { A } { B } a n d \d e d u c e { A } { B } produce A and A. To produce many steps, we just use the alignment character &, and the code for the fi rs t equation o f the display
F & G & H
7T
D
A & B & C
H 0
(Scl)
C & l D Β Γ.
( 5.7)
\[ \p i = \v c e n t e r {\i n f e r [ (\& I ) ] { A\,\&\» B\,\&\,C } { D &
\i n f e r = [ (\t o I ) ] { E } { F\,\&\,G\,\&\,H }\h s p a c e { 2 e m } } }\]
w h e r e \v c e n t e r c e n t e r s i t s a r g u m e n t v e r t i c a l l y t o t h e b a s e l i n e a n d \h s p a c e i s u s e d i n o r d e r t o ma k e t h e s ec ond t o p a r g u m e n t b i g g e r t o f o r c e a b i g g e r i n f e r e n c e l i n e. The c o d e f o r t h e s ec ond e q u a t i o n i s
126 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
\i n f e r{A )~C\i n f e r * [ ( 3 ) ] & E}
5.4.1 0 S i z e S e l e c t i o n i n M a t h M o d e s
Size selection f o r delimiters has already been discussed through the \l e f t and \r i g h t commands. These commands provide automatic adjustment of the size o f the delimiters to the size o f the expression that they enclose. However, there are cases where we want to force a specific size.
Suppose that we want to w r i t e ((« + l )/n ) . I f w e t y p e $\l e f t ( ( n + l )/n \r i g h t )
A2$, we w i l l get ((n + 1 ) j n) , whi ch is not as satisfactory. Here, we w ant to force M e K to make the size o f the external parentheses bigger. The \l e f t and \r i g h t com­
mands do not fail, they do p ro pe r l y enclose the expression that they surround. The problem is w i t h our aesthetics, w h i c h require bigger parentheses since the inner ex­
pression also uses parentheses and not because the inner part creates a larger box that the external parentheses failed to surround. The correct i n p u t f o r this task is $\b i g l ( ( n + l )/n \b i g r ) ~2$. LTgX provides the f o l l o w i n g commands f o r predeter­
m i n i n g the size o f a delimiter:
$\B i g g l ( \b i g g l ( \B i g l ( \b i g l (
\ \b i g r ) \B i g r ) \b i g g r ) \B i g g r ) $
The same commands w o r k f o r a ll delimiters lef t or right. Another application o f this f a c i li t y is when w r i t i n g b ig operators such as \sum. I n the next display, the second expression (which used \b i g g l ( \b i g g r ) parentheses) looks better than the fi r s t (which u s e d\l e f t ( \r i g h t ):
\ 1/2 / 00 \ 1/2____________________________________
Ι>») (Σ>») ·
. i— 1 / 2—1
There are some delimiters though that do not come i n pairs, such as the character /. For these, the commands are
4/5/6/ 7/8
$3\Biggm/ 4\b i g g m/ 5\B i g m/ 6\b i g m/ 7/8$
5.4.1 1 C o m m u t a t i v e D i a g r a m s
Commutative diagrams are often used i n mathematics to depict a relation between mathematical entities. I n this section, the term "d i a g r a m" w i l l stand f o r commutative diagram. There are several ways that one can d r a w diagrams. One o f them is presented as part o f the Am.S packages i n Section 5.5.16. However, this is not a complete solution since i t cannot produce diagonal arrows. A complete solution is p rovided by the kuvio package of A n d ers Svensson and t h e pb- diagram package o f Paul Burchard.
54 T h e A r t o f T y p e s e t t i n g M a t h e m a t i c a l Τ ε χ γ Φ · 127
Both packages w o r k w i t h a conceptual g r i d and attach nodes and arrows to it. The pb-diagram package provides the environment diagram. The two main commands are \a r r o w and \node. The syntax of the command \a r r o w is like this: \a r r o w { x The { χ, y> show the direction of the arrow. The parameter x can take all of the cardinal points o f the compass; that is, i t can be e (for east), w (for west), s (for south), and n (for north) and their intermediate positions: ne, nw, se, sw, nne, nnw, sse, ssw, ene, ese, wnw, and wsw. I f pb-lams is used, we have additional directions available. These are nee, see, nww, sww, neee, mine, nnnw, nwww, swww, ssse, seee, nnnee, nnnww sssww, sssee, nneee, nnwww, sswww, and sseee. The argument y sets the position of the label z w i t h respect to the arrow. I t can be t (for top), b (for bottom), 1 (for left), and r (for right ). The \a r r o w command can be used w i t h a dditional arguments:
\a r r o w [ s ] { χ,y 1,y 2 } { z > or \a r r o w [ s ] { χ, y 1, y 2 > { z l } { z 2 >
I n the second case, we have t w o labels: the z l and z2 that are set above and below the a rrow ( y l = t b ) or lef t and r i g h t ( y l = l r ). The y2 argument i n both o f the syntaxes above specifies the a r r o w shaft head and ta i l to be used. Most of the f o l l o w i n g options are available i f either the pb-lams or the pb-xy package is used. Shafts can be .. f o r dotted lines, = f o r double lines, and ! fo r invisible lines. The head can be - f o r no arrowhead, <> fo r arrowheads at both sides, A for double arrowhead, ’ fo r lef t h a lf arrowhead, and ‘ f o r r i g h t h a lf arrowhead. The t a i l can be V f o r single arrow tail, J f o r l ef t hook arrow tail, and S f o r square a r r o w tail. The s i n the optional argument sets the number of columns or rows that the arrow w i l l span.
The position o f the label on the a rr ow length can be set b y d i v i d i n g the arrow int o a number of pieces, adding a y3 argument to hold the a r r o w shape information, and g iv i n g to the y2 option the number o f the piece on w h i c h the label w i l l be set. The d i v i s i o n is done b y setting the \dgARROWPARTS (by default, \dgARR0WPARTS=4; thus, the y2 can be 1, 2, 3, or 4).
The \node command is used i n the fo r m \n o d e { n o l s } { f ormula}, where n c o l s is a number that sets how many columns after the last node the f o r m u l a w i l l be set.
The typesetting of diagrams is w r i t t e n i n rows, and we move to the next r o w b y \\. Here is a simple example:
\b e g i n { d i s p l a y m a t h } -
x — > y
V
\b e g i n { d i a g r a m } \n o d e { X }\a r r o w { s, l M p } \a r r o w { e,t,.->{g> \n o d e { Y }\a r r o w { s,r } { q }\\ \n o d e { A } -\a r r o w { e,b,. .M r } ·
A B \node{B}-
\end{diagram}- \e n d { d i s p l a y m a t h }
and here is a rather complex example (we used the lamsarrow, pb-lams, and pb-diagram packages):
128 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
A\ ---------------------> A2
The code f o r this (and i t w i l l be good f o r the reader to study it) is $ $\b e g i n { d i a g r a m }
\node [ 3 ] {A_l}- \a r r o w [2] { e, \node [2] - fA_2}\arrow [2] { s, ’ }\\
w
\node-[ B_l}-\arrow [2] { n e, 1, =}-Cb_l}-\arrow-Ce, t, - } { b _ 2 } - \n o d e { }\a r r o w { e ,b)-[b_3}-\node-[B_2}· \a r r o w [2] { n,r, . -!Kb_4}
\a r r o w [2 ] { e,t, J}{b_5}-\node [2] {B_3)-\arrow [2] { s w, L }\\
w
\node{C_l}- \a r r o w [ 2 ] { n n e,l,l } - { c _ l ) - \a r r o w [ 2 ] {n e,r } - { c _ 2 ) - \node [ 2 ] {C_2}-\arrow [2 ] { w, t, <>, . . }"Cc_3)-\arrow [2 ] { e, t, A}-[c_43·
\a r r o w [2 ] { η, l r, S}{c_5}-[c_6}· \node [2] {C_3}- \end{diagram}-$$
I f these capabilities o f the pb-diagram package are not enough for the user (and this can happen), then, most probably, the capabilities of the kuvio package w i l l cover the reader's needs. This is a b i g p la i n T^ X macro package w i t h a Ι^Τ^ Κ w rapper package. The reader can check the documentation of this package, whi ch provides more features than simply diagrams. For example, i t provides some a dditional math symbols, i nc l u d in g a circle symbol f o r composition of functions (the \c i r c command produces a circle that is too b ig f o r compositions). The package documentation can be found at f t p: //f t p. math. u b c. c a/p u b/s v e n s s o n/k u v i o/ w it h n a m e td w k-A4. p s. gz or t d w k. p s. gz. The package itself is available fr o m the CTAN.
5.5 The Λ/^φ
Classes and Packages
The Aj\z(S document classes amsart, amsbook, and amsproc fo r articles, books, and proceedings, respectively, provide a much better control f o r mathematical text than the standard document classes. This is w h y these are usually the preferred classes f o r texts containing a l o t of mathematics. I n a m u l t i l i n g u a l environment, the classes have a problem w i t h accented letters i n the r u n n i n g heads. The problem is solved i f one uses t h e t extcase package b y Davi d Carlisle. Actually, t h ese classes p r o v i d e t h e
5.5 T h e A m S C l a s s e s a n d P a c k a g e9v>· 1 2 9
same f u n c t i o n al i ty as the amsmath package plus the document design characteristics o f the Aj\/{S publications. So, one may either d ire c t ly use one o f these classes or load the amsmath package w i t h any other class. Note that this package defines the \AmS command, w h i c h print s the Aj ^S logo.
In the fo l lo w i ng, we discuss the features provided b y the amsmath package plus some a dditional packages provided b y the Aj^S, such as amsthm f o r customizing theorem environments and amscd f o r commutative diagrams. Since these are loaded b y the Α μ § document classes, w h a t we w i l l say is v a l i d f o r both strategies {Aj ^S classes or any class plus amsmath and other Aj ^S packages). We w i l l refer to either of these strategies by saying "t h e Aj\4S packages."
Information about these classes can be found i n the Aj ^S documentation o f the ^ V f £ _^T|i>( d istributi on, as these packages and classes are usually called. I n version
2.0 the file to look at is i n s t r - 1. d v i, whi ch presents useful i nf ormat ion about article preparation f o r journals and describes also the commands f o r t i t l i n g (which are very similar to the standard a r t i c l e class o f I ^ Ie X). I f y o u r system has already installed these classes, this file is usually i n t e x m f/d o c/l a t e x/a m s c l s/.
5.5.1 A d d i t i o n a l S y m b o l s
The Am.S packages p rovide bo ld symbols, Greek letters included, through \b o l d s y m - b o l. Also, i ta li c capital Greek letters are p rovided b y using the letters "v a r" between the backslash and the name of the Greek letter. For example,
$\b o l d s y m b o l {\p i }\b o l d s y m b o l {\i n } \v a r P s i $
gives π 6 Ψ.
They also provide w ha t is k n o w n as "p o o r man's b o l d" f o r cases where the \b o l d - symbol command does not do anything (due to the lack of a bold g lvp h o f the symbol needed). The poor man's b o ld command is \pmb and simulates bold b y t y p i n g several copies of the symbol we want w i t h slight offsets. Here are a few examples:
\b e g i n { d i s p l a y m a t h }
Σ Π ν \pmb{\sum}-\pmb{\prod}-
_______________________________________\p mb {\b i g vee j -
Accents are also supported i n bold. The command $\mathbf {\t i l d e { A } } - $ w i l l produce the r i g h t (bold) accent above the bold A i n I ^ X: A. But w i t h the Α\φ packages we w i l l get the r i g h t t h i n g even fo r $\m a t h c a l {\v e c { A } } $ (A).
Alternatives to \mathbb and \m a t h f r a k are also provided, and they are \Bbb and \f r a k, respectively. They are useful when the standard IffT]gX commands have been redefined (as i n the case of the mathbbol package).
5.5.2 A c c e n t s i n M a t h
The Ajv[S packages p rovide better accents f o r math mode. The advantage is clear when one wants to use double accents. One should compare t h e following:
13 ° ^ 5 T y p e s e t t i n g M a t h e m a t i c s
standard Τ^ΤβΚ $\hat{\hat A}$ : A, A Μ β $\hat{\hat A>$ : A.
The same holds true f o r all other accents (see Table 5.3). Double accents take a l o t of processing time, and this is why, i f we use them repeatedly, i t is better to store the result of a double accent to a command using the \accentedsymbol available w i t h the amsxtra package. This command introduces a shorthand and should be used only i n the document's preamble. Here is an example:
\accentedsymbol{\Ahathat)-{7o \hat{\hat{A>}}
\accentedsymbol{\Ybrevedot}"C%
A and Y \dot-[\breve{Y)·}·}
$\A h a t h a t $ and $\Ybrevedot$
The commands \d d d o t and \d d d d o t produce t r i p l e and quadruple dot accents i n ad­
d i t i o n to the \d o t and \d d o t accents (which are already available w i t h standard I^TgX): $\d d d o t { E } $ and $\d d d d o t { T } $ give E and T, respectively.
Special symbols that are set as superscripts f o r m another k i n d of accent. These are useful i n math (for instance the Fourier transform uses a \h a t as superscript unless the function is a single letter or a few letters). For example,
$\b i g l (\e x p ( - x ~ 2 )\b i g r )\s p h a t $
gives ( e x p ( —x2)^j . Notice that we do not use the Λ character. The reader is recom­
mended to t r y the commands \spcheck, \s p t i l d e, \s p d o t, \s p d d o t, \sp d d d ot, and \sp b r e v e. A l l of them are available w i t h the amsxtra package.
5.5.3 D o t s
The Aj vfi packages pr ovide five commands f o r accessing d if fe re nt ly positioned ellipsis dots, \d o t s c represents "d o ts w i t h commas" l ik e this 1,2,...,n ( $ l,2,\d o t s c,n $ ). \d o t s b stands f o r "d o t s w i t h binary operator s/relations" as i n 1 + 2 + · · · + « ($1+2+ \d o t s b +n$). \dotsm. stands fo r "m u l t i p l i c a t i o n dots" as i n αια2 · · · α η ($a_l a_2 \d otsm a_n$). \d o t s i stands for "d ots w i t h i n t egra ls" as i n f A f B - · · ($\i n t _ A\i nt_B \d o t s i $ ). Finally, \d o t s o covers "o t h e r dots," w hi c h are none of the above: a .. .b +
... + c ( $ a\d o t s o b +\d o t s o +c$).
5.5.4 N o n b r e a k i n g D a s h e s
There are cases (such as when we give the page range of a reference) when we do not w ant to a ll o w a line break at the en dash point. This can be done w i t h the command \nobreakdash. So, i f you w r i t e "pages 321-345" as pages 321\nobreakdash—345, a line break w i l l never occur between the dash and 345. The command can also be used f o r combinations such as $ p $- a d i c. Naturally, one can define shorthands f o r commonly used constructs, b u t this is t h e subject of th e n ex t chapter.
5.5 T h e A m S C l a s s e s a n d P a c k a g e9v>· 1 3 1
5.5.5 O v e r a n d U n d e r A r r o w s
Standard I^TgX, as we have shown i n Section 5.4.3, provides the commands \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. Some additional commands i n c l u d in g underarrows are n o w available. A l l o f them are as follows:
\o v e r l e f t a r r o w \u n d e r l e f t a r r o w
\o v e r r i g h t a r r o w \u n d e r r i g h t a r r o w
\o v e r l e f t r i g h t a r r o w \u n d e r l e f t r i g h t a r r o w
For example, $\u n d e r l e f t a r r o w { x y } ’'{\o v e r l e f t r i g h t a r r o w { z w » $ gives xyzw. Note: This is not to be used f o r projective l imits. See Table 5.5.12.
5.5.6 M u l t i p l e I n t e g r a l S i g n s
The commands \i i n t, \i i i n t, and \i i i i n t give m u l t i p l e integral signs w i t h nice spacing between them i n both text and display styles. The command \i d o t s i n t gives t w o integral signs w i t h ellipsis dots between them. Also, the domain of integration is set nicely below these signs i f the \l i m i t s command is w r i t t e n immediately f o l l o w i n g the integral command:
JJ f { x,y ) d x d y JJJ f ( x,y,z ) d x d y d z
x x
f ( x,y,z,w) d x d y d z d w J J f ( x^' · · *' xk) x x
The code that generates these formulas has the f o l l o w i n g general pattern:
\ ( i i i ) i n t\l i m i t s _ X
5.5.7 R a d i c a l s
A better control f o r the placement of the root index is p rovided through the commands \l e f t r o o t and \u p r o o t. These commands shift the index of the root, g iv i n g a better appearance i n certain circumstances. I n the f o l l o w i n g example, we move the letter μ 3 units u p and 1 to the right:
$\s q r t [\mu] -f\nu")-$
V u
$\s q r t [\l e f t r o o t { - l 3 -\u p r o o t { 3 }\m u ] {\nu)-$
132 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
5.5.8 E x t e n s i b l e A r r o w s
The commands \x l e f t a r r o w and \x r i g h t a r r o w provide extensible arrows i n order to accommodate expressions above and below them:
f(x) ^
1
x ^ c o
$ 0\x l e f t a r r o w { x\t o -\i n f t y > f ( x )
\x r i g h t a r r o w [ x\t o\i n f t y ] { x\n o t i n\m a t h b b { Q } - } - 1$
5.5.9 A f f i x i n g S y m b o l s t o O t h e r S y m b o l s
St andar d I^TgX p r o v i d e s t he \s t a c k r e l c o mman d f o r p l a c i n g so me t h i n g above a b i n a r y r e l a t i o n. The Aj\/iS packages p rovide more general commands, \o v e r s e t and \u n d e r - s e t. These w o r k w i t h anything and not only w i t h b in a r y relations:
O
X $\o v e r s e t - C\c i r c } {\t e x t r m { X } } $
X $\u n d e r s e t {\a s t } {\t e x t r m { X } } $
*
5.5.1 0 F r a c t i o n s a n d R e l a t e d C o n s t r u c t s
The command \g e n f r a c provides an easy interface to define new fractions. Its syntax is as follows:
\g e n f r a c { l ef t - del i m} { r i ght - del i m} - {. l i ne - t hi c k ne s s }
{ dt yl e} { numerat or} { denomi nat or}
The lef t and r i g h t d e li m it e r s are used, f o r example, f o r b inomial expressions. The line thickness refers to the fraction line and is set to 0 p t f o r b inomial expressions. To select the style, we use a number f r o m 0 to 3. The number 0 is f o r display style, 1 fo r text style, 2 f o r script style, and 3 fo r script-script style.
By default, the f o l l o w i n g commands are defined:
Command
Expansion
\t f r a c { x H y >
\g e n f r a c O O - C H l H x H y }
\d f r a c { x } { y }
\g e n f r a c O O - C H 0 H x H y }
\binom-Cx}--Cy}
\g e n f r a c { ( > { ) H O p t H H x H y }
\dbinom{x)-{y)-
\g e n f r a c { ( > { ) K 0 p t > { 0 > { x > { y >
\tbinom-[x)"Cy)-
\g e n f r a c { ( > { ) H O p t H l H x H y }
The commands \t f r a c and \d f r a c p r ovide convenient abbreviations f o r {\t e x t s t y - l e\f r a c {. .} {. .} > and {\d i s p l a y s t y l e\f r a c {. .} {. .} }, respectively. Here is an ex­
ample:
5.5 T h e A m S C l a s s e s a n d P a c k a g e9v>· 1 3 3
^ l o g J $ $\t f r a c { l > { x >\l o g x$$
$ $\d f r a c { l } - [ x }\l o g x$$ Here is an example o f \dbinom and \t b i n o m:
l logX
$$\dbinom{n)-{k)-+
\f rac-C\tbinom{n3"[k}-3-[k! }$$
The special command \c f r a c is f o r w r i t i n g continued fractions:
$$
1 \c f r a c { l } { a +
\c f rac{l}"Ca+
\c f rac-[l}-Ca+-C
\aboveOpt \ddots}-
» >
$$
Λ +
a +
d “I- .
You can request that the numerators to be set to the lef t or r i g h t of the fraction line. This is accomplished b y using \c f r a c [1] or \c f r a c [ r ].
5.5.1 1 T h e \s m a s h C o m m a n d
The \ smash command zeros the depth (option b) or height (option t ) of characters and is useful fo r alignments. I n the f o l l o w i n g example we present t w o dif ferent formulas typeset using the \ smash command (odd rows) and w i t h o u t using the \ smash command (even rows). The reader should have a close look at the result to see the difference.
v ^ “i- V y “i- V% ^
+ Vv
+ _______________________ ( i - V X i ) x
(1 - v ^) x
5.5.1 2 O p e r a t o r N a m e s
$\s q r t { x } - +\s q r t {\s m a s h [ b ] { y } - } - +\s q r t { z } $ $\s q r t { x } - +\s q r t { y } - +\s q r t { z } - $
$ ( l -\s q r t - C\s m a s h [ b ] {\l a m b d a _ j » ) X$
$ ( l -\s q r t {\l a m b d a _ j } ) X$
W e s a w i n S e c t i o n 5.4.2 h o w t o d e f i n e n e w f u n c t i o n s/o p e r a t o r s w i t h s t a n d a r d I f f l i g X.
T h e Aj\4S packages pr ovide an easy interface fo r this. I f you w ant to define the operator \random, all you have to say is
\Declare Ma th Op e r at o r{\r a n do m}{ra n d om}
There is also a starred form:
134 ^ 5 T y p e s e t t i n g M a t h e m a t i c s
\DeclareMathOperator*-C\LimMLim}-
This means that the defined operator should have subscripts and superscripts placed i n the “ l i m i t s" positions (above and below like, say, the \max operator).
I n a d d i t i o n to the ones already predefined b y standard I^TgX (see Table 5.24), we also have the f o l l o w i n g available:
\i n j l i m (i nj l i m ) \l g (lg) \p r o j l i m (proj l i m ) \v a r l i m s u p ( l i m )
\v a r l i m i n f ( l i m ) \v a r i n j l i m ( l i m ) \v a r p r o j l i m ( l i m )
There is also the command \operatorname such that \operatorname-[xyz}- can be used as a b in a r y operator. You can use \operatorname* i n order to get l imits.
5.5.1 3 T h e \m o d C o m m a n d a n d i t s R e l a t i v e s
The several space conventions f o r the mod notation are handled b y the commands \mod, \bmod, \pmod, and \pod. The second and t h i r d commands are available i n standard I^TgX as well. Here is an example:
gcd(m, n mod n) x = y (mod b) x = y mod c x = y (d)
$\gcd(m,n\bmod n)$ $ x\e q u i v y \pmod b$ $ x\e q u i v y\mod c$ $ x\e q u i v y \p o d d$
5.5.1 4 T h e \t e x t C o m m a n d
The command \t e x t is provided f o r w r i t i n g text i n math mode. I f the text is to be w r i t t e n i n sub/super-script position, the text size is adjusted automatically, and this is
its main advantage over the previously described method using a \mbox:
f { x ) X2
$$f ( x )\s t a c k r e l {\t e x t { d e f )-}-{=} x*2$$
I n a m u l t i l i n g u a l environment, the command w i l l use the current text language and w i l l accept language-specific commands.
5.5.1 5 I n t e g r a l s a n d S u m s
We have seen how to deal w i t h stacked expressions under a \sum symbol using the \a t o p command. The Am S packages provide the command \s u b s t a c k and the sl ightly more general environment subarray, w h i c h has a column specifier:
5.5 T h e A m S C l a s s e s a n d P a c k a g e9v>· 135
Σ/Μ
neZ n> 0
\b e g i n { d i s p l a y m a t h } \sum_-C\substack{ n\i n\m a t h b b Z\\ n\g e q 0 » f (n) \e n d { d i s p l a y m a t h }
Σ /(»)
neZ
0<«<A:!
\b e g i n { d i splaymath} \sum_{%
\b e g i n { s u b a r r a y }"C l ] · n\i n\m a t h b b Z\\ - k!\l e q n\l e q k! \e n d { su b arr a y}-} f (n) \e n d { d i splaymath}
I i one wants to p u t accents and l im i t s on a large operator, he or she can use the command \s i d e s e t. Here is an example that f u l l y demonstrates the capabilities of this command:
b
2ς 4
1 ^ 3
a
$$\sideset{_l''2>-C_3''4}\sum_a''b$$
5.5.1 6 C o m m u t a t i v e D i a g r a m s
Commutative diagrams are supported w i t h the amscd package. This is provided n o t as a complete solution b u t as a package f o r a quick diagram, d ra wn w i t h o u t diagonal arrows (for a complete solution, see Section 5.4.11). Consequently, we w i l l not go to the trouble to describe the f u n c ti o n al i t y of this package. Here is an example that demonstrates the use of the package:
\b e g { d i splaymath} \begin{CD>
A @>a>b> B\\
C
D
OVcVV OAAdAW
C 0= D \end{CD}- \e n d { d i splaymath}
5.5.1 7 D i s p l a y e d E q u a t i o n s a n d A l i g n e d S t r u c t u r e s
Maybe the biggest advantage of using the A v f S packages is the a b i l i t y they give to better deal w i t h displayed and aligned environments ^ n u c h better than the already discussed eq na rra y environment o f I£T|iX. These environments are:
e q u a t i o n e q u a t i o n * a l i g n a l i g n *
g a t h e r g a t h e r * f l a l i g n f l a l i g n *
m u l t l i n e m u l t l i n e * a l i g n a t a l i g n a t *
s p l i t g a th e re d a l i g n e d a l i g n e d a t
136 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
x = y
(Λ*?)
The eq na rra y environment can s ti l l be used, b u t i t is preferable to use the a l i g n envi­
ronment or a combination o f the e q u a t i o n environment plus the s p l i t environment.
The starred forms (except s p l i t ) do not number the environment. You can also suppress the number o f any line b y p u t t i n g \n o t a g before the \\. The \nonumber command is s ti l l v a l i d and can be used. I f we w ant to give a specific tag to a line, we can use the \t a g command:
\b e g i n { e q u a t i o n ) - x=y\tag{$x~y$?>
\e n d { e q u a t i o n }
Notice that \t a g automatically puts the given text i n parentheses. This can be avoided w i t h its starred version: \t a g *. The s p l i t environment can o nly be used inside some o f the other environments (except m u l t l i n e ).
The most i mpo rta n t difference f r o m the standard eqnarray environment is that here we have no extra w hi t e space around the aligned symbol, and the main syntactical difference is the use o f a single & i n f r o n t of the symbols to be aligned instead of surrounding the symbol b y tw o &. Here are some examples:
\b e g i n { e q u a t i o n }
\b e g i n { s p l i t } a & = b+c+d \\
& \quad + e + f\\
& = g + h\\
& = i \e n d { s p l i t }
\e n d { e q u a t i o n }
Notice here that the s p l i t environment is treated as one mathematical f ormula and therefore takes only one number. The same happens w i t h m u l t l i n e:
a — b c d + e + f = g + h — i
( 5.9)
ci-\-b-\-c-\-d-\-6-\-
+ 1 + 2 + 3 + 4 + 5 ( 5.10)
\b e g i n - C m u l t l i n e } a + b + c + d + e + f\\ +1+2+3+4+5
\e n d - C m u l t l i n e ) -
The m u l t l i n e e n v i r o n m e n t i s u s e d f o r e q u a t i o n s t h a t d o n o t f i t o n o ne l i n e, a n d i t a l w a y s set s t h e f i r s t l i n e o f t h e e q u a t i o n f l u s h e d t o t h e l e f t a n d t h e l a s t l i n e f l u s h e d t o t h e r i g h t ( a p a r t f r o m t h e i n d e n t a m o u n t \m u l t l i n e g a p ). I f t h e r e a r e m i d d l e l i n e s, t h e y a r e c e n t e r e d i n d e p e n d e n t l y w i t h i n t h e d i s p l a y w i d t h. Th i s c a n c h a n g e w i t h t h e c o m m a n d s \s h o v e l e f t a n d \s h o v e r i g h t. These c o m m a n d s t a k e t h e e n t i r e e q u a t i o n l i n e as a n a r g u m e n t ( e x c e p t t h e f i n a l \\).
The g a t h e r e n v i r o n m e n t a l l o w s u s t o w r i t e s e v e r a l d i s p l a y e d f o r m u l a s w i t h o u t b i g v e r t i c a l spaces s e p a r a t i n g t h e m. M o r e o v e r, a n y o f i t s e q u a t i o n s c a n b e a s p l i t e n v i r o n m e n t:
5.5 T h e A m S C l a s s e s a n d P a c k a g e9v>· 1 3 7
\b e g i n { g a t h e r > a = b + c\\
(5.11) \b e g i n { s p l i t > d+e & = f + g\\
(5.12) h &= i
\end-Csplit }- \e n d { g a t h e r } -
The a l i g n environment is an enhanced version o f the standard e q n a r r a y. I n a ddi ti on to the better spacing around the aligned symbol, i t also accepts many align points:
a = b + c d + e = f + g h = i
a = b + c h = i (5.13)
d + e = f + g j = k (5.14)
\b e g i n { a l i g n } a &= b+c & h &= i\\ d+e &= f + g & j &= k \e n d { a l i g n }
The a l i g n environment can also be used f o r adding comments to equations:
\b e g i n { a l i g n } a &= b+c & &
\t e x t { b y axiom 5 }\\ d+e &= f+ g & &
\t e x t { b y t h e h yp o t h e s i s } · \e n d - [ a li g n } -
The variant a l i g n a t takes as an argument the number of columns that are to be aligned and leaves no space between them, w hi c h is useful f o r constructs such as
a = b + c b y axiom 5 (5.15)
d + e = f + g b y the hypothesis (5.16)
\begin{alignat}--C2}-
l O & ^ + l l l & v - l W
\ | X X X m A. V * /
x+ y = 0 (5.18)
The f l a l i g n environment sets the equations flushi o f the display. That is w h y the starred version is to be
&x+ &y=0 \e n d { a l i g n a t }
2d to the l ef t and to the r i g h t preferred. I f o n ly one p o in t of
alignment is given, then i t behaves l ike the a l i g n e nvin
a = b + c h = ι d + e = f + g j = k
m m e n t:
\b e g i n { f l a l i g n * }
a & = b + c & h & = i\\ d + e & = f + g & j & = k \e n d { f l a l i g n * } -
T h e e n v i r o n m e n t s t h a t w e h a v e s e e n t h u s f a r a r e d e s i g n e d t o p r o d u c e d i s p l a y s t h a t o c c u p y t h e f u l l w i d t h o f t h e d i s p l a y/p a g e. T h e e n v i r o n m e n t s g a t h e r e d, a l i g n e d, a n d a l i g n e d a t o c c u p y o n l y t h e s p a c e n e e d e d b y t h e e q u a t i o n. T h u s, t h e y c a n b e u s e d a s b u i l d i n g b l o c k s f o r c e r t a i n a p p l i c a t i o n s. F o r e x a m p l e:
138 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
w e l l - k n o w n equations
\b e g i n { e q u a t i o n * }
\l e f t.\b e g i n { a l i g n e d }
E &= mc',2\\
E &= h\n u \e n d { a l i g n e d }\r i g h t\} - \qquad \t e x t { % w el l - k no w n e q u a t i o n s } \e n d { e q u a t i o n * }
These -ed variants accept the optional arguments f o r vertical positioning [ t ] and [b] like the a r r a y environment.
Finally, the cases environment gives another way of typesetting nonanalytically defined functions w i t h tighter spacing between the de li m it e r and the array:
\b e g i n { d i splaymath}
\c h i _ A $ =
\b e g in { c a s e s } - 1 & \t e x t { i f $ l\i n A $ }\\
0 & \t e x t { o t h e r w i s e.} \end{cases}- \e n d { d i splaymath)-
Notice the absence of \{ i n the i n p u t above!
L5Te X is not allowed to break the displays produced b y the commands described thus far at the end o f a page. To a ll o w this i n a p articular line o f an equation, you must use \d i s p l a y b r e a k [ n ], where n can be either 0 or 1 or 2 or 3 or 4, immediately before the \\. I f n is set to zero, i t means that a break is permissible here, whereas i f i t is set to four, Ι^ΤβΧ is forced to break. I f you w ant this policy to be used systematically f o r all equations, you can p u t the command \a l l o w d i s p l a y b r e a k s [n ] i n the preamble of y o u r document, where n has the same meaning as the argument of the \d i s p l a y b r e a k command. Recall here that \\* prohibits a page break.
Displays can also be i nt errupted for inserting text using the \i n t e r t e x t command. A l i g n points are preserved:
x a
1 m e A 0 otherwise.
hence
II II
(5.19)
(5.20)
\b e g i n { a l i g n ) - x &= y\\ y &= z\\
\i n t e r t e x t { h e n c e }
X = z
(5.21)
x &— z \e n d { a l i g n }
5.5.1 8 N u m b e r i n g E q u a t i o n s a n d R e f e r e n c i n g
5-5 T h e A\i S C l a s s e s a n d P a c k a g e ^ 139
Δ
Equation numbers are usually set with respect to the section that the equation belongs to. Usually, the equation counter is used for this purpose; this counter is predefined for the book document class. For the a r t i c l e document class, we usually define
\renewcommand{\theequation}{\thesection.\arabic{equation}}
This works fine except that it must be reset at the beginning of each new section us­
ing the \setcounter command. The packages make this easier by providing the \nuraberwithin command, so we can set
\numberwithin{equation}{section}
Of course, this command can be applied to any other counter. Adjusting the tag placement can be done using the \r a i s e t a g command. For example, \r a i s e - tag{6pt> w il l raise the tag by 6 pt. For cross referencing, we additionally have the \eqref command as well as the standard \r e f command. The only difference is that \eqref also provides the parentheses around the equation number.
Finally, we can create subordinate equations with the subequations environ­
ment:
λ: - y (522)
y - z (5.23a)
ξ - w (5.23b)
\be g i n-f equat i on } x=y
\end{equation}
\begin-f subequations} \label{subeqnarray}
\be g i eqnarr ay} y &=& z\\ z &=& w \end{eqnarray}
\end{subequations}
Notice that we still need a math display environment inside the subequations environment. This inner environment can be any of the ones discussed in the previous section (here we used the standard eqnarray). In addition, you w i l l see that the numbers start from the next number after the last equation. The \r e f or \eqref command for these w i l l not produce the subordinate numbering but the parent one instead i f the label is immediately after the start of the subequations environment. Thus, i f we refer to the last eqnarray, we get (5.23).
The counters involved in the subequations are parentequation and equation. So, i f we want to change something, we can use standard IAT^X commands. For example:
\begin{subequation}
\renewcommand-C\the equat ion}{*/,
\theparent equat ion \roman{equat i o n } }
\end{subequ at i an}
140 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
5.5.1 9 M a t r i c e s
For matrices, the environments d i f f e r f r o m the standard a r r a y environment i n that they have predefined delimiters and a more compact appearance. On the negative side is the fact that they do not a ll o w alignment of the entries. For such a task, we must use the a r r a y environment. The available environments are the p m a t r i x ( w i t h parentheses as delimiters), b m a t r i x ( w i t h delimiters [ ]), v m a t r i x ( w i t h delimiters | |), and V m a tr i x ( w i t h delimiters || ||). I n a d di ti o n to these, we have the m a t r i x environment (for whi ch delimiters must be provided) and the s m a l l m a t r i x environment f o r matrices such that f i t nicely inside text. Notice that f o r the s m a l l m a t r i x environment the
as
a b c d
delimiters must also be provided. Thus, the small m a tri x above was
$\l e f t [\b e g i n { s m a l l m a t r i x } a & b \\ c & d \e n d { s m a l l m a t r i x } -\r i g h t ] $
The command Y h d o t s f o r{.number} produces a r o w o f dots that spans the given number of columns. Here is an example:
\b e g i n { d i s p l a y m a t h }
\b e g i n { m a t r i x ] - a&b&c&d\\ e &\h d o t s f o r { 3 }
\ end-[mat r i x } $ $
\end-Cdisplaymath}-
The \h d o t s f o r command takes an optional argument that is used as a mu lt ip l ica t ive factor for the distance between consecutive dots:
a
e
d
\b eg i n { d i splaymath}
\b e g i n { b m a t r i x }
a _ { l l > & a_{12> &
a_-[13}- & \d o t s & a _ { l n }\\
a_{21> & a_{22> &
a_{23}- fe \d o t s fe a _ { 2 n }\\
\h d o t s f o r [.5 ] { 5 }\\
\h d o t s f o r { 5 }\\
\h d o t s f o r [ 3 ] { 5 }\\ a _ { n l } & a_{n2> & a_{n3}- & \d o t s & a _ {n n}
a 1 1 a\2 di?,
#21 Λ 22 &23
d i n 0-2 n
d n\ &n2 &n?>
\e n d { b m a t r i x ) -
\e n d { d i s p l a y m a t h }
5.5.2 0 B o x e d F o r m u l a s
The \b o x ed command puts a fra me around its argument:
5.5 T h e A m S C l a s s e s a n d P a c k a g e9v>· 1 4 1
a + b = c (5-24)
\b e g i n { e q u a t i o n }
\boxed{a+b=c}
\e n d { e q u a t i o n }
5.5.2 1 C u s t o m i z i n g T h e o r e m s
Customization o f the appearance of the theorem-related environments can be done b y using the amsthm package. Like the theorem package discussed i n Section 5.4.8, i t recognizes the \t h e o r e m s t y l e specification and has a starred fo rm f o r unnumbered environments. I t also defines a p r o o f environment that automatically enters the QED symbol at the end of the proof. The available theorem styles are p l a i n, def i n i t i o n, and remark. The theorem styles are declared before the relative \newtheorem commands. For example, the preamble of a document may contain
\t h e o r e m s t y l e { p l a i n } % d e f a u l t \newtheorem{thm}{Theorem} [ s e c t i o n ]
\newtheorem{prop} [thm] { P r o p o s i t i o n }
\newtheorem{lem} [thm] {Lemma}
\n e w t h e o r e m { c o r } [ t h m ] { C o r o l l a r y }
\t h e o r e m s t y l e { d e f i n i t i o n }
\n e w t h e o r e m { d e f n } [ t h m ] { D e f i n i t i o n }
\n e wtheorem{exa}[t hm] {Exampl e}
\t h e o r e m s t y l e { r e m a r k }
\newtheorem{rem}[thm]{Remark}
\n e w t h e o r e m * { n o t e } [ t h m ] { N o t e }
The \swapnumbers command is available i n order to a ll o w the theorem number to be prin t ed before the theorem header:
5.1 Theorem. Every bounded monotone sequence in ]R converges.
C o r o l l a r y 5.2. A monotone sequence in R either converges or diverges to either 00 or
----------ΘΟ.----------------------------------------------------------------------------------------------------------------------------------------------
T h i s w a s p r o d u c e d b y i s s u i n g t h e \s wa p n u mb e r s c o m m a n d b e f o r e t h e d e f i n i t i o n o f t h e t h e o r e m e n v i r o n m e n t i n t h e p r e a m b l e a n d b e f o r e t h e d e f i n i t i o n o f t h e c o r o l l a r y e n v i r o n m e n t.
The p a c k a g e a l s o p r o v i d e s t h e c o m m a n d \n e w t h e o r e m s t y l e, w h i c h e nabl es u s t o d e f i n e c u s t o m t h e o r e m s t y l e s. The s y n t a x i s
\n e w t h e o r e m s t y l e { n a/n e of s t y l e y { s pac e - abo v e y
{ s pace- bel owy{ body- f ont y { i ndent amounty{Thm head f o nt y { punct uat i on a f t e r Thm heady {.space a f t e r Thm heady {.Thm head specy
142 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
The space-above is the space between the theorem and the last line o f the previous paragraph. The space-bel ow is the space between the theorem and the next paragraph. I f you leave these tw o empty, then the "u s u a l" space w i l l be used. The body-f ont declaration needs no explanation (you can use, f o r example, \i t s h a p e ). The i ndent amount is the indentation space before the header begins. I f you leave this empty, then no i ndentation w i l l be used. You can also use an already defined length such as \p a r i n d e n t f o r paragraph-like indentation. For example, Thm head f ont can be set to \b f s e r i e s and the punct uat i on a f t e r Thm head is the punctuation that w i l l be set after the theorem (for example, a dot: {.} ). Finally, space a f t e r Thm head is self- explanatory ( i f set to \n e w l i n e i t w i l l create a line break after the theorem head) and the Thm head s pec, i f set to [\t h m n o t#3 ], w i l l produce the comment i n the theorem's header, read fr o m the square brackets o f \b e g i n { t h m } [Thm Head s p e c ].
The p r o o f environment has an optional argument that customizes the head of the proof. For example, you may say
\b e g i n { p r o o f }- [ P r o o f o f t h e main theorem]
The shape o f the q e d symbol is controlled b y \qedsymbol. The default is □. I t can also be accessed, i f necessary, b y the \q e d command. I t frequently happens i n mathematics that a p ro of may end w i t h a display equation or array. I n these cases, the position of the q e d symbol is problematic. The nice way is to use the command \qedhere at the end o f the line where the display ends. For example,
Proof.
f(x) =x-x
= 0 □
was produced by
\b e g i n { p r o o f }
\b e g i n { a l i g n * } - f ( x ) & = x - x\\
&=0\qedhere \e n d { a l i g n * } - \e n d { p r o o f }
I t is i mpo rta n t to note that the amsthm package must be loaded before the amsmath package. I t is automatically loaded w i t h the document classes. I n case you get an error relating to the \qedhere command, t r y \mbox-C\qedhere} instead.
5.5.22 O p t i o n s o f t h e a m s m a t h P a c k a g e
The f o l l o w i n g options are available f o r the amsmath style file:
5.5 T h e A m S C l a s s e s a n d P a c k a g e9v>· 1 4 3
c e n t e r t a g s (default) place the equation number o f a s p l i t environment vertically centered on the total height o f the environment, t b t a g s place the number o f the s p l i t environment at the bottom of the environment i f the tags are on the r i g h t and at the top when the tags are on the left, s u m l i m i t s (default) place the sub/super-scripts of summation symbols above and be­
l o w the symbol i n displayed equations. This affects products, direct sums, and direct products as well, b u t not integrals (see two items below), n o s u m l i m i t s always place the sub/super-scripts to the side o f a sum (or similar) sym­
bol, even i n displays, i n t l i m i t s The same as s u m l i m i t s b u t f o r integrals, no i n t l i m i t s (default) The opposite o f i n t l i m i t s.
n a m e l i m i t s (default) L ike sum l imits, b u t f o r certain operator names such as det, inf, lim, max, min, and so on. n o n a m e l im i t s The opposite of n a m e l i m i t s. leqno Place equation numbers on the left, reqno Place equation numbers on the right.
f l e q n Position the equations at a fixed indentation fr o m the l ef t margin (not centered).
You can choose any of the options above w i t h the optional argument o f the \u s e - package command; f o r example, \usepackage [ n o s u m l i m i t s ] { amsmath}·.
5.5.2 3 C o n v e r t i n g f r o m S t a n d a r d t o t h e A\^ S P a c k a g e s
I f you have already w r i t t e n something b u t now you w ant to load the amsmath and other A\4S packages, you usually have only to load them and yo u r files should ru n successfully (provided that they are i n LTEX2g). Some changes that you may w ant to do are to substitute all eq n a r r a y environments w i t h the a l i g n environment and to use the p r o o f environment combined w i t h the \qedhere command f o r y o u r proofs that end w i t h displays.
5.5.2 4 T h e a m s a r t T o p M a t t e r C o m m a n d s
The top matter o f an Aj^tS article document contains i nf ormat ion about the author, the t i t l e subject classification, the key words, the abstract, and so on. I n Table 5.25, we see the commands defined b y the amsart class f o r such information. A l l arguments i n square brackets are optional and are not always necessary. A short ti tl e should be pro vid e d f o r use i n the r u n n i n g heads i f the t i t l e is too long. I n this case, we can force a line break i n the ti t l e using \\ or let LTgX take care o f this. A n author command is given f o r any author separately. The optional argument is f o r a shortened name, such as
\a u t h o r [ L. E u l e r ] {Leonard E u l e r }
144 ^ 5 T y p e s e t t i n g Μ λ τ η ε μ λ t i c s
Table 5.25: amsart top matter commands
\t i t l e [ short - t i t le ] { t i t l e }
\a d d r e s s {address>
\email{e/7iaii >
Xdedicatoryidedication}
\t h a n k s { t h a n k s >
\keywor ds{comma separated key words} \b e g i n { a b s t r a c t }...\end{abst ract}
\author [ short-name ] {name } \curraddr{current-a<2<2ress } \i i r l a d d r { f/?i l }
\d a t e { i i ( 2 i.e }
\t r a n s l a t o r { i r a n s l a i o r’s name}
\subj c l a s s [2000] {Primary ; Secondary } \m a k e t i t l e
Δ
Ι ί there are many authors and their names do not fit into the running head, then we can replace the running head names with "FIRST AUTHOR ET AL." by us­
ing \markboth{FIRST AUTHOR ET AL.}{short t i t l e in al l caps} (for more details on the \mathboth command, see the next chapter.) The \markboth com­
mand should come after the \m a k e t i t l e command.
For each author, we must provide an address. Line breaks in the address are again by \ V The same applies for the \c u r r a d d r i f an author is current ly i n another (temporary) address. The e-mail address is w r it t e n as usual (user@server .domain) and fo r the URL address, i f a ~ is needed, we use the command \t e x t a s c i i t i l d e. The class w i l l automatically use labels l ike "
E-mail address:.” In a m u lt i l i n g u a l environment, you should be careful, as these terms may not be translated i n the main document language.
The \t h a n k s field is provided fo r acknowledgments of grants and support, and i t can appear more than once i n the top matter.
The subject classification and keywords appear as footnotes b u t w i t h o u t f o o t n o t e ­
mark. The 2000 in the subject classification's optional argument follows the 2000 Mathe­
matics Subject Classification scheme ( h t t p: //www. auns. org/msc). I f the optional argu­
ment is omitted, the 1991 Subject Classification w i l l be used.
Finally, f o r the abstract, let us note that i t should be placed before
the \m a k e t i t l e command.
5.6 From A to MathML
This section shows how we can generate X M L content, in general, and M a THMLcontent, i n particular, from Λ i n p u t files. Therefore, the material presented here is not necessary for the understanding of the rest o f the book.
XML, the extensible M a r k up Language, is a standard f o r document markup that is getting universal acceptance. Data can be marked up w i t h simple, human-readable tags. In addition, X M L is becoming the standard format for computer-related documents.
5-6 F r o m Λ τ ο Μ α t h M L <>- 145
XML elements are delimit ed b y start and end tags. Start tags begin w i t h a <, and end tags begin w i t h a </. Both of these are followed b y the name of the element and are closed b y a >. For example,
< t i t l e > My A r t i c l e </t i t l e >
is a simple example of a title element. Note that this element has content. There are elements w i t h o u t content, w hi c h are called empty elements. Empty elements start w i t h a <, the name o f the tag, and close w i t h a /> (e.g., < h r/> ). X M L itself does not specify any parti cul ar formatting; rather, i t specifies the rules for tagging elements. These tags can then be interpreted to format elements i n dif ferent ways. SGML, the Standard Generalized M a r k u p Language, is a system f o r organizing and tagging elements o f a document. SGML, l ike XML, is used to mark u p documents, but, u n li ke XML, i t is a very complex system.
M a thM L is an X M L application that is p r i m a r i l y intended to facilitate the use and reuse o f mathematical and scientific content on the Web. Of course, other applications, such as computer algebra systems and p r i n t typesetting, are possible as well. I n general, Ma thM L markup is embedded i n t o H T M L documents. But, currently, o n ly Mozilla, Netscape's successor, can render Ma t h M L content.
Since many people w o u l d really love a tool that w o u l d a ll o w them to w r i t e ord in a ry I^T^X content and transform i t very easily to M a thM L the authors o f Ω have extended this system so that i t can d ire c t ly produce M a thM L content. These new features are described i n b r i e f i n [10]. Here, we w i l l t r y to completely document these new features.
The command \MMLmode2 tells Ω to enter Ma ra MLmo d e; that is, n o w mathematical formulas w i l l be o u t p u t as Ma t h M L instructions. The command \noMMLmode cancels the effect o f \MMLmode so mathematical formulas are o u t p u t as D V I instructions. Nev­
ertheless, i t is not enough to enter Ma thM L mode i n order to get M a thM L output: we must d e l i m i t each mathematical formula b y the commands \M M L s t a r t t e x t and \MMLendtext. Let us see a concrete example. Suppose that the code that is shown on the r i g h t of Table 5.26is stored i n file m a t h.t e x. Then, A w i l l generate two o u t p u t fi l es— math. mml, w hi c h w i l l contain the Ma thM L content (or, i n general, the X M L content), and m a t h.d v i, whi ch is just a normal D V I file. The code at the lef t of Table 5.26 is the o u t p u t generated b y A: N ow, th e next st ep i s t o see h o w we can generate a com p l ete H T M L or X M L file fr o m a A i n p u t file. I f we feed Λ w i t h the f o l l o w i n g i n p u t f i l e 3
\d o c u m e n t c l a s s { a r t i c l e } -
\begin-[document}
\MMLmode
\SGMLwrite{ <! ——Gener a t ed by Omega v er s i o n \0megaVer s i o n — >}---------------
\SGMLwriteln
\S G M L s t a r t t e x t t a g { h t m l } %
2. The discussion aplies to Ω version 1,15, new features introduced to versions 1.23 and later are discussed on Appendix E.
3, Whatever appears between <! — and —> is considered a comment and it is ignored.
146 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
Table 5.26: A A input file and the generated Ma t h ML content.
<mtext>
<inlinemath>
<math>
<mrow>
<mi> E </mi>
<mo> = </mo>
<mi> m </mi>
<msup>
<mi> c </mi>
<mn> 2 </mn>
</msup>
</mrow>
</math>
</inlinemath>
</mtext>
\SG MLst a rtte xtt a g{h e a d }% \S G M L s t a r t t e x t t a g { t i t l e } %
A Simple HTML document \S G M L e n d t e x t t a g { t i t l e } % \SGMLendtexttag{head}% \SG MLs t a rtt e x t t a g{b o d y }% \SGMLemptytag{hr>{>
Th i s i s a simple HTML document \SGMLloneta g { h r w i d t h = 1150\SGMLpercent11} {}% \SGMLendtexttag-Cbody}-% \SGMLendtexttag{html}-%
\e n d {d o cument}
then we w i l l get the f o l l o w i n g output:
<!— Generated by Omega v e r s i o n 1.1 5 — > <html>
<head>
< t i t l e >
A Simple HTML document </t i t l e >
</head>
<body>
< h r/>
Th i s i s a simple HTML document
<hr w i d t h =ll 50%n>
\document c l a s s i a r t i c l e } \begin{document} \MMLmode \MMLstarttext $E=mc"2$
\MMLendtext
\noMMLmode
$E=mc~2$
\end{document}
5-6 F r o m Λ τ ο Μ λ t h M L -φ- 147
</body>
</h t m l >
The command \S G M L s t a r t t e x t t a g is used to specify start tags and the command \SGMLendtexttag is used to specify end tags. The commands \SGMLemptytag and \SGMLlonetag are used to specify empty tags and lonely tags, which are tags similar to the <p> and <br> tags o f the H T M L markup language. The command \SGMLwrite is used to o u t p u t content to the . mml file, w h i l e the command \SGMLwriteln just changes line to the o u tp u t file. The command \OmegaVersion prints the current version of the Π typesetting engine. Since certain symbols have a predefined meaning but, at the same time, are frequently used in X M L and SGML content, Π provides the fo l lo w i n g commands, which generate the symbols on the left-hand side o f each column.
\SGMLampersand
&
\SGMLbackslash
\
\3GMLcarret
\3GMLdollar
$
\SGMLleft b r a c e
ΐ
\SGMLriglitbrace
}
XSGMLhash
#
\SGMLpercent
I
\SGMLunderscore
_
The commands \SGMLstartmathtag and \SGMLendmathtag are used to introduce M a t h M L elements. These commands are necessary when one wants to create macros and so forth.
A
Although the Π MathML engine is capable of handling a wide range of mathe­
matical expressions, there are still cases where it fails. The main problem is that it cannot handle complex macros well. For example, the \s q r t command is such a case:
<mtext>
<inlinemath>
<mi> x </mi>
</raath>
</inlineinath>
\documentclass{ a r t i c l e }
Ybeginidocument}
\MMLmode
\M M L c t a r t t e x t
$\s q r t { x } $
\MMLendtext
\end{document>
</mtext>
To assist Ω to produce correct Math ML output, we need to redefine the \s q r t
macro:
\renewcommand{\sqrt}{\®ifnextchar[\s qrt t w o\s q rt o n e} \newcommand{\sqrtone} [1] {*/,
\SGMLstartmathtag{msqrt} #1 \SGMLendmathtag{msqrt}}
\d e f\s q r t t w o [#l ] {\s q r t t w o e n d {#l } }
\newcomraand{\sqrttwoend} [2] */.
{\SGMLstartmathtag{raroot} {#2} {#1} \SGMLendmathtag{mroot}}
The command \®ifnextchar checks whether the next input character is the same with the character that follows the command and, i f i t is, i t executes the first
148 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
command that follows; otherwise, i t exe< again the example above to see what we
<mtext>
<inlinemath>
<math>
<msqrt>
<rai> x </mi> </rasqrt>
</math>
</inlinemath>
</ratext>
Of course, now we get correct output, a new document class, which would be 1 DocBook format.
tes the second command. Now, we try i l l get:
\document class { a r t i c l e ] ·
\begin{document}
\MMLmode \MMLst a r t t ext $\s q r t { x } $
\MMLendtext
\end{document}
le same technique can be used to create ?d to create output, for example, in the
The f o l l o w i n g exercise assumes f a m i l i a r i t y w i t h HTML, so readers not fa m i l i a r w i t h this markup can skip it.
>- Exercise 5.4 Design a A file that w i l l generate a simple H T M L file that w i l l display the text Planck's Equation: E = fiv centered. □
5.7 Generating OMDoc Files
Ma thM L is not the only X M L application related to mathematical markup. OMDoc is an X M L application that allows us to represent the semantics and structure of various kinds o f mathematical documents. Qn the other hand, OpENMATHand M a t h M L only p a r ti a l l y f u l f i l l the goal of establishing a basis fo r communication between mathematics and mathematical software systems (and humans) since they exclusively deal w i t h the representation o f the various mathematical objects i n par ti cul ar and not w i t h mathe­
matical documents i n general. Roughly speaking, i t is possible to transform any k i n d of X M L content to LTfcXby using XSLT. The latex2omdoc package (by Michael Kohlhase) is a tool that allows the generation of OMDoc content fro m LT^X markup. The fo l l o w i n g example shows a simple Ι^ΤβΧ file that when processed w i l l generate OMDoc content.
\d o c u m e n t c l a s s [ a 4 p a p e r ] { a r t i c l e }
\usepackage{latex2omdoc}
\b e g in { d o c u m e n t }
\b e g in { o m d o c o u t }
\begin{ommetadata}
\d c t i t l e { S i m p l e OMDoc Example}
\d c c r e a t o r [ e d t ] { J i m E d i t o r }
\d c c o n t r i b u t o r { S t e v e A u t h o r }
5.7 G e n e r a t i n g O M D o c F i l e s <>- 149
\d c d a t e {\t o d a y }
\e n d { ommet adat a }
\omchapt er{About programming}
\o m s e c ti o n { A b o u t P e r l }
\ommigtheory{About P e r l b e in g a f i n e l anguage}
\b e g i n { t h e o r e m }
\b e g i n { o m v e r b }
P e r l i s a f i n e programming language.
\end{omverb}
\e n d { th e o r e m }
\ommigtheory{About P e r l b e in g an e f f e c t i v e language}
\beg in {l e mma}
\b e g i n { o m v e r b }
P e r l i s a l s o e f f e c t i v e.
\end{omverb}
\end{lemma}
\o m r e f {
h t t p://www.mathweb.o r g/o m do c/}
\end{omdocout}
\en d {d o cument}
Before we give you the OMDoc output, we should mention that I^T^X creates a file that has the same filename as the i n p u t file b u t w i t h the . omdoc filename extension. The en­
viron me n t omdocout creates the o u t p u t file and writes the file header. The ommetadata environment is used to add metadata inf o rma t io n to the o u t p u t file w i t h the com­
mands \d c t i t l e, \d c c r e a t o r, \d c c o n t r i b u t o r, \d c d a t e. The \d c t i t l e command has an optional argument that should be used to specify the language o f the ti t l e [default language is en(glish)]. Naturally, i t is possible to include metadata i nf ormat ion w i t h i n the various environments that the package provides. The nonstandard environments theorem, lemma, c o r o l l a r y, c o n j e c t u r e, d e f i n i t i o n, and remark are used to generate the corresponding markup. The environment omverb should be used to enter content inside the tags. O f course, the package offers some other features and commands, b u t they are meaningless unless one is f a m i l i a r w i t h OMDoc.
Here is the OMDoc file that corresponds to the Ι^ΤβΧ file above:
<?xml v e r s i o n ="l.0"?>
<!DOCTYPE omdoc SYSTEM
"
h tt p://w w w.m a t h w e b.o r g/o m d o c/d t d/o m d o c.d t d
" [ ] >
<!— generated from t.t e x, do n o t e d i t —>
<omdoc i d ="t o p">
<metadata>
< d c:T i t l e x m l:lan g ="e n"> Simple OMDoc Example </d c:T i t l e >
< d c:C r e a t o r r o l e ="e d t"> Jim E d i t o r </d c:Crea t o r >
150 -φ- 5 T y p e s e t t i n g Μ α t h e m a t i c s
<dc:C o n t r i b u t o r r o l e ="a u t"> Steve Author </d c:C o n t r i b u t o r >
<dc:Date>February 3, 2002</dc:Date>
</metadata>
</omgroup>
<omgroup i d ="0 { —[About programming})·" t y pe="About programming"> <metadata>
< d c:T i t l e x m l:l ang="en">
c h a p t e r
</d c:T i t l e >
</metadata>
</omgroup>
<omgroup i d ="0 { —[About P e r l } }" type="About P e r l">
<metadata>
< d c:T i t l e x m l:l ang="en">
s e c t i o n
</d c:T i t l e >
</metadata>
< a s s e r t i o n i d ="1 - t h e o r e m"
th e o r y ="A b o u t P e r l b e in g a f i n e language" type="theorem">
<CMP x m l:la n g ="e n" f o r m a t ="o m t e x t">
P e r l i s a f i n e programming language.
</CMP>
</a s s e r t i o n >
< a s s e r t i o n id="2-lemma"
th e o r y ="A b o u t P e r l b e in g an e f f e c t i v e language" type="lemma"> <CMP x m l:la n g ="e n" f o r m a t ="o m t e x t">
P e r l i s a l s o e f f e c t i v e.
</CMP>
</a s s e r t i o n >
< r e f x l i n k:h r e f ="
h t t p://www.mathweb.o rg/o mdo c/"/
> </omdoc>
“ “ 6
M o r e o n t h e C o r e
In this chapter, we describe additional topics not covered i n the previous chapters: labels, horizontal and vertical spacing, page breaking, floating objects, marginal notes, page parameters and page setup, slide preparation, TgX boxes, lines, the d e f i n i t i o n o f new commands, environments and catalogs, the file i n p u t f a m i l y o f commands, and the interactive use of I^TgX.
6.1 Labels and References
As we have already mentioned i n the introduction, one o f the benefits o f using I^TgX instead of an o rd in a ry WYSIWYG document preparation system is that one does not have to take care of the various labels (e.g., section labels, equation labels and others), as these are automatically generated by I^TeX. However, in many instances one wants to be able to refer to a p a rti cul a r label or page number. I n this case, all we have to do is to p u t a \l a b e l command after the command that generates the label and to use a reference command at the place where we want to make the reference. The command \l a b e l has one argument, which is a symbolic name f o r a particular label. The symbolic name may consist o f letters, digits, and punctuation symbols:
\s e c t i o n { 0 n t h e S t r u c t u r e o f D N A }\l a b e l { d n a:s t r u c t }
To refer to this p articular label anywhere i n our document, we must use the command
\r e f;
As we d e s c r i b e on s e c t i o n ~\r e f { d n a:s t r u c t }...
The character ~ creates a space that cannot be chosen by KTgX to s p li t a line. So, we make sure that the word before the reference and the reference itself w i l l appear on the same o u t p u t line. Of course, one may choose not to use this trick. But then the document may be h ig h l y unreadable. Note that i n some languages this special character is used to accent letters. I f the reader uses I^TgX to typeset a text i n such a language, we suggest the use of the \nobreakspace command:
152 -φ- 6 M o r e o n t h e C o r e
As we d e s c r i b e on s e c t i o n\n o b r e a k s p a c e\r e f - [ d n a:s t r u c t }. . .
I f one wants to refer to the page number where a parti cul ar label occurs, the command \p a g e r e f needs to be used:
As we d e s c r i b e on p a g e ~\p a g e r e f { d n a:s t r u c t }...
When processing a I^TgX file that contains references to labels fo r the f i r s t time, L5TgX is n o t able to correctly resolve the labels, so one has to r u n I^TgX on the file a second time. I f there is a reference to a nonexisting label, Ι^ΤβΧ w i l l complain that there were undefined references. Note that one w i l l get this message anyway the very f i r s t time I^TgX is r u n on a file.
Suppose that one wants to refer to both an equation and the page where this equation actually appears. A possible solution to this problem follows:
s e e ~\r e f { e q n } on p a g e ~\p a g e r e f { e q n }
However, this solution has the drawback that i f the equation happens to be on the same page where we actually p u t the reference, the result looks odd and i n that instance should be replaced by
s e e ~\r e f -[eqn}
Since i t is inconvenient to t r y to keep track of all references and labels, Frank Mittelbach has created the varioref package that takes care of such problems. When using this package, you w i l l usually use the commands \v r e f and \v p a g e r e f instead o f \r e f and \p a g e r e f. The command \v r e f is equivalent to the \r e f command when the reference and the \l a b e l are on the same page. I n cases where the label and the reference are on pages that d i f f e r b y one, the command w i l l i n a d d i ti o n produce a short phrase such as "o n the f o l l o w i n g page." For example, i n the excerpt
E q u at io n \v p a g e r e f { e q:e u l e r } i s known as E u l e r ’ s e q u a t i o n.
\newpage
\b e g i n { e q u a t i o n } e ~ { i\p i } + l = 0\l a b e l { e q:e u l e r }
\e n d { e q u a t i o n }
the fi r s t sentence w i l l be typeset as
Equation 1 on the f o l l o w i n g p a ge...
The command \newpage forces 15T]hX to start a new page. Finally, i f the reference and t h e l abel are on pages that d i f f er by more t han one, i t w i l l p r o du ce both t h e \r e f and the \p a g e r e f. The command \v p a g e r e f w i l l produce the same phrase as \v r e f except that i t does n o t start w i t h the \r e f. For example, i n
The e q u a t i o n \v r e f { e q:e u l e r } i s known as E u l e r's e q u a t i o n.
\newpage
\b eg i n { eq u a t i o n }
6.1 L a b e l s a n d R e f e r e n c e s <>· 153
e ~ { i\p i } - - i - l = 0\l a b e l { e q: eu le r}- \e n d { e q u a t i o n ] -
the f i r s t sentence w i l l be typeset as
The equation on the f o l l o w i n g page...
Nevertheless, i t is possible to control the o u tp u t of this command b y using the tw o optional arguments that this command can take. W i t h the f i r s t argument, one can specify the text that should be used i f the label and the reference f a l l on the same page. This feature is p a r ti c u l a r ly useful when the label and the reference are near each other. When we k n o w i f the label is before or after the reference, we say something like
... see t h e example \v p a g e r e f [ a b o v e ] { e x:1} ...
This w i l l be typeset as .. see the example above..." i f the label and the reference are on the same page, b u t as .. see the example on the page before ..." i f the reference comes after the label. The second optional argument can be used i f we want f iner control over the o u t p u t phrase. For example, the i n p u t text
The \v p a g e r e f [ f o l l o w i n g e q u a t i o n ] [ e q u a t i o n ] { e q:e u l e r } - i s known as E u l e r's e q u a t i o n.
\b e g i n { e q u a t i o n } e ~ { i\p i } + l = 0\l a b e l { e q:e u l e r }
\e n d { e q u a t i o n }
w i l l be typeset as
The f o l l o w i n g equation is k n o w n ...
On the other hand, the i n p u t text
The \v p a g e r e f [ f o l l o w i n g e q u a t i o n ] [ e q u a t i o n ] { e q:e u l e r } - i s known as E u l e r's e q u a t i o n.
\newpage
\b e g i n { e q u a t i o n } - e~{ i\p i } - + l =0\l a b e l { e q: e u l e r }- \e n d { e q u a t i o n ) -
w i l l be typeset as
The equation on the f o l l o w i n g page is kn o w n ...
I f w e want to r ef er to a range o f labels (i.e., labels that appear i n consec u t i v e order), we can use the \v r e f range command. So, i f we want to collectively refer to labels eq: 1, eq: 2, and eq: 3, we can use the f o l l o w i n g i n p u t text:
The e q u a t i o n s ~\v r e f range{eq: l } { e q:3 } - are c a l l e d...
The text above w i l l be typeset as
1 5 4 ^ 6 M o r e o n t h e C o r e
The equations 3.1 to 3.3 are ca ll e d...
The command above has an optional argument that can be used when all of the labels are placed on the same page. One command \v p a g e r e f range has functionality similar to the \v r e f range command. I f both labels fall onto the same page, the command acts exactly like the \v r e f range. Otherwise, i t produces something l ike "o n pages 21-23." The command may take an optional argument that can be used i n cases where all labels are placed on the current page.
A
The command \vrefpagenura is provided to allow users to write their own little commands that implement functions similar to those provided by tine two previous commands. This command has two arguments: the first is the name of an arbitrary , command that receives a page number related to the second argument, which is a label. So, i f we have two (or more) labels, we can get their page numbers, compare them, and then decide what to output. Here is a slightly modified example from the documentation of the package:
\newcomraand{\myvrefrange} [2] {*/,
\v r ef page num {\f stnura} {# 1 }*/0 \v r ef pagenuin { \ sndnura } { #2 }7a \i f thenelse{\equal{\fstnura}{\sndnum}}{*/.
\r e f {#l } and \r e f {#2 } \vpageref{#1}}{*/.
\r e f {#l } \v p a g e re f {#l} and \r e f {#2 } \vpageref{#2}}'/.
}
The command makes use of the package ifthen. The first sentence in the following input text
The equations \rayvrefrange{eq:euler}{eq:einstein} are E u l e r ’ s and E i n s t e i n ’ s equations.
\newpage
\begin{equation} e''{ i\p i } + l = 0\l a b e l { e q: euler}
\end{equat ion}
\nsvpage
\begin{equation}
E=mc~2\label{eq:einstein}
\end{equat ion}
will be typeset as
The equat i ons 1 on t he f o l l o w i n g page and 2 on page 3 a r e...
I f we ar e not sat i sf i ed w i t h t he pr edef i ned phr ases t hat t he commands above pr oduce, we can cust omi ze t hem by r edef i ni ng t he f o l l o w i n g commands:
\r e f t e x t b e f o r e Thi s command i s used f o r backwar d ref er ences when t he l abel i s on t he pr ecedi ng page b u t i s i nvi si bl e.
6.2 H y p e r - r e f e r e n c e s <>· 155
\r e f t e x t f acebef ore This command is used when the label is on the facing page (i.e., i f the current page number is odd).
\r e f t e x t a f t e r This command is used when the label comes on the next page but one has to turn the page.
\r e f t e x t f aceaf t e r This command is used when the label is on the following facing page.
\r e f t e x t f araway This command is used whenever the label and the reference are on pages that differ by more than one or when the page numbers are not Arabic numerals.
\v r e f t e x t v a r i o This command has two arguments and outputs one of the two arguments depending on the number of \v r e f and/or \vpageref commands that are already seen. Here is an example:
\newcommand-C\ref t e x t a f ter}-C% on the \r e f t e x t v a r i o { f o l l o w i n g i K n e x t ] - page}
\r e f textpagerange This produces text that describes the page range of two labels denoting a "label" range.
\r e f t e x t l a b e l r a n g e This command produces text that describes the range of equations, figures, and so forth.
The varioref package defines these commands so that they produce the correct
phrases when used with the babel package.
6.2 Hyper-references
One of th e main r easons that made t h e Portable Documen t Format (or PDF, f o r short) so popular is the fact that people can read and p r i n t the same document i n a w id e range of computing platforms. Another i mpo rta n t reason is that PDF documents can contain hyperlinks (or hyper-references) to parts of the document or to external URLs. A d d it io n a ll y, recent versions o f the PDF format a ll o w the inclusion of forms (a template f o r data or text i n p u t ) just l ike those found i n many H T M L documents. Since forms are useful o nly when they are interactive, PDF forms can be made interactive by using the JavaScript programming language or by i n v o k i n g external cgi-scripts.
The hyperref package b y Sebastian Rahtz, when used on LT^X sources that are processed b y pd fLTgX, allows people to easily create PDF documents w i t h hyperlinks and/or forms. However, there are many useful packages that cannot be used w i t h pdfL'TgX(e.g., the PSTricks packages; see section 9.9.2 on page 286), so the package allows users to generate PostScript files. When we transform these PostScript files to PDF files, the latter w i l l actually have the "h y p e r" features that we described i n our LT^X source file. The package can be used w i t h more or less any normal LTgX document. However, the package provides a number of options. These options can be specified
156 Φ- 6 M o r e o n t h e C o r e
\usepackage [ l i n k c o l o r = b l u e,p d f p a g e m o d e = F u l l S c r e e n ] { h y p e r r e f }-
Some of the options are characterized as Booleans. I n this case, we can enable t heir use b y s i m pl y specifying the corresponding key; otherwise, we can set them to either true or false. Alternatively, we specify the options w i t h the command \h y p e r s e t u p:
\h y p e r s e t u p { b a c k r e f,l i n k c o l or= b lu e,p d f p a g em o d e =F ul l S c r ee n }-
I f we have a number of options that we always want to use, we can create a file called h y p e r r e f. c f g (which we store i n a place accessible b y pdfTgX) to w hi c h we w i l l store o nly a \h y p e r s e t u p command. I f we w ant to override any o f the options, we have to specify the changes i n the options pa rt o f the \usepackage command.
We w i l l n o w b r i e f l y describe most o f the available options. The f u l l l ist of options is available fr o m h t t p://w w w.t u g.o r g/a p p l i c a t i o n s/h y p e r r e f/m c i n u a l.h t i i i l
. Note that default options are overridden automatically when selecting some other option.
General options These options can be used to specify general behavior and page size.
d r a f t (Boolean, default: false) A l l hypertext options are turned off. debug (Boolean, default: false) A d d i t i o n a l diagnostic messages are print ed i n the log file.
a4paper (Boolean, default: true) Sets paper size to A4.
a5paper (Boolean, default: false) Sets paper size to A5.
b5paper (Boolean, default: false) Sets paper size to B5.
l e t t e r p a p e r (Boolean, default: false) Sets paper size to letter paper size.
l e g a l p a p e r (Boolean, default: false) Sets paper size to legal paper size.
e x e c u t i v e p a p e r (Boolean, default: false) Sets paper size to executive paper size.
Configuration options
r a i s e l i n k s (Boolean, default: true) The relevant commands that deal w i t h hyperlinks reflect the real height o f the links, b r e a k l i n k s (Boolean, default: false) A l l o w s l i n k text to break across lines, page anchor (Boolean, default: true) Determines whether every page is given an i m ­
p l i c i t anchor at the top l ef t comer. I f this is turned off, the table of contents w i l l not contain hyperlinks.
p l a i n p a g e s (Boolean, default: true) Forces page anchors to be named b y the Arabic fo r m of the page rather than the formatted form, n e s t i n g (Boolean, default: false) A l l o w s links to be nested; this opti on is not actually supported.
Backend drivers
The package provides a number o f drivers, b u t here we w i l l use the p d f t e x d r iv e r and the d v i p s driver. The former has been set u p f o r use w i t h pdfTgX and the latter fo r use w i t h d v i p s. I n case we want to produce an H T M L file f r o m a LTpX document,
6.2 H y p e r - r e f e r e n c e s <>· 157
we may opt to use the l a t e x 2 h t m l driver. I n addition, the h y p e r t e x opti on is useful when previewing w i t h x d v i or when generating a PostScript file w i t h d v i p s w i t h the - z option.
E x t e n s i o n o p t i o n s
e x t e n s i o n (Text) Sets the file extension that w i l l be appended to the l in ks fi l e created when one uses the hyper-xr package. This package is a modified version of the xr package b y D av i d Carlisle and Jean-Pier Drucbert. The xr package implements a system f o r eXtemal References. I f one f i l e needs to refer to sections of another file, say aaa. t e x, then this package may be loaded i n the main file, and the command \e x t e r n a ld o c u m e n t { a a a } must be given i n the preamble. Then, one may use \r e f and \p a g e r e f to refer to labels defined either i n aaa. t e x or i n the main file, h y p e r f i g u r e s (Boolean, default: false) Makes included figures hypertext l in k s (see Chapter 9 f o r details on the inclusion o f figures), b a c k r e f (Boolean, default: false) A d d s "b a c k - l i n k" text to the end of each item i n the b ib l i og ra p hy as a l ist o f section numbers. This works p ro pe r l y only i f there is a b lank line after each \b i b i t e m. pagebackref (Boolean, default: false) Ad d s "b a c k - l i n k" text to the end o f each item i n the bib l i og r a p hy as a l ist o f page numbers, h y p e r i n d e x (Boolean, default: false) Makes the text of index entries int o hyperlinks, c o l o r l i n k s (Boolean, default: false) Colors the text of links and anchors, l i n k c o l o r s (Color, default: red) The color fo r normal links, a n c h o r c o l o r (Color, default: black) The color f o r anchor text, c i t e c o l o r (Color, default: green) The color for bibliographic citations i n text, f i l e c o l o r (Color, default: magenta) The color fo r URLs that open local files, menucolor (Color, default: red) The color f o r Acrobat menu items. page c o l o r (Color, default: red) The color f o r links to other pages. u r l c o l o r (Color, default: cyan) The color f o r l inked URLs.
P D F d i s p l a y a n d i n f o r m a t i o n o p t i o n s
b a s e u r l (URL) Sets the base URL o f the PDF document.
p d f pagemode (Text, default: empty) Determines h o w the file opens i n Acrobat; the possible values are None, UseThumbs (show thumbnails), UseOu tl in e s (show book­
marks), and F u l l S c r e e n. I f no mode is e x p li c i t l y chosen b u t the bookmarks option is set, U seOu tl in e s is used, p d f t i t l e (Text, default: empty) Sets the document i nf ormat ion Title field, p d f a u t h o r (Text, default: empty) Sets the document i nf o rma t io n A u t h o r field, p d f s u b j e c t (Text, default: empty) Sets the document i nf ormat ion Subject field, p d f c r e a t o r (Text, default: LaTeX w i t h h y p e r r e f package) Sets the document i n f o r ­
mation Creator field.
p d f p ro du c e r (Text, default: the current version of pdfTjiX) Sets the document i nf orma­
ti o n Producer field. The default value depends on the version of pdfTgX. p d f k eywords (Text, d efault: em p ty ) Sets th e documen t i nf ormat ion K eywords f i eld.
158 Φ- 6 M o r e o n t h e C o r e
p d f view (Text, default: f i t b h ) Sets the default PDF "v i e w" for each l in k. The possible values are shown i n Table 6.1. p d f s t a r t p a g e (Integer, default: 1) Determines the page on w hi c h the PDF f i l e is opened.
p d f s t a r t v i e w (Text, default: F i t B ) Sets the startup page view.
pdfpagescrop (Four numbers, no default value) Crops the page and displays/prints only that part. The f o u r numbers correspond to the coordinates o f the lower-lef t corner and the u p p e r - r i g h t corner o f the page.
Table 6.1: Outline and destination appearances.
Value
Description
F i t
fit the page in the window
FitH
fit the width of the page
F i tV
fit the height of the page
F i tB
fit the "bounding box” of the page
FitBH
fit the width of the "bounding box"
FitBV
fit the height of the "bounding box"
XYZ
keep the current zoom factor; can op­
tionally be followed by a zoom factor that must be an integer
I t is possible to activate the menu options o f the Acrobat Reader b y using the command \Acrobatmenu. This command has t w o arguments: the name of the Acrobat Reader menu option and the text that w i l l be displayed on the screen. By clicking on a w ord, Acrobat Reader w i l l activate the corresponding menu option. Some interest­
ing menu options are: FirstPage, PrevPage, NextPage, LastPage, and Ο μ ϋ The reader should consult the online manual f o r the f u l l l is t o f menu options. Here is a simple example:
\d o c u m e n t c la s s { a r t i c l e } -
\usepackage[a4pape r,p d fp a g emo d e =Ful l Scre en ] {hyp e rre f )-
\b e g i n { d o c u m e n t } -
\Acrobatmenu{Quit}{\LARGE QUIT}
\e n d {d o cument}-
I f the PDF f i l e corresponding to the code above is viewed w i t h Acrobat Reader, i t w i l l be displayed i n f u l l screen. By clicking on the w o r d QUIT, we terminate Acrobat Reader. We can create v i sua l l y appealing PDF files i f we use images instead of words for actions. Moreover, b y using the \Acrobatmenu command, we can create slide shows.
I f we need to make references to URLs or w r i t e explicit links, the f o l l o w i n g com- mands are p r o v i d ed:
6.2 H y p e r - r e f e r e n c e s <>· 159
\h r e f {URL}-{text > The t e x t is made a h y p e r l i n k to the URL; the URL must be a f u l l URL (e.g., h t t p: //www. t u g. org). Special characters such as # and ~ lose t heir special meaning and are treated as "le tt e r s." I f we have defined a base URL w i t h b a s e u r l, then the url can be relative to it. Here is an example that starts the Web browser and points i t to the TUG Web page:
\h r e f {
h t t p://www.t u g.org}{\LARGE
TUG}
Suppose n o w that we have set
b a s e u r l = {
h t t p://www.t u g.o r g }
Then, the fo l l o w i n g is a h y p e r l i n k to the applications section o f the TUG Web pages:
\h r e f { a p p l i c a t i o n s/i n d e x.h t m l } {\L A R G E A p p l i c a t i o n s }
Note that the package makes use o f the url package b y Donald Arseneau to typeset URLs. This package provides the command \u r l, whose argument can be a URL, w hi c h w i l l be typeset correctly (i.e., i t w i l l be s p l i t across lines i f this is necessary). \h y p e r b a s e u r l { t/RL} This is an alternative way to specify a base URL.
\h y p e r r e f { URL} { cat egor yy{ namey{ t es t y The t e x t is made int o a l i n k to URL# c a t ­
egory .name.
\h y p e r l i n k { n a/7 7 e } { t e c c t } The t e xt is made a l i n k to the internal target name. \h y p e r t a r g e t { t a r g e t } { t e s t } The t e x t is made an internal l i n k w i t h symbolic name t a r g e t. Here is a simple usage example:
\h y p e r l i n k { p r o p } { S e e p r o p o s i t i o n }
\b e g i n { p r o p o s i t i o n }
\h y p e r t a r g e t { p r o p } { T e x t o f p r o p o s i t i o n } \e n d { p r o p o s i t i o n }
However, i n this particular case, i t is easier to use the f o l l o w i n g to get the same effect:
See p r o p o s i t i o n ~\r e f { p r o p }
\b e g i n { p r o p o s i t i o n }\l a b e l { p r o p }
Text o f p r o p o s i t i o n \e n d { p r op o s i t i on}
We w i l l n o w present PDF forms and th e i r usage. But w hat exactly is a form? According to the Wor l d Wide Web Consortium (W3C): A fo r m is a section of a document containing normal content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls. Users generally "com p l e te" a fo rm b y m o d i f y i n g its controls (entering text, selecting menu items, etc.) before submitting the f o r m to an agent fo r processing (e.g., to a Web server, to a mail server, etc.). So,
ι 6 ο - Φ 6 M o r e o n t h e C o r e
one must k n o w w ha t controls are available and then h o w i t is possible to process the modified controls. We start b y b r i e f l y addressing the second issue.
There are tw o ways to process controls: either we send the data to some Web server b y a specific transmission method (the available methods are Post and Get) or we process them locally w i t h the JavaScript programming language. The second method is usually employed i n simple cases. For example, i t makes no sense to use the first method to get the square root o f a number. The f i r s t method assumes that there is a so-called cgi-script (usually a program w r i t t e n i n Perl) on the Web server that w i l l actually process the data and send the processed data back to the client. Forms were i n i t i a l l y introduced i n H T M L documents b u t can n o w be part o f a PDF document. I f we want to transmit data from a PDF form, we have to use the Acrobat Reader w i t h i n a Web browser. This is necessary, as the Web browser w i l l do all necessary actions to actually deliver the data.
We can create forms w i t h the Form environment. The body of the environment contains several controls. Here is the l ist o f the available controls:
\T e x t F i e l d [parameters] { l a b e l }- A text fi e ld is a control where we can enter data fro m the keyboard.
\CheckBox [paramet ers] { l a b e l > Checkboxes are on/off switches that maybe toggled by the user. A switch is "o n" i f the control element's checked attribute is set. When a fo rm is submitted, o nly "on" checkbox controls can become successful. \ChoiceMenu [paramet ers] { l a b e l > Menus offer users options fr o m w hi c h to choose. \Pu sh Bu tt on [paramet ers] { l a b e l } Push buttons have no default behavior. Each push b u tto n may have client-side scripts associated w i t h the element's event at­
tributes. When an event occurs (e.g., the user presses the button, releases it, etc.), the associated script is triggered.
\Su b mi t [paramet ers] { l abel > When a Submit button is activated, i t submits a form.
A fo r m may contain more than one submit button.
\R e s e t [parameters] { l a b e l > When a Reset b u tt o n is activated, i t resets all controls to their i n i t i a l values.
Before we proceed w i t h a b r i e f presentation of the most i mpo rta n t parameters, we give a sh o r t example of a f o rm that asks i t s user t o ent er tw o numbers i n tw o t ext f i e l ds, submits the data, and returns t heir sum:
\d o c u m e n t c l a s s { a r t i c l e } -
\usepackage [bookmarks=f a l s e, p d f s t a r t v i e w = { X Y Z 4 } ] { h y p e r r e f }- \b e g in { d o c u m e n t }
E n t er two number s i n t h e f o l l o w i n g t ex t f i el d s and get t h ei r sum! \begin{Form}- [ a c t i o n = { h t t p: //o c e a n l. ee. d u t h. g r/c g i - b i n/s u m n u m } -, e n c od i n g= h t m l, method=post]
\b e g i n { c e n t e r }
\T e x t F i e l d [w i d t h = l c m, h e i g h t = 4 p t, name=numl, v a l u e = 0 ]
{ F i r s t number: }\\
6.2 H y p e r - r e f e r e n c e s 1 6 1
\T e x t F i e l d [ w i d t h = l c m, h e i g h t = 4 p t, name=num2, v a l u e = { } ] •[Second number: }\\ [ 4 p t ]
\Submit{Send}\qquad \R e s e t { C l e a r }
\e n d { c e n t e r >
\end{Form}
\end{document}
forml .p d f
File Edit Document View Window
ΗίίΙιι
μ os ""^ τ, < ί * ί | * ■ □ icairi «
E n t e r t w o n u m b e r s i n t h e f o l l o w i n g t e x t f i e l d s a n d g e t t h e i r s u m!
F i r s t n u m b e r:
S e c o n d n u m b e r: |_________|
S e n d
C l e a r
1 κ ι K ■ Ί 1 ur 1 |; » h i mi »1.
Figure 6.1: A simple PDF form.
The o u tp u t of the code above is shown i n Figure 6.1. Readers can download from the book's Web site the source code of a Perl script that can manipulate the data generated by the form above.
As is evident from the example above, i t is important to give each control a name. The optional arguments o f the Form environment are pretty standard, and we w i l l make no attempt to explain them. Readers not f a m i li a r w i t h them are advised to v i s i t the URL h t t p://w w w.w 3.o r g/T R/h t m l 4/i n t e r a c t/f o r m s.h t m l
. We now b r ie f ly present the most important parameters:
h e i g h t and w i d t h The height and w i d t h o f a text field, m u l t i l i n e I f set to true, the text field becomes a text area, menulength The number o f elements shown in a list.
c h a r s i z e and c o l o r The font size and color of a text field. Note that the color must be expressed as R(red)G(reen)B(lue) triplets, i n the range 0..1, that is,
c o l o r = 0 1 0
1 0 2 -φ 6 M o r e o n t h e C o r e
combo, popdown and r a d i o The choice l is t is "c o m b o", "p o p - u p" or "r a d i o," respec­
tively.
password Text f i e ld is "p a s s w o r d" style, v a lu e I n i t i a l value of a control.
I f we want to process a f o r m locally, we must use pieces of JavaScript code that are activated when certain events happen (i.e., users push buttons, change the value of text fields, etc). I n the example that follows, the user enters the parameters o f a simple equation and b y pressing "Solve Equation" gets the solution i n a text field.
\b e g i n { F o r m }
\b e g i n { c e n t e r }
\T e x t F i e l d [w i dt h =l cm,h e ig h t= 5 p t,n a me =n u ml,v a l u e = { } ] {\q u a d }
$x$
\ChoiceMenu [popdown, d e f a u l t = + ,name=sign] { } { +,- }
\T e x t F i e l d [w i d t h = l c m, h e i g h t = 5 p t, name=num2,v a l u e = 0 ] O $=$
\T e x t F i e l d [w i d t h = l c m, h e i g h t = 5 p t, name=num3,v a l u e = 0 ] O \\[ 0.5cm]
\P u s h B u t t o n [ o n c l i c k = { v a r numl = t h i s .g e t F i e l d ("n u m l") ; v a r a=numl.v a l u e; v a r n u m 2 = t h i s.g e t F i e l d ("n u m 2"); v a r b=num2.v a l u e; v a r s i g n = t h i s.g e t F i e l d ("s i g n"); v a r num3 = t h i s.g e t F i e l d ("n u m 3"); v a r c=num3.v a l u e; i f ( s i g n.v a l u e != "+") b =-b; i f (a == 0) app.a l e r t ("No s o l u t i o n!");
e l s e t h i s .g e t F i e l d ("s o l") .v a l u e = ( c - b )/a;} - ] { S o l v e E q u a t i o n } \T e x t F i e l d [width=2cm, h e i g h t = 5 p t, n a m e = s o l,v a l u e = { } ] { S o l u t i o n:} \e n d { c e n t e r }
\end{Form}
Figure 6.2 shows a captured screen o f the fo r m as i t is displayed b y Acrobat Reader.
As is evident fr o m the example above, the JavaScript code is actually the value o f a parameter. Such parameters are called event handlers. Also note that the JavaScript code must be surrounded by cu r ly brackets. The available event handlers are:
o n b l u r onchange o n c l i c k o n d b l c l i c k
onfocus okeydown okeypress onkeyup
onmousedown onmousemove onmouseout onmouseover onmouseup o n s e l e c t
A t this point, i t is really i mpo rta n t to stress that the JavaScript language supported b y the PDF format is rather different f r o m the language used i n H T M L documents. The reader interested i n learning more should read the Acrobat Forms JavaScript Object Specification, Adobe Technical Note 5186, available from: h t t p: / /p a r t n e r s. adobe. com/ a s n/d e v e l o p e r/t e chnote s/a c r o b a t p d f.html.
6-3 H o r i z o n t a l a n d V e r t i c a l S p a ce £ - 163
f o rm ^.p d f
bile Edit tXir.unwit Vil-w Window
Help
w α f i s Ε»«, t, « i * λ | * * π iQiti*i »
So l ve a S i m p l e E q u a t i o n!
1 1 3 G U I = I
Solve E q u a tio n
Solution:
-2
_j_- ι ι .<r 1 u =■ hjxn Ί »;
Figure 6.2: A simple JavaScript-enabled PDF form.
6.3 Horizontal and Vertical Space
I n this section, we introduce length variables and their manipulation as wel l as the commands that a ll o w users to p u t (additional) horizontal and vertical space i n t heir document.
6.3.1 Length Variables
Length variables are either predefined or user-defined control sequences that can be used instead of a normal length. N e w length variables can be introduced w i t h the command \n e w le n g th:
\n e w l e n g t h {\L e n V a r }
The name of a length variable consists of a leading backslash and one or more t r a i l i n g ASCII letters. We can set a length variable w i t h the command \ s e t l e n g t h:
\s e t l e n g t h - C\L e n V a r } { £ z p r e s s i o n }
Here, Expressi on is either an ordinary length (e.g., 5 cm or 35 p t) or the name of another length variable, possibly prefixed by a number or, more generally, the value of a counter. In the latter case, we set the length variable to the product of the number (or the value o f the counter) times the second length. For example, after the execution of the commands
1 6 4 Φ 6 M o r e o n t h e C o r e
\n e w l e n g t h {\l e n A }
\s e t l e n g t h {\l e n A } { 1 0 p t }
\n e w l e n g t h {\l e n B >
\s e t l e n g t h {\l e n B > { 5\l e n A >
the value of \l e n A w i l l be 10 p t and the value of \l e n B w i l l be 50 pt. Moreover, we can increase or decrease the value of length variables by using the command \a d d t o l e n g t h:
\a d d t o l e n g t h {\l e n B } {\l e n A }
\a d d t o l e n g t h {\l e n B > { - 2\l e n A >
The first command increases the value o f \l e n B b y the value o f \l e n A, so the value of \l e n B becomes 60 pt. The second command decreases the value o f \l e n B by two times the value of \l e n A, so the value o f \l e n B becomes 40 pt. Note that the leading minus sign indicates that I^TfiX must decrease the value of the length variable. Naturally, we are allowed to use o rd in a r y lengths.
When TgX typesets a line, i t puts letters and other objects, such as tables, on an i maginary line called the baseline. The height of a letter or a word refers to the vertical space the letter or the w ord occupies above the baseline. Similarly, the depth refers to the vertical space that the letter or the w o r d occupies below the baseline. Now, i t is even possible to set a variable to the w id t h, height, or depth of a letter or a word. For e
xample, after the execution o f the f o l l o w i n g code, the three length variables w i l l be set to the w id t h, the height, and the depth of the tight frame that encloses the w ord Pipe, respectively.
\s e t t o w i d t h - C\l e n A } { P i p e }
\s e t t o h e i g h t {\l e n B } { P i p e }
\s e t t a d e p t h {\l e n C } { P i p e }
Δ
In some cases i t may be useful to be able to print the value of a length variable. The solution to this problem involves using a Ythe command. When we prefix a length variable or a counter with this command, we get its value. I f we have a length variable, then we get its value in points. Here is a simple example:
'Iho length oi \lenA is 56.9055pt.
\newlength{\lenA>
\setlength{\lenA}{2cm}
The length, of \v e r b |\le n A I i s \t he\le n A,
The interested reader may find more information about the \t he command in [19].
6.3.2 Horizontal Space
Basically, there are tw o commands that allow one to p u t horizontal space i n a document—\hspace and \hspace*. Both have one argument, which can be either a
6.3 H o r i z o n t a l a n d V e r t i c a l S p a cev>· 165
Hello World Hello World!
Hello World!
WMd>!
l ength or a length variable. The difference between the t w o commands is that the starred one can be used to p u t horizontal space at the beginning o f a line; otherwise, this space is ignored:
H e l l o WorldW \hspace-Clcm>Hello World !\\ Yhspace*-Clcm}-Hello World !\\ H e l l o\h s p a c e { - l c m } W o r l d!
The last example also shows wha t happens when we use a negative length. I n a ddi ti on to the tw o commands above, I^Te X provides three more commands that produce a predefined horizontal space:
a b\\
a\t h i n s p a c e b\\ a\n e g t h i n s p a c e b\\ a\enspace b
I n Section 2.3, we introduced the noti on of glue lengths (i.e., lengths that can shrink and stretch). I^TgX provides the glue \h f i l l, w hi c h flushes whatever follows to the r i g h t margin:
a b ab cb a b
a b
a
a
b
c
a b\\
a\h f i l l b\\ a\h f i l l b\h f i l l c
The commands \d o t f i l l and Y h r u l e f i l l have the same effect as \h f i l l, b u t they f i l l the space w i t h dots and or a horizontal rule, respectively:
a b
a.........
. ...b
a b\\
a\d o t f i l l b\\
a........
....b....
........c
a\d o t f i l l b\d o t f i l l c\\
a
b
a\h r u l e f i l l b\\
a
b
c
a\h r u l e f i l l b\h r u l e f i l l c
W h e n w e i n t r o d u c e d t h e c o m m a n d \h f i l l, w e t o l d a l i t t l e w h i t e l i e: t h i s c o m m a n d i s n o t a g l u e b u t i s e q u i v a l e n t t o
\h s p a c e {\f i l l }
O f c ou r s e, \f i l l i s t h e g l u e w e w e r e t a l k i n g a b o u t. Su p p o s e n o w t h a t w e w a n t t o p u t t h r e e l e t t e r s o n o n e l i n e so t h a t t h e d i s t a n c e b e t w e e n t h e f i r s t a n d t h e s e c o n d i s t w o t i m e s t h e d i s t a n c e b e t w e e n t h e s e c o n d a n d t h e t h i r d, t h a t i s
T h i s e f f e c t c a n n o t b e c r e a t e d w i t h
a\h s p a c e { 2\f i l l } b\h f i l l c
ι 6 6 -Φ 6 M o r e o n t h e C o r e
as the expression 2\f i l l w i l l be transformed int o an ord in a r y length equal to 0 pt! The correct code follows.
a\h s p a c e {\f i l l }\h s p a c e - [\f i l l } b\h f i l l c
Since t y p i n g the command \h s p a c e {\f i l l } tw o or more times is cumbersome, LTgX provides the command \s t r e t c h, whi ch takes as argument an integer, say n, and produces a glue that is equal to n times \f i l l. So, the construct above can be w r i t t e n as
a\h s p a c e {\s t r e t c h { 2 } } b\h f i l l c >· Exercise 6.1 Typeset the f o l l o w i n g ( w it h o u t the underbraces!):
““V ---------------------
5 2
□
f< ‘ H e l l o ’, he s a i d\\ ‘ ‘\,‘ H e l l o ’, he s a i d\\ ‘ ‘ ‘ H e l l o ’, he s a i d
There are t w o more useful commands that produce horizontal space. The command \, produces a \t h i n s p a c e and is used to correctly typeset quotes inside quotes:
77 'H e l l o 7, he said 77 'H e l l o 7, he said "'H e l l o 7, he said
I f the command \@ is placed before a 7.', i t makes i t a sentence, ending w i t h a period. This is necessary f o r American and British typography, as the space after a 7.7, that ends a period is longer than that after a 7.', w hi c h ends an acronym. However, this is n o t a common practice i n some European nations, where the space is the same i n both cases. For this reason, DT^X provides the declaration \f renchspacing, whi ch changes the default behavior described above.
6.3.3 V e r t i c a l S p a c e
The space between paragraphs, sections, subsections, and so on, is determined auto- matically b y Τ^Ι^Χ. I f necessary, more space between two paragraphs can be added w i t h the command \vspace. I f we need to add vertical space at the top or bottom of a page, we should use \v s p a c e *. Both commands have one argument, w h i c h can be either a length or a length variable.
I ^ g X also supports three commands that insert a predefined amount o f whi te ver­
tical space:
Line 1
L in e 1 \\ \s m a l l s k i p
Line 2
L in e 2 \\ \medskip
Line 3
L in e 3 \\ \b i g s k i p
L in e 4
Line 4
6.3 H o r i z o n t a l a n d V e r t i c a l S p a cev>· 167
The command \pagebreak encourages W j i K to break a page at a certain point. This command has an optional argument that is an integer f r o m 0 to 4. The higher the number, the stronger the encouragement. The command \pagebreak is b y d e fi ni ti o n equivalent to \pagebreak [4 ] .Likewise, the command \nopagebreakdiscourages f r o m breaking a page at a certain point. The commands \l i n e b r e a k and \n o l i n e b r e a k are the corresponding line-breaking commands.
>- Exercise 6.2 Write a I^TgX file that w i l l create a one-page document w i t h o nly three letters on three dif ferent lines that w i l l occupy the whole page. The distance between the f i r s t and the second letter must be tw o times the distance between the second and the th i r d. □
Extra vertical w hi t e space can be added w i t h the command \addvspace. The se­
quence
\addvspace{Si}- \addvspace{S2)-
is equivalent to
\addvspace{max(Si, S2) }
The command \e n l a r g e t h i s p a g e streches or shrinks a page b y a specific length that is the argument o f this command. Obviously, i f the argument, w h i c h is a length or a length variable, is positive, then the page is stretched and vice versa. The command \f l u s h b o tt o m stretches the blank space on pages to make the last line of all pages appear at the same height. The opposite effect can be achieved w i t h the command \raggedbottom.
I f we f i n d that the hyphenation a lgori thm fails to properl y break lines, then we can assist i t b y manually hyphenating words. Suppose that TgX fails to correctly hyphenate the w o r d omnipresent. Then, we can type i t as follows:
o m\- n i\- p r e s\- e n t
that is, we p u t the symbol \- between the syllables of the word. Alternatively, i f a w o r d o r a l ist o f words appears frequently i n our text, we can use the command
\h y p h e n a t i o n { o m - n i - p r e s - e n t Ath e n ia n }-
Here, syllables are separated b y - and words b y space. Note that, i n the example above, we t e l l TgX not to hyphenate the second word. I f these "t r i c k s" do n o t produce good results, we can manually break lines or force T^X to typeset sloppy paragraphs w i t h the command \sloppy. This command fo r ces TgX to increase th e i n t erw o r d space i f t here is no other way to make the words f i t on a p articular line. I n addition, the s l o p p y p a r environment should be used to typeset a \s l o p p y paragraph. The command \f u s s y forces ΤβΚ to switch back to its normal typesetting mode. These commands should be used w i t h care and preferably i n a local scope.
ι 68 -Φ 6 M o r e o n t h e C o r e
6.4 Counters
Counters are I^TgX variables that can h o ld an integral value. We can create a new counter w i t h the command
\newcounter{newcnt}- [ o l d c n t ]
I f we use the optional argument, each time the counter o l d c n t is increased b y one, the value of newcnt becomes equal to zero. This feature is very useful and, f o r example, i t is used to produce the section and subsection numbers. I n i ti a ll y, all counters are set to zero. We can set the value of a counter w i t h the command \s e t c o u n t e r:
\s e t c o u n t e r { n e w c n t } { 7 }
When we want to set a counter to the value of another counter, we have to use the command \v a l u e:
\s e t count er{newcnt } {\v a l u e { o l d c n t } } -
Another possibility is to advance the value o f a counter b y using the command \a d d - t o c o u n t e r:
\s e t c o u n t e r {newcnt } - {5 } %% newcnt=5
\ad d to co un t er {n e w cnt }-{4 )- %% newcnt=9
\a d d t o c o u n t e r { n e w c n t } { - 2 } %% newcnt=7
\a d d t o c o u n t e r { n e w c n t } - {\v a l u e { n e w c n t } } - % newcnt=14
The command \s t e p c o u n t e r { n e w c n t > globally increments the counter newcnt b y one and resets all subsidiary counters. Similarly, the command \r e f s te p c o u n t e r { n e w c n t } globally increments the counter newcnt b y one, resets all subsidiary counters, and also takes care so that a subsequent \l a b e l causes a \r e f to generate the current value of the counter newcnt.
The f o l l o w i n g commands have one argument that must be a counter, and they p r i n t a visual representation of the value of the counter:
Command
Produces...
\a r a b i c
an Srabic numeral.
\roman
a lowercase Roman numeral.
\Roman
an uppercase Roman numeral.
\a l p h
a lowercase letter that corresponds to the value o f the counter.
\A l p h
an uppercase letter that corresponds to the value o f the counter.
\f n s y m b o l
the standard footnoting symbols: *, t, t, §/ % ||, * *, ++, and φφ.
H er e are some exampl es:
64 C o u n t e r s 169
§
XX
xx
T
\n e w c o u n t e r { c n t }
\s e t c o u n t e r { c n t } { 2 0 >
\R o m a n { c n t }\\
\r o m a n { c n t }\\
\A l p l i { c n t }\\
\s e t c o u n t e r { c n t } { 4 }
\f n s y m b o l { c n t }
Usually, Ι5Γε Χ typesets page numbers as Arabic numerals, but i n certain situations we want to change the page numbering. For example, in many instances, the fi r s t few pages of a book are numbered in Roman numerals. offers the command \p a g e - numbering, which has one argument that takes care o f the visual representation of a counter, resets the page counter, and uses the argument to typeset the page numbers. For example, the command \pagenumbering{Roman} should be used to start typesetting the page numbers i n capital Roman numerals.
A
When we define a new counter, say cnt, IATgX defines a new command that consists of the token \t h e and the name of the counter (e.g., \thecnt in our case). This command simply prints the value of the counter. However, one should not confuse the command \t h e c n t with the command \value{cnt>, as the latter provides access to the actual value of the counter. Usually, the command \t hecnt prints the value of the counter in Arabic numerals; that is, the command \t hecnt is actually equivalent to the following definition:
The names of these counters make their usage evident. Below, as an example of ause of the predefined counters, we present how we can customize page numbers.
In many apparatus manuals, the page "numbers" consist of the chapter num­
ber, a dash, and the page number, while the page counter is reset each time we issue a \chapter command. To achieve this effect, we have to redefine the \page- numbering command, whose standard definition follows:
\newcommand{\thecntM\arabic{cnt}}
However, it is possible to redefine the command \t h e c n t to print whatever pleases us:
\renewcommand{\thecnt}{-\Roman-Ccnt}-}
This "t r i c k" is employed to change how the predefined or user-defined counters will be printed. The list of predefined counters includes the following:
\newcommand{\pagenumbering} [1] {'/, \setcounter{pageMl}*/(
170 ·φ· 6 M o r e o n t h e C o r e
\newcommand{\thepage]-{yo
\csname @#l\endcsname{\value{page}]-]-}
Note that I^TgX uses internally the commands XOarabic, \@roman, etc., instead of \arabic, \roman, etc., respectively.
>■ Exercise 6.3 Redefine the \pagenumbering command so that i t prints page numbers for apparatus manuals. □
By using the calc package (see Section 7.1), one can better manipulate counters and length variables.
6.5 Floating Objects
Most modem publications contain a l o t of figures and tables. There are instances where a table can be broken across pages, b u t this is unacceptable fo r figures. For this reason figures and short tables need special treatment. The naive method of treating these objects is to start a new page every time a floating object is too large to f i t on the present page. A more sophisticated method to tackle this problem is to "f l o a t" any object that does not f i t on the current page to a later page w h i l e f i l l i n g the current page w i t h text. This is w h y these objects are called floating objects. I^TpX provides two environments that are treated as floating objects: the f i g u r e and the t a b l e environments. Both envi­
ronments are w r i t t e n the same way; they d if fe r only i n the text that is prepended i n the caption. Moreover, there are tw o environments that can be used i n double column doc­
uments to generate floats that may occupy both columns: the f i g u r e * and the t a b l e * environments. Here is how we can begin a table or a figure:
\b e g i n { t a b l e }[pl acement s p e c i f i e r ]
\b e g i n { f i g u r e }[placement s p e c i f i e r ]
The optional pl acement s p e c i f i e r is used to tell Ι£ΓεΧ where the float is allowed to be moved to. The pl acement s p e c i f i e r consists o f a sequence of float placing permissions:
P l a c e me n t
S p e c i f i c a t i o n
Pl ac e t h e Fl oat...
h
here at the place where i t occurred.
t
at the top o f a page.
b
at the bottom of a page.
P
on a special page containing o nly floats.
A p a r t f r o m the float placing permissions above there exists a f i f t h one, namely !, whi ch forces I^TgX to actually ignore most of the internal parameters related to float placement. ETgX also p r o v i d es t h e command \s u p p r es s f l o a t s, whi ch p r ev ents I^TgX fr o m p u tt i n g
6-5 F l o a t i n g O b j e c t s Φ 171
more floats on the current page. The command has an optional argument, whi ch can be either b (for bottom) or t (for top). These arguments prevent ΙίΤβΧ fro m p u tti n g more floats on the bottom or the top o f the current page.
A n y float object can have a caption, which is generated by the \c a p t i o n command:
\c a p t i o n [ S h o r t] { Long }
One o p t i o n a l a r g u m e n t Short is useful when we want to have a list o f figures or tables i n our document and the caption text is quite long. The l is t of figures and tables can be generated w i t h the 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, respectively. Naturally, we do not have to specify the optional argument to generate either a l i s t of figures or a l ist o f tables. I f we want to have a reference to a floating object i n our text, we have to p u t the \l a b e l after the caption.
Suppose that the placing mechanism has deferred the placement of some float objects. I f we want to immediately place all floats deferred on a given page and start a new page, we have to use the command \c l e a r p a g e. The command \c l e a r d o u b l e p a g e does the same job b u t starts a new odd-numbered page.
Δ
There are a number of parameters that control both the number of float objects that can appear on a page and the general appearance of floats. Here, we briefly present these parameters. The counters topnumber and bottoranumber can be used to specify the number of floats allowed at the top or bottom of a column, re­
spectively. The counter totalnuraber can be used to specify the total number of floats allowed in a single column. The commands \t o p f r a c t i o n and \bottom- f r a c t i o n denote the fraction of the top or bottom of a column that can be devoted to floats. The command \d b l t o p f r a c t i o n is used for double-column floats. The command Y t e x t f r a c t i o n denotes the minimum fraction of column that must contain text. The commands \f l o a t p a g e f r a c t i o n and \d b l f l o a t p a g e f r a c t i o n specify the minimum fraction of a page that must be taken up by floats for single- and double-column documents, respectively. Here is an example that shows how one can set these counters and commands:
\setcounter{ topnumber} { 2 }
\renewcommand\topfr a c t i o n {.7}
The command \®makecaption is used to customize the appearance of the figure. The following definition is equivalent to the one provided by IATgX:
\neucommand-C\@makecaption} [2] {*/. \vspace{\abovecaptionskip}
\sbox{\OtempboxaH#l: #2}*/,
\ifthenelse{\wdV9tempboxa > \hsize}{%
#1: #2\par)<*/
\setboolean{Sminipage}{false}
\centerline-C\usebox{\®tempboxa}}
>
\vspace{\belowcaptionskip>
>
172 -Φ 6 M o r e o n t h e C o r e
IAT[hX leaves an amount of blank vertical space before and after the caption that is stored in the length variables \abovecaptionskip and \belowcaptionskip, respectively. The first argument of the command corresponds to the "number" of the floating object (e.g., "Figure 3.1"), and the second argument to the actual text of the caption. We store both arguments to the internal box variable \®tempboxa, and i f its width is greater than the width of the line, we ask T^TeK to typeset them and then to change paragraphs. Otherwise, we ask I^TgX to typeset the contents of the box in a centered line. The internal Boolean variable \Ominipage is set to f a l s e to ensure that the floating object is not part of a minipage.
>■ Exercise 6.4 Modify the definition above so that the caption' 'number" does not appear in captions. □
There are a number o f packages that can prove useful when dealing w i t h floating objects. I n w hat follows, we w i l l b r i e f l y present these packages.
T h e a f t e r p a g e p a c k a g e
This package b y Davi d Carlisle implements a command, \a f te rp a ge, that causes the commands specified i n its argument to be "executed" after the current page is output. For example, the command
\a f t e r p a g e {\c l e a r p a g e }
can be used to f i l l the current page w i t h text and force l^TgX to p u t all remaining floats onto the next page.
T h e m o r e f l o a t s p a c k a g e
This package b y Don Hosek increases KT^X's current l i m i t o f 18 unprocessed floats i n memory at once to 36.
T h e p l a c e i n s p a c k a g e
This package by Donald Arseneau keeps floats "i n t heir place," preventing them fr o m floating past a \F l o a t B a r r i e r. A more convenient way to use this package is to rede­
fine the sectioning commands and p u t the \F l o a t B a r r i e r command somewhere. The package provides tw o options: below and s e c t i o n. The first option allows float objects to appear after the heading o f a new section. The second "embeds" float barriers into \ s e c t i o n commands.
T h e e n d f l o a t p a c k a g e
The purpose of the this package is to p u t a ll figures on pages b y themselves at the end of an a rti cl e i n a section named Figures. The package has b een d esigned b y James D a r r el l
6-5 Fl o a t i n g O bjects Φ 173
McCauley and Jeff Goldberg. The list of tables and figures can be suppressed by using the nof i g l i s t and n o t a b l i s t options. Both can be suppressed with the n o l i s t option. The default is l i s t,
A
The package leaves notes on the text for each figure or table. The appearance of these notes is controlled by the commands \tableplace and \f igureplace. Unfortunately, the current version of this package does not directly support the babel package. So, one has to manually redefine these commands. Here are the standard definitions:
\newcommand{\f igureplace} {'/, \begin{center}
[\f igurename ~\thepostf ig\ about here.]
\ en d {('.e n t er }
\newcommand{\tableplace}{'/, \begin{center> [\tablename~\theposttbl\ about here.] X e n d i o e n t e r }
Here is a redefinition that should be suitable for Italian-speaking people:
\renewcominand{\f igureplace}{%
\begin{center}
[\figurename~\thepostfig\ circa qui.] \end{centerl·}
These and other redefinitions should be kept in the file endf l o a t. cf g.
Tilt’ f l oat package
This package provides an interface to define new float objects. Moreover, the package defines certain “ float styles" that can be used to define new floating objects. The package was designed by Anselm Lingnau. New float objects can be defined with the command
\ne wf l o a t
{ t ype } { pI ace ment
}{
e x t
} [wi t hi n]
Here t ype
is the "type" of the new class of floats (e.g., program, diagram, etc.),
pl acement gives the default placement specifier, and ext is the filename extension for the file that will keep the captions in cases where we want to have a list of programs, list of diagrams, or other lists. The optional argument wi t hi n is used to number float objects within some sectioning unit (e.g., chapter, section). Here is a complete example:
\newfloat{program}{htb}{prg}[section]
Note that after each such definition, a new environment will be available. Naturally, its name depends on the "type" (e.g., the example code above will create the program environment). The "float style" can be specified with the \f l o a t s t y l e command. The command has one argument, which is the name of a "float style":
174 ^ 6 M o r e o n t h e C o r e
plai n This style is identical to one that LiTgX applies to floats. The only difference is that the caption always goes below the body of the float, regardless of where it appears in the body of the new environment, boxed The body of the float is printed inside a box. The caption goes below this box. ruled The caption appears on the top of the float; ruled lines are put before and after the caption, and another rule is put after the float.
The command \l i s t o f is used to produce a list of all floats of a given class:
\l i s t o f { t y p e y - { t i t i e }
program 1.1 A trivial Java program.
public class t e s t {
public s t a t i c void main(String[] args) { f o r ( i n t i=0; i<args.length; i++) -[ System.out.printIn(args[i]);
}
>
}
Figure 6.3: Sample output of the float package.
So, if one wants to typeset the list of programs, the following command needs to be used:
\l i s t o f {program}{List of programs}
Figure 6.3 shows a sample output generated with the new program environment defined above and the ruled float style.
An important feature introduced by this package is the H placement specifier, which actually forces I^TgX to put a float at the very position where it appears. H differs from h in that the latter just suggests that LTgX put the float here, whereas the former forces ΙΉβΧ to put the float exactly here. Note that the H placement specifier cannot be used in the definition of a new class of float objects.
The picinpar package
By using the picinpar package (by Friedhelm Sowa), one can easily embed figures or tables inside paragraphs. The package provides the environment window plus the environments f igwindow and tabwindow. The latter environments are just applications of the window environment. The window environment has four required arguments:
\begin{window}[
l i n e s, pl acement, ma t e r i a l, e xpl anat i on]
6.5 Fl o a t i n g O bjects <>- 175
Here, I i nes is the number of lines from the paragraph top, ρ I acement is either 1, c, or r and is used to print the picture at the left-hand side, centered, or at the right-hand side of the paragraph, respectively, mat er i al is the figure to be displayed, and expl anat i on is the caption for the figure. This environment is used mainly for graphics, and the environment tabwindow is for tables created with the tabular environment. Here is how one may create the dangerous paragraphs of this book:
\begin{window} [0,1, \i n c l u d e g r a p h i c s [ s c a l e =. 2] {danger. eps}, {}] \s m a l l\n o i n d e n t b l a h, b l a h, b l a h, b l a h...
\end{window}
The wrapfig package
Donald Arseneau has created the wrapfig package to allow people to place figures or tables at the side of a page and wrap text around them. The package provides the environments wrapf igure and wrapt able. Both environments have two required and two optional arguments:
\begin{wrapf igure} [nl i nes ] {.pl acement} [overhang] { wi dt h}
n l i n e s is the number of narrow lines, and pl acement is one of r, 1, i, o, R, L, I, or 0 for right, left, inside, and outside, respectively. The uppercase placement specifiers differ from their lowercase counterparts in that they force to put the float "here," whereas the lowercase placement specifiers just give a hint to I^TgX to place them "here." The wi dt h argument is the width of the figure or table that appears in the body of the environment. Finally, overhang tells ΐ^ΤβΧ how much the figure should hang out into the margin of the page. Here is how one may create more dangerous paragraphs of this book:
\b egi n {w r a p f igu r e }[4]{1}{1.5cm}
\i n c l u d e g r a p h i c s [scale=0.2] {danger.eps}
\end{wrapf igure}
{\s m a l l\n o in d e n t b l a h, b l a h, b l a h, b l a h...}
Note that the text can have more than one paragraph.
The sub figure package
This package provides support for the manipulation and reference of subfigures and
subtables within a single f i g u r e or t a b l e environment. The package was designed by Steven Douglas Cochran. It provides a number of options, which are presented in Table 6.2.
In order to embed subfigures or subtables inside a figure or table, respectively, one has to use the following commands:
1 7 6 ·φ· 6 M o re o n th e C o re
Table 6.2: Options of the subfigure package.
Option
Description
normal
Provides "normal" captions, this is the default.
hang
Causes the label to be a hanging indentation to the caption paragraph.
center
Causes each line of the paragraph to be separately cen­
tered.
centerlast
Causes the last line only to be centered.
nooneline
If a caption fits on one line, it will, by default, be centered. This option left-justifies the one-line caption.
scriptsize, ..,, Large
Sets the font size of the captions.
up, i t, si, sc, md, bf, rm, sf or t t
Sets the font attributes of the caption labels.
\s u b f i g u r e [ c apt i on] {f i g u r e }
\s u b t a b l e [ capt i on] {tab Ze}
If the capt i on is given (including the empty caption [ ]), the subfigure is labeled with a counter formatted by the command \t h e subfigure. Similarly, the subtable is labeled with a counter formatted by the command \thesubtable. In Figure 6.4, we show the output generated by the following code fragment:
\begin{figure}%
\c e n t e r i n g
\s u b f igure [ F i r s t ] {.. . }\hspace{\len}
\s u b f igure[Second F i g u r e ] {... }\\
\s u b f i g u r e [Third] {\l a b e l { 3 f i g s - c }. . .}%
\caption{Three s u b f i g u r e s.}
\l a b e l { 3 f igs}
\en d {f ig u r e}
F i g u r e ~\r e f { 3 f i g s } c o n ta in s two t op su b f i g u r es and F i g u r e ~\r e f { 3 f i g s - c }.
If one wants to have the captions of subfigures or subtables to be included in the list of figures or the list of the tables, respectively, the following commands must be put in the preamble of the input file:
\s e t c o u n t e r { l o f d e p t h } { 2}
\s e t c o u n t e r { l o t d e p t h } { 2}
The ccaption package
The ccaption package by Peter Wilson provides the necessary commands to restyle captions. In addition, it provides commands that produce "continuation" captions,
6.5 Fl o a t i n g O bjects <>- 1 7 7
(a) First (b) Second
Figure
(c) Third
Figure 2: Three subfigures.
Figure 2 contains two top subfigures and Figure 2(c).
Figure 6.4: A typical figure with subfigures.
unnumbered captions, bilingual captions, or legends. The command \captiondelim should be used to change the symbol that is placed between the caption number and the caption text. To change the default symbol to an en dash, use the following command:
\captiondelim{—u}-
caption title; that is, the float name, the number, and the delimiter. The argument of this command can be any font selection and/or size changing-commands, such as
\cap ti o n n a me f o n t{\L ar g e\sf f amily}
Similarly, the command \c a p t i o n t i t l e f ont should be used tn change the font that is used to typeset the caption text. The \c a p t i o n s t y l e command should be used to change the way the whole caption is being typeset. For example, if the argument of this command is the \r a g g e d r i g h t declaration, then the whole caption will be typeset accordingly. Other possible arguments of this command are the declarations \rag g e d - l e f t and \c e n t e r i n g. In addition, the package defines the declaration \c e n t e r l a s t - l i n e, which should be used to get a caption being typeset the usual way but with the last line centered.
The command \hangcaption will cause captions to be typeset with the second and later lines of a multiline caption text indented by the width of the caption title. The command \indent capt ion takes a length or a length variable as argument and uses it
178 -Φ 6 M o re o n th e C o re
to indent all caption text lines after the first line. To undo any effect produced by \hang- cap t io n and \ indent capt ion, just use the \normalcaption command. Furthermore, it is possible to change the total width of a caption by using the \ch a n gec ap t io n - width command. The total width must be set with the \c a p t i o n w i d t h command. This command has one argument, which is just a length or a length variable. Each of the com­
mands \p r e c a p t i o n and \p o s t c a p t i o n have one argument, which will be processed at the start and the end of a caption. For example, the commands
\pr ecap ti o n {\r ul e{\l i new id t h}~[ 0 · 4pt}\par}- \p o s t caption-C\rule{\linewidth]-{0. 4pt}}
will draw a horizontal line above and below the captions. The length of the line will be equal to the current line width. The ccaption package assumes that initially both commands have empty arguments.
The \c o n t c a p t i o n command can be used to place a "continuation" caption into a float environment. It does not increment the float number nor make any entry into a float listing. The \legend command should be used to place a caption without a caption title in a float environment.
Bilingual captions can be produced with the following command:
\bitwonumcaption [ l ab e l ] {sTiortdM longAy{namey-{shortBy-{_ longB}
The l abel is an optional argument that is a normal label that can be used to refer to the caption. short A and longA are the short and long forms of the caption in the primary language of the document, short B and longB are the short and long forms of the caption in the second language, and name is the name of the caption title in the second language of the document. However, we have noticed that this command does not function when used with the babel package when the two languages use different scripts (e.g., the Latin and the Cyrillic). Fortunately, it does work with A! The package offers some other capabilities, which we feel are not of general interest so we do not describe them.
6.6 M a r g i n a l N o t e s
Some Marginal notes are used to label paragraphs . Usually, they consist of a few words (up
Marginal to five or six) and give the reader an idea of what the paragraph deals with. Marginal Notes notes can be created with the command
\m a r g i n p a r [l e f t ] { r i g h t )·
The l e f t text is optional, is used mainly for two-sided printing, and always appears on the left margin of a page. The r i ght text always appears on the right margin of the page. One can easily reverse this functionality with the command \reversemarginpar. We can revert to normal marginal notes placement with the command \normalmarginpar.
There are three parameters that control the appearance of marginal notes:
6.7 P a g e L a y o u t <>- 179
\marginparwidth is the width of marginal notes.
\marginparsep is the distance between marginal notes and the text.
\mar ginparpush is the minimum vertical blank space between adjacent marginal notes.
Marginal notes are actually floating objects, and therefore one should be careful when using them.
6.7 P a g e L a y o u t
As we have already explained, one can specify the paper size of a document in the \do cument c l a s s command. Then, LT^X automatically calculates the right text margins. In case one is not satisfied with these values, one can either change some of these predefined values or use either the vpage package or the geometry package to define a new page size. Figure 6.5 on page 181 shows most of the parameters that can be changed. Variables \paperheight and Ypaperwidth are used to store the paper height and width, respectively. There are also some parameters (i.e., length variables) that are not shown in this figure:
\evensidemargin is used to store the width of the outer margin of even-numbered pages in two-sided documents.
\columnsep contains the width of space between columns of text in a multicolumn document.
\columnseprule refers to the width of the vertical line separating two adjacent columns in a multicolumn document.
\columnwidth holds the width of a single column in a multicolumn document. \li n ewid th keeps the width of the current text line; usually it is equal to the current column width, but in many cases it is altered by environments, and so forth.
In addition, Ω provides the primitive length variables \pageheight and \pagewidth, which hold the height and the width of the page, respectively. The default values for these are for A4 pages. Furthermore, the Ω primitive commands \pagerightof f s e t and \pagebottomof f s e t should be used to move the page horizontally (from the left to the right) and vertically (upwards), respectively. Similarly, the command \hof f se t and \v o f f s e t are use to move the page horizontally (from the left to the right) and vertically (downwards).
Figure 6.5 has been drawn with the layout package by Kent McPherson. In order to produce such a figure, simply create a LTgX file that uses the layout package and contains only the \lay o ut command in its body.
The package vmargin (by Volker Kuhlmann) provides an interface to change the layout of documents that are typeset using the metric paper sizes (i.e., AO, A l,..., BO, B l,..., CO, Cl, and so on) and all of the standard American paper sizes. The package options include the paper size format (e.g., A6), the words po r t ra i t and landscape for a document that will be typeset either portrait or landscape, respectively, and the
ι 8 ο -Φ 6 M o r e o n t h e C o r e
option nohf for a document without header and footer lines. When the last option is specified, the document will be produced without page numbers. If we want to use a custom paper size, we can define its dimensions with the command
\setpapersize{custom}{u/idi/i}{/ieig/it }
Once the paper size is selected, margins can be set by
\setmargins{ I eftmargin}~{ t opmarg i n } { t ext wi dt h } { t e x t h e i g h t }%
{ he adhe i gh t } { heads ep } {/o o t he i ght } {/o o t s k i p }
or by
\setmarginsrb{ leftmargi n}~{ t op margi n)-{ri ght margin}-{ bo ttommarginy% { h e a dh e i ght y { he ad s e py { f oo t he i gh t y { f oot s k i py
In t he l atter case, \t e x t w i d t h and \t e x t h e i g h t are cal cul at ed us i ng t he wi dt h and he i ght of t he s el ect ed paper. The c ommands \s e t ma r g n o h f and \s e t ma r g no h f rb pro­
v i d e a page wi t h no header and no footer. They work t he s ame as \s e t m a r g i n s and
\s e t m a r g i n s r b except that t hey onl y ne e d t he fi rst f our paramet ers. The l ast four paramet ers are set t o Opt. The c ommands \s e t ma r g and \s e t ma r g r b are t he same as \s e t ma r g n o h f and \s e t ma r g no h f rb except that t he l ast f our paramet ers are kept unchanged i ns t ead of be i ng set t o 0 pt.
The package geometry, by Hi deo Umeki, pr ovi de s an e as y and f l exi bl e us er i nter­
face t o c us t omi ze t he page l ayout. It i mpl ement s aut o- cent eri ng and aut o- bal anci ng mechani s ms s o t hat t he us ers have onl y t o gi ve a f e w i t ems of dat a for t he page l ayout. Most of t hes e dat a can be s uppl i e d as package opt i ons. For exampl e, one has to gi ve the command
\u s e p a c k a g e [ bo dy ={ 8 i n, l l i n } - ] {geomet ry}·
to obt ai n an 8 i n x 11 i n page. The \g e o me t r y command provi de d by t he package can be us e d t o achi eve t he s ame effect:
\u s e p a c k a g e { g e o me t r y }
\g e o m e t r y { b o d y = { 8 i n,l l i n } }
Here i s anot her e xampl e borrowed f rom the package document at i on. Suppos e t hat we want a page l ayout descri bed as f ol l ows:
The total allowable width of the text area is 6.5 inches wide by 8.75 inches high. The first line on each page should begin 1.2 inches from the top edge of the page. The left margin should be 0.4 inch from the left edge.
________________________________________
Then, we can specify the page layout above with geometry as follows:
\usepackage[body={6.5 i n,8.75in},
top=1.2in, l e f t = 0.4 i n, nohead] {geometry}.
The package offers many options, but here we only present the most significant ones:
6.7 P a g e L a y o u t <>- 181
4 (5
-
Θ-*
T
Header
Body
0
Margin
Notes
m CD ee!
Footer
1 one inch + \hoffset________ 2
3 \oddsidemargin = -llpt 4
5 \headheight = 25pt 6
7 \textheight = 511pt 8
9 \marginparsep = 7pt 10
11 \footskip = 25pt
\hoffset = Opt
\paperwidth = 538pt
one Inch + \voffset____________
\topmargin = -30pt
\headsep = 22pt
\textwidth = 393pt
\marginparwidth = 55pt
\marginparpush = 5pt (not shown)
\voffset = Opt
\paperheight = 668pt
Figure 6.5: Page layout parameters.
1 8 2 -φ 6 M o re o n th e C o re
landscape switches the paper orientation to landscape mode, p o r t r a i t switches the paper orientation to portrait mode, two side switches on two-sided printing, nohead sets the page head to 0 pt. nofoot sets the page foot to 0 pt. noheadfoot sets the page head and foot to 0 pt.
dvips writes the page layout informa­
tion to the PostScript file generated by
DVIPS.
pdf tex sets the page layout when pro­
cessing a T^TeX file with pdfT^T^. paper=paper specifies a paper name (i.e., aOpaper,.. ., a6paper, bOpaper,..., b6paper) and the American paper sizes.
paperwidth = l engt h width of paper. paperheight= l engt h height of paper, papersize={.wi dt h,hei ght y width and height of the paper. t ot al =- { wi dt h,hei ght y width and height of the total body (i.e., head, body, foot and marginal notes). hody={_widt h,hei ght y text width and text height of the body of the page.
hmargin={ l e f t, r i g h t } left and right margins.
vmargin={t op,bottorriy top and bottom margins.
width= l engt h text body width (includ­
ing margins). height= l engt h text body height (includ­
ing margins), l e f t =l engt h left margin of text body, r ight= I engt h right margin of text body. top= l engt h top margin of text body. bottom= I engt h bottom margin of text body.
hscale=scale ratio of width of text body to paper width, vs cale=s c al e ratio of height of text body to paper height. marginpar= l engt h modifies \margin- parwidth.
marginparsep= l engt h modifies \mar- ginparsep. head= l engt h modifies the \headheight. headsep= l engt h modifies the Yheadsep. i oot =l e ngt h modifies the \f o o t sk i p. hof f set= l engt h modifies the \hof f set. vof f set= l engt h modifies the \v o f f set. f ootnotesep= l engt h modifies the \s k i p\f ootins.
6.8 P a g e S t y l e s
Page styles define what goes in the header/footer of a page, provided, of course, that we have left enough room for headers and/or footers. I^T^X offers the following page styles:
empty both header and footer are empty.
plai n header is empty and footer contains page number.
headings footer is empty and header contains the name of a chapter/section and the page number.
myheadings footer is empty and header contains the page number and user-supplied
information.
6.8 P a g e Sty les 183
A user can select a particular page style with the command \pagestyle. This command has one argument, which is the name of a page style. Moreover, it is possible to change the page style of an individual page with the command \t h i s p a g e s t y l e, which also has one argument: the name of a page style. The myheadings page style makes it possible to define what will go in the header using the commands \markright and \markboth. The first command has one argument and is useful for one-sided printing, whereas the second has two arguments and is useful for two-sided printing. The first argument goes on even-numbered pages and the second on odd-numbered pages.
► Exercise 6.5 Suppose that George Typesetter wants to prepare a manuscript and wants his name to appear on the header of even-numbered pages. Moreover, suppose that he wants the (short) title of his manuscript to appear on the header of odd-numbered pages. Write down the necessary commands that achieve the desired effect.
A
Suppose that we prepare a book and want the word "chapter" to be in uppercase and the title of the chapter to be in lowercase. Then, we have to redefine the commands \chaptermark and \sectionmark as follows:
\renewcommand{\chaptermark} [1] {\markboth{'/0 \MakeUppercase{\chaptername}\
Note that the command \chaptername contains the word "chapter," or in the case where we are using the babel package, the corresponding word for "chapter" for the main language of the text. Moreover, the command \MakeUppercase forces its argument to be in uppercase. Now these definitions can be used, even with the fancy hdr package. Here is an example:
\f ancyhead [LE] {’/.
\scshape\thepage\ $\spadesuit$ \leftmark}
\f ancyhead [RO] {’/.
\scshape\rightmark $\spadesuit$ Ythepage}
\l e f tmark contains the left argument of the last processed \markboth command; the \rightraark contains either the right argument of the last processed \mark- both command or the only argument of the last processed \markright command. When an argument appears in uppercase by default, we can disable this feature by making any mark an argument of the command \nouppercase:
\lhead{\nouppercase{\rightmark}}·
Although one can easily customize a page style, we recommend that people use the package fancyhdr by Piet van Oostrum, to create their own page style. The general page layout can be seen in Figure 6.6 (a). The LHdr and LFtr are left-justified; the CHrd and CFtr are centered; the RHdr and the RFtr are right-justified. We have to define each of the six elements and the two decorative lines separately.
Let us see how we can define the example page layout of Figure 6.6 (b):
1 8 4 ·Φ 6 M o re o n th e C o re
LHdr CHdr RHdr
About your paper
page body
page body
LFtr CedFtr RFtr
From: Apostolos To: Antonis 4
(a) General page layout. (b) An example page layout.
Figure 6.6: Page layouts.
\pag e st y le {f a n cy }
\l h e a d O \c h e a d O \r h e a d {\b f s e r i e s About your paper}
\lfoot-fFrom: Apostolos} \cfoot{To: Antonis} \r f o o t {\t h e p a g e } \renewcommand{\headrulewidth}{0.4pt}
\renewcommand-C\f ootrulewidth}-[0. 4pt}
In the code above, we set the width of the two rules with a redefinition. For the moment, one does not need to know anything more to define simple page layouts. We first specify that we are going to use the fancy page style for the rest of the document, except of course for the first page. If we do want to have a fancy page, we have to select the fancy page style for the first page only. The commands \lhead, \l f oot, and so on, are used to set the six elements of the header and the footer.
In Figure 6.7 we show an example of a page layout suitable for two-sided printing.
(a) Even-numbered page. (b) Odd-numbered page.
Figure 6.7: An example of two-sided printing.
Here are the commands for this particular page layout:
\fanc yheadO % c l e a r a l l f i e l d s \fancyhead[RQ,LE]{\bfseries About your paper}
6.9 T h e P r e p a r a t i o n o f Sl i d e s · ^ 185
\f ancyf oot [LE,R0] {\thepage)- \f a n c y f o o t [L0,CE]{From: A.S.}
\fancyfoot[CO,RE]{To: A.T.}
\renewcommand{\headrulewidth}-{0 · 4pt}
\renewcommand{\f ootrulewidth}-{0. 4pt}
In the example above we use the commands \f ancyhead and \f a n c y f oot to set the header and the footer. The optional arguments are called selectors, and the full list is: E(venpage), 0(dd page), L(eft element), R(ight element), C(enter element), H(ead), and F(ooter). The last two elements can be supplied to the command \f ancyhf, which is useful to combine the specifications for footers and headers.
Suppose that we want to get rid of the decorative lines on pages that have a float object on the top (or bottom) of the page. Then, the following command will achieve the desired effect:
\renewcommand{\headrulewidth}-{\if f loatpage{0pt}-{0. 4pt}}
The first argument specifies the width of the decorative line if there is a float object on the top (bottom) of a page. The second one specifies the width of the decorative line in "normal" pages.
Another problem that can be tackled with this package is the redefinition of the standard page styles. Here is an example:
\f ancypagestyle{plain)-{%
\f ancyheadO %
\f ancyf oot [C] {\b f s e r i e s \thepage}- \renewcommand{\headrulewidth}-{Opt}-}
6.9 T h e P r e p a r a t i o n o f S l i d e s
The production of simple transparencies (“slides") for use on overhead projectors can be done with the s l i d e s document class. However, one can create fancy transparencies by using special document classes that we will describe later.
An individual transparency is produced with a s l i d e environment (see Figure 6.8). Any ordinary command can appear in the body of this environment. However, one
should not use any sectioning commands, floating objects, or page breaks, as these commands make no sense in a s l i d e environment. The overlay environment is used for an overlay (i.e., a slide that is meant to be put on top of another slide). This environment
is the same as the s l i d e environment except for numbering; suppose that the page number of a slide is 5. Then, the first overlay is numbered "5-a," the second one is numbered “5-b," and so on. Since overlays are put on top of a slide, the overlays must contain exactly the same text as the slide but, at the same time, we must make certain parts of the slide invisible. There are two approaches to this problem: (a) we use
ι 8 6 -Φ 6 M o r e o n t h e C o r e
\documentclass[llpt]{slides}
\begin{document}
A |AT[zX Tutorial for
Scientists and Authors.
\begin{slide}
\begin{center}
By A.B. Rose
A \LaTeX\ Tutorial f o r\\
Typography Dept.
Scientists and Authors.\\
By A.B. Rose\\
Athens
Typography Dept.\\
AthensW
2003
2003
\end{center}
\end{slide}
1
\end{document}
Figure 6.8: A slide and the code that generates it.
the colorackage and make the text invisible by coloring it, or (b) we use the \phantom command. This command has one argument, which is a piece of text that TgX typesets without printing any glyphs so the text is actually invisible. For example, the command
\underline{\phantom{\LaTeX}}
prints a s (Π provides the primitive commands \l e f t g h o s t and \r i g h t ghost,
which do the same thing for the character that immediately follows the commands. The first command is useful for left-to-right typesetting and the second for right-to-left typesetting.) If one wants to write notes between slides, one can use the note environ­
ment. Notes that follow slide 3 are numbered "3-1," "3-2," and so on. The commands \o n l y s l i d e s and \o n l y n o t e s can be used to print some of the slides and/or some of the notes. Both commands have as arguments a comma-separated list of slide/note numbers and possibly a range of slide/note numbers, respectively. For example, the commands
\o n l y s l i d e s { l,4,6 - 8,1 5 } \o n l y n o t e s { 2,8-10}
will produce slides 1, 4, 6-8, and 15 and notes 2 and 8-10. These commands must be specified in the preamble of a ϊ£ΓεΧ file.
When giving a lecture, it is a good practice to have a strict time schedule, so one does
not actually run out of time. To assist people, Ι£ΓβΧ provides the command \addtime, which has one argument—the total time (in s econds) that the speaker should spend on a slide. This command can be placed before or after a slide. The total time that the
6.9 T h e P r e p a r a t i o n o f Sl i d e s · ^ 187
speaker should have taken so far will be printed at the bottom of each note. One can reset the elapsed time with the \s e t t ime command. The command \s e t t ime{120}- sets the total elapsed time to 120 seconds (2 minutes). This command must not appear in the body of any environment described in this section.
6.9.1 Advanced Slide Preparation
The seminar document class (by Timothy P. Van Zandt) provides an environment for advanced slide preparation. The document class provides two environments for slides: the s l i d e environment for landscape slides and s l i d e * for portrait slides. By default, the slides will be typeset in landscape mode, but if one specifies the p o r t r a i t option, the slides will be typeset in portrait mode. Both environments have two optional arguments that let one change the width and the height of a slide. For example, the command
\begin{slide}[5cm, 7cm]
starts a slide in landscape mode that is 5 cm wide and 7 cm long.
The standard s l i d e environment disables the use of commands that do page breaks in its body. Fortunately, this is not the case with the corresponding environments that the seminar document class provides. One can easily break a long slide into "sub^-slides with the command \newslide. However, this mechanism works only if we enlarge the standard slide height with the command
\e x t r a s l i d e h e i g h t { 10cm}
Note that we just make slides long enough so that it makes sense to break them into "sub"-slides. This mechanism is particularly useful when we want to transform a manuscript into slides.
If one wants to customize a group of slides, then one has to change the value of the length variables shown in Figure 6.9.
Slides can be framed. The command \s l i d e f rame [ command] { s t y l e } · specifies the frame style to use. The predefined frame styles are none and plain. If one uses the fan- cybox, then the following frame styles are available: shadow, oval, Oval, and doublebox. It is even possible to create your own frame style, but we think that the six frame styles are more than enough.
The commands \o n l y s l i d e s and \n o t s l i d e s can be used to include or exclude only those slides that are in the argument lists.
If we just want to preview our slides, we can force I£TeX to put two slides per page with the command \twoup. This command should be placed in the preamble of a LT^X file. The command has an optional argument (an integer) that increases or decreases the two-up magnification. Additionally, if one wants four slides per page, the a r t i c l e document class option is used; then the \twoup command produces the desired effect. This option offers slide styles that can be used to specify where slide labels should go. The slide style can be selected with the command \s l i d e s t y l e. There are three
ι 8 8 -Φ 6 M o r e o n t h e C o r e
\slideleftmargin
\sliderightmargin
\slidetopraargin ^
\slidebottommargin T
Here is my header
9/30/99
f
Λ
M y s l i d e
V
J
Here is my footer
7-9
\paperwidth
\paperhe ight
Figure 6.9: Slide margins.
predefined slide styles: empty, l e f t, and bottom. Moreover, one can specify one's own slide style with the commands
\newpagestyle{s ty I e}{7ieader}{/oo t e r } \renewpagestyle{sti/le}{7ieacZer}{/ooter}
Here, s t y l e is the name of a (new or predefined) page style; the other arguments have the expected meaning. Naturally, if one chooses to use a predefined page style, then marks have to be set.
There is no special environment for notes. Consequently, one can write notes be- tween slides. The document class has three options that handle the printing of notes: s l i d e s o n l y (only the slides will be printed), not es (both notes and slides are printed), and n ot es only (only the notes are printed).
Overlays are produced in a “natural way" (i.e., overlays are part of the s l i d e environment, and the user just types the additional text in each overlay). Overlays are written in the body of the overlay environment. Each overlay has an argument that specifies the order in which overlays will be generated. This argument is a number from 0 to 9; number 0 denotes the slide. In order to be able to generate overlays, users have to specify the semlayer and the semcolor class options. Moreover, the frame style of an overlay can be specified with the command \o v e r l a y f rame. Here is a small example:
6.9 T h e P r e p a r a t i o n o f Sl i d e s · ^ 189
\documentclass [semlayer, semcolor] {seminar}
\usepackage{f ancybox}
\s l i d e f rame{0val}
\overlayframe{Oval)-
\begin{document}
\b e g i n { s l i d e }
This a s l i d e \begin{overlay}-{l}
This i s t he t e x t of t h e f i r s t o v e rl a y.
\end{overlay}
\begin{overlay}{2>
This i s t he t e x t of t h e second overl ay.
\end{overlay}
\end { s li d e >
\end{do cument}
Another document class that provides an environment for advanced slide prepa­
ration is the p rosper document class (by Frederic Goualard). When generating slides with prosper, you have to transform the resulting output file to PostScript. If you want to create a slide show, you have to transform the PostScript file to PDF using a program such as p s 2 p d f. To make fancy slide shows, prosper supports a number of transition effects, that is, visual effects employed when going from one slide to anothe, which are specified as optional arguments to s l i d e enviroments (see Figure 6.10); the available transition effects are:
S p l i t Two lines sweep across the screen revealing the next slide.
Box A (growing) box sweeps from the center, revealing the new slide.
Blinds A number of lines evenly placed on the screen appear and together sweep in the same direction to reveal the next slide.
Wipe A line sweeps across the screen from left to right revealing the new slide. Dissolve The old slide dissolves to reveal the next slide.
G l i t t e r Similar to Dissolve, except that the old slide dissolves from left to right as if a
wave is moving in this direction._______________________________________________
Replace The effect of this option is just to replace the current slide with the next one.
The prosper document class accepts the following options:
draft Figures are not included in the resulting file and are replaced by frames that have the size of the figures. In addition, the caption at the bottom of every slide displays the processing date and time together with the filename, f i n a l Figures are included in the resulting file; the text of captions appears as it was requested.
slideColor Slides will be colorful; this option should be used with caution when the slides are to be printed on a black and white printer.
1 9 0 ·φ· 6 M o re o n th e C o re
slideBW Slides will be colored with a reduced number of colors and so they can be printed on a black and white printer without any problem, t o t a l The caption at the bottom of every slide displays the number of the current slide along with the total number of slides, n o t o t a l Only the number of the current slide appears in the caption. nocolorBG The background of the slide is white whatever the style may be. colorBG The background color depends on the current style, ps Must be used when you want to print the slides on a PostScript printer, pdf Must be used when you want to display the slides using Acrobat Reader, accumulate The commands \o n l y S l i d e, \u n t i l S l i d e, and \fromSlide operate in PostScript mode, also called ps mode, noaccumulate The commands \o n l y S l i d e, \u n t i l S l i d e, and \f romSlide do not op­
erate in PostScript mode, d i s t i l l e r This option should be used when the resulting PostScript file will be trans­
formed to PDF by Adobe Distiller.
It is now time to present the commands and the environments that this document class provides. In Figure 6.10, one can see the general structure of a ΜβΧ file that uses the prosper document class. The following commands should always appear in the preamble of the T^T^X file:
\t i t l e The argument of the command becomes the title of the presentation.
\s u b t i t l e The argument of this command is the subtitle of the presentation. This command is optional.
\author The author(s) of the presentation.
\email The e-mail address(es) of the author(s) of the presentation.
\i n s t i t u t i o n Author(s) affiliation (optional).
\s l i d e C a p t ion The argument of this command will be put at the bottom of every slide. If we do not use this optional command, the title of the presentation is used as each slide's caption.
\Logo The command has two forms: \Logo (as,y){logc>y and \Logo{ l ogo}. Here, logo is a set of commands that draws a figure or an image inclusion command (see Chapter 9 for more details). The optional arguments surrounded by parentheses specify the exact location where the logo will be placed. Point (0,0) is located at the lower left-hand corner of the slide.
\displayVersion A draft caption is printed instead of the standard one.
\Def a u l t T r a n s i t i o n The argument of this command is the name of a supported tran­
sition effect and will be the default transition effect employed. \NoFrenchBabelItemize This command should be used only if the frenc h option of the babel is used. This way, one can choose to have one's own itemization style.
The s l i d e environment may have an optional argument that specifies the transition efect. The new Itemize environment corresponds to the standard itemize environ- ment, and the i temize environment has been redefined so that the text is not justified.
6.9 T h e P r e p a r a t i o n o f Sl i d e s · ^ 191
\docuraentcla s s [ O p t i o n s ] {prosper}
\title{ri£Ze o f p r e s e n t a t i o n } \subtitle-C5ui>tit i e } \author-CJyames o f t h e a u t h o r s}
\ inst itut ± o n {.A f f i I i a t i o n } XslideCaption-fcaption t e x t }
\begin{document}
\maketitle
\begin{slide}[ t r a n s i t i o n ] {slide t i t l e }
M a t e r i a l f o r t h e s l i d e
\e n d { s l i d e }
\o v e r l ays { n} {
\b e g i n { s l i d e }[ t r a n s i t i o n ] { s l i d e t i t l e }
M a t e r i a l f o r t h e o v e r l a y
\e n d { s l i d e }
}
\e nd{ do c ume nt }
Fi gure 6.10: Structure of a IATeX file using the prosper document class.
The i t emst ep environment can be used in the slide of an overlay only. Each item of this environment is displayed incrementally in PDF mode. For example, the overlay
\overlays{3}-{%
\b e g i n { s l i d e } [ S p l i t ] { T h i r d Slide}
Hello
\begin{itemstep}
\i t e m One \i t e m Two \i t e m Three \end{itemstep}
There
\e n d { s l i d e }
}
will initially display the first item. The second item will appear once we proceed to the next page by pressing Ctrl+PgDn and so on. The \o v e r l a y s command should be used
1 9 2 -φ 6 M o re o n th e C o re
to create overlays. Note that here we use a command to create overlays instead of an environment. The \o v e r l a y s command has two arguments: a number that indicates the number of overlays and a s l i d e environment.
>- Exercise 6.6 Suggest a slide construction method that will allow readers to nav­
igate in a slide show using only the mouse. □
The following commands may appear in the body of a slide:
\FontTitle This command should be used to change the font/size/color to be used for the slide titles. The command has two arguments: the first for color slides and the second for black and white slides. To change the color, one should not use the color package described in Section 9.11.1. Instead, one can use either the predefined colors \black, \darkgray, \gray, \li g h tg r a y, \white, \red, \green, \blue, \yellow, \cyan, or \magenta. If we want to use other colors, we can define them with the command \newrgbcolor, which is provided by the pstricks package. This command has two arguments: the name of a color and its r gb color specification (see Section 9.11.1). Here is a simple color definition:
\newrgbcolor{gold}"CO.804 0.498 0.1963-
Note that the color is defined without a leading backslash, which, however, is necessary when using the color.
\FontText A command that can be used to change the font/color/size of the slide text.
It has two arguments, exactly like \FontTitle.
\f ontTi tl e Typesets its argument in the font/color/size specified with the \FontT i t l e command.
\f ontText Typesets its argument in the font/color/size specified with the \FontText command.
\ColorFoot The footer of the slide is typeset with the color, which is the argument of this command.
\PDFtransition Can be used to alter the transition effect. The command has one argument, which is the name of a transition effect.
\myitem This command has two arguments and is used to redefine the itemization symbol. The first argument is the itemization level (possible values 1, 2, or 3), and the second argument is a command that defines the symbol. This command can be
a graphics inclusion command or drawing.
The following commands may be used in the creation of a set of overlays:
\f romSlide Has two arguments and puts the second argument on all overlays starting from the one that the first argument (a number) specifies.
\o n l y S l i d e Puts the second argument on the overlay specified by the first argument. \u n t i l S l i d e Puts the second argument on all overlays starting from the first one and finishing with the one that is specified by the first argument.
6.9 T h e P r e p a r a t i o n o f Sl i d e s · ^ 193
\FromSlide All the material that follows the command will be placed on all overlays starting from the one that its only argument specifies.
\0 n l y Slide Adds the material that follows the command to the overlay that its only argument specifies.
\U n t i l S l i d e Similar to \FromSlide but adds the material to all overlays starting from the first one and finishing with the one that its only argument specifies.
As one might expect, all of these commands are meaningful in PDF mode. The com­
mands \o n l y S l i d e, \f romSlide and \u n t i l S l i d e have starred counterparts that type­
set the material exactly in the same place. For example, the code
\overlays{3}{%
\begin{slide}{Example)-
\onlySlide*{l}-{\Huge\green A}% \onlySlide*{2}"C\Huge\yellow A}°/0 \onlySlide*{3}{\Huge\blue A}%
\e n d { s l i d e }
>
will create three overlays that will print the letter A at the same position in each overlay in three different colors. Note that the % is necessary to avoid unwanted white space that would distort the appearance of our slide show.
In certain cases, we want to place different material in an overlay or slide depend­
ing on whether it will be printed or displayed on a computer screen. The following commands have been designed to facilitate this procedure:
\PDForPS Has two arguments, and the first is used if we are preparing our slides in PDF mode. The second argument is used if we are preparing our slides in PostScript mode.
\onlyInPS The only argument of this command is used if we are preparing our slides in PostScript mode.
XonlylnPDF If we are preparing our slides in PDF mode, then Ι^Τ^Χ will use the only argument of this command.
For example, one can add the following command in the overlay above in case it is necessary to print the overlays:
\onlyInPS{\Huge\gray A}%
What makes the prosper document class exceptional is its ability to use a number of predefined presentation styles. The presentation styles currently available are presented on pages 194-195. Note that the document class declaration used to create these slides is
\do cument c l a s s [ slideBW,no colorBG,p s,xxxxx]{pro s p e r )- where χχχχχ is the name of a presentation style.
194 ^ 6 M o r e o n t h e C o r e
1
Gyom cxnmplc
Jwi PieiiG nlo r
■ft* IW
Lr.:. Ar USA
1
R i c a e x a m p l e
J i n Ρι βμπΙβγ
Sl i de Sf ca*v, I nc
USA
r i c o s t y l e g y o m s t y l e
A u t u m n e x a m p l e
Sfcde Shows, Inc Lot USA
A l i e n g l o w e x a mp l e
jIieti ^rc-ai -TOi -j SjiJg Ewa Inc.
| Li * USA
a l i e n g l o w s t y l e
a u t u m n s t y l e
A z u r e e x a m p l e
■
Ji m Pr esent er
Sl x*r SIh*w, Inc
PKeeot ef
Los Angel es, USA
Λι * SfcCw*. Ira
Lw USA
...
a z u r e s l y l e
c o n t e m p o r a i n S t y l e
6.9 T h e P r e p a ra t i o n o f S lid es 195
Darkblue example
Jim
SK4» SfcWMi. *C.
Lf» tagnteo, |>SA
Frames example
Sbsic ShrMii.hvc
LO* Αΐ>φ6£& USA
d a r k b l u e s t y l e
f r a m e s S t y l e
Lignesbleues example
AfTi froSCrtlM
sine &CHtk Inc LD& ATitMOfl, USA
l i g n e s b l e u e s style
N u a n c e g r i s e x a m p l e
JlfY.
State ShcwrtL I k Lrti Αγη>^. USA
nuancegris style
Troispoints example
$*** Sko**, Iik; U g Angulos. USA
▲..........................................
t r o i s p o i n t E s t y l e
1 9 6 ·φ· 6 M o r e o n t h e C o r e
6.1 0 B o x e s
When building a wall, we put bricks one on top oi the other, and in between them we put mortar to make the wall rigid. Similarly, TgX constructs pages by putting lines one above the other, and in between them it puts a special rubber length called glue. Each line consists of words, which, in turn, consist of letters (i.e., glyphs). In Section 1.4, we said that T^X treats every glyph as a "box," so a line is a big box that consists of little boxes (i.e., glyphs). A paragraph is an even bigger box that consists of lines and so on. A box is just a rectangle that has height, width, and depth:
bas el i ne
hei ght
de pt h
wi dt h
The vi rt ual l i ne wher e characters si t i s cal l ed t he baseline. Here is a little example that demonstrates how T^X perceives two lines of text:
I love [HE you! ^
Since boxes are so important, I^TpX provides a number of commands that create boxes. Moreover, it provides box variables to which one can store boxes.
The following command can be used to create a box of width equal to wi dt h that contains an obj: positioned at p o s:
\make box[width] [pos]{_obj }
If the wi dt h is missing, we have to omit the pos, so the width of the box is equal to the natural width of the o b j. The height and the depth of the new box are equal to the natural height and width of the obj. The possible values for pos are: s (for stretched), 1 (for flush left), r (for flush right), and c (for centered). The last value is the default one. This shows the difference between these values:
That's all folks!
\makebox[2\width] [1] \makebox [2\width] [r] {...) -
That's all folks!
That's all folks!
\makebox[ 2\w i d t h ] [ c ] {...} \makebox[2\width] [ s ] {...}
That's all folks!
Note that the frames are not produced by the commands that we give on the right- hand side! When IATjnX creates a box, it automatically sets the variables \width, \he ight,
6.i o Bo x es <>- 1 9 7
\depth, and \t o t a l h e i g h t. These variables contain the width, height, depth, and the total height of the o b j. The total height is equal to the height plus the depth. These variables are constants, so we cannot alter their values.
The command \mbox{ obj}· is a fast shorthand for the command \makebox{obj}. An interesting thing to note is that in a \mbox I^TgX uses the main document font. Therefore, if we want to have a word or a short phrase in a mathematical formula that has to be typeset using the main font, we simply can use a \mbox:
X > 0 iff y > 0 J $x>0\quad\mbox{if f}-\quad y>0$
The command \f ramebox is like the command \makebox except that it puts a frame around the box. Similarly, the command \f b o x { o b j } is shorthand for the command \f ramebox{ ob j >. The frame is made of lines of thickness \f boxrule, separated by space \f boxsep from the text. Both \f boxrule and \f boxsep are length variables.
>- Exercise 6.7 Write down the code that produces the framed "That's all folks!" example. □
A box variable can be declared with the command \newsavebox{\c/??<2}-, provided of course that \cmd has not been used before. We can define a box variable with the command
\savebox{\c/n<2)- [wi dt h] [pos] { obj }
The arguments of this command are exactly the same as the corresponding arguments of the \makebox command. Once we have defined a new box variable, we can use it with the command \usebox. The command \sbox{\cmd}-{ob j > is actually a fast shorthand version of the command \savebox{\cmd}-{ob j >.
We can draw ruled lines with the command \r u l e [rai sed] {wi dt h}{hei ght }·. The command draws a wi dt h x hei ght line, raised from the baseline by r ai s e d. In particular, a ruled line with width equal to 0 pt is called a strut. Here is a simple example that shows the use of struts:
Compare this with
this
Compare \fbox{this)- with \f b o x {\r u l e [ -.5cm]{Ocm}{lcm}this}.
Normally, boxes are put on the baseline, but it is possible to raise boxes with the command Xraisebox-Cdistance}- [hei ght ] [dept h] {.box}·. This command raises the box up by di s t ance (or down if di s t ance is negative). Moreover, if the optional arguments are present, it makes Tj?X believe that the box has height and depth equal to hei ght
and dept h
, respectively. For example, the following piece of code produces
the T^X logo:
T\h s p ac e{ -. 1667em}\raisebox{-. 5ex}iE}-\hspace-C-. 125em}X
>· Exercise 6.8 The A in the logo is in \ s c r i p t s i z e and is raised up by 0.2 em.
Moreover, the distance between the L and the A is —0.36 em and the distance between the A and the T is—0.15 em. Write down the commands that generate the TATjgX logo. □
1 9 8 -Φ 6 M o r e o n t h e C o r e
>- Exercise 6.9 Define a box variable that contains a rectangle that is 3 ex long and 4 ex wide. □
If one wants to create a box that contains verbatim text, then one can use the lrbox environment. Here is a simple example:
The characters ~ # $ % ~ & _ are special.
\newsavebox{\temp}
\begin{lrbox}-[\temp}·
The characters \verb|~ # $ % ~ & _l are s p e c i a l.
\end{lrbox}- \usebox-C\temp)-
Note that the space before or after the text in the body of an lrbox is ignored. Moreover, we cannot have more than one paragraph in such a box. If we want to have more than one paragraph, we have to use either a \parbox or a minipage.
The command \parbox|j?os] [h e i g h t ] [i nner- pos] {.wi dt hy- i t ext y makes a box with width equal to wi dt h, positioned by pos relative to the baseline. The possible values of pos are: t (the first line of the box is placed on the baseline), b (the last line of the box is placed on the baseline), c (the box is centered vertically on the baseline), and s (the same as before, but here the box is somehow squeezed). Here is a simple example:
M
a
c
a
I \parbox [t] { 1 0 p t } -C t\\h\\i\\n\\k > \parbox [b] {10pt}-CM\\a\\r\\s> i s \parbox[ c ] { 1 0 p t > { c\\a\\l\\l\\e\\d > \parbox[s]{35pt}{the Red P l a n e t.>
I
t
h
r
s
is
1
1
the Red Planet.
i
e
n
k
d
The optional arguments hei ght and i nner - pos can be used to specify the height of the box and the placement of the t e x t inside the box. The possible values are identical to the value that pos may take. The following example clearly shows the functionality of the i nner- pos argument (the horizontal line is the baseline):
\parbox[t] [20pt] [b] {10ρΐ}{Τ}°/0 \parbox[t] [20pt][c]{10pt>{E>%
\p ar b o x [ t ] [ 2 0 p t ] [ t ] {10ptMX}%
A minipage is a box that looks like a page by setting the \t extwidth and the \columnwidth equal to the width of the box. In addition, one can even have footnotes in a minipage. Minipages can be created with the minipage environment:
\begin-Cminipage}-os] [h e i g h t ] [i nner- pos] { wi d t h y ^ t e x t } t e x t of the minipage \end{minipage}-
6.10 B o x e s -Φ 199
For an expl anat i on of the meani ng of the vari ous argument s that t hi s envi ronment takes, s ee t he di s cus s i on on t he corres pondi ng argument s of t he \pa r bo x command. Here is an exampl e:
An aardvark* i s a burrowi ng mammal of sout hern Afri ca, havi ng a stocky, hai ry body, l arge ears, a l ong t ubul ar snout, and powerf ul di ggi ng cl aws.
aOrycteropus ater
\b e g i n { m i n i p a g e } { 1 5 0 p t } An a a r dva r k%
\f o o t n o t e { O r y c t e r o p u s
a f e r } i s a .......................
\e n d { m i n i p a g e }
6.10.1 Fancy Boxes
The package fancybox (by Ti mot hy P. Van Zandt ) provi des c ommands that create framed boxes. The package provi des four c ommands that create framed boxes ( s e e Fi gure 6.11).
Shadow box
Ϊ
Doubl e box
Oval box
( Al t ernat i ve oval box
\shadowbox{Shadow box} \d o u b l e b o x { Do u b l e box} \o v a l b o x { O v a l box} \O v a l b o x { A l t e r n a t i v e o v a l box}
Figure 6.11: Framed boxes provided by fancybox.
Note that the frame is separated by space \f boxsep from the text. The width of the shadow is stored in the length variable \shadowsize. In a double box the width of the frames, as well as the distance between the two frames, is controlled by \f boxrule. The width of the frame in a \ovalbox and a \0valbox is set by the \t h i n l i n e s and Y t h i c k l i n e s declarations, respectively. The diameter of the corner arcs is set with the \c o r n e r s i z e command. For example, the command
\c o r n e r s i z e { n u m }
sets the diameter of the comer arcs to num times the lessor of the width or height of the box. Similarly, we can set the diameter with the command \c o r n e r s i z e { dim}, where dim is just a length.
Δ
Ιί we want to create a framed minipage, we can just have the minipage as the argument of a \f box command. However, if we want to define an environment that will produce a framed minipage, then there is no obvious solution. The package fancybox provides the Sbox environment; this is a variant of the \sbox command
2 0 ο -Φ 6 M o r e o n t h e C o r e
that saves the body of the environment in an internal box variable. The contents of this box variable can be retrieved with the command \TheSbox. Here is a simple example:
\newenvironraent{f minipage}*/,
{\begin{Sbox}\begin{minipage}}*/, {\end{minipage}*/, \end{Sbox}\fbox{\TheSbox}}
\begin{fminipage}{130pt} hoi polloi (hoi-puh-LOI), noun:
\end{fminipage}
Note that hoi polloi is actually a transliteration of the Greek term Οι πολλοί, which means "the many.”
>■ Exercise 6.10 Define an environment that will be equivalent to a framed equation environment. (Hint: Use the length variables \abovedisplayskip and \belowdisplayskip, which are used to set the white space before and after a math display.) □
In some cases, one may want to display a table or a figure in landscape mode just because it is too wide to fit in portrait mode. The environment landf loat is useful in such cases. It takes two arguments: the name of a float object (e.g., a table) and a rotation command. In the example that follows, we use the command \rotatebox:
\newcomraand{\rotateleft}[l] {*/,
\rotatebax{-90H#l}}
\begin{landfloat}{figure}{\rotateleft} \begin{center}
\includegraphics[scale= 0.1] {gr.eps}
\eild{c enter}
\caption{The Greek Flag}
\end{landfloat}
The package fancybox provides the commands \boxput and \boxput* that can put a box behind or in front of another box, respectively. The command has three arguments: the first box, the second box and, just after the name of the command, an optional pair of coordinates that determine where the center of the first box is positioned. For example, (0,0) puts it in the center of the second box, (0,1) places it in the center-top, and ( - 1,- 1) puts it in the bottom-left corner. Thus, the coordinates are always numbers, with one exception: if the second coordinate is b or B, the first box is positioned vertically at the baseline of the second box. Here is a rather complicated example of its use:
i i'
φ
O
-j
<r
Sf
a*
u
hoi polloi (hoi-puh-LOI),
noun: The common people
generally; the masses.
Lizzie insisted that her chil­
dren distinguish themselves
from the hoi polloi by
scrupulous honesty. -Kate
Buford, Burt Lancaster: An
American Life
6.10 B o x e s 20 1
The process or met hod of sel ect i ng one or more i n­
di vi dua l s from a group, as for a servi ce or duty: a candidate icho did not pursue the nomination, but accepted a draf t by the party convention.
\boxput-f\raakeboxCO
Huge\rot at ebox{45M7.
\s c a l e b o x {2}{*/.
color [gray] {0 . 7}{Draf t>}»>{7, \parbox{4cra}{The process or } }
Framing the body of the text and even a whole page is easy with this package. The commands \f ancypage and \t h i s f ancypage frame either a complete document or a particular page, respectively. Both commands have two arguments: the first one is used to frame the body of the text and the second the whole page, including the header and the footer. For example, the page in Figure reffancy:page:l has been framed with the following commands;
\t h i ε f a n c y p a g e { “/„
\setlength{\fboxsep}{ 8pt}yo
\se tl en g t h {\s h a d o w s iz e} { 8pt}*/,
\shadowboxM*/.
\s e t l e n g t h {\f b o x s e p > { 8p t }\0valbox>
If wre want to frame a f l u s h l e f t, a f l u s h r i g h t,o r c e n t e r environment, we can use the environments Bf l u s h l e f t, Bf l u s h r ig h t, or Bcenter, respectively. Similarly, we can get framed lists wilh the environments Benumerate, Bitemize, and Bdescription. Nat­
urally, the unframed versions of these environments are the environments enumerate, itemize, and d e s c r i p t i o n, respectively.
If we want to produce a framed verbatim environment, we can use the environments that the package provides:
Verbatim This works almost like the corresponding standard I^TeX environment. LVerbatim Just like Verbatim except that the text is indented.
BVerbatim Produces a box with the same width as the longest line of the verbatim text. It has an optional argument that specifies the baseline of the box: b for alignment with the bottom line and t for alignment with the top line. By default, the baseline is assumed to be at the center of the box.
VerbatimOut Has an argument that must be a filename w^here the body of the environ­
ment is written.
SaveVerbatim Stores the body of the environment in a command that is the only argument of the environment. Note that the package does not check whether this command is in use, so it may overwrite the definition of an existing command.
There are some other useful commands for short pieces of verbatim text:
20 2 -φ- 6 M o r e o n t h e C o r e
r
Λ
ανάλογα του που βρίσκεται ο μεταφραστής της γλώσσας. Επίσης, θα πρέπει να κάνουμε εκτελέσιμο το αρχείο το οποίο περιέχει τον κώδικα Perl με την εντολή chmod του Unix. Σε περίπτωση που εργαζόμαστε σε περιβάλλον Windows, θα πρέπει να χρησιμοποιήσουμε το εμπορι­
κό πρόγραμμα perl2exe. Το πρόγραμμα αυτό μετατρέπει αερχεία με κώδικα σε Perl απ’ ευθείας σε εκτελέσιμα αρχεία. Για περισσότερες πληροφορίες για το πρόγραμμα αυτό, επισκευθήτε το δικτυακό τόπο: h t t p://w w w.i n d i g o s t a r.c o m/p e r l 2 e x e.htm
). Σε κάθε περίπτωση, το «εκτελέσιμο» αρχείο εκτελείται γράφοντας απλά το πλήρες όνομά του στην γραμμή εντολών του λειτουργικού μας συστήματος. Από την άλλη η άμεση τροφοδότηση γίνεται απλά με το να δώσουμε την εντολή
p e r i α ρ χε ί o - P e r l.p i
Η προέκταση ονόματος .ρ ΐ δεν είναι υποχρεωτική (μόνο το στρατιωτικό είναι...), αλλά πολλές φορές τη βάζουμε ώστε να γνωρίζουμε ότι το εν λόγω αρχείο περιέχει κώδικα Perl. Φυσικά η παραπάνω εντολή μπορεί να περιέχει και μια σειρά από δι ακόπτ η οι οποίοι μπορούν να αλλάξουν την προκαθορισμένη συμπεριφορά του μεταφραστή.
Η γενική μορφή της εντολής με την οποία καλούμε τον μεταφραστή έχει ως εξής:
p e r i [ δί ακόπτ €ζ ] [ -] [όνομα-προγρ.] [ορίσματα]
Σημειώστε ότι αυτό που εμφανίζεται ανάμεσα σε αγκύλες μπορεί απλά να παραληφθεί. Επίσης, αν χρησιμοποιήσουμε το όρισμα —, οτιδήποτε το ακολουθεί δεν θεωρείται διακόπτης. Στον πίνακα που ακολουθεί
παρουσιαζονται οι βασικοί διακόπτες που αναγνωρίζει ο μεταφραστής της Perl.
Διακόπτες του μεταφραστή της Perl Διακόπτης Περιγραφή
-0
[οκταδικό^] καθορισμός χαρακτήρα τερματισμού
γραμμών (\0 αν δεν υπάρχει όρισμα)
- a «σπάσιμο» των γραμμών εισόδου και
αποθήκευση στην παράταξη @F - c μόνο συντακτικός έλεγχος (τρέχει
μόνο τα μπλοκ κώδικα τύπου BEGIN και END)
συνεχίζεται στην επόμενη σελίδα
\
4 Κεφάλαιο 1-Βασικές δομές της γλώσσας y
Figure 6.12: A page framed with the commands provided by fancybox.
6.i i N e w C o m m a n d s <>- 2 0 3
\SaveVerb This command works like the \verb command but has an argument that is a command name in which we store the verbatim text.
\UseVerb This command has one argument (a command name) and is used for includ­
ing short pieces of verbatim text saved with \SaveVerb.
6.1 1 N e w C o m m a n d s
Although ΕΤβΧ and the many packages that exist provide commands that can tackle a great many problems, there are still situations where one may want to be able to define a command that will solve a particular problem that no package designer had thought of. For this reason, I^TeX provides a facility for the creation of new commands. New commands are defined with the \newcommand command. This command has two re­
quired arguments: the name of the new command and the “code" that will be executed every time we use this new command. The name of our new command must start with a backslash and must be followed by one or more letters.1 Suppose that we want to create a command that will print the expression { x i,..., xn}. Then, the following code will create a new command, \seq, that will do the job every time it is used:
\newcommand-[\seq)"[\-[x_l, \l d o t s, x_n\}}·
Now, we can write $\seq$ to get the expression above. Obviously, the definition above has a big drawback: one cannot use it to print the expression { x i,..., xk}, so one has to define a new command to do the job.
>· Exercise 6.11 Define this new command. □
Now, suppose that we want to be able to define parametric commands (i.e., com- mands that have arguments such as most Ϊ^ΤεΧ commands). The good news is that we can actually create such commands, but the bad news is that we can have at most nine parameters! Here is how we can define a parametric command:
\newcommand{\c/n<2} [n] {commands}
n denotes the number of arguments that \ cmd has. In order to refer to an individual argument inside the commands, we have to use the character # followed by a number. So, if we write #3 in commands, we are actually referring to the third argument of \cmd. We now give a concrete example that is a general solution to the problem above:
\newcommand{\seq} [1]{\{ x _ l,\l d o t s,x _ {#l >\} >
Now, we can write $\s eq{k}$ to get { x\,..., It is important to note that the argu- ments of a command must be surrounded by curly brackets. Although the definition above is quite useful, whenever we use it we must make sure that it occurs in math mode. A simple solution to this problem is to have the commands as an argument of the command \ensuremath. Here is how we can rewrite the definition above:
1. Actually, it must be followed by characters having a category code equal to 11.
2 0 4 O' 6 M o r e o n t h e C o r e
\newcommand{\seq} [ 1] {%
\ens u rem at h {\{x _ l, \l d o t s, x_{#l}\}}}
Now, the commands \seq{k} and $\seq{k}$ produce identical output.
>■ Exercise 6.12 Why do you think we had to use curly brackets to surround the parameter of the command in the expression x_{#l}? □
Suppose now that we want to have a command that will also parameterize the "x." In order to do that, we must introduce a second parameter:
\newcommand{\seq}[2] {%
\e n s u r e m a t h {\{#l _ l,\l d o t s,#1_{#2}\}}}
Although we have parameterized x, in most cases people will use the letter x in such expressions, so it could be useful to have a default value for the first parameter. In other words, we want "x" to be an optional argument with a default value. I^TeX supports command definitions with optional arguments: the default value is surrounded by square brackets and is placed after the number of arguments. Here is the new definition:
\newcommand{\seq} [2] [x] {%
\e n s u r e m a t h {\{#l _ l, \l d o t s, #1_{#2}\}}}
Now, the command \seq{n} will print {x\, ...,x n}, and the command \s e q [y] {k> will print {yi,...,yjfc}.
>- Exercise 6.13 Define a command that will print the phrase I love to fly! one hundred times. □
If we define a new command with \newcommand, IiT^C checks whether this command has already been defined. This is a way to ensure that existing commands will not be redefined accidentally. But there are cases where we need to redefine a command, so I^TeX provides the command \renewcommand, which can be used to redefine an existing command. This command has exactly the same arguments as the command \newcommand.
The commands \newcommand and \renewcommand are also available in starred ver- sions. The only difference between a starred and an unstarred command is that the former introduces new commands whose arguments cannot contain more than one
paragraph. Consider the following document fragment:
\newcommand*{\bdf ace} [1] { {\b f s e r i e s #1}}
\newcommand{\bldf ace} [1] {-[\bf s e r i e s #1})-
\b l d f ace{text t e x t t e x t \par t e x t t e x t } \bdface{text t e x t t e x t \par t e x t t e x t }
6.i i N ew C o m m a n d s -φ- 2 0 5
Remember that the \par command forces I^TgX to start a new paragraph. Now, when I^T^X will processes the command \bdf ace, it will stop and complain with the following message;
Runaway argument?
{ t h i s i s t e x t
! Paragraph ended b efo re \b dface was complete.
< t o b e r e a d a g a i n >
\p a r
1.14 \b d f a c e { t h i s i s t e x t\p a r
a n d m o r e t e x t >
7
Naturally, the line number refers to a hypothetical input file, and of course Ι^Τ^Χ had no problem processing the \b l d f ace command.
Δ
Creating simple commands with IAT^X is not a difficult task. However, when one wants to create commands that have two optional arguments or optional argu­
ments surrounded by parentheses, one has to know the IATgX internals in order to create such complicated commands. To assist people in creating really compli­
cated commands, Scott Pakin has created a Python script called newcommand.py. Suppose that you want to create the first version of the \seq command. Then, you have to invoke the program and type the following (the '/, character is the program prompt):
$ newcommand.py
7, P r o t o t y p e: MACRO s e q
\neucommand{\seq}{7.
y. P u t y o u r c o d e h e r e.
>
As we see, we just type the word MACRO and then the name of the new com­
mand. The program responds by generating a "skeleton” command definition. This definition has to be copied to a file. Then, we must fill in the code that actually implements our command. Let us now see how we can define a command with one parameter:
7, Prototype: MACRO seq #1 \ne«comraand{\seq> [1] {7.
7. Put your code here.
>
Suppose that we want to create a command with an optional argument surrounded by parentheses:
7. Prototype: MACRO seq 0PT(#l={x>) #2 \roakeatletter \def\seq{7,
20 6 -φ- 6 M o r e o n t h e C o r e
\@ifnextchar({\seq@i)"C\seq@i (x)}%)
}
\def\seq@i(#l)#2{%
% Put your code here.
}
\makeatother
Here, we use the keyword OPT to denote an optional argument. The parentheses are used to denote the tokens that should surround the optional argument. The expression #l={x> is used to specify the default value of the first argument, which is optional. Note that the code above uses the "unknown" command \def. This command is used to create commands with TgX, and its functionality will not concern us here. Now, it is very easy to make the second argument an optional argument:
7. Prototype: MACRO seq #1 OPT[#2={x>]
Vnakeatletter \newcommand{\seq>[1]{%
\@ifnextchar [{\seq@i#l}{\seq@i#l [x] J-%]
}
\def\seq@i#l[#2]
°/„ Put your code here.
}
\raakeatother
As we see, the optional argument must be surrounded by square brackets. If we want a command with two optional arguments, the following prototype will do the job:
1 Prototype: MACRO seq #1 OPT[#2={n}] 0PT[#3={1>]
\makeatletter \newcommand{\seq]- [1]
\@ifnextchar [{\seq@i#l]-{\seq®i#l [n] }%]
}
\def\seq@i#l[#2] {%
\@ifnextchar[{\seq@ii#l[#2]}{\seq@ii#l[#2] [1]}%]
>--------------------------------------------------------------------------------------------------------------------------------------------
\def\seq@ii#l[#2][#3]
7, Put your code here.
}
Another interesting example is the way one can create a command that has two required arguments surrounded by parentheses and separated by acomma:
% Prototype: MACRO seq {0#1 ,#2{)]- \def\seq(#l,#2){%
% Put your code here.
}
Note that here we have to put the surrounding parentheses in curly brackets.
6.1 2 N ew E n v i r o n m e n t s <>· 2 0 7
6.1 2 N e w E n v i r o n m e n t s
Up to now, we have presented many environments, so we hope that the reader will have an understanding of how an environment operates. A new environment is introduced with the command \newenvireminent:
\newenvironment{Bar}[n]{.opening commandsy{closi ng commands}
Bar is the name of the environment. The opening commands and the c l os i ng commands are the code that will be executed before and after the processing of the body of the environment, respectively; n is the number of arguments. In other words, the definition above is equivalent to the following definitions:
\newcommand-[\Bar} [n] {openi ng commands } \newcommand-[\endBar}-Cc losing commands}
As is evident, a new environment can have at most nine arguments and one of them can be an optional argument. We will now give a few examples. Suppose that we want to define an environment that will produce a quote in boldface. Here is a solution to this problem:
\newenvironment-[bf quote}{%
\b egin{quot e}\bf series}{%
\end{quote}}
Here is an example:
Text before
A short quote.
Text before \begin{bfquote} A s h o r t q u o t e. \end{bfquote}
Text after.
Text a f t e r.
A more interesting example is the creation of the following environment:
Text before
Text before
Quotation 1 (
Hamlet
) To be,
or not to be: that is the ques­
tion
Text after.
\begin{cquote}{Hamlet}{2pt} To be, or not t o be: t h a t i s t h e q u e s t io n \end{cquote}
Text a f t e r.
The environment above has two arguments: the first is the name of the person to whom the quotation is attributed, and the second is the width of the horizontal rule. Moreover, it is evident that the quotes are numbered, so in order to create this new environment, we definitely need a new counter. However, it is important to stress that the arguments of an environment are not visible to the c l os i ng commands. This means that we must
2 0 8 -φ- 6 M o r e o n t h e C o r e
store the second argument to a (global) length variable in order to make it visible to the c l os i ng commands. Here is the complete definition of the new environment above:
\newcounter{qcounter}- \newlength{\qrulewidth}- \newenvironment{cquote}- [2] {%
\s e t l e n g t h {\q r u l e w i d t h } {#2}
\b e g i n { q u o t e }\r u l e {\l i n e w i d t h } {#2}
\refstepcounter{qcounter}%
\t e x t b f -[Quotation \theqcounter)- (\t e x t i t {#l » H %
\n e w l i n e\r u l e {\l i n e w i d t h 3"C\qrulewidth}
\end{quote}}
The command \newline is actually a “verbose" form of the \\, but it does not accept the optional arguments that the latter command does.
>- Exercise 6.14 Define a framed quote environment. □
If we want to redefine an existing environment, we have to use the command \renewenvironment. This command can have exactly the same arguments that the command \newenvironment can have.
6.1 3 N e w L i s t s
Most of the environments presented in Chapter 4 are defined in terms of two generic list-creation environments: \l i s t and \t r i v l i s t. The second environment is actually
a special case of the first one, so we will briefly present its functionality at the end of this section. The first environment has two arguments:
\b e g i n { l i s t } { l abel }~{commands }
...body...
\en d { l i s t }
label specifies item labeling and commands contains commands for changing, among other things, the horizontal and vertical spacing parameters. Each item of the environ­
ment starts with the command \i t em[ i t eml abel ~\. This command produces an item labeled by i t e ml a b e l. If the argument of \item is missing, the l abel is used as the item label. The label is formed by putting the output of the command \makel a b e l{ - i - t eml abel } in a box whose width is either its natural width or equal to \labelwidth, whichever is longer. Moreover, if the width of the label is less than \labelwidth, the label is put flush right separated by \l a b e l s e p from the item's text (see Figure 6.13 on page 210 for a complete list of all length variables associated with lists). If we define a customizes
6.13 N e w L ists < > - 2 0 9
God morgon
i n S we d i s h.
Al oha kakahi aka
i n Ha wa i i a n.
Κ α λ η μ έ ρ α
i n Gre e k.
\m a k e l a b e l i n t he commands part to change the default behavior of the environment. The following code produces an environment like the description environment, which, however, frames the item labels:
\newcommand-f\f l a b e l } [ 1] {\h f i l\f b o x {\t e x t b f {#1}}} \newenvironment{fdescription}{\begin{list}{}{% \renewcommand-C\makelabelM\f l a b e l } } } {\e n d { l i s t } }
Note that we put a \h f i l before the actual label to flush right the label. The following is an example of this new environment:
\b e g i n { f d e s c r i p t i o n }
\item[God morgon] i n Swedish.
\i t e m [Aloha kakahiaka] i n Hawaiian.
\ϊΐβιη[Καλημέρα] i n Greek.
\e n d { f d e s c r i p t i o n }
If we want to create numbered lists, we have to include the command
\u s e c o u n t e r { c n t }
in the commands; cnt is a new counter and is stepped every time a \i t e m command is encountered. In order to show the use of this command, we will design an enumeration environment that will display the item labels in a \f box:
\newcounter{oenumi}
\renewcommand-C\theoenumi}-C\roman{oenumi}} \newcommand{\labeloenumi}-[\f box{\theoenumi}} \newenvironment{oenum}-[\begin-[list}-C\labeloenumi}-C%
\usecounter-Coenumi}% \renewcommand-C\makelabel} [1]
{\h f i l ##l } } } } {\e n d { l is t} }
Because the redefinition of \makelabel occurs inside the first argument of the newenvironment environment, we refer to the argument of the command with ##1. This is necessary to distinguish between arguments in a definition occurring inside another definition. Let us see what we have done:
[T] one [u~| two
\begin{oenum} \i t e m one \i t e m two
iii I three
\i t e m t h r e e \end{oenum}
If you have come to the conclusion that the standard enumerate environment is defined in a similar way, then you are absolutely right. However, the definition of enumerate is far more tricky compared to the definition above. To continue with the definition
2 1 0 Φ 6 Mo re o n th e C o re
above, one problem is that the text that follows each item label is not justified. In order to fix this problem, we need to introduce a new length variable, which will be used to measure the width of the box containing the label. Moreover, we must make the \labelwidth wide enough to hold any (reasonably) wide label. Now, we compare the two length variables and create boxes whose width depends on the comparison above.
Label
1
h—5—H
— -------
8
first object first paragraph — τ------------------------------
7
♦___________________
Label
first object second paragraph
— T------------------------------------------------
1______________________
second object first paragraph
1. \topsep + \p a r s e p [+\partosep] 3. \i t e x i n d e n t 5. \labclwidth 7. \paraep
9, X i t e T.s e p + Y p a r s e p
2. \l a b e l R e p 4. \rightmargin 6. \l c f t n a r g m 8. \l i κ ΐ ρ a r i n d e n t
Figure 6.13: Length variables associated with list structures.
>- Exercise 6.15 After you read Section 7.2, implement the description above. □
6.14 F i l e I n p u t 2 1 1
Δ
Envi ronment s such as quote ar e act ual l y l i s t s wi t h a si ngl e unl abel ed i tem. A probl em t hat must be t ackled is t he case wher e t he fi rst charact er of t he envi r on­
ment is a l eft squar e bracket. If such a charact er occurs, T^( wi l l compl ai n of a runaway argument. The sol ut i on to t hi s probl em is to put the command \r e l a x i mmedi at el y aft er t he \i t era command. The fol l owi ng is t he st andar d defi ni t i on of t he quote envi ronment:
\newenvi ronment {quote} {\b e g i n { l i s t }{}{*/ \s e t l e ngt h{\r i ght mar gi n} {\l e f t mar gi n} }'/s \i t e r o\r e l a x }
{\e n d l i s t }
For the purpos es of t hi s book, the t r i v l i s t envi ronment may be cons i dered to be def i ned as f ol l ows:
\n e w e n v i r o n m e n t { t r i v l i s t } {\b e g i n { l i s t } { } { 7.
\s e t l e n g t h {\l a b e l w i d t h } {0p t } 7,
\s e t l e n g t h {\l e f t m a r g i n } { 0p t } 7,
\s e t l en g t h {\i t e m i n d e n t } { O p t } } } {\e n d { l i s t } }
When using this environment, one must always specify a label, even the empty label (i.e., \item[]),
6.1 4 F i l e I n p u t
When preparing a long document (e.g., a book), it is a good practice to keep individual units in separate files. For example, if you prepare a book, you can keep each chapter in a separate file and have a master file that will be used to include all chapters. In order to facilitate this process, provides the command \in cl u de and its friends.
The command \include has one argument—a filename—and forces L ATgX to process this file as if it was part of the current file. Suppose that we are preparing a long report that consists of four chapters. Then, the master file will look like this:
\documentclass[a4paper,12pt ]{report }
..................... preamble commands ................
\begin{document}
\ i n e l u d e { c h a p 1 }
\ i n e l u d e { c h a p 2 }
\ i n e l u d e { c h a p 3 }
\include{chap4}
\end{document}
2 1 2 φ 6 M o re o n th e C o re
Note that MpX assumes that the files have the .t e x filename extension. If we want to \i n c l u d e only some files, we can put the command \i n c l u d e o n l y { F i,.. . ,Fn} in the preamble of the master file to include only the files specified in the argument list of the command. For example, if we process the following file, the output will consist of Chapters 1 and 4 only:
\document class[a4paper,12pt]{report}
\i n c l u d e o n l y { c h a p l,chap4}
\begin{document}
\inc l u de{c h ap l }
\i n c l u d e{ c hap2}
\include{chap3>
\include{chap4>
\end{document}
The command \i n p u t {/i l e } is also used to include the f i l e in the master file. More­
over, this command is useful when one wants to include a file that does not have the . t e x filename extension. For example, the command
\i n p u t { c h a p 5.l t x }
will include the file chap5. l t x.
Δ
Ιη many instances, people create large documents that contain lots of figures that are stored in separate files. In such cases, it is useful to be able to store all files associated with a particular document unit in a directory. In order to do this we can > use the command \graphicspath (provided by the graphics package) to specify the path to individual graphics files. The command has as arguments either full or relative paths, which must be surrounded by curly brackets:
\graphicspath{/path/to/files}{pics/files}
Now, we can use any file inclusion command to input both document and graphics fi l es:
\i n c l u d e {/p a t h/t o/f i les/rayf i l e.tex}
As is evident, for ordinary files we must give the full path.
If we want to see which files 1?TeX inputs while processing our document, we simply put the command \l i s t f i l e s in the preamble of our document. On the other hand, if we want to stop I^TgX from reading all of the auxiliary files, the files related to indices, bibliographies, and so on, we simply put the command \nof i l e s in our document's preamble*
6.1 5 Ι^ Τ β Χ A l'i n t e r a c t i v e <>- 2 1 3
6.1 5 B T g X a l'i n t e r a c t i v e
TgX is not only an excellent typesetting engine but also a real programming language. Without any doubt, it is a programming language that lacks certain features found in almost all programming languages (e.g., real number manipulation, repetitive con­
structs, arrays, etc.).2 On the other hand, it provides facilities for data input and output. This is also true when it comes to terminal input and output, so we can create ΤβΚ/ΜβΚ “programs" that can interact with their users. In the next chapter, we will see how to introduce conditional branches and looping using the ifthen package and so be able to create real I^T]hX programs.
The command \typeout prints its argument to the computer console. For example, consider the following LJTeX file:
\do cument c l as s {ar t i c le }
\begin{document}
Ytypeout{*****************}
\t y p e o u t {Hello from LaTeX!}
\·type out {***************** }
\end{document}
Here is what we get if we feed this file to Ι5ΓβΧ:
$ latex test
This is TeX, Version 3.14159 (Web2C 7.3.3.1)
(./te st.te x LaTeX2e <2000/06/01>
Babel <v3.7h> and hyphenation patterns for american, english, greek, loaded.
(/usr/local/teTeX/share/texmf/tex/latex/base/article.els Document Class: article 2000/05/19 vl.4b Standard LaTeX document class
(/usr/local/teTeX/share/texmf/tex/latex/base/sizelO.clo))
(./t e s t.aux)
Hello from LaTeX!
(./test.aux) )
Mo pages of output.
Transcript written on test.log.
Skeptical readers may think that this ability is actually useless unless, of course, we can provide input to our "programs." The command \typein can be used to input data from our computer console. The command has two arguments: a required text string, which
2. T^X is a Turing complete programming langauge. so one can essentially implement any algorithm in TgX.
2 1 4 ^ 6 M o r e o n t h e C o r e
is used to prompt the user to enter data, and an optional command name. If we specify the optional argument, I^TgX stores what the user types to this command; otherwise, it includes the text into the file verbatim. Let us see a trivial, although complete, example: \do cument c l a s s { a r t i cle}
\begin{document}
\t y p e i n [\name]{ e n t e r your name...}
\t e x t b f {\name}
\end{document}
If we feed the file above to I^T^X, we get:
$ l a t e x example
This i s TeX, Version 3.14159 (Web2C 7.3.3.1 )
(./t t.t e x
LaTeX2e <2000/06/01>
Babel <v3.7h> and hyphenation p a t t e r n s f o r american, e n g l i s h, greek, loaded.
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s Document Cl ass: a r t i c l e 2000/05/19 v l.4 b Standard LaTeX document c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e 10.c l o ) )
(./t t.aux) e n t e r your name...
\name=Apostolos Syropoulos [1] (./example.aux) )
Output w r i t t e n on example.dvi (1 page, 284 b y t e s ).
Now, if we view the resulting file, it will contain the name of the first author in bold­
face. Here is another example that is useful if we want to prepare many identical letters interactively:
\d o c u m e n t c l a s s { l e t t e r }
\add r e ss{ Sp a r ta n \TeX\ Users GroupW 1, C e n tr a l P l a z a.\\
SPARTA}
\s i g n a t u r e { D r. E u c l i d\\P r e s i d e n t of STUG}
\begin{document}
\t y p e i n [\Pname]{ e n t e r p a r t i c i p a n t's name}
\t y p e i n [\P a d d r e s s ] { e n t e r p a r t i c i p a n t ’ s address}
\t y p e i n [\P tow n ] {ent e r p a r t i c i p a n t ’ s town}
\b e g i n { l e t t e r } {\P n a m e\\ \P a d d r e s s\\ \Ptown}
\opening{Dear \Pname}
This i s t o acknowledge t h e acceptance of your paper.
\closing{Yours t r u l y }
\e n d { l e t t e r }
\end{do cument}
M i s c e l l a n e o u s Pa c k a g e s
In this chapter, we present some packages that do not comfortably fit anywhere else.
7.1 T h e c a l c P a c k a g e
The calc package by Kresten Krab Thorup, Frank Jensen, and Chris Rowley re­
implements t h e Ι^Τ^Χcommands \s e t c o u n t e r, \a d d t o counter, \s e t l e n g t h, and \add - t o l e n g t h in such a way that these commands accept an infix mathematical notation instead of a number. T£X provides commands such as \advance and \m u l t i p l y in order to do arithmetic, but the calc package provides additional functionality. One can use standard notation for the four arithmetic operations with the symbols +, * and /, so if
you write 44 / 10, you will get 4. Note that the result is 4 and not 4.4, as the division performed is integer division. Arithmetic with dimensions is also allowed, so you can say, for example, 7cm+2in, but the arithmetic must be well-defined (thus 7cm+2 makes no sense). The \r e a l command allows the use of real numbers in calculations. Thus, if we want to multiply 99 by 2.1, we will use 99 * \r e a l { 2.1 >.
Let us see an example. Suppose that we want to print the time and date on the documents we create in order to keep track of the newest versions. The counter \time holds the number of minutes since last midnight. Thus, we will have to define two counters, the hour counter and the minutes counter. The hour counter will be set to \time / 60 and the minutes counter to \time - \value{hours} * 60, suggesting the following code:
\newcounter{hours} \newcounter{minutes} \newcommand{\printtime}{7c
\setcounter{hours}{\time / 60}%
\setcounter{minutes}{\ti me - \value{hours} * 60}*/,
\t h e h o u r s:\t h e m i n u t e s\ \today}
Now, the command \printtime will give: "23:29 March 6, 2001." The package de­
fines additional commands for specifying a length using some text. The commands
2 ΐ 6 -Φ 7 M i s c e l l a n e o u s P a c k a g e s
\widthof {some t ext }·, \he ight of {some t e x t }, and \depthof {some t e x t } can be used to store the width, height, and depth, respectively, of some t e x t to a length variable. Now one can use commands such as
\s e t l e n g t h {\p a r s k i p } - {\h e i g h t o f ib)- * \r e a l { l. 8}-}
7.2 T h e i f t h e n P a c k a g e
The ifthen package by David Carlisle, based on earlier work of Leslie Lamport, provides the command \i f thenelse with the following syntax:
\ifthenelse{conii'it'icm}"C ‘ ‘t hen 3 3 commands}{ ‘ ‘e l s e 3 3 commands}
The c ommand comput e s t he val ue of t he condi t i on. If t he val ue i s t r u e, i t execut es t he ‘ ‘t h e n 3 3 commands; otherwise, the value is f a l s e and it executes the ‘ ‘e l s e 3 3 commands. The condition is either checked on the spot (it could say 1>0 or it can use >, <, or = for the obvious comparisons) or it can be the value set for a Boolean variable. For this task, the package provides the commands \newboolean and \s e t b o o l e a n. For example, \newboolean{BoolVar> defines a new Boolean variable, and the commands \setboolean{BoolVar}--Ctrue)- and \setboolean-[BoolVarMf alse}- set the variable to t r u e and f a l s e, respectively. The truth value of this variable is read by \i f t h e n e l s e with the help of the \boolean command. Thus, the commands
\newboolean{Boolvar}
\setboolean{BoolVar}{true}
\i f thenelse{\boolean{BoolVar»{l>{2>
will produce the number 1.
Let us continue with the example of the previous section and improve it to give the time in the am-pm format.
\newcommand{\printtime
\s e t c o u n t e r { h o u r s } {\t i m e / 60}-%
\setcounter{minutes}-{\time - \value{hours} * 60}%
\i f t h e n e l s e {\v a l u e { h o u r s } > 12}%
{\setcounter-Chours}-C\value-[hours}- - 12}%
\t h e h o u r s:\t h e m i n u t e s\,p m\ \t o d a y } %
{\t h e h o u r s:\t h e m i n u t e s\,a m\ \t o d a y }
Now, t he \p r i n t t i m e command wi l l g i v e “ 11:29 pm March 6, 2001." Two ot her c om­
mands that he l p us t o check t he condi t i on are \i s odd{m}- ( where m i s an i nt eger) and \l e n g t h t e s t. The fi rst checks i f t he number m i s odd, and t he s econd command i s us e d for l engt h compari s ons. The code
\i f t h e n e l s e {\l e n g t h t e s t - [2cin > 2in}-}-[ciii}{in3-
7-3 S y n t a x C h e c k i n g <>-217
will print the unit i n since 2cm > 2i n is false. Another command is \equal{wl>{w2>, which checks whether the character string wl is the same as the character string w2. For example,
\i f thenelse{\equal{TeX}-[TEX}\Kyes3"Cno)-
will print the word no since TeX and TEX are not the same. If the arguments of the \e q u a l command are themselves commands, then these are expanded before they are compared. Thus, the commands
\ne w command-C\one one }
\newcommand-C\OneMone}
\ifthenelse{\equal{\one>{\One}}{Yes}{No}
will produce Yes since although \one and \One are not the same, after they are expanded they are both equal to one. We close this section by adding that the package provides the command \whiledo that gives the possibility of repeating commands until a condition fails. The syntax is \whiledo{condit ion>{Commands>. Here is an example that produces the phrase "I must not cheat" 100 times:
\newcounter-[Pcounter}
\newcommand-C\mustnotMl must not c h e a t.\ } \newcommand-C\punishment} [1]
\setcounter{Pcounter}{#l)-%
\whiledo{\value{Pcounter)->0}-C%
\mustnot%
\addtocounter{Pcounter}{-l}%
»
\punishment-Cl003-
Finally, one more command, the \ifundefined\command command, is available, which checks if the \command is already defined or not.
7.3
There are a few ways to check for errors in a LTfiX
file without really running the file
through the standard I^TeX procedure. One of them is provided by the syntonly package by Frank Mittelbach and Reiner Schopf. The package implements the command \s y n -
of allowing ETeX to check our code for errors but produces no output. Consequently, since no DVI file is produced, the parsing of the code is much faster.
Another way for syntax-only checking is provided by the L a C h e c k program by Kresten Krab Thorup with modifications by Per Abrahamsen. The program checks for common errors in a file and is very helpful for beginners. It checks for mismatched
2 ΐ 8 -Φ 7 M i s c e l l a n e o u s P a c k a g e s
groups (braces), environments and math mode delimiters, bad spacing such as \u after an abbreviation, or a missing \@ before the period when a sentence ends with a capital letter. It also checks for bad choices of dots, wrong or absent italic corrections, badly placed punctuation, and poor use of quotation marks. Let us see how La CHECKperforms when it is supplied with an erroneous LT^X file. Suppose that we feed La CHECKwith a file that contains the following:
\documentc l a s s [ a 4 p a p e r ] { a r t i c l e \begin{documnent}
This i s a simple \LoTeX\ f i l e.
\emd-[do cument}
Then, if we run La C h e c k o u this file, we will get the following:
$ lacheck t e s t
"t e s t.t e x",
l i n e
5:
< -
unmatched
"end of f i l e t e s t.t e x"
"t e s t.t e x",
l i n e
2:
- >
unmatched
"\begin{documnent}"
"t e s t.t e x",
l i n e
5:
< -
unmatched
"end of f i l e t e s t.t e x"
"t e s t.t e x",
l i n e
1:
- >
unmatched
11 ^ II
The last message informs us that there is an unmatched left curly bracket. Indeed, we have to place a right curly bracket after the keyword a r t i c l e. The second line informs us that there is an unmatched command. Indeed, if we replace the last line of the input file with
\end{documnent} and rerun La C h e c k o u the resulting file, we will get the following:
$ lacheck t e s t
"t e s t.t e x", l ine 4: <- unmatched "\e nd{documnet}"
"t e s t.t e x", l i n e 2: -> unmatched "\begin-Cdocumnent}"
"t e s t.t e x", l i n e 5: <- unmatched "end of f i l e t e s t.t e x"
"t e s t.t e x", l i n e 1: -> unmatched
As is obvious now, La CHECKhas detected that our file does not contain the commands that begin and end a "document." The reader may wonder why La C h e c k has failed to recognize that the environment document has not been defined. In order to be able to do this, we must have a system that can process both Ι^ΤβΚ and TgX commands and moreover has the capability to expand macros. Naturally, such a system exists, and it is T]hX itself... and this is the reason why the system is not able to check whether the command \LoTeX has been defined or not.
7.4 T y p e s e t t i n g C D C o v e r s
The package cd-cover by Christian Holm provides an easy interface to typeset compact disc covers, especially now that CD burners are widely available.
7.4 Ty pe s e tt i n g C D C o v ers <>· 219
The package provides three environments rightpag eb oo k l et, l e f t p a g e b o o k l e t, and backpage. Moreover, it provides the commands \b o o k l e t s h e e t and \backsheet, which give easy access to the environments above. One difficulty for creating CD covers is that the pages should be output in such a way that, when the booklet is folded, the pages will have the correct order. The DVI file should be processed in landscape mode; that is by using the command
dvips - t landscape f i l e.d v i
The code that follows provides an example. Here, we use the landscape option of the \documentclass command that swaps the values of the predefined ΐ^ΤβΧ length variables \textwidth and \t e x t h e i g h t. The output is shown in Figure 7.1 on page 221 scaled to fit in one page.
\documentclass [landscape, l l p t ] { a r t i c l e }- \usepackage{cd-cover}
\renewcommand{\labelenunii}-{\oldstylenums{\theenuiiii}- · }
\begin{document}- \b o o k l e t s h e e t {%
{\Large \s c Singer ----- T i t l e (A)}\\
\b eg i n { c en t er }
\begin{enumerate}-
\s e t l e n g t h {\i t e m s e p } { - 4 p t >
\i t e m Song 1 (Creator) (B) \i t e m Song 2 (Creator)
\i t e m Song 3 ( C r e a t o r )\i t em Song 4 (Creator)
\i t e m Song 5 (Creator) \i t e m Song 6 (Creator)
\i t e m Song 7 (Creator) \i t e m Song 8 (Creator)
\i t e m Song 9 (Creator)
\end{enumerate)-
\end{center}
K
\b eg i n { c en t er }
{\huge\sc Singer ( C ) }\\[ 1 6 p t ]
{\huge\sc T i t l e (C)}
\end{center}>
\b a c k s h e e t {\s c Singer ---- T i t l e (D)}{
{\Large \s c Singer ---- T i t l e (E)}
\b eg i n { c en t er }
\begin{enumerate}·
2 2 0 -Φ 7 M i s c e l l a n e o u s P a c k a g e s
\setlength{\itemsep)"C-4pt)-
\i t e m
Song
1
(Creator) (F)
\i t e m
Song
2
(Creator)
\i t e m
Song
3
(Creator)
\i t e m
Song
4
(Creator)
\i t e m
Song
5
(Creator)
\i t e m
Song
6
(Creator)
\i t e m
Song
7
(Creator)
\i t e m
Song
8
(Creator)
\i t e m
Song
9
(Creator)
\end{enumerate)-
\end{center>
>
\end{do cument}
7.5 D r o p C a p i t a l s
L
e t t r i n e s are “dropped capitals"such as the letter L that started this paragraph, and we see them very often in magazines and books. It is very easy to pro­
duce them using the package lettrine by Daniel Flipo. The package provides the command \l e t t r i n e, which is used with the following syntax
\l e t t r i n e [ opt i ons ] { l et t er}~{paragraph}·
Here, l e t t e r is a letter or a word that will be “dropped" and paragraph the text that starts a paragraph. Several parameters are provided for customizing the layout of the dropped capital. These are entered as optional arguments in a comma-separated sequence. The parameters are:
l i n e s = i n t e g e r Sets how many lines will be occupied by the dropped capital. The default is 2.
lhang= deci mal The deci mal is any number between zero and one and controls how much the dropped capital will hang out in the margin. The default is zero, and if it is set to one, the dropped capital will be entirely in the margin, l o v e r s i z e=decimal The deci mal is used to enlarge the capital's height and can vary from — 1 to 1. The default is zero and if, for example, it is set to 0.1, the height of the dropped capital will be enlarged by 10%, rising above the top of the paragraph, l r a i s e=decimal This controls the vertical position of the dropped capital. It moves it up or down without changing its height. It is useful for letters such as J or Q that have a positive depth. The default value is zero,
f i ndent = I engt h This parameter controls the horizontal gap between the dropped capital and the indented block of text. The default value is 0 pt. nindent= l engt h This parameter is used to horizontally shift all of the indented lines after the first one by l engt h. slope= l engt h This is used for letters such as A or V whose geometry requires that the amount of indentation of each of the lines after the second one changes progres- sively. The default value is zero, and the effect works after the third line.
7-5 D r o p C a p i t a l s <>- 2 2 1
Figure 7.1: cd-cover output
ante=ieasi This is used for entering text to be set before the dropped capital. It is mainly used with guillemots, quotation marks, and so forth, that start a paragraph.
Figure 7.2 shows a usage example of the package. The default values of the above options can easily be changed by putting the following commands in the preamble (here we give them with their default values):
\setcounter{DefaultLines}{2}
\renewcommand-C\Def aultLoversize}{0}
\r enewcommand-C\Def a u l t L r a i s eMO}
2 2 2 7 M i s c e l l a n e o u s P a c k a g e s
π α τ ι α» was a mat hemat i ci an and a phi l osopher, daught er of t he mat h­
emat i ci an Θεων. She st udi ed i n t he Academy of At hens. Then she r et ur ned to Al exandri a, Egypt, wher e she was t each­
i ng phi l osophy and mat hemat i cs. She was ex­
t remel y beaut i ful and t he most i mpor t ant sci ­
ent i st in her era. She was br ut al l y mur der ed in 415 ah by a Christian mob.
\l e t t r i n e [lines=4,loversize=% 0.1,slope=-6pt,lhang=.4,ante=% \textgreek{ (( >, f indent =4pt ] */, {\textgreek{U}MYtextgreek*/4 {pa t i a) )» was a mathematician and a philosopher, daughter of the...
...by a Christian mob.
Figure 7.2: Using the lettrine package.
\renewcommand{\DefaultLhang>{0>
\setlength{DefaultFindent}{Opt}
a The package provides additional functionality. It is possible to use a PostScript 1 file in the position of a dropped capital. Note that this paragraph is not a regu- / » \ lar dangerous paragraph. We are using the warning symbol that designates « * ■ dangerous paragraphs and taking advantage of the extra functionality of
the package lettrine to give slope to the text. The PostScript file should be named with one letter (in our case, the dangerous symbol is called d. ps). The package provides the commands \LettrineFont and \LettrineFontEPS, which control whether we use text or a PostScript file (that should be loaded) as a dropped capital instead. To load a PostScript file in the position of the dropped capital, we must redefine \LettrineFont to be \LettrineFontEPS. The code that follows shows how this paragraph started.
\renewcommand{\LettrineFont>{\LettrineFontEPS>
\l e t t r i n e [ l i n e s = 4,s l o p e =.85em,findent= - 1.3em,nindent=lem]{d}{}The
package provides additional f u n c t i o n a l i t y...
7.6 P r e p a r i n g a C u r r i c u l u m V i t a e
A curriculum vitae is a very personal issue. Consequently, some may argue that it does not make sense to give a recipe. However, it is also true that style customization in L?TeX can be done only by a minority of its users. Tine great majority would benefit from such a recipe in the sense that they will at least have a starting point.
The package currvita by Axel Reichert provides a nice and easy interface for creating curriculum vitae. There are two package options: LabelsAligned and TextAligned. The default is TextAligned and uses space generously. If a more compact form is preferred, then we have to use the LabelsAligned option. The package provides two environments: cv and c v l i s t. The whole curriculum vitae must be in the body of the cv environment:
7-6 P r e p a r i n g a C u r r i c u l u m V i t a e <>- 223
Xbegin-CcvMCK Headi ng} CV t e x t \end-Ccv)-
The c v l i s t is used to create the curriculum vitae's items; for example,
\begin{cvlist3~CPersonal Information)·
\item Steve WorkerW
Sparta \item ...
\end{cvlist}-
On page 224, we show the curriculum vitae of a hypothetical person called Steve Worker.
>· Exercise 7.1 Write the code for your curriculum vitae based on the one given in figure 7.3. □
Other options of the package are
ManyBibs This is for documents with multiple bibliographies using multibbl (see Sec­
tion 8.2.4). It is particularly useful for multilingual documents.
NoDate This suppresses the date printed at the end of the document, openbib This is for cases where you like the “open" format of bibliographies.
The package also provides the command \c v p l a c e { l ocat i on)· for printing the l ocat i on where the CV was written together with the date at the end of it. More­
over, the command \date{daie)- can be used to override the default date printed at the end of the CV with the \today command.
One can customize several variables of the package. The command \cvheading- f ont controls the font to be used for the heading of the CV. The default is to use \Large and \b f s e r i e s and if we want to change this, we must redefine it. For instance, the redefinition
\renewcommand-C\cvheadingf ont}{\Large\scshape}-
will change to \Large small caps. Similarly, we may change the default values of the following commands:
\c v l i s t h e a d i n g f ont This controls the font used for the headings of the lists. \c v l a b e l f ont This controls the font of the lists' items.
\cvlabelwidth This is a length variable and controls the label's width in the c v l i s t
environments.
\c v l a b e l s k i p This is another length variable that controls the vertical space between the first c v l i s t item and the c v l i s t label.
\cv l a b e l sep A length variable that controls the horizontal space between the items' labels and the items.
\cvbibname This controls the bibliography label (whose default is “Publications") and if we want to change the label, we simply redefine it. For example,
2 2 4 ^ 7 M i s c e l l a n e o u s P a c k a g e s
\renewcommand-C\cvbibnaime3-{List of Papers}-.
C u r r i c u l u m v i t a e o f S t e v e W o r k e r Personal Information
Steve Worker University of Sparta Department of Fine Arts Sparta
Email: sworkerQfn. s p a r t a. edu
Bom in Thebes
B.Sc. in Mathematics from University of Athens.
Ph.D. in Mathematics from the University of Pella. Ti­
tle: Symmet ri zat i ons and Convolut i ons of Convex Bod­
ies. Thesis advisor: Euclid.
Research Interests
Geometry of Convex Bodies, Functional Analysis, Ge- ometry of numbers:
Publications List
1. On a Conjecture by Ari st archus Annals of the Athe- nean Mathematical Society 60:187-206, 306.
2. Is Hi ppasus’s Theorem Correct? (to appear).
Studies
June, 300 September, 305
January 4. 310
Figure 7.3: An example of the currvita package.
7-7 M u l t i c o l u m n Ty pe s e tt i n g <>· 2 2 5
7.7 M u l t i c o l u m n T y p e s e t t i n g
The multi col package by Frank Mittelbach provides the multi c o l s environ­
ment, which can be used
to typeset text in many columns (up to ten). The en­
vironment has a required argument, which is the number of columns. If we want to include some long single-column text, we can do this by specifying the text in square brackets af­
ter the number of columns. Also, we can specify that
the space the long text should occupy:
\begin{multicols}-{33- [\section{People}-] [5cm]
The space between columns is controlled by the length variable \columnsep. Moreover, we can add a vertical line that will sep­
arate columns by setting the length variable \c o l - umnseprule. In the body of the mult i c o l s envi­
ronment, all columns are
balanced. However, the environment multicols* disables this feature. The counters unbalance and collectmore can be used to fine-tune the balancing algorithm. The first one should be used to make all but the rightmost column longer by the value of the counter. If set, the value of the second counter is used by the typesetting engine to find proper page breaks.
7.8 H y p h e n a t a b l e L e t t e r S p a c i n g
Emphasizing text by spacing it out is not considered a good typographic practice by many professionals. However, there are cases (other than emphasizing) where one would want to use this technique. For example, a little letter spacing will increase the readability of small caps or huge titles (e.g., in posters). For small caps, this may not be necessary, as a well-thought out font (such as the default fonts by Knuth) contains glyphs that have some extra horizontal space in both sides of the character. For most fonts, however, this is not the case. Probably, the best way to space out text is provided by the soul package by Melchior Franz. The package can also be used to underline text. The package name derives from the names of the commands \s o (space out) and \ul(underline) that it provides. One of the big advantages of the package is that it does not inhibit hyphenation. Table 7.1 shows a summary of the available commands and their result.
The \s o command is the basic command for letter spacing. It uses a certain amount of i n t e r - l e t t e r sp ace between every two characters, i nner space between the words, and out er space before and after the spaced-out text. You can use the command
spacing as follows:
\s o d e f\s p a c e i t { f o n t } { i n t e r - l e t t e r space} { i nner s pac e } { out e r space}
Here, \s p a c e i t is a new letterspacing command. All of the arguments above are mandatory. If the new command refers to the default fonts, then the first argument can
2 2 6 -Φ 7 M i s c e l l a n e o u s P a c k a g e s
Table 7.i: soul package command summary.
\so{spaced{\hyphen}out t e x t } \caps-[CAPITALS, Small C a p it a l s } \u l { u n d e r l i n e d t e x t }
s p a c e d - o u t t e x t CAPITALS, Small Capitals underlined text
\s t { s t r i k e out t e x t }
strike out text
\s o d e f \cs-[lem}{2em}-[3em}
\r e s e t s o \c a p s r e s e t \c a p s d e f {////}{lem}{2em}{3em}
\c a p s s a v e\c s
\s e t u l i l e x } { 2 e x }
\r e s e t u l
\s e t u l d e p t h { y }
define the new spacing command \c s
resets the \s o dimensions
clears the \ca p s dataset
defines the default \c a p s data entry
save \ca p s dataset under the name \c s
sets the \u l dimensions
resets the \u l dimensions
sets the underline depth 1 point
beneath the depth of y
be empty (i.e., {>). The lengths are actually glue (see page 21) and should be given in em units. Here is an example:
\s o d e f\s p a c e i t O { · 2em}{lem pluslem}-C2em plus.2em minus .3em}
By using the \sod ef command, it is possible to redefine the meaning of the \s o com­
mand instead of defining a new letter spacing command. To reset the \s o command to the default values, use \r e s e t s o.
A useful variation of the \s o command is the \caps command, which in addition to spacing out the text changes lowercase letters to small caps. This command can also be redefined with the \capsdef command. The syntax of this command is as follows:
\c a p s d e f\s pacei t { f ont y{ commandy { i n t e r - l e t t e r space}
{ i nner spacey- j out er space}
Here, t he f ont decl arat i on i s of t he f orm
encodi ng/f a mi l y/s e r i e s/s h a p e/s i z e
For exampl e, t he f ont decl arat i on T l/p p l/m/n/6 - 1 4 s houl d be us e d whe n we want to have the Pal at i no f ont f ami l y wi t h t he TI encodi ng, t he medi um seri es, normal shape, and al l s i z e s f rom 6 pt t o 14 pt. The command can be any font-switching command such as \scshape. The s i z e entry may contain a size range as in our example; if we omit the lower bound of the range, then it is assumed to be equal to zero; otherwise, if we omit the upper bound, it is assumed to be a very large number. The \capsdef command redefines \caps, and we can reset the default values with \capsreset. If we want
7-8 H y p h e n a t a b l e L e t t e r S p a c i n g -Φ 2 2 7
to save our custom values, we should use the \capssave command to create a new command that when invoked will set the values associated with it. For example,
\c a p s d e f {/cmr///}{\scshape}{10pt}{20pt}{30pt}
\capssave\widecaps
\r e s e t c a p s
\ca p sd e f {/cmr///}{\scshape}{ · l p t } {. 2 p t } {. 3pt} \capssave\narrowcaps
defines the two commands \widecaps and \narrowcaps with different spacing-out values.
There are cases when inside a spaced-out phrase there are some parts that should not be spaced out, such as the case of accented letters that would get decom­
posed. To prevent spacing out an accented letter, we enclose it in braces like this "\s o { t h {\} e } { V a } t r e }" in order to get "t h e a t r e." In addition to this, anything set in a box or in two pairs of braces ({{}}) will not be spaced out.
A few rules of thumb follow. Punctuation marks should be spaced out except the period (sometimes commas, too). Quotes and numbers are not spaced out. Conse­
quently, all of these should be put outside the \s o command or the i n t e r - l e t t e r space can be temporally canceled with the command \<. For instance, we can write "\so{2\<3 June {{2002}»" to get "23 J u n e 2002." The hyphen, the en dash, the em dash, and the slash should be entered with the commands \hyphen, \endash, \em-
dash and \s l a s h, respectively, instead of writing -, —,----, and /. An unbreakable
space should be followed by a space like this \so{Mrs. \~ UF}· The \\ command works as usual, but without additional arguments.
If the rules of thumb above are not observed, LTgX may complain that "Reconstruc­
tion failed."
We will now discuss how it is possible to typeset narrow columns using this package. In many newspapers, magazines, and so forth, when we need to typeset in a narrow column, we usually space out a few words to avoid overfull boxes and bad breaks. Typographically, this is not an acceptable practice, as it severely disturbs the page color. This fact has made the author of the package exclude commands that would provide this feature. The package documentation provides all of the necessary information for those users who are in absolute need of it. Figure 7.4 shows an example from the package's documentation. For multilingual documents, the only problem seems to be that accented letters should be put in braces. The reason is that multilingual LT^X documents use the inputenc package (see Chapter 10), which will decompose accented letters to a sequence of accents followed by the letter to be accented. Thus, in order to space out the word έρως, we have to type \Ξο{{>έ}ρως}. However, there are exceptions to this rule. One does not need these extra braces for simpler accents. For example, \εο{έρως} will work out fine. Note that if we use A with a real Unicode font, then this problem simply does not exist!
We conclude this section with a few words about underlining. The \u l command, which is used to produce underlined text, can be modified with the \s et u l command
2 2 8 -Φ 7 M i s c e l l a n e o u s P a c k a g e s
S o m e m a g a ­
zines and news­
p a p e r s p r e ­
f e r t h i s k i n d
of sp a ci n g b e ­
cause it reduces h y p h e n a t i o n a n d o v e r f u l l p r o b l e m s to a minimum.
Some magazines and newspapers prefer this kind of spacing because it reduces hyphen­
ation and over­
full problems to a minimum.
Figure 7.4: Typesetting narrow columns.
\Ξβΐπ1{ωη<2βΓΐϊηβ dept hy{.underl i ne t h i c k n e s s }
where both arguments are lengths or length variables. If we do not want to change one of the parameters, we simply pass an empty argument. Both lengths should be expressed in ex units; they can be restored to their default values with the \r e s e t - u l command. The \setul depth command sets the underline depth 1 pt beneath its argument's deepest depth. For example, the command \setuldepth{ag}- will set the underline depth 1 pt beneath the depth of the letter g. Finally, if we use underlining, it is better to use the package with the overlap option. This option extends the underline segment for each of the underlined letters by 0.5 pt, which helps get rid of little gaps in the underlining that may appear.
8 - - - - - - - - - - - - - - - - - - - - - - - - - - -
B i b l i o g r a p h y a n d I n d e x
The bibliography and, in particular, the index are two parts of a document that usually get neglected during the initial stages of the document creation process. This leads to problems later on, so it is wise to plan ahead, as these two parts are very important for a document to be considered complete and with easily accessible material.
8.1 P r e p a r i n g t h e B i b l i o g r a p h y
A bibliography is a list of writings used or considered by an author in preparing a particular work. Therefore, a typesetting system must provide the ability for users to refer to bibliographic items that will be typeset according to prespecified rules, usually at the end of a document For referencing a bibliographic item, I^TgX provides the command \c i t e. The syntax of this command is the same as that of the command \r e f. The argument of the command can be any letters, numbers, or symbols of the English language, so for referring to a book that is labeled as knuth: 1, we use the command \cite{knuth: 1>. Moreover, this command has an optional argument that is a piece of text that will be printed together with the text generated by the \c i t e command. But how do we label a book (or article) reference? There are two ways of completing this task. The simpler one is the following: 15ΓβΧ provides the environment thebibliography, which is a list environment. This list uses the \bibitem command for each bibliographic entry. Each \bibitem command has an argument that is a label used to denote a bibliographic entry. The same label is used by the \c i t e commands to refer to a particular item in the bibliography. This command also takes an optional argument that is used to set the way the reference appears in the text. Finally, the environment thebibliography has an argument that specifies the number of characters allowed in the referencing names. Here is a complete example:
\documentclass{article}
\begin{document)-
Donald Knuth has written several important books. In \c i t e { k n u t h:2} he
2 3 0 -φ- 8 B l B L I O G R A PHY A N D I N D E X
covers t o p i c s ranging from random number generators to f l o a t i n g point operations and other optimized arithmetic algorithms.
In \c i t e [Chapter~l]{knuth:1} he describes the game of the name.
\begin{thebibliography}{999}
\bibitem{knuth: 1} D. Knuth, \t e x t i t { T h e \TeX book}·.
\bibitem[Kn2]{knuth:2} D. Knuth, \t e x t i t { T h e Art of Computer Programming}·, v o l. 2, Seminumerical Algorithms.
\end{thebibliography>
\end{do cument}
Donald Knuth has written several important books. In [Kn2] he covers topics ranging from random number generators to float­
ing point operations and other optimized arithmetic algorithms. In [1, Chapter 1] he describes the game of the name.
R e f e r e n c e s
[1] D. Knuth, The Ttftbook.
[Kn2] D. Knuth, The Art of Computer Programming, vol. 2, Seminu­
merical Algorithms.
Figure 8.1: A first example with bibliography.
The formatted output is seen in Figure 8.1. We have asked from the environment thebibliography to allow a maximum of three characters for referencing (this is what 999 stands for; of course, it could be 637, having the same effect).
As we see, in this example, the references in the text appear with a number or a sequence of letters in brackets. It is customary though in areas such as literature or philosophy that references appear as superscripts:
... as Aristotle has explained in his work.21
If we want such a referencing mechanism, we have to redefine the \@cite command. Here is the standard definition:
\newcommand\@cite[2]{%
[{#l\ifthenelse{\boolean{@tempswa}>{, #2>{}>]}
As is evident, the whole body of the definition is enclosed in square brackets. Thus, the
change we want is achieved by writing the following code in the preamble of a I^TeX
file:
8.2 U s i n g Β ι β Τ ^ Χ 2 3 1
\renewcommand\@cite[2]{\t e x t s u p e r s c r i p t {#l \i f thenelse{\boolean{@tempswaJ-}"C, #2}0}-)-
>■ Exercise 8.1 If we put the code above in the preamble of a ET^X document, ET^X will complain as follows:
! LaTeX Error: Missing \begin-Cdocument)-.
Can you suggest a remedy to this problem? □
What if we have several references in the same place? It is typographically correct for these references to appear in one group of brackets with labels separated by commas. For example, [2, 5, 6] is to be preferred over [2], [5], [6] (it also conserves more space). Moreover, if we have consecutive numbers, it is better to use a range. Thus, [2-5] should be preferred over [2, 3,4, 5]. This mechanism is provided by the package cite by Donald Arseneau. The corresponding package for superscript referencing is the overcite package by the same author. With these packages, a reference to the bibliographic entries 2,3,4,5,7,9,6 (\c i t e { 2,3,4,5,7,9, 6>) will become [2-7,9] and 2~7,9, respectively. The cite package provides a modified version of the command \c i t e, which is \c i n t en. This command removes the square brackets from the citation, allowing further formatting. Note that the package sorted the numbers before typesetting them (the number 6 was given after the number 9). However, older versions did not provide sorting. If you are working on an installation with an older version, you may additionally use the citesort package (by Ian Green) to sort the references before they are typeset.
8.2 U s i n g B i b T ^ X
The method for typesetting the bibliography described in the previous section is useful when we have a few bibliographic references. When we have a lot of them, we would prefer the automatic bibliographic generation available through the use of BrnTgX, as this provides a flexible mechanism for dealing with bibliographic entries. BibTjzX is a program designed by Qren Patashnik.
The preparation of a bibliography using B
ib
T^X
involves two steps: the preparation
of a bibliographic database and the choice of a bibliographic style (i.e., we have to choose a program written in the internal language of BrnTpX that will format the bibliography according to certain stylistic rules). We now present these steps.
Prepare and store the bibliographic records in a .bib file. Assume that our work is in the file f i l e.tex. We create the file b i b f i l e .bib (the choice of name is irrelevant),
which consists of records having the general form
@D0C{key,
author = "Martin, William Ted", publisher = "Springer-Verlag",
2 3 2 - φ 8 B l B L I O G R A PHY A N D I N D E X
t i t l e = "From \LaTeX\ to $\Lambda$ An {Ij-ntroduction
{T}o { D } i g i t a l {Typography}", year = 2001
>
where DOC is the kind of bibliographic reference and can be book, a r t i c l e, booklet, and so on, (see next section). As we see from the previous example, each bibliographic record starts with a left curly bracket and ends with a right curly bracket. However,
one may opt to start each bibliographic record with a left parenthesis and end it with
a right parenthesis. Note that the case of the field names or the bibliographic records does not matter. In multilingual environments, some additional possibilities are usually provided. The general form of the fields is
field-name = "value" or f i el d- name = { v a l u e }
The only exception is the year field-^we do not need to enclose the year in quotation marks or curly brackets unless it is a complete date or a year with some attribution (e.g., B.C. and so on). Also, note that fields must be separated by commas.
The key is the label that we use to refer to this bibliographic entry in f i l e.t e x through the \c i t e command. For the author field, we must say that we first write the family name, a comma, and then the first name. Alternatively, we can write
author = "William Ted Martin"
without a comma, and BibT^X assumes that the last word is the family name. There are cases where the author is a company. For example, the author of the official books for the PostScript language is Adobe Systems, Inc. In such cases, we must inform BibT^X that it should not expect a first name and a family name but, instead, it should treat the author field as one entity. We do this by writing the author like this:
author = "{Adobe Systems Inc.}"
If the name uses the word Junior, we write
M a r t i n,J r., William
Finally, when we have many authors, we can use the keywords and or and others. For
example,
de Bakker, John and others
will give de Bakker, John et al.
For the publisher field, a publisher may appear many times. That is why it may be
useful to create a string shorthand. If we write
@string{sv = "Springer-Verlag"}
then whenever we want to write Springer-Verlag as the publisher, we can just write
8.2 U s i n g B i b T ^ X 2 3 3
publisher = sv
We note here that when we want to add something to such a string shorthand, we can use the special character #. So, if we want to write Springer-Verlag GmbH, we can use
publisher = sv # GmbH
The command ©preamble has a syntax that is similar to the syntax of the ©string command, except that there is no name or equal sign, just the string. This command is useful to add verbatim text to the generated bibliography file. For example, if we want to add an entry to the table of contents we can use the following command:
©preamble("\addcontentsline{toc}{chapter}{Bibliography}")
For the title field, it is a common problem that the words after the first one are set in lowercase; this holds even if the first letter is capital. To override this, we put either the capital letter or the whole word in curly braces:
t i t l e = "On the {Meaning} of {N}umbers"
Note that the following characters cannot be part of the value of the field:
"#·/.’ ( ) = { }
If such a character is needed, we can escape it by putting a backslash in front of it and by placing the entire accented character in braces:
author = G{\"o}del
Note that it is good practice to avoid further nesting of accented characters or else we may not get the expected results for certain bibliographic styles. The records in a bibliographic database can have many more fields, which we will present in the next section. We will close this section by showing the working cycle of BraT^X.
Suppose that we are preparing a document that we store in a file called text. tex. Our bibliographic database is stored in a file called biblio. bib. Note that files contain­
ing bibliographic databases that can be processed by ΒιβΤ^Χ by default have the . bib filename extension. In order to be able to successfully generate a bibliography, we must specify the bibliographic style that will be used. Therefore, we place the command
\b i b l i o g r a p h y s t y l e { s i i/i e }
somewhere in file t e x t. tex. Note that s t y l e is the name of a bibliographic style. The next thing that we must do is to put the command
\bibliography{bibZioi, bi bl i o 2, bibli oN}·
s ome wher e i n t he f i l e t e x t .t e x ( us ual l y at t he e nd of t he fi l e). The argument s are t he names of t he bi bl i ographi c dat abases that wi l l be us e d t o create t he bi bl i ography. Now, we are ready to proces s our I^TeX file:
2 3 4 ^ ^ Bi b l i o g r a p h y a n d I n d e x
$ l a t e x t e x t
This i s TeX, Version 3.14159 (Web2C 7.3.3.1 )
(./t e x t.t e x LaTeX2e <2000/06/01>
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s Document Class: a r t i c l e 2000/05/19 v l.4 b Standard LaTeX document c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e 10.c l o ) )
No f i l e t ex t.a u x.
LaTeX Warning: Citation ‘man’ on page 1 undefined on input l i n e 4.
LaTeX Warning: Citation ‘yager1 on page 1 undefined on input l i n e 4.
LaTeX Warning: Citation *knuth1 on page 1 undefined on input l i n e 4.
No f i l e t e x t.b b l.
[1] (./t e x t.a u x )
LaTeX Warning: There were undefined r ef e r e n c e s.)
Output written on t e x t.d v i (1 page, 292 b y t e s ).
Transcript written on t e x t.l o g.
As is evident I^TgX does not recognize the various bibliography-related labels, so we have to run BibT^X:
$ bibtex text
Transcript written on text.log.
This is BibTeX, Version 0.99c (Web2C 7.3.3.1)
The style file: alpha.bst Database file #1: biblio.bib
Note that we always supply to BibT^X the name of the auxiliary file produced by so that BibTjjX will resolve the undefined references that are stored in the auxiliary file. Let us now rerun LTjiX:
$ latex text
This is TeX, Version 3.14159 (Web2C 7.3.3.1)
(./tex t.tex LaTeX2e <2000/06/01>
(/usr/local/teTeX/share/texmf/tex/latex/base/article.els Document Class: article 2000/05/19 vl.4b Standard LaTeX document class
(/usr/local/teTeX/share/texmf/tex/latex/base/size10.clo))
(./tex t.aux)
LaTeX Warning: Citation ‘man’ on page 1 undefined on
8.2 U s i n g B i b T ^ X 235
i n p u t l i n e 4.
L a T e X W a r n i n g: C i t a t i o n ‘ y a g e r ’ o n p a g e 1 u n d e f i n e d on i n p u t l i n e 4.
L a T e X W a r n i n g: C i t a t i o n ‘ k n u t h ’ o n p a g e 1 u n d e f i n e d on i n p u t l i n e 4.
(./t e x t.b b l ) [ 1 ] (./t e x t.a u x )
L a T e X W a r n i n g: T h e r e w e r e u n d e f i n e d r e f e r e n c e s.
L a T e X W a r n i n g: L a b e l ( s ) may h a v e c h a n g e d. R e r u n t o g e t c r o s s - r e f e r e n c e s r i g h t.)
O u t p u t w r i t t e n o n t e x t.d v i ( 1 p a g e, 960 b y t e s ).
T r a n s c r i p t w r i t t e n on t e x t.l o g.
Now, we have to r erun I^TgX one more time to have everything i n order:
$ l a t e x t e x t
T h i s i s T e X, V e r s i o n 3.1 4 1 5 9 (Web2C 7.3.3.1 )
(./t e x t.t e x L a T e X 2 e <20 00/06/01>
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s D o c u m e n t C l a s s: a r t i c l e 2 0 0 0/0 5/1 9 v l.4 b S t a n d a r d L a T e X d o c u m e n t c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e l O.c l o ) )
(./t e x t.a u x ) (./t e x t.b b l ) [ 1 ] (./t e x t.a u x ) )
O u t p u t w r i t t e n o n t e x t.d v i ( 1 p a g e, 932 b y t e s ).
T r a n s c r i p t w r i t t e n on t e x t.l o g.
That's all! We n o w briefly present the basic bi b l i o g r a p h y styles:
p l a i n This style file uses nu mbers i n brackets for tags, and the entries are sorted alphabetically.
a l p h a This style uses alphanumeric tags u s i n g the first letters of the author name(s) and the last two digits of the publication year of the record (e.g., [PS00]). Records are sorted alphabetically, u n s t r This style u ses n u m eri c tags and th e entries a p p ear i n the b i b l i o g r a p h y in th e order that they are referenced, a b b r v This style is the same as w i t h the p l a i n style but uses a compact form wherever possible (e.g., for month names), a m s p l a i n This style is similar to p l a i n except that document titles are typeset i n italics, ams a l p h a This style is also similar to a l p h a except that document titles are typeset in italics.
acm This style is similar to p l a i n except that author names are typeset i n small caps.
236 -φ- 8 B l B L I O G R A P H Y A N D I N D E X
8.2.1 T h e B i b T j X F i e l d s
W e r e t u r n n o w t o t h e i s s u e o f w h a t a B m T g X e n t r y c a n b e a n d w h a t f i e l d s i t c a n c o n t a i n. T h e e n t r i e s o f B i b T ^ X c a n b e: a r t i c l e, b o o k, b o o k l e t, i n b o o k ( f o r r e f e r r i n g t o a p a r t i n s i d e a b o o k ), i n c o l l e c t i o n ( a p a r t o f a b o o k w i t h i t s o w n t i t l e ), i n p r o c e e d i n g s, m a n u a l, m a s t e r t h e s i s,p h d t h e s i s, p r o c e e d i n g s, t e c h r e p o r t, u n p u b l i s h e d, a n d m i s c, i f n o t h i n g e l s e f its.
The above are the c ommon entries, and it is not a complete list. For example, these entries w i l l not w o r k for a language other than English. O n e s h o u l d have special entries for on e's language that take care of the language selection. S u c h entries are either p r o v i d e d b y a custom bib liog rap hic style for the specific language or one must define them. A s an example, A p o s t o l o s S y r o p o u l o s has designed the bi bliographic style h e l l a s that defines entries such as g r - b o o k, g r - a r t i c l e, and so on. If one wants either to define a n e w b ib l io g ra p h y style or to im pr o ve or change the functionality of an existing style file, one is ad vi se d to s t u d y the document contained i n file b t x h a k.t e x, w h i c h is included in every Tj?X installation. I n addition, one can study the code of an existing style file. A l l that we can say here is that B i b T ^ X style files are written in a language that manipulates a stack and uses the so-called post f i x notation. L a n g u a g e s similar to this language are the PostScript language, the Forth p r o g r a m m i n g language, and the r p l language used in the Hewlett-Packard calculators.
Each bibliographic record can have several fields. The f o l l o w i n g are the most common: a d d r e s s, a n n o t e, a u t h o r, b o o k t i t l e, c h a p t e r, c r o s s r e f, e d i t i o n, e d i t o r, h o w p u b l i s h e d, i n s t i t u t i o n (for technical reports), j o u r n a l, k e y, m o nt h, n o t e, n u m b e r, o r g a n i z a t i o n (for a sponsor), p a g e s, p u b l i s h e r, s c h o o l (for a thesis), s e r i e s, t i t l e, t y p e, v o l u m e, and y e a r. M o s t of these entries are self evident but the c r o s s r e f entry must be explained. S u p p o s e that we have the f o l l o w i n g two bibliographic entries
© i n p r o c e e d i n g s ( o b j s,
c r o s s r e f ="p l d i", a u t h o r = 11 J u l i a n D o l b y", t i t l e ="A u t o m a t i c I n c l i n e", p a g e s ="7 — 1 7")
© p r o c e e d i n g s ( p l d i,
t i t l e ="C o n f e r e n c e o n P r o g r a m m i n g", y e a r = 2 7 7 8,
o r g a n i z a t i o n ="A C M S I G P L A N")
Then, the f o l l o w i n g things happen: if the first entry is used, it inherits all of the fields of the second entry, and the second entry w i l l automatically appear i n the bibliography, even if it is not called explicitly. I n each bi bliog raphi c record, we can have three k i n d s of fields:
R e q u i r e d fields that is, fields that m ust be present i n the record. However, if we either forget or d o not have e n o u g h data to specify the field, B i b T ^ X w i l l w a r n about a m i s s i n g field.
8.2 U s i n g B i b T ^ X 237
O p t i o n a l f ields that w i l l he used h y B i b T ^ X on l y if they are present.
O t h e r fields that are u s u a l l y ignored b y B ibT^X.
Consequently, if we use a particular field i n the bi bliographic record and the information stored i n this field does not appear i n the formatted bibliography, this means that the field has been ignored b y B ibT^X.
8.2.2 T y p e s e t t i n g a B i b l i o g r a p h i c D a t a b a s e
I f we want to typeset the whol e bi bliographic database contained i n some file, then one w a y is to cite each record. Since this is cumbersome, an easier w a y is to use the \n o c i t e { * } command. The f ol l o wi n g file w i l l typeset all of the bi bliog raphic records contained in the f i l e. b i b file:
\d o c u m e n t c l a s s { a r t i c l e }
\b e g i n { d o c u m e n t }
\b i b l i o g r a p h i c s t y l e { a l p h a }
\n o c i t e { * }
\b i b l i o g r a p h y { f i l e }
\e n d { d o c u m e n t }
Here, we u s e d the a l p h a style, but one can use an y other style instead.
This simple file can be further customized b y l o a d i n g special packages that w i l l affect the appearance of the bibliography. Here is an example:
\d o c u m e n t c l a s s [ t w o c o l u m n ] { a r t i c l e }
\u s e p a c k a g e { b i b m o d s,s h o w t a g s }
\b e g i n { d o c u m e n t }
\b i b l i o g r a p h i c s t y l e { a l p h a }
\n o c i t e { * }
\b i b l i o g r a p h y { f i l e }
\e n d { d o c u m e n t }
F igu re 8.2 s h o w s an example output.
8.2.3 M u l t i p l e B i b l i o g r a p h i e s i n O n e D o c u m e n t
There are b o ok s (e.g., collections of papers) that need a different bi b l i o g r a p h y for each chapter or section. The solution for this problem is pr o v i d e d b y the package chapterbib b y N i e l K e m p s o n and D o n a l d Arseneau. The package makes it possible to have one bi b l i o g r a p h y for each i ncl uded file i n a m a in document (through the \i n c l u d e command) despite the o b v i o u s connotation of its name. B i b T ^ X s h o u l d be r u n o n each i ncluded file separately instead of on the m ai n document file ("r o o t" file). Each of these i ncluded files m ust have its o w n \b i b l i o g r a p h y s t y l e and \b i b l i o g r a p h y commands. N o t e that if y o u are u s i n g the babel package, then chapterbib mu s t b e loaded b efore
238 -φ- 8 B l B L I O G R A P H Y A N D I N D E X
R e f e r e n c e s
pldi
[ACM78] A C M S I G P L A N. C o n f e r e n c e o n P r o g r a m m i n g, 2778.
objs
[Dol78] J u l i a n Dolby. A u t o m a t i c incline. [ACM78], pages 7-17.
Hobby: MetaPost
[Hob92] J o h n Hobby. A u s e r ’s m a n u a l f o r M e t a P o s t. A T & T B e l l L a b o r a t o ­
ries, M u r r a y H i l l, N J, 1992.
Lamport
[Lam94] Lesli e La mp o r t. B'T jtX; A D o c u ­
m e n t P r e p a r a t i o n S y s t e m. Addison W e s l e y P u b l. Co., 2 edition, 1994.
latex
[MarOl] W i l l i a m Ted M a r t i n. F r o m 3 Τ β Κ t o A A n I n t r o d u c t i o n T o D i g i t a l T y p o g r a p h y. Springer Verlag, 2001.
Figure 8.2: Bibliography typesetting using bibmods and showtags.
babel. Naturally, one can use the combine document class to solve this problem i n a more general w a y (see Section 2.9 o n page 3 4 ).
8.2.4 B i b l i o g r a p h y i n a M u l t i l i n g u a l E n v i r o n m e n t
A n e w v e r sion of B ibT^X, called B i b T ^ X S, capable o i h a n d l i n g bibliog raphi c databases written in an extended A S C I I, has been developed b y N i e l K e m p s o n and Alejandro Aguilar-Sierra. The p r og r a m has a nu mber of switches, but the most important is the - c switch (or its equivalent: — c s f i l e ) b y w h i c h we can specify the so-called csfile to use. The csfile s h o u l d be u s ed to define h o w B i b T ^ X S sh o u l d treat an extended A S C I I (e.g., whether an accented letter s h o u l d have the same letter o r d e ri n g as the unaccented one). Each csfile has a nu mber of sections, each h a v i n g the form of a L T g X command:
\s e c t i o n - n a m e - T
s e c t i o n - d e f i n i t i o n s
>
I n a csfile, one can have, at most, four sections:
\l o w u p c a s e This section is used to define the lower/uppercase relationship of pairs of specified characters. The syntax of this section is
\l o w u p c a s e {
L C - 1 UC-1 % comment
L C - 2 UC-2 % t o u s e % i n s i d e a d e f i n i t i o n
................. % u s e '“'2 5 i n s t e a d
LC-N UC-N >
8.2 U s i n g Β ι β Τ ^ Χ -φ- 239
O n e is not allowed to redefine the lowercase and uppercase equivalents of a normal A S C I I character.
\l o w e r c a s e This section is u s e d to define the lowercase equivalent of specific charac­
ters.
\u p p e r c a s e This section is used to define the uppercase equivalent of specific charac­
ters.
\o r d e r This section is u sed to define the sorting order of the characters. The syntax of the \o r d e r section is (CH-N denotes a single character):
\o r d e r {
CH-1
CH-2 CH-3 CH-4 _ CH-5 CH-6 - CH-7
CH-N >
A l l characters on the same line have the same sorting “w ei gh t." I n order to define that a range of characters has the same sorting "w e i g h t/' we use the construct CH-4 _ C H - 5 (e.g., A _ Z denotes that characters A th r o u g h Z have the same sorting "w e i g h t"). The construct CH-6 - CH-7 is u s e d to denote that all characters i n the range CH-6 to CH-7 s h o u l d have ascending sorting "w e i g h t s" starting w i t h CH-6 and e n d i n g w i t h CH-7. The position of characters i n the file from top to bottom denote their sorting "w e i g h t s" i n increasing order. A l l characters not present i n this section ( in cl udin g A S C I I characters) are g i v e n the same v e r y h i g h sorting "w e i g h t" to ensure that they come last w h e n sorting alphabetically. Therefore, it is a g o od idea to include the A S C I I characters to ensure proper sorting of "m i x e d" bibliographies.
Let u s see an example. A s s u m e that we have a b i b l i o g r a p h y database i n the file g r e e k.b i b that includes two citations i n Greek and one i n Eng li sh, and assume that we want to print it. We set u p a file, say, t e x t .tex, according to Section 8.2.2 slightly modified to sup port the Greek language (see Section 10.4 ):
\d o c u m e n t c l a s s [ a 4 p a p e r ] { a r t i c l e ) ·
\u s e p a c k a g e [ i s o - 8 8 5 9 - 7 ] { i n p u t e n c }
\u s e p a c k a g e [ g r e e k ] { b a b e l } - \b i b l i o g r a p h y s t y l e { h e l l a s ] - \b e g i n { d o c u m e n t } - \n o c i t e { * }
\b i b l i o g r a p h y { g r e e k ) -
\e n d { d o c u m e n t ) -
The file i s o
8 8 5 9 - 7. c s f, b y A p o s t o l o s Syropoulos, defines the correspondence of l o w ­
ercase to uppercase Greek letters as well as their order. For example, the \l ow u pc ase part looks l i k e
240 -φ- 8 B l B L I O G R A P H Y A N D I N D E X
\l o w u p c a s e { a A ά A
\o r d e r {
0-9
and the \o r d e r comman d looks like A a
Ω ω Ώ ώ }
N o w, w e r u n t h e t e x t .t e x f i l e t h r o u g h I ATgX, t h e n w e r u n b i b t e x S t e x t, a n d f i n a l l y w e r u n L i T g X t wi c e. T h e r e s u l t l o o k s l i k e t h i s:
[1] D o n a l d E. K n u t h. The Tf i X book. Addison-Wesley, 2 000.
[2] Απόστολος Συρόπουλος. $ Τ β Κ. Παρατηρητής, Θεσσαλονίκη, 1998.
[3] Δημήτριος Φιλίππου. Τ α πρώτ α β ή μ ατ α σ τ ο ΤβΚ. Παρατηρητής, Θεσσαλονίκη,
S u p p o s e n o w that one is pr ep ari ng a document that uses at least two different scripts (e.g., the Lat in and the Hebrew); then it may be necessary to have at least two bibliog raphic sections: one for the L a t i n script and one for the H e b r e w script. This particular problem can be han dl ed b y u s i n g the multibbl package b y A p o s t o l o s Syropoulos. This package redefines most of the comman ds related to the I^TgX user interface for the creation of bibliographies. The comman d \n e w b i b l i o g r a p h y is used to create a n e w aux iliary file, which, i n turn, w i l l be u s ed to create a ne w b i b l i og ra p h y section. The comman d has one argument: the name of an aux iliary file that w i l l be used to create the n e w bi b l i o g r a p h y section. The n e w ver s i on of the \c i t e command has two required arguments a nd one optional one. The first required argument is the name of the bibliography, and the second retains the functionality of the origi nal command. The same d e si g n principle applies to the comman ds \b i b l i o g r a p h y s t y l e and \n o - c i t e. The command \b i b l i o g r a p h y has three required arguments, the first be i ng the name of the aux iliary file, the second the argument that w o u l d be used if we had o n l y one bibliography, and the third a string that w i l l be used to typeset the title of the bi b l i o g r a p h y section and the r u n n i n g heads of this section (the first and second arguments are u s u a l l y the same). Here is a sample input file that s h o ws h o w to use the package:
\d o c u m e n t c l a s s { a r t i c l e }
\u s e p a c k a g e { m u l t i b b l } -----------------
\b e g i n { d o c u m e n t }
\n e w b i b l i o g r a p h y { b o o k s } \n e w b i b l i o g r a p h y { p a p e r s } \b i b l i o g r a p h y s t y l e { b o o k s } { a l p h a } \b i b l i o g r a p h y s t y l e { p a p e r s } { u n s r t }
1999.
8.3 P r e p a r i n g t h e I n d e x <>- 241
t e x t t e x t t e x t t e x t t e x t t e x t t e x t
t e x t t e x t ~\c i t e { p a p e r s } { e u c l i d,p y t h a g o r a s }
\n o c i t e { b o o k s } { * }
\b i b l i o g r a p h y { p a p e r s } { p a p e r s } { P a p e r L i s t } \b i b l i o g r a p h y { b o o k s } { b o o k s } { B o o k L i s t }
\e n d { d o c u m e n t }
8.3 Preparing the Index
A n i nd ex is something that serves to guide, point out, or otherwise facilitate reference, especially an alphabetized list of names, places, and subjects treated i n a printed work, g i v i n g the page or pages on w h i c h each item is mentioned. I n I^T]hX, we include a w o r d i n the index b y u s i n g the comman d \i n d e x, so if the w o r d p e r i s h o u l d be included i n the index, we s h o u l d use the command
\i n d e x { p e r l }
I f the w o r d is to be printed in bold, we use
\i n d e x { p e r l @\t e x t b f { p e r i } }
The special character @ is used to denote that what appears o n its left side must be typeset as it appears o n its right side. Thus, the first occurrence of p e r i w i l l also be u sed b y the sorting algorithm. This is v e r y useful since what is u s ed for sorting and what w i l l be printed may be different! For example, we m ay want to have the name “D o n a l d K n u t h" u n d e r the letter K. Then, we sh o u l d write
\i n d e x { K n u t h Q { D o n a l d K n u t h } }
A n o t h e r th ing we m a y want to change is the w a y that the page nu m be r is type­
set. I f we want, for example, to have the page number i n bold, we w o u l d write \i n d e x { p e r l I t e x t b f }. Notice that we wrote t e x t b f without the backslash. O f course, the above can be combined. The command
\i n d e x { p e r l @\t e x t b f { p e r i } | t e x t i t }
w i l l print the w o r d p e r i in the index (the entry w i l l be typeset i n boldface type) sorted as “p e r i," and its page n u m be r w i l l be italic. A c om m o n application of this is t h ro u g h the comman d \s ee. I f we want to send the reader to another index entry, say, to send the reader from the $\omega$ to the $\0mega$ command, we can write
\i n d e x { o m e g a @ $\o m e g a $ | s e e { $\0 m e g a $ } }
Here, we a sk for the entry to be sorted according to the w o r d omega and, i n its place, the p r og r a m must use $\omega$ | s e e { $\0mega$}.
If a w o r d is used repeatedly i n a range of pages and we want to have this range i n the i n d ex, w e d o not w r it e the relative \i n d ex comman d all of the time. Instead,
242 - φ 8 B l B L I O G R A P H Y A N D I N D E X
w e w r i t e \i n d e x { c o n v e x | (> a t t h e p l a c e w h e r e w e h a v e t h e f i r s t o c c u r r e n c e a n d \i n d e x { c o n v e x | )}- a t t h e p l a c e w h e r e w e h a v e t h e l a s t o c c u r r e n c e. T h i s w i l l p r o d u c e a p a g e r a n g e i n t h e i n d e x f o r t h e w o r d c o n v e x.
Subindices are prod uced u s i n g an exclamation mark. I f we want the w o r d "Z e u s" to appear i n the category of "G r e e k" w h i c h is i n the category of "G o d s," we w i l l write
\i n d e x { G o d s!G r e e k!Z e u s }
Let u s see the first example. I n order to produce an index, we need to load the package makeidx and immediately issue the c ommand \makeindex. A t the place where we want the index to be printed, we use \p r i n t index. We create a document w i t h name i n d t e s t. t e x w i t h the f o l l o w i n g lines:
\d o c u m e n t c l a s s - C a r t i c l e }
\u s e p a c k a g e { m a k e i d x }
\m a k e i n d e x \b e g i n { d o c u m e n t }
T h i s i s p a g e 1. \i n d e x { p e r l | ( } \i n d e x { J a v a | t e x t b f } \i n d e x { 0 m e g a @ $\0 m e g a $ | t e x t b f } \i n d e x { l a n g u a g e!f o r m a l!l o t o s } \i n d e x { l a n g u a g e!G r e e k }
\n e w p a g e T h i s i s p a g e 2.
\index-Comega@$\omega$ | s e e -C $\O me g a $ }}
\i n d e x { l a n g u a g e ! p r o g r a m m i n g! s e l f }\i n d e x - ["@ @\t e x t i t - [ a t } s y m b o l }
\i n d e x { j a v a }\i n d e x { l a n g u a g e!S p a n i s h }\i n d e x { G o e t e b o r g Q G o t h e n b u r g }
\n e w p a g e
T h i s i s p a g e 3.
\i n d e x { G o e t e b o r g ® G l,V t"{ o } t e b o r g } \i n d e x { J a v a }
\i n d e x { o m e g a @ $\o m e g a $ | s e e { $\0 m e g a $ } }
\i n d e x { l a n g u a g e!p r o g r a m m i n g!o b e r o n } \i n d e x { l a n g u a g e!f o r m a l }
\n e w p a g e T h i s i s p a g e 4.
\i n d e x { p e r l | ) } \i n d e x { G o e t e b o r g @ G o t h e n b u r g }
\i n d e x {"@ @\t e x t t t {"@ } s y m b o l }
\p r i n t i n d e x \e n d { d o c u m e n t }
W e n o w r u n L?TeX. T h i s f i r s t r u n w i l l c r e a t e t h e f i l e i n d t e s t. i d x, w h i c h c o n t a i n s t h e I n d e x e n t r i e s a s t h e y a r e r e a d b y Ι^ΤβΧ t o g e t h e r w i t h t h e i r p a g e n u m b e r i n f o r m a t i o n. N o w, t h e y m u s t b e t y p e s e t a n d s o r t e d. T h i s i s d o n e b y t h e p r o g r a m makeindex. T o p r e p a r e t h e i n d e x, w e h a v e t o u s e t h e p r o g r a m m a K E i N D E x b y P e h o n g C h e n:
$ m a k e i n d e x i n d t e s t
T h i s i s m a k e i n d e x, v e r s i o n 2.1 3 [ 0 7 - M a r - 1 9 9 7 ] ( u s i n g k p a t h s e a ). S c a n n i n g i n p u t f i l e i n d t e s t.i d x....d o n e ( 1 7 e n t r i e s a c c e p t e d,
8.3 P r e p a r i n g t h e I n d e x <>- 243
0 r e j e c t e d ).
S o r t i n g e n t r i e s .... d o n e ( 6 8 c o m p a r i s o n s ).
G e n e r a t i n g o u t p u t f i l e i n d t e s t.i n d....d o n e ( 3 6 l i n e s w r i t t e n,
1 w a r n i n g ).
O u t p u t w r i t t e n i n i n d t e s t.i n d.
T r a n s c r i p t w r i t t e n i n i n d t e s t.i l g.
A s i s e v i d e n t, t h i s p r o c e s s c r e a t e s t h e f i l e i n d t e s t. i n d, w h i c h c o n t a i n s t h e s o r t e d i n d e x. I t i s t i m e t o r e r u n I^TgX. T h e \p r i n t i n d e x c o m m a n d w i l l l o a d t h e i n d e x i n f o r m a t i o n f r o m t h e f i l e i n d t e s t. i n d i n t o t h e m a i n d o c u m e n t. I n F i g u r e 8.3, w e c a n s ee t h e r e s u l t o f t h e e x a m p l e a b o v e.
I n t h i s e x a m p l e, w e o b s e r v e t h e u s e o f q u o t e s (") i n f r o n t o f s p e c i a l c h a r a c t e r s s u c h a s 0. T h i s i s a g e n e r a l p r i n c i p l e a n d i s h o w w e c a n h a v e a s p e c i a l c h a r a c t e r i n t h e i n d e x. F o r t h e w o r d "G o t e b o r g" a b o v e, w e h a d t o t y p e "\ s o t h a t t h e makeindex p r o g r a m w i l l l e a v e a b a c k s l a s h i n t h e i n d t e s t.i n d f i l e; w e a l s o h a d t o t y p e 11" so t h a t m a k e i n d e x w i l l l e a v e a d o u b l e q u o t e " i n t h e i n d t e s t. i n d f i l e. S o n o w, w h e n w e r e r u n I5Tp;X, i t w i l l f i n d i n t h e i n d t e s t. i n d f i l e t h e s e q u e n c e \", t h u s p r o d u c i n g a n u m l a u t a b o v e t h e o i n G o t e b o r g. A n o t h e r e x a m p l e t h a t o f t e n a p p e a r s i n t h i s d o c u m e n t c o m e s f r o m t h e c o m m a n d s t h a t w e w a n t t o h a v e i n t h e i n d e x a n d s t a r t w i t h a b a c k s l a s h. F o l l o w i n g t h e p o i n t a b o v e, i f w e w a n t t h e c o m m a n d \ a l p h a i n o u r i n d e x ( n o t t h e c h a r a c t e r a. b u t t h e c o m m a n d i t s e l f ), w e m u s t w r i t e
\i n d e x { a l p h a @"\v e r b |"\a l p h a | }
B e t t e r r e s u l t s a r e a c h i e v e d b y d e f i n i n g a c o m m a n d \P P
\newcommand-C\PP} [ 1 ] {\t e x t t t {\t e x t b a c k s l a s h#l } } - a n d u s i n g i t l i k e t h i s
\i n d e x { a l p h a @\P P { a l p h a } - } -
at symbol, 2 Z, 4
Φ symbo l, 4 Greek, 1
p r o g r a m m i n g Goteborg, 3 oberon, 3
Got henbur g, 2, 4 self, 2
Spanish, 2
J a v a, 1, 2, 3
Ω, 1
la nguage W/ s e e Ω
formal, 3
lotos, 1 peri, 1 - A
Fi gure 8.3: A s t andar d i ndex.
244 ^ ^ B i b l i o g r a p h y a n d I n d e x
8.4 m a k e i n d e x in a Multilingual Environment
I n a mul t i l i ngu al document, we have a problem that needs to be addressed. Different alphabets have different orderings of letters, or they are entirely different from the Lat i n alphabet. Consequently, the sorting algorithm w i l l not produce any satisfactory results. The nice solution w o u l d be to produce one index for every different l anguage and sort the entries of each of them w i t h the language letter-order. This is achieved u s i n g the package multind b y F.W. Lo ng. The package modifies the c omman ds of the makeindex package to accept an additional required argument; this is just the name of the index file. Thus, in a document w it h mixed E n g l i s h and Greek, we w o u l d use:
\u s e p a c k a g e { m u l t i n d }
\m a k e i n d e x { e n g l i s h }
\m a k e i n d e x { g r e e k }
Then, w h e n we want an E n g l i s h w o r d i n the index, say, the w o r d love, we write \i n d e x { e n g l i s h } { l o v e }. Similarly, if έρως s h o u l d appear i n its index, we w i l l write \i n d e x { g r e e k } { c p < i K;} This way, the first L T g X r u n w i l l produce two index files. These w i l l be e n g l i s h. i d x and g r e e k. idx. Now, we have to sort the entries and typeset them. The m a k e i n d Exprogram w i l l w o r k fine for the E n g l i s h language, but it w i l l fail for other languages. There is n o global solution to this problem. Each language m a y or m a y not have its o w n p r o g r a m for d o i n g this. The s up por t for the Greek language includes a Perl script written b y A p o s t o l o s S y r o p o u l o s w i t h name m k i n d e x that can d o for the Greek index file what makeindex does for the E n g l i s h index. After the script is r u n on the file g r e e k.i d x, we rerun so that the indices get incorporated into the main document. This is done b y w r i t i n g the comman ds
\p r i n t i n d e x { g r e e k > { E O p £ T ^ p L O ε λ λ η ν ι κ ώ ν ό ρ ω ν }
{\u s e f o n t { O T l } { c m r } { m } { n }
\p r i n t i n d e x { e n g l i s h } { E u p 0^ p i o ξενόγλωσσων ό ρ ω ν } }
at the places where we want to have them. The second argument of the \p r i n t i n d e x c ommand is the section header.
Here, we assume that we are actually pr epari ng a Greek language document so we h a d to enclose the "f o r e i g n" index i n a local scope that temporally changes the font i n use. Naturally, this is not necessary w h e n p r e p ari n g o u r document w it h A. The \p r i n t i n d e x c ommand also writes an entry i n the table of contents. However, this entry corresponds to a section entry (i.e., the author of the package as s umed that indices are just sections). I n case we want to change this behavior, all we have to d o is to change the cor r es pondin g c ommand i n the definition of the \p r i n t i n d e x command.
>- Exercise 8.2 S t u d y the definition of the \p r i n t i n d e x c omman d and then m o d i f y it so that indeces are "t r e a t e d" as chapters. □
8.5 C u s t o m i z i n g t h e I n d e x <>- 245
8.5 Customizing the Index
We can customize the index either b y d e s i g n i n g a style file or b y redefining the e n v i­
ronment that is used to typeset the index. A style file m a y have at most two sections: the first defines the meanin g of the v a r iou s special characters (input specifiers), and the second defines the comman ds that w i l l be inserted i n the output file (output specifiers). Table 8.1 s h o w s specifiers associated w i t h the definition of the inp ut specifiers. Fo r ex­
ample, if we want the s ymbol = to be u s ed instead of @, we have to place the f ol l o win g line i n a style file:
a c t u a l ’ = 3
N o t e t h a t c h a r a c t e r s a n d s t r i n g s m u s t b e e n c l o s e d i n s i n g l e q u o t e s. W e n o w p r e s e n t t h e v a r i o u s o u t p u t s p e c i f i e r s. I n w h a t f o l l o w s, t h e l et t er s d e n o t e s a s t r i n g t h a t m u s t b e e n c l o s e d i n d o u b l e q u o t e s a n d n d e n o t e s a n u m b e r.
p r e a m b l e s P r e a m b l e o f t h e o u t p u t f i l e ( i.e., w h a t w i l l a p p e a r a t t h e v e r y b e g i n n i n g o f t h e o u t p u t f i l e ). T h e d e f a u l t v a l u e i s \\b e g i n { t h e i n d e x }\n. T h e t o k e n \n f o r c e s m a K E i N D E x t o c h a n g e l i n e, p o s t a m b l e s P o s t a m b l e o f t h e o u t p u t f i l e ( i.e., w h a t w i l l a p p e a r a t t h e e n d o f t h e o u t p u t f i l e ). T h e d e f a u l t v a l u e i s \n\n\\e n d - C t h e i n d e x } -\n. s e t p a g e _ p r e f i x s P r e f i x o f c o m m a n d t h a t s e t s t h e s t a r t i n g p a g e n u m b e r. T h e d e f a u l t v a l u e i s \n\\s e t c o u n t e r { p a g e } - [. s e t p a g e _ s u f f i x s S u f f i x o f c o m m a n d t h a t s e t s t h e s t a r t i n g p a g e n u m b e r. T h e d e f a u l t v a l u e i s }\n.
g r o u p _ s k i p s V e r t i c a l s p a c e t o b e i n s e r t e d b e f o r e a n e w g r o u p b e g i n s. T h e d e f a u l t v a l u e i s \n\n\\i n d e x s p a c e\n.
Tabl e 8.i: I nput styl e speci fi ers, ch denot es a s i ngl e char act er and s a stri ng. C o m m a n d M e a n i n g D e f a u l t S y m b o l
a c t u a l c h s e e S e c t i o n 8.3 @
a r g _ c l o s e c h s e e S e c t i o n 8.3 }
a r g _ o p e n c h e n c a p c h e s c a p e c h
k e y w o r d s
s e e S e c t i o n 8.3 s e e S e c t i o n 8.3
S y m b o l t h a t e s c a p e s t h e f o l l o w i n g l e t t e r, u n l e s s i t s p r e c e d i n g l e t t e r i s e s c a p e
C o m m a n d t h a t t e l l s m a k e i n d e x
1
\\
W i n d e x e n t r y
l e v e l c h
t h a t i t s a r g u m e n t i s a n i n d e x e n t r y s ee S e c t i o n 8.3
1
q u o t e c h
s ee S e c t i o n 8.3
π
r a n g e _ c l o s e c h
see S e c t i o n 8.3
)
r a n g e _ o p e n c h
see S e c t i o n 8.3
(
246 -φ- 8 B l B L I O G R A P H Y A N D I N D E X
h e a d i n g _ f l a g s Fl a g indicating the treatment of ne w g r o u p headers, w h i c h are i n ­
serted before a n e w group. The possible g r o u p s are symbols, numbers, and the 26 letters. A positive (negative) value causes an uppercase (lowercase) letter to be inserted between prefix and suffix. Default value is 0, w h i c h produces n o header. h e a d i n g _ p r e f i x s H eade r prefix to be inserted before a n e w letter begins; the default value is the empty string. s y m h e a d _ p o s i t i v e s H e a d i n g for s y m bol s to be inserted if h e a d i n g _ f l a g is positive;
the default value is Symbols. symhead_negative s H e a d i n g for symbols to be inserted if h e a d i n g _ f l a g is negative;
the default value is symbols. n u m l i e a d _ p o s it iv e s H e a d i n g for s y m bol s to be inserted if h e a d i n g _ f l a g is positive;
the default value is Nu mbers. n u m h e a d _ n e g a t i v e s H e a d i n g for symbols to be inserted if h e a d i n g _ f l a g is negative;
the default value is numbers. item_0 s C o m m a n d to be inserted between two p r i m a r y items; the default value is \n \\i t e m.
i t e m _ l s C o m m a n d to be inserted between two secondary items; the default value is \n W s u b i t e m.
i t e m _ 2 s C o m m a n d to be inserted between two level 2 items; the default value is \n W s u b s u b i t e m.
i t e m _ 0 1 s C o m m a n d to be inserted between a pr i m a r y and a secondary item; the default value is \n W s u b i t e m. i t e m _ x l s C o m m a n d to be inserted between a pr i m a r y and a secondary item w h e n the pr im a r y item does not have associated page numbers; the default value is \n W s u b i t e m,
i t em_ 12 s C o m m a n d to be inserted between a secondary and a level 2 item; the default value is \n W s u b s u b i t e m. i t e m _ x 2 s C o m m a n d to be inserted between a secondary and a level 2 item w h e n the secondary item does not have associated page numbers; the default value is \n W s u b s u b i t e m.
d e l i m _0 s Delimiter to be inserted between a pr i m a r y k e y and its first page number;
the default v al ue i s , u (i.e., a comma fol l o w ed b y a blank).__________________________
d e li m_ 1 s Delimiter to be inserted between a secondary k e y and its first page number;
the default value is , u. d e l i m _2 s Delimiter to be inserted between a level 2 key and its first page number;
the default value is , u- d e l i m _ n s Delimiter to be inserted between two page numbers for the same key in any level; the default value is ,u· d e l i m _ r s Delimiter to be inserted between the starting and e n d i n g page nu mbers of a range; the default value is —. d e l i m _ t s Delimiter to be inserted at the end of a page list. This delimiter has n o effect o n entries that have n o associated page list. The default value is the empty string.
8.6 G l o s s a r y P r e p a r a t i o n < > - 247
e n c a p _ p r e f i x s First part of prefix for the comman d that encapsulates the page n u m ­
ber; the default value is \\. e n c a p _ i n f i x s Second part of prefix for the comman d that encapsulates the page number; the default value is {. e n c a p _ s u f f i x s Suffix for the c ommand that encapsulates the page number; the de­
fault value is >.
l i n e _ m a x n M a x i m u m length of a line i n the output, beyond w h i c h a line wraps; the default length is 7 2.
i n d e n t _ s p a c e s Space to be inserted i n front of w r a p p e d line; the default value is \t\t (i.e., two tabs).
i n d e n t _ l e n g t h n L e n g t h of i n d e n t _ s p a c e; the default value is 16, w h i c h is equivalent to two tabs.
s u f f i x _ 2 p s Delimiter that replaces the range delimiter and the second page nu mber of a two-page list. W h e n present, it overrides d e l i m _ r. The default value is the empty string. Example: f .. s u f f i x _ 3 p s Delimiter that replaces the range delimiter and the second page nu mber of a three-page list. W h e n present, it overrides d e l i m _ r and s u f f i x _ m p. The default value is the empty string. Example: f f.. s u f f i x _ m p s Delimiter that replaces the range delimiter and the second page nu mber of a multiple-page list. W h e n present, it overrides d e l i m _ r. The default value is the empty string. Example: f..
A s an application, we w i l l s h o w y o u h o w to define a style file suitable for the generation of glossaries. Moreover, we w i l l use the definition of the t h e i n d e x environment to define an environment suitable for the typesetting of a glossary.
8.6 Glossary Preparation
L5TgX pr ov id es the command \g l o s s a r y, w h i c h can be u s e d i n order to generate a gl o s sa ry for, say, a book. However, one must first define a suitable package that can be u sed b y μ α κ ε ι ν ρ ε χ ϊ ο process the generated g l o ssary file. Naturally, in a glossary, the entries d o not need to have associated page numbers. However, each \g l o s s a r y c omman d w i l l print to the g l o s sary file a line of the form
\g l o s s a r y e n t r y {.g I o s s a r y - 1 e x t }--[ρ a g e - n u m b e r }
w h e r e p a g e - n u m b e r i s j u s t a n u m b e r. A g o o d s o l u t i o n i s t o i g n o r e t h e p a g e n u m b e r s b y i n s t r u c t i n g m a K E i N D E x t o m a k e t h e m t h e a r g u m e n t s o f a c o m m a n d t h a t j u s t i g n o r e s i t s a r g u m e n t s! A c t u a l l y, w e w i l l h a v e o n l y o n e p a g e n u m b e r, a s i t m a k e s n o s e n s e t o h a v e m u l t i p l e e n t r i e s f o r t h e s a m e k e y. M o r e o v e r, w e m u s t l e t m a k e i n d e x k n o w t h e n a m e o f t h e n e w c o m m a n d t h a t w i l l a p p e a r i n t h e g l o s s a r y f i l e. B e l o w is t h e c o d e f o r a s t y l e f i l e t h a t i m p l e m e n t s a l l o f t h e s e f e a t u r e s:
248 -φ- 8 B l B L I O G R A P H Y A N D I N D E X
a c t u a l >=’
k e y w o r d "W g l o s s a r y e n t r y" p r e a m b l e
"\\n e w c o m m a n d {\\I g n o r e } [ 1 ] { }\n \\b e g i n { t h e g l o s s a r y } -\n" p o s t a m b l e "\n\\e n d { t h e g l o s s a r y } -\i i" d e l i m _ 0 "\\I g n o r e {" d e l i m _ t
N o t e t h a t w e h a v e c h o s e n t h e = s i g n i n s t e a d o f t h e <3 s i g n s i n c e w e a r e s u p p o s e d t o e x p l a i n t h e m e a n i n g o f a t e r m. N o w, w e h a v e t o c r e a t e a l i t t l e p a c k a g e t h a t w i l l d e f i n e a t h e g l o s s a r y e n v i r o n m e n t. T o d o t h i s, w e u s e t h e d e f i n i t i o n o f t h e t h e i n d e x e n v i r o n m e n t. W e c r e a t e a p a c k a g e, w h i c h w e s t o r e i n f i l e g l o s s a r y. s t y ( l i n e n u m b e r s a r e i n c l u d e d f o r f u t u r e r e f e r e n c e ):
%% P a c k a g e * * g l o s s ’ ’
1 \R e q u i r e P a c k a g e { i f t h e n }
2 \n e w c o m m a n d {\g l o s s a r y n a m e } - { G l o s s a r y } -
3 \n e w e n v i r o n m e n t { t h e g l o s s a r y Μ 0/»
4 \i f t h e n e l s e {\b o o l e a n { @ t w o c o l u m n } ) - { %
5 \s e t b o o l e a n { @ r e s t o n e c o l } - { f a l s e } } - { %
6 \s e t b o o l e a n { @ r e s t o n e c o l } { t r u e } } °/0
7 \s e t l e n g t h {\c o l u m n s e p r u l e } { O p t } %
8 \s e t l e n g t h {\c o l u m n s e p } { 3 5 p t } %
9 \t w o c o l u m n [\s e c t i o n * {\g l o s s a r y n a m e } ] %
1 0 \m a r k b o t h {\M a k e U p p e r c a s e\g l o s s a r y n a m e } - %
1 1 {\M a k e U p p e r c a s e\g l o s s a r y n a m e } - %
4 2 \t h i s p a g e s t y l e { p l a i n } -
1 3 \s e t l e n g t h {\p a r i n d e n t } { O p t } -
1 4 \s e t l e n g t h {\p a r s k i p } { O p t p l u s .3 p t }
1 5 \l e t\i t e m\® i d x i t e m }
1 6 {\i f t h e n e l s e {\b o o l e a n { @ r e s t o n e c o l } } { %
17 \o n e c o l u m n ) - { %
18 \c l e a r p a g e } } ·
19 \n e w c o m m a n d {\p r i n t g l o s s a r y } { %
20 \l n p u t l f F i l e E x i s t s {\ j o b n a m e. g l d } { ) - { %
21 \t y p e o u t { N o f i l e \j o b n a m e.g l d } } >
We w i l l n o w try to explain what the code above does. The comman d \R e q u i r e P a c k a g e is u se d on l y inside packages to load another package. W h e n we want to load a package w i t h some options, we have to put the options i n square brackets:
\R e q u i r e P a c k a g e [
o p t i o n s ] { p a c k a g e }
O n l i n e 2, w e d e f i n e t h e n a m e o f t h e g l o s s a r y. N o t e t h a t t h e ba bel p a c k a g e r e d e f i n e s t h i s c o m m a n d s o t h a t i t p r o d u c e s t h e c o r r ect n a m e f o r t h e l a n g u a g e i n u s e. I n l i n e 3,
8.6 G l o s s a r y P r e p a r a t i o n < > - 249
we define a new environment that w i l l be u s ed to typeset the glossary. The internal Boolean variable @ t w o c o l u m n is set to true w h e n we typeset o u r document in two columns; otherwise, it is set to false. So, if this variable is true, we d o not have to switch back to one c olu mn typesetting. This hap pen s w h e n the g l o s s ary w i l l be typeset i n two columns. Then, o n lines 7 and 8, we set the values of the lengths \c o l u m n s e p r u l e and \c o l u m n s e p. The first length h o l d s the w i d t h of the rule that u s u a l l y appears between columns i n two- column typesetting. The second length h o l d s the length that separates columns i n two-column typesetting. O n line 9, we use the command \t w o c o l u m n to typeset the b o d y of the environment i n two columns. The optional argument is u s e d to produce the header for the glossary. O n lines 10 and 11, we use the comman d \m a r k b o t h to set the r u n n i n g heads. O n line 12, we declare the page style of the first page of the glossary. O n lines 13 a nd 14, we set two lengths: \p a r i n d e n t and \p a r s k i p. The second one corresponds to space that is left between paragraphs. W h e n the environment ends, we check the value of the internal Boolean variable \@ r e s t o n e c o l. I f it is true, we again start one col u m n typesetting. Otherwise, we s i m p l y start a ne w page. O n lines 19- 21, we define the c ommand that w i l l print the index. It uses the comman d \l n p u t l f F i l e - E x i s t s, w h i c h checks whether the file we want to include i n ou r file exists. If it exists, it includes the file and performs the action specified i n the curly brackets after the filename. I f the file does not exist, it performs the actions specified i n the third pair of cur l y brackets. Here, the filename has the name of the m a i n file (that is what is stored i n variable \j obname) and extension g l d. We take this opport unity to present another similar command: \I f F i l e E x i s t s. This comman d has three arguments: the name of a file, a t h e n part and an e l s e part. I f the file exists, the t h e n is executed; otherwise, the e l s e part is executed. Back to o u r business! Now, it is time to test ou r packages. We first create a file that contains gl o ss ary entries:
\d o c u m e n t c l a s s [ a 4 p a p e r ] { a r t i c l e }
\s e t l e n g t h {\t e x t w i d t h } { 3 2 0 p t } °/„ We c h o o s e t h i s e x t r e m e l y s m a l l \s e t l e n g t h {\t e x t h e i g h t } { 8 0 p t } % p a g e s i z e t o s e e t h e t w o - c o l u m n \u s e p a c k a g e { g l o s s } - % e f f e c t.
\m a k e g l o s s a r y \b e g i n { d o c u m e n t } p a g e 1
\g l o s s a r y { c o m p u t e r =\t e x t b f { C o m p u t e r } An e l e c t r o n i c d e v i c e.} \g l o s s a r y { S t o c k h o l m =\t e x t b f { S t o c k h o l m } T h e c a p i t a l o f S w e d e n.} \n e w p a g e p a g e 2
\g l o s s a r y { A t h e n s =\t e x t b f { A t h e n s } T h e c a p i t a l o f G r e e c e.} \g l o s s a r y { V i e n n a =\t e x t b f { V i e n n a } T h e c a p i t a l o f A u s t r i a.}
\p r i n t g l o s s a r y \e n d { d o c u m e n t }
The next th ing we d o is to r u n DTe X:
250 -φ- 8 B l B L I O G R A P H Y A N D I N D E X
$ l a t e x g l o s s
T h i s i s T e X, V e r s i o n 3.1 4 1 5 9 (Web2C 7.3.3.1 )
(./g l o s s.t e x L a T e X 2 e <20 00/06/01>
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/a r t i c l e.e l s D o c u m e n t C l a s s: a r t i c l e 2 0 0 0/0 5/1 9 v l.4 b S t a n d a r d L a T e X d o c u m e n t c l a s s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/s i z e 1 0.c l o ) )
(./g l o s s a r y.s t y
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/t e x/l a t e x/b a s e/i f t h e n.s t y ) )
W r i t i n g g l o s s a r y f i l e g l o s s.g l o No f i l e g l o s s.a u x.
[ 1 ]
No f i l e g l o s s.g l d
[ 2 ] (./g l o s s.a u x ) )
O u t p u t w r i t t e n on g l o s s.d v i ( 2 p a g e s, 320 b y t e s ).
T r a n s c r i p t w r i t t e n o n g l o s s.l o g.
Now, we have to r u n m a k e i n d e x
$ m a k e i n d e x - s g l o s s.i s t - o g l o s s.g l d g l o s s.g l o
T h i s i s m a k e i n d e x, v e r s i o n 2.1 3 [ 0 7 - M a r - 1 9 9 7 ] ( u s i n g k p a t h s e a ).
S c a n n i n g s t y l e f i l e ./g l o s s.i s t d o n e ( 6 a t t r i b u t e s
r e d e f i n e d, 0 i g n o r e d ).
S c a n n i n g i n p u t f i l e g l o s s.g l o.... d o n e ( 4 e n t r i e s a c c e p t e d,
0 r e j e c t e d ).
S o r t i n g e n t r i e s.... d o n e ( 1 0 c o m p a r i s o n s ).
G e n e r a t i n g o u t p u t f i l e g l o s s.g l d.... d o n e ( 1 7 l i n e s w r i t t e n,
0 w a r n i n g s ).
O u t p u t w r i t t e n i n g l o s s.g l d.
T r a n s c r i p t w r i t t e n i n g l o s s.i l g.
Here, we have to use two command-line switches: - s and -o. The first one is used to specify the name of the style file that the p r og r a m w i l l use to process the glossary. The second one is used to specify the name of the output file. The last th i ng we have to d o is to rerun T^TgX to include the g l o ss a ry i n ou r document. The typeset g l o s s a ry looks like this:
G l o s s a r y
Athens T h e c a p i t a l of Greece.
Stockholm T h e c a p it al of Swe­
den.
Computer A n electronic device.
Vienna T h e c a p it al of Austria.
8.6 G l o s s a r y P r e p a r a t i o n < > - 251
> Exercise 8.3 Write d o w n the style file that the authors used to typeset the index of this book. □
G r a p h i c s
One ability to include drawings, pictures, and line art i n m o d e m publications is more than necessary for any typesetting system. A l t h o u g h b y itself can be used to
produce drawings, such as those found i n mathematics books, it pr ov i d es facilities to include vir tually any k i n d of graphics file. I n this chapter, we describe the p i c t u r e environment, w h ic h can be used to create simple drawings. I n addition, we discuss h o w to add graphics to a I^TeX file. We also di s cu s s h o w one can create graphics with other packages. Graph ics inclusion was discussed earlier w h e n we dealt with floats (see Section 6.5 ), but here we w i l l g o into detail.
9.1 Drawing with the p i c t u r e Environment
The I^TeX2£ format contains a basic set of comman ds that can be used to d r a w illustra­
tions made u p from simple components, such as straight lines, arrows, simple curves, and text. A n advantage of u s i n g the p i c t u r e environment is that no special support is required from the device driver. Some limitations of the p i c t u r e environment include a limited range of slopes for lines or arrows, circles of only a fixed range of sizes, and li m­
itations on the thickness of slanted lines, circles, and oval shapes. These restrictions are to be removed i n an enhanced ver sion of the package k n o w n as pict2e, but this requires special features of the device dr iver that are not yet w i d e l y available. For this reason, we shall focus on the standard p i c t u r e environment, pointin g out the restrictions to the graphical components as we g o along.
A d ia gr am or illustration is started with the command
X b e g i n i p i c t u r e X x - s i j z e ^ - s t z e ) ( cc - o r i g i n, y - o r i g i n )
W i t h t h i s c o m m a n d, w e s p e c i f y t h a t t h e p l o t t i n g a r e a w i l l b e x - s i z e across and y - s i z e units upwards. The last two arguments sho ul d be used to optionally specify the lower- left corner of the plotting area when it is di fferent from the default of (0,0 ). For example, Lhe command
254 ^ 9 G r a p h i c s
\b e g i n { p i c t u r e } ( 2 0,4 0 )
sets u p a picture 40 u nits across b y 20 units upwards, while
\b e g i n { p i c t u r e } ( 2 0 0,1 1 0 ) ( - 1 0 0,- 1 0 )
defines a plotting area w i t h 200 horizontal units and 110 vertical u nits w i t h the lower- left comer not at (0,0 ) but this time at (— 1 0 0, — 1 0 ). The di me nsi ons of the units used in the figure are specified separately u s i n g
\s e t l e n g t h - C\u n i t l e n g t h } - C w i i i d i m e n s i o n s }
F o r e x a m p l e, \s e t l e n g t h {\u n i t l e n g t h } { 5 p t } s p e c i f i e s a u n i t o f 5 p t, a n d \s e t - I e n g t h - C\u n i t l e n g t h } { 0. 1mm} i n d i c a t e s a u n i t o f 0.1 m m. T h i s m a k e s d r a w i n g m o r e s t r a i g h t f o r w a r d s i n c e o n e c a n u s e c o n v e n i e n t d i m e n s i o n s s u c h a s t h o s e o f t h e o r i g i n a l d a t a a n d t h e n s c a l e t h e f i g u r e b y a d j u s t i n g t h e v a l u e o f t h e u n i t l e n g t h. N o t e t h a t s c a l i n g d o e s n o t a f f e c t t h e t h i c k n e s s o f l i n e s o r t h e s i z e o f t e x t a n d s y m b o l s. T o a c h i e v e s c a l e d m a g n i f i c a t i o n o f a l l o f t h e i t e m s i n a p i c t u r e, t h e graphicx p a c k a g e i s r e q u i r e d.
The components of a picture are placed w it h the comman d
\p u t ( x - c o o r d i n a t e, y - c o o r d i n a t e ) { c o m p o n e n t }
w h i c h a l s o i n c l u d e s t h i n g s l i k e text, e q u a t i o n s, a n d s y m b o l s f r o m Ι ^ Τ β Κ a n y w h e r e i n t h e p i c t u r e, f o r e x a m p l e
\p u t ( 1 0,1 0 ) { $\d i a m o n d $ }
p l a c e s a o s y m b o l i n o u r p i c t u r e at t h e c o o r d i n a t e ( 1 0,1 0 ), a l i g n e d u p o n i t s r e f e r e n c e p o i n t. T h i s i s u s e f u l f o r g r a p h p l o t t i n g a n d t h e l a b e l i n g o f a f i g u r e. I t i s w o r t h m e n t i o n i n g t h a t w e c a n u s e t h e \p u t c o m m a n d t o p l a c e t h i n g s e v e n o u t s i d e t h e s p e c i f i e d p l o t t i n g ar ea. F o r e x a m p l e, t h e v e r t i c a l b a r at t h e r i g h t w a s p l a c e d at p o i n t (1 0 5,0 ) i n a p l o t t i n g a r e a w i t h z e r o h o r i z o n t a l a n d v e r t i c a l u n i t s!
W e s h a l l n o w i n t r o d u c e t h e b a s i c d r a w i n g c o m p o n e n t s b e f o r e g i v i n g s o m e i l l u s t r a ­
t i o n s o f h o w t h e y m a y b e c o m b i n e d t o p r o d u c e d i a g r a m s a n d p l o t s.
9.1.Ί I n v i s i b l e a n d F r a m e d B o x e s
T h e a d d i t i o n o f a \m a k e b o x c o m m a n d a l l o w s u s t o p o s i t i o n s y m b o l s a n d t ex t w i t h i n a n i n v i s i b l e b o x a n d t o s h i f t t h e r e f e r e n c e p o i n t a r o u n d. T h e s y n t a x o f t h e c o m m a n d i s
\m a k e b o x ( c c, y ) [ p o s i t i o n ] { t e x t }
a n d i t g e n e r a t e s a n i n v i s i b l e b o x w i t h d i m e n s i o n s x
units b y y
units. A n optional argument for position determines the alignment w i t h i n the bo x (i.e., lleft, right, top, and bottom). A useful trick is to enclose text or a symbol i n a b o x of zero width; this has the effect of shifting the reference point to its center, w h i c h is h a n d y for plotting. Thus,
\p u t ( 1 0,1 0 ) {\m a k e b o x ( 0,0 ) { $\d i a m o n d $ } }
g.i D r a w i n g w i t h t h e p i c t u r e E n v i r o n m e n t -φ- 255
n o w places ou r earlier d i a m o n d centered over the point (10,10 ).
Other b o x - m a k i n g c omman ds include
\f r a m e b o x ( c c,y ) [ p o s i t i o n ] { t e x t y
w h i c h i s s i m i l a r t o \m a k e b o x b u t p l a c e s a f r a m e a r o u n d t h e r e c t a n g l e, a n d
\d a s h b o x {d a s h _ d i m e n s i o n } ( x,y ) [ p o s i t i o n ] { t e x t y
w h i c h e n c l o s e s t h e r e c t a n g l e i n a d a s h e d f r a me, w i t h t h e w i d t h o f t h e d a s h e s d e t e r m i n e d b y t h e s i z e o f d a s h _ d i m e n s i o n,
> · E x e r c i s e 9.1 P u t a ζ? i n a 1 0 x 1 0 f r a m e at p o i n t (1 0,2 0). □
9.1.2 L i n e s a n d A r r o w s
T h e c o m m a n d
\l i n e( x - a m o u n t, y - a m o u n t ) { u n i t s _ a c r o s s y
p r o d u c e s a l i n e w i t h a s l o p e o f y - a m o u n t/x - a m o u n t w i t h its size determined b y the nu mber of horizontal u n i t s _ a c r o s s; for example,
\p u t ( 0,0 ) A l i n e ( 1,2 ) { 1 0 »
w i l l create the f o l l o w i n g line placed w i t h the bottom-left comer at the point (0,0 ).
The slope of lines i n the p i c t u r e environment is restricted in that the values of x - a m o u n t, y - a m o u n t must be integers between the range —6 and 6, and, i n a d d i ­
tion, they can have n o common d i v i s o r greater than one. Leg al values include (1,2 ) and (0,- 1 ), and examples of values that are illegal include (1.5,2 ) and (4,- 8 ). The smallest line is limited to a length of about 10 pt, or 3.6 mm. There are two prede­
fined thicknesses of (sloping) lines available. The default setting is \t h i n l i n e s, w h i c h
looks like ----------, whil e the \t h i c k l i n e s declaration produces a line like this ------------.
Other line thicknesses can be requested w i t h the W i n e t h i c k n e s s i b r e a d t/i } command (e.g., \l i n et h i c k n ess{l mm} w i l l produce a line like this ^ ^ ^ ™ ^ and \l i n et h i c k -
n e s s {
0
.
05
mm} w i l l produce a line like this -----------). The declaration \l i n e t h i c k n e s s
o n l y applies to lines that are horizontal or vertical. L i n e s that are slanted, circles, or oval shapes are not altered.
A r r o w s are d r a w n u s i n g a similar command
\v ec t o r (as- a m o u n t, y - a m o u n t ) { u n i t s _ a c r o s s y
t h a t w o r k s i n t h e s a m e w a y a s t h e \l i n e c o m m a n d b u t i s f u r t h e r r e s t r i c t e d t o v a l u e s o f x - a m o u n t and y - a m o u n t that are integers between —4 and 4. Thus, u s i n g units of
1 mm, the command \v e c t o r ( - 1,0 ) { 10} gives u s this a r r ow ------- w i t h its reference
point o n the right-hand side. A n arrow that is specified to have a length of zero is an exception to this i n that the r eference point is at the tip of the arrow.
256 -Φ 9 G r a p h i c s
9.1.3 C i r c l e s a n d C u r v e d S h a p e s
Circles are produced w i t h the c ommand \c i r c l e i d i a m e t e r } but have a limited range of sizes, the closest one to the requested diameter be i ng produced. D i s k s are filled circles p rod uced w i t h the \c i r c l e * command. So, w i t h 1 m m units, requesting a \c i r - c l e { 3 > produces Ο , and a \c i r c l e * { 3 > request gives u s a Φ . The reference point of a circle or d i s k is its center. Note also, that the m a x i m u m size of a d i s k is 15 pt, and the m a x i m u m size of a circle is 40 pt.
Two other curved elements can be d r a w n w i t h the p i c t u r e environment: ovals and Bezier curves. O v a l s consist of rectangles w i t h r ou n d e d comers and are i n v o ke d w it h the comman d
\o v a l ( w i d t h,h e i g h t ) [ p a r t ]
w h i c h p r o d u c e s a n o v a l w i t h r o u n d e d c o m e r s s e l e c t e d f r o m t h e q u a r t e r c i r c l e s t h a t a r e a v a i l a b l e o n t h e s y s t e m. T h e s e a r e c h o s e n t o m a k e i t a s c u r v e d a s p o s s i b l e. T h e p a r t argument is an option that specifies w h i c h parts of the oval we w o u l d like I^TeX to draw: left, right, top, or bottom. A single letter produces the indicated half (e.g., [r] gives u s the right half of the oval), and two letters result i n a cor r es po ndin g quarter be i ng d r a w n (e.g., [ l b ] produces the lower-left comer). I f we try \o v a l ( 2,4 ) [ t ], then
this oval is d r a w n ί Λ.
A quadratic Bezier curve has three control points specified b y the c ommand
\q b e z i e r [ n u m b e r ] ( x\, y 1) ( x 2,y i ) ( X 3, y z )
a n d t h e c u r v e i s d r a w n f r o m ( x i,y i ) t o (cc3, y 3 ) w i t h ( x 2r y i ) t h e g u i d i n g p o i n t. F o r e x a m p l e, \q b e z i e r ( 1,1 ) ( 5,2 0 ) ( 1 0,5 ) p r o d u c e s a c u r v e l i k e t h i s:
Bezier curves are d r a w n so that the curve at ( x i,y i ) is tangential to an i m ag in ar y line between (as 1,2/1) and ( x i, y i ), whi l e the same curve at ( x ^, 3/3 ) is tangential to an i m a g i n a r y line between ( x 3/ y 3) and { χ ι,ν ι ) · B e ar i n g this i n mind, it is possible to make two curves join u p smoothly b y e n s u r i n g that they have the same tangent at the point where they join. The optional argument n u mb e r requests that the curve be made u p of the specified nu mber of points (e.g., \q b e z i e r [ 2 5 ] ( 0,0 ) ( 2 0,2 ) ( 0,4 ) produces
this curve . ’, w h i c h is made u p of 25 points).
9.1.4 T h e C o n s t r u c t i o n o f P a t t e r n s
Repeated patterns are constructed from a compact specification of regularly occurring picture com p on ents. They are p r o d u c ed wi th
9· ΐ D r a w i n g w i t h t h e p i c t u r e E n v i r o n m e n t -φ- 257
\m u l t i p u t ( x - c o o r d i n a t e, y - c o o r d i n a t e') ( x - s h i f t, y - s h i f t ) { n u m b e r } · { c o m p o n e n t }
This makes it a simple matter to generate hatched s h a d i n g s and ruler markings. For example,
\p u t ( 0,1.5 ) { M i n e ( 1,0 ) { 2 0 } }
\m u l t i p u t ( 0.4 5,0 ) ( 1,0 ) { 2 0 } {\m a k e b o x ( 0,0 ) %
{ {\f o o t n o t e s i z e /} } }
produces
////////////////////////////////////////
We w i l l n o w lead y o u t h r o u g h some examples that illustrate h o w the simple compo­
nents available in the p i c t u r e environment can be combined to produce more elaborate drawings. The examples are all d r a w n i n the default C ompu ter M o d e m family of fonts.
9.1.5 A n E x a m p l e o f t h e C a l c u l a t i o n o f t h e A r e a o f a S q u a r e
I n this first example, we shall d r a w a box, a d d arrows and labels, and ad d a formula for its area. The basic p i c t u r e environment is set u p w i t h a un i t length of 0.15 mm, di me nsions of 220 units across and 140 units vertically and w i t h the lower-left corber at ( —2 5,0 ). This is specified w i t h the sequence of commands
\s e t l e n g t h {\u n i t l e n g t h } { 0. 15mm}
\b e g i n { p i c t u r e } ( 2 2 0,1 4 0 ) ( - 2 5,0 )
\e n d { p i c t u r e }
Initially, n o t h i n g is drawn, but b y a d d i n g successive picture-drawing commands i n the b o d y of the p i c t u r e environment and r u n n i n g the I^Te X p r o g r a m and a D V I viewer, we can watch the figure b u i l d up. B y r u n n i n g Ι^ΤβΧ each time a component is added or modified, we also catch errors and deal w i t h them as they occur.
Next, we d r a w the b o x b y inserting the line
\p u t ( 0,0 ) {\t h i c k l i n e s \f r a m e b o x ( 1 0 0,1 0 0 ) { } }
i n the b o d y of the environment followed b y four lines that produce m a r k i n g s delineat­
i n g the x dime nsions
\p u t ( - 1.5,1 0 5 ) {\l i n e ( 0,1 ) { 1 6 } } ------------------------------
\p u t ( 1 0 1.2,1 0 5 ) {\l i n e ( 0,1 ) { 1 6 } }
\p u t ( 1 0 5,1 0 1.2 ) {\l i n e ( 1,0 ) { 1 6 } }
\p u t ( 1 0 5,- 1.5 ) { M i n e ( l,0 ) { 1 6 } }
Double-headed arrows are d r a w n as a series of vectors b y inserting these commands:
258 -Φ 9 G r a p h i c s
\p u t ( 5 0,1 1 3 ) {\v e c t o r ( 1,0 ) { 5 0 } }
\p u t ( 5 0,1 1 3 ) {\v e c t o r ( - 1,0 ) { 5 0 } }
\p u t ( 1 1 3,5 0 ) {\v e c t o r ( 0,1 ) { 5 0 } }
\p u t ( 1 1 3,5 0 ) {\v e c t o r ( 0,- 1 ) { 5 0 } }
W e t h e n i n s e r t c o m m a n d s f o r o u r l a b e l s o f x ( i n \s c r i p t s i z e )
\p u t ( 5 0,1 2 6 ) {\s c r i p t s i z e \m a k e b o x ( 0,0 ) { $ x $ } }
\p u t ( 1 2 6,5 0 ) {\s c r i p t s i z e \m a k e b o x ( 0,0 ) { $ x $ } }
F i n a l l y, w e a d d t h e e q u a t i o n f o r t h e a r e a o f a s q u a r e ( s e t i n a \s m a l l s i z e f o n t ) \p u t ( 1 9 0,5 0 ) {\s m a l l $\t e x t r m { A r e a } = χ Λ2 $ }
I n c o m b i n a t i o n, t h e s e p i c t o r i a l e l e m e n t s p r o d u c e t h i s f i g u r e.
x A r e a — x 2
9.1.6 A D i a g r a m f o r t h e C a l c u l a t i o n o f t h e A r e a o f a C i r c l e
F o l l o w i n g a p a t t e r n s i m i l a r t o t h e l a s t e x a m p l e, w e b u i l d u p a g r a p h i c f o r t h e a r e a o f a c i r c l e. O n c e a g a i n, t h e p i c t u r e s t a r t s w i t h a n e m p t y p i c t u r e e n v i r o n m e n t w i t h a u n i t l e n g t h o f 0.15 m m
\s e t l e n g t h {\u n i t l e n g t h } { 0.15mm}
\b e g i n { p i c t u r e } ( 2 2 0,1 4 0 ) ( - 2 5,0 )
\e n d { p i c t u r e }
I n t o t h i s w e i n s e r t a c o m m a n d t o d r a w a c i r c l e t h a t i s a s n e a r 90 u n i t s i n d i a m e t e r as t h e s y s t e m c a n p r o v i d e:
\p u t ( 5 0,5 0 ) { {\t h i c k l i n e s \c i r c l e { 9 0 } } }
W e b u i l d u p d i a m e t e r a n d r a d i u s a r r o w s as a s e r i e s o f v e c t o r s b y i n s e r t i n g t h e c o m ­
m a n d s
\p u t ( 5 0,5 0 ) {\v e c t o r ( 3,1 ) { 4 4 } }
\p u t ( 5 0,5 0 ) {\v e c t o r ( - 3,- 1 ) { 4 4 } }
\p u t ( 5 0,5 0 ) {\v e c t o r ( - 1,3 ) { 1 4.5 } }
a n d t h e n a d d l a b e l s f o r d a n d r:
\p u t ( 4 5,3 4 ) {\s c r i p t s i z e $ d $ }
9· ΐ D r a w i n g w i t h t h e p i c t u r e E n v i r o n m e n t -φ- 259
Finally, we insert statements to a d d the equations for the area of a circle:
\p u t ( 1 9 0,5 0 ) {\s m a l l $\t e x t r m { A r e a } = \f r a c {\p i d ~ 2 } { 4 } $ o r $\p i r"2 $ }
Together, the w hole sequence of statements generates this drawing:
A r e a = Έψ - or n r 2
9.1.7 B o x - a n d - W h i s k e r P l o t s i n t h e S t y l e o f J o h n W. T u k e y
B o x - a n d - w h i s k e r p l o t s, c a l l e d b o x p l o t s f o r s h o r t, a r e a s i m p l e a n d e l e g a n t w a y o f s u m ­
m a r i z i n g i n f o r m a t i o n a b o u t t h e c e n t r a l t e n d e n c y, r a n g e, a n d s h a p e o f t h e d i s t r i b u t i o n o f s a m p l e d a t a. T h e y w e r e d e v e l o p e d a t s o m e l e n g t h, f r o m e a r l i e r i d e a s, i n T u k e y's c l a s s i c (1 9 7 7) b o o k Expl orat ory Dat a Anal ys i s, w h i c h made them popular. The emphasis is o n robust statistics that are easily calculated and insensitive to extreme observations. We shall plot the m a in features present i n data collected o n 219 of the w o r l d's volcanos and produce a v e r sion of T u k e y's h a n d - d r a w n b o x plot suitable for reproduction i n a document typeset in Ι£ΓεΧ (see [28] pages 40- 41, and page 73). We b e g in w i t h an empty picture environment that contains a declaration that all of the text i n the figure w i l l be i n a sans serif font.
{\s f f a m i l y
\s e t l e n g t h {\u n i t l e n g t h } { 0.33mm}
\b e g i n { p i c t u r e } ( 5 0,2 6 0 ) ( - 3 0,0 )
\e n d { p i c t u r e } }
A median line represents the central tendency of the dataset and is larger than 50% of the observations and smaller than the r emainin g 5 0 %. This is d r a w n b y inserting the comman d
\p u t ( 4 0,6 5 ) {\l i n e ( 1,0 ) { 2 0 } }
We a d d the box that contains the central 5 0 % of observations, r a n g i n g between the u p p e r and l ower quartiles. A lower quartile is larger than 2 5 % of the observations, and an u p p e r quartile is larger than 75% of the observations. This is done w i t h the statement
\p u t ( 4 0,3 7 ) {\f r a m e b o x ( 2 0,5 8 ) { } }
26ο -Φ 9 G r a p h i c s
T h e f i r s t o b s e r v a t i o n s l y i n g w i t h i n 1.5 t i m e s t h e d i f f e r e n c e b e t w e e n t h e l o w e r a n d u p p e r q u a r t i l e s a r e t h e s o - c a l l e d a d j a c e n t v a l u e s, a n d t h e y a r e m a r k e d t o i n d i c a t e t h e l i m i t s t o t h e r a n g e o f t y p i c a l v a l u e s.1
\p u t ( 5 0,1 8 5 ) {\c i r c l e { 2 } }
\p u t ( 5 0,6 ) {\c i r c l e { 2 } }
W e c o n n e c t t h e a d j a c e n t v a l u e s t o t h e q u a r t i l e b o x w i t h t w o t h i n l i n e s, c a l l e d t h e w h i s k e r s, u s i n g t h e s e c o m m a n d s:
\p u t ( 5 0,7 ) { M i n e ( 0,1 ) { 3 0 } }
\p u t ( 5 0,9 5 ) {\l i n e ( 0,1 ) { 8 9 } }
A n y v a l u e s e x t e r n a l t o t h e r a n g e d e f i n e d b y t h e a d j a c e n t v a l u e s a r e c o n s i d e r e d e x t r e m e a n d p o s s i b l y a t y p i c a l. W e d r a w t h e s e i n w i t h t h e s e s t a t e m e n t s:
\p u t ( 5 0,2 0 0.5 ) {\c i r c l e { 2 } }
\p u t ( 5 0,1 9 7 ) {\c i r c l e { 2 } }
\p u t ( 4 7,1 9 3 ) {\c i r c l e { 2 } }
\p u t ( 5 3,1 9 3 ) {\c i r c l e { 2 } }
\p u t ( 5 0,1 9 0 ) {\c i r c l e { 2 } }
\p u t ( 5 0,2 ) {\c i r c l e { 2 } }
W e d r a w a f l o o r t o t h e d i a g r a m a n d s h a d e b e n e a t h i t t o i n d i c a t e t h e l i m i t s o f p o s s i b l e m e a s u r e m e n t w i t h t h e s e c o m m a n d s:
\p u t ( 2 4,0 ) {\l i n e ( 1,0 ) { 5 2 } }
\m u l t i p u t ( 2 6.5,- 4.5 ) ( 4,0 ) { 1 3 } { %
\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e /} } }
L a b e l s a r e a d d e d f o r t h e a d j a c e n t v a l u e s w i t h t h e s t e t e m e n t s
\p u t ( 5 4,1 8 0 ) { {\t i n y T u p u n g a t i t o } }
\p u t ( 5 4,5 ) { {\t i n y A n a k K r a k a t a u } }
a n d w e l a b e l t h e e x t r e m e o b s e r v a t i o n s w i t h t h e s e a d d i t i o n a l c o m m a n d s:
\p u t ( 5 4,1 9 9 ) { {\t i n y G u a l l a t i r i } }
\p u t ( 2 8,1 9 6 ) { {\t i n y L a s c a r } }
\p u t ( 1 2,1 9 1 ) { {\t i n y K i l i m a n j a r o } }
\p u t ( 5 6,1 9 1.5 ) { {\t i n y C o t a p a x i } }
\p u t ( 5 4,1 8 6 ) { {\t i n y M i s t i } }
\p u t ( 2 0,1.5 ) { {\t i n y I l h a N o v a } } -------------------------------
F i n a l l y, w e p u t t h e v e r t i c a l n u m e r a l s a n d a l a b e l f o r t h e m e a s u r e m e n t u n i t s w i t h t h i s g r o u p o f s t a t e m e n t s:
l. Note that Tukey's figure connected the whiskers to two values that are close to, although not the actual, adjacent values.
9· ΐ D r a w i n g w i t h t h e p i c t u r e E n v i r o n m e n t -φ- 261
\p u t ( - 1 0,- 2 ) {\m a k e b o x ( 0,0 ) [ r ] {\s c r i p t s i z e 0 } }
\p u t ( - 1 0,4 8 ) {\m a k e b o x ( 0,0 ) [ r ] {\s c r i p t s i z e 5,0 0 0 } }
\p u t ( - 1 0,9 8 ) {\m a k e b o x ( 0,0 ) [ r ] {\s c r i p t s i z e 1 0,0 0 0 } }
\p u t ( - 1 0,1 4 8 ) {\m a k e b o x ( 0,0 ) [ r ] {\s c r i p t s i z e 1 5,0 0 0 } }
\p u t ( - 1 0,1 9 8 ) {\m a k e b o x ( 0,0 ) [ r ] {\s c r i p t s i z e 2 0,0 0 0 } }
\p u t ( - 1 8, 2 0 8 ) {\v e c t o r ( 0,1 ) { 1 5 } }
\p u t ( - 3 0,2 3 0 ) { {\s c r i p t s i z e\s h o r t s t a c k { H e i g h t\\ ( f e e t ) } } }
Note that the command \s h o r t s t a c k puts the “ w o r d s" that make u p its argument one above the other. These w o r d s must be separated w i t h \\. Back to o u r example! W h e n the complete sequence of statements is r u n th r o u g h and viewed or printed, we obtain the f o l l o w i n g plot.
Height
(feet)
20,000
. o Gallatin
Lascar o Kilimanjaro 0 0 Cotapaxi ° Misti Tupungatito
15,000
10,000
5,000
... .. 0 Anak Krakatau
llha Nova o
2 /////////////-----------------------------------------------------------------------
The calculations are most easily carried out in a statistical or spreadsheet software package and the coordinates of the points pasted into the Ι^ΤβΧ document, where they can be inserted into the relevant comman ds described above.
9.1.8 A S c a t t e r P l o t o f T e m p e r a t u r e
I n this example, we demonstrate a simple scatter plot for the exploration of temperature measured d u r i n g the course of a 2 4 -h our period in Botswana, taken i n December 1940 (data from Pearson and Hartley, reproduced i n [6], page 352). The figure w i l l s h o w a
s ub sampl e of the origi nal points suitable for d emonstration p u r p o s es. The data pairs
2 0 2 - φ 9 G r A p h i c s
(time/temperature pairs) that we w i l l use are: (1,6 5 ), (2,6 9 ), (3,7 4 ), (4,7 9 ), (5,8 3 ), (6,8 6 ), (7,8 8 ), (8,9 0 ), (9,9 0 ), (1 0,9 0 ), (1 1,8 9 ), (1 2,8 8 ), (1 3,8 5 ), (1 4,8 0 ), (15,7 6 ), (1 6,7 4 ), (1 7,7 3 ), (1 8,7 2 ), (1 9,7 1 ), (2 0,6 9 ), (2 1,6 8 ), (2 2,6 7 ), (2 3,6 7 ), and (2 4,6 6 ). Moreover, we use the formulas x — t ■ 1 0 0 0/2 5 and y — ( T — 6 5 ) · 1 0 0 0/( 9 5 — 6 5 ) to scale o u r data for plotting.
This time, we be gin b y defining a plotting symbol to save t y p i n g later, and to allow for easy subsequent changes i n ou r plotting symbol just b y ch a n g i n g a single statement.
\n e w c o m m a n d {\p l o t s y m b o l } { %
\p u t ( 0,0 ) {\s m a l l \m a k e b o x ( 0,0 ) { + } } }
Then, the basic picture environment is defined w it h a unit length of 0.0 8 m m
{\s f f a m i l y
\s e t l e n g t h {\u n i t l e n g t h } { 0.08mm}
\b e g i n { p i c t u r e } ( 1 1 0 0,1 1 0 0 )
\e n d { p i c t u r e } }
and we proceed b y inserting picture-drawing statements in the b o d y of the p i c t u r e environment, as before. First, we ad d some axes
\p u t ( 0,0 ) {\l i n e ( 1,0 ) { 1 0 0 0 } }
\p u t ( 0,0 ) {\l i n e ( 0,1 ) { 1 0 0 0 } }
followed b y tick mar ks o n the axes
\m u l t i p u t ( 0,- 1 0 ) ( 2 0 0,0 ) { 6 } {\l i n e ( 0,1 ) { 1 0 } }
\m u l t i p u t ( - 1 0,0 ) ( 0,1 8 9 ) { 6 } {\l i n e ( 1,0 ) { 1 0 } }
We insert the comman ds for the X-axis numerals, each numeral is centered over its coordinate b y enclosing it in a \m a k e b o x of zero w i d t h
\p u t ( 0,- 4 0 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 0 } } }
\p u t ( 2 0 0,- 4 0 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 5 } } }
\p u t ( 4 0 0,- 4 0 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 1 0 } } }
\p u t ( 6 0 0,- 4 0 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 1 5 } } }
\p u t ( 8 0 0,- 4 0 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 2 0 } } }
\p u t ( 1 0 0 0,- 4 0 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 2 5 } } }
and the c omman ds for the y-axis numerals
\p u t ( - 4 0,0 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 6 5 } } }
\p u t ( - 4 0,1 8 9 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 7 0 } } }
\p u t ( - 4 0,3 7 9 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 7 5 } } }
\p u t ( - 4 0,5 6 8 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 8 0 } } }
\p u t ( - 4 0,7 5 7 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 8 5 } } }
\p u t ( - 4 0,9 4 7 ) {\m a k e b o x ( 0,0 ) { {\f o o t n o t e s i z e 9 0 } } }
9· ΐ D r a w i n g w i t h t h e p i c t u r e E n v i r o n m e n t -φ- 263
We label o u r axes b y inserting the statements
\p u t ( 5 0 0,- 1 1 0 ) {\m a k e b o x ( 0,0 ) { { %
\f o o t n o t e s i z e T i m e i n h o u r s s i n c e m i d n i g h t J } } - \p u t ( - 1 0 5,1 0 0 0 ) {\m a k e b o x ( 0,0 ) { { %
\f o o t n o t e s i z e Temp $ ~\c i r c $ F } - ] - } -
and, finally, we plot o u r data points
\p u t ( 4 0, 8 ) {\p l o t symbol}·
\p u t ( 1 2 0, 3 1 5 ) { X p l o t s y m b o l ) ·
\p u t ( 2 0 0, 5 9 1 ) {\p l o t s y m b o l } - \p u t ( 2 8 0, 7 7 0 ) {\p l o t s y m b o l }
\p u t ( 3 6 0, 8 4 5 ) - C\p l o t s y m b o l ) ·
\p u t ( 4 4 0, 7 9 7 ) {\p l o t s y m b o l }
\p u t ( 5 2 0, 6 6 5 ) - C X p l o t s y m b o l }
\p u t ( 5 6 0, 5 1 4 ) { X p l o t s y m b o l }
\p u t ( 6 0 0, 3 7 2 ) { X p l o t s y m b o l ) ·
\p u t ( 6 8 0, 2 7 1 ) {\p l o t s y m b o l } - \p u t ( 7 6 0, 1 8 6 ) {\p l o t s y m b o l 3 - \p u t ( 8 4 0, 1 0 4 ) - C X p l o t s y m b o l }
\p u t ( 9 6 0, 2 9 ) - [\p l o t symbo l}-
C o m b in e d together, this sequence of commands d r a w s the f ol l o win g scatter plot.
Temp °F 90
+
H -
85 -
80 -
75 -
70 -
+
+
+
+
+
+
+
65
-4=-
+
Time in hours since midnight
5 10 15 20
25
264 ·Φ 9 G r a p h i c s
A s w h e n d r a w i n g a bo x plot, the reader w i l l often find it convenient to first d o the calculation of the coordinates i n a statistical or spreadsheet software package and then import the points into their I^T^X document for editing into a series of c omman ds for the p i c t u r e environment.
9.1.9 p i c t u r e - R e l a t e d P a c k a g e s a n d S y s t e m s
There are a nu mber of packages that are either based o n the p i c t u r e environment or extend it. A l t h o u g h there are m a n y such packages, we th i nk that it is better to use a system such as x t e x c a D b y Johannes Sixt, w h i c h has a graphical user interface and can d r a w arbitrary circles, lines, and vectors of arbitrary slope. The output of the p r o g r a m is usable once the eepic package is loaded. This package was o r i gi nal l y created b y C o n r a d K w o k and w as last updated b y Piet v a n Oostrum. A n important thing that we must note is that pictures generated w i t h x t e x c a d cannot be u s ed w i t h pdfl^TEX.
The bar package b y Joachim Bleser and E d m u n d L a n g can be u s e d to d r a w bar gr ap hs w it h LT^X. N o w a d a y s, most people use spreadsheets to generate really fancy bar graphs, but nevertheless we believe it is w o r t h the trouble to experiment w i t h this package, so we w i l l briefly present it.
The package defines the environment b a r e n v, in w h i c h we specify the bars and the axis. The current implementation of the package offers eight different patterns that are used to “ c o l o r" the bars:
18
The bars are specified w i t h the \b a r command, w h i c h has two required and one optional argument:
\baoc-iheighty-ipattemy [ d e s c r i p t i o n ]
h e i g h t is the height of the bar i n points and p a t t e r n a number from one to eight denoting one of the patterns i n the figure above. The optional d e s c r i p t i o n is just the description of an i n d i v i d u a l bar. Here is a simple example:
\b e g i n { b a r e n v }
\s e t n u m b e r p o s { e m p t y } \s e t s t r e t c h { 3.5 } \b a r { 1 0 } { l }
\b a r { - 1 0 } { l }
\b a r { - 5 } { l }
\b a r { 1 5 } { l }
\b a r { 5 } { l }
\e n d { b a r e n v }
Before describing the m eanin g of the v ar iou s commands, we must point out that the example above also s h o ws a limitation of the package: it produces p o o r results w h e n
9· ΐ D r a w i n g w i t h t h e p i c t u r e E n v i r o n m e n t -φ- 265
46
24 24
lines overlap. The comman d \s e t n u m b e r p o s controls where the nu mber denoting the height of the bar w i l l go. The possible values are: e m p t y, a x i s (under or above the x-axis), down (under the bar), i n s i d e (inside the bar), o u t s i d e (outside the bar), and u p (on top of the bar). The command \s e t s t r e t c h is u s e d to vertically stretch the bar graph. Here is another example:
\b e g i n { b a r e n v }
\s e t s t r e t c h { 2 }
\s e t n u m b e r p o s { u p }
\s e t w i d t h { 2 0 } - \s e t h s p a c e { 0.2 } \s e t y a x i s { 0 }"C 5 0 } { 1 0 3 ·
\b a r { 4 9 } { 6 } [ U S ]
\b a r { 4 6 > { 6 > [ S E ]
\b a r { 2 4 } { 6 } [ U K ]
\b a r { 2 4 > { 6 > [ D E ]
\b a r { 1 7 > { 6 > [ F R ]
S E U K D E F R \e n d { b a r e n v } -
The c ommand \s e t w i d t h is u s e d to set the w i d t h of the bars. Moreover, the command \s e t h s p a c e has one argument, w h i c h denotes the distance between bars; this number is multiplied w i t h the actual w i d t h of the bars to get the distance between bars. The comman ds \s e t x a x i s and \s e t y a x i s are u sed to d r a w the x and y axes, respectively. Both commands have three arguments: the ori gi n, the end, and a st ep. Furthermore, the comman ds \s e t x n a m e and \s e t y n a m e have one argument w h i c h is the text that w i l l be disp l ay ed o n the x and y axes, respectively. We present one more example that sho ws some other capabilities of the package:
I
I
17
■
U S S E U K D E F R,
\b e g i n { b a r e n v } -
\h l i n e o n
\s e t l i n e s t y l e { d o t t e d } \s e t s t r e t c h { 2 > \s e t n u m b e r p o s { u p } \s e t w i d t h { 2 0 ) - \s e t h s p a c e { 0.2 } \s e t d e p t h { 1 0 ) - \s e t y a x i s - C 0 M 5 0 M l 0 ] -
\e n d { b a r e n v j -
The comman d \h l i n e o n activates the ba ckg r ou n d horizontal lines as i n the example above. There are two line styles, s o l i d and dotted, and they can be selected w i t h the c omman d \s e t l i n e s t y l e. The 3D effect is achieved w i t h the comman d \s e t d e p t h. This comman d has one argument, w h i c h must be a nu mber greater than or equal to ten. The comman d \s et p r ec i s i o n is u s ed to d efine the n u m b er of d i g i t s to b e printed
266 -Φ 9 G r a p h i c s
after the decimal sign. We s h o u l d note at this point that p a t t e r n s 5 and 6 are not d r a w n correctly, unless we use the eepic package.
9.2 The G n u p l o t System
G n u p l o t is a free software package that removes muc h of the tedious calculation re­
quired w h e n plotting data, and also makes it possible to plot fitted curves and complex functions b y constructing the curves from small line fragments. Since the resulting graphics are generated u s i n g standard p i c t u r e commands, they are h i g h l y portable. However, they can create large files that m a y consume I ^ X's memory. This figure is a scatter plot of data from a stu dy of child witness testimony, b y Graeme, Hutcheson, and colleagues [14]. It d i s p l a y s the empirical relationship between the accuracy and completeness of child re n's statements i n two age groups, adapted for reproduction w i t h k i n d pe rmission of the authors. A n advantage of u s i n g G n u p l o t over some other graphics software is that, since the output can be entirely i n Ι£ΓεΧ, the user can easily m o d i f y the file (e.g., to change labels or m a n u a l l y move adjacent plotting symbols for increased clarity).
100
90
80
accuracy (%) 70
1 1 1 1 1 1 1 o * * *
* * * * *
* * *
o <y o *
o * *
* * * - £
o °
*
o o *
o
60
o
o
50
5 - 6 year old O
40
8 - 9 year old *
0 10 20 30 40 50 60 70 80
completeness (%)
9.3 The graphicx Package
I n this section, we describe the graphicx package b y D a v i d Carlisle. The package p r o ­
v i d e s a nu mber of options that sh o u l d be u s e d on l y w h e n the appropriate driver p r og r am w i l l be u s e d to display, print, or transform the resulting D V I file. The default option is d v i p s for u s e w i t h d v i p s. O t h er u s eful options inclu de the options pd f t ex
9-3 T h e g r a p h i c x P a c k a g e <>- 267
(see Section 9.5 ), x d v i (for use w it h the x d v i previewer), d v i w i n (for use w i t h the d v i - w i n previewer), and d v i p d f (should be u s e d w h e n transforming a D V I file u s i n g the d v i p d f converter). However, at most installations, the file g r a p h i c s. c f g is used to a u ­
tomatically load the approriate option w h e n processing an inp ut file w i t h a particular typesetting engine.
The most important command of the package is \i n c l u d e g r a p h i c s
\i n c l u d e g r a p h i c s [ k e y v a l - l i s t ] { f i l e }
w h e r e f i l e is the name of the graphics file (usually a PostScript file) to be included and k e y v a l - l i s t is a comma-separated list of parameters i n the form paramet er=value. The available parameters are:
b b This sets the b o u n d i n g box and is g i v e n i n the form b b=a b e d, where ( a, b ) are the coordinates of the lower-left comer of the graphics and ( c, d ) the coordinates of the upper-right comer. I f these are not set, I £ I e X w i l l try to find this information inside the graphics file. If y o u want to m o d i f y it, then G h o s t V i e w sh o ws the coordinates of the current position of the mou se i n its graphics window, b b l l x.b b l l y,b b u r x,b b u r y These also set the b o u n d i n g b o x and are o n l y here for compatibility reasons w i t h older packages. b b l l = a,b b l l y = b,b b u r x = c,b b u r y = d is the same as bb= a b e d. n a t w i d t h,n a t h e i g h t A g a i n, these set the b o u n d i n g b o x: n a t h e i g h t = h,n a t w i d t h = w i s equivalent to bb=0 0 h w. v i e w p o r t This modifies the b o u n d i n g b o x that is already specified i n the graphics file.
The four values specify a b o u n d i n g bo x rel at i ve to the origi nal b o u n d i n g box. t r i m The same as above but n o w the fou r values specify amounts to be r emoved from the coordinates of the b o u n d i n g box specified i n the graphics file, h i r e s b b This is a Boolean parameter w i t h default value set to t r u e. It causes T g X to loo k for a % % H i R e s B o u n d i n g B o x comment rather than the standard % % B o u n d i n g B o x. a n g l e Rotation angle, o r i g i n Rotation origin.
w i d t h This is a length that asks for the graphic to be scaled to this width, h e i g h t Same as above, for height.
t o t a l h e i g h t Same as above, but includes the depth (i.e., it is equal to height plu s depth).
k e e p a s p e c t r a t i o This is a Boolean value key; if set to t r u e, it makes sure that the graphic is not distorted i n the attempt to make both the required w i d t h and h e i g h t but scales so that neither d im e n s i on exceeds the stated dimensions. s c a l e Scale factor; it can b e a p o s it iv e rational n u m b er. I f it is less than o n e, it s hr i nk s the figure; otherwise, it stretches the figure, c l i p A g a i n, a Boolean value k e y w i t h default value set to t r u e. It clips the graphic to the b o u n d i n g bo x or the v iew po rt if it is specified, d r a f t I f set to t r u e, it switches locally to draft mode so that the gr aphic is not printed but the correct space is reserved and the filename printed.
268 -Φ 9 G r a p h i c s
type Specifies the file type w h i c h is no rmal l y determined b y the file extension, ext Specifies the file extension. U s e d onl y w i t h the ty p e option, r e a d Specifies the “ read file/' w h i c h is used to determine the size of the graphic, command Specifies the file command. U s e d onl y w i t h the type option.
Note that the order of k ey values is important. The two options
[ a n g l e = - 9 0,s c a l e = 4 ] and [ s c a l e = 4,a n g l e = - 9 0 ]
are not the same. The former first executes the scaling and then rotates, whi l e the latter does it the other w a y a r ou n d (first rotates and then scales).
>- Exercise 9.2 Give the necessary comman ds to make an image the header of a document. □
The overpic package (by Ro l f N iepraschk) p r ov i d e s the o v e r p i c environment. This environment can be used to include a graphics file, and it defines a plotting area above the included image that has the di m e n s i on s of the graphics file. I n addition, all of the p i c t u r e - r e l a t e d c omman ds can be u sed to place an y t h i n g that I^TjiX can typeset o n the included image. To assist users i n the placement of things on the image, the package makes it possible to d r a w a g r i d of lines o n the image. A g r i d can be 100 units across and 100 units u p w a r d s (enabled w i t h the default p e r c e n t option) or 1000 u nits across and 1000 units u p w a r d s (enabled w i t h the p e r m i l option). I f we specify the abs option, then we must set the \u n i t l e n g t h length variable. I n this case, the placement over the image is expressed i n “ ab solute" units; otherwise, it is expressed i n “ relative" units. The o v e r p i c environment can have the f o l l o w i n g optional arguments:
s c a l e = s c a l e - f a c t o r Scale the included image.
g r i d D r a w a g r i d above the image (default is p e r c e n t grid).
t i c k s = i m i t.s Place ticks on all axes at every u n i t s.
u n i t = l e n g t h Implicitly set the length variable \u n i t l e n g t h to l e n g t h.
T h e e x a m p l e i n F i g u r e 9.1 d e m o n s t r a t e s a l l o f t h e c a p a b i l i t i e s o f t h e o v e r p i c e n v i r o n ­
me n t.
9.3.1 P l a y i n g w i t h W o r d s
F o r T]hX, a l et t er o r a w o r d i s j u s t a b o x, s o w e c a n e a s i l y s t r e t c h i t o r c h a n g e i t s p o s i t i o n. I f w e p l a n t o u s e a P o s t S c r i p t d r i v e r, t h e n w e c a n d o a m a z i n g t h i n g s t o b o x e s! H o w e v e r, w e w i l l g o i n t o d e t a i l s g r a d u a l l y. T o w h e t y o u r a p p e t i t e, w e c a n s h o w y o u t h a t i t i s p o s s i b l e t o < - i i ^ > ι l, r ot at e/ a n c | ^ a j o r i o s f i s i text.
A l l o f t h i s i s d o n e w i t h t w o c o m m a n d s p r o v i d e d b y t h e g r a p h i c x p a c k a g e. T h e s e a r e \r o t a t e b o x a n d \s c a l e b o x. T h e s y n t a x f o r \r o t a t e b o x i s
\r o t a t e b o x[ k e y v a l u e l i s t ~\{ _ a n g l e y {.t e x t y
a n d f o r \s c a l eb o x
9 3 T h e g r a p h i c x P a c k a g e ■<> 269
LOO
SO
6 0
4 0
20
\begin{overpic}'/,
[Ecale=.2 5,grid, t i c s =20 ,unit=lrara]yt { g o l f e r.ps}
\p u t ( 5,45){\huge \LaTeX> NputiSS.lOX*/.
\includegraphics [scale=. 07]'/, - f g o l f e r.p s » \end{overpic>
Figure 9.1: A demonstration of the capabilities of the overpic environment.
\scalebox{horizontaZ, s c a l i n g }
[ ver t zcal scal i ng ]
{ t ext to be scal ed }
I f the o p t i o n a l a r g u m e n t i s n o t g i v e n, the s c a l i n g w i l l b e u n i f o r m w i t h a scal e factor c o r r e s p o n d i n g to the factor g i v e n i n the c o m p u l s o r y a r g u me n t. T h e s c a l i n g f act ors c an be negat i ve, r e s u l t i n g i n refl ecti ons. Let u s see s o m e exampl es:
C o m m a n d
R e s u l t
\s c a l e b o x { 3 } [.5 ] { H e l l o!}
\s c a l e b o x {.5 } [ 2 ] { H e l l o!>
l i!
\s c a l e b o x { - 3 > [.5 ] { H e l l o!}
\s c a l e b o x { -.5 } [ 2 ] { H e l l o!}
\s c a l e b o x { - l > [1] { H e l l o!>
lollaH
The c o m m a n d \r e f l e c t b o x { £ e c c £ } i s e q u i v a l e n t to the l a s t c o m m a n d of the table above.
E x e r c i s e 9.3 H o w can w e get the A 8 B A l o g o? □
A n o t h e r w a y o f a c h i e v i n g s i m i l a r r e s u l t s w i t h \s c a l e b o x i s p r o v i d e d b y the c o m ­
m a n d \r e s i z e b o x. H i e di f f er enc e i s that w i t h \s c a l e b o x the d i m e n s i o n s o f the r e s i z e d b o x ar e n o w g i v e n n o t as a f act or f o r s c a l i n g b u t as a b s o l u t e l engt hs. T h e y c a n be, f or e xampl e, 3 c m o r a n u m b e r m u l t i p l i e d b y a n y o f the d i m e n s i o n s of the b o x that i s to be
270 -Φ 9 G r a p h i c s
resized. These are \h e i g h t, \w i dt h, \depth, and \t o t a l h e i g h t (see Section 6.10). The syntax is
\r e s i z e h o x - { w i d t h y - { h e i g h t y - {.t e x t t o b e r e s i z e d }
O ne can use a ! i n place of one of the dimensions, and i n this case this d i m e n sion w i l l be determined from the other one, w h i c h must be g iv e n explicitly. The next table clarifies the use of this command:
C o m m a n d
Result
\r e s i z e b o x {. 5 c m } { · l c m M H e l l o!}
Hello!
\r e s i z e b o x {. 5\w i d t h } { 2\h e i g h t } - [ H e l l o! }
f t!
\r e s i z e b o x { 2\w i d t h } {! M H e l l o!}
H e l l o!
\r e s i z e b o x { ! } { - 2\h e i g h t M H e l l o ! J-
ΐ ° Π θ Η
Finally, \r e s i z e b o x has a starred v e r s i on for w h i c h the height of the bo x refers to the height pl us the depth. The next table s h o ws the difference:
C o m m a n d
Result
\r e s i z e b o x {\w i d t h } { 2\h e i g h t } - [ B y e!}
Bye!
\r e s i z e b o x * {\w i d t h } { 2\h e i g h t } { B y e!>
Bye!
9.4 Images t hat Can Be Loaded to a I£TeX File
The o n l y picture format that can be directly loaded into a Ι^ΤβΚ file w it h the default d v i p s dr iver is the Encapsulated PostScript format (or EPS, for short). A n y other picture format must first be converted to PostScript. A nice software application for such conversions is the p r og r am j p e g 2p s b y Thomas Merz, w h i c h converts the v e r y common J P E G files to PostScript. Actually, this p r o g r a m puts a wr a ppe r a r o u n d the J P E G file. Note that this p r og r a m uses features introduced to PostScript level 2. If we have a J P E G file, then the f o l l o w i n g command can be used to transform o u r file to EPS:
$~jpeg2ps - r R E S - o f i l e.e p s f i l e.j p g
R E S is the required resolution i n dots per inch.
Fo r formats such as TIFF, GIF, P I X X, and others, one can use the p r o g r a m b m 2f o n t b y Friedhelm Sowa, but this w o r k s o n l y w i t h grayscales. However, we strongly suggest that y o u use a graphics manip ulation p r o g r a m to transform y o u r graphics file either to JP E G or to EPS. The G n u I mage M anipulation P ro gr am (or g i m p for short) b y Spencer
9.5 I m a g e I n c l u s i o n w i t h p d f K T ^ X -φ- 271
K i m b a l l and Peter Mattis is an excellent freely available graphics manipulation pr og r am that the authors strongly recommend.
9.5 Image Inclusion with pdfl^T^X
I f y o u are u s i n g pdfl^TEX and want to include graphics, the graphicx package must be used w it h the pd f t e x option. The graphics formats that pdfl^TEX can directly handle are PDF, TIFF, JPEG, and P N G. So, if y o u want to include a P N G file, y o u have to enter a c ommand such as the f o l l o w i n g one:
\i n c l u d e g r a p h i c s [ s c a l e = 3 ] { f i l .p n g }
It is a fact that P D F and PostScript are v e r y different document formats, so we cannot embed an E P S file into a P D F file. The situation is s imilar to a Java p r o g r a m that contains Perl code n a t u r a l l y, the Java compiler w i l l not be able to handle this peculiar program. So, if we have an E P S file, h o w can we embed it into a IATgX file that w i l l be processed b y pdfl^TEX? The simplest solution is to use the p r og r am e p s t o p d f (by Sebastian Rahtz). The p r og r am has a nu mber of options, w h i c h are s h o w n below:
O p t i o n
M e a n i n g
— h e l p
P r i n t u s a g e
— o u t f i l e =/i l e
W r i t e r e s u l t t o f i l e
— ( n o ) f i l t e r
R e a d s t a n d a r d i n p u t ( d e f a u l t: — f i l t e r )
— ( n o ) g s
R u n G h o s t s c r i p t ( d e f a u l t: — g s )
— ( n o ) c o m p r e s s
U s e c o m p r e s s i o n ( d e f a u l t: — c o m p r e s s )
— ( n o ) h i r e s
S c a n H i R e s B o u n d i n g B o x ( d e f a u l t: — h i r e s )
— ( n o ) e x a c t
S c a n E x a c t B o u n d i n g B o x ( d e f a u l t: — n o e x a c t )
— ( n o ) d e b u g
D e b u g i n f o r m a t i o n ( d e f a u l t: — n o d e b u g )
9.6 I m a g e s i n t h e B a c k g r o u n d
I n t h e p r e v i o u s s e c t i o n s, w e s h o w e d h o w t o i n c o r p o r a t e p i c t u r e s i n t o o u r d o c u m e n t s. B u t w h a t i f w e w a n t t o h a v e a b a c k g r o u n d p i c t u r e? T h i s i s p o s s i b l e w i t h t h e p a c k a g e e s o - p i c b y R o l f N i e p r a s c h k. T h e p a c k a g e p r o v i d e s t h e c o m m a n d s \A d d T o S h i p o u t P i c - t u r e, \A d d T o S h i p o u t P i c t u r e *, a n d \C l e a r S h i p o u t P i c t u r e. A l l o f t h e a r g u m e n t s o f t h e \A d d T o S h i p o u t P i c t u r e c o m m a n d w i l l b e a d d e d t o a n i n t e r n a l m a c r o t h a t i s a p a r t o f a z e r o l e n g t h p i c t u r e e n v i r o n m e n t w i t h b a s e p o i n t at t h e l o w e r - l e f t c o m e r o f t h e p a g e. C a l l i n g \C l e a r S h i p o u t P i c t u r e, w e c a n c e l t h e ef f ect o f \A d d T o S h i p o u t P i c t u r e. T h e \A d d T o S h i p o u t P i c t u r e * c o m m a n d f u n c t i o n s j u s t l i k e t h e \A d d T o S h i p o u t P i c t u r e c o m m a n d, b u t i t i s u s e d t o a d d m a t e r i a l o n l y t o t h e c u r r e n t p a g e.
272 9 G r a p h i c s
Thus, sup pose that we have an image in the file p i c t u r e. e p s and we want to set this as the ba ckg r ound of an A 4 document. Here, we assume that the image is upside- down, so we must rotate it b y 1 8 0 °. This is the code that achieves the result that w e want:
\A d d T o S h i p o u t P i c t u r e { “/,
\s e t l e n g t h {\u n i t l e n g t h H lmm}
\p u t ( 0,0 ) {\m a k e b o x ( 2 1 0,2 9 6 ) [ t ] {*/,
\i n c l u d e g r a p h i c s [ h e i g h t = 2 9 6 m m, a n g l e = 1 8 0 ] {'/, p i c t u r e.e p s } } } }
Let u s explain the code above. First, we set the unit length to 1 mm. Then, we create a box that has the height and the w i d t h of the logical page. Tn this box, we include the p i c t u r e. e p s file rotated and scaled so that its height will be the height of ou r page (this is achieved by the h e i g h t parameter in the \i n c l u d e g r a p h i c s command). Notice that the height of the b o x matches that of the picture height (i.e., 2 9 6 mm) w h i c h is also the height of an A 4 page. Finally, the whole gr aphic is put at coordinates (0,0 ). A l l of the commands that makeup the argument of \A d d T o S h i p o u t P i c t u r e will be executed every time T^X s h ip s out a page. To stop the inclusion of the picture in the b ackg round for consecutive pages, we use \C l e a r S h i p o u t P i c t u r e.
A
The eso-pic package uses a m o re p r i m i t i v e mechani sm p r o v i d e d b y the package everyshi b y M a r t i n Schroder. This package p r o v i d e s the c o m ma n d \E v e r y S h i p o u t analogous to the ΙΔΤβΧ command \AtBeginDocument, w h o s e a r g u m e n t is executed before e v e r y shipout. A n o t h e r interesting use of this package is as a w a y to add text at the bottom o f each page b e l o w the footer, as seen on this page w h e r e w e added the logo '"T ypeset b y ΙΑΤβΧ 2 c." On e m a y also use the \A d d T o S h i p o u t P i c - t u r e co m ma n d for this.
This capability is exploited by the package prelim2e by Martin Schroder, which adds version control to a document. His package provides the commands \P re- limText and \PrelimWords. The user adds the version to a document by redefining one of these commands with the contents to be written as the document version. For example, one may say
\renewcommand{\PrelimWordsHVersion 1.2, l a s t revised \today}
If the commands are not redefined, they print something like "Preliminary version -June 27, 2002” centered at the bottom of each page.
9.7 The r o t a t i n g Package
The rotating package b y Sebastian Rahtz and L e o n o r Barroca provi des the rotating environment r o t a t e. Whatever is included between \b e g i n { r o t a t e } { d e g r e e s } and \e n d { r o t a t e } w i l l be rotated counter-clockwise b y the angle of d e g r e e s (a numerical
9.7 T h e r o t a t i n g P a c k a g e ^ 273
p o s i t i v e or negative— quantity). This environment does not attempt, though, to find the required space for what is rotated, so if n o special care is taken, the rotated material m a y be printed on other s u r r o u n d i n g material like this:
%
%
\b e g i n { r o t a t e } { - 4 5 } r o t a t e \e n d { r o t a t e }
C om p a r e w i t h the rotations i n Section 9.3.1. This property allows for more complex tricks like the ones i n Figures 9.2 a n d 9.3 taken from the package documentation. I n this example, we use the c ommand \r l a p. This command has one argument, and it typesets its argument and backs u p as if it has not typeset anything. A similar comman d is the \l l a p command. This c ommand creates a box of w i d t h zero w i t h its o n l y argument extending to the left of the box. For example, one w a y to get the sy mbol φ is b y u s i n g c omman ds \r l a p { = }/ and /\l l a p { = >.
If instead y o u want to make r oom for the rotated text, then y o u m ay use the envi­
ronment t u r n instead of the r o t a t e environment.
I n addition to the above, the package p r ov i d e s the s i d e w a y s environment. This is very useful, for example, for t u r n i n g tabular material that is w i d e r than the page width.The environments s i d e w a y s t a b l e and s i d e w a y s f i g u r e can be used instead of the standard t a b l e and f i g u r e environments, and they w i l l rotate the table or the
Π) ^ 0)
* \ 1 £ 3 J * %, % % \ t
\newcount er - Cwang} \newl en g t h - C\wa ng s p a c e} \n e w s a v e b o x {\w a n g t e x t } \newcommai i d- [\wheel } [1] \s a v e b o x - C\wa n g t e x t } {# 1} %
f-'H 9/ ^ ρ, Λγβ -woV© orcuu o u a o i?f l a v e the whale
\C1L1 v UU WXLL Uli\ \W ίΐϋκώυlLUj \If 1 j
\a d d t o l e n g t h - C\w a n g s p a c e H l c m}
\c e n t e r l i n e { %
\r u l e {0p t } {\w a n g s p a c e }7„ \r u l e [ -\wa n g s p a c e ] { O p t } { % \wa n g s p a c e } %
^ ^ J i g $ e ^ a k
\s e t c o u n t e r - L wa n g J"L -1 8 0>A
\w h i l e d o { %
\v a l u e { w a n g } < 1 8 0} { % \r l a p {\b e g i n { r o t a t e ] - { % \v a l u e { w a n g» °/0 \r u l e { l c m } {0p t }#l7t
# £ s. s % % \ 4
* · # £ K 1 % *
CD CD ®
\end{rotate}}%
\addt ocount er{wang3"[ I O } } } } \wheel-[Save the whale}
Figure 9.2: An example of the rotating package.
274 ^ 9 G r a p h i c s
\ 'V
<5^ <S^ <5^ \<x \<y Go Go Go
1 2 3~~
4 5 6
7 8 9
\b e g in{ tab ul ar }-[ r rr }
\begin{rotate}-[45}Column l\end{rotate}ft \begin{rotate}-[45}Column 2\end{rotate}& \begin{rotate}-[45}Columii 3\e n d { r o t a t e }\\ \h l i n e
lk 2k 3\\ 4& 5& 6\\ l k 8& 9\\
\h l i n e
\end{tabular}
Figure 9.3: A second example of the rotating package.
figure together wi t h its caption. These always take the whole page. I n the example of Fi gu re 9.4, we have inserted the table as a figure to easily b y p a s s the problem of sacrificing a whole page for a simple example.
0
1n
13
0)
T3
Ή
Vi
<
CD
3
&
\begin{sidewaystable}
\begin{center]-
\b e g i n { t a b u l a r } { I c I c I }\h l i n e a& b\\ \h l i n e ck d\\ \h l i n e \end{tabular}
\caption{A Ytexttt-Csideways} tab l e} \end{center}
\end{sidewaystable}
Figure 9.4: An example of the sidewaystable environment.
9.8 Mathematics Drawing
G o o d mathematics d r a w i n g is a difficult issue. O n a U n i x system, the standard tool is x f i g. This tool has the ability to save the file i n PjCT]hX commands, and then the user can
A better tool seems to be the p r o g r a m d i a (for DiAgram) available at h t t p: //www. l y s a t o r. l i u. s e/"a l l a/d i a/. The native format of d i a is X M L compressed w i t h g z i p, but the strong point is that it has the ability to export PSTricks code. After exporting, it is easy for the user to adjust the parameters inside the PSTricks file in order to overcome the inaccuracy of the use of the mouse w h e n drawing. W i t h little work, we can easily get
9 - 9 T h e P i C T e X P a c k a g e -φ- 275
hi g h-q ualit y mathematical drawings. Moreover, it is possible to install d i a on Mi c r osoft W i n d o w s. For this and other n o n - U n i x platforms, there are also other d r a w i n g tools such as C o r e l D r a w b y Corel. We w i l l not di s cu s s these pr og r am s except for h o w to overcome the difficulties they impose.
M o s t of these pr og r am s can save i n PostScript format, but the most com m o n problem is that the labels used are not typeset w i t h the same font as the m a in document font u s e d b y I^TgX and, even worse, it is v e r y com m o n to have a label i n I^T]hX math mode that these pr og r a m s cannot typeset. Moreover, the label alignment is u s u a l l y not as g o o d as I^Te X's positioning.
The solution is pr o v i d e d b y the package psfrag b y C r a i g Barratt, Mich ae l C. Grant, and D a v i d Carlisle. This package pr ov i d es an easy interface to edit the labels o n a PostScript file. It pr ov id es the comman d \p s f r a g w i t h syntax
\p s f r a g { l a b e l t o b e r e p l a c e d } - {\$\$ ( c o d e f o r t h e r e p l a c e m e n t}
We shall giv e an example here. The top d r a w i n g i n Fi gu re 9.5 w as generated b y x f i g and saved as the E P S file t r i g c i r c l e. eps. The lower d r a w i n g i n Fi gu re 9.5 is the resulting d r a w i n g after modification b y the E T ^ X code g i v e n to the right. We have used the c omman ds \r a i s e b o x and Yhspace i n order to achieve better po s i ti on i ng of the labels.
9.9 The P[CT£X Package
PjCTeX [30] is a collection of macros (by Mi chael J. Wi ch ur a) that have been desig ned to allow TeX/I^TeX users to typeset pictures as a part of their manuscripts. A l t h o u g h PjCTeX has been designed for use w i t h pl ai n TeX, ETeX users can still use PiCTeX b y l o a d i n g the pictex package b y A n d r e a s Schrell. Since PjCTeX is a little bit cumbersome to use, we w i l l briefly present the system. A l s o, we w i l l briefly present MathsPjC, a pr o g r a m that can be u s ed to create P[Ctures (i.e., d r a w i n g s made w i t h PjCTeX). One t h i n g that the reader must have i n m i n d is that spaces are necessary between k e y w o r d s and special symbols such as braces and slashes.
Each P[Cture begins with the c omman d \b e g i n p i c t u r e and ends with the command \e n d p i c t u r e. The first thing one has to d o is to set the coordinate system w i t h the comman d
\s e t c o o r d i n a t e s y s t e m u n i t s < x - u n i t s, y - u n i t s >
p o i n t a t x c o o r d y c o o r d
T h e u n i t s p a r t i s u s e d t o s p e c i f y t h e l e n g t h o f o n e u n i t o n t h e x and y axes, respectively. The p o i n t part (which is optional) is used to specify the reference poi nt of the system. We can (re)set the coordinates system as often as we like. The coordinate system of the f o l l o w i n g figure
276 -φ- 9 G r a p h i c s
R1
/ sin
Title
\documentclass{article}
\usepackage{ k e r k i s,kmath} \pagestyle{empty}
\usepackage{amsfonts,graphicx} \usepackage{psfrag} \begin{document}
\p s f rag{R}{\hspace-[. 6em}\raisebox% {-lex}{$\mathbb R$}} \p s f r a g { R l } {\r a i s e b o x { 3.5ex}% {$\mathbb R$}} \p sf r a g { t h e t a } { $\t h e t a $ } \psfrag{cos}{\hspace{-lem}\mbox{% $\c os\t heta$ } }
\p s f r a g { s i n } {\r a i s e b o x {.5ex}{% $\s i n\t h e t a $ } }
\p sf r a g { T i t l e } { T ri g o n o m e t r i c
C i r c l e }
\includegraphics [bb=80 -10 "L 300 280] - C t r i g c i r c l e.e p s }
\end{document}
theta 1
ffi.
/ sin
E
Trigonome ric Circle
1
cos I ffi.
V
J
Figure 9.5: The original drawing (top), the modified output (bottom), and the IaTeX code that modified the original drawing. Here, we use the experimental packages kerkis and kmath, which support the Kerkis typeface. However, one gets similar results when using either the standard typeface or any other typeface.
9-9 T h e P j C r g X P a c k a g e -φ- 277
- 2 ~
- 1
3
2
1
-1
-2
-3
x
reference point
has been established w it h the command
\s e t c o o r d i n a t e s y s t e m u n i t s <.5 i n,.2 5 i n > p o i n t a t 1.5 - 2
We can place a piece of text or another Picture at a particular point w i t h the c ommand
\p u t { t e a 5 i } \.0x 0 y ] a t x c o o r d y c o o r d < x s h i f t,y s h i f t >
T h i s c o m m a n d p l a c e s t h e t e x t at ( x c o o r d, y c o o r d ). The optional l o xoyl part is used to place the t e x t inside the resulting box. The v alid values are: l(eft), r(ight), t(op), b(ottom), and B(aseline). O ne can also omit the oy part. The optional part inside the < > is u sed to shift the resulting box x s h i f t units right and y s h i f t units u p from where it w o u l d otherwise go. The comman d
\m u l t i p u t { i e x t } · \_0x 0 y\ < x s h i f t ,y s h i f t > at ... x c o o r d y c o o r d ... * n d x c o o r d d y c o o r d .. /
is used to place the same text at several places i n a PjCture. Between "a t" and the terminating each occurrence of x c o o r d y c o o r d gives the effect of
\p u t { t e x t }- [o^Oy] < x s h i f t,y s h i f t > at x c o o r d y c o o r d
a n d e a c h o c c u r r e n c e o f * n d x c o o r d d y c o o r d gives the effect of
χ = x + dxcoord y = y + dycoord
\p u t { t e a t }■ [ o ^ Q y ] < x s h i f t,y s h i f t > a t J U i ___________________________________________________
Here is a simple example:
278 -φ- 9 G r a p h i c s
( 2,2 )
( 0,0 ) ■ ·.
■' ( 3,- 1 )
\s e t c o o r d i n a t e s y s t e m u n i t s <.2 5 i n,.2 5 i n > \m u l t i p u t {.} a t 0 0 * 1 0 .2 .2 * 1 0 .1 -.3 * 1 0 -.3 .1 /
I f w e u s e a p r o g r a m t h a t g e n e r a t e s t h e c o o r d i n a t e s o f a p l o t, w e c a n u s e t h e c o m m a n d
\m u l t i p u t {t e x t } a t "f i l e"
w h i c h p u t s t h e t e x t at the coordinates that are specified i n the f i l e.
I f w e w a n t t o d r a w a x e s, w e f i r s t h a v e t o s p e c i f y t h e p l o t a r e a w i t h t h e c o m m a n d
\s e t p l o t a r e a x f r o m x c o o r d\ t o y c o o r d\t y f r o m x c o o r d 2 t o y c o o r d 2
The first pair of coordinates determine its lower-left corner a nd the second its top right comer. The next step i nvolves the actual d r a w i n g of the axes. For this, we use the \a x i s command. Since the command has m a n y options, we w i l l g r a d u a l l y introduce most of them b y g i v i n g some examples that demonstrate the features of the command. The d r a w i n g
I— I— I— I— I— j— I— I— I— I— j— I— I— I— I— j— I— I— I— I— j
- 1 0 0 - 5 0 0 50 100
F i r s t E x a m p l e
has been generated b y the f o l l o w i n g code:
\s e t p l o t a r e a x f r o m -1 0 0 t o 1 0 0, y f r o m 0 t o 0 \a x i s b o t t o m l a b e l { F i r s t E x a m pl e }· t i c k s n u m b e r e d f r o m -1 0 0 t o 100 b y 50 u n l a b e l e d s h o r t q u a n t i t y 21 /
Note that b o t t o m specifies that the axis s h o u l d be placed at the bottom of the plot­
ting area. To d r a w tick marks, we must specify the t i c k s keyword. Ticks are u s u a l l y u n l a b e l e d, but they can be n u m b e r e d. Note that here we request PjCTeX to number the ticks i n the range —100 to 100 units b y 50 units. A l s o, we request P[CTeX to put 21 unlabeled equally spaced s h o r t ticks. The k e y w o r d q u a n t i t y is followed b y the precise nu mber of ticks to be drawn. The \a x i s command is terminated b y □/. Ticks they can be s h o r t, l o n g, or l e n g t h < l e n g t h >: Here is another example
\s e t p l o t a r e a x f r o m 0 t o 1 2 5,
y f r o m 0 t o 0
\a x i s t o p l a b e l { S e c o n d E x a m p l e }
S e c o n d E x a m p l e
t i c k s w i t h v a l u e s $ 1 0 Λ0$ $10 ~1$
1 0 ° 101 102 10n
$10 ~2$ Ο O $1 0 ~ n$ /
1 1 1 1 1 1
q u a n t i t y 6 /
9-9 T h e P j C r g X P a c k a g e -φ- 279
The example above s h o w s h o w to d r a w a t o p axis. A s the reader m i gh t expect, we can also d r a w l e f t and r i g h t axes. I n this example, we a s k P j C T g X to d r a w six ticks that w i l l be numbered w i t h the "v a l u e s" specified after the k e y w o r d w i t h v a l u e s. E m p t y values are allowed and m us t be specified w i t h O. Note that the w i t h v a l u e s part must be terminated b y u/· Ticks can also be put a c r o s s the plotting area. Let u s see two more examples:
Top
L
e
f
t
1 0
Ri g ht
axis
- 1 0
- 5
- 1 0
1 0
Bottom
The commands that are necessary to d r a w the left d r a w i n g are:
\s e t p l o t a r e a x f r o m 0 t o 1 0 0, y f r o m 0 t o 100 \a x i s t o p l a b e l { T o p } /
\a x i s b o t t o m l a b e l { B o t t o m } /
\a x i s l e f t l a b e l {\s t a c k { L,e,f,t } } /
\a x i s r i g h t l a b e l {\l i n e s { R i g h t\c r a x i s\c r } } /
The \s t a c k command is used to produce a short stack of comma-separated items, and the M i n e s comman d produces r o w s of lines. Since this is a plai n TgX command, lines are separated b y the \c r command. The right d r a w i n g is d r a w n wi th the f ol l o wi n g commands:
\s e t c o o r d i n a t e s y s t e m u n i t s < l p t, l p t > p o i n t a t -1 5 0 0 \s e t p l o t a r e a x f r o m 0 t o 1 0 0, y f r o m 0 t o 100 \a x i s b o t t o m s h i f t e d t o y=50 t i c k s
i n w i t h v a l u e s $ - 1 0 $ $- 5 $ { } 5 10 / q u a n t i t y 5 /
\a x i s l e f t s h i f t e d t o x=50 t i c k s
i n w i t h v a l u e s $ - 1 0 $ $- 5 $ { } 5 10 / q u a n t i t y 5 /
or vertically, d e pend ing on whether the k e y w o r d is followed b y x = u n i t s or y = u n i t s. Ticks can be placed i n( side) or out(side) the plotting area. The last example s h o ws the creation of a logarithmic axis:
28ο -φ- 9 G r a p h i c s
1 0 0 0 0
1
ο
g
a
r
i
t
h
m
i
c
1 0 0 0
1 0 0
1 0
0 10 30 50 70 90 110 130 150 170 190
nonlogarithmic
and here is the code that makes this drawing:
\s e t c o o r d i n a t e s y s t e m u n i t s < 2.5 p t,3 0 p t >
\s e t p l o t a r e a x f r o m 0 t o 1 0 0, y f r o m 0 t o 4.3 \a x i s l e f t l a b e l {\s t a c k { l,o,g,a,r,i,t,h,m,i,c } } t i c k s l o g g e d n u m b e r e d a t 1 10 100 1000 10000 / u n l a b e l e d s h o r t f r o m 2 t o 9 b y 1
f r o m 20 t o 90 b y 10 f r o m 200 t o 900 b y 100 f r o m 2000 t o 9000 b y 1000
a t 2 00 00 / /
\a x i s b o t t o m l a b e l { n o n l o g a r i t h m i c } t i c k s o u t w i t h v a l u e s 0 10 30 50 70 90 110 130 150 170 190 / s h o r t u n l a b e l e d
q u a n t i t y 11 /
\p u t { $\c i r c $ } a t 10 4 \p u t { $\c i r c $ } a t 50 2 \p u t { $\c i r c $ } a t 80 3 \p u t { $\c i r c $ } a t 90 2.5 \p u t { $\c i r c $ } a t 75 .8 \p u t { $\c i r c $ } a t 35 1.5
The “ m a g i c" trick here is accomplished w i t h the k e y w o r d logged.
>- E x e r c i s e 9.4 D r a w the p i c t u r e of Section 9.1.8 u s i n g PiCT^X.
□
O n e can construct ruled lines w it h the comman d \p u t r u l e f r o m x i n i t y i n i t t o x f i n a l y f i n a l. Similarly, we can construct rectangles w it h the comman d \p u t - r e c t a n g l e c o r n e r s a t x i n i t y i n i t a n d x f i n a l y f i n a l. The command \f r a m e [ s e p a r a t i o n ] { t e x t } puts the t e x t in a frame separated from the t e x t b y s e p ­
a r a t i o n.
A n o t h e r i n t e r e s t i n g f e a t u r e o f P j O g X i s i t s a b i l i t y t o c r e a t e h i s t o g r a m s a n d b a r g r a p h s. T h e c o m m a n d s
9-9 T h e P j C r g X P a c k a g e -φ- 281
\s e t h i s t o g r a m s
\p l o t x c o o r d o y c o o r d o x c o o r d\ y c o o r d\
. . . x c o o r d n y c o o r d n /
produce a hist ogram composed of rectangles h a v i n g opposite corners at the points
(xcoordo / ycoord0 ) - ( x c o o r d\, ycoordx)
(x c oor di, ycoord0 ')-{xcoord2, ycoord2)
(xcoord 2,ycoor d0 ) - ( xcoor d^, ycoord3)
Here is the PjCTgX equivalent of the Fi gu re on page 2 6 4:
\s e t c o o r d i n a t e s y s t e m
u n i t s < 2 5 p t,2 5 p t >
\p u t r u l e f r o m -1 0 t o 6 0 \s e t l e n g t h - C\l i n e t h i c k n e s s M. 8 p t }
_____________________ ______________\s e t h i s t o g r a m s
_ _ l \p l o t 0 0 1 1 2 - 1 3 -.5
4 1.5 5 .5 /
T h e l e n g t h v a r i a b l e \l i n e t h i c k n e s s d e t e r m i n e s t h e t h i c k n e s s o f t h e l i n e s u s e d. B a r g r a p h s a r e d r a w i n g s s u c h a s t h e f o l l o w i n g on e:
U S S E U K D E F R
T h e c o d e t h a t d r a w s t h e f i g u r e a b o v e i s:
\s e t c o o r d i n a t e s y s t e m u n i t s < 2 p t,2 p t > \s e t b a r s b r e a d t h < 2 0 p t > b a s e l i n e a t y = 0 b a s e l a b e l s ( [ B r ] < 7 p t,- 1 5 p t > ) \s e t l e n g t h {\l i n e t h i c k n e s s } ~ C 2 p t 3 - \p l o t 0 4 9 "U S" 1 5 4 6 "S E"
3 0 2 4 "U K" 4 5 2 4 "D E" 6 0 1 7 "F R" / \s e t b a r s b r e a d t h < 2 0 p t > b a s e l i n e a t y = 0
282 -φ- 9 G r a p h i c s
e n d l a b e l s ( [ t r ] < 9 p t,1 5 p t > )
\p l o t 0 49 "4 9\%" 15 46 "4 6\%"
30 24 "2 4\%" 45 24 "2 4\%" 60 17 "1 7\%" / \s e t l e n g t h {\l i n e t h i c k n e s s } - [. 2 5 p t }
\s e t p l o t a r e a x f r o m -1 0 t o 1 0, y f r o m 0 t o 50 \a x i s l e f t t i c k s n u m b e r e d f r o m 0 t o 50 b y 10 /
The c omman ds
\s e t b a r s b r e a d t h <β> b a s e l i n e a t z = z c o o r d \p l o t x c o o r d i y c o o r d\ x c o o r d x y c o o r d 2 ... /
have the effect of
\p u t r u l e b r e a d t h <β> fr o m x c o o r d\ z c o o r d t o x c o o r d\ y c o o r d\
\p u t r u l e b r e a d t h <β> fr o m x c o o r d 2 z c o o r d t o x c o o r d 2 y c o o r d 2
w h e n z is the letter y and the effect of
\p u t r u l e b r e a d t h <β> fr o m z c o o r d y c o o r d\ t o x c o o r d i y c o o r d\
\p u t r u l e b r e a d t h <β> fr o m z c o o r d y c o o r d\ t o x c o o r d 2 y c o o r d 2
w h e n z is the letter x. The command
\p u t r u l e b r e a d t h <β> f r o m x c o o r d s y c o o r d s t o x c o o r d e y c o o r d e
d r a w s a r e c t a n g l e h a v i n g (x c o o r d s, x c o o r d s ) and ( x c o o r d e, x c o o r d e) as the mi dp oi n ts of opposite sides of length β. The labels can be attached to the base of the bars b y c on tinuing the \s e t b a r s w it h either b a s e l a b e l s or e n d l a b e l s, respectively. The example above makes full use of the capabilities of this command. The lengths that are s u r r o u n d e d b y < and > are u sed to shift the bars.
To d r a w a figure or part of a figure that is composed of straight lines, we use the commands
\s e t l i n e a r
\p l o t x c o o r d i y c o o r d\ x c o o r d 2 y c o o r d 2 ... /
The \p l o t comman d connects the points ( x c o o r d i, x c o o r d i ) and (x c o o r d i +\, x c o o r d i +χ) w i t h straight lines. Similarly, the comman ds
\s e t q u a d r a t i c
\p l o t x c o o r d i y c o o r d\ x c o o r d 2 y c o o r d 2 ... /
d r a w quadratic arcs th ro ugh the points that are specified i n the \p l o t command. Note that the nu m be r of points must be odd. The example that follows s h o w s the use of both l ine- dr awing commands:
9-9 T h e P j C r g X P a c k a g e -φ- 283
\s e t q u a d r a t i c
\p l o t 0 0 .1 6 6 7 .2 5 8 8 2 .3 3 3 3 3 .5 .5 .7 0 7 1 1 .6 6 6 6 7 .8 6 6 0 3 .8 3 3 3 3 .9 6 5 9 3 1 1/
\s e t l i n e a r \p l o t 0 0 1 0/ \p u t { $\p i/2 $ } a t 1 -.1 5
\a r r o w <4pt> [.1 5,.6 ] f r o m .2 .6 t o .2 8 .4 7 \s e t d a s h e s \s e t l i n e a r \p l o t .3 0 .3 .5 /
The \a r r o w comman d is used to d r a w arrows. The general form of the comman d is
\a r r o w < £ > [/3,7 ] < x s h i f t,y s h i f t >
f r o m x c o o r d s y c o o r d s t o x c o o r d e y c o o r d e
T h e < x s h i f t, y s h i f t > is optional, and the comman d above d r a w s an arrow of the form
C
^ B B'
σ
where E = ( x c o o r d s,y c o o r d s), A = ( x c o o r d e, y c o o r d e), £ is the distance between A and D, β£ is the distance between B and B', and y £ is the distance between C and C f. The arrow above was set w i t h
\s e t c o o r d i n a t e s y s t e m u n i t s < l p t,l p t >
\s e t p l o t a r e a x f r o m - 1 6 0 t o 1 0, y f r o m -3 0 t o 10 \a r r o w <45pt> [.2,.6 7 ] f r o m - 150 -2 5 t o 0 0
The comman d \s e t d a s h e s <£> specifies an interrupted line pattern composed of dashes of length £ separated b y b l a n k space of length £. The <£> is optional; if it is omitted, P[CTeX assumes that the len g t h of the b l a n k space is 5
we can use the c ommand \s e t d o t s, w h i c h has the same optional argument as the \s e t d a s h e s command. I f we want a more general pattern, we use the command
\s e t d a s h p a t t e r n < d\,g\,d 2,
w h i c h s p e c i f i e s a n i n t e r r u p t e d l i n e p a t t e r n o f a d a s h o f l e n g t h d 1, followed b y a ga p of length g 1, followed by a da sh of length d 2, and so on.
>* Exercise 9.5 Exp re ss \s e t d a s h e s i n terms of \s e t d a s h p a t t e r n. □
To revert to no n d a s h e d mode, just use the comman d \s e t s o l i d.
A n o t h e r useful facility that PiCT^X offers is the ability to change the plot symbol w i t h the command
284 "Φ 9 G r a p h i c s
\s e t p l o t s y m b o l ( {.p l o t s y m b o l } [ 0 x 0y~\ < x s h i f t,y s h i f t > )
T h e p a r a m e t e r s s u r r o u n d e d b y s q u a r e b r a c k e t s a n d b y < > a r e o p t i o n a l a n d h a v e t h e e x p e c t e d m e a n i n g.
I f w e w a n t t o p l a c e s o m e t ex t b e t w e e n a r r o w s (i.e., t o l a b e l s o m e t h i n g ), w e c a n u s e t h e \b e t w e e n a r r o w s c o m m a n d
\b e t w e e n a r r o w s { t e x t } \_0x 0 y ] < x s h i f t,y s h i f t > f r o m x c o o r d s y c o o r d s x c o o r d e y c o o r d e
A s a b o v e, t h e p a r a m e t e r s s u r r o u n d e d b y s q u a r e b r a c k e t s a n d b y < > a r e o p t i o n a l. T h e f o l l o w i n g i s a s i m p l e e x a m p l e:
\s e t c o o r d i n a t e s y s t e m u n i t s < 3 c m,3 c m >
\p u t r e c t a n g l e c o r n e r s a t 0 0 a n d 1.5 .6 \s m a l l \b e t w e e n a r r o w s { w i d t h ) · [ t ] < 0 p t,- 5 p t > f r o m 0 0 t o 1.5 0 \b e t w e e n a r r o w s { h e i g h t } · [ r ] < - 5 p t,0 p t > f r o m 0 0 t o 0 .6
h e i g h t
w i d t h
^ C Te X p r o v i d e s c o m m a n d s t h a t c a n b e u s e d t o d r a w a r c s o f c i r c l e s o r e l l i p s e s. T h e c o m m a n d
\c i r c u l a r a r c Θ d e g r e e s f r o m x c o o r d s y c o o r d s c e n t e r a t x c o o r d c y c o o r d c
d r a w s a n a r c o f a c i r c l e c e n t e r e d at p o i n t (x c o o r d C/ y c o o r d c)·, the arc starts from ( x c o o r d s, y c o o r d s ) and goes counterclockwise b y Θ degrees. Here is a simple exam-
p i e:
\s e t c o o r d i n a t e s y s t e m
u n i t s < 5 p t,5 p t > \m u l t i p u t {
\c i r c u l a r a r c 360
Μ—
^ γ
d e g r e e s f r o m 5 0
V X /
c e n t e r a t 0 0 }
a t 0 0 8 0 1 6 0 4 - 5 1 2 - 5 /
S i m i l a r l y, t h e c o m m a n d
\e l l i p t i c a l a r c a x e s r a t i o ξ : η Θ d e g r e e s f r o m x c o o r d s y c o o r d s c e n t e r a t x c o o r d c y c o o r d c
d r a w s a n a r c o f a n e l l i p s e w h o s e m i n o r a n d m a j o r a x e s a r e p a r a l l e l t o t h e x and y axes. The nu mbers ξ and η are proportional to the lengths of the horizontal and vertical axes of the ellipse.
9-9 T h e P j C r g X P a c k a g e -φ- 285
O f course PjCTgX provid es some more facilities, but we w i l l stop o u r description of PjCTfrX here. The interested reader s h o u l d consult the user manual. We m ust also stress that P]CTgX d r a w s b y putting tiny dots next to one another. This means that PjCTgX is quite memory-demanding, but m o d e m TgX installations u s u a l l y have n o problem w i t h most P[Ctures.
MathsP]C is a p r og r a m that accepts a simple p r o g r a m m i n g notation that is used to specify mathematical drawings. The p r o g r a m yields PjCTgX code, w h i c h then can be processed b y Ι^ΤβΧ. The p r og r a m w a s o r i gi nal l y developed b y Richard W.D. Nickalls as an m s - d o s utility. The p r o g r a m has been rewritten i n Perl b y A p o s t o l o s S y r o p o u l o s i n collaboration w i t h the origi nal author. The f o l l o w i n g is a simple example that s h o ws the code that is necessary to d r a w the figure o n the left:
p a p e r { u n i t s ( 5 m m ),x r a n g e ( 0,1 0 ),y r a n g e ( 0,1 0 ) } p o i n t ( a ) { 0,0 }
p o i n t ( b ) { a.p o l a r ( 5,l O d e g ) } p o i n t ( c ) { a,p o l a r ( 3,5 0 d e g ) } d r a w p o i n t ( a b c ) d r a w l i n e ( a b c a ) v a r d = 0.5
t e x t ( $ A $ ) { a, s h i f t ( - d,0 ) } t e x t ( $ B $ ) { b, s h i f t ( d,0 ) } t e x t ( $ C $ ) { c, s h i f t ( - d,0 ) }
9.9.1 T h e P P C H j e x P a c k a g e
PPCHtex is a m od ul e o r igi nal l y developed b y H a n s H a g e n for use w i t h C O N T E X T 2 to typeset chemical formulas and structures. The mod ule can be used as a no rmal E T ^ X package b y putting the f o l l o w i n g code i n the preamble of a file:
\u s e p a c k a g e { m - p i c t e χ,m - c h - e n }
The mod ule is actually a PiCT^X application. The f o l l o w i n g example s h o w s h o w to typeset the deoxyribose molecule w i t h PPCHj e x and is du e to Ton Otten:
OH
\s t a r t c h e m i c a l [ l e f t = 1300,width=2000,height=1000]
/
\chemical[ONE,Z0,SB4][OH]
h 2c
O
OH
\stopchemical
\s t a r t c h e m i c a l [width=3000,top=1100,bottom=1500]
\h
h
/
\chemical[FIVE,FRONT,BB125,+SB3,-SB4,Z4] [0]
h\
/ H
\chemical[-R
1235
,-RZ
1235
] [Η,OH,Η,H]
\chemical[+R1235,+RZ1235] [Η,Η,\SR{H_2C },OH]
OH
H
\stopchemical
The reader is invited to consult the package's manu al for details o n the use of the package.
2. CONTEXT is another T^X format that has been designed by Hans Hagen. This format is gaining steadily wider acceptance as an alternative to LiT^X.
--------------- --------------------------------------------------------------------------
286 - φ 9 G r a p h i c s
9.9.2 The PSTricks Packages
PSTricks b y T imot hy Van Z and t is a set of packages that pr o v i d e s a T^X-like interface to access PostScript commands. The packages are n o w maintained by D e n i s G i r o u and extended b y h i m and several other people. The capabilities of these packages are quite extensive, and it w o u l d not make sense to cover these i n detail i n this book. D o c u ­
mentation for these packages is available with standard installations and, of course, in C T A N.
The main package is the pstricks package and should always be loaded if any of the other packages in the suite is loaded.
Figures 9.6- 9.12 present a small gallery of graphics that can be done with the PSTricks packages. It is b y no means exhaustive, as the packages p rovide a h u g e amount of possibilities. However, at least the reader m ay get a feeling of what PSTricks can do.
■ΑΔΒ
t
Figure 9.6: An example of pstricks functionality.
Figure 9.7: pstricks, pst-blur shadows (by Martin Giese), and pst-char.
Figure 9-8: pstricks, pst-3d, and pst-lens by Denis Girou and Manuel Luque.
A l t h o u g h PSTricks are quite useful, one cannot use them with pdflfT^C. For this rea­
son the pdftricks package has been written by C.V. R a d h a k r i s h n a n and C.V. Rajagopal.
9-9 T i i i i P j C T ^ X P a c k a g e 287
A
1 ·
v w v
Figure 9-9: pstricks with pst-plot for the graph, with pst-node for the commutative diagram, and with pst-node and pst-coil for the rest.
<-A
v \1 4 2 / 4- t o . ° o
J o
0 r
°c
v ^
g H M S ··, ·■ 1
t - CO V- : - · · v S CO
*u ^ c
s'
/·
o
Q d
<0
Figure 9.10: pstricks with pst-3d for the graphs and with pst-plot and pst-text for the number spiral (Courtesy of D e n i s Girou).
288 -φ- 9 G r a p h i c s
Figure 9.11: pstricks and multido (from the pstricks documentation).
Figure 9.12: pstricks, pst-text, pst-grad, pst-char, and pst-eps (example by Stephan Lehmke, here scaled to fit).
9· ΐ ο G r a p h s w i T r i v l E T f i P O S T ■$· 289
The package uses a special feature f o u n d i n most TpX implementations (in particular, those that are based on the web2c implementation) that permits the LTpX processor to escape to a shell, execute some commands and after this to resume processing of the i np ut file and finish its job. Since escape to the shell is used, the package w o r k s best on U n i x systems. This feature is disabled b y default since it da nger ou s for the security of the system. A l t h o u g h it can be enabled b y default it is suggested to pass it to ράΠ^Τ^Χ as a command-line option like this:
$ p d f l a t e x - s h e l l - e s c a p e f i l e n a m e.t e x
Since, we have not explained h o w one can create graphics w i t h the PStricks, we w i l l not g o into the details of h o w to generate P D F files from Ι 5ΓβΧ sources that contains PSTricks code. The interested reader, s h o u l d consult the package's documentation instead.
9.1 0 Graphs w i t h METAPOST
A s we have already stated M E T A P O S T is a reimplementation of M E T R F O N T that pr o­
duces E P S files. Certainly, it is be yon d the scope of this b o o k to give details of this program. The reader interested i n M E T R P O S T, i n general, sh o u l d consult [13]. H o w ­
ever, there is a M E T R P O S T package that can be easily u s ed to d r a w g r ap h s like those that we d i d w i t h the p i c t u r e environment and PiCT^X, s o we w i l l describe this feature of M E T R P O S T.
First of all, M E T R P O S T assumes that the data we are g o i n g to use to plot ou r g r a p h are stored in some external file. This is v ery convenient, as most of the time we d o have data stored externally. Let u s start w i t h a simple example. S u p p o s e that the data for the example of Section 9.1.8 are stored i n the file temp. d a t a. Next, we create a text file, say s c a t t e r p l o t .mp, w i t h the f ol l o wi n g M E T R P O S T code:
i n p u t g r a p h; % p e r c e n t i s u s e d f o r b e g i n f i g ( l ); % comments d r a w b e g i n g r a p h ( 2 5 0 p t,2 7 0 p t ); g d r a w "t e m p.d a t a" p l o t b t e x $+$ e t e x; e n d g r a p h;
e n d f i g; % s e m i c o l o n s t e r m i n a t e e n d. %commands
T h e n, w e f e e d t h i s f i l e t o M E T R P O S T t o g e t t h e E P S f i l e:
$ m p o s t s c a t t e r p l o t.m p
T h i s i s M e t a P o s t, V e r s i o n 0.6 4 1 (Web2C 7.3.3.1 )
( s c a t t e r p l o t.m p
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/m e t a p o s t/b a s e/g r a p h.mp (/u s r/l o c a l/t e T e X/s h a r e/t e x m f/m e t a p o s t/b a s e/m a r i t h.mp (/u s r/l o c a l/t e T e X/s h a r e/t e x m f/m e t a p o s t/b a s e/s t r i n g.m p ) )
290 -φ- 9 G r a p h i c s
(/u s r/l o c a l/t e T e X/s h a r e/t e x m f/m e t a p o s t/b a s e/f o r m a t.m p (/u s r/l o c a l/t e T e X/s h a r e/t e x m f/m e t a p o s t/b a s e/s t r i n g.mp) (/u s r/l o c a l/t e T e X/s h a r e/t e x m f/m e t a p o s t/b a s e/t e x n u m.m p ) ) ) [ 1 ] )
1 o u t p u t f i l e w r i t t e n: s c a t t e r p l o t.1 T r a n s c r i p t w r i t t e n o n s c a t t e r p l o t.l o g.
The resulting file can be included i n an y or d i n a r y I^TfiX document w i t h the commands that we described i n pr evio us sections. Note that we cannot directly use the resulting file w it h pdfLTEX, but we can transform it to P D F b y feeding it to the mptopdf format (by H a n s H ag e n ) and then include the resulting P D F file i n our document. A n o t h e r problem is that M E T A P O S T, b y default, uses the C om pu t e r M o d e r n typefaces. Certainly, it is possible to use an y font we like, but the relevant details fall outside the scope of this book. The interested reader s h o u l d consult the M E T A P O S T documentation. Now, it is time to explain the comman ds of the M E T A P O S T file.
The c omman d i n p u t g r a p h must always be present, as it i nputs the M E T A P O S T package that allows u s to create graphs. The comman d b e g i n f i g is used to start a figure, and a M E T A P O S T file can contain the code of m a n y figures. Each resulting E P S file has the same name as the inp ut file and a file extension cor r espondi n g to the nu mber i n parentheses that follows this command. The comman d draw b e g i n g r a p h is used to define the plotting area, and the lengths in parentheses define the w i d t h and the height of the resulting picture. The comman d gdraw is the c ommand that actually d r a w s our graph. Here, we d r a w a g r a p h w i t h data stored i n the file temp.data. Moreover, we plot the points u s i n g the p l u s s i g n of the default font. The k e y w o r d s b t e x and e t e x are used to delimit Ι^ΤβΧ code. We w i l l discu s s this ability later w h e n we introduce labels to o u r graph. I f we omit the p l o t part, then M E T A P O S T w i l l connect the points without d r a w i n g the i n d i v i d u a l point symbols.
To ad d labels to gr ap hs is a little bit tricky, as we w i l l see i n a moment. The command
g l a b e l.l a b e l s u f f i x ( s t r i n g, l o c a t i o n)
is u sed to place labels b y the axes. The available l a b e l s u f f i x includes: top, bot, 1f t and r t. A s for the l o c a t i o n, it can just be a pair of numbers, but we recommend the use of the k e y w o r d OUT. This l o c a t i o n places a label relative to the w hol e graph. I f we replace gdraw "t e m p.d a t a" p l o t b t e x + e t e x; w i t h
g l a b e l.I f t ( b t e x Temp $\m b o x O ~\c i r c\m a t h r m - [ F } - $ e t e x, O U T ); g l a b e l.b o t ( b t e x T i m e i n h o u r s s i n c e m i d n i g h t e t e x, O U T ); g d r a w "t e m p.d a t a" p l o t b t e x $+$ e t e x ;
t h e n w e c o u l d, i n t h e o r y, g e t a g r a p h w i t h l a b e l s. H o w e v e r, M E T A P O S T u s e s p l a i n T ^ X t o f o r m a t t h e s t r i n g, a n d s i n c e p l a i n T g X d o e s n o t h a v e t h e \mbox c o m m a n d, t h e p r o c e s s i n g w i l l f a i l. T h e s o l u t i o n i s t o a d d t h e f o l l o w i n g l i n e s a t t h e b e g i n n i n g o f t h e f i l e:
v e r b a t i m t e x \d o c u m e n t c l a s s [ a 4 p a p e r ] { a r t i c l e } - \b e g i n - T d o cument]- e t e x
9· ΐ ο G r a p h s w i T r i v l E T f i P O S T ■$· 291
and then set the ne w system variable TEX to l a t e x. O n a U n i x system w i t h the bash shell, this can be done w it h the command
e x p o r t T E X = l a t e x and o n an M S - W i n d o w s system w it h the command
s e t T E X = l a t e x
E v e n if y o u m o d i f y the file above as suggested, the output still w i l l not be satisfactory. The reason is that the coordinate system is not completely correct. To change the coordinate system, M E T f i P O S T p r ov id e s the c ommand
s e t r a n g e ( c o o r d i n a t e s, c o o r d i n a t e s )
where c o o r d i n a t e s is a pair consisting of strings, numbers, or the special k e y w o r d whatever. The first c o o r d i n a t e s give (^min/i/min) and the second ( ^ m a x/ί/m a x ) * If we use the k e y w o r d o r i g i n for the first c o o r d i n a t e s, M E T f i P O S T w i l l set X m i n = 0 and i/rnin = 0. Moreover, if we are not concerned about the value of any of the components of the c o o r d i n a t e s, we can use the k e y w o r d whatever. I f we want to specify a b i g nu mber as a component of the c o o r d i n a t e s, we must type the nu mber i n the so-called scientific notation su r r ou n d e d b y quotation mar ks (i.e., "I e 6", but not "1E 6"!). This trick is necessary, as M E T f i P O S T cannot handle a nu m be r greater than 3 2768. Now, if we a d d the command s e t r a n g e ( 0,6 5,2 5,9 2 ) just after the draw command, we w i l l get the f o l l o w i n g graph:
T ime in hours since midnight
292 -φ- 9 G r a p h i c s
S h o u l d w e w i s h to plot a logarithmic or a semilogarithmic graph, we can use the s e t c o o r d s commands. This comman d has two arguments, w h i c h can have the values: l o g (for a logarithmic axis) or l i n e a r (for a linear axis). I f we place a m i n u s s i g n in front of these keywords, M E T f i P O S T makes the x (or y ) values r u n backwards, so the largest value is on the left (or bottom) side.
>- E x e r c i s e 9.6 D r a w the semilogarithmic g r a p h o n page 280 u s i n g M E T f i P O S T. □
I f we put one or more b l a n k lines between the data i n the data file, then M E T f i ­
P O S T assumes that we have two or more datasets that can be used to plot at least two plots in the same graph. Naturally, the reader m a y w o n d e r h o w it is possible to d i s t i n g u i s h i n d i v i d u a l plots i n a g r a p h w it h multiple line plots. There are three ways: a) to d r a w plots i n different colors, b) to d r a w dashed lines, and c) to d r a w lines of different widths. I n all cases, we s i m p l y ad d some commands just after the file name of the g d r a w command. To produce colored lines, we ad d the k e y w o r d w i t h c o l o r and a color specification. This, i n turn, can be either an r g b color or a grayscale color (see the next section). The grayscale shade is specified b y w r i t i n g a decimal nu mber from 0 to 1 in front of the k e y w o r d w h i t e. The f o l l o w i n g examples s h o w h o w to get grayscale and color curves, respectively:
g d r a w "t e m p.d a t a" w i t h c o l o r 0.3 2 w h i t e; % g r a y s c a l e g d r a w "t e m p.d a t a" w i t h c o l o r ( 0.7,0.3.,1 ); % r g b
The simplest w a y to get a dashed line is to write the k e y w o r d dashed followed either b y e v e n l y (for a dashed line) or b y w i t d o t s (for a dotted line). Additionally, we can ad d a scale factor just after the k e y w o r d s dashed and w i t h d o t s. The scale factor starts w i t h the k e y w o r d s c a l e d and is followed b y a n u m be r (the real scale factor). Here are two examples:
g d r a w "t e m p.d a t a" d a s h e d s c a l e d 1.5; % d a s h e d l i n e g d r a w "t e m p.d a t a" w i d t h d o t s s c a l e d 2; % d o t t e d l i n e
I f we want a thick line, we just use withpen p e n c i r c l e s c a l e d s c a l e - f a c t o r, w h e r e s c a l e - f a c t o r is a length denoting the w i d t h of the line. Fo r example,
g d r a w "t e m p.d a t a" w i t h p e n p e n c i r c l e s c a l e d 1.5 p t
d r a w s the plot w i t h a line of w i d t h 1.5
pt.
I f we want to plot two functions on the same graph, we can use the a u t o g r i d command
a u t o g r i d ( l a b e l,l a b e l ) o p t i o n l i s t
H e r e l a b e l is g r i d (for grids), i t i c k s (for ticks inside the graph), and o t i c k s (for ticks outside the graph). The l a b e l can have a suffix denoting the axis on w h i c h the l a b e l s h o u l d appear. These suffixes are: .1 f t, .r t, .t o p, and .b o t. Note that the period is part of the suffix. The o p t i o n l i s t is a command that colors the ticks and is optional.
9- i i C o l o r I n f o r m a t i o n -φ- 293
We note that one sh o u l d use this command w i t h great care, as o u r practical experience has shown.
It is even possible to change the appearance of the frame that s u r r o u n d s the g r a p h b y u s i n g the comman d frame:
f r a m e.l a b e l o p t i o n - l i s t
I f t h e l a b e l is not specified, then it applies to the whole frame. Other possible values include l i f t (for the bottom and left sides), l r t (for the left a nd right sides), u l f t (for the left a nd top sides), and u r t (for the top and right sides).
A s a f i n a l w o r d, w e p o i n t o u t t h a t t h e g r a p h p a c k a g e h a s s o m e o t h e r o p t i o n s, w h i c h, h o w e v e r, a r e u s e f u l o n l y i f o n e h a s a r a t h e r d e e p k n o w l e d g e o f M E T f i P O S T. F o r i n f o r m a t i o n a b o u t M E T f i P O S T, t h e i n t e r e s t e d r e a d e r s h o u l d h a v e a l o o k a t h t t p: //c m.b e l l - l a b s.com/who/hobby/MetaPost.html.
9.11 Color Information
There are two m a i n issues concerning the use of color. The first is h o w to a d d color to o u r document, and the second is w hat one s h o u l d k n o w for industry-qu ality color printing.
9.1 1.1 C o l o r i n o u r D o c u m e n t s
Imagi ne that y o u are s tan din g i n front of a v e r y beautiful and colorful landscape. Y ou decide to take a picture of it. Later on, y o u gi v e y o u r photographic film for processing, and w h e n y o u get the printed photographs y o u realize that the colors are not those y o u expected. We are sure that this is not a science fiction scenario but rather a v ery frequent situation, and most people blame the proc essing shop for not d o i n g a g o od job. Fortunately, for the people w h o r u n this k i n d of business, color is a physiological sensation and as such cannot be directly measured or described. So, we cannot blame them, even if we think they are not d o i n g g o o d work! A color model is a mechanism b y w h i c h we can describe the color formation process i n a predictable way. There are two categories of color models: those that are related to device color representation and those related to h u m a n v i s u a l perception. The first category is directly supported b y but the second is not supported at all. Grayscale, r g b, h s b, and c m y k are color models of the first category. supports all of these color models except h s b.
The grayscale color model is u sed to specify shades of gray. I n this color model, black is denoted b y 0.0 and white b y 1.0, so shades of g r a y are just nu mbers between 0 and 1. r g b is the Red-Green-Blue color model. Other colors are derived from combinations of the three pr i mar y colors and are specified as triplets of nu mbers from 0.0 to 1.0. For example, purple is defined to be the triplet (0.7,0.3,1.0 ). Obviously, 0.7 is the "a m o u n t" of red, 0.3 the "a m o u n t" of green, and 1.0 the "a m o u n t" of blue (actually, it is blue
294 ^ 9 G r a p h i c s
phosphorus), rgb is an addi t i ve color model and is u s e d w h e n light is generated. For example, this color model is used i n computer monitors a nd color televisions, hsb is the Hue-Saturation-Brightness color model. This is actually not a color model but rather an alternative convention for specifying colors i n the rgb color model, and that is probably the reason w h y Ι^ΤβΧ does not support this color model, cmyk is the Cyan - M ag e n t a- Yellow-blacK color model and has four pr im a r y colors. A s i n the case of the rgb color model, other colors are derived from combinations of the four primitive colors. For example, purple is defined to be the q u adr up le (0.45,0.86,0.0,0.0). This is a subt ract i ve color model and is used i n applications where light is reflected, such as printing.
The terms additive and subtractive refer to the w a y colors are formed. I n the rgb model, each component of a color specification defines the i nt ens i t y of the particular pr i m a r y colo r —the larger the number, the h ig h e r the intensity. I n the cmyk color model, each component of a color specification represents the degree of l ight absorption ^the larger the number, the hig her the absorbability.
C o l o r i n L T g X documents can be added i n several ways, the most standard one being the color package b y D a v i d Carlisle. This package supports the color models grayscale, rgb, and c m y k. Additionally, it supports the named color model, w h i c h is u s ed to access predefined colors. The set of predefined colors depends o n the option one chooses to use. Each option is associated w i t h an external dr i ver p r og r a m that w i l l be u sed to transform a D V I file to some format that directly supports color. The most common options are d v i p s (which is the default option) and pdf t e x (for use w i t h pdfL^TgX).
Once we have selected the option that is suitable for ou r purposes, we can define n e w colors w it h the \d e f i n e c o l o r command:
\d e f i n e c o l o r - C c o i o r n a m e y ^ c o l o r m o d e i y - i c o l o r c o m p o n e n t s }
The c o l o r name is the name that we w i l l use i n o u r document to call the color we just d efined, c o l o r mo d e l is the m o d el w e want to u s e (it can b e either rgb, cmyk, or gray). Finally, c o l o r c o mp o n e n t s are triplets, quadruplets, or just a single number, d e p e n d in g on the color model used. Here are some typical definitions:
\d e f i n e c o l o r { R G B p u r p l e } { r g b } { 0.7,0.3,1.0 }
\d e f i n e c o l o r - C C M Y K p u r p l e M c m y k M O. 45,0.86,0.0,0.0 }-
A typical question that most newcomers ask is: "W h e r e can I get the c o l o r c o mp o n e n t s of a particular color I want to use in m y d o c u m e n t?" Since the cmyk color model is u sed i n the pr in t in g industry, one must consult the color tables that each c om p an y publishes. However, a g o o d source of information for both the cmyk and the rgb color models is the Internet. Just point y o u r favorite Web br ow s er to y o u r favorite search engine and type the necessary search keywords. I n addition, for the rgb color model, one can also consult the H T M L color tables.
After we have defined the colors that w e want to use, we can see h o w to actually use them. To change the text color, there are two possibilities. The global one is \c o l o r { c o - l o r n a me y, and the local one is \t e x t c o l o r { c o l o m a m e } { t e x t }·. The second command
9· ΐ ι C o l o r I n f o r m a t i o n 295
is essentially the same as {\c o l o T { c o l o m a m e } t e x t >. O ne can a v oid the predefinition of colors and define them "o n the fly":
\c o l o r [ c o l o r m o d e l ] { c o l o r c o m p o n e n t s } o r \t e x t c o l o r [ c o l o r m o d e l ] { c o l o r comp o n e n t s } { t e x t }
O n e c a n a l s o s e t t h e p a g e c o l o r. T h e r e l a t i v e c o m m a n d s a r e \p a g e c o l o r { c o l o r n a/n e } o r i f t h e c o l o r i s n o t d e f i n e d \p a g e c o l o r [ c o l o r m o d e l ] { c o l o r c o m p o n e n t s }.
Two more comman ds are available with the color package. These have to d o with local coloring of a box. The package pr ov id es the comman ds \c o l o r b o x for colored boxes and \f c o l o r b o x for colored framed boxes. Here is an example:
colored box
c o l o r e d b o x
\c o l o r b o x [ g r a y ] {.9 5 } { c o l o r e d b o x }
\f c o l o r b o x [ g r a y ] {.9 5 } {.8 } { c o l o r e d b o x }
Both comman ds put a color backg round i n the box, while the latter also colors the frame.
>- Exercise 9.7 Find a w a y to demonstrate the difference between an additive and a subtractive color model. □
There are other possibilities for a d d i n g color to documents and in much more sophisticated ways. O ne such example is the color support for the PStricks packages. One main package pstricks already p r ov id e s more possibilities than the color package, and additional functionality is available. A n example is the pst-slpe package by M a r t i n Giese, w h i c h a d ds s up por t for advanced gradients. We s h o w an example from the documentation of the package in Figu re 9.13.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
Figure 9.13: pstricks, pst-plot, and pst-slpe.
9.11.2 C o l o r i n g T a b l e s
The coloring of tables can be done u s i n g the colortbl package b y D a v i d Carlisle. The package provides comman ds for coloring rows, columns, cells, and table b o u n d a r y lines. Figu re 9.14 s h o w s some of the capabilities of the package.
296 -φ· 9 G r a p h i c s
ΑνΌεστηριών
Σε
Ao
Ep
Δ ι
Αφ
K p
Η λ
1
2
3
4
5
6
7
8
9
10
11
12
1J
14
15
16
17
IS
19
20
21
22
23
24
25
26
27
2y
1 1 -1 3 Ανβεστήρια: Τιμή Δ ι ο νύ σ ο υ κ«ι Ψυχοπομπού Ερμή 23 Διάσια: Μέγιστη γιορτή Δ ιός και υποδοχή της Άνοιξης
Figure 9.14: An application of the colortbl package: the calendar of the second Athenian month for the year 2000.
A l t h o u g h Figure 9.14 was prepared with the colortbl package, let us note here that D e n i s G i r o u is pr ep ari ng the package pst-cal, which, when released, will considerably ease the creation of calendars. The package should appear as part of the PStricks suite.
N o w back to the colortbl package. To color a column, the package provi des the \c o l u m n c o l o r comman d w it h the syntax
\c o l u m n c o l o r [ c o l o r mode I ] { c o l o r } [ l e f t o v e r h a n g ] [ r i g h t o v e r h a n g ]
where c o l o r mo d e l is any of the color models that L?T^X understands, and c o l o r is either a named color o r the components of a color specification. I f we d o not specify the c o l o r m o d e l, Τ^Ι^Χ assumes that we are u s i n g a user-defined color. The last two arguments control h o w close the coloring wil l get to the b o u n d a r y of the table columns. The c omma n d goes in the definition of the table like this:
\b e g i n { t a b u l a r } { | > {\c o l u m n c o l o r [ g r a y ] { 0.8 } [ 1.5p t ] [5p t ] } 1 1 > {\c o l o r { w h i t e } \c o l u m n c o l o r [ g r a y ] {.4 } [ O p t ] } 1 |} one & two \\ t h r e e & f o u r \e n d { t a b u l a r >
Tine example above also demonstrates the use of the l e f t /r i g h t - o v e r h a n g parameters. I f they are omitted, then the full column w id t h is filled with color. Moreover, we can specify a percentage of the o v e r h a n g space left aroun d the text of the column, w h ic h is the parameter \t a b c o l s e p, like this:
one
three
one
two
three
four
\b e g i n { t a b u l a r } { I > {\c o l u m n c o l o r [ g r a y ] { 0.8 } } 1 1 */, > {\c o l o r { w h i t e }\c o l u m n c o l o r [ g r a y ] {.4 } [ 0.5\t a b c o l s e p ] } 1 | } one & two \\ three & four \e n d { t a b u l a r }
9· ΐ ι C o l o r I n f o r m a t i o n Φ 297
The command \r o w c o l o r is similar to \c o l u m n c o l o r and is used to color rows. The \r o w c o l o r c ommand sho ul d be positioned at the b e g i n n i n g of a row, and if it crosses a colored column, the r ow color will overwrite the colu mn color. W h e n overhang arguments are not used, then the o v e r h an g information is read from the \c o l u m n c o l o r commands, if there are any. Here is an example:
two
three
four
\b e g i n { t a b u l a r } { I > {\c o l u m n c o l o r [ g r a y ] { 0.2 }'/,
[ 0.5\t a b c o l s e p ] > 1 11 1 }\h l i n e \r o w c o l o r [ g r a y ] {.8 } o n e & t w o \\ \h l i n e t h r e e & f o u r\\ \h l i n e \e n d { t a b u l a r }
Cell coloring is more tricky and requires the use of the \m u l t i c o l u m n command. We put the cell into a mult icolumn and then color it like this:
one
two
threef
four
\begin{tabularH 11111 }\hline
o n e & \m u l t i c o l u m n { l } { > {\c o l o r { w h i t e }\c o l u m n c o l o r y o [ g r a y ] { 0.4 } } l | H t w o > \\ \h l i n e \m u l t i c o l u m n { l } { | > {\c o l u m n c o l o r [ g r a y ] { 0.8 }'/, [.5\t a b c o l s e p ] } l | } { t h r e e } & f o u r\\ \h l i n e \e n d { t a b u l a r }
Let u s turn to coloring the ruled lines of a table. Fo r vertical ruled lines, the solution is simple. I n the table definitions, instead of u s i n g the I character to denote a vertical rule, y o u can use
{!\c o l o r [ g r a y ] {.8 }\v l i n e }
C o l o r i n g horizontal lines is more tricky. The package provides the command \a r r a y - r u l e c o l o r, w h ic h can be given before a table or even inside it. I n any case, the command colors the lines that follow it and, if g i v e n inside a table, it does not change the color p r e v i o u s l y specified for the vertical lines:
\b e g i n { t a b u l a r } { 1 1 1 1 1 } %
\a r r a y r u l e c o l o r [ g r a y ] {.8} \h l i n e one & two \\ \h l i n e t h r e e & f o u r\\ \h l i n e \e n d { t a b u l a r }
W h e n u s i n g double lines for table separators ( u s i n g I I in the t a b u l a r table specification or \h l i n e\h l i n e after a row), one m ay want to color the white space between them. This is done with the \d o u b l e r u l e s e p c o l o r command, w h i c h is used like the \a r r a y - r u l e c o l o r command:
one
two
three
four
298 Φ 9 G r a p h i c s
\s e t l e n g t h {\a r r a y r u l e w i d t h } { 2 p t } \s e t l e n g t h {\d o u b l e r u l e s e p } { 3 p t } \d o u b l e r u l e s e p c o l o r [gray] {. 8}
\b e g i n { t a b u l a r } { I I c I | c I I}
\a r r a y r u l e c o l o r [gray] {.6}
\h l i n e\h l i n e one & two \\
t h r e e & f o u r\\ \h l i n e\h l i n e \e n d { t a b u l a r >
We give one more example, where color is used for emphasis. We put the whole table in a colored box using the \colorbox command, and then we emphasize a row u^ing white.
Item
Quantity
Price per Unit
Partial Total
Book A
1
24.99
24.99
Book B
3
29.99
89.97
Book C
2
44.99
89.98
Total
204.94
Tax S%
16.40
Grand Total
221.34
\colorboz[gray]{0.S}{%
\b e g i n { t a b u l a r } { l c r r }
Item & Q u a n t i t y & P r i c e p e r Unit & P a r t i a l T o t a l\\[ 2 e x ]
Book A & 1 & 24.99 & 2 4.9 9\\
Book B & 3 & 29.99 & 8 9.9 7\\
Book C & 2 k 44.99 k 8 9.9 8\\
\ro w c o l o r{ w h i te } T o t a l & \ k \ & 204.94W Tax 8\y, & \ k \ & 16.40W \ k\ &\textbf{ Grand T o t a l } k 221.34W \end{tabular}>
When working with colored tables, it is very convenient to define your own column types, incorporating the color commands in their definition. This saves a lot of typing. For example, for coloring the columns of a table, we may define new column types by
\newcolumntype{A}{>{\columncolor[gray]{0.8}[.5\tabcolsep]}c} and then use \begin{tabular}{AAA}. You can do something similar for cells:
\newcommand{\cellcol} [2]{\multicolumn{l}{>{\columncolor{#l}}#2}}
one
three
two
four
9 · ΐ 2 P r i n t i n g i n L a n d s c a p e M o d e -Φ- 299
Provided that you have defined the colors you want to use with \definecolor (see Section 9.11.1), you can say
\c e l l c o l - [ c ol o r name)- {.t abl e a l i g n m e n t } { t e x t o f t he c e l l }
for every cell you want to color (where the t a b l e al i gnment is a character of r, 1, c, or a column type that you may have defined previously as above.
9.11.3 Color and the Printing Industry
All of the material of the previous section should be enough for printing colored documents on desktop color printers. However, there is an additional step needed to prepare colored documents for a professional printer. The professional printer will actually perform color separation. This means that the printer will print a color plate four times. Each separation layer will print the corresponding color component of the picture elements. The overprinting of the color components on the page will create the final colors of the color plate. Thus, it is clear that we must somehow perform the necessary step of color separation. The easiest way to do this is by using the aurora package by Graham Freeman. Actually, this is not a I^TgX package but rather it consists of PostScript "header" files that should be used to generate four different PostScript files, one for each color. Let us now describe the procedure. First, we run our document through LTeX. Next, we create the four PostScript files with the commands:
d v i p s f i l e - h a u r o r a.p r o - h c y a n.p r o -o f i l e - c y a n.p s
d v i p s f i l e - h a u r o r a.p r o - h magenta.pro -o f i l e - m a g e n t a.p s
d v i p s f i l e - h a u r o r a.p r o - h y e l l o w.p r o -o f i l e - y e l l o w.p s
d v i p s f i l e - h a u r o r a.p r o - h b l a c k.p r o -o f i l e - b l a c k.p s
Finally, we send these files to a PostScript printer, usually in the order in which they are generated. Of course, changing the order will not affect the final output as long as we know which layer corresponds to which color.
Let us note here that the aurora package uses PostScript Level 1 commands and not the full possibilities supported by the PostScript Level 2 colorimage command. It should be clear though that the quality of the separation is the work of the PostScript driver (like d v i p s ) and not of Privately developed drivers have been shown to be capable of full-scale color work with LT^X (see [22]).
9.12
As we have already seen, it is possible to typeset a whole document in landscape mode. However, there are cases where we simply want to typeset parts of a document in landscape mode. For example, if we have a very long table, it makes sense to typeset it in landscape mode in a document that is otherwise typeset in portrait mode. The Iscape
30 ο -φ- 9 G r a p hics
package (by David Carlisle) provides the l a n d s c a p e environment; its body is typeset in landscape mode. The environment may span several pages.
>- Exercise 9.8 Suppose that you are using a document class that does not provide the l a n d s c a p e option. Create a simple package that implements this option. (Hint: Use the internal I^TgX length variable \®tempdima.) □
1 0 ----------------------------------------------------------
M ultilingual Typesetting
The electronic typesetting of a document written in a language other than English is a problem that has been tackled seriously by the TgX community. A complete solution to this problem involves the solution of two subproblems: the preparation of the ET^X file and the typesetting of this file according to the typographic idiosyncrasies of the (main) language of the document. There are at least three different approaches to this really complicated problem:
• The use of standard I^TeX packages (i.e., packages that suppose the use of TgX as the underlying typesetting engine and allow multilingual text processing in a portable way). The main drawback of this approach is that in many cases the user has to type commands that seem unnatural.
• The use of customized typsetting engines, such as pTgX, that are based on T^X and take care of most peculiarities of a particular language. The main drawback of this approach is that it is not adequate for documents written in languages other than the native language of the customized typesetting engine.
• Standard TgX extensions, such as ε-Τ^Χ and Ω, which have been designed to allow true multilingual typesetting. The drawback of this approach is that these systems have not gained really wide acceptance, mainly because their documentation is still under development.
In this chapter, we will not present the various approaches to multilingual type­
setting but, instead, we will describe the tools that are available for the typesetting of documents written in a particular language. However, since there are some tools that are commonly used for the electronic typesetting of documents written in big groups of languages, we will first present the core of these tools and then will present the solution available either for groups of languages or individual languages (if, for example, such languages do not belong to any language group).
30 2 -φ ί ο M u l t i l i n g u a l T y p e s e t t i n g
10.1 The babel Package
The babel package (by Johannes Braams) is the standard package that allows people to typeset multilingual documents with LT^X. However, one of the biggest drawbacks of this package is that it does not offer the facilities for typesetting documents written in most Asian languages. The package provides various options that correspond to the language(s) that we want to use in a document.
Each document has a main language, which is the last language (option) specified in the option list. For example, with the command
\u s e p a c k a g e [ g e r m a n,e n g l i s h,g r e e k ] { b a b e l }
we inform LTgX that the main language of our document is the Greek language. All of the standard LTeX phrases, such as "chapter," "appendix," and so on, appear in the main language of the document. In some cases, we want to use a language with some additional attributes (e.g., we want to typeset poly tonic Greek instead of monotonic Greek, which is the default), so, after the \u se p a c k a g e command, we have to use the command \l a n g u a g e a t t r i b u t e to "activate" these additional attributes. The command has two arguments: the name of a language and a list of attributes. Currently, the g r e e k option supports the p o l u t o n i k o attribute, which can be used for polytonic typesetting, and the l a t i n option supports the medieval attribute, useful for Latin texts that follow the rules of medieval Latin. Suppose now that we want to write polytonic Greek. To do this, we must have the following commands in our preamble:
\u se p a c k a g e [ l a t i n,g r e e k ] { b a b e l } \l a n g u a g e a t t r i b u t e { g r e e k } { p o l u t o n i k o }
\u se p a c k a g e [ is o - 8 8 5 0 - 7 ] { i n p u t e n c }
The last command is useful only for people having a Greek keyboard. To switch from one language to another, we can use the command \selectlanguage. This command makes sure that the hyphenation patterns as well as all peculiarities associated with its argument, which is the name of an option (language) declared in the preamble, are enabled. For example, if we have in our preamble
then the command \s e l e c t l a n g u a g e { b a s q u e } switches to the basque language and the command \s e l e c t l a n g u a g e { c z e c h } switches back to the main language of the document. Another way to switch languages is to use the environment o t h e r language. This environment does what the \s e l e c t l a n g u a g e is doing, but it is useful when we want to mix languages that use different writing directions. This environment has one argument, which is the name of a language. The environment o t h e r language* differs from the o t h e r l a n g u a g e environment in that the standard phrases do not change. Similarly, the command \f o r e i g n la n g u a g e is used to locally typeset a piece of text in another language. The command has two arguments: the name of the "foreign" language and the text to be typeset with the typographic conventions of the "foreign"
ίο .ι T h e b a b e l P a c k a g e -φ- 30 3
language. Of course, the package provides some more commands that are useful for package developers, and we will not describe them. Interested people should consult the package's documentation for more information.
Given a character set, an encoding arranges the characters in a specified order. The associated code point assigned to each character is used as a means for accessing that character. A code point is an integer value that is assigned to a character. Each character receives a unique code point. The standard approach to typesetting documents that are prepared in some extended ASCII character set is to use some input encoding file that will map the non-ASCII characters either to commands or to ASCII characters. The inputenc package (by Alan Jeffrey and Frank Mittelbach) is used to perform this mapping. The package provides a number of options that correspond to the extended ASCII character set in which the document is written. In what follows, we present the standard options and their corresponding character sets:
• ascii: ASCII encoding for the range 32-127.
• latinl: ASCII plus the characters needed for most Western European languages, including Danish, Dutch, English, Faroese, Finnish, Flemish, French, German, Ice­
landic, Italian, Norwegian, Portuguese, Spanish, and Swedish. Some non-European languages, such as Hawaiian and Indonesian, are also written in this character set.
• l a t i n 2: ASCII plus the characters needed for most Central European languages, including Croatian, Czech, Hungarian, Polish, Romanian, Slovak, and Slovenian.
• latin3: ASCII plus the characters needed for Esperanto, Maltese, Turkish, and Gali­
cian. However, latin5 is the preferred character set for Turkish.
• latin4: ASCII plus the characters needed for the Baltic languages (Latvian, Estonian, and Lithuanian), Greenlandic, and Lappish.
• latin5 is essentially the same as l a t i n l, except that some Turkish characters replace less commonly used Icelandic letters.
• decmulti: DEC Multinational Character Set encoding.
• cp850: IBM 850 code page, almost the same as ISO Latin 1, but character arrangement is not the same.
• cp852: IBM 852 code page.
• cp437: IBM 437 code page, which is the original American code page and contains letters, digits, mathematical symbols, and some characters useful in the construction of pseudographics.
• cp437de: IBM 437 code page (German version).
• cp865: IBM 865 code page.
• applemac: Macintosh encoding.
• next: Next encoding._______________________________________________________
• ansinew: Windows 3.1 ANSI encoding, extension of Latin-1.
• cpl252: Synonym for ansinew.
• cpl250: Windows 1250 (Central and Eastern Europe) code page.
Some other options (encodings) exist, such as the iso-8859-7 option, which is used to typeset Greek, but those must be obtained separately. To change the input encoding in
3 0 4 "Φ ί ο M u l t i l i n g u a l T y p e s e t t i n g
a document, we should use the \ i n p u t encoding command, which has as its argument the name of an input encoding.
10.2 The Ω Typesetting Engine
Ω has been designed to facilitate the typesetting of multilingual documents without any restriction. A Λ file consists of text written either in some extended ASCII character set or in any Unicode encoding. Unless, we use the UCS-2 input encoding, we have to use some QCP (i.e., a binary form of an ΩΤΡ that can be readily used by Ω, which will convert the characters of the extended ASCII character set to their Unicode counterparts). In addition, Ω extends T^X's capabilities by allowing the use of 65,536 fonts that may contain up to 65,536 glyphs (T^X supports 256 fonts with up to 256 glyphs). The same capabilities are available to length variables and counters. Also, Ω introduces some new primitive commands that are necessary to properly typeset multilingual documents.
In French typography, quotations start with an opening guillemet and an unbreak­
able space. After the text, we have an unbreakable space and a closing guillemet. If the quoted text span to more than one line, the guillemets must also appear at the begin­
ning of each line that contains quoted text. It is almost impossible to write a macro that will implement this typographic convention, so Ω offers the commands \l o c a l l e f tbox and \localrightbox to solve problems such as this. Both commands must be used in a local scope and have one argument, which is the “symbol" that will appear on the left or right side, respectively, of each output line. For example, the text
« Jean Calas, age de soixante et huit ans, exergait la profession de « negotiant a Toulouse depuis plus de quarante annees, et etait
« reronnu dp tous reux qui ont veru avpr lui pour un bon p£re. TI_________
« etait protestant, ainsi que sa femme et tous ses enfants, excepte un,
« qui avait abjure l'heresie, et a qui le pere faisait une petite pension.
« II paraissait si eloigne de cet absurde fanatisme qui rompt tous les « liens de la societe qu'il approuva la conversion de son fils Louis « Calas, et qu'il avait depuis trente ans chez lui une servante zelee « catholique, laquelle avait eleve tous ses enfants. »
has been typed in as follows
{ « ~\l o c a l l e f tbox{«~}-Jean C a l a s,... t o u s s e s enf a n t s . ~>>}
TgX is a typesetting system that only supports left-to-right typesetting. Therefore, it is inadequate for many languages such as Hebrew, Arabic,1 and so on. Ω, on the other hand, provides primitive commands that can be used to specify the direction of pages and paragraphs. The commands \pagedir, \bodydir, \pardir, \textdir, and \math- dir are used to specify the direction of a page, of the main body of text, of a paragraph,
1. Actually, this is not strictly true. But it is true that it is quite cumbersome to typeset Arabic text with L5T]hX.
ί ο .2 Τ ηεΩ T ypesetting Engine -Φ 30 5
of a short text passage or of a mathematical formula, respectively. All commands have an argument consisting of three letters that specify the "top" of each page, the "left" of each page, and the "top" of each character. The command and the argument are separated by at least one space, and the argument must not be enclosed in braces. The letters can be T (for top), B (for bottom), L (for left), and R (for right). The direction specified by the first letter must be orthogonal to the direction specified by the second letter. The third letter may take all possible values. For example, the command \p a g e - d i r TLT specifies that the top of the logical page is the top of the physical page, the left of the logical page is the left of the physical page, and the top of each character is the top of the physical page. For a traditional Japanese text, the corresponding command is \p a g e d i r RTR because the top of the logical page is the right of the physical page, the left of the logical page is the top of the physical page, and the top of each character is at the right of the physical page. Finally, for Arabic and Hebrew, the corresponding command is \p a g e d i r TRT just because the left of each logical page is the right of the physical page.
>· Exercise 10.1 How can we embed English text in an Arabic document and vice versa?
Δ
In Section 6.10, we presented the various box construction and manipulation com­
mands provided by IMgX. These commands make use of the primitive commands \hbox, \vbox, and \vtop. These commands are used to construct horizontal and vertical boxes. A horizontal box produces material that is appended to the current paragraph. A vertical box produces material that is used to build up the current page. The difference between \vtop and \vbox is demonstrated by the following example:
vbox A vtop and a box box
XhboxiA
\vtop{\hbox{vtop}\hbox{box}} and a \vbox{\hbox{vbox}\hbox{box}}}
For more information on these commands, the reader must consult the TgXbook. In Ω, all of these primitive commands can have an optional argument that is used to specify the writing direction of the contents of the box. Here is how we can specify the writing direction:
\hbox
\vbox V d i r di r ect i on { mat er i al }
\v t o p
} di:
The a ut h o r s bel i eve t h a t all c omma nds t ha t can be us e d t o speci fy t he wr i t i ng di r ect i on mu s t s ome how f i nd t he i r way i nt o f ut ur e r el eas es of A. For exampl e, Apos t ol os Syr opoul os has r e i mpl e me nt e d s ome s t a n d a r d e nvi r onme nt s wi t h an opt i onal a r g u me n t t ha t is us e d t o speci f y t he wr i t i ng di r ect i on. Of cour se, t hi s wor k is compl et el y exper i ment al, a nd i t wi l l t ake s ome t i me bef or e i t is f i nal i zed.
30 6 -φ· ί ο M u l t i l i n g u a l T y p e s e t t i n g
We have already mentioned Π translation processes, and here we will go into the details. An ΩΤΡ is a little "program" that is used to map one character set to another so that Ω can process our documents. For example, if we prepare a document using the ISO-8859-7 extended ASCII character set, we need a mechanism to map the characters of this set to Unicode, as this is the default character set Ω understands. Although this step may seem redundant, it is necessary in cases where people do not prepare their input files with a Unicode editor. Moreover, there are certain problems that are not related at all to Unicode. For example, in Turkish we use both i and 1, so when we type f i l (elephant) we want to get til and not fil2 (which is not a Turkish word)! This is definitely a problem that can be tackled by ΩΤΡ5.
Δ Αη ΩΤΡ defines a finite state automaton [i.e., an abstract machine consisting of a set of states (including the initial state), a set of input events, a set of output events, and a state transition function]. The function takes the current state and an input event and returns the new set of output events and the next state. Some states may be designated as "terminal states." The state machine can also be viewed as a function that maps an ordered sequence of input events into a corresponding sequence of (sets of) output events. A deterministic finite state automaton is one where the next state is uniquely determined by a single input event. But what's a state? We will explain the notion of a state by means of a simple example. Suppose that we want to write a simple program that will count the words of a text file. A simple strategy is to read the input stream character by character and to advance a counter whenever we see a nonblack character provided a Boolean variable is set to true. To avoid advancing the counter while reading the characters of a word, we set the Boolean variable to false. So, from this example, it is obvious that our program will be in two states: In and Out. In addition, we change state simply by setting the Boolean variable to true or false, respectively. We will now describe the structure of an ΩΤΡ file.
Usually, OTPs are stored in files that have the . otp filename extension. An ΩΤΡ file consists of six parts. Some of them have default values and may not be present in an ΩΤΡ file. The six parts are: the input, the output, the tables, the states, the aliases and the expressions. The input and output parts specify the number of bytes occupied by each character of the input and output streams. The input and output parts are specified as follows:
input: n u m b e r; output: n u m b e r ;
Here, number is either a decimal, an octal (preceded by ®’), a hexadecimal (pre­
ceded by @"), or an ASCII character enclosed by a grave accent and an apostrophe. Note that for hexadecimal numbers the digits above 9 can be in either uppercase or lowercase form. If we omit either of these parts, Ω assumes that number is equal to 2 (the number of bytes each UCS-2 character occupies). The tables part
2. The fi ligature of the main font of this book is designed so that the dot above letter i does not vanish in the fi glyph. So, we had to use another font where the dot vanishes.
ί ο .2 Τ η ε Ω T y p e s e t t i n g E n g i n e -· 3 ° 7
is used to define arrays that will be referred to later in the expressions part. To make things clear we give a simple example. Suppose that we want to map the characters of some extended ASCII character set to their Unicode counterparts. Then, we define the array ASCII with length equal to the number of characters with code point greater than 127 (in extended ASCII). Next, we assign to each array element the code point of the corresponding Unicode character. Now, it is easy to get the Unicode code point of an extended ASCII character with code point C with the expression ASCII [C-F], where F is the code point of the first non-ASCII character that appears in the extended ASCII character set. Of course, we can use this “trick" only if Unicode preserves the character order of the corresponding extended ASCII character set, which is the case for most character sets. The ta­
ble part begins with t a b l e: and is followed by one or more t a bl e - s pe c s. Each t abl e- s pecs is terminated with a semicolon (;) and its syntax follows:
table-id [ t abl e-l engt h~\={_t abl e-ent ri es }
Here, t a b l e - i d is the name of the array. The name of a t a b l e - i d, as well as all names appearing in an ΠΤΡ file, must start with a letter and can be followed by zero or more letters, underscores, or digits. The t abl e- l engt h is the length of the table (i.e., a number). Finally, t abl e - e nt r i e s is a comma-separated list of numbers. The following is the table part of a real ΩΤΡ:
tables: tab8859_7[©"60] = { ©"00A0, «"0371, ©"0372, ...};
T h e s t a t e s p a r t i s u s e d t o d e f i n e states that will be used later in the expressions part. The states part is optional and if present it must be specified as follows:
s t a t e s: s t a t e - l i s t ;
Her e, s t a t e - l i s t is a comma separated list of state names. Here is a fragment of the states part of a real ΩΤΡ:
s t a t e s: ESCAPE, JISX0208_1978, JISX0208_1983, JISX0212;
The aliases part is used to define expressions that are frequently used in the expressions part. The aliases part is also optional and its syntax is
a l i a s e s: a l i a s e s - l i s t
whe r e t he a l i a s e s - l i s t consists of one or more definitions:
aliase-name - left ;
left is defined below. Here is a simple aliases part:
a l i a s e s: ESC = ©"lb; LSO = ©"Of;
The last part of an ΩΤΡ, namely the expressions part, is the most interesting and important part. This part starts with the keyword expression followed by a colon and a list of expressions. Individual expressions have the form
LeftState TotalLeft Right PushBack RightState ;
30 8 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
where Lef t St at e defines for which state this expression is applicable, Tot al Left defines the left-hand side regular expression, Right defines the characters to be output, PushBack declares which characters must be added to the input stream, and Ri ght St at e is used to define the new state. Roughly speaking, a regular expression is a character string that contains wild-card characters. For example, a very simple form of regular expression is used in commands that list the files of a directory. Here is how an ΩΤΡ operates: if it is in a given state Lef t St at e and the regular expression Tot al Left matches the beginning of the input stream, then it skips to the character that immediately follows the substring that matched Tot al Lef t, the characters generated by Right are put onto the output stream, the characters generated by the PushBack are placed at the beginning of the input stream, and, finally, the system changes its state to Ri ght St at e. The characters that have been put back to the input stream will be looked at upon the next iteration of the automaton. We will now describe the syntax of expressions.
The Lef t St at e can be either empty or of the form <StateName >. The syntax of Tot al Left is
beg: l e f t s end:
Note that both beg: and end: are optional. If beg: is present, the regular expression will succeed only if it can match the beginning of the input stream. Similarly, if end: is present, the regular expression will succeed only if it can match the end of the input stream. The l e f t s is a list of l e f t items separated by vertical bars. Certainly, if the list consists of only one I e f t, we must not put a vertical bar at the end of it. A l e f t item can be:
• A number, a list of space separated numbers, or a range of numbers specified as n-m, where n and m are numbers, which match any current character that has code point in the specified range.
• The character ".", which matches anything.
• A parenthesized list of l e f t items separated by vertical bars. This list de- notes a choice (i.e., the ΩΤΡ will try each l e f t from left to right to see if it can be "applied" to the input stream). If we put the symbol ~ in front of the parenthesized list, then this means that if each l e f t will fail, the whole expression will succeed.
• An alias-name surrounded by curly brackets. In this case, we substitute the l e f t
item with what the alias-name
stands for.
• A l e f t item followed by <n,m>. Here, both n and m are numbers, and m is optional. Its meaning is that I e f t must match between n and m times; if ra is missing, then l e f t must match at least n times.
The syntax of Right is: => chars, while the syntax of PushBack is:
<= chars
, Here, chars
is one or more char
items, which, in turn, can be:
• An ASCII character string enclosed in double quotation marks (e.g., "abc") or a number.
• The expression \n, where n is a number, corresponds to the nth character of the string that matched the To t a l L e f t. For example, \1 is the first character
of this string.
ί ο .2 Τ η ε Ω T y p e s e t t i n g E n g i n e 3 ° 9
• The expression \$ corresponds to the last character of the string that matched the Tot al Lef t, while the expression \($ - n ), where n is a number, corre­
sponds to the nth character from the end of the string that matched the Tot al Lef t.
• The expr e s s i on \* de not e s t he whol e s t r i ng t h a t ha s b e e n mat ched.
• The expr es s i ons \( * - n ) a n d \( * + n ), whe r e n i s a number, de not e t he whol e s t r i ng t h a t ha s b e e n ma t c he d wi t h o u t t he l as t or f i r s t n char act er s, r es pec­
ti vel y, a n d t he expr e s s i on \ (*+n-m), wh e r e m i s al so a number, i s t he ma t c h­
i ng s t r i ng wi t h o u t t he f i r st n a n d t he l as t m char act er s.
• Fi nal l y, i t can be a n ar i t hmet i c expr ess i on: #ari t hmet i c- expressi on,
For i nst ance, t he f ol l owi ng i s a n exampl e of a n ΠΤΡ t h a t t r a ns f or ms i n a Gr eek t ext t he l et t er (3 t o 6 i f i t does n o t occur a t t he be gi nni ng of a wor d.
e x p r e s s i o n s:
{LETTER}© ,,03B2@"03B 2 => \1 ©"03D0 <§"03D0 ;
{LETTER}®1103B2 => \1 @"03D0 ;
. => \1;
The number @"03B2 corresponds to β and the number @"03D0 to 6. Of course, LETTER is an alias that corresponds to the (code points of the) Greek letters. Here is another example. Suppose that we want to write an ΩΤΡ that will transform text written in the Latin transcription of the Cherokee syllabary (see Table 10.8) to Unicode. The only real problem is the handling of the syllables: s, sa, se, and so on. The following code fragment shows exactly how we can tackle this particular problem:
end: => <§"13CD;
a,| <e,| ti,l <o,l <u,l tT,>
'13CD <= \2;
=> 13CC; => 13CE;
Here is what we actually do: if the input stream contains only the letter s, then we emit the character with code point ©" 13CD; otherwise, if there is a leading s that is not followed by an a, or an e, and so on, then we emit the same character and push back the character that follows s. Of course, it is now easy to handle the cases where the head of the input stream consists of the letters s and a, or s and e, and so on.
As we have shown with the array “trick," arithmetic expressions are really
useful, sn it is not surprising that OTPs support arithmetic expressions. The ralrn- lations performed by an arithmetic expression refer to the string that matched the regular expression. An arithmetic expression can be one of the following:
• A number or the expressions \n, \$, or \ ($-n). All of these expressions have the expected meaning.
3 ΐ ο -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
• Suppose that a and b are arithmetic expressions. Then a + b, a - b, a * b, a div: b, a mod: b, and (a) are all arithmetic expressions. The symbols +, -, *, and d i v: are used to perform addition, subtraction, multi­
plication, and division, respectively. The symbol mod: returns the quotient of the integer division of the two operands. Parentheses are used to override operator precedence (e.g., to perform an addition before a multiplication).
• The expression t abl e - i d [ar i t hmet i c- expres si on] is used to get an ele­
ment of an array.
We note, again, that an arithmetic expression must be prefixed with the symbol #. Here is how we can implement the array “trick”:
expressions:
<§"00-©"9F => \1;
©"A0-@"FF => #(tab8859_7[\1-@"A0]);
=> ©"FFFD;
The character @"FFFD is the replacement character and is used to replace an incoming character whose value is unknown or unpresentable in Unicode. Readers not famil­
iar with regular expressions are advised to experiment with a real programming language that supports regular expressions, such as Perl [29].
The Ri ght St at e can either be empty or can have one of the following forms: <state-name>, <push: stat e-name>, or <pop:>. If it is empty, the ΠΤΡ stays in the same state. If it is of the first form, the ΩΤΡ changes to state s t a t e-name. The second form changes the ΩΤΡ to state <state-name > but saves the previous state into a special data structure. Finally, the third form returns the ΩΤΡ to the state that was previously saved into this special data structure and of course deletes this state from the data structure.
>■ Exercise 10.2 Unicode contains two different characters for the Greek small letter theta—& (@"03D1) and Θ (@"3B8). According to [4], when typesetting Greek text, we should use θ only at the beginning of a word. Write an ΩΤΡ that will implement this typographic convention. □
> Exercise 10.3 Write an ΩΤΡ that solves the “fi" ligature problem de­
scribed above. □
An Ω compiled translation process (or OCP, for short) is the binary equivalent of an ΠΤΡ. The program o t p
2
o c p transforms an ΩΤΡ to an QCP. In addition, the program
o u t o c p transforms an OCP to human readable form. This program is provided for
debugging purposes. If we want an Ω/Λ file to read an OCP, we have to use the following command:
\ocp\IntemalOCPname=RealOCPname
Here, \I nt emal OCPname is a new control sequence with which we will refer to the actual QCP named RealOCPname. An OCP list is a mechanism to combine OCPs. The
ί ο .2 Τ ηεΩ Typesetting En gine -φ- 3 1 1
QCPs of an QCP list are applied one after the other to the input stream. QCP lists are like the pipes that are available in most operating systems. Roughly speaking, pipes are sequences of programs where the output of one program is the input of the next program in the pipe. Merging two pipes means that the input to the first program of the second pipe is the output of the last program of the first pipe. However, this is the fundamental difference between pipes and QCP lists. An QCP list consists of pairs where the first element is a number and the second is an QCP. Now, when we merge two QCP lists, we get a new QCP list whose elements are sorted using the first element of each pair in ascending order.
To build an OCP list, we use the five commands \n u l l o c p l i s t, \a d d b e f o r e - o c p l i s t, \a d d a f t e r o c p l i s t, \removebef o r e o c p l i s t, and \re mo v e a f t e r o c p l i s t. The command \o c p l i s t is actually used to build an QCP list:
\o c p li s t \ListName = ocpLi st
If we are creating an ocpLi st from QCPs only, then we must use the \nullocplist command at the end. The effect of this command is to create an empty QCP list, which is then populated with QCPs. Here is an example:
\o cp\0CPut f=inutf 8
\ocp\0CParab=uni2cuni
\ocplist\OCPArablistutf=\addbeforeocplist 1000 \0CPutf
\addbeforeocplist 1000 \0CParab \nullocplist
If the \nul locplis t is replaced by an existing QCP list, then we get a modified version of the existing QCP list. An QCP list forms a queue, so we can add or remove QCPs from the head or the tail of the queue. Given an QCP list I, the command \addbe- foreocplist n ocp ί adds the ocp at the head of the list. The number n is used to form the pair that we were talking about before. This number is used to place the QCP in a position so that the order is preserved. The command \addafterocplist n ocp I adds the ocp at the end of the list and takes care so that the order is preserved. The command \removebef oreocplist η I removes from the head of t the QCP with number n. Similarly, the command \removeaf terocplist n t removes from the tail of ί the QCP with number n. Having defined our QCP lists, we must be able to activate and deactivate them. To activate an QCP list, we use the command \pushocplist o c p Li s t. The command \popocplist deactivates the last QCP list that has been activated. To deactivate all QCP lists, we use the command \clearocplist. To see which QCP is active while Q processes an input file, set the variable \ocptracelevel to a number greater that zero, such as
\ocptracelevel=l
The authors of Q present in [11] the use of external QCPs. An external QCP is a program written in some real programming language that reads data from the keyboard
(or the standard input in general) and writes data to the screen (or the standard output
3 1 2 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
in general). When using an external OCP, Ω actually forms a pipe that sends the current input stream to the external OCP, which, in turn, processes the input stream and sends the result back to Ω for further processing. The command \e x t e r n a l o c p is used to introduce an external OCP, while it is activated as a normal OCP. Let us give a simple example. Suppose that we have an QCP that solves the "fi" ligature problem and an external program that prints the word f i f i ten times. When the following A file is processed, the output will "contain" the text that precedes the use of the OCP list, the "word" fifi ten times (without fi ligatures), and the text that follows the use of the OCP list.
\documentclass{article}
\begin{document}
\ocp\FIlig=filig \externalocp\FIgen=figen {}
\ocplist\MyOCP=
\addbeforeocplist 1 \FIgen \addbeforeocplist 2 \FIli g \nullocplist text text text text text text text {\pushocplist\MyOCP text text > text text text text text text text \end{do cument)-
Note that the name of the external program must be followed by {>. Also, the text inside the local scope is completely ignored, as the external QCP does not need input.
>- Exercise 10.4 What is the paper size used in the example above? □
In [11], the authors of Ω present a little Perl script that has been designed to detect spelling errors by using i s p e l l. However, the script presented in their paper has a couple of errors (remember: to err is human!). Here is a slightly modified version of the external QCP that actually works:
#!/usr/bin/per1 (SIM = <>;
$in = sprintf "%s", SIN;
open OUT, "| i s p e l l - t -1 > tmp.spell";
print OUT $in;
close OUT;
open IM, "tmp. s p e l l 11; while (<IN>) {
foreach $mot ( s p l i t /\n/, $_) {
$M0TS{$mot}=$mot;
>
>
ί ο .2 Τ ηεΩ Typesetting En gine -φ 313
close IM;
foreach $mot (sort keys %M0TS) {
$in =~ s/$mot/\\textcolor{red}-{$mot}-/g;
>
print $in;
Try the following A input file to see what happens:
\do cument class [a4paper] {article}- \usepackage{color}
\externalocp\OCPverif=verif.pi O \o c p l i s t\v e r i f ier=
\addbeforeocplist 100 \0CPverif \nullocplis t \begin{document}
\pushocplist\verifier
This i s a semple taxt that has errors.
\end{document}
Ω can operate in four different input modes. Each mode characterizes the character
set used to prepare the input file. The input modes are:
onebyte Each character occupies exactly one byte and includes ASCII, the various ISO-8859-X, and the shifted East Asian character sets.
ebcdic The EBCDIC character set is IBM's 8-bit extension of the 4-bit Binary Coded Decimal encoding of digits 0-9. This mode is useful only on machines that support this character set.
twobyte Assumes that each character occupies exactly two bytes (i.e., the input is encoded with the Unicode UCS-2 encoding).
twobyteLE The same as twobyte, but characters are encoded in little endian order. In little endian order, the most significant bits are stored at the end of a byte cluster. The opposite convention is called big endian order. To see the difference, consider the character Σ ( g r e e k l e t t e r c a p i t a l s i g m,). In big endian, this letter is @"03A3, and in little endian it is ®"A303.
Here are the primitives for manipulating modes:
\Def aultlnputMode mode Sets the default input mode to mode.
\noDef aultlnputMode Ω processes input just like T^X does.
\Def aultOutputMode mode Sets the default output mode to mode.
\noDef aultOutputMode Ω generates output just like T^X does.
\InputMode f i l e mode The input mode for f i l e is changed to mode, where f i l e can be either current f i l e, meaning the current input file, or a file number (i.e., a number that is used to identify an external file name). For most purposes, the use of currentf i l e will be enough.
XnoInputMode f i l e Now, Ω processes f i l e just like T^X does.
314 ^ 10 M u l t i l i n g u a l T y p e s e t t i n g
\OutputMode f i l e mode The output mode for f i l e is changed to mode, where f i l e can be either currentf i l e, meaning the current input file, or a file number. \noOutputMode f i l e Π generates output to file f i l e just like T^X does.
There are also a number of primitives for manipulating translations. These commands are primarily intended for "technical translations," such as onebyte to twobyte or from little endian to big endian. However, we warn the reader to avoid using these commands, as they may change the way commands are expanded. Here is the list of these commands:
\Def aultlnputTranslation mode ocp Sets the default input translation for mode to ocp.
\n o De f a u l t l n p u t T r a n s l a t i o n mode There is no longer a default input translation for mode.
\Def aultOutputTranslation mode ocp Sets the default output translation for mode to ocp.
\I n p u t T r a n s l a t i o n f i l e ocp The input translation for f i l e is ocp, where f i l e can be either current f i l e or a file number.
\noInputTranslation f i l e There is no longer an input translation for f i l e. \OutputTranslation f i l e ocp The output translation for f i l e is ocp, where f i l e can be either currentf i l e or a file number.
\noOutputTranslation f i l e There is no longer an output translation for f i l e.
Cur re nt l y, o n e c an u s e t he Ome gaSe r i f a nd Ome gaSans t y pe f a c e s wi t h Ώ f or t r ul y mul t i l i ng ua l t y pe s e t t i ng. I n part i cul ar, t o t y pe s e t Ar abi c t ext, o n e s ho ul d u s e t he OT1 f o nt e n c o d i n g and t he omarb f o nt f ami l y. For Eur o pe a n t ext, o n e s ho ul d u s e t he OT1 f o nt e n c o d i n g and t he o ml g c f o nt f ami l y. I n a ddi t i o n, o ne has at h i s/he r d i s p o s a l t he uc t t mo no s p a c e d f o nt f ami l y.
I n t he f o l l o wi n g s e c t i o ns, t he r e ade r wi l l ha v e t he c hanc e t o s e e real a ppl i c a t i o ns of OCPs.
10.3 The £-TpX Types et t i ng Engi ne
ε-ΤβΧ i s a c t ua l l y a s uc c e s s o r of b o t h ΤβΧ and T]hX—XgT ( t he bi di r e c t i o na l v e r s i o n o f TeX). Nor mal l y, ε- TgX o pe r a t e s i n T^X mo de. To e nt e r t he ΤβΧ—Xj T mo de, we mus t s e t t he s t at e var i abl e \Te XXe Ts t a t e. Us ual l y, w e s e t t hi s var i abl e t o 1 t o e nt e r T]hX—XgT mo d e a nd t o 0 t o r e ve r t t o nor mal T^X mo de. The c o mma nds \b e g i n R and \e ndR are u s e d t o t y pe s e t t e x t wi t h a r i g ht - t o- l e f t wr i t i ng di r e c t i on. The c o mma nds \b e g i n L and \e ndL are u s e d t o t y pe s e t t e xt wi t h a l e f t - t o - r i ght wr i t i n g di r e c t i o n i n s i d e a r i ght - t o- l e f t "e nvi r onme nt." ε-ΤρΧ e x t e nds t he a l l o wa b l e numbe r o f c ount e r s a nd l e ng t h var i abl e s f r om 256 t o 32767. Ano t he r i nt e r e s t i ng f e at ur e of ε- TgX i s t hat i t a d ds s ynt ac t i c s ugar s o ar i t hme t i c e x pr e s s i o ns are wr i t t e n i n a nat ur al way. He r e i s an e xampl e:
ί ο 4 T he G r e e k L a n g u a ge^· 3 15
\ifdim\diinexpr (2pt-5pt) *\numexpr 3-3*13/5\relax + 34pt/2<\wd20
\e l s e
\f i
Note that length expressions are prefixed by the \dimexpr command and numerical ex­
pressions are prefixed by the \numexpr command. Note also that we use the "expected" symbols when writing down an arithmetic expression. The constructs \ifdim-\f i and \ifnum-\fi introduce two control constructs like those found in ordinary computer languages. In addition, ε-ΤβΧ provides a number of other constructs that are really use­
ful when it comes to macro definitions. All in all, we do believe that neither Ω nor ε-TgX can be a true ΤβΧ successor. We must definitely incorporate ideas from both systems when the time comes to develop a universally accepted T^X successor.
10.4 The Greek Language
Although the name of T^X derives from the common root of two Greek words, only recently has it become possible to prepare a LT^X/A document and process it with the mainstream tools, babel provides the greek option (by Apostolos Syropoulos3) and the polutoniko language attribute. The option allows people to prepare documents in monotonic Greek, while the language attribute is useful for the typesetting of polytonic Greek. When preparing a Greek document, the following transliteration is actually employed:
Γ\ R Λ' ?> F Γ ΤΊ f t 1 V A I I V
abgde z h j i k l m n
ξ ο π ρ σ τ υ φ χ ψ ω ς x o p r s t u f q y w c
C l a u d i o B e c c a r i d e s i g n e d t h e s t a n d a r d G r e e k f o n t s i n s u c h a w a y t h a t o n e d o e s n o t h a v e t o u s e t h e c h a r a c t e r "c" t o g e t t h e l e t t e r ς [ 1 ]. O f c o u r s e, t h i s t r a n s l i t e r a t i o n m a y b e h e l p f u l f o r p e o p l e w i t h o u t a G r e e k k e y b o a r d, b u t f o r G r e e k s i t i s u n a c c e p t a b l e t o w r i t e G r e e k u s i n g a L a t i n t r a n s l i t e r a t i o n. S o, t h e f i r s t a u t h o r d e s i g n e d t h e i s o - 8 8 5 9 - 7 i n p u t e n c o d i n g, w h i c h i s s u i t a b l e f o r b o t h U n i x a n d M i c r o s o f t W i n d o w s. F o r M a c O S, D i m i t r i o s A. F i l i p p o u h a s d e s i g n e d t h e m a c g r e e k e n c o d i n g. B u t, a l t h o u g h w e c a n u s e t h e s e t w o e n c o d i n g s, w e s t i l l n e e d a m e c h a n i s m t o e n t e r a l l p o s s i b l e a c c e n t s a n d b r e a t h i n g s y m b o l s t h a t a r e n e e d e d t o c o r r e c t l y t y p e s e t p o l y t o n i c G r e e k. H e r e i s w h a t w e h a v e t o t y p e i n o r d e r t o g e t t h e c o r r e c t a c c e n t a n d b r e a t h i n g s y m b o l s:
3. W h e n w e d o n o t m e n t i o n t h e a u t h o r o f a b a b e l o p t i o n, t h e r e a d e r m u s t a s s u m e t h a t i t i s J o h a n n e s B r a a m s.
316 -φ io M u l t i l i n g u a l T y p e s e t t i n g
Accent
Symbol
Example
Output
acute
g J at a
γάτα
grave
<
dad* i
δαδί
circumflex
ful~hc
φυλής
rough breathing
<
<Jotan
όταν
smooth breathing
>
>’aneu
αν ευ
subscript
1
>anate’ i l h |
άνατείλη
dieresis
It
qa"ide’uh|c
χαϊδεύης
Note that the subscript symbol is placed after the letter. The last thing someone must know in order to be able to write normal Greek text is the punctuation marks used in the language:
Punctuation Sign
Symbol
Output
period
.
*
semicolon
9
•
exclamation mark
!
1
comma
9
/
colon
;
I
question mark
7
/
left apostrophe
< i
\ \
right apostrophe
) )
left quotation mark
((
«
right quotation mark
))
»
When typesetting Greek text, the command \t e x t l a t i n can be used for short passages in some language that uses the Latin alphabet, while the command \l a t intext changes the base fonts to the ones used by languages that use the Latin alphabet. However, all words will be hyphenated by following the Greek hyphenation rules! Similar com­
mands are available once someone has selected some other language. The commands \t e x t greek and \greekt ext behave exactly like their Latin counterparts. For example, the word Μιμης has been produced with the command \t extgreek{Mi μης>. Note that one cannot put a circumflex on a vowel using these commands —it is mandatory to enable the polutoniko language attribute.
The greek option offers the commands \Greeknumeral and \greeknumeral, which are used to get a Greek numeral in uppercase or lowercase form:
Command Output
\Greeknumeral-C9999} \greeknumeral{9999}
ί ο 4 T he G r e e k L a n g u a ge^· 3 1 7
In order to correctly typeset the Greek numerals, the g r e e k option provides the fol­
lowing commands: \qoppa (h), \sampi (^), and \s t i g m a (9 ). In addition, we can get the so-called Attic (or Athenian) numerals with the command \athnum provided by the athnum package (by Apostolos Syropoulos with assistance from Claudio Beccari, who designed the necessary glyphs in the standard font).
Command
Output
\ at hnum{9999}-
Ιχ ΙΧΧΧΧΙηΙΗΗΗΗΙδΙΔΔΔΔΠΙΙΙΙ
\athnum{2002}-
XXII
Note that the package grnumalt (by Apostolos Syropoulos) can be used to get Attic numerals without using the greek option and Greek fonts.
The command \Grtoday typesets the current date using Greek numerals instead of Arabic, so the command \today prints 20 Αύγουστου 2002 and the command \Grtoday prints Κ' Αύγουστου ,ΒΒ'. Finally, the greek option provides the commands \Digamma (F) and \ddigamma (f), which are necessary to typeset archaic Greek texts. The package grtimes [24] (by Apostolos Syropoulos with assistance from Antonis Tsolomitis) allows users to typeset their documents using the Times Roman typeface.
Although Ω is currently our best choice for multilingual typesetting, there is still no single package that can cover at least the European languages. In [9] the authors of Ω describe a Greek option of the omega package, dated 1999/06/01, that can practically process text in Greek, English and French. Recently, Javier Bezos released his lambda package, which is actually a reimplementation of the omega package. The only "real" advantage of this package is that it can also process Spanish text. However, the package is not yet stable, so it is necessary to develop a package that will cover at least the European languages, and the authors of this book are working in this direction.
When using the omega package, we declare the main language of the document with the \background command. Additional languages can be "loaded" with the \load command. The last version of the package supports the greek, the us english, and the french options (languages). To switch languages, one can use the command \l o - calLanguage, where Language is any of the three languages. Certain features can be enabled by adding a comma-separated list of key=value pairs. The key accents allows the processing of either monotonic or polytonic Greek text. The only difference is that the symbol = is used instead of ~. Of course, this is just a convention implemented by an ΠΤΡ. To allow the two forms of the letter (3, use the key beta with value twof orm.
Although DTjiX comes tuned to write the most demanding mathematical text, this is not the case with philological texts. The capability to work with this kind of text can be added using the package teubner by Claudio Beccari. Using this package, it is easy to typeset most philological documents. It is in a preliminary version now, but hopefully
318 -φ io M u l t i l i n g u a l T y p e s e t t i n g
in the future it will provide full support for the most demanding texts. It is supposed to be used with the fonts of Claudio Beccari that have been recently extended to include the italic font used in the past 100 years or so by the Teubner printing company in Lipsia; the font is so well-known in Greece that it is normally referred to with the name of "Lipsiakos."
The Lipsiakos font can be locally selected with the command \textLipsias or by using the declaration \Lipsiakostext, which switches to the Lipsiakos font. For example, to typeset a paragraph with the Lipsiakos typeface, we can use the following construct:
\begin{Lipsiakostext} t e x t \end{Lipsiakostext}-
The package defines several verse environments, several commands for accessing special symbols used by philologists, and commands for producing metrics. The inter­
ested user can find all of the details in documentation that accompanies the package. As a simple demonstration of the capabilities of the package, we give a simple exam­
ple that shows how numbering on the (left) side of a poem works (we start the verse enumeration from 1 and the “subverse” enumeration from 10):
ίο Κνανέοις κόλποισιν ένημένη, άερόμορφε, ιι Ήρα παμβασίλεια, Διός σνλλεκτρε μάκαιρα, ΐ2 ψνχοτρόφονς αύρας ΰνητοΐς παρέχονσα προσηνείς, ΐ3 δμβρων μέν μήτηρ, ανέμων τροφέ, παντογένεϋλε'
5 ΐ4 χοιρίς γάρ σέϋεν ονδέν δλως ζωής φύσιν εγνοχ ΐ5 κοινωνεΐς γάρ απασι κεκραμένη ξρι σεμνώι- ιβ πάντων γάρ κρατέεις μούνη πάντεσσί τ' άνάσσεις ΐ7 ηρίοις ροίζοισι τινασσομένη κατά χεϋμα. ι8 αλλά, μάκαιρα ϋεά, πολνώννμε, παμβασίλεια, ίο ΐ9 ελΰοις εύμενέονσα καλώι γήϋοντι ττροσώτχωι.
The input code that produces the example above follows:
\begin-CLipsiakostext}-
\begin{VERSI}\SubVerso[10] %
Kuan’eoi c k’o l poi s i n >enhni’enh, >aer ’ omorf e , \ \\
>Je l j o i c e>umenJeousa kal “wi g ’hj ont i pros’wpwi. \end{VERSI>
\end{Lipsiakostext}-
10.4.2 Working with Thesaurus Linguae Grecae
Thesaurus Linguae Grecae is a collection of all of the Greek documents from the be­
ginning of the Greek civilization until 1453 A.D. in electronic form. The collection is available in a CD from htt p://www.tl g.uci.edu
and is one of the most important
ί ο .5 The L a t i n L a n g u a g ^ - 319
tools for classicists and people with an interest in Greek literature. The texts are writ­
ten in files using a transliteration similar (but different) to the transliteration of the babel package. For example, they write w)\| instead of babel's >‘w| for the character φ. There are several interfaces to the CD: programs that read the text written in this transliteration and show them in Greek on screen. However, the best one seems to be the d i o g e n e s program (by Peter Heslin). It is a Web interface (it also comes with a command-line tool) that is capable of showing the TLG texts through a Web browser in several encodings, among them Unicode and the babel transliteration. This makes it ideal for typesetting a passage or the whole text of a work using babel or Ω. It is available from http: //www. durham. ac .uk/p. j . heslin/diogenes.
10.5 The Latin Language
The l a t in option (by Claudio Beccari) of the babel package is set up in such a way that hyphenation is prohibited between the last two lines of a paragraph. The medieval attribute should be used for Latin text that follows the conventions and rules of medieval Latin. The main difference between "normal" Latin and medieval Latin is that in the latter we systematically use the letter u even in cases where "normal" Latin uses the letter v; quite the opposite happens when we use uppercase letters^the letter V systematically replaces the letter U even when U is used in "normal" Latin. In medieval Latin the following digraphs were used: ae, oe, /E, and (E. In classical Latin, these digraphs were actually written as two letters. To access these digraphs, one should just use the commands presented in Chapter 3. The lat in option provides the commands, or shorthands in babel's terminology, ~£ and =£. The former is used to place a breve accent above the vowel I (e.g., the command Ai prints 1). The latter is used to place a macron accent above the vowel I (e.g., the input =0 is typeset as o). Note that both commands cannot be used to put accents on digraphs.
10.6 The Dutch Language
The dutch option of the babel package provides a few commands that we will describe
now. The "£ shorthand, where £ is one of the letters a, e, i, 0, or u, has the effect of the command \"£, but the former takes special care when the letter i is used and produces ϊ instead of ΐ. Also, this shorthand does not disturb the hyphenation process. The commands "y and "Y produce the ligatures ij and IJ. These ligatures are very common in Dutch. The command " I disables ligatures. In modem Dutch typography, it is customary to use apostrophe-quote for quoted text (e.g., 'this is quote'). However, the traditional convention was to use the symbols „ and " to open and close a quotation (e.g., „This is a quote"). These symbols are produced by the commands "* and "J, respectively. The Afrikaans language is actually a dialect of the Dutch language spoken
320 -φ- ί ο M u l t i l i n g u a l T ypesetting
in South Africa. This dialect is also supported by babel (option af rikaans). If we do not want to prepare our input file using all of these shorthands, then we simply prepare our input file with an editor that is aware of the ISO-8859-1 character set and use the tlenc package. As far as it regards A, one should type a document using a Unicode editor to avoid all of these commands. Otherwise, the appropriate QCP must be loaded. And since Obabel is still far away, one has to redefine the commands that produce the predefined name strings such as "chapter," "preface," and so on.
10.7 The Esperanto Language
Esperanto is an artificial language intended for use between people who speak different native languages. Esperanto was developed during the period 1877-1885 by L.L. Za- menhof of Warsaw, Poland. The esperanto option defines all of the language-specific macros for the Esperanto language. The language uses the Latin alphabet and the letters
Cl, c, G, g, H, h, J, j, S, s, ύ, and u. All of these extra letters can be accessed with the command where ί is any of the extra letters. For example to typeset the sentence "Mi farisginpor vi," we simply type Mi faris "gin por vi. Of course, if we type our document with the aid of an editor that supports the Latin 3 encoding, then our input file will contain the extra characters of this encoding. For example, in the following screen dump, it is clear that we type Latin 3 characters and use the necessary input encoding;
emacs@oceanKee.duth.gr
_______|_jJ
B u f f e r s F i l e s T o o l s E d i t S e a r c h Mule TeX H e l p
[\] d o c u m e n t c l a s s [ a 4 p a p e r ] { a r t i c l e } \u s e p a c k a g e [ e s p e r a n t o ] { b a b e l } \u s e p a c k a g e [ 1 a t i n 3 ] { i n p u t e n c } \b e g i n { d o c u m e n t J Mi f a r i s g i n p o r v i. e n d { d o c u m e n t }
:— e s p.t e x
B ( N o c h a n g e s n e e d t o b e s a v e d )
( L a T e X ) — L I — A l l —
Thi s i s i n ge ne r al t he me c hani s m by whi c h we pr e par e mul t i l i ng ua l I£I£X i nput f i l es. If we wa nt t o t y pe s e t Es pe r ant o l a ng ua g e do c ume nt s wi t h A, we mus t u s e t he i n 8 8 5 9 3 QCP. Si mi l ar OTPs e x i s t f or ot he r Lat i n e nc o di ng s: i n 8 8 5 9 1 ( f or Lat i n 1), i n 8 8 5 9 2 ( f or Lat i n 2), and i n 8 8 5 9 4 ( f or Lat i n 4).
ί ο .8 T he I t a l i a n L a n g u a g^· 321
10.8 The Italian Language
Currently, A offers no special tools for typesetting Italian documents, but the babel package offers the it a lia n option (by Claudio Beccari). This option disables hyphen­
ation between the last two lines of a paragraph. The command "" is used to enter the opening American quotation marks. Although the introduction of this command may seem redundant, the reality is that with an Italian keyboard it is not easy at all to enter a back-tick! To insert guillemets, one can either use the command "< and "> or the symbols « and », if the tlenc package has been loaded. The various commands that place accents on letters are redefined to avoid elaborate input sequences such as \ ‘ {\i } that can be replaced with the much simpler and more readable V i. Of course, if tlenc has been loaded, these facilities are superfluous. The commands \unit, \ped, and \ap are introduced to enable the correct typesetting of mathematical signs and symbols that are used in the physical sciences and technology (ISO 31-12:1992). More specifically, the \unit command is used to typeset the unit part of a quantity (e.g., the text 3\unit{cm> will be typeset as 3 cm). Note that we get the same output even in math mode! The commands \ap and \ped are used to typeset superscripts and subscripts (e.g., the command $V\ped{min}$ will be typeset as Fmin).
10.9 The Irish and “British" Languages
The default language of both LT^X and A is American English, so the english option is used to enable hyphenation according to the British English conventions. To use the default American English hyphenation patterns, use the american option. The options welsh, irish, and scottish are used for Welsh, Irish, and Scottish, respectively.
10.10 The German Language
German is an official language in five countries: Germany, Austria, Luxembourg, Licht­
enstein, and Switzerland. The babel package provides the options german and austrian (bothby Bemd Raichle), which are suitable for German that uses the old orthography. In August 1998, the new orthography of the German language was officially announced. The new orthography is a unified set of rules on German spelling, hyphenation, and pronunciation. The purpose of this reform was to eliminate inconsistencies in the way the German language has been written to date. The options ngerman and naustrian support the new orthography. As far as it regards babel, the only difference between German and Austrian is the spelling of the name of the first month of the year—fanuar in German and Janner in Austrian. To place an umlaut above a vowel, we use the command "£, where i is a vowel. The commands "s and "z produce the letter β, while the commands 11S and 11Z produce the digraph SS. In addition, the commands 11 ’, 11 *.
322 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
"<, and "> produce the German quotation marks, „ and ", and the opening and closing guillemets, « and », respectively. The command "t t, where t is one of the consonants c, f, 1, m, n, p, r, or t, will force T^X to hyphenate the double consonant as I t - 1. Similarly, the command "ck will force the letters ck to be hyphenated as k-k. Note that these hyphenation conventions belong to the old orthography. As in the case of the Dutch language, we can prepare our input files using the ISO-8859-1 character set if we use the tlenc package.
10.11 The French Language
The f renchb option (by Daniel Flipo) of the babel package implements the typographic conventions of the French language. First of all, this option uses the symbol in all levels of the itemize. If we want to change the symbol used in all levels of the itemize environment, we can use the command \FrenchLabelItem.For example, the command
\renewcommand{FrenchLabelItem}-C\textemdash]-
will change the itemization symbol to an em dash. If we want to change the symbol used in a particular level of the itemize environment, we can use the commands presented in Section 4.3.1. An interesting feature of French typography related to lists is that they occupy less vertical space. This feature can be turned off with the command \French- ListSpacingf alse. The command \FrenchListSpacingtrue turns on this feature. To write quoted text, one can use the commands \og and \f g, which yield the symbols « and », respectively, plus the necessary unbreakable space. If we prepare the input file using the ISO-8859-1 character set, then we have to type « and » to get the opening and closing guillemets. The command \up is provided to typeset superscripts like Mme (abbreviation for "Madame") or l er (for "premier"), and so on. The command has one argument, which is the text that appears as a superscript. Since family names must be typeset using small capitals, the command \bsc is used to correctly typeset family names. For example, the input text Antonis~\bsc{Tsolomitis} will be typeset as Antonis T s o l o m i t i s.
The commands \primo, \secundo, \t e r t i o and \quarto print the symbols 1°, 2°, 3°, and 4°, respectively. Similarly, the commands \fprimo), \fsecundo), \f t e r t i o ), and \f quarto) print the symbols 1°), 2°), 3°), and 4°), respectively. Note that we must type in the parenthesis. More generally, we can create any ordinal with the com­
mand \FrenchEnumerate and \FrenchPopularEnumerate. For example, the command \primo is defined as follows:
\ne w c ommand -C\primo}-[\FrenchEnumerate-[ 1}]-
Note that the output of the command \FrenchPopularEnumerate{l> is 1°)! So, we really do not understand why the user has to type the parenthesis when using commands such as \f secundo). The commands \No and \no print N° and n°, which are abbreviations
ί ο .12 T h e B r e t o n L a n g u a g e ^ · 323
for "Numero" and "numero/' respectively. The command \degres is used to typeset temperatures and alcohol's strength. To typeset a temperature, use 20~\degres C. To typeset the strength of an alcoholic beverage, use 46\degres. The command \nombre is provided to facilitate the typesetting of numerals. This command functions properly in both text and math mode and prints the number in clusters of three digits separated either by a space or by a comma (if the current language is other than French). The commands \FrenchLayout and \StandardLayout are provided so that either the French or the Anglo-Saxon typographic conventions are applied throughout a document. The frenchb option implements also the typographic rule that specifies that some white space should be added before the punctuation symbols ;, !, ?, and :.
Both the omega and the lambda packages provide support for the French lan­
guage. In particular, the lambda package provides the options uppercase (with val­
ues unaccented and accented) and guillemets (with values line, paragraph, and normal), which have the expected meaning. In addition, we can specify the input char­
acter encoding with the option charset, which may assume the value i s o l a t l.
10.12 The Breton Language
The Breton language is a Celtic language spoken in Brittany (NW France). The breton option (by Christian Rolland) can be used to typeset Breton I^T^K documents. The characters ! and ? are shorthands that print a little white space and then the corresponding glyph. The commands \kentan, \e i l, \trede, \pevare, and \pempvet print the numerals 1m, 21, 3re, 4re, and 5vet, respectively.
10.13 The Nordic Languages
The babel options danish, Icelandic, norsk, swedish, f innish, and samin can be used to typeset documents written in Danish, Icelandic, Norwegian, Swedish, Finnish, or the Northern Sami
4
language. The nynorsk dialect of the norsk option is used when we
want to typeset Nynorsk instead of Bokmal.5
The danish option defines the commands " ‘,
" "< and "> which print the symbols
", «, and », respectively. The norsk option also defines the commands "< and "> plus the command "tt, where t is one of the letters b, d, f, g, 1, m, n, p, r, s, or t, and the command "ee. The command "tt forces ΤβΧ to hyphenate the double consonant t t as t t - t. The command "ee will force T^X to hyphenate ee as e-e. The swedish option
4. The Sami language belongs to the Finnic group of languages that are spoken in Lapland.
5. Bokmal (“book language") is used by about 90% of the population. After 400 years of union with Denmark, the Norwegian written language had been very much influenced by Danish. Nynorsk (“new Norwegian") was constructed as a reaction to this. Based on common spoken language in rural Norway, a new written language was constructed by Ivar Aasen, but it has never gained much popularity outside rural regions.
324 "Φ· ί ο M u l t i l i n g u a l T y p e s e t t i n g
defines the commands "a, "o, "w, and their uppercase forms. These commands print the letters a, 0, and a, respectively. The command "££, where £ is one of the letters b, d, f, g, 1, m, n, p, r, s, and t, is used to hyphenate ££ in compound words as ££-£. For example, the words s k o"t t a v l a and s t r a"f f e i h e t will be hyphenated as skott- tavla and straff-feihet, respectively. In Swedish typography, it is customary to use the English quotation marks so there are no special commands to access quotation marks. The f i n n i s h option provides the commands " ‘, "5, " <, and " >, which function just like their Danish counterparts. These commands produce the same symbols when used in the I c e l a n d i c option (by Einar Amason). In addition, the I c e l a n d i c option provides the following commands:
Commands:
"0 "0 "6 "0 "e
"E
"e "E
Result:
q Q q 0 e
3
4 %
The \t a l a command is used to typeset numbers. Here are two examples:
\tala{1234567} 1 234 567
\t a l a { 1 2 3,4567} 123,456 7
The command \grada produces the symbol °, while the command \gradur is used to typeset temperatures and alcohol's strength, as shown in the following example:
5\gradur C | 5 °C
The command \upp functions like the command with the same name provided by the frenchb option. The samin option does not provide any special commands, but we need the letters T and t, which are not available in most standard fonts. An easy way out is to put the following definitions in the preamble of our input files:
\newconrniand-C\tx3~Ct\hspace-[-. 35em}—} \newcommand-C\Tx3"CT\hspace-[-. 5em}—}
>- Exercise 10.5 The commands above produce correct visual results when we typeset our documents with the Computer Modem typeface. The main font of this book is the Palatino typeface and, of course, the commands above are not suitable for this typeface. Rewrite the commands so that they produce correct visual results with this typeface. We remind you that we set Palatino as the document's main font by using the palatino package. □
10.14 The Thai Language
The Thai language is written like all European languages -^rom left to right and from top to bottom. Thai text must be typed in using the TIS-620 encoding (TIS stands for Thai
Industrial Standard). It is interesting to note that ISO-8859-11 is equivalent to TIS-620.
ί ο .14 T h e T h a i L a n g u a g ^ - 325
Currently, there are two approaches to typesetting Thai documents using LT^X—the ThaiTgX system and the unofficial thai option of the babel package.
The ThaiTgX system (by Vuthichai Ampomaramveth) consists of Thai fonts, the thai package, and the program c t t e x, which is a Thai word separator. The Thai script is written continuously without using spaces for breaking between words. A program such as LTgX, then, needs to know where to break the sentence for a new line. So, c t t e x is a preprocessor that does exactly this thing: it adds spaces between words. All Thai files can contain both Thai and English text. The author of the package provides his own commands for font size, series, and shape selection, as the usual commands do not give the expected result. So, the font selection commands are \sptiny, \spscriptsize, and so on. Also, the commands for font series and shape selection are \spbf (for boldface series), \s p i t (for italic shape), and \sprm (for upright shape). Now we describe how to process a document written in Thai. Initially, we prepare our file with our favorite editor ( e m a csmule mode is a good choice). Then, we use c t t e x to separate the words in Thai sentences with a space so that TgX can render Thai paragraphs correctly. After that, we can process the resulting file with LTgX. The following is the output of a simple Thai MeX document.
gnaltafij wwf a aTwATaa
More information on ThaiTgX, Thai fonts, and utilities are available from h t t p:// thaigate.rd.nacsis.ac.jp.
Another approach to typesetting Thai with I^T^K is the thai option of the babel package. The thai option was originally developed by Surapant Meknavin and further developed by Theppitak Karoonboonyanan. All LTgX files that contain Thai text must be preprocessed with swATH(another Thai word separator). This option also provides the command \textthai and the declaration \thaitext for switching to Thai text mode if the main language of the document is not the Thai language. Unfortunately, the current version of the thai option is not officially part of the babel package. Moreover, a serious drawback of this language option is that it cannot coexist with ThaiTgX on the same installation—there are two files with the same name but with rather different functionality. We believe that this is something that has to be tackled by the maintainers of this language option. The latest version of the thai option is available from ftp: //f t p.n e c t e c.or.th/pub/linux.t l e/3.O/SOURCES/.
The current version of Ω provides the intis620 OCP, which transforms Thai text encoded with TIS-620 to Unicode. In addition, it provides a set of Thai fonts. However,
OCPs are useless when it comes to word-breaking, and one has to resort to an external QCP. Here is a skeleton A document that shows how things should be done:
\ocp\InTIS=tis620
\externalocp\WordBreaker=swath.pi O
326 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
\ocplist\ThaiProcList=
\addbeforeocplist 100 \WordBreaker \addbeforeocplist 101 \InTIS \nullocplis t
\begin{document} \pushocplist\ThaiProcList
Here is the source of the Perl script that this A input file uses:
#!/usr/bin/per1
open OUT, "| cttex > tmp.cttex"; while (<STDIN>) { print OUT;
}
close OUT;
open IN, "tmp.cttex"; while (<IN>) { print STDOUT;
}
close IN;
The code is presented without explanation as we do not plan to teach Perl. For this purpose, the reader should consult the Perl bible [29].
The official language of Indonesia is called Bahasa Indonesia. The word bahasa in In­
donesian means "language," so Bahasa Indonesia is the Indonesian language! This lan­
guage uses the basic Latin alphabet (i.e., there are no accented or "stranger-looking let- ters). The bahasa option (by Jorg Knappen) just provides a translation of the language- dependent fixed words for "chapter," "caption," and so on.
10.16 The Slovenian Language
The Slovene option of the babel package can be used to typeset Slovenian language documents with Ι£ΓεΧ. The shorthand "£, where c is one of the letters c, C, s, S, z, or Z, produces the letter c. To get guillemets, one has to use the shorthands "< and ">. The shorthands " ‘ and " ’ produce the symbols „ and ", respectively. Naturally, by using the inputenc package with the l a t i n 2 option, one can avoid using all of these shorthands.
ί ο .17 T h e Ro ma n i a n L a n g u a g ^ · 327
10.17 The Romanian Language
The romanian option of the babel package provides only translations of the various predefined names, so this package is not particularly useful for Romanian language document typesetting. More features are provided by the romanian package (by Adrian Rezus). This package, which cannot coexist with the babel package, allows the type­
setting of multilingual documents. The languages supported are Romanian, English, French, and German. The commands \romanianTeX, \originalTeX, \germanTeX, and \f renchTeX are used to switch languages. The shorthands "a and "A produce the sym­
bols a and a. Note that there are no uppercase forms of these shorthands. In addition, the shorthands "i, "I, "s, "S, "t, and "T produce the symbols ϊ, ί, §, §, and 7, respec­
tively. Note that it is customary nowadays to put a comma under t and T and not a cedilla.
10.18 The Slovak Language
documents written in Slovakian can be processed with the Slovak option (by Jana Chlebikova) of the babel package. In addition to changing all of the predefined fixed names, the option provides the \q command, which has as argument one of the letters t, d, 1, and L and yields the letters f, cT, I, and L, respectively.
10.19 The Czech Language
The czech option of the babel package can be used to typeset Czech language doc- uments. This option provides the \q command, which functions exactly like the \q command of the Slovak option. In addition, it provides the \w command, which puts the 0 accent over the letters u and U. As is obvious, one can use the l a t i n 2 option of the inputenc package to avoid using these commands. Of course, the same thing applies to Slovak language documents as well.
(by Jaroslav §naidr, Zdenek Wagner, and Jin Zlatuska) is a nonstandard ET^K-based format that has been designed to facilitate the typesetting of either Slovak or
Czech language documents. The packages czech and Slovak are the main tools to typeset Czech or Slovak documents. The options IL2, TI, and 0T1 enable the corresponding font encodings. The options s p l i t and nosplit turn the splitting of hyphens on and off.
10.20 The Tibetan Language
The documents written in the Tibetan language can be processed with the otibet pack- age for A (by Norbert Preining). The package contains all of the necessary files to
328 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
process documents writen in Tibetan. The Tibetan text is typed in using either the "Wylie's transcription" or the Unicode v.2.0 transcription. Table 10.1 shows the tran­
scription employed. Double entries in the transcription rows denote Wylie/Unicode transcriptions.
Table io.i: Transcription table for the otibet package.
Transl.
Tib.
nxa/nna
F
zha
ka
'T
ta
7
za
a ·
kha
F
tha
'a
c v
ga
‘T
da
ya
nga
C
na
ta
7
ca
β ·
pa
la
OJ*
cha
« ·
pha
s r
sha
ja
E"
ba
R m
shxa/ssa
p,·
nya
y
ma
*1*
sa
s r
txa/tta
?
tsa
tf·
ha
*)'
thxa/ttha
tsha
<£*
a
dxa/dda
r
dza
Ei*
I
1
dxha/ddha
- 4 -
wa
g
·/
•
To allow A to distinguish between a prefixed "g" and a main "g," we have to put "g" in curly brackets. Short passages in Tibetan can be written using the \texttb command, while long passages can be written as follows:
{\tbfamily \pushocplist\TibetanInputOcpList ...}
> - E x e r c i s e 1 0.6 Cr e a t e a n e n v i r o n me n t T i b e t a n t o b e u s e d f o r T i b e t a n t e x t. □
ί ο .21 T h e Ja p a n e s e L a n g u a g ^ · 329
The package allows the mixing of English and Tibetan text. However, to write, say, Greek and Tibetan text, as in the example
Η ι σ τ ο ρ ί α τ ο υ β ρ α χ μ ά ν ο υ
> 0
^ Ό ^
S ’ c r q a < v q · * * * συνεχίζεται
we have to use the following code:
\ocp\Greek=in88597
\ocplist\GreekInputOcpList=
\addbeforeocplist 1 \Greek \nullocplis t
\newcommand-C\greek} [1] {{\pushocplist\GreekInputOcpList%
\fontfamily-Comlgc}\selectfont #l\popocplist}}
Now, the heading of the text is coded as follows:
\t e x t bf {\greek{H ιστορία του βραχμάνου} \texttb{dbyug pa can }}
For more information on Tibetan fonts and software, see http: //www. cf ynn. dir con. co. uk/Links/bodhsof t _links. html. The otibet package is available from http: //www. l o g i c.at/people/preining/tex/tex.html.
10.21 The Japanese Language
The writing system of Japanese is really a very complex one. A regular Japanese doc- ument contains a liberal mixture of three separate systems! One system is the kanji, which are the ideographs borrowed from Chinese. Today there are about two thousand kanji ideographs in regular use in Japan. The two other systems, which are generically called kana, are much more simple because they are both syllabic. Katakana, the first syllabary, is more angular and is used mostly for transcribing words of foreign origin. Hiragana is more cursive and can be used for grammatical inflections or for writing native Japanese words where kanji ideographs are not used. Because of the complexity of the Japanese writing system, there are a number of Japanese character set standards, all of which are identified by a code starting with "JIS," which stands for Japanese Industrial Standard. The most popularly used Japanese character set is known as JIS X 0208-1990. It includes 6879 characters, among which are the hiragana and katakana syllables, 6355 kanji ideographs, the Roman, the Greek, and the Cyrillic alphabets,
330 -φ· ί ο M u l t i l i n g u a l T ypesetting
the numerals, and a number of typographic symbols. There are three different ASCII- based encodings that are in common use for Japanese text: the ISO-2022-JP encoding, the EUC (Extended Unix Code) encoding, and the Shift-JIS encoding (usually employed in Microsoft Windows and MacOS).
To typeset a Japanese document using I^TgX, one can either use the pI^TgX system or A. pI^T^X sits on top of the pTgX typesetting engine, a modified version of T^X developed for the typesetting of Japanese text by the ASCII Corporation (see http: //
www.ascii.co
. jp/pb/ptex). pIATEX(i.e., I^I^X for pT^X) offers modified versions of all standard document classes: j art ic le (for articles), jbook (for books), and j reports (for reports). The figure that follows shows the first few lines of a pliTjiX file that describes the new features of a pI^TgX release that was available at the second half of the year 2000.
J a r n a c s P o c e a n l .e e.d u t h.g r
B u f f e r s F i l e s T o o l s E d i t S e a r c h M u l e T e X H e l p
pi <2SOO/11/03>
\d o c u * i e n t c l a s s { p i n e w s }
\p u b l 1 c a t l o n y e a r [2 0 0 0 } 35^
\p u b l 1 c a t l o r w o n t h j 1 1 } ”
\p u h l i c a t i o n i s s u e i6 } *;
\a u t h n r { t j j ^ W (\t e x t t t { <
k e n - n a @ a s c i i.c o.j p
> } )
\& m i l f f t u (\t e x t t t { <
h i d e a k - t @ a s c1 1.c o.j p
> } ) 1
\b e g i n {document}
\»ake title
\sect 1onC0 ^S*C-?V^T}
p\L a T e X e { } \t e x t t t - £ < 2 0 0 0/1 1/0 3> J t e x t t t { < 1 9 9 9/0 8/0 9 > } )
iCOV'iT,
LaT^
m i x
\s e c t1o n { f i f A — 1/ a
\bvjgi nJM t^rni zvjj
\1teni 3 E f f i M £ t e\T e X i }
\i t eni | η 1 danfl oat I / Vy~—-y ϊ'η . ____
V t e n. \\t * x l \z i v y I\x k a n j 1 s k i p | v W > * m E ( f t 0
\itcn, tarti cle, t t o o l ^ t r e p o r t ^
|\a d j u s t b a s e l i n e |2H g i E L i L f c. , ,
\item \LaTeX \t e x t t t { < 2 0 0 0/0 6/0 1 > } f c J t i 5 L J t -,
\^ncl{itkinil7^1
\t e x t 1 t f v T e X { } L I v e } i:V v o T i
cn— TUGhoatH^f^MJ.v^
. T i A T e X i ) ( T h o m a s E s s i i r t c J;·
iTJCboatt ..
i i\t e x t i t {\T e X i } L i v e }
:— n l n e ws Of i.t e x ( La Te X) —LI —Tnn-
[ L o a d i n g t e x - m o d e...d o n e
ί ο .21 T h e Ja p a n e s e L a n g u a g ^ · 331
Note that similar files accompany each release of standard I^TjiX. pTjjX also provides modified versions of BmTgX and ma KEiNDExcapable of handling Japanese bibliographies and indices.
By default, pI^TEK uses virtual Japanese fonts that are called min 10, min9, etc., and gothlO, goth9, etc. Therefore, one has to resort to fonts that are available to one's system. For example, on an MS-Windows installation people use TrueType fonts, and on Unix systems the various drivers make use of the v f l i b library, which understands all possible font formats. The situation is better for people working on MacOS. This operating system provides both PostScript Type 1 fonts and TrueType fonts, so they can map min 10 to Ryumin-Light and gothlO to GothicBBB-Medium to preview DVI files. Moreover, ASCII Corp. and other publishers who prepare their publications with pLT^X use Japanese PostScript fonts to typeset their products. If you wonder how they manage to do this, the answer is very simple: the resulting PostScript file uses resident PostScript fonts (i.e., fonts that are provided by a PostScript printer). Such PostScript files cannot be directly previewed with Ghostscript, and we need to patch the program to be able to preview our documents. The necessary information is available from http://www.cit.ics.saitama-u.ac.jp/~far/howto/gs-cid.html
. Of course, the Omega-j system, described below, has the same font problems, but one can use the Ω virtual fonts bundled with pTgX or the one that is part of Omega-j. Now, for ordinary people, a good solution is to use TrueType fonts. Let us suppose that we have a complete TrueType font at our disposal. Then, we also need the programs t t f 2 p k and t t f 2 t f m (see Section 12.6).
The Omega-j system developed by Matt Gushee allows Ω users to typeset Japanese documents written in the ISO-2022-JP encoding. Moreover, Ichiro Matsuda has de­
veloped the necessary ΠΤΡ for the two other encodings that are part of the pTgX distribution, while Hideyuki Suzuki has developed an improved version of the origi- nal ΩΤΡ for the ISO-2022-JP encoding. The people that have developed plftTjjX provide also a Japanese version of Λ that can be used directly to typeset Japanese text, but this version is not portable. A good solution is to create a little package that will be loaded by A and that would provide all of the necessary definitions. Here is a little package that the first-named author of this book has created:
\ocp\JISInput=inj i s
\newcommand-C\japanese}-C\InputTraiislation currentfile \JISInput%
\f ontf amily-f ommincho}\select font}
\endinput
Of course, we have to use the new command introduced by this little package at the beginning of the body of a A document. Moreover, if we want to write text in another input encoding, we can define similar commands. Naturally, we also need a simple font definition file. Before we present the simple font definition file that we created, we must stress that the author of Omega-j provides an QVP file that can be used to create all of the necessary support files, so again we have to find a real font! Of course, one
3 3 2 "Φ" i o M u l t i l i n g u a l T y p e s e t t i n g
can rename this file and use it also for a boldface font and so on. Anyway, here are the contents of the simple font definition file (see Section 12.4):
\ProvidesFile{otlommincho.f d}
\DeclareFontFamily{OTl}{ommincho}0
\DeclareFontShape-COTl}-Commincho}-Cm}-Cn}-[
<-> omminchoJO \endinput
Note that the command \ProvidesFile is used to identify a font definition file. Using these tools, we created a simple Λ file and successfully processed it with A. The output of our file follows
The Omega-j system is available for download from http://www.havenrock.com/
archives/classic/docproc/nihongo/omega-j/index.html.
10.22 The Spanish Language
Although Spanish is spoken in many areas on the globe, babel still provides only the s p a n i s h option (by Javier Bezos) for typesetting Spanish text. If we request Spanish language typesetting with the command
\u s e p a c k a g e [ a c t i v e a c u t e,s p a n i s h ] { b a b e l }
then we can place an acute accent over the letters a, e, i, o, and u, simply by typing ’ £, where I is one of these letters. Similar shorthands can be used for uppercase letters. To get the letters n and N, use the shorthands ’n and ’ M, respectively. The shorthands “-,
~—, ~ produce a hyphen, an en dash and an em dash, but these commands take
care so that a line break does not occur after the dash. The shorthands "u and "c are used to get the letters u and ς. To get guillemets, we have to use the shorthands "< and
11
>. The shorthands « and » behave rather strangely since they place the guillemets,
but if they occur inside another pair of « and » they print the American opening and closing quotation marks. Now, if we have a pair of « and » that occur inside another pair, which in turn occurs in another pair, then the innermost symbols produce the symbols grave accent and apostrophe. Here is an example that makes things clear:
«Ε1 art ’iculo «Estudio de la palabra « a ’n ej o » y sus u s o s » apenas ten’ia in te r’e s »
«Ε1 articulo "Estudio de la pa­
labra 'anejo' y sus usos" apenas tenia interes»
The symbols « and » are actually shorthands for the commands \begin{quoting} and \end{quo ting}. The feature just described is used by default. To deactivate this feature,
ί ο .23 O t h e r I b e r i a n L a n g u a g e s ^ - 333
use the command \deactivatequoting. To reactivate it, use the command \a c tiv e - quoting. In the past, Spanish grammar dictated that if a word was to be hyphenated before a double r, the double r should be transformed into a single r. To enable this rule, we must use the shorthand "rr, e.g., contra"rrelo j. The shorthand " I is used to disable the formation of a ligature, but it is not used at all.
In Spanish mathematical typography, the operators lim, max, and min are accented (e.g., the expression lim^o ^ = 00 should actually be typeset as lim^_0 I — °°)· To deactivate this feature, use the command \unaccentedoperators. Qn the other hand, the command \accentedoperators can be used to reactivate this feature. The command \d o t l e s s i is useful to get the letter 1 in normal text mode as well as in math mode.
Spanish is also supported by the lambda package. To enable the typesetting of Spanish text, use the spanish option.
10.23 Other Iberian Languages
With the aid of the babel package, it is now possible to typeset LTjiK input files written in Portuguese, Catalan, Galician, and Basque. The corresponding options supporting typesetting in these languages are: p o r t u g e s, C a t a l a n, g a l i c i a n (by Manuel Carriba), and b a s q u e (by Juan M. Aguirregabiria).
The port u g e s option defines the shorthands " I, " <, and " >, which are used to disable ligatures and to produce left and right guillemets. These shorthands are defined in all options described in this section. The C a t a l a n option provides a number of shorthands and the following new commands:
Command Output
\Γ Ί Π
\L. L L-L
\lgem 1Ί
\Lgem LL
The activeacute option activates the shorthand > where I can be e, i, o, or u, which places an acute accent over I. Similarly, the act iveagrave option activates the shorthand ‘ I, where i can be a, e, or o, which places a grave accent over L The shorthand " c produces the letter ς, while the shorthands "1 and "L produce the same output as the commands \lgem and \Lgem. The galician option provides the following shorthands:
Ja (accent over all vowels), ’η (n), "u (ii), "a for feminine ordinals as in 2-, and "o for masculine ordinals as in 2Q. The basque option provides the shorthand ~n, which produces the letter n.
3 3 4 ^ ί ο M u l t i l i n g u a l T y p e s e t t i n g
10.24 The Estonian Language
The typesetting of Estonian input files is currently supported only by babel and the estonian option (by Enn Saar). The shorthand "i, where i is one of the letters a, o, or u, produces the letter ϊ. The shorthands ~s, ~z, and ~o print the letters s, z, and o, respectively. Of course, all of these shorthands can also be used with capital letters. The author of this option recommends that people use the tlenc package to get better hyphenation. Note that this package must be loaded before the babel package.
10.25 The Korean Language
Chinese characters, known as hanja, were used to write Korean, in a system called Ido (known also as Ito and Idoo), until the 15th century. However, the system never gained wide acceptance, and its use was very restricted. Tn 1446, after many years of study and testing by the ruler of the time, King Sejong, and his scholars, a unique Korean alphabet, known as Hunminjongum, was introduced. Tine modem Korean alphabet, Hangul, was derived from this earlier form. However, the Chinese characters were not abandoned altogether. For example, Hangul is used almost exclusively in South Korea, but certain newspapers and scholars still use Chinese ideograms, in parentheses, just after words referring to ideas or concepts in general. On the other hand, North Korea has completely abandoned all Chinese characters and uses Hangul exclusively. The KSC-5601 character set, also known as Korean Wansung, includes the Hangul, the Roman, the Greek, and the Cyrillic alphabets plus the Chinese ideograms. Note that the official name of KSC-5601 has changed, and it is now known as KSX-1001. Today, most people use the EUC-KR encoding to type their texts.
The ΗΙ5ΓεΧ "system" (by Koaunghi Un) facilitates the typesetting of Korean text with both l^T^C and A. The basic packages that HI^TfiX provides are the hfont and the hangul packages. The hfont package is used to activate the use of Korean fonts (which are also part of the HL?TeX), but it does not change predefined words such as "chapter," "glossary," and so on. For example, the input file shown below
____________________________emacs©oceanl .ee.duth.gr
Buffers Files Tools Edit Search Mule TeX Help
|\documentclass{arti cle}
]\usepackage{hfont} % We need this package to use HLaTeX-0.991. \beg1n{document}
|My name i s Apostolos and I an from Greece!
\x\±r r+ ■
Vind{document}
- K ( D O S ) — k s c - t e s t.t e x
CLaTeX)— LS—ATI —
ί ο .25 T h e K o r e a n L a n g u a g ^ - 335
will be typeset as follows:
My name is Apostolos and I am from Greece!
Note that we will get the same output regardless of what typesetting engine we use (I^TgX, pdfLTgX, or A). If we want to use the Moonhwabu TrueType font, we must use the moonttf package. The hangul package "koreanizes" the predefined words and thus is suitable for real Korean documents. The package provides the following options:
han j a All names (e.g., "chapter/' "bibliography," etc.) are typeset in Hanja. Otherwise, they are typeset in Hangul, h a r d b o l d Documents are typeset with real boldface fonts, s o f t b o l d Documents are typeset with poor man's bold.
no j osa This option is used to turn off the automatic selection of an appropriate josa. A josa is a functional unit that is used to determine the case of nouns and pronouns. The author of HI£Tj$( has opted to include the automatic josa selection just because in certain cases the josa has different forms depending on the last syllable of the preceding noun or pronoun. Josa is a linguistic phenomenon of the Korean and Japanese languages.
The commands \textmj, \textgt, and \t e x t t z are used to select a Roman, a sans serif, or a monospaced font family. These commands are "koreanized" versions of the corresponding standard commands. The following shows the default font families supported by HLT^X:
My name is Apostolos and I am from Greece!
My name is Apostolos and I am from Greece!
My name i s Apostolos and I am from Greece!
7: L _ - j “ I £ Λ | O -A--|| - p . Ο Π | - ^ 1 _ | C | |-
Numbering in general can be altered by using the following commands:
\jaso:
\gana:
7} L-} t\ ϋ} u} n} λ} o\ 7\ 7\
\ojaso:
(3>©©<§)@®Θ®@@
\ogana:
\pjaso:
(g (t.) (h) ® (h) w (0) & &
\p g a n a:
\onum: φ © © ® © © ® ® ® ®
\o e n g: ® © © ( d ) © © ( D ® © ©
\p e n g: ( a ) ( b ) ( c ) ( d ) ( e ) ( f ) ( g ) ( h ) ( i ) ( j )
N o t e t h a t a l l o f t h e s e c o m m a n d s e x p e c t a c o u n t e r a s t h e i r o n l y a r g u m e n t.
336 "Φ· ί ο M u l t i l i n g u a l T y p e s e t t i n g
V Exercise 10.7 Give the command that will set the page numbering to \gana. □
The ΗΕΤβΧ system provides also the halpha bibliography style and two style files for the generation of indices and glossaries.
10.26 The Hebrew Language
The Hebrew language is supported through the hebrew option of the babel pack­
age (by Boris Lavva). This option assumes that we are actually using ε-TgX as our typesetting engine. In addition, text using only consonants is fully supported. Sup­
port for vowels (nikud) is not yet available through the standard packages, but one may find the necessary files to use vowels at Sivan Toledo's homepage at http://www.math.tau.ac.il/~stoledo
. The following is an example from the doc­
umentation of his work:
,Drt?np3 'irtiy ivob D’p’o vby
The Hebrew script has a right-to-left writing direction. If we want to type in a Hebrew input file, we need a tool that provides both the fonts and the capability to write text from right to left. A good choice is to use LyX from http://www.lyx.org
, which fully supports bidirectional writing. Information about setting up LyX to use Hebrew can be found on Toledo's homepage mentioned above. However, one can always use the babel transliteration for the Hebrew letters if a short passage is to be written. The following table shows the transliteration employed:
ί
a
b
c
d
e
f
g
h
i
j
k
1
m
N
1
y
Ί
Π
ί
Π
V
>
Ί
D
ϊ
O
n
0
P
q
r
s
t
u
V
w
X
y
z
tt
1
1
Ό
V
n
Q
ϋ
P
Ί
n
As is customary for the babel package, one can write in Hebrew without having a Hebrew-enabled keyboard by using the correspondence of the Latin letters to the Hebrew ones. If a Hebrew keyboard is available, then one may load the inputenc package with the appropriate option: 8859-8 for Unix systems, cpl255 for Microsoft Windows, cp862 for the IBM code page usually found on DOS, and si960 for the "old- code" 7-bit Israeli Standard Hebrew encoding. It should be noted here that up to now only the Microsoft code page (cpl255) supports the input of vowels and dots (nikud).
The command \R{Hebrew t e x t > switches to Hebrew and to the right-to-left di- rection in order to typeset the Hebrew t ext. Similarly, the command \L{Non-Hebrew t e x t y is used to switch to another language (left-to-right). These two commands can be used in the middle of a paragraph, thus allowing us to set a Hebrew word in a non-Hebrew paragraph and vice versa. For example, with default language hebrew
and with american and greek loaded, the input
ί ο .
2.6 T h e H e b r e w L a n g u a ge^· 337
\R{abg}- \L{\textlatin{abc}-}- \R{abg}- \L{\textgreek{abg}}-
will produce: αβΥ a^c
The \extrashebrew command changes to Hebrew encoding and to right-to-left writ­
ing direction. This is undone by \noextrashebrew. Two useful box commands are \hm- box and \embox. The first one is for creating a right-to-left box, whereas the second one is for the left-to-right direction. These are very useful when writing Hebrew inside math:
I f 0 ) = 1
was produced by the input n",:iN
$\int\limits_{\hmbox{\scriptsize *acd}} f(x)=l$
The \hebmonth{/nonth} command produces month names in Hebrew. The com­
mand Miebdate-Cdai/MmoniTiMi/ear} translates a given Gregorian date to Hebrew, while \hebday replaces the \today command in Hebrew documents. The \datehebrew command redefines the command \today to produce Gregorian dates in Hebrew. Here are two examples:
\hebdate{26>{12>{2000> 2000 ΊΙΕίΠΙ 26
\hebday 2001 υΟΊΠΝΙ 29
The hebrew option of the babel package supports most aspects of document typeset­
ting. This includes a right-to-left table of contents, table of figures, headers, footnotes, sectioning commands, and so on. To create a right-to-left table of contents, list of figures, and list of tables, we use the commands \r It ableof contents, \r l l i s t o f figures, and \r l l i s t o f tables, respectively. By reversing the first two letters of these commands, we get the lists in the left-to-right direction. Thus, the following commands are available for left-to-right lists: \l r t ableof content s,\l r l i s t of figures, and \l r l i s t of table s. The command \captionshebrew will change the caption names with the Hebrew equiva- lents.
The work of Toledo on nikud is using the ligature mechanism of TgX in order to access precomposed accented letters (the accents are used to specify the correct vowel on a syllable). One font that can be used is the Hebrew font provided by the Ω project, which has been properly modified to work with LT]gX.
Ω has most of the files for Hebrew support ready. Fonts are available (that sup­
port nikud as well) and an OCP for translating the ISO-8859-8 to Unicode (called in88598. ocp). But, the current virtual fonts must incorporate support for Hebrew. Sup­
port for the Microsoft code page (CP-1255) is still to be added as well as the necessary commands for calling the Hebrew scripts. The following defines a simple environment
that permits the typesetting of Hebrew text with A:
\ocp\NewHebrew=in88598
\ocplist\NewHebrewList=
\addbeforeocplist 1 \NewHebrew \nullocplis t
338 "Φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
\newenvironment{newhebrew}{%
\textdir TRT\pardir TRT\pushoplist\NewHebrewList%
}{\popocplist}
10.27 The Cyrillic Script
The Russian, Bulgarian, and Ukrainian languages use the Cyrillic script and are sup­
ported by the babel options r u s s i a n b, b u l g a r i a n and U k r a i n i a n, respectively. The input encodings supported by the inputenc package are: i s o 8 8 5 9 5 for Unix systems, c p l 2 5 1 for Microsoft Windows, and m a c c y r for the Macintosh. Other supported input encodings include: k o i 8 - r, k o i 8 - r u, k o i 8 - u, cp855, and more. Of course, the choice of input encoding depends heavily on the operating system that one uses to prepare an input file. Naturally, sticking to ISO standards is the best solution.
The following code snippet shows what we have to type to typeset a document that conains text fragments that use three different scripts. Note that we have to use the \inputencoding command to (locally) change the input encoding:
{\selectlanguage{russian}-\inputencoding{iso88595)- \begin{verse}- ‘ ‘Russian t e x t ’ ’ \end{verse}-}
{\selectlanguage{greek}-% Greek text in Latin transliteration \begin{verse> *‘Greek t e x t ’ ’ \end{verse}>
\begin{verse} ‘ ‘English t e x t ’ ’ \end{verse}
will be typeset as follows:
Ά π ο μ η Κ ) 3 t o MyAHoe μ γ ηο βθημ θ
K o r 4 a n e p e ^ o m h o h RBUASLCb τ η. ( Π γ ι π κ Μ Η )
Θυμάμαι εκείνη την εκπληκτική στιγμή
Όταν μπροστά μου εμφανίστηκες εσύ. (Πούσκιν)
I remember that wonderful moment when you appeared in front of me. (Puchkin)
Observe that we had to enter the Greek text using its Latin transliteration, as it is not
possible to have three different scripts in an extended ASCII file! Of course, this is possible when typing in the input file using Unicode.
The fonts for Cyrillic script are available in several encodings. The default is the T2A encoding, which contains both Cyrillic and the standard English letters. Other encodings are the X2, OT2, LCY, and LWN, and they are made available if loaded as an option with the fontenc6 package; for example to use the X2 encoding, we should use
6. This package is used to select the font encoding of a particular script. For example, for the Latin script there are two font encodings: the TI (or Cork encoding) and the OT1 encodings.
ί ο .27 T h e C y r i l l i c S c r i p t -φ- 339
\usepackage [X2] {f ontenc}-
The different font encodings offer different characters. For example, the characters « and » are not available with the OT2 encoding but are available with the T2A. Although the T2A encoding is the default, the X2 encoding is more complete, as it contains no Latin letters. With X2, the user has more Cyrillic characters available. In addition to this, users are forced to switch languages using standard (babel-type) commands, and LT^X pays back with correct hyphenation for all languages used. To locally switch to the Cyrillic script, we use the command
\t e x t C y r i l l i c - [ C i/r ’'i£ l i e t e x t } ·
For a global switch to the Cyrillic script, we use the \C y r i l l i c t e x t command instead. The standard commands \t ext l a t i n and \l a t i n t e x t switch back to the Latin alphabet locally and globally, respectively (all of these commands are not needed for the default T2A encoding unless a third language other than English and a language that uses the Cyrillic script is to be used). Of course, to turn on the proper hyphenati on for the languages that use the Cyrillic script we use, for a short phrase, the command
\f orei gnl anguage- Cbul gari an}{5t iI g a r i a n t e x t }
should be preferred (here written for Bulgarian).
The \d a t e r u s s i a n redefi nes the \t oday command to produce Russian dates and similarly for the commands \dat e bul gar i an and \dat eukrai ni an.
An important issue to be noted for these languages is that the character " is made active and used as in Table 10.2.
The quotes in Table 10.2 can also be typeset by usi ng the commands in Table 10.3. The French quotes are also available as ligatures « and » in Cyrillic font encodings LCY, X2, T2A, T2B, and as < and > characters in Cyrillic font encodings OT2 and LWN. Currently, Ω provides the fol l owi ng OTPs:
i n88595 Suitable for conversion to Uni code from ISO-8859-5 (Latin/Cyrillic), i nav Can be used to convert to Uni code from Cyrillic Al temati vnyi Variant. i ncpl 251 When the input file has been prepared usi ng the Cyrillic MS-DOS encoding CP-1251.
i ncp8 6 6 Suitable for conversion to Uni code from Cyrillic MS-DOS encoding CP-8 6 6. i n k o i
8
For conversions to Uni code from Cyrillic KOI
- 8
(GOST 19769-74).
i nov Can be used to convert to Uni code from Cyrillic Osnovnoj Variant, inucode For conversion to Uni code from Cyrillic U-code.
Also, the current version of O fonts does support the Cyrillic alphabet, so it is easy to prepare documents wi th A. Of course, what remains to be done is to change the standard names in the predefined documented classes.
3 4 ° ^ 1 0 M u l t i l i n g u a l T y p e s e t t i n g
Table 10.2: The extra definitions made by russianb, bulgarian, and Ukrainian. 111 disable ligature at this position.
11 - an explicit hyphen sign, allowing hyphenation in the rest
of the word.
11 — Cyrillic em dash in plain text.
11 —~ Cyrillic em dash in compound names (surnames).
" —* Cyrillic em dash for denoting direct speech.
"" like but producing no hyphen sign (for compound
words with hyphen; e.g. x-""y or some other signs such as as "disable/enable").
" ~ for a compound word mark without a breakpoint.
"= for a compound word mark with a breakpoint, allowing
hyphenation in the composing words.
11, thin space for initials with a breakpoint following sur­
name.
" ‘ for German left double quotes („).
" ’ for German right double quotes (").
11 < for French left double quotes («).
"> for French right double quotes (»).
Table 10.3: More commands that produce dashes and quotes.
\cdash-----
Cyrillic emdash in plain text.
\cdash—~
Cyrillic emdash in compound
names (surnames).
\cdash—*
Cyrillic emdash for denoting direct
speech.
\g1qq
for German left double quotes („).
\grqq
for German right double quotes (").
\f l q q
for French left double quotes («).
\f rqq
for French right double quotes (»).
\dq
the original quotes character (").
10.28 The Armenian Language
The arm tex package (by Serguei Dachian, Amak Dalalyan, and Vardan Hakobian) is an effort to provide a complete solution to the problem of typesetting Armenian documents with l5TgX.
The package is loaded in the usual way, by putting the following command in the document's preamble:
\usepackage f options'] -t~armtex~)-
ί ο .28 T h e A r m e n i a n L a n g u a g ^ - 341
It accepts several options. The most important one is the option latin. When this option is not used, the document language is changed to Armenian; that is, the entire document (including the main text, the headers, the table of contents, words such as "chapter," "appendix," etc.) is typeset in Armenian. When this option is used, the document language is not changed to Armenian, but, nevertheless, all of the commands described below become available.
The package automatically loads the OT6 font encoding since it uses Armenian fonts conforming to this encoding. So, using the f ontenc package to explicitly load the OT6 encoding is unnecessary (and may even cause some LTgX errors).
If a user has a standard Armenian keyboard to type in an input file, it is necessary to use the ARMSCII8 input encoding: that is, the following command must appear in the document's preamble:
\usepackage[armscii8]{inputenc}
Otherwise, the text must be entered using the following transliteration:
U iu
A a
I* li
I i
3 j
Υ y
S
Φ
T t
Ρ p
B b
L I
L 1
L Q
Ν η
P
P
R r
q- q
G g
fu \u
X χ
0 2
Sh s h
5
9
C c
η- n
D d
U 5
C> c ’
i l n
0 0
fc
1
W w
b b
E e
^ 4
K k
2 ί
Ch c h
Φ
Ψ
P J p ’
S q
Z z
^ h
H h
'Ί u]
Ρ p
£
e
Q q
fc t
E’ e>
2 δ
Dz dz
2 2
J 3
u
ev
c Π
u ’
Ί η
Gh gh
β- η
RJ r>
0
0
O’ o ’
13- p
Ύ’ t >
β 6
r
U u
S s
Φ
Φ
F f
d* d
GJ g ’
U ύ
M m
V v
flfc ni
U u
Most punctuation and general symbols can be accessed wi th the expected keystrokes. The fol l owi ng table shows the very f ew exceptions:
! '
\! '
7 '
\? ?
1 '
\l -
As we have already seen, mixing scripts wi th LT^X is a cumbersome task. In the case of the armtex package, there are three types of font-changing commands.
1. Orthogonal commands that work like \i t s h a p e or \b f s e r i e s:
\art mf ami l y, \a r s s f ami l y, \armds eri es, \ar bf s e r i e s,
\arupshape, \a r i t s h a p e, \a r s l s ha pe.
2. Orthogonal commands that work like \t e x t i t or \t e x t b f:
3 4 2 ^ 1 0 M u l t i l i n g u a l T y p e s e t t i n g
\armtm, \armss, \armmd, \armbf, \armup, \armit, \armsl.
3. Commands that are not orthogonal, which work like \i t or \b f:
\artm, \artmit, \artmsl, \artmbf, \artmbf i t, \artmbf si,
\arss, \ar sssl, \arssbf, \arssbf si.
Besides choosing Armenian fonts, these commands enter Armenian mode (if needed); that is, they switch to Armenian encoding and set up the commands \- and \today to be Armenian. The declaration \aroff is used to leave the Armenian mode. The commands \rm, \bf, and others are redefined to leave the Armenian mode automatically.
>- Exercise 10.8 Define the command \noarmtext that can be used in Armenian mode to typeset its argument using the Latin alphabet. □
The declaration \armdate can be used to have \today produce the current date in the Armenian way. The declaration \armdateof f cancels the effect of \armdate and so dates are printed in the language that was in use before we switched to the Armenian language. Here is an example:
\today 19 uhuqiptiilpbpli 2001p.
\armdateoff \today 19th September 2001
The declaration \armhyph sets up the command \- to be Armenian. The declaration \armhyphof f cancels the effect of \armhyph.
The commands \armnamesof f and \armnames can be used to force LTjiX to print in the output file the words "chapter," "appendix," and so on in either English or Armenian. Basically, one does not need to mess with these commands, but they can become useful when typesetting a multilingual document combining, for example, babel and arm tex packages.
If we want to use Armenian letters for mathematical symbols, we can use the following mathematical font selection commands: \mathartm, \mathartmit, \math- artmbf, and \mathartmbf i t.
For additional information, the interested reader may refer to the very detailed manual (in Armenian) distributed with the package.
The following shows the names of the authors in Armenian, but which name is which?
Uiqnuipri|riu U}ipnu.]m |nu & Ιίίιφηίφιι 2ημΐΐϊ]ιιρ]ιιι.
10.29 The Polish Language
To typeset Polish text, one can use the polish option of the babel package (by Elmar Schalueck and Michael Janieh). This option provides a number of shorthands that can
ί ο .30 T h e G e o r g i a n L a n g u a g £ - 343
be used to print additional Polish letters. More specifically, the shorthands "a, "A, "e, and "E print the letters 3, P\, ς, and ξ, respectively. In addition, the shorthands "1, "L, "r, "R, "z, and "Z print the letters L, I, z, Z, z, and Z, respectively. Guillemets can be printed with the shorthands "< and ">, while " ‘ and " ’ produce the opening („) and closing (") quotation marks.
The Ρΐ^ΓβΧ system (by Mariusz Olko and Marcin Wolmski) has been specifically de­
signed to typeset Polish language documents. The system consists of a version of LT^X with the hyphenation patterns of the Polish langauge preloaded, the polski package, and some other support files. The system solves the problem of directly entering Polish language text, much like inputenc does. However, the polski package offers a number of options that make things even easier, p l m a t h should be used to load Polish language fonts for use in mathematical text, n o m a th s y m bo ls deactivates the use of Polish names for standard mathematical functions. The options ΤΙ, 0T1, and 0T4 activate the corre­
sponding font encodings, and last, the MeX option allows the processing of LMgX files. T^M^X is a special T^T^X format that is based on an obsolete version of LT^X.
10.30 The Georgian Language
The Georgian language uses two scripts the Mkhedruli (secular script) and the Khutsuri (ecclesiastic script). Mkhedruli is a caseless script (i.e., there is only one form for each letter) and is the official script of Georgia. The Khutsuri script is used mainly by the Georgian Orthodox Church. Currently, only the mxedruli and the xucuri packages (by Johannes Heinecke) provide rudimentary support for typesetting Georgian language documents with I^TgX. The two input encodings Georgian-Academy and Georgian-PS have not found their way into the ΤβΧ/Ω world so one must type in Georgian text using a transliteration. For the Mkhedruli script, the following transliteration is employed:
«i
b
3
0
3
%
ai
a
b
g
d
e
v
z
t
3
i -
6
n
3
1
.k
1
TI
n
o
•P
+z
n
b
6
<2
d
ϋ
r s . t
TI
P
k
•g
HI
fi
ϋ
-t-
b
+s
+c
c
j
. c .+c
X
+j
h
The mxedruli package provides the commands \mxedr, \mxedb, \mxedi, and \mxedc, which select the Roman, the boldface, the italic, and the caps and small caps typefaces, respectively. It is even possible to put accents above Georgian letters (this is a feature of some Kartvelian languages). The commands V, \=, and V are used to put a circumflex,
3 4 4 ^ 10 M u l t i l i n g u a l T y p e s e t t i n g
a macron, or an umlaut on the letter that follows the command. The following table shows the transliteration employed for the Khutsuri script:
c
*!,·
A,
a
Ί ·,
I, i
J1 ih
R,
r
a u
+S, +s
a
B,
b
K, .k
I b
s,
s
b fl
+C, +c
TS
G,
g
b ta
L, 1
* B
.T
, .t
Gi g
C, c
δ τ
D,
d
th d
M, m
0 * mf
u,
u
A th
J. 3
τ
E,
e
E 6
N, n
V T
p,
P
R pi
.C, .c
•ψ
v,
V
CL hi
0, o
+ φ
K,
k
5 g
,+C, .+c
z,
z
'U -u
• P, -p
n -n
-G
> -g
« E
X, x
m
T,
t
+Z, +z
Q,
q
> ? T) -m
+ J, + j H, h
Currently, there is only one upright font available for this script. Note that numbers and punctuation symbols have no special transliteration.
10.31 The Ethiopian Language
The ethiop package (by Berhanu Beyene, Manfred Kudlek, Olaf Kummer, and Jochen Metzinger) is a complete solution to the problem of typesetti ng documents written in any of the Ethiopian languages wi th either LTgX or A. The package is an extension of EthTpX, and it has been desi gned as if it were an option of the babel package. This means that if we load both the babel and the ethiop packages, then we can actually use \s e l e c t l a n g u a g e { e t h i o p }. Of course, if we want to typeset a monoli ngual document, there is no reason to load the babel package.
The typi ng of Ethiopian text is not a straightforward task. Unless we use a Unicode editor to type in our text, we do need to master the transliteration that the authors of ethiop have devi sed. The transliteration is based on the observation that the letters of the Ethiopian languages do represent syll ables that start wi th a consonant and are fol l owed by a vowel. Table 10.4 shows the letters that the ethiop package recognizes. To enter any of the letters, we type the consonant on the l eft and the vowel at the top. For example, the letter is pronounced qi and is entered as qi. Accented consonants are entered by prefixing the consonant with a symbol that denotes the accent (e.g., .p). In addition, capital vowels denote long vowels.
Although the punctuation symbols look different from the punctuation symbols used in other scripts (e.g., the Latin, the Greek, or the Cyrillic) they still have essentially the same meaning. The upper row of the following table presents the input and the lower row the output that we get:
ί ο .31 T h e E t h i o p i a n L a n g u a g ^ - 345
Table 10.4: The Ethiopian characters.
u
o
u
U
o
0
h
1
h
m
s
r
s
s
q
q
b
V
t
c
h
n
n
/
k
k
w
y
h 1 .h m ’ s r s 's
q
■q
b
V
t
'c
_h
n
"n
>
k
_k
w
<
z
'z
υ
Λ
rfi
on
U-l
d
Λ
fi
+
n
Π
Φ
Ψ
Ί
'i
T
K
h
Ti
CD
0
H
Ih
Λ-
rty
on·
ix>.
<■
fV
fi.
f>
rt
Φ
%
'V
>·
■p
i>
Th
CD.
O'
tb
•tr tf
Ί
Λ.
<+>.
"L
έ
fX
it
•fe
ί
a
rt
•t ΐ Ί. ί Ύ. Κ h. TL Έ Ί tt
ή:
e.
ν
A
*+j
° v
•7
O
n
Π
i t
Λ#'
3*
2
?
?
*
h
Ti
*p
•w
Λ,
<+i.
“i
ώ
Λ,
η
*fe
a
f t
φ
έ
Ύ>
k
T
h,
U
H,
7i,'
&_
υ
A
rh
?°
/"
c
fl
YS
¥
Ά
■U
-h
*
Ί
*>
Λ
h
l i
a y ·
ό
Ή
f-
If
A“
ί+·
Τ’
5^
(Γ
i i
fi
Φ
fi
fi
■s”
*?
h
Ti
JP
p
H
I f
&_
w a w i w a w e w e
ua
Ul
u l
uA
uE ue
if preferred
Φ>
O
Ti
TW
4«t
f i ·.
Ί*.
‘η*.
Th
■t·.
£
a
i t
&
3P
a
Cl
£
55
Λ
£
2
i t
•tc
F0'
+'■
=1-
f>
h*·
*$. Hr*
d
d
d
.d
~g
g
• g
£
£
£
T
m
&
£
T *
*?·
n>
■Ί
£
%
ecu *al. f t *
f t.
t
■S ^
^ A A- A
2 £ £ £
ρ ί, η Ί
3 ^ ι n
Ί} m, T
>
T”
T*.
■5.
Λ
£
ί*
3
Τ'
m, ete* 'T'·
f t,
R,
f”
ft
fi
P
C
9.
A
;r
c
P
s
c
f
T -P . s . c f
ft
«
0
6t£
A-
Λ·
0-
4·
ft
a
4»
^Eb
ft-
ft-
6
<P
q
k
h
P
’q
»k
» h
’ g
r
¥
f i
1ft
*t
r
ft
%
τ
%
rt
f L
%
:c
P
ft
1ft
2
T
f t
1ft.
1
T ^
3f $
ff fi
1ft 1ft
t n
&
ί:·
&
•p.
• p
346 ^ 10 M u l t i l i n g u a l T y p e s e t t i n g
Arabic numerals are gaining widespread acceptance in the Ethiopian script, but today the Ethiopian numerals are still used in many situations. When we type in Arabic numerals, they are printed as they are. To get Ethiopian numerals, we have to use the command \ethnum. The argument of this command can be either a number or a counter, and the value of its argument cannot be greater than 999,999. The \today command does not print the current Gregorian date where the name of the month is printed using the Ethiopian script, but prints the date according to the Ethiopian calendar. In the following table, we demonstrate the use of the commands presented in this paragraph:
Command
Output
\ e t hnum-[2002}
\ethnum{9999993-
\today
#-* r * r »
£?· υ t vV: V V:·ΐ
* - * ψ—· r * φ—* w~+ r * * - * *-· r *
fK’batirr 4 1993 (September 9, 2001)
To have Ethiopian letters in a mathematical formula, use the \e t h m a t h command.
>- Exercise 10.9 Write the code that produces the following formula:
sin h.2 + cos f\2 = 1
□
The ethiop package provides rudimentary Λ support: users are expected to type in text using a Unicode editor. Of course, this makes it easy to type in Ethiopian text, but it is our firm belief that the TjjX/Ω community must develop a new package that will incorporate Ethiopian and all of the languages covered in this chapter in a uniform way.
10.32 The Serbian Language
The serbian option of the babel package allows users to typeset Serbian documents written with the Latin script. However, there are plans to provide the necessary facilities
so that the typesetting of Serbian documents written with the Cyrillic script would also be possible. Naturally, the serbian option defines a number of shorthands, which we are going to describe now. The character sequence "£, where £ can be one of the letters c, C, s, S, z, or Z, prints the "letter" £. The shorthands 11 d and 11D print the letters d and D, respectively. In addition, the shorthands " " ’, "<, and "> are used to print the
symbols „ and " and the French guillemets.
ί ο .33 T h e S o r b i a n L a n g u a g e s ^ · 347
10.33 The Sorbian Languages
The Sorbian language belongs to the Slavic family of languages and is closely related to Polish, Kashubian, Czech, and Slovak. These languages, along with the extinct Pomera­
nian (for example, Slovincian) and Polabian (for example, Draveno-Polabian in the Hanoverian Wendland), compose the West Slavic language group. Sorbian is still used in Upper and Lower Lusatia, where the Old Sorbian tribes of the Milceni and Luzici settled. The babel package provides the usorbian and the lsorbian options (both by Eduard Werner) that provide support for the Sorbian language spoken in Upper and Lower Lusatia, respectively. As far as it regards babel, Lower Sorbian is a "dialect" of Upper Sorbian. This simply means that one can use the lsorbian option only if the usorbian option is loaded.
The command \olddatelsorbian should be used when we want the \today com­
mand to print the date in an old-fashioned way. The command \newdatelsorbian causes \today to print the date in a "modern" way. The commands \olddateusorbian and \newdateusorbian have similar effects but for the Upper Sorbian language. The lsorbian option does not define any shorthands, but the usorbian option defines a number of shorthands. First of all, the shorthand "£, where £ is one of the letters a, A, o, O, u, U, e, E, i, and I, prints an umlaut above £. The shorthands "s and "S produce the letters β and SS. As in the case of the ngerman option, "c, "f, and so on, are used to hyphenate cc as cc-c. In addition, the shorthands "J, " *, "<, and "> produce the German quotation marks, „ and ", and the opening and closing guillemets, « and », respectively.
10.34 The Croatian Language
The current version of the Croatian option of the babel package supports only the Latin script that is used for Croatian. However, Darco Zubrinic has created a set of fonts suitable for the typesetting of various Glagolitic and Croatian Cyrillic scripts. The following is a specimen of the various forms of the Croatian scripts:
Script Type
Example
"Round type" Glagolitic
Baska Glagolitic
Angular Glagolitic
Croatian Cyrillic
dnocTTTO/voc
Unfortunately, these fonts have not found their place in the LSTeX world yet—one can use them with the \f ont command. Of course, it is a straightforward exercise to write down the necessary font definition files and a supporting package that will provide
348 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
commands such as \textangglag and so on. Such a command should simply select the appropriate font and typeset its argument using this font. For more information on these fonts, see [31, 32].
10.35 The Perso-Arabic Languages7
The ArabTgX system (by Klaus Lagally) is a bundle of I^TgX packages that allows people to typeset virtually any kind of Arabic text. In addition, the system provides support for Hebrew document typesetting. Another option is to use the omega package that is part of the Ω distribution. However, ArabT^X is rather slow and, in our humble opinion, it is not a system suitable for the typesetting of really long documents. Nevertheless, since ArabTgX is an extremely intelligent system (e.g., it can typeset in a right-to-left direction without using any of the advanced features of Ω or ε-ΤρΧ), we will briefly describe the system and then describe the omega package.
We begin our brief presentation of ArabT^X by giving the contents of a sample input file and the typeset output (see Figure 10.1).
\documentclass [a4paper] ■[ article}·
\usepackage{arabtex}- \sloppy \frenchspacing \begin{docuinent}
\setarab \transfalse \setnashbf \Large \centerline {<nawAdiru>}
\normalsize
\centerline {Ogu.hA wa-.hamlruhu a l - ‘a''saraTu>}
\setnash
\begin{arabtext}
i"starY "gu.hA ‘a^saraTa .hamlriN. fari.ha bihA wa-sAqahA ’amAmahu,
\end{arabtext}
\begin{center}
This i s not Arabic text! %%%%%%% ‘ ‘ordinary^ text \end{center>
\setnashbf
\transtrue
\centerline {<al-waladu wa-al-.t .tablu>}·
7. The term refers to languages that use the Perso-Arabic script.
ί ο -35 T h e P e r s o - A r a b i c L a n g u a g e s ^ · 349
\setnash
\begin{arabtext}
.talaba waladuN min ’ablhi J an ya^stariya lahu .tablaN .sa.glraN.
\end{arabtext} \end{do cument}
J#
£ - ί * ? ' - - - ?
t * Z Z * ^ Z Z Z
T h i s i s n o t A r a b i c t e x t!
a l - w a l a d u w a - ’ t - t a b l u
t a l a b a w a l a d u n m i n > a b i h i >an y a s t a r i y a l a h u t a b l a n s a g f r a/a. f a - r a f a d a Ί - w a - l i d u, w a - q a l a l a h u: y a b u n a y y a, l a w - i
»■* ·»· s ^ JJ*»· Η» C* C"
4 l j · <d ‘ J J I5 JI j j l 4» ui
’s t a.r a y t u l a k n t a b l a.n f a.- x a w f a. t u,z a,H g u n a b i - s a w t i h i.
• 4J^ >λ\ l i Λ ί ^ ί ώ ύ ο *
q a l a Ί - w a l a d u: l a t a g d a b y d > a b i. l a 3u t a b b i l u b i h i, HUa w a - ^ a n t a n a H m u n.
- ; -
y i; 0 i | 3 S H ‘ -u j i f c l S - j l b « ..i.i i S j i l
Figure 10.1: Output of a sample ArabTgX input file.
To typeset documents written in the Arabic script, we must load the a ra btex package. Then, we must choose a language; in this case we have chosen the Arabic language with the command \setarab. Other possible choices include the modem Iranian language called Farsi (\setfarsi), Urdu (\seturdu), the official literary language of Pakistan, Pashto (\setpashto), the principal vernacular language of Afghanistan and parts of western Pakistan, the Arab dialects spoken in Maghreb (\setmaghrib), Uigur (\s e t - uigur), the language of the Turkic people inhabiting the Xinjiang region in China,
350 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
Kashmiri (\setkashmiri), the Dardic language of Jammu and Kashmir, Sindhi (\s e t - sindhi), the Indie language of Sind, Old Malay (\setmalay), Kurdish (\setkurdish), the language of the Kurds, and Ottoman Turkish (\setturk).
The command \transf alse turns off the automatic generation of a transliteration of Arabic text. The command \transtrue turns on this feature. Just in case we only want the transliteration, we have to use the command \arabfalse. Since ArabTgX supports so many different languages, it makes sense to provide support for the various transliterations available. We can select a particular transliteration with the command \settrans, which has one argument —the name of a transliteration. The supported transliterations are: zdmg (the default), english (used in the Encyclopaedia of Islam), ir ani ca (used in the Encyclopaedia Iranica), lazar d (conventions set by Gilbert Lazard), urdu (follows the a la -Lcromanization tables—transliteration schemes for non-Roman scripts), kashmir i (a la -Lozonventions), and turk (similar to modern Turkish). Another option is to select the font that is used for the transliteration with the command \s e t - transfont{ f ont
The c o mma nds \s e t n a s h and \s e t n a s h n f are u s e d t o s e l e c t t he me d i u m and b o l d ­
f ac e s e r i e s of t he de f a ul t f ont. The c o mma nds \LR a nd \RL are u s e d t o pr o duc e no n- Ar a bi c t e xt i n a n Ar abi c c o nt e x t a nd v i c e ve r s a. An Ar a bi c c o nt e x t c an be c r e a t e d wi t h t he e nv i r o nme nt s RLt e x t and a r a b t e x t. Bo t h e nv i r o nme nt s b e h a v e i de nt i c al l y. The l as t a s pe c t o f Ar a bi c do c u me nt t y pe s e t t i ng wi t h ArabTgX i s t he wa y we pr e par e t he i nput f i l e. The "s t anda r d" i nput e n c o d i n g i s s h o wn i n t he f o l l o wi n g t abl e:
a 1
*g c
r J
b v .h c
z J
t ir*
P v
- h C
s u*
Z k
t o d s
s
4- a
_ t CJ
_d i
.S j *
σ i·
c r
f L3
1 J
y
ώ
c ^
q J
m r - A
Λ
V lJ
n j T 5
Λ
c
k i ) h o
c K
"1 Ϊ
- g ^ g ^
W j
£ T ,
’ C «
A 1 -A &
i N 1
J
1 Φ
a ί uN ]
U j i i 1
~A ]
u
_ a ΐ
u ί
J
<
_ i 1 aN \
β
Ot he r i nput e n c o d i n g s are a l s o s uppo r t e d b y l o a d i n g t he appr opr i a t e package: ASMO 449 ( i s o9036), I SO- 8859- 6 ( i s o88596), CP- 1256 ( arabwi n), ISIRI 3342 Pe r s i an St andar d Co de ( i si ri ), a nd UTF- 8 ( ut f8).
ί ο .36 I n d i a's L a n g u a g e s ^ - 351
The omega package provides a number of environments that can be used to typeset Perso-Arabic text. All of the environments assume that text is entered using some ASCII transliteration. To typeset Arabic, we need to use the environments ar ab and similar ab. The second environment should be used only for short passages. The environments latberber and berber should be used to get Berber written with Latin or Arabic letters, respectively. The environments t i f inagh, urdu, pashto, pashtop, and sindhi should be used to typeset text in the corresponding languages. Note that pashtop should be used for Pakistani Pashto. The standard ASCII transliteration is shown in the following table:
A
1
P
z
j
t
I
iS
1 a
1
3
ε
zh
j
gh
t
n
ύ
y
IS
'i
1
9
H
C
s
0»
f
'n
0
'y
t-
iS
' A
1
kh
i
s h
q
3
- h
6
11
9-
"A
7
ch
ε
s
V
Jj
"h
s
E
d
b
b
1—1
d
J
D
k
til
e
ί
6
dh
j
T
J=,
g
£
U
J
LI ah
ί <
th
0
r
J
Z
1
J
'u
β
j
SLh
S§
Ta
L'
Ti
Tu
L’
TO
k°
Ta|
Ja'
TaN
L ·'
TiN
L
TuN
L*
10.36 India's Languages
India's languages are numerous and difficult to deal with in a system such as LTgX. The main reason is the number of characters needed due to the large number of ligatures required for most of them.
Unfortunately, it is not a straightforward exercise to typeset a document written in one of India's numerous languages and dialects. The main reason is that the "letters" of these languages in many cases consist of two or more characters that may be placed before or after a main, or central, character, so it is absolutely necessary to have some preprocessor that will modify the input file (think of the preprocessor needed for Thai documents). Obviously, this is a task ideally suited for Ω, but, unfortunately, no one has really done anything in this direction. Meanwhile, the best solution seems to be the itra Nsprogram (by Avinash Chopde) available from http: //www. aczone. com/itrans.
itransis a transliteration program—the user t ypes in the text with Latin characters using some (predefined) conventions in a file (for an example, see Table 10.5). Once we have prepared our input file, we process this file with itra Nsto get another file, which, in turn, will be processed by LTgX. The file produced by itransis far too complex and is not intended for human inspection.
3 5 2 "Φ" i o M u l t i l i n g u a l T y p e s e t t i n g
i t r a n s supports the languages Devanagari (Sanskrit, Hindi, and Marathi), Tamil, Bengali, Telugu, Gujarati, Kannada, Punjabi (Gurmukhi), and Romanized Sanskrit. Malayalam and Oriya are not supported at the moment oi this writing, but future versions of i t r a n s will probably support them.
There are some special arrangements for i t r a n s to work properly. First of all, we must load the package itrans. Then, we have to inform i t r a n s what transliteration tables (i.e., which languages) we will need. The transliteration tables are contained in files having the . i f m filename extension and are part of the distribution of the i t r a n s program. Table 10.6 shows the available . i f m files and their corresponding language. These files are loaded in the preamble of our input file by using the "command"
#b e n g a l i i f m = i t x b e n g.i f m
for Bengali and similarly for the other languages. We also have to load the proper font. For Bengali, the proper declarations are
\n e w f o n t {\i t x b e n g } { i t x b e n g a t 1 4 p t }
#b e n g a l i f o n t =\i t x b e n g
Notice that we asked here for the 14 pt size. Finally, any text to be transliterated must be inside the environment
{#l a n g u a g e t e x t #e n d l a n g u a g e }
Here is an example (from the documentation of i t r a n s ):
\documentclass{article} \usepackage{itrans}- \newfont{\itxbeng}{%
UP ^ >1^1
^R*ji M s «os R<K3*i i ^
lli^ 'd'RM g
>
i
«*[Scri, ^
'SpM *\H <^R<1 o f 1
| ί
itxbeng at 14pt}- #bengaliifm=itxbeng.ifm #bengalifont=\itxbeng \begin{document} {#bengali
— ό\<Ρ<\
C-N
sandhyaa rabi \\ shuniYaa j agat.h rahe ni rutt ar chhabi | \\
maaTir pradiip chhi l a, se kahi l a, sbaamii \\
aamaar JeTuku saadhya kariba taa aami | \\
---- rabiindranaath Thaakuur
# endbengali} \end{document)-
ί ο .36 I n d i a's L a n g u a g e s ^ - 353
Vowels
3Γ
a
3TT
aa or A
i
f
i i or I
T
u
uu or U
w
RRi or R~i
RRI or R~I
LLi or L~i
LLI or L~I
e
ai
3ΓΓ
0
3^-
au
3f
aM
ϊΓ:
aH
Digits
\9
0
7
8
Consonants
3Γ
W
TT
*T
T
IT
ka
kha
ga
gha
'Na or N~a
cha
Cha or chha
J®
jha
"na or JNa
Ta
Tha
Da
Dha
Na
ta
tha
da
dha
na
pa
pha
b a
bha
ma
ya
r a
la
va or wa
Consonants
W
sha
T
Sha or shha
sa
€
ha
Ida or La
ST
kSha or xa
^r
j~na or GYa
Specials/Accents
W
π
3ΤΓ
i f
*T
arr
qa
Ka
Ga
Ja or za
fa
,Da
.Dha
AUM or OM
Rga
rga or ga r
ga. n
aa. c
Z?a.N
£>.h
dvH
. a
Table 10.5: The transliteration tables for Devanagari (Hindi, Sanskrit, and Marathi).
3 5 4 ^ 1 0 M u l t i l i n g u a l T y p e s e t t i n g
Table 10.6: The transliteration table files for the Indian languages.
Devanagari
(Sanskrit,
Hindi,
Marathi)
dvnc. ifm (uses PostScript fonts)
dvngfull.imf (fully ligaturized METRFONT fonts)
dvng. ifm (simplified form of dvngf u l l. ifm; it eliminates many ligatures; looks sim­
pler/better)
xdvng.ifm [modified form of dvng. ifm; some characters are different (adds "ha-ri", deletes "ja-jnh")]
Gujarati
i t x g u j.ifm
Bengali
bnbeng. ifm (METR FO NT fonts) i t xbeng. ifm (PostScript fonts)
Tamil
wntml. ifm (METRFONT fonts)
Telugu
t l gu t x. ifm (METRFONT fonts)
Kannada
kantex.ifm (METRFONT fonts)
Gurmukhi
pun. ifm (PostScript fonts)
Romanized Sanskrit
romancsx. ifm (PostScript fonts)
Table 10.7 shows example commands for the fonts that need to be defined for each script.
Table 10.7: Transliteration tables and sample fonts.
dvnc.ifm
dnh
dvngfull.ifm
dvnglO
dvng.ifm
dvng10
xdvng.ifm
xdvng
i t x g u j.ifm
itxguj
itxbeng.ifm
itxbeng
wntml.ifm
wntml10
tlgutx.ifm
tellO
kantex.ifm
kanl8
pun.ifm
pun
romancsx.ifm
ncprcsxp
Alternative fonts can be found in the font declarations of the samples of the i t r a n s distribution (check the i t x files). For example, the font for Romanized Sanskrit comes with an italic version under the name ncpicsxp.
ί ο - 3 7 T h e C h e r o k e e L a n g u a g e < > 355
Romanized Sanskrit (ncprcsxp font)
Romanized Sanskrit (ncpicsxp font)
yogasthah kuru karmani sangam tyaktva dhanamjaya 1 siddhyasid- dhyoh samo
yogasthah kuru karmani sangam tyaktva dhanamjaya 1 siddhyasid- dhyoh samo
A nice feature of i trans is that it can input a file into your document. This is very useful when dealing with big documents. For this, it provides the command #input = f i l e - t o - i n p u t. It also supports short forms for the language markers. If the last language used was, say, Marathi, then more Marathi text follows, one can use ## instead of #marathi or #endmarathi, and itra Nswill remember to use the last language used.
The itrans package has several options, such as devanagari or talugu (check out the file itrans. sty), that help produce special characters for these languages.
There are cases when one needs to break the lexical scan of the language; that is, avoid the association (and the resulting ligatures) of some consecutive characters. Breaking of the lexical scan is done with the character _. Thus, in Marathi ai produces ή but a_i produces 315.
It is very important to note that since the preprocessor does not change anything unless it is inside a group
Slanguage t e x t #endlanguage
it is very easy to use other languages in the same document (e.g., the languages sup­
ported by the babel package).
More information for itra ns (for example, the transliteration tables for all lan­
guages) can be found in its documentation.
10.37 The Cherokee Language
Cherokee ^nore properly spelled Tsalagi^s an Iroquoian language with an inno- vative written syllabary invented by the Cherokee scholar Sequoya. Currently, the Cherokee syllabary consists of 84 "letters," each of them denoting a particular syllable. The cherokee package (by Alan M. Stanier) allows one to write simple phrases or words in Cherokee. The package defines a command for each syllable. The general form of these commands is \Cxxx, where xxx is any of the Cherokee syllables. For example, to typeset the Cherokee word for bread (gadu). we have to enter the commands \Cga\Cdu! However, care must be taken since some commands do not use the standard names of the Cherokee syllables.
356 "Φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
D
a
R
e
T
i
ώ
0
σ
u
*
1
V
$
ga
0
ka
l·
ge
y
gi
A
go
J
gu
E
gv
ha
l·
he
j
hi
I
ho
Γ
hu
fir
hv
w
la
e
le
P
l i
c
lo
M
lu
lv
ma
a
me
H
mi
mo
y
mu
Θ
na
I
hna
Λ
ne
h
ni
z
no
q
nu
O
nv
X
qua
tO
que
ΊΫ
qui
quo
C0
quu
ε
quv
u
sa
<£)
s
se
b
s i
i
so
r
su
R
sv
l
da
W
ta
S
de
X
te
Λ
di
I
t i
V
do
s
du
<y*
dv
«ft
dia
C
t l a
L
t i e
c
t l i
•J
t i o
tlu
P
t l v
G
tsa
M
tse
If
t s i
K
tso
cT
tsu
G
tsv
a
wa
m
we
Θ
wi
wo
$
wu
6
wv
ya
3
ye
75
yi
fi
y°
GT
yu
B
yv
Table 10.8: The standard Cherokee syllabary and its Latin transcription.
oSbiiO m Dfio.
The ocherokee8 package (by Apostolos Syropoulos with assistance from Antonis Tsolomitis) is an experimental package to typeset Cherokee text with Λ. The cherokee environment can be used to typeset Cherokee text using the standard Latin transcription (see Table 10.8 on page 356). Here is an example:
\begin{cherokee}- ssiquaya ale ayoka.
\end{cherokee}
If we have a Unicode editor at our disposal, we should use the ucherokee environment. This way, we can enter Cherokee syllables directly. The commands \textcher and \textucher are actually shorthands of the two environments presented above.
Although the syllable nah is part of Unicode, the ocherokee package does not support this syllable, as it is not used anymore by the Cherokee people. We conclude this section with the following Cherokee blessing:
cfttJhG ΌΙΟώ DlVfy hAJ^T θ<££ hJ.
As of this writing, there are no other packages that support the typesetting of any other Native American language. It seems that the main reason for this lack of typesetting tools is the fact that all other Native American languages use the Latin alphabet. For example, the Apache language uses all of the Latin letters and the letters a, e, i, o,
8. The package is accompanied by a PostScript version of the Official Cherokee font created by Tonia Williams. The author of the package wishes to thank Tonia Williams for allowing him to redistribute the PostScript version of the font._____________________________________________________________________________
ί ο .38 T h e H u n g a r i a n L a n g u a g ^ · 357
and u with an acute accent [e.g., isdzan (woman), gidi (cat)], an ogonek [e.g., nk^z (time)], or both [e.g., nad4' (com)], and the letter l[e.g., log (fish)]. However, there are some languages of the Americas, such as Cree or Inuktitut (the Amerindian Eskimo language), that have their own writting systems, but their support is under development (see Section 10.43).
10.38 The Hungarian Language
Currently, only the magyar option (by Jozsef Berces) of the babel package provides the facilities to typeset Hungarian documents. This option redefines the \caption command so that the words tablazat (table) and abra (figure) come after the number and the colon is replaced by a dot (e.g., 2.1. tablazat). Since the Hungarian definite article is heavily used in the referencing mechanism, the magyar option provides a number of commands that allow LT^X to produce the correct strings for references. But let us now present these commands.
The command \ondatemagyar works like the \today commands but produces a slightly different date format, which is used in expressions such as "... on September the 6th Here is an example that shows the difference:
2004. szeptember 6. \today
2004. szeptember 6-an \ondatemagyar
The commands \Az and \az have a Hungarian word as argument and both print the correct form of the definite article, a nonbreakable space, and the word. The first command should be used at the beginning of a sentence. The commands \Azr and \azr have a label as argument and are used to print references with the correct definite article. In particular, when we want to reference mathematical equations, we can use the form \Azr(label) (or \azr(label)), but the l abel must be surrounded by parentheses. The commands \Azp and \azp should be used for page referencing. Both commands
have one argument, which is a label. Similarly, the commands \Azc and \azp should
be used for referencing bibliographical items. The magyar option also defines a number of shorthands, which are shown in the following table:
Shorthand Explanation Example
‘ c, ‘ C ccs is hyphenated as cs-cs lo ‘ ccsan— ^locs-csan
*d, fD ddz is hyphenated as dz-dz e ‘ ddzV'unk— >edz-dziink
‘g, £G
ggy is hyphenated as gy-gy
po ‘ ggy\»asz— >pogy-gyasz
<1, ‘L
lly is hyphenated as ly-ly
Kod\ ’ a f l l y a l — ^Kodaly-lyal
‘n, ‘ N
nny is hyphenated as ny-ny
me ‘ nnyei — ^meny-nyei
‘a, f S
ssz is hyphenated as sz-sz
vi ‘ ssza— ^visz-sza
*t, £T
tty is hyphenated as ty-ty
po ‘ t t y a n — >poty-tyan
*z. £Z
zzs is hyphenated as zs-zs
r i ‘ zzs e l — >rizs-zsel
358 "Φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
In addition, the shorthands ‘ ‘ and ’ ’ produce the opening („) and closing (") quotation marks. Usually, Hungarian input files should be prepared in the Latinl character set, so one has to use the corresponding encoding for the inputenc package.
10.39 The Turkish Language
Currently, only the turkish option (by Mustafa Bure) provides a complete solution to the problem of typesetting Turkish documents with 1?·ΤβΧ. This option implements the typographic rule that dictates that some space must be added before the characters :,
!, and =.
10.40 The Mongolian Language9
Mongolian writing is a fairly complex topic. In the history of the written language, numerous scripts were either accepted from other cultures or domestically designed. Important scripts with a practical significance today are Uighur and Cyrillic. Other scripts were also employed at given times in history (e.g., Chinese, Phagsba, Soyombo, and Latin, which had been used during the 1930s).
The traditional Mongolian script is called Uighur and is written in vertical lines from left to right (i.e., LTL in Q's parlance). Now, the Uighur script is again, in legal though not in practical terms, the official script of Mongolia. Despite the legal status, the de facto writing system in Mongolia is Cyrillic; however, Uighur is the standard script used in Inner Mongolia, China.
The Chinese script was used for a short time during the 13th and the beginning of the 14th century, during the Yuan dynasty, in cultural and linguistic applications such as dictionaries and so on.
The Phagsba or Square Writing was developed in the 13th century by a famous Tibetan monk and scholar, Phagsba. This script incorporated features from the Tibetan script and inherited the writing direction from Chinese. In the 17th century, a second Square Writing, called Horizontal Square Writing, was developed. This script was also heavily influenced by the Tibetan script.
Another script, the conception of it politically motivated, was the Soyombo script designed by the Mongolian monk and scholar Zanabazar in 1686. This script has never managed to become a script for daily usage, although it survives in religious inscrip- tions. The only symbol of that script that can be seen literally everywhere in Mongolia is the Soyombo symbol (see Figure 10.2 on page 365). It is even formally described in Mongolia's constitution as a national symbol and decorates flags, money, official buildings, official documents, and seals, to name just a few examples.
9. The information regarding the writing systems of the Mongolian language is based on the Mongolian FAQ by Oliver Corff (see htt p://use rp ag e.fu -b e rl i n.d e/~ c o rff/m f.h t m l
).----------------------------------------------
ί ο 4 ° T h e M o n g o l i a n L a n g u a g £ - 359
In 1940, the then Mongolian People's Republic started using a modified Cyrillic alphabet after a short period of latinization experiments. Despite a few orthographic instabilities, the Cyrillic system is the major vehicle of written communication today in Mongolia; virtually all newspapers, books, etc., are printed in the Cyrillic alphabet.
10.40.1 Modern Mongolian — Cyrillic
The MonTjrX system (by Oliver Corff with assistance from Dorjpalam Dorj) provides the necessary tools to typeset Mongolian language documents transcribed in the Cyrillic and the Uighur scripts. In addition, the system provides the necessary tools for the typesetting of other languages such as Buryat and Manchu. All of these features are supported by the mis package of the MonT^X system. The package provides a number of options that correspond to the main language of the document and the input encoding to be used. The available languages are xalx (modem Mongolian as spoken in Mongolia today), buryat (Buryat is a Mongolian language that is spoken by the Buryat people living north of the Russian-Mongolian border in the Buryat Autonomous Republic near Lake Baikal), kazakh (Kazakh is a Turkic language spoken in Kazakhstan and by the Kazakh minority in Mongolia), bicig (Uighur Mongolian), bithe (Manchu), english, and russian.
There are two methods to prepare a Mongolian document transcribed in the Cyrillic script: either we use a Cyrillic character set or a Latin transliteration. If we choose to enter text using a Latin transliteration, then we must follow the conventions presented in the following table:
A a A a Γ r G g
B 6 B b Hfl D d
Β b W w E e E e
E e "E/E "e/e H h I i JI ji L I 0 0 0 0 Ρ ρ E r
jK >k J j He "Ι/Ϊ "i/ϊ Mm Mm θ θ "0/0 "0/0 C c S s
3 3 Z z Κ κ K k Η η N n Π π Ρ p T τ T t
y y U u
X χ X x Η h
q q
\Y \y 3 3 "A/A "a/a
Υ γ "U/U "u/ii h h H h TTT
ttt
\Sh sh
Bl Bi Y y IO io Yu yu
Φ φ F f Π n C c njm \Sc \s c Bb \I \i 51 a Ya ya
On the other hand, if we have at our disposal an environment with a Cyrillic character set, accompanied by a suitable keyboard (or a multilingual editor such as emacs ), then we can use any of the available predefined input encodings —MLS (based on the original Mongolian Language Support for IBM computers), NCC (a popular encoding with only Cyrillic characters), MOS, MNK, DBK, CTT (four Cyrillic-only encodings),
360 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
I B M R U S ( n o t s u i t a b l e f o r M o n g o l i a n ), K O I ( a R u s s i a n - o n l y C y r i l l i c e n c o d i n g ), 8 5 0,8 5 2, M A C, A T A R I, o r R O M A N 8. T o s w i t c h t o t h e f i r s t i n p u t m e t h o d, u s e t h e \S e t D o c u - m e n t E n c o d i n g L M C c o m m a n d. T h e c o m m a n d \S e t D o c u m e n t E n c o d i n g N e u t r a l s w i t c h e s t o t h e C y r i l l i c i n p u t m e t h o d a n d r e q u i r e s t h e s e l e c t i o n o f o n e o f t h e a v a i l a b l e i n p u t e n c o d i n g s. I n a d d i t i o n, t h e c o m m a n d s \S e t D o c u m e n t E n c o d i n g B i c i g a n d \S e t D o c u - m e n t E n c o d i n g B i t h e a r e u s e d t o s w i t c h t o t h e S i m p l i f i e d C l a s s i c a l M o n g o l i a n a n d t o t r a n s l i t e r a t e d M a n c h u i n p u t m e t h o d s, r e s p e c t i v e l y. M o r e o v e r, t h e d e c l a r a t i o n s \m n r a n d \r n m c a n b e u s e d t o s w i t c h t o f r o m o r d i n a r y t e x t t o t r a n s l i t e r a t e d C y r i l l i c t e x t. T h e c o m m a n d s \x a l x a n d \l a t h a v e o n e a r g u m e n t a n d c a n b e u s e d t o t e m p o r a r i l y s w i t c h t o M o n g o l i a n o r L a t i n t e x t m o d e, r e s p e c t i v e l y.
D e p e n d i n g o n t h e s e t t i n g s o f t h e d o c u m e n t l a n g u a g e, o r m a i n l a n g u a g e, t h e c o m ­
m a n d \t o d a y i s r e d e f i n e d t o m a t c h B u r y a t, X a l x, R u s s i a n, o r B i c i g c o n v e n t i o n s. R e ­
g a r d l e s s o f t h e m a i n l a n g u a g e, t h e i n t e r n a l c o m m a n d s f o r p r o d u c i n g t h e p r o p e r d a t e a r e n o n e t h e l e s s d i r e c t l y a c c e s s i b l e b y t h e u s e r:
2 0 0 1 OHOH H O i i G p n i i H 2 7 - η ο ι ϊ y a a p 2 0 0 1 o h m a p B a H Η 9 Γ\π;γ Γ 3 3 ρ c a p M H 2 7 2 7 H o a 6 p a 2 0 0 1 N o v e m b e r 2 7, 2 0 0 1
\B u r y a t T o d a y \X a l x T o d a y \R u s s i a n T o d a y \t o d a y
T h e c o m m a n d \B i c i g T o d a y p r i n t s t h e d a t e u s i n g t h e U i g h u r s c r i p t ( s e e m a r g i n ). S i m ­
i l a r l y, t h e c o m m a n d s \K a z a k h T o d a y a n d \B i t h e T o d a y p r o d u c e t h e c u r r e n t d a t e i n K a z a k h a n d M a n c h u, r e s p e c t i v e l y.
T h e c o m m a n d s \T o g r o g a n d \t o g r o g p r o d u c e t h e s y m b o l f o r t h e n a t i o n a l c u r r e n c y o f M o n g o l i a —T o g r o g o r T u g r i k. T h e s e c o m m a n d s p r o d u c e s a n s s e r i f v e r s i o n s o f t h e
c u r r e n c y s y m b o l, w h i c h i s c o n s i d e r e d s t a n d a r d. I t i s p o s s i b l e t o p r o d u c e a n y f o r m o f t h e c u r r e n c y s y m b o l b y u s i n g t h e c o m m a n d s \M y T o g r o g a n d \m y t o g r o g. T h e s e c o m m a n d s p i c k t h e c u r r e n t f o n t s t y l e t o r e n d e r t h e c u r r e n c y s y m b o l:
3
>
y*·
Cd
\T o g r o g
T
Ό
0
0
Ό
w
3=
a>
10.40.2
\t o g r o g
\t e x t r m {\M y T o g r o g } - \t e x t b f {\m y t o g r o g } -
— Uighur
T o p r e p a r e a n U i g h u r M o n g o l i a n d o c u m e n t, o n e c a n u s e t h e M L S c o d e p a g e a n d c h a r ­
a c t e r s e t o r, s i m i l a r i n s t r u c t u r e t o t h e C y r i l l i c a p p r o a c h d e s c r i b e d a b o v e, u s e o n e o f t w o L a t i n t r a n s l i t e r a t i o n s c h e m e s. T h e f i r s t M o n T g X t r a n s l i t e r a t i o n s y s t e m i s i d e n t i c a l t o t h e b r o a d r o m a n i z a t i o n f i r s t p u b l i s h e d i n t h e 1 9 9 0 s, w h e r e a s t h e S i m p l i f i e d T r a n s l i t e r a t i o n
ί ο 4 ° T h e M o n g o l i a n L a n g u a g£- 361
u s e s a s m a l l e r s e t o f v o w e l s a n d a c t u a l l y i m i t a t e s s o m e o f t h e i n h e r e n t a m b i g u i t i e s o f t h e U i g h u r M o n g o l i a n s c r i p t. T h e M o n T g X s y s t e m s u p p o r t s b o t h t r a n s l i t e r a t i o n s c h e m e s i n d i f f e r e n t e n v i r o n m e n t s; w h i l e t h e b r o a d s y s t e m i s t o b e u s e d w i t h s m a l l p o r t i o n s o f t e x t, l i k e o n e - w o r d o r o n e - p h r a s e i n s e r t i o n s i n s c i e n t i f i c p a p e r s, f o r e x a m p l e, t h e S i m p l i f i e d T r a n s l i t e r a t i o n c a n b e u s e d f o r c o m p l e t e d o c u m e n t s a s t h e m a i n l a n g u a g e o f t h e b o d y t e x t.
T o t y p e s e t c o m p l e t e U i g h u r d o c u m e n t s v e r t i c a l l y, i t i s a b s o l u t e l y n e c e s s a r y t o p r o ­
c e s s y o u r i n p u t f i l e w i t h ε - L T g X. I f o n e w a n t s t o t y p e s e t i n d i v i d u a l U i g h u r M o n g o l i a n w o r d s ( e.g., d i c t i o n a r y e n t r i e s, a n d s o o n ), t h e n s t a n d a r d Ι £ Γ β Χ c a n b e u s e d i n s t e a d. T h e s a m e p r i n c i p l e a p p l i e s t o M a n c h u ( s e e S e c t i o n 1 0.4 2 ).
I n e a c h c o l u m n o f t h e f o l l o w i n g t a b l e, w e p r e s e n t t h e U i g h u r l e t t e r, t h e M L S, a n d t h e M o n T ^ X t r a n s l i t e r a t i o n e m p l o y e d.
a
a
J
a
a, E
Λ
i
i
0
0
*|
u
u
0
0, 0
i i
i i, U
I
- J
n
n
Ί
- i
* n g
n g
?
x
X
Y
G
m J
k
k
p
g
g
b
b
P
P
ay
f
f
S
s
Ξ
S
*
t
t
d
d
Xi
1
1
m
tn
N
c
c
-Ί
z
z
- Ί
y
y
Π
r
r
V
V
A
h
h
'ψ
j
j
K
K
1
[ - ]
Q
C
C
^ 1 -
Z
Z
T o e n t e r U i g h u r M o n g o l i a n, w e c a n u s e t h e c o m m a n d \b i c i g, w h i c h i s s i m i l a r t o \x a l x, m e n t i o n e d a b o v e, o r t h e e n v i r o n m e n t s b i c i g t e x t a n d b i c i g p a g e. T h e e n v i r o n m e n t b i c i g p a g e s h o u l d b e u s e d w h e n w e w a n t t o p r e p a r e w h o l e p a g e s o f U i g h u r M o n g o l i a n t e x t. T h e c o m m a n d \b i c i g a n d t h e e n v i r o n m e n t b i c i g t e x t s h o u l d b e u s e d t o t y p e s e t U i g h u r i n h o r i z o n t a l m o d e. T h e c o m m a n d \b o s o o t y p e s e t s i t s a r g u m e n t v e r t i c a l l y, s o i t c a n b e u s e d i n c o n j u n c t i o n w i t h \b i c i g t o t y p e s e t s m a l l p a s s a g e s i n v e r t i c a l m o d e. T o m a k e t h i n g s e a s y, M o n T g X p r o v i d e s t h e c o m m a n d s \m b o s o o a n d \m o b o s o o, w h i c h p r o d u c e U i g h u r t e x t t y p e s e t i n v e r t i c a l m o d e, \m b o s o o e x p e c t s i n p u t i n b r o a d t r a n s l i t e r a t i o n, a n d \m o b o s o o e x p e c t s i t s i n p u t t o b e i n S i m p l i f i e d s t y l e, a s t h e f o l l o w i n g e x a m p l e s h o w s:
362 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
\m b o s o o { m o n g G o l b i c i g }
\mobosoo-Cmunggul b i c i k }
r r
i
H e r e i s h o w w e c a n e n t e r t h e s p e c i a l s y m b o l s a n d t h e p u n c t u a t i o n m a r k s o f t h e U i g h u r s c r i p t:
1
!
?
?
1 ?
1?
? 1
91
1*1 *
MSP
^ (
^ )
<
>
^ «
FV51
ifvszi
iMVSl
1
*
* j
:
j
I
0 0
0 1
a 2
il 3
0 4
j 5
6 6
& 7
00
G 9
I n th e p r e c e d in g ta b le, c e r ta in c h a ra c te rs s u c h as th e M o n g o lia n sp a ce, a r e in t e n t io n a lly p re s e n te d v is u a lly. T h e g l y p h in p u t s ty le is s h o w n in th e f o llo w in g ta b le:
1
@
a
A
vi
i
C|
0
GJ
0
-
n
1
O i
L
Q
-n
m
M
0
X
to
X
g
0
I
CTv
B
oy
b
j *
t
<λ
d
n
r
0
R
U
z
^1
y
s
S
q
U
c
<ί
V
<Λ
h
K
k
tn
P
p
'CTl
f
il
z
.JJ
c
j
—
e
__
>
E
1
Y
G
•
-
=
*
j
5
V
u
T
T i
U
W
m l
1 1
T h e H o r i z o n t a l S q u a r e W r i t i n g m e t h o d i s k n o w n a s X a w t a a D o r b o l j i n, o r H o r i z o n t a l S q u a r e A l p h a b e t ( a l t h o u g h i t i s c a l l e d a n “ a l p h a b e t," i t i s a c t u a l l y a s y l l a b a r y ). T h e m x d p a c k a g e ( b y O l i v e r C o r f f ) i s a f i r s t a t t e m p t t o a l l o w t h e t y p e s e t t i n g o f d o c u m e n t s t r a n ­
s c r i b e d i n X a w t a a D o r b o l j i n w i t h I f f l j g X. L i k e t h e S o y o m b o s c r i p t, t h e X a w t a a D o r b o l j i n s c r i p t i s t w o - d i m e n s i o n a l a n d i n p r a c t i c e i s h e a v i l y i n f l u e n c e d b y t h e T i b e t a n s c r i p t.
T h e m a j o r a r e a o f e a c h s y l l a b l e i s o c c u p i e d b y a m a i n c o n s o n a n t. I f n o v o w e l i s a d d e d, t h e b a s i c v o w e l a
i s a s s u m e d. I f o n e o f t h e v o w e l s a, 0
,
o r 0 i s a d d e d, i t i s p l a c e d o n t o p o f t h e s y l l a b l e; o t h e r w i s e, i f o n e o f t h e v o w e l s u
o r u
i s a d d e d, t h e n i t i s p l a c e d a t t h e b o t t o m o f t h e c h a r a c t e r b o x. L o n g v o w e l s a r e m a r k e d b y a p r o t r u d i n g t i p o f t h e
ί ο 4 ° T h e M o n g o l i a n L a n g u a g£- 363
r i g h t - s i d e b e a m. A s i s o b v i o u s, X a w t a a D o r b o l j i n s y l l a b l e s a r e c o n s t r u c t e d i n a m a n n e r s i m i l a r t o S o y o m b o a n d T i b e t a n s y l l a b l e s.
T h e m x d p a c k a g e p r o v i d e s t h e \m x d c o m m a n d, w h i c h s h o u l d b e u s e d t o s w i t c h t o t h e X a w t a a D o r b o l j i n m o d e. S i n c e t h e r e i s a t t h e m o m e n t n o w a y t o s w i t c h b a c k t o t h e p r e v i o u s m o d e, t h e u s e r s h o u l d u s e t h i s c o m m a n d i n a l o c a l s c o p e. T h e v o w e l s o, o, u,
u,
a n d a
a r e e n t e r e d a s o, G, u, U, a n d e, r e s p e c t i v e l y. I n a d d i t i o n, t h e p a c k a g e s u p p o r t s f o u r d i f f e r e n t s c r i p t s t y l e s, w h i c h a r e s h o w n b e l o w:
vi έ & έ
□ ID ID ID
N o r m a l B o l d W o o d W o o d b o l d
T h e w o o d s t y l e i s a c t u a l l y t h e i t a l i c s h a p e o f t h e f o n t u s e d. T a b l e 1 0.9 s h o w s t h e c h a r a c t e r s t h a t a r e c u r r e n t l y s u p p o r t e d.
Table 10.9: Xawtaa Dorboljin script input.
LTU ‘
m{ *-
[JTJ ‘ u f f | ‘ 0- J1 g
a =
m p
ΠΙ Ί
0
f i \s A
t i <i
^ £U -
ffij £o ra k
R d OJ m HI \ φ
1
Cn\ £i - \m ‘u
H ‘ 0-
Ξ
B t LU y N
II
M ‘
e ‘ u -
IUU ‘ w 31' z □Ί n R r
UU >
£e - 1 £o
LTU ‘
1
HI c
U b D w
1U J.
LTU ‘ G H J ‘ B
luj ‘ s
\s l i -
ru \ψ
UU £k M
£M
£- a
UU £o
1M S
LTU £*
H J ‘ R
\s r i
LTU £h
ul π
LUJ £d H J ‘ L
\s r i - [11 \s g
□ 1 \SKS
UU £n UU £Q
fD \s l i 31 \s g h
r·
E j X \s d h I I \s B H ΪΙ \s l k
ΓΞ @
E \s j h ^ \s d n 13 \s d s
N N ΙΌ s s k
f7 T
E \s D 03 \s k y S \s r k
X \s t h E \s D H p] \s k r R X
X \s d d □ \s B DJ \s k l
3 q
10.40.4 Classical Mongolian - Soyombo
T h e s o y o m b o p a c k a g e ( b y O l i v e r C o r f f ) p r o v i d e s s u p p o r t f o r t h e t y p e s e t t i n g o f M o n - g o l i a n t e x t u s i n g t h e S o y o m b o s c r i p t. T h e \S o y o m b o c o m m a n d p r o d u c e s t h e S o y o m b o
364 "Φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
s y m b o l ( s e e F i g u r e 1 0.2 ). T o s w i t c h t o t h e S o y o m b o f o n t, u s e t h e \s o y o m b o c o m m a n d. I t m a k e s s e n s e t o b r i e f l y d e s c r i b e t h e w a y S o y o m b o s y l l a b l e s a r e c o n s t r u c t e d. T h e r e i s a l w a y s a b a s i c c o n s o n a n t a t t a c h e d t o t h e t o p l e f t c o r n e r o f a v e r t i c a l b e a m. I f n o v o w e l s i g n i s a d d e d, t h e b a s i c v o w e l a
i s a s s u m e d. I f o n e o f t h e v o w e l s i, a, 0
,
o r 0 i s a d d e d, t h e n i t i s p l a c e d o n t o p o f t h e s y l l a b l e; o t h e r w i s e, i f o n e o f t h e v o w e l s u
o r u
i s a d d e d, t h e n i t i s p o s i t i o n e d i n t h e l o w e r t h i r d o f t h e s y l l a b l e. L o n g v o w e l s a r e i n d i c a t e d b y p l a c i n g a t i p u n d e r t h e b e a m. C l o s i n g c o n s o n a n t s a r e p l a c e d i n t h e r i g h t t h i r d o f t h e l o w e r t h i r d o f t h e s y l l a b l e. F i g u r e 1 0.2 p r e s e n t s t h e s t r u c t u r a l l a y o u t o f t h e S o y o m b o s y l l a b l e s. B u t h o w d o w e e n t e r S o y o m b o s y l l a b l e s? I n i t i a l c o n s o n a n t s a r e e n t e r e d a s s u c h ( s e e T a b l e 1 0.1 0 ). T h e v o w e l a
i s n o t m a r k e d; o t h e r v o w e l s a r e e n t e r e d b y u s i n g l o w e r c a s e l e t t e r s f o r s h o r t v o w e l s a n d u p p e r c a s e l e t t e r s f o r l o n g v o w e l s. I n p a r t i c u l a r, t h e v o w e l s 0
, 0
, u, ii,
a n d a
a r e e n t e r e d a s o, 0, u, U, a n d e, r e s p e c t i v e l y. T h e “ l e t t e r s" u a n d U h a v e a s h o r t e r f o r m a c c e s s e d w i t h t h e "l e t t e r s" v a n d V, r e s p e c t i v e l y. T h e s e s h o r t e r f o r m s a r e u s e d f o r c o m b i n a t i o n s w i t h a f i n a l c o n s o n a n t. S y l l a b l e f i n a l c o n s o n a n t s a r e a l w a y s e n t e r e d i n u p p e r c a s e. C o m m a n d s t h a t t y p e s e t s p e c i a l s y m b o l s f o r w r i t i n g S a n s k r i t a n d T i b e t a n a r e a l s o p r o v i d e d a n d a r e s h o w n i n T a b l e 1 0.1 0.
n
‘
m i
^ =
*1 m ^ s
1
^0 e ^0 0
ί β
^ d
*1 y
"1 h
I I ..
e-
0-
^ k
^1 t S | r
\s k s
i\
\s o H u
n
0
^ X
^ n
*1 w ^
G
^ _ % u- %
0- y
z
^
b
1
1 K
i u
m
w
c
3 P
^
\$ *
%\
D 1 Q
^ 0 η τ
Π \ nu
11 N
1 s
H
*1 \s t h
Gl K n
B
\
- a
*1 \s g Ή \s d d ° l \sBH
^1J M ^1 \s r i
*1 \s g h *1 \s d h
R
Ά
\s l i
* J
+1 \s d n
\ 1
1 L
\s l i -
^ \s j h
*1 \s D
ΨΙ \
1
1 \s D H ^
\s k l Ά
\s n d ^
Z
1 \s B °l \skra Ά
P *1 C
^ \s k k *1 \s l k ^1 J
™ \s d s ^ \s n k ^ \s S k ^ X
Ql \s k y Ά
\s n c ^ \s s k
=1 q
ΔΙ \s k r *1 \s n t ^ \s r k
"1 Q
Table 10.10: Soyombo character input method.
ί ο -41 T h e V i e t n a m e s e L a n g u a gb> 365
V o w e l ( t )
B
B a s i c C o n s.
e
a
m
1 1 1 1
1 i i i
V o w e l ( b ) C n y.
1 I I 1 1 I I I
D
ί
P
h
t
h
o
n
8
t i p -
T h e s t r u c t u r a l l a y o u t o f S o y o m b o s y l l a b l e s T h e S o y o m b o s y m b o l
F i g u r e 1 0.2: S o y o m b o l e t t e r s a n d s y m b o l.
1 0.4 1 T h e V i e t n a m e s e L a n g u a g e
W e r n e r L e m b e r g h a s p r o d u c e d t h e n e c e s s a r y f i l e s t h a t a l l o w p e o p l e t o t y p e s e t V i e t ­
n a m e s e d o c u m e n t s t h a t h a v e b e e n p r e p a r e d u s i n g o n e o f t h e f o l l o w i n g i n p u t e n c o d i n g s: V I S C I I, V P S, a n d T C V N. T h e V i e t n a m p a c k a g e b y W e r n e r L e m b e r g a n d H a n T h e T h a n h h a s t h r e e o p t i o n s, w h i c h c o r r e s p o n d t o t h e i n p u t e n c o d i n g m e t h o d e m p l o y e d t o p r e p a r e t h e i n p u t f i l e. O n e d e f a u l t o p t i o n i s v i s c i. T i n e V i e t n a m p a c k a g e r e d e f i n e s t h e c o m m a n d s t h a t h o l d t h e p r e d e f i n e d n a m e s s o t h a t t h e y p r i n t V i e t n a m e s e n a m e s. V i e t n a m e s e i s w r i t t e n i n t h e L a t i n s c r i p t a u g m e n t e d w i t h a n u m b e r o f l e t t e r s w i t h v a r i o u s a c c e n t s. T h i s m e a n s t h a t o n e c a n n o t p r e p a r e a V i e t n a m e s e i n p u t f i l e w i t h a n o r d i n a r y e d i t o r. A s u i t a b l e s o l u t i o n i s t o u s e t h e e m a c s m u l e m o d e. F o r e x a m p l e, t h e f o l l o w i n g t e x t h a s b e e n p r e p a r e d w i t h t h i s e d i t o r:
X i n c h a o A p o s t o l o s H 5 m q u a t 6 i d a, b i £ t c a c h d u n g V i g t t r o n g T u y n h i e n c h a t l i r o n g f o n t k h o n g d u o c t o t, d & c b i e t l a k h i h o a n c h u y e n s a n g P D F f o r m a t.
O f c o u r s e, o u r V i e t n a m e s e f r i e n d c o m p l a i n e d t h a t h e c o u l d n o t c r e a t e q u a l i t y o u t p u t f r o m p d f L?T E X. B u t t h i s j u s t h a p p e n e d b e c a u s e h e w a s n o t a w a r e o f s o f t w a r e t h a t c a n c r e a t e P o s t S c r i p t T y p e 1 f o n t s f r o m M E T R F O N T s o u r c e s. F o r e x a m p l e, h e c o u l d u s e t e x t r a c e ( b y P e t e r S z a b o ). T o t y p e s e t t h e s a m e d o c u m e n t w i t h A, w e m u s t p u t t h e f o l l o w i n g i n o u r d o c u m e n t s p r e a m b l e:
366 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
\o c p\v i s c i i = i n v i s c i i
\o c p l i s t\I n V I S C I I =
\a d d b e f o r e o c p l i s t 1 \v i s c i i \n u l l o c p l i s t \p u s h o c p l i s t \I n V I S C I I
O f c o u r s e, w e m u s t a l s o p u t t h e f o l l o w i n g c o m m a n d i n t h e b o d y o f o u r i n p u t f i l e:
\f o n t f a m i l y { o m l g c }\s e l e c t f o n t
t o m a k e A u s e t h e Ω f o n t s. H e r e i s h o w Λ w i l l t y p e s e t t h e t e x t a b o v e:
X i n c h a o A p o s t o l o s H o r n q u a t o i d a b i e t c a c h d u n g V i e t t r o n g M T g X. T u y n h i e n c h a t l t f c f n g f o n t k h o n g d t f o ’c t o t, d a c b i e t l a k h i h o a n c h u y e n s a n g P D F f o r m a t.
I f w e h a v e p r e p a r e d o u r f i l e u s i n g a U n i c o d e e d i t o r t h a t p r o d u c e s U C S - 2, w e d o n o t n e e d t o u s e a n y O C P. I f o u r U n i c o d e e d i t o r p r o d u c e s U T F - 8 f i l e s, t h e n w e m u s t u s e t h e i n u t f 8 Q C P.
10.42 The Manchu Language
T h e M a n c h u l a n g u a g e i s p a r t o f t h e T u n g u s i c l a n g u a g e f a m i l y, a s u b d i v i s i o n o f t h e A l t a i c l a n g u a g e f a m i l y, w h i c h i n c l u d e s M o n g o l i a n, T u r k i c, a n d a c c o r d i n g t o s o m e s c h o l a r s, J a p a n e s e a n d K o r e a n ( u n d e r t h e t i t l e "m a c r o t u n g u s i c"). M a n c h u i s w r i t t e n u s i n g a m o d i f i e d f o r m o f t h e U i g h u r s c r i p t. T h i s f o r m i n c l u d e s d o t s a n d c i r c l e s a n d i s c a l l e d tongkifuka sindaha hergen
( s c r i p t w i t h d o t s a n d c i r c l e s ). T h e M o n T g X s y s t e m p r o v i d e s s u p p o r t f o r t h e M a n c h u l a n g u a g e. T o e n t e r M a n c h u t e x t, w e m u s t u s e t h e f o l l o w i n g t r a n s l i t e r a t i o n:
—£ a
*b V
e
n
C k
£■ 0 C g
& ϋ
C li
(S' b fr d
^ y
y
f
l^fc * dz
•l·
Ed p 1
Q, k>
L> W
-+£ * tsh
-«t s
^ m
^ g’
£ * sy
Λ. * tshy
s’
n c
°Q. h’ °ΙΊ * cy - * zr
fr t
^ j
* y
0 ^ z
•l·
0^’ zh
t 5
0 |*i: ' ts <t a i i
ΛοΤ
p- T i>
(n t p*
M a n c h u c h a r a c t e r s m a r k e d w i t h a n a s t e r i s k a r e s p e c i a l c h a r a c t e r s l i s t e d i n m a j o r d i c t i o - n a r i e s, w h e r e a s t h e c h a r a c t e r s m a r k e d w i t h a d a g g e r a r e u s e d t o t r a n s c r i b e t h e T i b e t a n
ί ο 4 3 T h e I n u k t i t u t L a n g u a ge^· 367
a l p h a b e t i n t h e M a n c h u s c r i p t. N o t e t h a t t h e d i p h t h o n g ai
i s t r a n s l i t e r a t e d a s a i i. T h e e n v i r o n m e n t s b i t h e t e x t a n d b i t h e p a g e a r e t h e M a n c h u e q u i v a l e n t s o f t h e e n v i r o n ­
m e n t s b i c i g t e x t a n d b i c i g p a g e. T h e \m a b o s o o c o m m a n d i s t h e M a n c h u e q u i v a l e n t o f t h e \m o b o s o o c o m m a n d.
10.43 The Inuktitut Language
I n u k t i t u t i s t h e l a n g u a g e o f t h e I n u i t ( a l s o k n o w n a s E s k i m o s, b u t t h e t e r m i s c o n s i d e r e d o f f e n s i v e b y I n u i t w h o l i v e i n C a n a d a a n d G r e e n l a n d ). T h e l a n g u a g e i s s p o k e n i n G r e e n l a n d, C a n a d a, A l a s k a, a n d t h e C h u k o t k a A u t o n o m o u s O k r u g, w h i c h i s l o c a t e d i n t h e f a r n o r t h e a s t r e g i o n o f t h e R u s s i a n F e d e r a t i o n, b y a p p r o x i m a t e l y 1 5 2,0 0 0 p e o p l e. T h e I n u k t i t u t s y l l a b l e s a r e u s e d b y I n u i t w h o l i v e i n C a n a d a, e s p e c i a l l y i n t h e n e w C a n a d i a n t e r r i t o r y o f N u n a v u t. T h i s w r i t i n g s y s t e m w a s i n v e n t e d b y R e v e r e n d J a m e s E v a n s, a W e s l e y a n m i s s i o n a r y. T h i s s y s t e m w a s b a s e d o n e a r l i e r w o r k o n t h e C r e e l a n g u a g e, w h i c h, i n t u r n, w a s b a s e d o n w o r k o n t h e O j i b w a y l a n g u a g e. T h e f o l l o w i n g t a b l e s h o w s t h e I n u k t i t u t s y l l a b l e s a n d t h e L a t i n t r a n s c r i p t i o n o f t h e I n u k t i t u t s y m b o l s:
A
Λ
n
P
Γ
r
cr
c~
r'
n.
A
Ψ
s p
e
“vp
1
P i
t i
k i
g i
m i
n i
l i
s i
j i
r i
v i
q i
n g i
l h i
n n g i
>
>
D
d
J
J
_o
_3
?
<
Sd
u
p u
t u
k u
g u
mu
n u
l u
s u
j u
r u
v u
q u
n g u
l h u
-N.J
n n g u
<1
<
C
b
I
L
CL
<L-
s
ς
<
sb
u
- v -
“'-L
a
p a
t a
k a
g a
ma
n a
l a
s a
j a
r a
v a
q a
n g a
l h a
n n g a
H
<
c
b
L
L
V
s
Sb
h
Ρ
t
k
g
m
n
1
s
j
r
v
q
n g
l h
n n g
T h e o i n u i t p a c k a g e ( b y t h e f i r s t a u t h o r o f t h i s b o o k ) i s a n e x p e r i m e n t a l p a c k a g e t h a t t r i e s t o s o l v e t h e p r o b l e m o f t y p e s e t t i n g I n u k t i t u t t e x t w i t h A. T h e p a c k a g e p r o v i d e s t h e o p t i o n s n u n a v u t, q u e b e c, i s c i i, u t f 8, a n d u c s 2. T h e f i r s t t w o o p t i o n s s h o u l d b e u s e d t o e n t e r I n u k t i t u t t e x t u s i n g t h e L a t i n t r a n s l i t e r a t i o n p r e s e n t e d a b o v e. T h e t e x t i s t y p e s e t u s i n g t h e A n g l i c a n o r t h e C a t h o l i c s y l l a b i c o r t h o g r a p h y, r e s p e c t i v e l y. T h e i n s c i i o p t i o n s h o u l d b e u s e d w h e n p r e p a r i n g a f i l e u s i n g a p a r t i c u l a r e x t e n d e d A S C I I t h a t i n c l u d e s t h e I n u k t i t u t s y l l a b l e s. T h e d e c l a r a t i o n \i n u i t t e x t c h a n g e s p e r m a n e n t l y t h e f o n t e n c o d i n g, t h e i n p u t m e t h o d, a n d t h e h y p h e n a t i o n r u l e s i n e f f e c t. I f w e d o n o t w i s h t o g l o b a l l y a l t e r t h e s e p a r a m e t e r s, t h e n w e s h o u l d u s e t h e c o m m a n d \t e x t i n u i t
368 -φ- ί ο M u l t i l i n g u a l T y p e s e t t i n g
Figure 10.3: A bilingual t e x t t y p e s e t with A and t h e oinuit p a c k a g e.
AL?ADb
Cb3
Imaruituq Taqtu
ϋ < Ι σ - Γ < ν < 1 _ 3 A r lbry n.m < l b j C. C < c A^-
o_r;<?c r < ] o"i >(: C L c l L ^ bC > j c t < 1 ο _ ο _ Π _ ο P r l < ^ n.n C X ( ^ > cl C.
< ] b C DCf- *- Δ J A ^/l j C r 6 S o _ -
^ o _ r ^ C—E ^ ^ L. L c < I q _ q _ L
^ b ^ n ^ ^ ^ L L b > ^ L n < d j c t L Α > γ^ Γ σ - 6 C ^ L c b C ^ L m · ^ - < D o > r;L o - < q ^ j r r n - < 1 _ 5 J C L cl L P Q _ t > ^ O _ < ] ci r i r J
^ο_Ι> ^c - t>bt>!rt>n<]b<scro"ciC
H L c r.
W h e n w e w e r e c h i l d r e n w e n e v e r h a d a n y t h i n g t o w o r r y a b o u t, a l l w e h a d t o d o w a s p l a y. I t w a s a l l t h e r e w a s a n d w e w e r e v e r y h a p p y. B u t a s w e g r e w o l d e r, o u r p a r e n t s, e s p e c i a l l y o u r m o t h ­
e r s, s t a r t e d t o t e a c h u s t h e t h i n g s w e h a d t o k n o w, s u c h a s h o w t o l o o k a f t e r a h o u s e. M y m o t h e r t o l d m e t h a t s h e w a n t e d m e t o l e a r n t h e s e t h i n g s b e c a u s e I w o u l d h a v e a h o u s e o f m y o w n w h e n I g r e w u p, b u t I d i d n't b e l i e v e i t.
o r t h e e n v i r o n m e n t i n u i t. F i g u r e 1 0.3 s h o w s s o m e b i l i n g u a l t e x t t y p e s e t w i t h A a n d t h e o i n u i t n p a c k a g e. T h e p a c k a g e u s e s a P o s t S c r i p t v e r s i o n o f t h e N u n a c o m T r u e T y p e f o n t d e v e l o p e d b y N o r t e x t (
h t t p://w w w.n o r t e x t.c o m
), w h i c h i s r e d i s t r i b u t e d w i t h p e r m i s s i o n f r o m N o r t e x t.
10.44 Archaic Writing Systems
P e t e r R. W i l s o n h a s d e v e l o p e d a n u m b e r o f p a c k a g e s t h a t c a n b e u s e d t o t y p e s e t t e x t w r i t t e n i n c e r t a i n a r c h a i c w r i t i n g s y s t e m s, w h i c h i n c l u d e:
P a c k a g e
S c r i p t
P a c k a g e
S c r i p t
c o p t i c
e t r u s c a n
C o p t i c
E t r u s c a n
c y p r i o t
g r e e k 4 c b c
C y p r i o t i c G r e e k
G r e e k o f t h e 4 t h c e n t u r y B.C.
h i e r o g l f
u g a r i t e
P h o e n i c i a n
r u n i c
H i e r o g l y p h i c
U g a r i t i c
P h o e n i c i a n
R u n i c
g r e e k S c b c
l i n e a r b
p r o t o s e m
o l d p r s n
G r e e k o f t h e 6 t h c e n t u r y B.C. L i n e a r B ( p r e c l a s s i c a l G r e e k s c r i p t ) P r o t o s e m i t i c
O l d P e r s i a n ( c u n e i f o r m w r i t i n g )
ί ο 4 4 A r c h a i c W r i t i n g S y s t e m s - ^ - 369
I n a d d i t i o n t o t h e c o p t i c p a c k a g e, o n e c a n a l s o u s e t h e c o p t e p a c k a g e ( b y S e r g e R o s m o r - d u c ) t o t y p e s e t C o p t i c t e x t.
I t s h o u l d b e n o t e d t h a t a s f a r a s t h e h i e r o g l y p h s a r e c o n c e r n e d, t h e p a c k a g e p r o v i d e s a c c e s s t o a s m a l l s u b s e t o f t h e g l y p h s o f t h e S e s h N e s o u t s y s t e m c r e a t e d b y S e r g e R o s m o r d u c. W i l s o n c h o s e a b o u t 7 0 o f t h e m o s t c o m m o n g l y p h s f r o m t h i s p a c k a g e t o c r e a t e t h e h i e r o g l y p h p a c k a g e.
T a b l e 1 0.1 1 s h o w s t h e n e w f o n t s e l e c t i o n c o m m a n d s p r o v i d e d b y t h e p a c k a g e s d e s c r i b e d i n t h i s s e c t i o n. T h e s h o r t p a s s a g e c o m m a n d s t a k e a s a r g u m e n t a p i e c e o f t e x t
Table 10.11: New c o m m a n d s provided by t h e p a c k a g e s t h a t provide s u pp o rt for a rc hai c writing s y s t e m s.
P a c k a g e
F o n t F a m i l y S e l e c t i o n
S h o r t P a s s a g e C o m m a n d
c o p t e
—
\t e x t c o p t e
c y p r i o t
\c y p r f a m i l y
\t e x t c y p r
e t r u s c a n
\e t r f a m i l y
\t e x t e t r
g r e e k 4 c b c
\g i v b c f a m i l y
\t e x t g i v b c
g r e e k 6 c b c
\g v i b c f a m i l y
\t e x t g v i b c
hieroglf
\p m h g f a m i l y
\t e x t p m h g
l i n e a r b
\l i n b f a m i l y
\t e x t l i n b
o ld p r s n
\c o p s n f a m i l y
\t e x t c o p s n
P h o e n i c i a n
\p h n c f a m i l y
\t e x t p h n c
p r o t o s e m
\p r o t o f a m i l y
Y t e x t p r o t o
ru n i c
\f u t f a m i l y
\t e x t f u t
u g a r i t e
\c u g a r f a m i l y
\t e x t c u g a r
i n t h e c o r r e s p o n d i n g l a n g u a g e. I n a d d i t i o n, t o t y p e s e t C o p t i c l a n g u a g e t e x t s, w e n e e d t o l o a d t h e f o n t e n c o d i n g s C O P a n d T I. I n o t h e r w o r d s, w e m u s t i n c l u d e t h e f o l l o w i n g c o m m a n d i n t h e p r e a m b l e o f o u r f i l e:
\u s e p a c k a g e [ C 0 P,T 1 ] { f o n t e n c ) ·
I n w h a t f o l l o w s, w e p r e s e n t t h e t r a n s l i t e r a t i o n s d e f i n e d b y t h e v a r i o u s p a c k a g e s t h a t c a n b e u s e d t o a c c e s s i n d i v i d u a l l e t t e r s o r s y m b o l s, i n g e n e r a l.
_________________________________________________6 t h c e n t u r y G r e e k _________________________________________________
Α Β Γ Δ Ε Ι Β Θ Ι Κ Γ Γ" Ν Ξ Ο Γ ^ Σ Τ Υ Χ Φ Υ Ο
\t e x t g v i b c { A B G D E Z H\T T h e t a\ I K L M N\T X i O P E S T U X\T P h i\T P s i\T O m e g a > ------
37° ^ 10 M u l t i l i n g u a l T y p e s e t t i n g
_________________________________________ 4 t h c e n t u r y G r e e k ( s m o o t h ) _________________________________________
Α&ΓΔ EZHO ΙΚΛ/Λ ΝΞΟΡ P<TY ΧΦΫΠ
\t e x t g i v b c { A B G D E Z H\T T h e t a\ I K L M N\T X i O P E S T U X\T P h i\T P s i\T O m e g a >
_________________________________________ 4 t h c e n t u r y G r e e k ( r o u g h ) __________________________________________
Α&ΓΔ EZHO ΙΚΛ/Λ ΝΞΟΓ Ρ ί ΤΥ ΧΦΫΑ
\t e x t g i v b c { a b g d e z h\t T h e t a\ i k l m n\t X i o p r s t u x\t P h i\t P s i\t O m e g a ) ·
_______________________________________________________ E t r u s c a n _______________________________________________________
ABTD P F I i <8>l KU ΓΤ ΘΟ *ΤΎΧ ΦΤ8 Α910 3=IIB
(S> I >1J 'Ί Ί ΘΟ 19 4 £ΤΓΧ <PY8
\t e x t e t r { A B G D E F Z H \T T h e t a I K L M N\T X i 0 P\T s a d e Q E S T U X\T P h i\T P s i 8 a b g d e f z h \t T h e t a i k l m n\t X i o p\t s a d e q r s t u x\t P h i\t P s i 8}-
_____________________________________________________ P h o e n i c i a n _______________________________________________
>(> τδ £ F i i (S>ι xu r - r i o r - m w+ <- η δ 3= iis <g>i
'Ί Ί Ϊ Ο 1ΓΦ4 W +
\t e x t p h n c { A B G D E F Z H \T T h e t a I K L M N\T X i 0 P\T s a d e Q E S T a b g d e f z h \t T h e t a i k l m n\t X i o p\t s a d e q r s t }
__________________________________________________________R u n i c ________________________________
Is hH* l^kXI> Η + ΙΦ J'KYH ΐ &ΜΠ r XHS : \t e x t f u t { F U\F t h o r n A E K G W H N I J Y P X S T B E M L\F n g DO :>
________________________________________________________ U g a r i t i c _________________________________________________________
n τ? m ^ ΐ <t>itw <t — ί=<?< t= u >-<»>- 4 ^ ^
j i l $Ta t
\t e x t c u g a r { a b g H d h w z I J y k S l m D n Z s ‘ p x q r T G t i u X:} -
abgh dhwz htyk slmd nzs' psqr tgti us:
\t r a n s l i t c u g a r {\U a\U b\U g\U h u \U d\U h\U w\U z\U h d\U t d\U y\U k \U s a\U l\U m\U d b \U n\U z d\U s\U l q \U p\U s d\U q\U r \U t b\U g d\U t\U i \U u\U s g\U w d }
ί ο 4 4 A r c h a i c W r i t i n g S y s t e m s - ^ - 371
_________________________________________________________L i n e a r B _______________________________________________________
isrm ΐ αχκά t t ^ © r r + 2 b
T T W Y z m A M B t T? W = i Jf +4 T7? ί f i r t h * n d r f T ε φ
\t e x t l i n b { a d j k m n p q r s t w z e D J K M W P Q R S T W Z i f c y C G X O Y 3 6 o g b h A E H 8 U 1 4 7 9 u x L v B F I V 2 5 }
O r
\t e x t l i n b {\B a\B d a\B j a\B k a \B m a\B n a\B p a\B q a \B r a\B s a\B t a\B w a \B z a \B e\B d e\B j e\B k e \B m e\B n e\B p e\B q e \B r e\B s e\B t e\B w e \B z e \B i\B d i\B k i\B m i \B n i\B p i\B q i\B r i \B s i\B t i\B w i \B o\B d o\B j o\B k o \B m o\B n o\B p o\B q o \B r o\B s o\B t o\B w o \B z o \B u\B d u\B j u\B k u \B m u\B n u\B p u\B r u \B s u\B t u }
____________________________________________________ H i e r o g l y p h s _____________________________________________________
Ά δΛ H?» T a
λ — ~ £\n ^ < = > P c
+H
\t e x t p m h g { A B C D E F G H I J K L M M O P Q R S T U V W X Y Z a b e d e f g h i j k l m n o p q r s t u v w x y z +?/| }
'b h d s%i bh h m k i w r n h t ^ s t t pwrst _ w d w h %bd 'r nd t r f g h i p r k l
m n w s p h r r s t h d n b w w y s i m y a z o t k m ^ w f m s d h w t y b3 g m \t r a n s l i t p m h g - C\H A\H B\H C\H D \H E\H F\H G\H H \H I\H J\H K\H L \H M\H M\H O\H P \H Q\H R\H S\H T \H U\H V\H W\H X \H Y\H Z \H a\H b\H c\H d \H e\H f\H g\H h \H i\H j\H k\H l \H m\H n\H o\H p \H q\H r\H s\H t \H u\H v\H w\H x \H y\H z \H p l u s\H q u e r y\H s l a s h\H v b a r \H m s\H i b p\H i b w\H i b s \H i b l\H s v }
I t i s i m p o r t a n t t o s t r e s s t h a t t h e h i e r o g l f p a c k a g e g i v e s a c c e s s t o a s m a l l s u b s e t o f t h e m o s t c o m m o n g l y p h s c h o s e n a m o n g t h e m a n y m o r e p r o v i d e d b y t h e S e s h N e s o u t s y s ­
t e m ( b y S e r g e R o s m o r d u c ), w h i c h i s a v a i l a b l e f r o m h t t p: //k h e t y. i u t. u n i v - p a r i s 8. f r/~ r o s m o r d. T h i s i s, h o w e v e r, a m u c h m o r e d i f f i c u l t s y s t e m t o u s e, a s i t r e q u i r e s a ( p r o v i d e d ) p r e p r o c e s s o r ( c a l l e d S e s h N e s o u t ) t h a t m u s t b e u s e d t o p r e p r o c e s s t h e i n p u t f i l e. O b v i o u s l y, o n e c a n w o r k o n t h e c r e a t i o n o f a n Ω Τ Ρ t h a t w i l l e v e n t u a l l y s u b s t i t u t e t h e p r e p r o c e s s o r.
372 ^ 10 M u l t i l i n g u a l T y p e s e t t i n g
____________________________________________________ P r o t o s e m i t i c ___________________________________________________
= § L ^ 0 D ^ — ^ < ξ > 0 I k H ^ c x.^ c o ^ +
\t e x t p r o t o { a b g d z e w h i y k l m n o p u v q r s x t A B G D Z E W H I Y K L MNOP U V Q R S X T >
______________________________________________________ O l d P e r s i a n __________________________________________________
ΊτΓ ff <ff Τϊ= <T «ΤΤ <T> 'ττ -H s4tT ΤΓΤ— XT £ ft ^T <S *=< <<t= ^ T« ^ H’rT
TE^<H«=< t=<K ίίΤΤ «Τ ^
\t e x t c o p s n { a i u k K x g G c j j t T o C d P D n N p f b m w M y r R l v V s S z h X q Q L B e E F :>
ΊτΓ Tf <fr Τϊ= <T «ΤΤ <TT*· <E= Tr M he Μ'ΤΤ TTl· XT £ ff ΕΠ’ <0 « <0 =
?T X< ^ tT X- Η Κ< α ^ ί ΤΗ H «=<
\t e x t c o p s n {\O a\O i\G u\O k a \0 k u\0 x a\0 g a\0 g u \0 c a\0 j a\0 j i\G t a \O t u\O t h a\O c c a\O d a \0 d i\0 d u\G n a\0 n u \0 p a\0 f a\O b a\O m a \0 m i\0 m u\0 y a\0 r a \0 r u\0 1 a\0 v a\0 v i \0 s a\0 s v a\0 z a\0 h a }
________________________________________________________ C y p r i o t ________________________________________________________
x>xn \n vm n vh>A< * > ^8 X w u r j j x t ^ v t>'< n + urn r^m
)\m ) x f i
\t e x t c y p r { a g j k l m n p r s t w e K L M N P R S TW i c d y C G O Y 3 6 o b h f A E H U 1 4 7 9 u v q B F I V 2 5 }
O r
\t e x t c y p r - C\C a\C g a\C j a\C k a \C l a\C m a\C n a\C p a \C r a\C s a\C t a\C w a \C e\C k e\C l e\C m e \C n e\C p e\C r e\C s e \C t e\C w e \C i\C k i\C l i\C m i \C n i\C p i\C r i\C s i \C t i\C w i
\C u\C k u\C l u\C m u \C n u\C p u\C r u\C s u \C t u ) -
_________________________________________________________C o p t i c_________________________________________________
eOXBC 2.6 ^ HIJbR MJHO Π(ΓΡΤ YUDCUJ ?,X t
A.&CZ. e ^ V H Ι<έ>Κλ JULItOIT 6ρΤΎ ο3Χ α » ζ Θ ^ Φ Ψ
\t e x t c o p t e { 8 A B C DEFG H I J K LMNO PQRT UWXY Ζ Ε Ε Ι IN D a b e d e f g h i j k l mnop q r t u w x yz Ε Ε Ι Ϊ DDO}-
ί ο 4 4 A r c h a i c W r i t i n g S y s t e m s - ^ - 373
I n a d d i t i o n t o t h e a b o v e, t h e h i e r o g l f p a c k a g e a l l o w s f o r t h e c r e a t i o n o f c a r t o u c h e s w i t h t h e c o m m a n d s \c a r t o u c h e a n d \C a r t o u c h e ( t h e s e c o n d c o m m a n d g i v e s w i d e r l i n e s a n d c u r v e s f o r t h e c a r t o u c h e ). H e r e i s a n e x a m p l e:
.□ ω
m.
\C a r t o u c h e - C\t e x t p m h g - [\H p: \H t -\H 0-\H 0: \H M -\H y -\H s »
V e r t i c a l c a r t o u c h e s c a n b e c r e a t e d u s i n g t h e \v a r t o u c h e a n d \V a r t o u c h e c o m m a n d s.
1 1 -------------
T o E r r Ts H u m a n
T o r e c a p i t u l a t e o n t h e u s e o f K T g X, t h e r e a d e r m a y r e c a l l t h a t w e t y p e o u r t e x t c o n ­
t a i n i n g t h e f o r m a t t i n g c o m m a n d s i n a n i n p u t f i l e u s i n g o u r f a v o r i t e e d i t o r. W e t h e n i n v o k e t h e T g X t y p e s e t t i n g p r o g r a m, w h i c h p r o c e s s e s t h e i n p u t f i l e u s i n g t h e L?T e X f o r m a t, o u t p u t t i n g a m i n i m u m o f t h r e e f i l e s: a D V T f i l e, a n a u x i l i a r y f i l e u s e d b y t h e p r o g r a m t o g e n e r a t e t h i n g s s u c h a s c r o s s - r e f e r e n c e s, a n d a l o g f i l e t h a t c o n t a i n s i n ­
f o r m a t i o n a b o u t w h a t T g X e n c o u n t e r e d, i n c l u d i n g d e t a i l s o f a n y w a r n i n g s o r e r r o r s. W h i l e i t i s t y p e s e t t i n g a f i l e, T ^ X t e l l s y o u a b o u t i t s p r o g r e s s e i t h e r i n a w i n d o w o r, o n o l d e r s y s t e m s, o n t h e f u l l s c r e e n o f y o u r c o m p u t e r. A n y w a r n i n g s a r e d e s c r i b e d w i t h o u t t h e p r o g r a m h a l t i n g, a n d o n f a s t e r s y s t e m s s o m e o f t h i s c a n b e r a t h e r f l e e t ­
i n g, b u t s i n c e t h e y a r e r e p r o d u c e d i n t h e l o g f i l e, t h i s c a n b e e x a m i n e d a f t e r w a r d s. W h e n a n e r r o r i s e n c o u n t e r e d, t h e p r o g r a m a c t u a l l y h a l t s, g i v i n g a n i n d i c a t i o n o f t h e n a t u r e o f t h e e r r o r, o n w h i c h l i n e o f y o u r i n p u t f i l e t h e e r r o r m i g h t b e f o u n d, a n d a ? p r o m p t. W a r n i n g m e s s a g e s i n d i c a t e p r o b l e m s t h a t a r e n o t s e r i o u s b u t t h a t a r e l i k e l y t o a f f e c t t h e o u t p u t ( e.g., p r o b l e m s w i t h h y p h e n a t i o n, l i n e - b r e a k i n g, c r o s s - r e f e r e n c e s a n d l a b e l s, f i n d i n g a p a r t i c u l a r f o n t, e t c.), w h i l e e r r o r s a r e m o r e s e r i o u s, c a u s i n g t h e T g X p r o g r a m t o s t o p ( e.g., t h e m e s s a g e s e n v i r o n m e n t u n d e f i n e d, a n o m i t t e d i t e m i n a l i s t m a k i n g e n v i r o n m e n t, a n d m i s p l a c e d a l i g n m e n t t a b c h a r a c t e r &, a m o n g o t h e r s ).
M i n o r e r r o r s c a n b e s k i p p e d o v e r b y j u s t p r e s s i n g t h e E n t e r k e y. T h i s a l l o w s y o u t o c h e c k f o r m o r e t h a n o n e e r r o r a t a t i m e. H o w e v e r, s o m e t i m e s a s i n g l e m i s t a k e c a n l e a d t o m u l t i p l e e r r o r s a n d y o u c a n exit
t h e p r o g r a m b y t y p i n g t h e l e t t e r x f o l l o w e d b y t h e E n t e r k e y. A n a l t e r n a t i v e i s t o a s k f o r a s s i s t a n c e w i t h e d i t i n g b y t y p i n g i n t h e l e t t e r e f o l l o w e d b y t h e E n t e r k e y. T h i s w i l l p r i n t o u t a m e s s a g e s t a t i n g o n t h e l i n e o n w h i c h t h e e r r o r m a y b e f o u n d, a n d o n s o m e s y s t e m s i t w i l l s t a r t u p y o u r e d i t o r a n d t h e n p l a c e y o u r p r o m p t b y t h e o f f e n d i n g t e x t. S o m e t i m e s, i n s t e a d o f a ? p r o m p t y o u w i l l s e e a * w i t h n o e r r o r m e s s a g e. T h i s u s u a l l y i n d i c a t e s t h a t t h e \e n d { d o c u m e n t > c o m m a n d h a s b e e n f o r g o t t e n a n d y o u c a n e x i t t h e p r o g r a m b y t y p i n g \s t o p f o l l o w e d b y t h e E n t e r k e y. E i t h e r m e t h o d o f s t o p p i n g T g X w i l l m a k e i t p r o d u c e t h e l o g f i l e. T h i s f i l e c a n b e o p e n e d u p i n y o u r t e x t e d i t o r t o t a k e a n o t h e r l o o k a t t h e e r r o r a n d w a r n i n g m e s s a g e s
376 ^ 11 T o E r r I s H u m a n
t h a t w e r e g e n e r a t e d d u r i n g t h e l a t e s t r u n o f y o u r i n p u t f i l e t h r o u g h t h e t y p e s e t t i n g e n g i n e.
V a r i o u s a l t e r n a t i v e r e s p o n s e s f r o m t h e u s e r a r e p o s s i b l e a t t h e p r o m p t f o l l o w i n g a n e r r o r m e s s a g e ?; u p p e r c a s e o r l o w e r c a s e l e t t e r s m a y b e t y p e d. Scroll
m o d e i s s t a r t e d b y t y p i n g t h e l e t t e r s, f o l l o w e d b y t h e E n t e r k e y a n d i t c a u s e s Τ β Χ t o p r o c e e d t h r o u g h t h e f i l e a n d d i s p l a y a n y e r r o r m e s s a g e s o n t h e s c r e e n w i t h o u t s t o p p i n g u n l e s s a f i l e m e n t i o n e d i n a \i n p u t o r \i n c l u d e c o m m a n d c a n n o t b e f o u n d o n t h e c o m p u t e r. Run
m o d e o c c u r s w h e n t h e u s e r t y p e s i n a l e t t e r r f o l l o w e d b y t h e E n t e r k e y a n d i s t h e s a m e a s Scroll
m o d e a p a r t f r o m t h e f a c t t h a t i t w i l l c o n t i n u e e v e n i n t h e a b s e n c e o f a f i l e n a m e d i n a \i n p u t o r \i n c l u d e c o m m a n d. Quiet
m o d e i n v o l v e s t h e u s e r t y p i n g a l e t t e r q f o l l o w e d b y t h e E n t e r k e y a n d a c t s t h e s a m e a s Run
m o d e, b u t n o m e s s a g e s a r e w r i t t e n t o t h e o u t p u t w i n d o w, a l t h o u g h t h e y s t i l l g o t o t h e l o g f i l e. A n Insert
m o d e i s a v a i l a b l e b y t y p i n g t h e l e t t e r i f o l l o w e d b y t h e E n t e r k e y. T h i s a l l o w s t h e u s e r t o t y p e i n a l i n e o f c o m m a n d s/t e x t f r o m t h e k e y b o a r d t o c o r r e c t t h e e r r o r. T h i s w i l l o n l y a f f e c t t h e c u r r e n t r u n t h r o u g h t h e t y p e s e t t i n g e n g i n e; i t w i l l n o t c h a n g e t h e u s e r's i n p u t f i l e. I t i s u s e f u l w h e r e s o m e t h i n g h a s b e e n o m i t t e d ( e.g., a m a t h e n v i r o n m e n t d e l i m i t e r, s u c h a s $ ). O n e c a n o b t a i n m o r e i n f o r m a t i o n a b o u t a n e r r o r t h r o u g h u s i n g t h e help
f a c i l i t y, i n v o k e d b y t y p i n g i n t h e l e t t e r h f o l l o w e d b y t h e E n t e r k e y. T h i s w i l l a l s o p r o d u c e h i n t s a b o u t h o w t h e p r o b l e m m i g h t b e s o l v e d.
A n a l t e r n a t i v e t o w o r k i n g t h r o u g h t h e e r r o r s i n y o u r f i l e i n t e r a c t i v e l y i s t o p l a c e t h e c o m m a n d \b a t c h m o d e a t t h e s t a r t o f y o u r I ^ T g X i n p u t f i l e. I n v o k i n g I ^ T g X w i l l t h e n c a u s e i t t o a u t o m a t i c a l l y w o r k a s f a r a s i t c a n t h r o u g h t h e i n p u t f i l e, a l t h o u g h y o u m a y e n d u p w i t h a l o n g l i s t o f e r r o r s i n y o u r l o g f i l e s i n c e t h e e f f e c t s o f e a c h c a n b e c u m u l a t i v e. N o t e t h a t s o m e t i m e s a n e r r o r c a n l e a d t o D T ^ X p r o d u c i n g e r r o r m e s s a g e s t h a t a r e p u r e l y a r t i f a c t u a l: i f y o u c o r r e c t t h a t e r r o r, t h e o t h e r s w i l l g o a w a y. H o w e v e r, a f t e r T g X o u t p u t s a p a g e o f o u t p u t, t h e e f f e c t o f t h e e r r o r h a s o f t e n p a s s e d, a n d t h e n e x t e r r o r e n c o u n t e r e d i s l i k e l y t o b e a g e n u i n e o n e w o r t h c h e c k i n g o u t.
T h e w a y i n w h i c h T ^ X d o e s i t s t y p e s e t t i n g h a s a n i m p a c t u p o n t h e m e s s a g e s t h a t i t g e n e r a t e s f o r e r r o r s a n d w a r n i n g s. T j?X s w i t c h e s b e t w e e n g e n e r a t i n g i t s o u t p u t o n a n e x p a n d i n g "s c r o l l" o f t y p e s e t o u t p u t a n d "c u t t i n g o f f" p a g e s o f o u t p u t t h a t a r e w r i t t e n o u t. L a m p o r t [ 2 0 ] p o i n t s o u t h o w t h i s i s a n a l o g o u s t o t h e w a y i n w h i c h t r a d i t i o n a l t y p e s e t t e r s p r o d u c e l e n g t h s o f m e t a l t y p e, c a l l e d g a l l e y s, t h a t a r e m a n a g e a b l e l e n g t h s f r o m a h y p o t h e t i c a l s c r o l l o f t e x t t h a t o p e n s o u t v e r t i c a l l y f r o m t h e b e g i n n i n g o f t h e d o c u m e n t d o w n w a r d s. B e c a u s e o f h i s t o r i c a l l i m i t s t o t h e a m o u n t o f m e m o r y a v a i l a b l e t o T g X, i t d o e s n o t k e e p m u c h m o r e t h a n a p a g e i n m e m o r y a t a t i m e. A f t e r i t g e n e r a t e s e a c h p a r a g r a p h u n i t, i t c h e c k s t o s e e i f t h e r e i s e n o u g h m a t e r i a l t o t y p e s e t a p a g e; i f s o, t h e p a g e i s a d d e d t o t h e D V I f i l e w i t h a n y h e a d e r a n d p a g e n u m b e r a d d e d. F o l l o w i n g e a c h p a g e o f o u t p u t, T g X d i s p l a y s a m e s s a g e i n t h e o u t p u t w i n d o w g i v i n g t h e p a g e n u m b e r i n s q u a r e b r a c k e t s. T h i s m e a n s t h a t t h e o f f e n d i n g m a t e r i a l f r o m o u r i n p u t f i l e t h a t g e n e r a t e d t h e e r r o r p r o b a b l y o c c u r r e d i n t h e s e c t i o n o f i n p u t t e x t t h a t c o r r e s p o n d s t o t h e t y p e s e t p a g e. H o w e v e r, i t i s p o s s i b l e t h a t t h e e r r o r a c t u a l l y o c c u r r e d i n t h e t e x t t h a t h a d b e e n t y p e s e t s i n c e t h e l a s t p a g e o f o u t p u t ( i.e., t h o s e p a r a g r a p h s p l a c e d o n t h e
i i.i L T ^ X's E r r o r L o c a t o r -φ- 377
"s c r o l l" t h a t d i d n o t y e t m a k e u p e n o u g h m a t e r i a l f o r a c o m p l e t e p a g e o u t p u t ). T h u s, t h e e r r o r m i g h t l i e o n t h e l a s t g e n e r a t e d p a g e o f o u t p u t, o r i t m i g h t b e i n t h e n e x t c o u p l e o f p a r a g r a p h s a w a i t i n g o u t p u t.
11.1 BT^X's Error Locator
W e h a v e d e s c r i b e d, i n o u t l i n e, h o w, w h e n T g X d i s c o v e r s a p r o b l e m w i t h t h e i n p u t f i l e, a n i n d i c a t o r o f t h e e r r o r i s p r o d u c e d i n t h e o u t p u t w i n d o w a n d t h e l o g f i l e. I n a d d i t i o n, a l o c a t o r f o r t h e e r r o r i n f o r m s y o u h o w f a r t h r o u g h y o u r i n p u t f i l e t h e t y p e s e t t i n g e n g i n e h a d g o n e, b e f o r e d i s c o v e r i n g t h e e r r o r. O f t e n t h e l i n e s h o w n b y t h e e r r o r i n d i c a t o r w i l l i n d i c a t e t h e e r r o r, a l t h o u g h d u e t o t h e w a y t h a t T g X o n l y f e e d s w h o l e p a g e s t o t h e D V I f i l e, i t i s p o s s i b l e t h a t t h e e r r o r m a y n o t b e s h o w n i n t h e t y p e s e t o u t p u t t h a t h a s b e e n g e n e r a t e d t h u s f a r. R u n n i n g I 5 T g X o n a s i m p l e i n p u t f i l e w i t h t h e c o n t e n t s:
\d o c u m e n t c l a s s [ 1 2 p t ] { a r t i c l e }
\b e g u n { d o c u m e n t } - M y s a m p l e t e x t.
\e n d { d o c u m e n t }
g e n e r a t e s t h i s e r r o r m e s s a g e o n t h e s c r e e n a n d i n t h e l o g f i l e
! U n d e f i n e d c o n t r o l s e q u e n c e.
1.2 \b e g u n
{ d o c u m e n t ) ·
7
w h i c h i n f o r m s u s t h a t a T g X e r r o r o c c u r r e d a t l i n e 2 o f t h e d o c u m e n t i n p u t f i l e. I n t h i s c a s e, i t i s t h e m i s s p e l l e d c o m m a n d n a m e \b e g u n, w h i c h s h o u l d b e c o r r e c t e d t o \b e g i n f o r t h e e x a m p l e t o t y p e s e t c o r r e c t l y.
O c c a s i o n a l l y, t h e e r r o r i s n o t d e t e c t e d w h e n T g X i s g e n e r a t i n g t h e s c r o l l; i n s t e a d, i t h a p p e n s w h e n i t i s c u t t i n g o f f t h e p a g e f o r o u t p u t t o t h e D V I f i l e. T h e s e a r e c a l l e d outputting
e r r o r s a n d a r e i n d i c a t e d b y t h e t e x t < o u t p u t > a p p e a r i n g a b o v e t h e e r r o r l o c a t o r, t h e l a t t e r s u g g e s t i n g w h e r e TpX.
g o t t o w h i l e t y p e s e t t i n g t h e s c r o l l, t h e e r r o r i t s e l f h a v i n g o c c u r r e d t h e r e o r a t s o m e p o i n t s i n c e t h e l a s t p a g e w a s c u t o f f t h e s c r o l l.
W h e n I £ I g X p r o c e s s e s t h e \b e g i n { d o c u m e n t } - c o m m a n d, t h e a u x i l i a r y f i l e i s r e a d i n, a n d a t t h i s p o i n t e r r o r s c a n b e d e t e c t e d. I n t h e c a s e o f a n e r r o r g e n e r a t e d b y t h e \b e g i n { d o c u m e n t >, i t i s l i k e l y t h a t t h e e r r o r w a s p r o d u c e d t h e p r e v i o u s t i m e t h a t y o u r a n ^ Τ ^ Χ o n t h e f i l e. H o w e v e r, i f t h e e r r o r w a s p r o d u c e d b y t h e \e n d { d o c u m e n t >, t h i s s u g g e s t s t h a t t h e p r o b l e m a r o s e f r o m m o v i n g a n a r g u m e n t t h a t c o n t a i n s a f r a g i l e c o m m a n d. S i m i l a r l y, s o m e o f t h e a d d i t i o n a l f i l e s t h a t I ^ T ^ X g e n e r a t e s c a n g e n e r a t e e r r o r s [ e.g., t a b l e s o f c o n t e n t s (. t o e f i l e s ), l i s t s o f f i g u r e s (. l o f f i l e s ), a n d l i s t s o f t a b l e s (. l o t f i l e s ) ]. T h e a p p e a r a n c e o f t h e e r r o r m e a n s t h a t i t w a s t h e p r e v i o u s r u n o f t h e i n p u t f i l e t h r o u g h E T ^ X t h a t p r o d u c e d t h e e r r o r t h a t i s n o w d e t e c t e d. O f t e n, t h i s i s a p r o b l e m w i t h a c a p t i o n i n g o r s e c t i o n i n g c o m m a n d.
yj% ^ 1 1 T o E r r I s H u m a n
I f y o u c a n n o t d e t e c t t h e n a t u r e o f t h e e r r o r f r o m t h e e r r o r m e s s a g e s t h a t 15ΤβΧ d i s p l a y s i n t h e o u t p u t w i n d o w a n d p r i n t s i n t o t h e l o g f i l e, t h e n t h e n e x t s t e p i s t o u s e t h e p r o g r a m f o r d i s p l a y i n g y o u r D V I f i l e s t o e x a m i n e t h e t y p e s e t o u t p u t. E n t e r i n g a n e x i t c o m m a n d χ a t t h e e r r o r p r o m p t ? f o l l o w e d b y t h e E n t e r k e y c a n l e a v e t h e p o r t i o n o f t h e t y p e s e t t e x t w i t h t h e e r r o r o n t h e s c r o l l, f o r i f T g X h a s n o t g e n e r a t e d t h e e r r o r i n a c o m p l e t e p a g e o f o u t p u t, t h e n i t w i l l n o t h a v e b e e n s e n t t o t h e d v i. Y o u c a n g e t a r o u n d t h i s b y u s i n g o n e o f t h e a l t e r n a t i v e m o d e c o m m a n d s a t t h e e r r o r p r o m p t ( e.g., s, r, a n d q w i l l c o n t i n u e t y p e s e t t i n g t h r o u g h t h e r e m a i n d e r o f t h e d o c u m e n t ). A n e a s i e r a l t e r n a t i v e, w h e n m a n y p a g e s f o l l o w t h e e r r o r, i s j u s t t o k e e p p r e s s i n g t h e E n t e r k e y u n t i l T g X i n d i c a t e s t h a t i t h a s p r o d u c e d o n e m o r e p a g e o f o u t p u t. F a i l i n g t h i s a p p r o a c h, y o u w i l l h a v e t o t r y, b y t r i a l a n d e r r o r, t o l o c a t e t h e s m a l l e s t f r a g m e n t o f y o u r t e x t t h a t g e n e r a t e s t h e e r r o r. T h e u s e o f t h e % s y m b o l c a n b e u s e f u l s i n c e y o u c a n t r y "c o m m e n t i n g o u t" s u s p e c t p i e c e s o f t e x t t o s e e i f t h e e r r o r t h e n d i s a p p e a r s. I f y o u r f i l e w i t h t h e c o m m e n t e d o u t t e x t n o w t y p e s e t s c o r r e c t l y t h r o u g h t h e a r e a w h e r e t h e e r r o r w a s, t h e n w e c a n b e c o n f i d e n t t h a t t h e e r r o r l i e s i n t h e i s o l a t e d p i e c e o f t e x t.
A s a l e a r n i n g a i d, w e s h a l l b e w r i t i n g s o m e s i m p l e f i l e s t h a t i l l u s t r a t e t h e k i n d o f e r r o r s t h a t o n e c a n e n c o u n t e r d u r i n g t h e c o u r s e o f p r e p a r i n g a Ι ^ Τ β Χ s o u r c e f i l e. A f t e r c a r e f u l l y t y p i n g i n t h e e x a m p l e, y o u w i l l n e e d t o t a k e a l o o k a t t h e m e s s a g e s t h a t a p p e a r i n t h e o u t p u t w i n d o w o f y o u r t y p e s e t t i n g e n g i n e, a n d y o u m a y a l s o n e e d t o e x a m i n e t h e l o g f i l e w i t h y o u r e d i t o r. A t a n e r r o r p r o m p t, y o u w i l l b e g u i d e d a s t o w h i c h c o m m a n d m o d e t o a s k f o r a n d s h o w n h o w t o c o r r e c t t h e e r r o r.
11.2 Error Messages
O n e c a n d e t e r m i n e w h e t h e r a n e r r o r w a s f r o m I ^ T jhX o r a c t u a l l y f r o m T jhX b y e x a m i n i n g t h e e r r o r m e s s a g e ( s e e T a b l e 1 1.1 ). A m e s s a g e f r o m a Ι ί Τ β Χ e r r o r w i l l b e g i n w i t h t h e t e x t
! L a T e X E r r o r:
F o r e x a m p l e,
! L a T e X E r r o r: L o n e l y \i t e m — p e r h a p s a m i s s i n g l i s t e n v i r o n m e n t.
i s p r o d u c e d i f y o u p l a c e d a l i s t i t e m o u t s i d e o f i t s l i s t e n v i r o n m e n t, w h e r e a s a T g X e r r o r s i m p l y b e g i n s w i t h a ! f o l l o w e d b y t h e m e s s a g e; f o r e x a m p l e,
! E x t r a a l i g n m e n t t a b h a s b e e n c h a n g e d t o \c r.
o c c u r s i f y o u p u t t o o m a n y e n t r i e s i n a s i n g l e r o w o f a t a b u l a r o r a r r a y e n v i r o n m e n t. T h i s i n f o r m a t i o n c a n t h e n g u i d e y o u t o t h e a p p r o p r i a t e s e c t i o n t o l o o k a t s i n c e w e h a v e d i v i d e d e r r o r s a n d w a r n i n g s i n t o t h e i r I ^ T g X a n d T g X c o u n t e r p a r t s.
i i.2 E r r o r M e s s a g e s ■$· 379
T a b l e 11.1: lAT^X e r r o r m e s s a g e s a n d t h e i r p r o b a b l e c a u s e s.
IAT[?X E r r o r M e s s a g e
P r o b a b l e C a u s e
B a d \l i n e o r \v e c t o r a r g u m e n t. B a d m a t h e n v i r o n m e n t d e l i m i t e r.
\b e g i n {...} o n i n p u t l i n e ... e n d e d b y \e n d {...}.
C a n b e u s e d o n l y i n p r e a m b l e.
C a n n o t d e t e r m i n e s i z e o f g r a p h i c ... ( n o B o u n d i n g B o x ). Command ... a l r e a d y d e f i n e d.
Command ... i n v a l i d i n m a t h m o d e.
C o u n t e r t o o l a r g e.
E n v i r o n m e n t ... u n d e f i n e d.
F i l e ... n o t f o u n d.
A n e g a t i v e l e n g t h o r i n v a l i d s l o p e w a s g i v e n a s a n a r g u m e n t t o a \l i n e o r \v e c t o r c o m m a n d. U n m a t c h e d d e l i m i t e r s f o r m a t h m o d e, o r b r a c e s; f o r e x a m p l e, \( o r \ [ u s e d i n m a t h m o d e, \] o r \) u s e d i n p a r a g r a p h o r L R m o d e.
A n V e n d c o m m a n d t h a t d o e s n o t m a t c h t h e a s s o c i ­
a t e d \b e g i n c o m m a n d.
A c o m m a n d w a s u s e d t h a t m u s t o n l y o c c u r i n t h e p r e a m b l e, \i n c l u d e o n l y, \m a k e i n d e x, \n o f i l e s, o r \u s e p a c k a g e s h o u l d g o b e f o r e \b e g i n { d o c u - m e n t },
l A T g X w a s u n a b l e t o f i n d t h e b o u n d i n g b o x c o m ­
m e n t i n a n i n c l u d e d g r a p h i c s f i l e.
O n e o f \n e w c o m m a n d, \n e w e n v i r o n m e n t, \n e w - l e n g t h, \n e w s a v e b o x, o r \n e w t h e o r e m w a s u s e d t o d e f i n e a n e x i s t i n g n a m e. T r y a d i f f e r e n t n a m e o r u s e \r e n e w s o m e t h i n g.
T h e n a m e d c o m m a n d c a n n o t b e u s e d i n m a t h m o d e.
A c o u n t e r f o r a n u m b e r e d e n t r y w a s s e t w i t h a n u m b e r t h a t w a s t o o b i g, o r a n e n u m e r a t e d l i s t i s t o o l o n g.
A \b e g i n c o m m a n d o c c u r r e d f o r a n e n v i r o n m e n t t h a t d o e s n o t e x i s t.
T h e n a m e d f i l e w i t h e x t e n s i o n t e x, d o c u m e n t c l a s s w i t h e x t e n s i o n e l s, o r p a c k a g e w i t h e x t e n s i o n s t y d o e s n o t e x i s t.
A n a r r a y o r t a b u l a r e n v i r o n m e n t, o r t h e s e c o n d a r g u m e n t o f a \m u l t i c o l u m n c o m m a n d, c o n t a i n e d a n i l l e g a l c h a r a c t e r.
A \ i n c l u d e c o m m a n d w a s u s e d t o i n s e r t a f i l e t h a t a l s o c o n t a i n e d a \i n c l u d e c o m m a n d.
A n \i t e m o c c u r r e d o u t s i d e o f a l i s t e n v i r o n m e n t.
I ^ Te X f o u n d s o m e t h i n g t h a t c a u s e d i t t o s t a r t t y p e s e t t i n g b e f o r e a c t u a l l y e n c o u n t e r i n g t h e \b e - g i n { d o c u m e n t ] - c o m m a n d.
I l l e g a l c h a r a c t e r i n a r r a y a r g.
\i n c l u d e c a n n o t b e n e s t e d.
L o n e l y \i t e m — p e r h a p s a m i s s i n g l i s t e n v i r o n m e n t.
M i s s i n g \b e g i n { d o c u m e n t }.
M i s s i n g p - a r g i n a r r a y a r g.
A n a r r a y o r t a b u l a r e n v i r o n m e n t, o r t h e s e c o n d a r g u m e n t o f a \m u l t i c o l u m n c o m m a n d, c o n t a i n e d a p n o t f o l l o w e d b y a n e x p r e s s i o n i n b r a c e s.
380 -φ- i i T o E r r I s H u m a n
T a b l e 11.1: C o n t i n u e d.
I^Te X E r r o r M e s s a g e
P r o b a b l e C a u s e
M i s s i n g © - e x p i n a r r a y a r g.
Wo c o u n t e r ‘ *
d e f i n e d.
No \t i t l e g i v e n.
N o t i n o u t e r p a r mode.
O p t i o n c l a s h f o r p a c k a g e ...
\p u s h t a b s a n d \p o p t a b s d o n't m a t c h.
S o m e t h i n g ’ s w r o n g — p e r h a p s a m i s s i n g \i t e m.
T a b o v e r f l o w.
T h e r e ’ s n o l i n e h e r e t o e n d.
A n a r r a y o r t a b u l a r e n v i r o n m e n t, o r t h e s e c o n d a r g u m e n t o f a \m u l t i c o l u m n c o m m a n d, c o n t a i n e d a n ® n o t f o l l o w e d b y a n © - e x p r e s s i o n.
A \a d d t o c o u n t e r o r \s e t c o u n t e r c o m m a n d, o r a n o p t i o n a l a r g u m e n t t o a \n e w c o u n t e r o r \n e w t h e - o r e m, w a s r e q u e s t e d w i t h a c o u n t e r t h a t d o e s n o t e x i s t.
N o \t i t l e c o m m a n d a p p e a r e d b e f o r e t h e u s e o f \m a k e t i t l e.
A \m a r g i n p a r c o m m a n d, o r a f i g u r e o r t a b l e e n ­
v i r o n m e n t, o c c u r r e d i n s i d e a p a r b o x, a m i n i p a g e, o r i n m a t h m o d e, o r a f l o a t i n g o b j e c t o c c u r r e d w i t h i n a n o t h e r f l o a t i n g o b j e c t.
D i f f e r e n t o p t i o n s w e r e u s e d f o r t h e s a m e p a c k a g e, w h i c h w a s l o a d e d t w i c e ( p o s s i b l y b y a n o t h e r p a c k ­
a g e ).
E i t h e r a \e n d { t a b b i n g } c o m m a n d a p p e a r e d w i t h a n u n m a t c h e d \p u s h t a b s c o m m a n d ( s ), o r a \p o p - t a b s c o m m a n d h a d n o m a t c h i n g \p u s h t a b s. P o s s i b l e c a u s e s i n c l u d e a n o m i t t e d \i t e m f r o m a l i s t e n v i r o n m e n t, o r a n a r g u m e n t t o a t h e b i b l i o g r a p h y e n v i r o n m e n t i s m i s s i n g.
T h e m a x i m u m n u m b e r o f t a b s t o p s h a s b e e n e x ­
c e e d e d b y a \= c o m m a n d.
A \\ o r \n e w l i n e c o m m a n d o c c u r s i n c o r r e c t l y b e - t w e e n p a r a g r a p h s. T r y a \v s p a c e c o m m a n d i n - s t e a d.
A d o c u m e n t c l a s s o r p a c k a g e w a s u s e d t h a t i s n o t c o m p a t i b l e w i t h t h i s v e r s i o n o f Ι £ Γ ε Χ, o r y o u h a v e a L?Te X i n s t a l l a t i o n p r o b l e m.
T h i s i s u n l i k e l y t o b e a n a c t u a l i A T g X b u g. P r o b a b l y, a p r e v i o u s l y a n n o u n c e d e r r o r h a s c o n f u s e d Έ^Τ^Χ. Y o u h a v e t o o m a n y l i s t - m a k i n g e n v i r o n m e n t s n e s t e d w i t h i n e a c h o t h e r.
T h r e e & c o l u m n s e p a r a t o r s a r e u s e d i n a n e q n a r r a y e n v i r o n m e n t w i t h o u t a \\ c o m m a n d b e t w e e n t h e m.
T h i s f i l e n e e d s f o r m a t ... b u t t h i s i s ...
T h i s may b e a L a T e X b u g.
T o o d e e p l y n e s t e d.
T o o m an y c o l u m n s i n e q n a r r a y e n v i r o n m e n t.
T o o m a n y f i g u r e s a n d t a b l e s h a v e b e e n s a v e d b y IATgX, o r o n e o f y o u r p a g e s h a s t o o m a n y \r a a r g i n - p a r c o m m a n d s o n i t.
T o o m an y u n p r o c e s s e d f l o a t s.
i i.2 E r r o r M e s s a g e s ■$· 381
T a b l e i i.i: C o n t i n u e d.
1 5 T ^ X E r r o r M e s s a g e
P r o b a b l e C a u s e
U n d e f i n e d c o l o r * . . . ’ .
U n d e f i n e d c o l o r m o d e l ‘ ... ’
U n d e f i n e d t a b p o s i t i o n.
U n k n o w n g r a p h i c s e x t e n s i o n
U n k n o w n o p t i o n ... f o r ... \v e r b e n d e d b y e n d o f l i n e,
\v e r b i l l e g a l i n c o m m a n d a r g u m e n t.
\< i n m i d l i n e.
T h e n a m e d c o l o r w a s n o t d e f i n e d w i t h \d e f i n e c o l o r.
T h e c o l o r m o d e l r e q u e s t e d i n \d e f i n e c o l o r i s u n k n o w n.
A \= c o m m a n d h a s n o t b e e n u s e d t o d e f i n e t h e t a b p o s i t i o n s o u g h t b y o n e o f \<, \>, \+, o r \-
A n u n k n o w n f i l e e x t e n s i o n w a s f o u n d w h e n t h e \i n c l u d e g r a p h i c s c o m m a n d t r i e d t o d e ­
t e r m i n e t h e f i l e t y p e o f t h e g r a p h i c.
A n u n a v a i l a b l e o p t i o n w a s s p e c i f i e d i n a \d o c u m e n t c l a s s o r \u s e p a c k a g e c o m m a n d. T h e t e x t f o l l o w i n g a \v e r b c o m m a n d g o e s b e ­
y o n d t h e p r e s e n t l i n e. Y o u m a y h a v e o m i t t e d a n e n d c h a r a c t e r.
T h e a r g u m e n t t o a c o m m a n d c o n t a i n s a \v e r b c o m m a n d.
A t a b b i n g e n v i r o n m e n t c o n t a i n s a \< i n t h e m i d d l e o f a l i n e r a t h e r t h a n a t t h e b e g i n n i n g o f t h e l i n e.
A s w e m e n t i o n e d e a r l i e r, s o m e t i m e s a s i n g l e e r r o r c a n g e n e r a t e o t h e r s i n a k n o c k - o n e f f e c t. T h e m o s t c o m m o n e x a m p l e i s a n i n p u t f i l e w i t h a p r o b l e m a t i c l i s t e n v i r o n m e n t. I n o u r v e r s i o n, t h e r e a r e t h r e e i t e m s i n a n e n u m e r a t e d l i s t t h a t h a s a n e r r o r i n t h a t t h e e n v i r o n m e n t s t a r t s w i t h \b e g i n { n u m b e r i n g } i n s t e a d o f \b e g i n - C e n u m e r a t e }. I n a d d i t i o n, a s i m p l e e r r o r i s e m p l o y e d t o d e m o n s t r a t e t h e e r r o r r e c o v e r y f a c i l i t i e s T g X o f f e r s.
T h e f o l l o w i n g t e x t c a n b e t y p e d i n a s a c o m p l e t e e x a m p l e o f e r r o r p r o p a g a t i o n:
\d o c u m e n t c l a s s { a r t i c l e }
\b e g i n - C d o c u m e n t } -
$ $\s u n x ~ 2 + \c o s x ~ 2 = 1 $ $
C o m p u t e r l a n g u a g e s a r e c o n s i d e r e d t o b e \e m p h - C o b j e c t - o r i e n t e d } i f t h e y s u p p o r t t h e f o l l o w i n g p r o p e r t i e s:
\b e g i n { n u m b e r i n g }
\i t e m a b s t r a c t i o n
382 -φ- 11 T o E r r I s H u m a n
\i t e m e n c a p s u l a t i o n \i t e m i n h e r i t a n c e \i t e m p o l y m o r p h i s m \e n d { e n u m e r a t e }
\e n d { d o c u m e n t } -
R u n n i n g I ^ T ^ X o n t h i s i n p u t f i l e g e n e r a t e s t h e f i r s t e r r o r:
! U n d e f i n e d c o n t r o l s e q u e n c e.
1.3 $ $\s u n
x"2 + \c o s x"2 = 1 $ $
7
A t t h e p r o m p t, w e c a n t y p e t h e l e t t e r i a n d t h e n t h e c o r r e c t n a m e o f t h e c o m m a n d:
? i
i n s e r t
>\s i n
! L a T e X E r r o r: E n v i r o n m e n t n u m b e r i n g u n d e f i n e d.
S e e t h e L a T e X m a n u a l o r L a T e X C o m p a n i o n f o r e x p l a n a t i o n.
T y p e H < r e t u r n > f o r i m m e d i a t e h e l p.
1.7 \b e g i n { n u m b e r i n g ) - 7
U n f o r t u n a t e l y, i t i s n o t n o w p o s s i b l e t o d o t h e s a m e a n d t o r e p l a c e t h e e r r o n e o u s p i e c e o f c o d e, a s i t c o n s i s t s o f m o r e t h a n o n e t o k e n. S o, a l l w e c a n d o i s t o p r e s s r e t u r n a n d g e t a s u c c e s s i o n o f e r r o r m e s s a g e s. T h u s, w e g e t t h e s e t h r e e \l o n e l y \i t e m m e s s a g e s c a u s e d b y o u r f a i l u r e t o c a l l u p a n e n u m e r a t e e n v i r o n m e n t s o t h a t I ^ T ^ X f i n d s t h e i t e m s o u t s i d e o f a l i s t e n v i r o n m e n t:
! L a T e X E r r o r: L o n e l y \i t e m — p e r h a p s a m i s s i n g l i s t e n v i r o n m e n t.
S e e t h e L a T e X m a n u a l o r L a T e X C o m p a n i o n f o r e x p l a n a t i o n.
T y p e H < r e t u r n > f o r i m m e d i a t e h e l p.
1.6 \i t e m a
b s t r a c t i o n
7
1 L a T e X E r r o r: L o n e l y \i t e m — p e r h a p s a m i s s i n g l i s t e n v i r o n m e n t.
S e e t h e L a T e X m a n u a l o r L a T e X C o m p a n i o n f o r e x p l a n a t i o n.
T y p e H < r e t u r n > f o r i m m e d i a t e h e l p.
i i.2 E r r o r M e s s a g e s ■$· 383
1.7 \i t e m e
n c a p s u l a t i o n
7
! L a T e X E r r o r: L o n e l y \i t e m — p e r h a p s a m i s s i n g l i s t e n v i r o n m e n t.
S e e t h e L a T e X m a n u a l o r L a T e X C o m p a n i o n f o r e x p l a n a t i o n.
T y p e H < r e t u r n > f o r i m m e d i a t e h e l p.
1.8 \i t e m i
n h e r i t a n c e
7
! L a T e X E r r o r: L o n e l y \i t e m — p e r h a p s a m i s s i n g l i s t e n v i r o n m e n t.
S e e t h e L a T e X m a n u a l o r L a T e X C o m p a n i o n f o r e x p l a n a t i o n.
T y p e H < r e t u r n > f o r i m m e d i a t e h e l p.
1.9 \i t e m p
o l y m o r p h i s m
7
T h e y a r e f o l l o w e d b y a f i n a l e r r o r m e s s a g e
! L a T e X E r r o r: \b e g i n { d o c u m e n t } e n d e d b y \e n d { e n u m e r a t e }.
S e e t h e L a T e X m a n u a l o r L a T e X C o m p a n i o n f o r e x p l a n a t i o n.
T y p e H < r e t u r n > f o r i m m e d i a t e h e l p.
1.1 0 \e n d - T e n u m e r a t e >
t h a t i n d i c a t e s t h a t t h e p r o g r a m a t t e m p t e d t o t e r m i n a t e a n e n u m e r a t e e n v i r o n m e n t t h a t w a s n e v e r s t a r t e d u p. P r e s s i n g e n t e r o n e m o r e t i m e c a u s e s t h e p r o g r a m t o t e r m i n a t e. S o, w e h a v e s e e n t h a t a s i n g l e e r r o r i n o u r i n p u t f i l e c a n l e a d t o a c a s c a d e o f o t h e r e r r o r m e s s a g e s. I n s u c h c a s e s, o n e i s o f t e n b e t t e r o f f t y p i n g I\s t o p r a t h e r t h a n X f o l l o w e d b y t h e r e t u r n k e y s i n c e t h e f o r m e r w i l l i n c l u d e t h e f i n a l m a t e r i a l t h a t h a s b e e n p r o c e s s e d i n t h e o u t p u t.
384 "Φ· i i T o E r r I s H u m a n
11.2.2 Errors in Packages
M a n y c l a s s e s a n d p a c k a g e s a r e a v a i l a b l e t o e x t e n d t h e f a c i l i t i e s o f f e r e d b y I i T ^ K. U s u a l l y a d d i t i o n a l p a c k a g e s a n d c l a s s e s h a v e e r r o r a n d w a r n i n g m e s s a g e s t h a t c o n c e r n t h e i r o w n u s e a n d a r e d e s c r i b e d i n t h e d o c u m e n t a t i o n t h a t a c c o m p a n i e s t h e m. F o r e x a m p l e, a d d i n g t h e c o m m a n d
t o t h e p r e a m b l e o f o u r d o c u m e n t p r o d u c e s t h e f o l l o w i n g e r r o r m e s s a g e:
! P a c k a g e b a b e l E r r o r: Y o u h a v e n ’ t s p e c i f i e d a l a n g u a g e o p t i o n.
B y a d d i n g t h e o p t i o n g e r m a n t o t h e o p t i o n s l i s t o f t h e \u s e p a c k a g e { b a b e l } c o m ­
m a n d, w e a r e e n a b l e d t o t y p e s e t G e r m a n l a n g u a g e d o c u m e n t s ( i.e., \u s e p a c k a g e [ g e r ­
m a n , e n g l i s h ] { b a b e l } ).
O n e e r r o r t h a t c a n c a u s e c o n f u s i o n o r p a n i c w h e n f i r s t e n c o u n t e r e d i s t h e m e s s a g e
! T e X c a p a c i t y e x c e e d e d, s o r r y [...].
T h i s h a p p e n s w h e n Τ β Χ h a l t s i t s e x e c u t i o n b e c a u s e t h e i n t e r n a l s p a c e r e q u i r e d t o p r o c e s s y o u r d o c u m e n t w a s u s e d u p. T h i s u s u a l l y h a s n o t h i n g t o d o w i t h n o t h a v i n g s u f f i c i e n t c a p a c i t y f o r y o u r d o c u m e n t b u t i s m o r e l i k e l y t o b e a k n o c k - o n e f f e c t o f a n o t h e r t y p e o f e r r o r i n y o u r i n p u t f i l e. T h e f o l l o w i n g e x a m p l e a t t e m p t s t o d e f i n e t w o n e w c o m m a n d s, \e s m i l e a n d \e f r o w n, t h a t a r e u s e d a s s h o r t h a n d s t o e x p r e s s f e e l i n g s i n i n f o r m a l m e s s a g e s ( u s u a l l y e - m a i l s ). T a b l e 1 1.2 l i s t s T g X e r r o r m e s s a g e s a n d t h e i r c a u s e s.
\d o c u m e n t c l a s s { a r t i c l e } \n e w c o m m a n d {\e s m i l e } { a \e s m i l e } \n e w c o m m a n d {\e f r o w n } {\t e x t t t {;( } } \b e g i n { d o c u m e n t }
T o d a y i s m y b i r t h d a y \e s m i l e \\
H o w e v e r, a c a r e l e s s s l i p h a s r e s u l t e d i n \e s m i l e b e i n g d e f i n e d i n t e r m s o f i t s e l f r a t h e r t h a n t h e s t r i n g o f c h a r a c t e r s t h a t m a k e s u p t h e e - m a i l i c o n. A s a r e s u l t o f t h i s, t h e f o l l o w i n g m e s s a g e w a s g e n e r a t e d b y T g X:
!TeX c a p a c i t y e x c e e d e d,s o r r y [ m a i n m e m o r y s i z e = 2 0 0 0 0 0 1 ].
\e s m i l e - > a
\e s m i l e
1.5 T o d a y i s m y b i r t h d a y \e s m i l e I f y o u r e a l l y a b s o l u t e l y n e e d m o r e c a p a c i t y, y o u c a n a s k a w i z a r d t o e n l a r g e m e.
\u s e p a c k a g e { b a b e 1 }
11.2.3 Errors Found by TgX
n
\e n d { d o c u m e n t }
i i.2 E r r o r M e s s a g e s ■$· 385
T a b l e 11.2: T^X e r r o r m e s s a g e s a n d t h e i r p r o b a b l e c a u s e s.
Τ β Χ E r r o r M e s s a g e
P r o b a b l e C a u s e
! D o u b l e s u b s c r i p t.
! D o u b l e s u p e r s c r i p t.
! E x t r a a l i g n m e n t t a b h a s b e e n c h a n g e d t o \c r.
! E x t r a }, o r f o r g o t t e n $.
! I c a n ’ t f i n d f i l e ! I l l e g a l p a r a m e t e r n u m b e r i n d e f i n i t i o n o f ...
! I l l e g a l u n i t o f m e a s u r e ( p t i n s e r t e d ).
! M i s p l a c e d a l i g n m e n t t a b c h a r a c t e r &.
M i s s i n g c o n t r o l s e q u e n c e
T w o a d j a c e n t s u b s c r i p t s h a v e o c c u r r e d i n a m a t h e n v i r o n m e n t. T r y n e s t i n g t h e b r a c e s ( e.g., $ y _ { 2 _ { 4 } } $ g i v e s i/24 ).
T w o a d j a c e n t s u b s c r i p t s h a v e o c c u r r e d i n a m a t h e n v i r o n m e n t. T r y n e s t i n g t h e b r a c e s ( e.g., $ y ~ { 2 ~ { 4 } } $ g i v e s y 2 *).
T o o m a n y f t c o l u m n s e p a r a t o r s i n o n e r o w o f a n a r r a y o r t a b u l a r e n v i r o n m e n t. P r o b a b l y a f o r g o t ­
t e n \\ c o m m a n d.
U n m a t c h e d m a t h m o d e l d e l i m i t e r s o r b r a c e s p r o b ­
a b l y c a u s e d b y a m i s s i n g { \ [ \ ( o r $.
Y o u r n a m e d f i l e d o e s n o t e x i s t.
I n c o r r e c t u s e o f a # i n o n e o f t h e \n e w c o m - m a n d, \r e n e w c o m m a n d, \p r o v i d e c o m m a n d ( t h e p a c k ­
a g e w r i t e r's v e r i o n o f \n e w c o m m a n d ), \n e w e n v i r o n - m e n t, o r \r e n e w e n v i r o n m e n t. N e s t i n g t h e s e c o m ­
m a n d s a l s o c a u s e s t h i s.
P o s s i b l y t h e s a m e p r o b l e m a s w i t h t h e m e s s a g e: ! m i s s i n g n u m b e r, t r e a t e d a s z e r o, o r y o u f o r ­
g o t u n i t s o f a l e n g t h a r g u m e n t ( e.g., 9 i n s t e a d o f 9 p t ).
Y o u t y p e d t h e s p e c i a l c h a r a c t e r & i n a p a s s a g e o f t e x t r a t h e r t h a n a n a r r a y o r t a b u l a r e n v i r o n m e n t. T r y a \f t.
A f i r s t a r g u m e n t t h a t i s n o t a c o m m a n d n a m e w a s
g i v e n a s a n a r g u m e n t t o o n e o f t h e \n e w c o m m a n d, \n e w l e n g t h, \n e w s a v e b o x, o r \r e n e w c o m m a n d c o m ­
m a n d s.
1 ) T g X e x p e c t e d a n u m b e r o r l e n g t h a s t h e a r g u m e n t t o a c o m m a n d b u t d i d n o t g e t o n e. 2 ) A s q u a r e b r a c k e t i n s o m e t e x t w a s m i s t a k e n f o r t h e s t a r t o f a n o p t i o n a l a r g u m e n t. 3 ) \p r o t e c t w a s p l a c e d i n f r o n t o f a l e n g t h o r \v a l u e c o m m a n d.
A t t h i s p o i n t T g X i s p r o b a b l y c o n f u s e d, a n d t h e e r r o r l o c a t o r i n d i c a t e s a p l a c e t o o f a r b e y o n d t h e a c t u a l e r r o r.
A m a t h m o d e c o m m a n d o c c u r r e d w h e n T g X w a s
i n s e r t e d.
! M i s s i n g n u m b e r, t r e a t e d a s z e r o.
! M i s s i n g { i n s e r t e d o r ! M i s s i n g } i n s e r t e d
! M i s s i n g $ i n s e r t e d o r ! M i s s i n g
$ $ i n s e r t e d.
! W o t a l e t t e r.
n o t i n m a t h m o d e o r a b l a n k l i n e w h i l e i t w a s i n m a t h m o d e.
A n i n a p p r o p r i a t e a r g u m e n t t o a \h y p h e n a t i o n c o m m a n d w a s u s e d.
3B 6 -φ- i i T o E r r I s H u m a n
Table 11.2: Continued.
T g X E r r o r M e s s a g e P r o b a b l e C a u s e
! P a r a g r a p h e n d e d b e f o r e ... w a s c o m p l e t e.
! T e X c a p a c i t y e x c e e d e d, s o r r y
! T e x t l i n e c o n t a i n s a n i n v a l i d c h a r a c t e r.
! U n d e f i n e d c o n t r o l s e q u e n c e.
! U s e o f ... d o e s n ’ t m a t c h i t s d e f i n i t i o n.
! Y o u c a n ’ t u s e 'm a c r o p a r a m e t e r c h a r a c t e r #’ i n m o d e.
S e e i f y o u c a n h e l p o u r u s e r o u t b y r e w r i t i n g t h e d e f i n i t i o n o f \e s m i l e i n t e r m s o f a s u i t a b l e e - m a i l i c o n s u c h a s : - ), a n d t h e n t r y r u n n i n g T g X. Y o u s h o u l d t h e n f i n d t h a t T ^ X r u n s s m o o t h l y a n d p r o c e s s e s t h e i n p u t f i l e w i t h o u t a n y d i f f i c u l t y.
T h e p r e s e n t g e n e r a t i o n o f c o m p u t e r s h a s s u f f i c i e n t m e m o r y t o g i v e Τ β Χ t h e s p a c e t h a t i t n e e d s f o r m o s t d o c u m e n t s, b u t a g i v e n i n s t a l l a t i o n o f T ^ X o n l y h a s a f i x e d a m o u n t o f s p a c e s e t u p. F o r t h i s r e a s o n, t h e v e r s i o n i n s t a l l e d o n y o u r c o m p u t e r m a y n e e d t o b e r u n w i t h d i f f e r e n t s e t t i n g s, o r a b i g g e r v e r s i o n m a y n e e d t o b e o b t a i n e d. L a m p o r t ( i n [ 2 0 ] p a g e s 1 4 2 - 1 4 4 ) g i v e s m o r e d i s c u s s i o n o f t h e t y p e s o f s p a c e t h a t m a y b e u s e d u p a n d s o m e s o l u t i o n s t o g e t a r o u n d t h e p r o b l e m.
W h e n w r i t i n g m a t h e m a t i c s, e r r o r s o f t e n a r i s e f r o m t h e o m i s s i o n o f a c l o s i n g c o m ­
m a n d t o r e t u r n t o a t e x t e n v i r o n m e n t, s u c h a s $ o r a f o r g o t t e n c l o s i n g b r a c e >. C o n t i n ­
u a l l y p r e s s i n g t h e r e t u r n k e y w i l l u s u a l l y g e t T g X t o f i n i s h p r o c e s s i n g t h e f i l e, b u t a m o r e c o n v e n i e n t a l t e r n a t i v e s o m e t i m e s i s t o u s e t h e s c r o l l m o d e ( t y p e S a n d t h e r e t u r n
A c o m m a n d a r g u m e n t c o n t a i n e d a n i n a p p r o p r i a t e b l a n k l i n e. Y o u m a y h a v e l e f t o f f t h e r i g h t b r a c e t o f i n i s h a n a r g u m e n t.
A n e r r o r i n y o u r i n p u t f i l e i s t h e m o s t l i k e l y c a u s e, r a t h e r t h a n T ^ X a c t u a l l y r u n n i n g o u t o f s p a c e. P r o b ­
a b l y, TjnX i s l o o p i n g e n d l e s s l y b e c a u s e o f a w r o n g c o m m a n d.
Y o u r i n p u t f i l e c o n t a i n s a n o n p r i n t i n g c h a r a c t e r. U s e a n e d i t o r t h a t j u s t p r o d u c e s A S C I I c h a r a c t e r s, o r c h o o s e "s a v e a s A S C I I" f r o m y o u r w o r d p r o c e s ­
s o r.
Y o u m a y h a v e m i s s p e l l e d o r m i s p l a c e d a c o m m a n d n a m e. A l t e r n a t i v e l y, y o u h a v e o m i t t e d a \d o c u - m e n t c l a s s o r \u s e p a c k a g e c o m m a n d.
1 ) I f ... i s a c o m m a n d f o r lATjnX, t h e n y o u m a y h a v e u s e d t h e i n c o r r e c t s y n t a x f o r a n a r g u m e n t t o a p i c t u r e c o m m a n d. 2 ) I f ... i s a \@ a r r a y, t h e r e i s a n e r r o r i n t h e © - e x p r e s s i o n i n t h e a r g u m e n t o f a n a r r a y o r t a b u l a r e n v i r o n m e n t ( t r y \p r o t e c t w i t h a f r a g i l e c o m m a n d ). 3 ) A f r a g i l e c o m m a n d h a v i n g a n o p t i o n a l a r g u m e n t t h a t o c c u r s i n a m o v i n g a r ­
g u m e n t c a n a l s o c a u s e t h i s.
Y o u t y p e d t h e s p e c i a l c h a r a c t e r # i n a p a s s a g e o f n o r m a l t e x t. T r y u s i n g \#.
i i -3 W a r n i n g s 387
k e y a t t h e e r r o r p r o m p t ), w h i c h w i l l p r o c e e d a l l t h e w a y t h r o u g h t h e f i l e a n d a l l o w s o n e t o l o o k a t t h e t y p e s e t r e s u l t i n t h e o u t p u t D V I f i l e t o s e e t h e n a t u r e o f t h e e r r o r.
11.3 Warnings
11.3.1 Warnings Generated by Ι£Γ|ηΧ
Y o u c a n t e l l w h e t h e r a w a r n i n g i s g e n e r a t e d b y I ^ T g X ( s e e T a b l e 1 1.3 ) s i n c e i t w i l l b e g i n w i t h t h e t e x t L a T e X W a r n i n g: . F o r e x a m p l e, i f w e r e f e r e n c e a n u n d e f i n e d l a b e l a s i n t h i s p a s s a g e
\d o c u m e n t c l a s s { a r t i c l e }
\b e g i n { d o c u m e n t }
T h e B r i t i s h p h i l o s o p h e r G i l b e r t R y l e i n t r o d u c e d t h e t e r m c<t h e G h o s t i n t h e M a c h i n e ’ ’ t o c h a r a c t e r i z e t h e C a r t e s i a n v i e w o f t h e m i n d. S e c t i o n
\r e f { v o l i t i o n } i n t r o d u c e s h i s v i e w o f m e n t a l p r o c e s s e s.
\s e c t i o n { T h e M y t h o f V o l i t i o n s, A c c o r d i n g t o R y l e ’ s ( 1 9 4 9 ) b o o k T h e C o n c e p t o f M i n d }
\e n d { d o c u m e n t }
t h e n t h e f o l l o w i n g I ^ T g X w a r n i n g i s g e n e r a t e d:
L a T e X W a r n i n g: R e f e r e n c e ‘ v o l i t i o n ’ o n p a g e 1 u n d e f i n e d o n i n p u t l i n e 5.
T l i i s c a n b e c o r r e c t e d b y a d d i n g t h e c o m m a n d \l a b e l { v o l i t i o n } i m m e d i a t e l y f o l ­
l o w i n g t h e c l o s i n g b r a c e o f t h e s e c t i o n i n g c o m m a n d. R u n n i n g I ^ T g X t w i c e o n t h e f i l e w i l l g e n e r a t e t h e c o r r e c t c r o s s - r e f e r e n c e a n d w i l l o m i t t h e w a r n i n g o n t h e s e c o n d r u n t h r o u g h. A n a d d i t i o n a l w a r n i n g i s s t i l l g e n e r a t e d o n t h e s c r e e n a n d w r i t t e n t o t h e l o g f i l e, n a m e l y
O v e r f u l l \h b o x ( 1 5.4 3 3 p t t o o w i d e ) i n p a r a g r a p h a t l i n e s 8 — 8 [ ]\0 T l/c m r/b x/n/1 4.4 T h e M y t h o f V o - l i - t i o n s, A c - c o r d - i n g t o R y l e ( 1 9 4 9 ) [ ]
W e c a n s e e t h a t t h i s i s a Τ β Χ w a r n i n g s i n c e i t h a s n o ? c h a r a c t e r p r e c e d i n g t h e m e s s a g e i n d i c a t i n g a n e r r o r a n d b e c a u s e i t i s n o t p r e c e d e d b y t h e w o r d s L a T e X W a r n i n g: . I t i s t e l l i n g u s t h a t Τ β Χ c o u l d n o t f i n d a g o o d p l a c e t o b r e a k t h e l i n e c o n t a i n i n g t h e s e c t i o n h e a d i n g. W e l e a v e i t a s a n e x e r c i s e f o r t h e r e a d e r t o a s s i s t T g X i n c o r r e c t l y b r e a k i n g t h e l i n e.
3B 8 -φ- i i T o E r r I s H u m a n
T a b l e 11.3: I£TeX w a r n i n g s a n d t h e i r p r o b a b l e c a u s e s.
I ^ T g X W a r n i n g M e s s a g e
P r o b a b l e C a u s e
C i t a t i o n ‘ . . .
’ o n p a g e ... u n d e f i n e d.
Command ... i n v a l i d i n m a t h m o d e.
F l o a t t o o l a r g e f o r p a g e b y ...
F o n t s h a p e ‘... >
i n s i z e ... n o t a v a i l a b l e
h f l o a t s p e c i f i e r c h a n g e d t o h t. o r !h f l o a t s p e c i f i e r c h a n g e d t o !h t.
L a b e l ‘ ’
m u l t i p l y d e f i n e d.
L a b e l ( s ) may h a v e c h a n g e d. R e r u n t o g e t c r o s s - r e f e r e n c e s r i g h t.
M a r g i n p a r on p a g e ... m o v e d.
No \a u t h o r g i v e n.
O p t i o n a l a r g u m e n t o f \t w o c o l u m n t o o t a l l o n p a g e ...
O v a l t o o s m a l l.
R e f e r e n c e ‘... ’
on p a g e ... u n d e f i n e d.
Some f o n t s h a p e s w e r e n o t a v a i l a b l e, d e f a u l t s s u b s t i t u t e d.
T h e r e w e r e m u l t i p l y - d e f i n e d l a b e l s.
T h e r e w e r e u n d e f i n e d r e f e r e n c e s o r c i t a t i o n s.
Y o u h a v e n o t d e f i n e d t h e k e y i n \c i t e c o m m a n d w i t h a \b i b i t e m c o m m a n d.
Y o u u s e d t h e n a m e d c o m m a n d i n m a t h m o d e w h e n i t i s n o t a l l o w e d t h e r e.
A t a b l e o r f i g u r e i s t o o l o n g b y t h e s t a t e d l e n g t h i n u n i t s o f p o i n t s. I t i s p r i n t e d o n a s e p a r a t e p a g e.
A f o n t w a s s p e c i f i e d t h a t i s u n a v a i l a b l e o n y o u r s y s t e m, a n d i t w a s r e p l a c e d b y t h e f o n t i n d i c a t e d o n t h e n e x t l i n e.
A t a b l e o r f i g u r e w i t h a n o p t i o n a l h o r ! h a r g u m e n t c o u l d n o t f i t o n t h e p r e s e n t p a g e a n d w a s p l a c e d o n t h e n e x t p a g e.
T h e s a m e a r g u m e n t s w e r e u s e d f o r t w o \b i b i t e m o r M a b e l c o m m a n d s. T h i s o c c u r r e d o n t h e p r e v i o u s r u n t h r o u g h I ^ T e X.
I n d i c a t e s t h a t t h e v a l u e s g i v e n b y \c i t e, \r e f, o r \p a g e r e f c o u l d b e w r o n g i f t h e c o r r e c t v a l u e s h a v e a l t e r e d s i n c e t h e l a s t r u n t h r o u g h 1?Te X.
A m a r g i n a l n o t e h a d t o b e p r i n t e d l o w e r t h a n t h e t e x t i t r e f e r s t o, s o a s n o t t o o v e r p r i n t a n e x i s t i n g m a r g i n a l n o t e.
A \a u t h o r c o m m a n d d i d n o t o c c u r b e f o r e \m a k e - t i t l e.
A b o x t o o b i g f o r t h e p a g e w a s s p e c i f i e d b y t h e o p t i o n a l a r g u m e n t o f a \t w o c o l u m n c o m m a n d.
A p o o r a p p r o x i m a t i o n t o t h e r e q u e s t e d o v a l o c - c u r r e d b e c a u s e t h e r e q u i r e d q u a r t e r c i r c l e s w e r e n o t a v a i l a b l e t h a t s m a l l.
A M a b e l c o m m a n d w a s n o t u s e d t o d e f i n e t h e a r g u m e n t o f a \r e f o r \p a g e r e f c o m m a n d.
A f o n t w a s s p e c i f i e d t h a t i s u n a v a i l a b l e o n y o u r s y s t e m a n d s u b s t i t u t e d w i t h a d e f a u l t a l t e r n a t i v e.
T w o d i f f e r e n t M a b e l c o m m a n d s w e r e u s e d i n t h e d e f i n i t i o n o f a l a b e l.
A n o n e x i s t e n t b i b l i o g r a p h y e n t r y o r M a b e l w a s r e f e r r e d t o b y a \c i t e o r \r e f c o m m a n d.
U n u s e d g l o b a l o p t i o n ( s ): [...].
Y o u h a v e r e q u e s t e d r e l e a s e ‘ ’
o f L a T e X, b u t o n l y r e l e a s e ‘... ’
i s a v a i l a b l e.
T h e \d o c u m e n t c l a s s c o m m a n d, o r p a c k a g e s t h a t w e r e l o a d e d, d i d n o t r e c o g n i z e t h e i n d i c a t e d o p ­
t i o n s.
Y o u r r e l e a s e o f I ^ T e X d o e s n o t w o r k w i t h a s p e c i f i e d d o c u m e n t c l a s s o r p a c k a g e. A l a t e r v e r s i o n o f L^T]h X w i l l b e r e q u i r e d t o w o r k w i t h t h a t.
i i -3 W a r n i n g s 389
W h e n u s i n g b a b e l, a c o m m o n e r r o r i s a m i s s i n g h y p h e n a t i o n p a c k a g e f o r a l a n g u a g e t h a t w e w i s h t o w r i t e i n. I f w e t y p e s e t t h e e x a m p l e
\d o c u m e n t c l a s s [ a 4 p a p e r, l l p t ] { a r t i c l e }
\u s e p a c k a g e [ s p a n i s h,e n g l i s h ] { b a b e l }
\b e g i n { d o c u m e n t }
A v e r s e f r o m t h e G u a n t a n a m e r a s o n g. L y r i c a d a p t i o n b y J u l i a n O r b o n, b a s e d o n a p o e m b y t h e C u b a n p o e t J o s\’ { e } M a r t V {\i }:
\b e g i n { v e r s e }
\s e l e c t l a n g u a g e { s p a n i s h }
Y o s o y u n h o m b r e s i n c e r o \\
D e d o n d e c r e c e l a p a l m a, \\
Y a n t e s d e m o r i r m e q u i e r o \\
E c h a r m i s v e r s o s d e l a l m a.
\e n d { v e r s e }
\e n d { d o c u m e n t }
t h e l o g f i l e i n f o r m s u s t h a t t h e r e i s a p o s s i b l e p r o b l e m w i t h t h e t y p e s e t o u t p u t a r i s i n g d u r i n g t h e u s e o f t h e a d d - o n p a c k a g e b a b e l:
P a c k a g e b a b e l W a r n i n g: N o h y p h e n a t i o n p a t t e r n s w e r e l o a d e d f o r ( b a b e l ) t h e l a n g u a g e ‘ S p a n i s h ’
( b a b e l ) I w i l l u s e t h e p a t t e r n s l o a d e d f o r
\l a n g u a g e = 0 i n s t e a d.
T h i s t e l l s u s t h a t i t c o u l d n o t f i n d h y p h e n a t i o n p a t t e r n s f o r S p a n i s h, s o i t w i l l u s e t h o s e f o r t h e d e f a u l t l a n g u a g e, w h i c h w i l l b e t h e f i r s t o n e e m b e d d e d i n t h e f o r m a t f i l e ( e.g., A m e r i c a n E n g l i s h ). I n o r d e r t o g e n e r a t e a f o r m a t f i l e, w e h a v e t o u s e i N i T g X ( o r i n i o m e g a, a n d s o o n ). T h i s p r o g r a m t r a n s f o r m s t h e f i l e l a t e x.l t x i n t o a f a s t l o a d a b l e b i n a r y f o r m a n d i n c l u d e s h y p h e n a t i o n p a t t e r n s f o r v a r i o u s l a n g u a g e s. S i n c e w e a r e t y p e s e t t i n g p o e t r y i n S p a n i s h w i t h l i n e s n a r r o w e r t h a n t h e w i d t h o f t h e p a g e, w e c a n c h o o s e t o i g n o r e t h e w a r n i n g s i n c e I ^ X d o e s n o t n e e d t o t r y a n d h y p h e n a t e t h e v e r s e. H o w e v e r, i f w e w e r e t y p e s e t t i n g a c o n t i n u o u s p i e c e o f S p a n i s h p r o s e, t h e n w e w o u l d l i k e t o l o a d t h e h y p h e n a t i o n p a t t e r n s f o r t h e S p a n i s h l a n g u a g e. T h i s i s d o n e b y l o c a t i n g t h e f i l e l a n g u a g e. d a t i n o u r Τ β Χ i n s t a l l a t i o n a n d a d d i n g t h e l i n e
s p a n i s h s p a n h y p h.t e x % S p a n i s h
t o t h e f i l e. F o l l o w i n g t h i s, a n e w L 5T gX f o r m a t f i l e m u s t b e g e n e r a t e d b y r u n n i n g i n i T ^ X o n t h e f i l e l a t e x.l t x o f o u r s y s t e m. T h i s w i l l p r o d u c e a f o r m a t f i l e f o r L5T^< t h a t w i l l a l l o w f o r l o a d i n g t h e S p a n i s h h y p h e n a t i o n p a t t e r n s w h e n t h e S p a n i s h l a n g u a g e i s s e l e c t e d u s i n g t h e B a b e l p a c k a g e. T h i s e x a m p l e i l l u s t r a t e s t h e d i f f e r e n c e b e t w e e n T g X o r L 5 T g X e r r o r s a n d w a r n i n g s. I n t h e c a s e o f a n e r r o r, t h e e x e c u t i o n o f T g X h a l t s a n d s o m e a c t i o n m u s t b e t a k e n b y t h e u s e r t o c o r r e c t t h e m i s t a k e, w h i l e a w a r n i n g h i g h l i g h t s a p o s s i b l e p r o b l e m w i t h t h e t y p e s e t o u t p u t b u t p r o g r a m e x e c u t i o n c o n t i n u e s a n d t h e
39° ^ 11 T ° E r r I s H u m a n
D V I f i l e i s p r o d u c e d. D e p e n d i n g o n t h e n a t u r e o f t h e w a r n i n g, t h i s m a y o r m a y n o t h a v e a n a c t u a l e f f e c t o n t h e t y p e s e t o u t p u t.
11.3.2 Warnings Generated by TgX
T a b l e 1 1.4 g i v e s t h e s u b s e t o f Τ β Χ w a r n i n g s h i g h l i g h t e d i n t h e T i T g X m a n u a l. T h e s e f o c u s o n p l a c e s w h e r e T ^ X h a d d i f f i c u l t l y i n b r e a k i n g a l i n e o r p a g e a n d c a n b e a i d e d i n t h e p r o c e s s b y t h e j u d i c i o u s u s e o f s o m e h i n t i n g c o m m a n d s f r o m t h e u s e r.
Table i i.4: T^X w a rnings and t heir probable c a u s e s.
T g X W a r n i n g M e s s a g e P r o b a b l e C a u s e
TjnX h a d d i f f i c u l t y f i n d i n g a g o o d p l a c e t o b r e a k t h e l i n e. Y o u m a y n e e d t o i n d i c a t e s u i t a b l e p l a c e s f o r t h e h y p h e n a t i o n o f a n u n u s u a l w o r d o r a d d a \l i n e b r e a k o r \n e w l i n e c o m m a n d.
T g X h a d d i f f i c u l t y f i n d i n g a g o o d p l a c e f o r a p a g e b r e a k a n d p u t t o o m u c h o n t h e p a g e. I t n e e d s s o m e a s s i s t a n c e f r o m y o u. T r y u s i n g a \p a g e b r e a k o r \e n l a r g e t h i s p a g e * c o m m a n d.
T w o s u c c e s s i v e \\ o r \n e w l i n e c o m m a n d s a d d e d v e r t i c a l s p a c e t o y o u r d o c u m e n t. A l t e r n a t i v e l y, a \s l o p p y d e c l a r a t i o n, a s l o p p y p a r e n v i r o n m e n t, o r a \l i n e b r e a k c o m m a n d m a y p r o d u c e t h i s w a r n ­
i n g.
T g X h a d d i f f i c u l t y f i n d i n g a g o o d p l a c e f o r a p a g e b r e a k a n d p u t t o o l i t t l e o n t h e p a g e. I t n e e d s s o m e a s s i s t a n c e f r o m y o u. T r y a d d i n g a \n o p a g e b r e a k c o m m a n d t o d e t e r T g X f r o m b r e a k i n g t h e p a g e t h e r e.
11.4 The Last Straw: Strategies for Dealing with Resistant
Errors
O c c a s i o n a l l y, t h e s i t u a t i o n m a y b e r e a c h e d w h e r e t h e T g X p r o g r a m c a n n o t b e s t o p p e d f o l l o w i n g a n e r r o r ( e.g., w h e n a s e r i o u s e r r o r p r o p a g a t i o n c a u s e s t h e t e x t p r o c e s s i n g t o c o n t i n u e i n d e f i n i t e l y ). I n t h i s c a s e, o n e m a y n e e d t o h a l t t h e p r o g r a m w i t h t h e o p e r a t i n g s y s t e m i n t e r r u p t, t h e n a t u r e o f w h i c h w i l l d e p e n d o n y o u r p a r t i c u l a r o p e r a t i n g s y s t e m, a l t h o u g h t y p i c a l l y s i m u l t a n e o u s l y p r e s s i n g t h e C t r l a n d c k e y s o r C t r l a n d B r e a k w i l l d o t h e t r i c k.
O v e r f u l l \h b o x ...
O v e r f u l l \v b o x ...
U n d e r f u l l \h b o x . . .
U n d e r f u l l \v b o x ...
i i.4 T h e L a s t S t r a w -φ- 391
W i t h o b s c u r e e r r o r s, a s t r a t e g y o f d i v i d e a n d c o n q u e r c a n b e h e l p f u l. B y i n s e r t i n g a \e n d { d o c u m e n t } c o m m a n d p a r t o f t h e w a y t h r o u g h, r u n n i n g L T g X, a n d e x a m i n i n g t h e o u t p u t, y o u c a n s e e i f t h e f i r s t p a r t o f t h e f i l e i s f r e e o f e r r o r s. I f i t i s, t h e n y o u c a n c u t a n d p a s t e t h e \e n d { d o c u m e n t } f u r t h e r d o w n, t y p e s e t t h e a l t e r e d d o c u m e n t, a n d s e e i f t h e e r r o r h a s o c c u r r e d i n t h e t e x t b e t w e e n w h e r e y o u l a s t e n d e d t h e i n p u t a n d t h e c u r r e n t l i n e w h e r e y o u h a v e e n d e d i t. O f c o u r s e, y o u w i l l n e e d t o m a k e s u r e t h a t a n y a c t i v e e n v i r o n m e n t s a r e a l s o e n d e d ( e.g., p l a c i n g t h e \e n d { d o c u m e n t } c o m m a n d a f t e r t h e e n d o f a q u o t a t i o n e n v i r o n m e n t ). T h i s s u c c e s s i v e m o v i n g o f t h e e n d i n g c o m m a n d d o w n t h r o u g h t h e d o c u m e n t, t o g e t h e r w i t h t h e j u d i c i o u s u s e o f a c o m m e n t c h a r a c t e r % t o t e m p o r a r i l y o m i t s u s p e c t l i n e s, c a n h e l p a g r e a t d e a l i n t r a c i n g a n e r r o n e o u s p i e c e o f L T ^ X i n p u t. S o m e Ι ^ Τ β Χ - o r i e n t e d e d i t i n g p r o g r a m s ( s u c h a s e m a c s ) a l l o w y o u t o s e l e c t p i e c e s o f i n p u t t e x t a n d t y p e s e t t h e p a s s a g e s a u t o m a t i c a l l y w i t h o u t h a v i n g t o c r e a t e a c o m p l e t e T g X d o c u m e n t, w h i c h i s v e r y c o n v e n i e n t f o r t r a c i n g e r r o r s ( s e e A p p e n d i x B ).
1 2 ---------------------
Installing N ew Type
M o s t c o m m o n f o n t f o r m a t s ( P o s t S c r i p t T y p e 1, T y p e 3, e t c., a n d T r u e T y p e f o n t s ) c a n b e u s e d w i t h a n y o f t h e I ^ T ^ X f o r m s ( i n c l u d i n g s t a n d a r d I ^ T ^ X, A, a n d p d f l A T g X ), a n d, o f c o u r s e, Ι ί Γ β Χ u s e s b y d e f a u l t f o n t s c r e a t e d w i t h M E T R F O N T. N e w e r f o r m a t s, s u c h a s t h e O p e n T y p e f o r m a t, c a n a l s o b e u s e d s i n c e i t i s p o s s i b l e t o c o n v e r t t h e m t o T y p e 1 f o n t s. D i r e c t s u p p o r t o f O p e n T y p e m a y b e a d d e d i n t h e f u t u r e.
T h e s t a n d a r d w a y t o i n s t a l l P o s t S c r i p t T y p e 1 f o n t s i s b y u s i n g t h e f o n t i n s t p r o g r a m b y A l a n J e f f r e y a n d R o w l a n d M c D o n n e l l. T h i s p r o g r a m i s a c t u a l l y a T ^ X a p p l i c a t i o n! A l t h o u g h f o n t i n s t i s q u i t e a p o w e r f u l p r o g r a m, i t c a n n o t h a n d l e a l l p o s s i b l e c a s e s, s o w e w i l l f u l l y d e s c r i b e t h e i n s t a l l a t i o n p r o c e d u r e o f v i r t u a l l y a n y P o s t S c r i p t T y p e 1 f o n t. I t i s v e r y i m p o r t a n t f o r t h e u s e r t o u n d e r s t a n d t h e i n s t a l l a t i o n o f T y p e 1 f o n t s, a s i t i s p o s s i b l e t o c o n v e r t a l l c o m m o n f o n t f o r m a t s t o T y p e 1. W e w i l l, h o w e v e r, s t a r t w i t h t h e d e f a u l t M E T R F O N T f o n t s.
12.1 Installing METRFONT Fonts
M o s t o f t h e t i m e, M E T R F O N T f o n t s c o m e f r o m "T ^ X - a w a r e" p e o p l e o r t h e C T A N a r c h i v e s, a n d t h u s t h e y c o m e w i t h i n s t a l l a t i o n i n s t r u c t i o n s. I n a n y c a s e t h e i n s t a l ­
l a t i o n o f M E T R F O N T f o n t s i s s i m p l e. I f t h e f o n t s c o m e w i t h s u p p o r t f i l e s, t h e n y o u j u s t p l a c e t h e M E T R F O N T s o u r c e s i n t h e T ^ X t r e e s ( u s u a l l y i n t e x m f/f o n t s/s o u r c e/) a n d t h e a c c o m p a n y i n g s u p p o r t f i l e s ( p a c k a g e s a n d f o n t d e f i n i t i o n s ) a n y w h e r e i n t e x m f/t e x/g e n e r i c/ o r t e x m f/t e x/l a t e x/. Y o u d o n o t r e a l l y n e e d t h e T F M f i l e s, a s t h e s e w i l l b e g e n e r a t e d a u t o m a t i c a l l y f r o m t h e M E T R F O N T s o u r c e s w h e n y o u u s e t h e f o n t s. H o w e v e r, i f T g X f o n t m e t r i c s a r e p r o v i d e d a n d y o u w a n t t o s a v e c o m p u t i n g t i m e, y o u c a n p u t t h e m a n y w h e r e i n t e x m f/f o n t s/t f m/.
N o w, y o u m u s t r e f r e s h t h e “ f i l e n a m e d a t a b a s e." U n f o r t u n a t e l y, t h e r e i s n o s i n g l e n a m e f o r t h i s o p e r a t i o n. I t s n a m e d e p e n d s c h i e f l y o n t h e T ^ X i m p l e m e n t a t i o n i n u s e, s o o n a U n i x s y s t e m, t h e s y s t e m a d m i n i s t r a t o r c a n p e r f o r m t h e o p e r a t i o n a b o v e b y i s s u i n g
$ m k t e x l s r o r $ t e x h a s h
3 9 4 ^ 12 I n s t a l l i n g N e w T y p e
O n W i n d o w s i n s t a l l a t i o n s, t h i s o p e r a t i o n i s o f t e n l i n k e d s o m e w h e r e i n t h e s t a r t m e n u.
I f t h e f o n t s a r e n o t a c c o m p a n i e d b y s u p p o r t i n g p a c k a g e f i l e s, t h e n y o u c a n s i m p l y u s e t h e m a s d e s c r i b e d i n S e c t i o n 3.4 u s i n g t h e \f o n t c o m m a n d, a n d, o f c o u r s e, y o u m a y c r e a t e y o u r o w n p a c k a g e a n d f o n t d e f i n i t i o n f i l e s. B u t, w e w i l l d i s c u s s t h e s e t h i n g s l a t e r, i n S e c t i o n 1 2.4.
12.2 Installing Type 1 Text Fonts in BT^X
Type 1 fonts com e in tw o flavors ^ binary and A S C II. The binary form is actually an encrypted and com pressed version of the A S C II one. The usual filenam e extensions are .p f a for the A S C II form and .p fb for the binary form. Both form s can be used w ith T^TgX b y follow ing the same procedure. Type 1 fonts are usually accom panied b y the so-called "A d o b e Font M etric" file w h ich usually has the . a f m filenam e extension. W e w ill see the im portance of the A F M file in the next paragraphs.
Suppose that w e have a Type 1 font nam ed fo n t.p fb (the same applies to .p fa fonts). The typesetting engine needs only to know the dim ensions of the glyphs, so it is not really concerned about the actual shape of the glyphs. A fter all, for TgX, each letter is just a box, as w e have already explained, and as the reader m ay recall, a box has a height, a w idth, and possibly a depth. H ow ever, w e m ust stress that there is a fourth param eter that w e intentionally did not present until now. It is called italic correction
and is the am ount of additional w hite space to be added after the character to avoid the collision of the slanted character w ith the next one (com pare 'leaf
b' w ith 'leaf
b'). O f course, you w ill need the file fo n t .p fb (i.e., the glyphs them selves) w hen you w ant to print or p review you r docum ent. Rem em ber: TgX typesets and it does not
print! So, w e do need the font m etrics to m ake available for use w ith I^TgX. The actual glyphs w ill be used b y the d river program.
Usually, each Type 1 font is accom panied b y its font m etrics file, but just in case w e have a font but not the font metrics, there is a sim ple procedure by m eans of w h ich one can get the font m etrics. This procedure is described in the next subsection and can be safely skipped on a first reading.
12.2.1 Extracting Metric Information
The easiest w a y to get the f o n t. a f m file is b y opening f o n t. p fb in a font editor. There are several font editors, depending on the platform w e w o rk w ith. For U n ix systems, one can use the pfa edit font editor b y George W illiam s available from h ttp://p fa ed i t
. so u rce f o rg e. net. For other platform s, there are up to n o w only com m ercial products.
If you have such a program, open the fo n t.p fb file and use the extract utilities provided in its m enus. If you do not have such a program, another w ay to do the job is b y using Ghostscript. Since w e use Ghostscript, the font m ust already be kn ow n to the program w ith a proper declaration in the Fontmap file of you r Ghostscript installation
12.2 I n s t a l l i n g T y p e i T e x t F o n t s i n E l g X -φ- 395
( o r t h e F o n t m a p.G S f i l e i n n e w e r r e l e a s e s ). O f c o u r s e, w e c a n c o p y t h i s f i l e i n t o o u r c u r r e n t w o r k i n g d i r e c t o r y a n d m a k e t h e c h a n g e s t e m p o r a l. H e r e i s t h e r e c i p e t o g e t t h e A d o b e f o n t m e t r i c:
1. F i n d o u t t h e i n t e r n a l n a m e o f t h e f o n t a t h a n d f o n t. p f b, c o n v e r t t h e . p f b f i l e t o t h e A S C I I f o r m a t b y i s s u i n g p f b 2 p f a f o n t .p f b. T h i s c r e a t e s f o n t .p f a, w h i c h w h e n o p e n e d i n a n y t e x t e d i t o r a l l o w s u s t o r e a d t h e f o n t's n a m e b y l o o k i n g a t t h e l i n e t h a t s t a r t s w i t h /F o n t N a m e. I f t h e n a m e i s, f o r e x a m p l e, T i m e s - N e w R o m a n, t h e n t h i s l i n e w i l l l o o k l i k e t h i s: /F o n t N a m e /T i m e s - N e w R o m a n.
2. M o d i f y t h e F o n t m a p ( o r F o n t m a p. G S ) f i l e b y a d d i n g t o i t a l i n e l i k e
/T i m e s - N e w R o m a n (/p a t h/t o/f o n t.p f b );
w h e r e /p a t h/t o/ i s t h e l o c a t i o n o f f o n t .p f b i n o u r s y s t e m.
3. G e t t h e a f m f i l e w i t h t h e c o m m a n d
$ g e t a f m f o n t.p f b | g s n d - > f o n t.a f m
( t h e c o m m a n d a b o v e i s w r i t t e n f o r t h e U n i x e n v i r o n m e n t ).
N o w, w e h a v e t o p r e p a r e m e t r i c f i l e s t h a t T g X c a n u n d e r s t a n d s i n c e i t c a n n o t u n d e r ­
s t a n d A F M f i l e s. Τ β Χ c a n d e a l o n l y w i t h T g X f o n t m e t r i c s. H e r e, w e h a v e o n e s e r i o u s r e s t r i c t i o n: e a c h T F M f i l e c a n n o t c o n t a i n m e t r i c d a t a f o r m o r e t h a n 2 5 6 g l y p h s. T h i s i s t h e m o s t s e r i o u s r e s t r i c t i o n t h a t Ω r e m o v e s, a n d i t i s a l s o t h e r e a s o n w h y w h e n s w i t c h i n g l a n g u a g e s, f o r e x a m p l e f r o m E n g l i s h t o G r e e k, w e h a v e t o s w i t c h f o n t s a n d, c o n s e ­
q u e n t l y, w e ( a r t i f i c i a l l y!) n e e d t o h a v e c o m m a n d s s u c h a s \t e x t l a t i n, a s d e s c r i b e d i n C h a p t e r 1 0.
B u t a n A F M f i l e m a y c o n t a i n m e t r i c i n f o r m a t i o n f o r m a n y g l y p h s. T h u s, w e h a v e t o c r e a t e o u r T F M b y s e l e c t i n g 2 5 6 g l y p h s f r o m t h e m a n y g l y p h m e t r i c s i n t h e A F M f i l e. T h i s i s d o n e b y w h a t w e c a l l a n encoding vector.
A c t u a l l y, a n e n c o d i n g v e c t o r i s s o m e t h i n g m o r e. I t l i s t s i n a s e q u e n c e t h e n a m e s o f t h e g l y p h s f o r w h i c h w e w a n t t o g e t i n f o r m a t i o n, a n d t h e o r d e r is
i m p o r t a n t, a s T g X r e a l l y i d e n t i f i e s e a c h g l y p h b y i t s p o s i t i o n i n t h i s r o w o f 2 5 6 g l y p h s.
12.2.2 Encoding Vectors
U s i n g C o m p u t e r S c i e n c e n o m e n c l a t u r e, w e c a n s a y t h a t a n e n c o d i n g v e c t o r i s j u s t a n a r r a y o f g l y p h n a m e s t h a t d e s c r i b e s t h e a r r a n g e m e n t o f g l y p h s i n a f o n t. E n c o d i n g v e c t o r s a r e u s e d t o r e a r r a n g e t h e p o s i t i o n s o f t h e v a r i o u s g l y p h s i n a f o n t. N a t u r a l l y, i n t h i s s e c t i o n w e w i l l d e a l o n l y w i t h e n c o d i n g v e c t o r s t h a t c a n b e a p p l i e d t o P o s t S c r i p t f o n t s. T h e d e f i n i t i o n o f a n e n c o d i n g v e c t o r c o n s i s t s o f i t s n a m e, a s e q u e n c e o f g l y p h n a m e s e n c l o s e d i n b r a c k e t s, a n d t h e k e y w o r d d e f. T h e e n c o d i n g n a m e a n d t h e g l y p h n a m e s m u s t b e p r e f i x e d w i t h a s l a s h (/), a s e a c h e n c o d i n g v e c t o r i s a v a l i d P o s t S c r i p t d a t a s t r u c t u r e a n d a s s u c h i t m u s t f o l l o w t h e c o n v e n t i o n s o f t h e P o s t S c r i p t l a n g u a g e. H e r e i s a n e x a m p l e d e f i n i t i o n:
/g r e e k [ /a l p h a /b e t a /g a m m a /d e l t a...] d e f
396 ^ 12 I n s t a l l i n g N e w T y p e
O b v i o u s l y, w e m u s t k n o w t h e n a m e s o f t h e g l y p h s o f a n e x i s t i n g f o n t i n o r d e r t o a p p l y a n e n c o d i n g v e c t o r t o t h i s f o n t. U s u a l l y, L a t i n f o n t s u s e s t a n d a r d n a m e s f o r e a c h g l y p h, b u t w e c a n n o t r e l y o n t h i s a s s u m p t i o n, s o i t i s b e s t t o c h e c k t h e n a m e s o f t h e g l y p h s o f t h e f o n t t h a t w e w a n t t o r e e n c o d e. T h i s c a n b e d o n e b y i n s p e c t i n g t h e P o s t S c r i p t f o n t w i t h a f o n t e d i t o r o r a f o n t v i e w e r s u c h a s g f o n t v i e w. T h i s f o n t v i e w e r i s p a r t o f t h e G n o m e d e s k t o p e n v i r o n m e n t ( h t t p: //w w w. g n o m e. o r g ). N o w, t h e p r o b l e m t h a t w e h a v e t o f a c e i s t o d e c i d e h o w t o o r d e r t h e s e g l y p h s i n o u r e n c o d i n g v e c t o r. T h e c h o i c e s t h a t w e w i l l h a v e t o m a k e d e p e n d h e a v i l y o n h o w w e a r e g o i n g t o u s e a p a r t i c u l a r f o n t. T h u s, a f o n t w i t h G r e e k l e t t e r s c a n b e u s e d a s a m a t h e m a t i c a l f o n t o r a s a f o n t t h a t w i l l b e u s e d t o t y p e s e t o r d i n a r y G r e e k t e x t. O n c e s u c h i s s u e s h a v e b e e n d e c i d e d, w e d e f i n e t h e e n c o d i n g v e c t o r. F o r e x a m p l e, i f o n e i s g o i n g t o u s e a G r e e k f o n t t o t y p e s e t G r e e k t e x t, t h e n t h i s f o n t m u s t f o l l o w t h e c o n v e n t i o n s o f t h e f o n t s d e s i g n e d b y C l a u d i o B e c c a r i. A l t h o u g h t h i s p a r t i c u l a r g l y p h a r r a n g e m e n t i s n o t u n i v e r s a l l y a c c e p t e d, i t c a n b e s a f e l y u s e d t o r e e n c o d e f o n t s. T h e t a s k o f d e f i n i n g a n o f f i c i a l e n c o d i n g f o r G r e e k f o n t s i s a n o n g o i n g p r o j e c t. S i n c e t h e r e i s n o o f f i c i a l d e f i n i t i o n, w e h a v e t o f i n d t h e o r d e r o f t h e g l y p h s u s i n g t h e d e f a u l t f o n t s b y u s i n g t h e n f s s f o n t. t e x i n p u t f i l e. W e r u n L T g X o n t h i s f i l e a n d f o l l o w t h e i n s t r u c t i o n s:
$ l a t e x n f s s f o n t
* N F S S f o n t t e s t p r o g r a m v e r s i o n < v 2.0 e >
*
* F o l l o w t h e i n s t r u c t i o n s
N a m e o f t h e f o n t t o t e s t = grmnlOOO
No w t y p e a t e s t c o m m a n d (\h e l p f o r h e l p ):
*\help
\i n i t s w i t c h e s t o a n o t h e r f o n t;
\s t o p o r \b y e f i n i s h e s t h e r u n;
\t a b l e p r i n t s t h e f o n t l a y o u t i n t a b u l a r f o r m a t;
\t e x t p r i n t s a s a m p l e t e x t, a s s u m i n g T e X t e x t f o n t c o n v e n t i o n s; \s a m p l e c o m b i n e s \t a b l e a n d \t e x t;
\m i x t u r e m i x e s a b a c k g r o u n d c h a r a c t e r w i t h a s e r i e s o f o t h e r s; \a l t e r n a t i o n i n t e r l e a v e s a b a c k g r o u n d c h a r a c t e r w i t h a s e r i e s; \a l p h a b e t p r i n t s a l l l o w e r c a s e l e t t e r s w i t h i n a g i v e n b a c k g r o u n d; \A L P H A B E T p r i n t s a l l u p p e r c a s e l e t t e r s w i t h i n a g i v e n b a c k g r o u n d; \s e r i e s p r i n t s a s e r i e s o f l e t t e r s w i t h i n a g i v e n b a c k g r o u n d;
\l o w e r s p r i n t s a c o m p r e h e n s i v e t e s t o f l o w e r c a s e;
\u p p e r s p r i n t s a c o m p r e h e n s i v e t e s t o f u p p e r c a s e;
\d i g i t s p r i n t s a c o m p r e h e n s i v e t e s t o f n u m e r a l s;
\m a t h p r i n t s a c o m p r e h e n s i v e t e s t o f T e X m a t h i t a l i c;
12.2 I n s t a l l i n g T y p e i T e x t F o n t s i n E l g X -φ- 397
\n a m e s p r i n t s a t e x t t h a t m i x e s u p p e r a n d l o w e r c a s e;
\p u n c t p r i n t s a p u n c t u a t i o n t e s t;
\b i g t e s t c o m b i n e s m a n y o f t h e a b o v e r o u t i n e s;
\h e l p r e p e a t s t h i s m e s s a g e;
a n d y o u c a n u s e o r d i n a r y T e X c o m m a n d s ( e.g., t o \i n p u t a f i l e )
*\table
*\bye
[ 1 ]
O u t p u t w r i t t e n o n n f s s f o n t.d v i ( 1 p a g e, 1 0 7 0 4 b y t e s ).
T r a n s c r i p t w r i t t e n o n n f s s f o n t.l o g.
N o w, w e c a n c r e a t e t h e e n c o d i n g v e c t o r a n d s t o r e i t i n a f i l e w i t h a r e a s o n a b l e n a m e. W e f i r s t p r i n t t h e o u t p u t o f t h e T^T ^X r u n a b o v e a n d u s e i t t o d e f i n e t h e e n c o d i n g v e c t o r. O f c o u r s e, t h i s t a s k a s s u m e s t h a t w e a r e f a m i l i a r w i t h t h e g l y p h s a n d t h e i r n a m e s.
T h e f i l e w h e r e w e s t o r e a n e n c o d i n g v e c t o r i s a l s o t h e r i g h t p l a c e f o r d e f i n i n g l i g a t u r e s b e t w e e n g l y p h s. L i g a t u r e s a r e d e f i n e d a f t e r t h e d e f i n i t i o n o f t h e e n c o d i n g v e c t o r. E a c h l i n e d e f i n i n g a l i g a t u r e i s l i k e t h e f o l l o w i n g o n e
% L I G K E R N q u e s t i o n d o w n q u e s t i o n d o w n =: g u i l l e m o t r i g h t ;
I t s t a r t s w i t h % L I G K E R M a n d t h e a c t u a l d e f i n i t i o n o f t h e l i g a t u r e. T h e l i g a t u r e d e f i n i t i o n m u s t b e t e r m i n a t e d w i t h a s e m i c o l o n. N o t e t h a t w e c a n h a v e m o r e t h a n o n e l i g a t u r e d e f i n i t i o n a s i n t h e f o l l o w i n g e x a m p l e:
% L I G K E R M h y p h e n h y p h e n =: e n d a s h ; e n d a s h h y p h e n =: e m d a s h ;
O f c o u r s e, a s i s e v i d e n t, t h e t w o d e f i n i t i o n s a r e r e l a t e d.
W e n o w e x p l a i n h o w t o s e t u p l i g a t u r e r u l e s. A s s u m e t h a t w e w a n t t w o g l y p h s t o c o m b i n e i n t o a n e w o n e. S u c h a c a s e i s t h e f i l i g a t u r e, w h e r e t h e l e t t e r f f o l l o w e d b y a n i b e c o m e s f i. T h e f i l i g a t u r e i s s p e c i f i e d a s f o l l o w s:
%
L I G K E R N f i =: f i ;
N o t e t h a t s p a c e s a r e i m p o r t a n t i n t h e a b o v e. T o a d d t h e f f a n d f f i l i g a t u r e s, w e m a y w r i t e:
% L I G K E R N f i =: f i ; f f =: f f ; f f i =: f f i ;
T h i s i s a l s o h o w w e h a v e a c c e s s t o a c c e n t e d l e t t e r s i n l a n g u a g e s s u c h a s G r e e k, H e b r e w, a n d o t h e r s. F o r e x a m p l e, w e u s e
% L I G K E R N t o n o s a l p h a =: a l p h a t o n o s ;
t o s p e c i f y t h a t t h e a c u t e ’ f o l l o w e d b y a
s h o u l d b e c o m e a ά.
A n o t h e r t y p e o f l i g a t u r e i s w h e n one
o f t h e l e t t e r s i s s u b s t i t u t e d b y s o m e t h i n g e l s e. F o r e x a m p l e, i n G r e e k, a s i g m a ( σ ) a p p e a r i n g a t t h e e n d o f a w o r d m u s t c h a n g e t o a f i n a l s i g m a ( ς ). T h u s, i f a s i g m a i s f o l l o w e d b y, s a y, a n e x c l a m a t i o n m a r k, t h e n t h e
398 ^ 12 I n s t a l l i n g N e w T y p e
s i g m a m u s t b e c o m e a f i n a l s i g m a ( w h i c h i s u s u a l l y c a l l e d i n s i d e a f o n t s i g m a l ) a n d t h e e x c l a m a t i o n m a r k s h o u l d r e m a i n i n i t s p o s i t i o n. T h i s s i m p l e r u l e c a n b e e x p r e s s e d a s f o l l o w s:
% L I G K E R N s i g m a e x c l a m =:| s i g m a l ;
T h e s y m b o l = : I i s u s e d t o s a y t h a t if sigma is followed by an exclamation mark replace
the sigma with sigmal but leave the exclamation mark at its position
( t h i s i s w h a t t h e I c h a r a c t e r s t a n d s f o r ). I f t h e f i r s t c h a r a c t e r i s t o r e m a i n i n t a c t b u t t h e s e c o n d c h a r a c t e r m u s t c h a n g e, t h e n t h e =: I s y m b o l s h o u l d b e r e p l a c e d b y t h e I =: s y m b o l. I f t h e l i g a t u r e m e c h a n i s m s h o u l d s k i p o n e o r t w o c h a r a c t e r s b e f o r e r e s u m i n g t h e s e a r c h o f l i g a t u r e s, t h e n w e u s e =: > a n d =:» o r =: I >, =: I », I =: >, a n d I =:». U n f o r t u n a t e l y, i t i s s t i l l n o t p o s s i b l e t o r e s c a n t h e p r e v i o u s c h a r a c t e r s f o r l i g a t u r e s. T h u s, s y m b o l s s u c h a s <=: a r e n o t a v a i l a b l e. T h i s i s a m i s s i n g f e a t u r e t h a t w o u l d b e v e r y u s e f u l f o r c o m p l e x t y p e f a c e s.
A n i n t e r e s t i n g t h i n g i s h o w w e c a n i n c o r p o r a t e s p e c i a l c h a r a c t e r s, s u c h a s t h e s p a c e c h a r a c t e r, i n t o l i g a t u r e d e f i n i t i o n s. T o d o t h i s, w e f i r s t d e f i n e a s h o r t h a n d f o r t h i s
c h a r a c t e r. F o r e x a m p l e, t h e f o l l o w i n g c o d e d e f i n e s t h a t t h e s y m b o l I I w i l l s t a n d f o r a
s p a c e:
% L I G K E R N I I = 3 9 ;
W e a l w a y s u s e t h i s n u m b e r a n d t h e n u s e i t f o r l i g a t u r e s l i k e t h i s:
% L I G K E R N s I I =: s i g m a l ;
N o t e t h a t h e r e w e d i d n o t u s e =: I. W i t h t h e s a m e m e c h a n i s m, w e a r e a b l e t o u s e i n i t i a l a n d f i n a l f o r m s o f l e t t e r s. F o r e x a m p l e, t h e w o r d "b o o k" i n G r e e k i s β ι β λ ί ο. N o t e t h a t t h e t w o b e t a s a r e d i f f e r e n t. T o g e t t h i s e f f e c t, o n e c a n u s e t h e f o l l o w i n g c o d e:
% L I G K E R N I I b e t a =: b e t a l ;
R e a d y - t o - u s e e n c o d i n g v e c t o r s a r e p r o v i d e d b y t h e d i s t r i b u t i o n o f t h e kerkis
f o n t f a m i l y a v a i l a b l e f r o m h t t p: //i r i s. m a t h. a e g e a n. g r/s o f t w a r e/k e r k i s.
12.2.3 Creating Virtual Fonts and Metric Files
A s w e h a v e a l r e a d y e x p l a i n e d, T g X i s a t y p e s e t t i n g s y s t e m t h a t n e e d s t o k n o w o n l y t h e d i m e n s i o n s o f e a c h g l y p h o f a g i v e n f o n t t o s t a r t t y p e s e t t i n g u s i n g t h i s f o n t. C o n ­
s e q u e n t l y, T g X d o e s n o t r e a l l y c a r e w h e r e t h e g l y p h s a r e s t o r e d a n d h o w t h e y a r e s t o r e d —t h i s i s s o m e t h i n g a d r i v e r m u s t b e a w a r e o f. T h i s m a y l e a d s o m e o n e t o c o n ­
c l u d e t h a t w e c a n t y p e s e t a d o c u m e n t u s i n g a virtual
f o n t t h a t c o n t a i n s g l y p h s f r o m d i f f e r e n t r e a l f o n t s. W e l l, t h i s i s n o t q u i t e t r u e i n t h e s e n s e t h a t T g X d i d n o t p r o v i d e t h i s f a c i l i t y o r i g i n a l l y. T h e d e s i g n e r o f T g X i n t r o d u c e d v i r t u a l f o n t s ( a n i d e a t h a t w a s d e v i s e d b y D a v i d F u c h s ) a t a l a t e r s t a g e t o a l l o w p e o p l e t o d o e x a c t l y w h a t w e d e s c r i b e d —t o u s e g l y p h s f r o m d i f f e r e n t f o n t s i n a t r a n s p a r e n t w a y s o t h a t i t i s n o t o b v i o u s t h a t w e a r e a c t u a l l y u s i n g d i f f e r e n t f o n t s. N o w, w e w i l l d e s c r i b e h o w w e c a n g e t a T F M f i l e f r o m a n A F M f i l e.
12.2 I n s t a l l i n g T y p e i T e x t F o n t s i n Ϊ Π | ϊ Χ -φ- 399
L e t u s a s s u m e t h a t w e h a v e t h e T i m e s - N e w R o m a n f o n t s t o r e d i n t h e f i l e t n r .p f b. M o r e o v e r, a s s u m e t h a t t h e f o n t m e t r i c s a r e s t o r e d i n t h e f i l e t n r. a f m a n d t h a t w e w a n t t o r e e n c o d e t h e f o n t u s i n g a n e n c o d i n g v e c t o r s t o r e d i n f i l e m y e n c. e n c, I f w e w a n t t o u s e t h e f o n t w i t h o u t k e r n i n g p a i r s a n d l i g a t u r e s, w e c a n u s e a f m 2t f m ( b y T o m a s R o k i c k i ) t o g e t t h e f o n t m e t r i c s:
$ a f m 2 t f m t n r.a f m r t n r.t f m » t n r.m a p
I f w e w a n t t o r e e n c o d e t h e f o n t, w e h a v e t o u s e t h e f o l l o w i n g c o m m a n d:
$ a f m 2 t f m t n r.a f m - T m y e n c.e n c - v t n r 8 a t n r 8 r » t n r.m a p
I n t h e e x a m p l e s a b o v e w e s t o r e d t h e o u t p u t o f a F M 2T F M t o f i l e t n r. m a p. T h i s f i l e c o n t a i n s i n f o r m a t i o n t h a t m u s t b e e d i t e d. T h e m o d i f i e d i n f o r m a t i o n s h o u l d b e c o p i e d t o t h e f i l e p s f o n t s. m a p o r e l s e t h i s f i l e m u s t b e c o p i e d t o t h e d i r e c t o r y w h e r e p s f o n t s. m a p r e s i d e s. I n t h e l a t t e r c a s e, w e m u s t a l s o a d d t h e f o l l o w i n g l i n e i n t h e f i l e c o n f i g .p s:
p + t n r.m a p
T h e c o m m a n d a b o v e g e n e r a t e s t w o f i l e s: t h e "r a w" T F M f i l e t n r 8 r .t f m a n d t h e vir­
tual property list
f i l e t n r 8 a.v p l. T h i s f i l e c a n b e f u r t h e r p r o c e s s e d b e f o r e i t w i l l b e t r a n s f o r m e d t o a v i r t u a l f o n t w i t h t h e f o l l o w i n g c o m m a n d:
$ v p t o v f t n r 8 a t n r 8 a.v f t n r 8 a.t f m
W e c o u l d u s e o t h e r n a m e s f o r t h e f o n t f i l e s i n s t e a d o f t h e n a m e s t n r 8 a a n d t n r 8 r. B u t, d u e t o t h e g r e a t a m o u n t o f a v a i l a b l e f o n t s, t h e r e a r e s t a n d a r d r u l e s f o r c r e a t i n g t h e s e n a m e s i n o r d e r t o a v o i d c o n f l i c t. T h e r e a d e r i s a d v i s e d t o c o n s u l t [ 3 ] i f h e o r s h e i n t e n d s t o s h a r e f o n t s w i t h o t h e r p e o p l e.
N o w, o p e n t h e f i l e t n r. m a p i n a t e x t e d i t o r. I t s h o u l d h a v e a l i n e l i k e
t n r 8 r T i m e s - N e w R o m a n " m y e n c R e E n c o d e F o n t " < m y e n c.e n c
T h e w a y t h i s l i n e a p p e a r s i n t h e f i l e w i l l m a k e d v i p s b e l i e v e t h a t T i m e s - N e w R o m a n i s a r e s i d e n t f o n t o f o u r P o s t S c r i p t p r i n t e r o r e m u l a t o r. G e n e r a l l y, t h i s i s n o t t h e c a s e, s o w e n e e d t o m o d i f y t h i s e n t r y a s f o l l o w s:
t n r 8 r T i m e s - N e w R o m a n " m y e n c R e E n c o d e F o n t " < m y e n c.e n c < t n r.p f b
W i t h t h i s l i n e, w e i n s t r u c t d v i p s
t o e m b e d t h e f o n t t n r. p f b w h e n e v e r i t g e n e r a t e s a P o s t S c r i p t f i l e f r o m a D V I f i l e t h a t u s e s t h e f o n t t n r 8 r.
W e a r e n o w r e a d y t o u s e o u r f o n t b y u s i n g t h e \f o n t c o m m a n d t o c a l l t h e f o n t t n r 8 r i n a n i n p u t f i l e ( s e e S e c t i o n 3.4 ) p r o v i d e d t h a t a l l o f t h e f o n t's f i l e s t h a t w e j u s t c r e a t e d a r e i n t h e s a m e d i r e c t o r y w i t h o u r d o c u m e n t ( f o r a s y s t e m w i d e i n s t a l l a t i o n, s e e S e c t i o n 1 2.5 ). I f w e h a v e a t o u r d i s p o s a l a l l o f t h e s h a p e s a n d s e r i e s o f t h i s f o n t, w e c a n c r e a t e t h e n e c e s s a r y f o n t d e f i n i t i o n f i l e s t h a t w i l l a l l o w u s t o a c c e s s s h a p e s a n d s e r i e s w i t h t h e c o m m a n d s t h a t w e h a v e l e a r n e d. F o r m o r e i n f o r m a t i o n o n t h e c o n s t r u c t i o n o f f o n t d e f i n i t i o n f i l e s, s e e S e c t i o n 1 2.4.
40 ο -φ- 12 I n s t a l l i n g N e w T y p e
12.2.4 Creating More Fonts from a Type 1 Font
A T y p e 1 f o n t c a n b e u s e d t o c r e a t e a d d i t i o n a l s h a p e s f r o m t h e g l y p h s o f t h e f o n t. F o r e x a m p l e, w e c a n e a s i l y c r e a t e s l a n t e d g l y p h s, a l t h o u g h s l a n t e d g l y p h s m a y n o t e x i s t i n o u r o r i g i n a l f o n t, o r w e c a n u s e extended
o r condensed
g l y p h s o r e v e n ( f a k e ) s m a l l c a p i t a l s. E x t e n d e d a n d c o n d e n s e d g l y p h s a r e g l y p h s t h a t a r e s c a l e d only
h o r i z o n t a l l y b y a f a c t o r b i g g e r o r s m a l l e r t h a n 1, r e s p e c t i v e l y. T h i s i s d o n e w h e n w e c r e a t e T F M f i l e s. H e r e a r e t h e n e c e s s a r y c o m m a n d s:
• U s e
$ a f m 2 t f m t n r.a f m - T m y e n c.e n c - s 0.1 6 7 - v t n r o 8 a t n r 8 r
i n o r d e r t o c r e a t e t h e ( v i r t u a l ) f o n t t n r o 8 a w h o s e g l y p h s a r e s l a n t e d t o t h e r i g h t a t 1 6.7 %. U s e a n e g a t i v e n u m b e r t o g e t s l a n t t o t h e l e f t!
• U s e
$ a f m 2 t f m t n r.a f m - T m y e n c.e n c - e 1.2 - v t n r e 8 a t n r e 8 r
i n o r d e r t o c r e a t e t h e ( v i r t u a l ) f o n t t n r e 8 a t h a t i s e x t e n d e d b y a f a c t o r o f 1.2, o r u s e a n u m b e r l e s s t h a n 1 t o g e t a c o n d e n s e d f o n t.
• U s e
$ a f m 2 t f m t n r.a f m - T m y e n c.e n c - V t n r s c 8 a t n r s c 8 r
i n o r d e r t o c r e a t e a f a k e s m a l l c a p i t a l f o n t ( t n r s c 8 a ) i f y o u r f o n t f a m i l y d o e s n o t p r o v i d e a r e a l s m a l l c a p i t a l f o n t. N o t e t h a t w e u s e a c a p i t a l V i n s t e a d o f a v ). T h e d e f a u l t s c a l i n g f a c t o r i s 8 0 % b u t i t c a n b e c h a n g e d w i t h t h e - c o p t i o n. F o r e x a m p l e, i n o r d e r t o c r e a t e ( f a k e ) s m a l l c a p i t a l s w i t h a s c a l i n g f a c t o r o f 7 5 %, w e s h o u l d u s e
a f m 2 t f m t n r.a f m - T m y e n c.e n c - c 0.7 5 - V t n r s c 8 a t n r s c 8 r
12.3 Virtual Property List Files
I n t h i s s e c t i o n w e d i s c u s s t h e s t r u c t u r e o f v i r t u a l p r o p e r t y l i s t f i l e s. T h i s f i l e f o r m a t i s h u m a n - r e a d a b l e a n d, c o n s e q u e n t l y, i t c a n b e m o d i f i e d i n o r d e r t o a d d m o r e f e a t u r e s t o t h e v i r t u a l f o n t s. A v i r t u a l p r o p e r t y l i s t f i l e c o n s i s t s o f t h r e e p a r t s o r l i s t s 1: t h e h e a d e r l i s t ( f r o m t h e s t a r t u p t o t h e L I G T A B L E l i s t ), t h e l i g a t u r e l i s t, a n d t h e m a i n l i s t t h a t d e s c r i b e s e a c h c h a r a c t e r t h a t g o e s i n t o t h e v i r t u a l f o n t. H e r e i s a n e x a m p l e ( o f a p a r t ) o f a v i r t u a l p r o p e r t y l i s t f i l e:
( V T I T L E C r e a t e d b y a f m 2 t f m k.a f m - T k e r k i s e c.e n c - v e k 8 a )
( C O M M E N T P l e a s e e d i t t h a t V T I T L E i f y o u e d i t t h i s f i l e )
( F A M I L Y T e X - e k 8 r )
( C O D I N G S C H E M E k e r k i s e c )
I. T h e t e r m l i s t h a s i t s r o o t s i n t h e L i s p p r o g r a m m i n g l a n g u a g e, w h i c h u s e s a s i m i l a r s y n t a x.
12.3 V i r t u a l P r o p e r t y L i s t F i l e s -· 40 i
( D E S I G N S I Z E R 1 0.0 )
( D E S I G N U N I T S R 1 0 0 0 )
( C O M M E N T D E S I G N S I Z E ( 1 e m ) I S I N P O I N T S )
( C O M M E N T O T H E R D I M E N S I O N S A R E M U L T I P L E S O F D E S I G N S I Z E/1 0 0 0 )
( F O N T D I M E N ( S L A N T R 0 )
( S P A C E D 3 2 0 )
( S T R E T C H D 2 0 0 )
( S H R I N K D 1 0 0 )
( X H E I G H T D 4 8 5 )
( Q U A D D 1 0 0 0 )
( E X T R A S P A C E D 1 1 1 )
)
( M A P F O N T D 0
( F O N T N A M E e k 8 r )
( F O N T A T R 1 2 0 0 )
( F O N T S I Z E R 1 0 0 0 )
)
( L I G T A B L E
( L A B E L C f ) ( C O M M E N T f )
( L I G C i 0 2 )
( L I G C j 0 3 0 )
( S T O P )
( L A B E L 0 2 3 ) ( C O M M E N T f f )
( L I G C 1 0 2 5 )
( L I G C i 0 2 4 )
( S T O P )
( L A B E L C A )
( K R N C w R - 6 8 )
( K R N C v R - 7 5 )
)
( C H A R A C T E R C V ( C H A R W D R 6 7 6 )
( C H A R H T R 6 8 1 )
( C H A R I C R 4 9 )
)
T h e h e a d e r l i s t p r o v i d e s s o m e g e n e r a l i n f o r m a t i o n. I n t h e e x a m p l e a b o v e w e s e e t h a t t h e f a m i l y n a m e o f t h e f o n t i s T e X - e k 8 r e n c o d e d a c c o r d i n g t o t h e k e r k i s e c e n c o d i n g s c h e m e. T h e d e s i g n s i z e o f t h e f o n t i s 1 0 p t, a n d a l l o t h e r s i z e s a r e g i v e n i n d e s i g n u n i t s, w h i c h a r e 1 0 0 0 f o r t h i s f o n t ( 1 0 0 0 u n i t s e q u a l s 1 e m ). E n t e r i n g t h e F O N T D I M E N l i s t, w e s e e ( i n t h e o r d e r o f t h e e x a m p l e ) t h a t t h i s f o n t i s n o t s l a n t e d ( z e r o S L A N T ), t h e i n t e r w o r d s p a c e i s 3 2 0 u n i t s, a n d i t c a n s t r e t c h 2 0 0 u n i t s o r s h r i n k 1 0 0 u n i t s. T h e X H E I G H T a n d QUAD
40 2 -φ- 12 I n s t a l l i n g N e w T y p e
l i s t s s p e c i f y t h e l e n g t h o f t h e d i m e n s i o n s 1 e x a n d 1 e m. T h e E X T R A S P A C E l i s t d e f i n e s t h e s p a c e t h a t Τ β Χ p u t s a t t h e e n d o f a s e n t e n c e p r o v i d e d t h a t \n o f r e n c h s p a c i n g i s e n a b l e d. T h i s c o m m a n d c a n c e l s t h e e f f e c t o f t h e \f r e n c h s p a c i n g c o m m a n d. T h e s u b l i s t s o f t h e F O N T D I M E N l i s t c o r r e s p o n d t o t h e f o n t d i m e n s i o n s d e s c r i b e d i n S e c t i o n 1 2.4. T h e COMM ENT l i s t i s u s e d t o i n t r o d u c e c o m m e n t s i n a p r o p e r t y l i s t.
O n e o f t h e m o s t i m p o r t a n t l i s t s i s t h e M A P F O N T l i s t. I n t h e e x a m p l e a b o v e, i t i s u s e d t o s a y t h a t t h e d e f a u l t e x t e r n a l f o n t t o u s e f o r t h e v i r t u a l f o n t i s n a m e d e k 8 r. I n a d d i t i o n, w e s p e c i f i e d t h e a c t u a l d e s i g n s i z e o f t h e e x t e r n a l f o n t a n d t h e s c a l i n g f a c t o r. T h e r o l e o f t h i s l i s t i s t o m a k e i t p o s s i b l e f o r o n e v i r t u a l f o n t t o d r a w c h a r a c t e r s f r o m m o r e t h a n o n e r e a l f o n t. T h i s i s d o n e b y a s s i g n i n g a n u m b e r t o e a c h r e a l f o n t t h a t w e w a n t t o u s e. T h u s, t h e l i n e s
( M A P F O N T D 0
( F O N T N A M E T i m e s - R o m a n )
)
( M A P F O N T D 1
( F O N T N A M E s y m b o l )
)
( M A P F O N T D 2
( F O N T N A M E c m r 1 0 )
( F O N T A T D 2 0 )
)
l o a d t w o r e a l f o n t s, T i m e s - R o m a n a n d s y m b o l, a n d o n e m o r e, c m r l O, a t t h e s i z e o f 2 0 u n i t s; e a c h o n e i s a s s i g n e d t o o n e o f t h e n u m b e r s 0, 1, a n d 2, r e s p e c t i v e l y. T h e s e
n u m b e r s a r e u s e d i n o r d e r t o s e l e c t t h e r e a l f o n t t o b e u s e d i n t h e t h i r d p a r t o f t h e
v i r t u a l p r o p e r t y l i s t f i l e. I n t h i s t h i r d p a r t, w e h a v e a s e q u e n c e o f s t a t e m e n t s, o n e f o r e a c h g l y p h. E a c h s t a t e m e n t d e s c r i b e s th e d i m e n s i o n s o f t h e g l y p h f r o m w h i c h th e r e a l f o n t i s t o b e d r a w n a n d h o w i t i s d r a w n. T h e f i r s t l i n e i d e n t i f i e s t h e g l y p h i n t h e v i r t u a l f o n t. I t s c o d e p o i n t c a n b e e x p r e s s e d i n f o u r d i f f e r e n t w a y s: b y t h e l e t t e r D a n d a d e c i m a l n u m b e r, b y t h e l e t t e r 0 a n d a n o c t a l n u m b e r, b y t h e l e t t e r H a n d a h e x a d e c i m a l n u m b e r, a n d b y t h e l e t t e r C a n d t h e g l y p h n a m e. H e r e i s h o w o n e c a n e x p r e s s t h e s a m e t h i n g i n a l l f o u r p o s s i b l e w a y s:
C H A R A C T E R C V C H A R A C T E R D 6 8
C H A R A C T E R 0 1 2 6 C H A R A C T E R H 4 4
I n t h e e x a m p l e a b o v e w e s e e t h i s i n f o r m a t i o n f o r t h e c h a r a c t e r V. I t s w i d t h i s 6 7 6 u n i t s, i t s h e i g h t 6 8 1 u n i t s, a n d i t s i t a l i c c o r r e c t i o n i s 4 9 u n i t s.
A n o t h e r v a r i a b l e n o t a p p e a r i n g i n t h e e x a m p l e o f t h e c h a r a c t e r V i s t h e C H A R D P v a r i a b l e, w h i c h c o n t r o l s t h e d e p t h o f t h e c h a r a c t e r ( i.e., h o w m u c h t h e c h a r a c t e r e x t e n d s b e l o w t h e b a s e l i n e ). F o r e x a m p l e, i n t h e f o n t a b o v e, t h e a m p e r s a n d a p p e a r s i n t h e v i r t u a l p r o p e r t y l i s t f i l e a s
( C H A R A C T E R 0 4 6 ( C O M M E N T a m p e r s a n d )
12.3 V i r t u a l P r o p e r t y L i s t F i l e s -· 40 3
( C H A R W D R 8 0 0 )
( C H A R H T R 6 9 4 )
( C H A R D P R 1 3 )
)
t h a t i s, i t e x t e n d s b e l o w t h e b a s e l i n e b y 1 3 u n i t s. N o t e t h a t f o r t h e c h a r a c t e r V w e h a d u s e d i t s n a m e i n t h e C H A R A C T E R s t a t e m e n t, b u t f o r t h e a m p e r s a n d w e u s e d i t s p o s i t i o n i n t h e f o n t ( w h i c h i s t h e p o s i t i o n o f t h e a m p e r s a n d i n t h e e n c o d i n g v e c t o r k e r k i s e c. e n c ).
T h e g l y p h d e s c r i p t i o n a b o v e i s t h e d e s c r i p t i o n o f a r e a l g l y p h. I f w e w a n t t o h a v e t h e d e s c r i p t i o n o f a g l y p h t h a t a c t u a l l y b e l o n g s t o s o m e o t h e r f o n t, w e m u s t h a v e a g l y p h d e s c r i p t i o n l i k e t h e f o l l o w i n g o n e:
( C H A R A C T E R H A F ( C O M M E N T c o d e p o i n t i s 1 7 5 )
( C H A R W D R 0.6 6 5 )
( C H A R H T R 0.7 9 9 )
( C H A R I C R 0.0 6 5 )
( M A P
( S E L E C T F O N T D 0 )
( S E T C H A R 0 4 1 ) ( C O M M E N T c o d e p o i n t i s 2 7 )
)
)
H e r e, w e s e e t h a t t h e d i m e n s i o n s a r e e x p r e s s e d i n d e c i m a l p o i n t u n i t s. T h i s i s p o s s i b l e w h e n t h e r e i s n o D E S I G N U N I T S d e f i n i t i o n. N o w, t h e d e s c r i p t i o n a b o v e s a y s t h a t w e h a v e t o m a p t h e c h a r a c t e r w i t h c o d e p o i n t 1 7 5 t o t h e c h a r a c t e r 2 7 o f t h e r e a l f o n t. T h e f o l l o w i n g i s a m o r e c o m p l e x e x a m p l e:
( C H A R A C T E R D 1 9 7
----------------- ( M A P --------------------------------------------------------------------------------------------------
( P U S H )
( S E T C H A R C A )
( P O P )
( M 0 V E U P R 0.9 3 7 )
( M O V E R I G H T R 1.5 )
( S E T C H A R 0 3 1 2 )
)
)
( C H A R A C T E R 0 2 0 0 ( M A P
( M 0 V E D 0 W N R 2.1 )
( S E T R U L E R 1 R 8 )
)
)
( C H A R A C T E R 0 2 0 1
----------------- ( M A P --------------------------------------------------------------------------------------------------
40 4 "Φ" 12 I n s t a l l i n g N e w T y p e
( S P E C I A L p s: /S a v e G r a y c u r r e n t g r a y d e f .5 s e t g r a y ) ( S E L E C T F O N T D 2 )
( S E T C H A R C A )
( S P E C I A L p s: S a v e G r a y s e t g r a y )
)
)
T h e f i r s t l i s t s a y s t h a t t h e c h a r a c t e r w i t h c o d e p o i n t 1 9 7 i s s e t a s f o l l o w s: a n Ά'
i s t y p e s e t, a n d t h i s i s e n c l o s e d b y P U S H a n d P O P, w h i c h r e s t o r e t h e o r i g i n a l p o s i t i o n. T h e n, t h e c h a r a c t e r w i t h c o d e p o i n t 1 3 0 i s t y p e s e t a f t e r i t i s m o v e d u p b y 0.9 3 7 u n i t s a n d t o t h e r i g h t b y 1.5 u n i t s. T h e l a s t l i s t i s m o r e c o m p l e x. B e f o r e w e a c t u a l l y e x p l a i n w h a t i t d o e s, w e m u s t w a r n t h e r e a d e r t h a t i t u s e s r e a l P o s t S c r i p t c o d e. T h e r e f o r e, t h i s e x a m p l e i s u s e f u l o n l y i f t h e r e a d e r i s a c c u s t o m e d t o t h e b a s i c s o f t h e P o s t S c r i p t l a n g u a g e. N o w, b a c k t o o u r e x a m p l e. T h e c o d e s a y s t h a t i n o r d e r t o t y p e s e t t h e c h a r a c t e r w i t h c o d e p o i n t e q u a l t o 1 2 9 i n t h i s v i r t u a l f o n t, w e s e t t h e P o s t S c r i p t c o l o r t o 5 0 % g r a y a n d t h e n t y p e s e t a n Ά'
f r o m c m r l O a t 2 0 u n i t s i n t h i s c o l o r. T h e S P E C I A L p s: c o m m a n d i s u s e d t o p a s s i t s a r g u m e n t t o t h e P o s t S c r i p t d r i v e r ( s u c h a s d v i p s ). H o w e v e r, w e c h o s e t o u s e t h e s e P o s t S c r i p t c o m m a n d s s i n c e t h e y w i l l b e u s e f u l i n o n e o f o u r a p p l i c a t i o n s ( s e e S e c t i o n 1 2.3.1 ).
T h e s e c o n d l i s t o f a v i r t u a l p r o p e r t y l i s t f i l e i s t h e p a r t t h a t h o l d s t h e l i g a t u r e a n d k e r n i n g i n f o r m a t i o n. I n o u r v i r t u a l p r o p e r t y l i s t e x a m p l e a b o v e, w e h a d
( L I G T A B L E
( L A B E L C f ) ( c o m m e n t f )
( L I G C i 0 2 )
( L I G C j 0 3 0 )
( S T O P )
( L A B E L 0 2 3 ) ( c o m m e n t f f )
( L I G C 1 0 2 5 )
( L I G C i 0 2 4 )
( S T O P )
( L A B E L C A )
___________________________________( K R N C w R - 6 8 )_____________________________________________________________________________
( K R N C v R - 7 5 )
)
T h i s t a b l e d e s c r i b e s t h e l i g a t u r e s f o r 'f' a n d f o r 'ff',
a n d t w o k e r n i n g p a i r s f o r Ά'.
W e f i r s t c h o o s e ( l a b e l ) t h e 'f
c h a r a c t e r a n d t h e n s t a t e t h a t i f t h e n e x t c h a r a c t e r i s a n Ύ
w e s u b s t i t u t e b o t h w i t h t h e g l y p h i n t h e ( o c t a l ) p o s i t i o n 2 ( w h i c h i s t h e "f i" f o r o u r f o n t ) a n d s i m i l a r l y f o r 'f j'. N e x t, t h e 'ffi'
a n d 'ffi'
l i g a t u r e s a r e d e f i n e d s i m i l a r l y. F i n a l l y, w e s t a t e t h a t i f t h e c h a r a c t e r 'w' f o l l o w s t h e c h a r a c t e r Ά',
t h e n 'w'
s h o u l d b e k e r n e d t o t h e l e f t b y 6 8 u n i t s a n d t h e s a m e f o r t h e c h a r a c t e r W
w i t h 7 5 u n i t s. M o r e c o m p l e x l i g a t u r e s c a n b e s t a t e d h e r e u s i n g i n s t e a d o f t h e L I G f u n c t i o n t h e f u n c t i o n s
L I G /L I G /L I G > L I G/ L I G/> /L I G/ /L I G/> /L I G/»
12.3 V i r t u a l P r o p e r t y L i s t F i l e s -· 40 5
t h a t c o r r e s p o n d t o t h e f u n c t i o n s
= : I =: I =: > =: I =:| > | = : I | = :| > l = :| »
i n t h e a f m f i l e, r e s p e c t i v e l y ( s e e S e c t i o n 1 2.2.2 ).
12.3.1 T wo A p p l i c a t i o n s
W e g i v e h e r e t w o n o n t r i v i a l a p p l i c a t i o n s o f m a n u a l l y e d i t i n g t h e v i r t u a l p r o p e r t y l i s t f i l e b e f o r e t h e p r o d u c t i o n o f t h e v i r t u a l f o n t s. F i r s t, w e g i v e t h e e a s y o n e. A s s u m e t h a t w e w a n t t o u s e a f o n t t h a t d o e s n o t c o m e w i t h s m a l l c a p i t a l s. A w a y t o b y p a s s t h i s p r o b l e m ( a l t h o u g h n o t t y p o g r a p h i c a l l y c o r r e c t ) i s t o p r o d u c e f a k e s m a l l c a p i t a l s u s i n g t h e - V o p t i o n o f t h e a f m2t f m p r o g r a m. H o w e v e r, t h e r e a r e l a n g u a g e s, s u c h a s G r e e k, w h e r e a c a p i t a l l e t t e r c o r r e s p o n d s t o m o r e t h a n o n e l o w e r c a s e l e t t e r. F o r e x a m p l e, t h e c a p i t a l i z a t i o n o f b o t h σ a n d ς i s Σ. I t t u r n s o u t t h a t w e h a v e t o e d i t t h e v i r t u a l p r o p e r t y l i s t f i l e a n d c o r r e c t t h e d i m e n s i o n s o f t h e c h a r a c t e r c ( w h i c h c o r r e s p o n d s t o t h e G r e e k f i n a l s i g m a ς; s e e S e c t i o n 1 0.4 ) t o h a v e t h e d i m e n s i o n s o f t h e c h a r a c t e r Σ a n d a l s o m a p ς t o Σ. T h e e n t r y f o r c ( w h i c h c o r r e s p o n d s t o ς ) l o o k s l i k e
( C H A R A C T E R C c
( C H A R W D R 4 9 6 )
( C H A R H T R 4 4 7 )
( C H A R D P R 2 0 8 )
)
a n d i t s h o u l d c h a n g e t o
( C H A R A C T E R C c
( C H A R W D R 5 5 0 )
( C H A R H T R 6 3 0 )
( M A P
( S E T C H A R 0 1 2 3 )
)
)
w h e r e t h e n e w d i m e n s i o n s a r e t h o s e o f t h e c a p i t a l s i g m a s c a l e d t o 8 0 % o r w h a t e v e r i s t h e s c a l i n g f a c t o r f o r t h e s m a l l c a p i t a l s, a n d t h e g l y p h f o r c i s t h e c h a r a c t e r w i t h c o d e p o i n t 8 3 ( o c t a l 1 2 3 ), w h i c h i s t h e c a p i t a l s i g m a.
T h e n e x t a p p l i c a t i o n i s m o r e c o m p l e x. W e w a n t t o c o n s t r u c t a n u n d e r l i n e d f o n t.
U n d e r l i n i n g i s n o t g o o d f o r t e x t w o r k b u t m a y b e u s e f u l i n o t h e r a p p l i c a t i o n s s u c h a s p o s t e r s. W e s a w h o w t o u n d e r l i n e w i t h t h e p a c k a g e u l e m o n p a g e 4 2. H o w e v e r, t h i s w a s a b a d u n d e r l i n i n g s i n c e t h e p o s i t i o n o f t h e u n d e r l i n e d e p e n d s o n t h e d e p t h o f t h e g l y p h s. A g o o d u n d e r l i n i n g s h o u l d s t a y a t t h e s a m e p o s i t i o n t h r o u g h o u t t h e u n d e r l i n e d t e x t a n d s h o u l d b r e a k n i c e l y a t a l l p l a c e s w h e r e t h e g l y p h s e x t e n d b e l o w t h e b a s e l i n e l i k e t h i s:
40 6 -φ- 12 I n s t a l l i n g N e w T y p e
Quit the joy of gambling!
F o r t h i s t a s k, w e s h o u l d a d d u n d e r l i n e s t o a l l o f t h e g l y p h s i n o u r v i r t u a l f o n t s a n d t a k e s p e c i a l c a r e f o r t h o s e t h a t e x t e n d w e l l b e l o w t h e b a s e l i n e.
A s s u m e t h a t w e a l r e a d y h a v e a f o n t f o n t.p f b f o r w h i c h w e h a v e p r e p a r e d a l l n e c e s s a r y f i l e s s u c h a s f o n t 8 a. v p l, f o n t 8 a. v f, a n d s o o n. W e r e p e a t t h e s a m e a f m 2t f m c o m m a n d, b u t n o w w e c h a n g e t h e l a s t t w o a r g u m e n t s t o f o n t u 8 a a n d f o n t u 8 r ( s e e S e c t i o n 1 2.2.3 ). O b v i o u s l y, t h e c o n t e n t s o f t h e r e s u l t i n g f o n t u 8 a. v p l w i l l b e t h e s a m e a s t h a t o f f o n t S a.v p l. N o w, w e e d i t t h e f i l e f o n t u S a.v p l. T h e f i r s t s t e p i s t o a d d a M A P F O N T c o m m a n d s o t h a t f o n t u 8 a c a n r e f e r t o f o n t 8 a. T h i s i s d o n e b y a d d i n g a f t e r t h e ( M A P F O N T D O (... t h e c o d e
( M A P F O N T D 1 ( F O N T N A M E f o n t 8 a ) )
N o w, f o r e a c h c h a r a c t e r t h a t d o e s n o t e x t e n d b e l o w t h e b a s e l i n e, w e a d d a n u n d e r l i n e o f l e n g t h e q u a l t o i t s w i d t h ( C H A R W D ). F o r e x a m p l e, i f t h e s t a t e m e n t f o r t h e l e t t e r Ά'
i s
( C H A R A C T E R C A ( C H A R W D R 7 7 7 )
( C H A R H T R 6 6 3 )
( C H A R D P R 2 9 )
)
w e c h a n g e i t t o
( C H A R A C T E R C A ( C H A R W D R 7 7 7 )
( C H A R H T R 6 6 3 )
( C H A R D P R 2 9 )
( M A P
( P U S H )
( M O V E D O W N R 1 3 1 )
( S E T R U L E R 5 9 R 7 7 7 )
( P O P )
( S E L E C T F O N T D 1 )
( S E T C H A R C A )
)
)
T h e l a s t m o d i f i c a t i o n s a y s t h a t w e s h o u l d m o v e d o w n 1 3 1 u n i t s a n d d r a w a l i n e o f h e i g h t 5 9 u n i t s a n d l e n g t h e q u a l t o t h e l e n g t h o f t h e l e t t e r 'A
'
( h e r e 777).
T h e n, a t t h e s a m e p o s i t i o n ( ( P U S H ) a n d ( P O P ) m a k e s u r e t h a t w e d o n o t m o v e f o r w a r d ), w e t y p e s e t t h e c h a r a c t e r 'A'
f r o m t h e f o n t 1; t h a t i s, t h e f o n t f o n t 8 a. N o t e t h a t w e h a v e t o l i n k t o a n o t h e r f o n t ( f o n t 8 a ) s i n c e r e f e r r i n g t o t h e c u r r e n t f o n t w o u l d l e a d t o a r e c u r s i v e f o n t
d e f i n i t i o n!
12.3 V i r t u a l P r o p e r t y L i s t F i l e s -· 40 7
L e t u s s e e n o w t h e c h a r a c t e r 'j' t h a t e x t e n d s b e l o w t h e b a s e l i n e. I f t h e i n f o r m a t i o n f o r i n t h e f o n t u 8 a. v p l f i l e i s
( C H A R A C T E R
C
j
( C H A R W D
R
2 3 3 )
( C H A R H T
R
6 8 3 )
( C H A R D P
R
2 8 0 )
)
w e c h a n g e i t t o
( C H A R A C T E R C j ( C H A R W D R 2 3 3 )
( C H A R H T R 6 8 3 )
( C H A R D P R 2 8 0 )
( M A P
( P U S H )
( M 0 V E D 0 W N R 1 3 1 )
( S E T R U L E R 5 9 R 2 3 3 )
( P O P )
( S P E C I A L p s: /S a v e G r a y c u r r e n t g r a y d e f 1 s e t g r a y )
( P U S H )
( M O V E L E F T R 4 0 )
( S E L E C T F O N T D 1 )
( S E T C H A R C j )
( P O P ) ( P U S H )
( M O V E R I G H T R 4 0 )
( S E L E C T F O N T D 1 )
( S E T C H A R C j )
( P O P )
( S P E C I A L p s: S a v e G r a y s e t g r a y )
( S E L E C T F O N T D 1 )
( S E T C H A R C j )
)
)
A s b e f o r e, w e f i r s t d r a w t h e u n d e r l i n e r u l e. A f t e r t h a t, w e c h a n g e t h e P o s t S c r i p t c o l o r t o g r a y 1 0 0 % ( i.e., w h i t e ). T h e n, w i t h t h e w h i t e i n k, w e d r a w t h e c h a r a c t e r f r o m t h e f o n t 1, s h i f t e d t o t h e l e f t ( M O V E L E F T ) a n d t o t h e r i g h t ( M O V E R I G H T ) b y 4 0 u n i t s. T h i s w a y w e e s s e n t i a l l y e r a s e t h e u n d e r l i n e a r o u n d t h e c h a r a c t e r p a r t s t h a t e x t e n d w e l l b e l o w t h e b a s e l i n e. W e r e s t o r e t h e b l a c k c o l o r a n d f i n a l l y p r i n t t h e l e t t e r 'j'. T h e r e a r e c a s e s w h e r e w e n e e d t o s h i f t t h e c h a r a c t e r u p a n d d o w n i n a d d i t i o n t o l e f t a n d r i g h t. T h i s i s t h e c a s e, f o r e x a m p l e, f o r t h e l e t t e r Q i n i n t h e l i g a t u r e Ο μ.
A f t e r t h e s e m o d i f i c a t i o n s, w e c r e a t e o u r v i r t u a l f o n t s w i t h v p t o v f.
40 8 -φ- 12 I n s t a l l i n g N e w T y p e
12.4 Creating Support Packages and Font Definition Files
Ι 5 Τ β Χ n e e d s w h a t w e c a l l font definition
f i l e s i f i t i s e x p e c t e d t o p r o p e r l y h a n d l e s i z e - c h a n g i n g c o m m a n d s s u c h a s \l a r g e, \t i n y, o r s e r i e s - a n d s h a p e - c h a n g i n g c o m m a n d s s u c h a s \t e x t i t a n d \t e x t s c. A f o n t d e f i n i t i o n f i l e s p e c i f i e s t h e s i z e s a n d s h a p e s a v a i l a b l e f o r a p a r t i c u l a r f o n t f a m i l y A n i m p o r t a n t c h a r a c t e r i s t i c o f a n y f o n t f a m i l y i s i t s f o n t e n c o d i n g. F o r a n y f o n t f a m i l y x x x t h a t f o l l o w s t h e f o n t e n c o d i n g y y y, w e n e e d t h e f o n t d e f i n i t i o n f i l e y y y x x x. f d i n o r d e r t o b e a b l e t o u s e t h e f o n t s o f t h e f a m i l y. F o r a n y f o n t e n c o d i n g, w e n e e d t o d e f i n e a f o n t e n c o d i n g d e f i n i t i o n f i l e. G i v e n a f o n t e n c o d i n g c a l l e d y y y, i t s f o n t e n c o d i n g d e f i n i t i o n f i l e w i l l b e n a m e d y y y e n c .d e f. I f w e h a v e a f o n t f a m i l y t h a t c o n s i s t s o f f o n t s t h a t c o n t a i n s u p e r s e t s o f t h e g l y p h s f o u n d i n m o r e t h a n o n e f o n t e n c o d i n g, i t i s p o s s i b l e t o c r e a t e m a n y f o n t d e f i n i t i o n f i l e s. W e w i l l n o w d i s c u s s h o w t o c r e a t e a f o n t d e f i n i t i o n f i l e a n d a s u p p o r t p a c k a g e. W e s t a r t w i t h t h e f o n t d e f i n i t i o n f i l e s.
F i r s t o f a l l, w e n e e d t o k n o w t h e f o n t f a m i l y n a m e. N e x t, w e n e e d t o k n o w t h e f o n t e n c o d i n g. I n m o s t c a s e s, i t i s v e r y e a s y t o d e d u c e t h e n a m e o f t h e f o n t e n c o d i n g. F o r e x a m p l e, f o r f o n t s u s a b l e f o r E u r o p e a n l a n g u a g e s, t h e p o s s i b l e c h o i c e s a r e t h e O T 1 a n d t h e T I e n c o d i n g s. O n c e w e h a v e t h i s i n f o r m a t i o n, w e c a n c r e a t e o u r f o n t d e f i n i t i o n f i l e. S u p p o s e t h a t w e h a v e a G r e e k f o n t f a m i l y. T h i s m e a n s t h a t w e w i l l u s e t h e L G R f o n t e n c o d i n g. T h e f i r s t l i n e o f a f o n t d e f i n i t i o n f i l e a n n o u n c e s t h e f o n t f a m i l y a n d i t s e
n c o d i n g:
\D e c l a r e F o n t F a m i l y i L G R M p t m J O
N o t e t h a t w e s p e c i f y t h e f o n t e n c o d i n g i n c a p i t a l l e t t e r s. T h e e m p t y a r g u m e n t s h o u l d b e u s e d t o s p e c i f y l o a d i n g s e t t i n g s, w h i c h w e d i s c u s s b e l o w. N e x t, w e s p e c i f y a s e r