A Guide toLATEX
and Electronic Publishing
Fourth edition
Helmut Kopka
Patrick W. Daly
Addison-Wesley
Harlow, England Reading, Massachusetts Menlo Park, California
New York Don Mills, Ontario Amsterdam Bonn Sydney Singapore
Tokyo Madrid San Juan Milan Mexico City Seoul Taipei
© Addison Wesley Longman Limited 2004
Addison Wesley Longman Limited
Edinburgh Gate
Harlow
Essex CM20 2JE
England
and Associated Companies throughout the World.
The rights of Helmut Kopka and Patrick W. Daly to be identified as authors of
this Work have been asserted by them in accordance with the Copyright,
Designs and Patents Act 1988.
All rights reserved. No part of this publication may be reproduced, stored in a
retrieval system, or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording or otherwise, without either the prior
written permission of the publisher or a licence permitting restricted copying in
the United Kingdom issued by the Copyright Licensing Agency Ltd,
90 Tottenham Court Road, London W1P 9HE.
The programs in this book have been included for their instructional value.
They have been tested with care but are not guaranteed for any particular
purpose. The publisher does not offer any warranties or representations nor
does it accept any liabilities with respect to the programs.
Many of the designations used by manufacturers and sellers to distinguish their
products are claimed as trademarks. Addison Wesley Longman Limited has
made every attempt to supply trademark information about manufacturers and
their products mentioned in this book. A list of the trademark designations and
their owners appears on page v.
Cover designed by Designers & Partners, Oxford
Typeset by the authors with the LATEX Documentation System
Printed in Great Britain by Henry Ling Ltd, at the Dorset Press, Dorchester,
Dorset
First published 1993
Second edition 1995
Third edition 1999. Reprinted 1999, 2000
Fourth edition 2004
ISBN ????????????
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Cataloging-in-Publication Data
Kopka, Helmut.
A guide to LATEX : and Electronic Publishing
/ Helmut Kopka, Patrick W. Daly -- 4th ed.
p. cm.
Includes bibliographical references and index.
ISBN 0-201-39825-7
1. LATEX (Computer file) 2. Computerized typesetting. I. Daly,
Patrick W. II. Title.
????????????
???????????
???????
CIP
v
Trademark notices
METAFONT™ is a trademark of Addison-Wesley Publishing Company.
TEX™, AMS-TEX™, and AMS-LATEX™ are trademarks of the American
Lucida™ is a trademark of Bigelow & Holmes.
Microsoft®, MS-DOS®, Windows®, Internet Explorer® are registered
Mathematical Society.
trademarks of Microsoft Corporation.
PostScript®, Acrobat Reader®, Acrobat logo® are registered trademarks and
PDF™ a trademark of Adobe Systems Incorporated.
UNIX® is a registered trademark in the United States and other countries,
licensed exclusively through X/Open Company, Limited.
VAX™ and VMS™ are trademarks of Digital Equipment Corporation.
IBM® is a registered trademark and techexplorer Hypermedia Browser™ a
trademark of International Business Machines Corporation.
Netscape™ and Netscape Navigator™ are trademarks of Netscape
Communications Corporation.
TrueType™ is a trademark and Apple® and Macintosh® are registered
trademarks of Apple Computer Inc.
Preface
A new edition to A Guide to LATEX begs the fundamental question: Has
LATEX changed so much since the appearance of the third edition in 1999
that a new release of this manual is justified?
The simple answer to that question is ‘Well . . . .’ In 1994, the LATEX world
was in upheaval with the issue of the new version LATEX 2ε, and the second
edition of the Guide came out just then to act as the bridge between the
old and new versions. By 1998, the initial teething problems had been
worked out and corrected through semi-annual releases, and the third
edition could describe an established, working system. However, homage
was still paid to the older 2.09 version since many users still employed its
familiar syntax, although they were most likely to be using it in a LATEX 2ε
environment. LATEX has now reached a degree of stability that since 2000
the regular updates have been reduced to annual events, which often
appear months after the nominal date, something that does not worry
anyone. The old version 2.09 is obsolete and should no longer play any
role in such a manual. In this fourth edition, it is reduced to an appendix
just to document its syntax and usage.
But if LATEX itself has not changed substantially since 1999, many of its
peripherals have. The rise of programs like pdfTEX and dvipdfm for PDF
output adds new possibilities, which are realized, not in LATEX directly, but
by means of more modern packages to extend the basic features. The
distribution of TEX/LATEX installations has changed, such that most users
are given a complete, ready-to-run setup, with all the ‘extras’ that one
used to have to obtain oneself. Those extras include user-contributed
packages, many of which are now considered indispensable. Today ‘the
LATEX system’ includes much more than the basic kernel by Leslie Lamport,
encompassing the contributions of hundreds of other people. This edition
reflects this increase in breadth.
The changes to the fourth edition are mainly those of emphasis.
1. The material has been reorganized into ‘Basics’ and ‘Beyond the
Basics’ (‘advanced’ sounds too intimidating) while the appendices
contain topics that really can be skipped by most everyday users.
Exception: Appendix H is an alphabetized command summary that
many people find extremely useful (including ourselves).
This reorganizing is meant to stress certain aspects over others. For
vii
viii
Preface
example, the section on graphics inclusion and color was originally
treated as an exotic freak, relegated to an appendix on extensions;
in the third edition, it moved up to be included in a front chapter
along with the picture environment and floats; now it dominates
Chapter 6 all on its own, the floats come in the following Chapter 7,
and picture is banished to the later Chapter 13. This is not to say
that the picture features are no good, but only that they are very
specialized. We add descriptions of additional drawing possibilities
there too.
2. It is stressed as much as possible that LATEX is a markup language,
with separation of content and form. Typographical settings should
be placed in the preamble, while the body contains only logical
markup. This is in keeping with the modern ideas of XML, where
form and content are radically segregated.
3. Throughout this edition, contributed packages are explained at that
point in the text where they are most relevant. The fancyhdr
package comes in the section on page styles, natbib where literature
citations are explained. This stresses that these ‘extensions’ are part
of the LATEX system as a whole. However, to remind the user that
they must still be explicitly loaded, a marginal note is placed at the
start of their descriptions.
4. PDF output is taken for granted throughout the book, in addition
to the classical DVI format. This means that the added possibilities
of pdfTEX and dvipdfm are explained where they are relevant. A
separate Chapter 10 on PostScript and PDF is still necessary, and the
best interface to PDF output, the hyperref package by Sebastian
Rahtz, is explained in detail. PDF is also included in Chapter 15 on
presentation material.
On the other hand, the other Web output formats, HTML and XML,
are only dealt with briefly in Appendix E, since these are large topics
treated in other books, most noticeably the LATEX Web Companion.
5. This book is being distributed with the TEXLive CD, with the kind
permission of Sebastian Rahtz who maintains it for the TEX Users
Group.
It contains a full TEX and LATEX installation for Windows,
Macintosh, and Linux, plus many of the myriad extensions that
exist.
We once again express our hope that this Guide will prove more than
useful to all those who wish to find their way through the intricate world
of LATEX. And with the addition of the TEXLive CD, that world is brought
even closer to their doorsteps.
Helmut Kopka and Patrick W. Daly
June, 2003
Contents
Preface
I Basics
1 Introduction
1.1
Just what is LATEX? . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Markup Languages . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 TEX and its offspring . . . . . . . . . . . . . . . . . . . . . . . .
1.4 How to use this book . . . . . . . . . . . . . . . . . . . . . . . .
1.5
Basics of a LATEX file . . . . . . . . . . . . . . . . . . . . . . . . .
1.6 TEX processing procedure . . . . . . . . . . . . . . . . . . . . .
2 Text, Symbols, and Commands
2.1 Command names and arguments . . . . . . . . . . . . . . . .
2.2
Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.3 Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.4
Lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Special characters . . . . . . . . . . . . . . . . . . . . . . . . . .
2.5
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.6
2.7
Fine-tuning text . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.8 Word division . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3 Document Layout and Organization
3.1 Document class . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2
Page style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.3
Parts of the document . . . . . . . . . . . . . . . . . . . . . . .
3.4 Table of contents . . . . . . . . . . . . . . . . . . . . . . . . . .
4 Displayed Text
4.1 Changing font . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.2 Centering and indenting . . . . . . . . . . . . . . . . . . . . . .
4.3
Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Generalized lists . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5 Theorem-like declarations . . . . . . . . . . . . . . . . . . . .
vii
1
3
3
4
6
10
11
14
17
17
19
20
21
22
27
28
34
37
37
42
52
58
61
61
67
69
74
80
ix
x
CONTENTS
81
4.6 Tabulator stops . . . . . . . . . . . . . . . . . . . . . . . . . . .
85
4.7
Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
95
4.8 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.9
Printing literal text . . . . . . . . . . . . . . . . . . . . . . . . . 110
4.10 Footnotes and marginal notes . . . . . . . . . . . . . . . . . . 112
4.11 Comments within text . . . . . . . . . . . . . . . . . . . . . . . 118
5 Mathematical Formulas
119
5.1 Mathematical environments . . . . . . . . . . . . . . . . . . . 119
5.2 Main elements of math mode . . . . . . . . . . . . . . . . . . 120
5.3 Mathematical symbols . . . . . . . . . . . . . . . . . . . . . . . 124
5.4 Additional elements . . . . . . . . . . . . . . . . . . . . . . . . 130
Fine-tuning mathematics . . . . . . . . . . . . . . . . . . . . . 145
5.5
5.6
Beyond standard LATEX . . . . . . . . . . . . . . . . . . . . . . . 151
6 Graphics Inclusion and Color
153
6.1 The graphics packages . . . . . . . . . . . . . . . . . . . . . . 153
6.2 Adding color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
7 Floating tables and figures
169
Float placement . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Postponing floats . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Style parameters for floats . . . . . . . . . . . . . . . . . . . . 171
Float captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Float examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
. . . . . . . . . . . . 177
Some float packages . . . . . . . . . . . . . . . . . . . . . . . . 178
7.1
7.2
7.3
7.4
7.5
7.6 References to figures and tables in text
7.7
8 User Customizations
181
8.1 Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
8.2
Lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
8.3 User-defined commands . . . . . . . . . . . . . . . . . . . . . . 185
8.4 User-defined environments . . . . . . . . . . . . . . . . . . . . 195
8.5
Some comments on user-defined structures . . . . . . . . . 200
II Beyond the Basics
205
9 Document Management
207
Processing parts of a document . . . . . . . . . . . . . . . . . 207
9.1
In-text references . . . . . . . . . . . . . . . . . . . . . . . . . . 213
9.2
9.3
Bibliographies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
9.4 Keyword index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
CONTENTS
xi
10 PostScript and PDF
231
10.1 LATEX and PostScript
. . . . . . . . . . . . . . . . . . . . . . . . 231
10.2 Portable Document Format . . . . . . . . . . . . . . . . . . . . 236
11 Multilingual LATEX
251
11.1 The babel system . . . . . . . . . . . . . . . . . . . . . . . . . 252
11.2 Contents of the language.dat file . . . . . . . . . . . . . . . 256
12 Math Extensions with AMS-LATEX
257
12.1 Invoking AMS-LATEX . . . . . . . . . . . . . . . . . . . . . . . . 258
12.2 Standard features of AMS-LATEX . . . . . . . . . . . . . . . . . 258
12.3 Further AMS-LATEX packages . . . . . . . . . . . . . . . . . . . 280
12.4 The AMS fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
13 Drawing with LATEX
287
13.1 The picture environment
. . . . . . . . . . . . . . . . . . . . 287
13.2 Extended pictures . . . . . . . . . . . . . . . . . . . . . . . . . . 302
13.3 Other drawing packages . . . . . . . . . . . . . . . . . . . . . . 307
14 Bibliographic Databases and BIBTEX
309
14.1 The BIBTEX program . . . . . . . . . . . . . . . . . . . . . . . . . 309
14.2 Creating a bibliographic database . . . . . . . . . . . . . . . . 311
14.3 Customizing bibliography styles . . . . . . . . . . . . . . . . 321
15 Presentation Material
323
15.1 Slide production with SLITEX . . . . . . . . . . . . . . . . . . . 324
15.2 Slide production with seminar . . . . . . . . . . . . . . . . . 330
15.3 Electronic documents for screen viewing . . . . . . . . . . . 340
15.4 Special effects with PDF . . . . . . . . . . . . . . . . . . . . . . 343
16 Letters
351
16.1 The LATEX letter class . . . . . . . . . . . . . . . . . . . . . . . 351
16.2 A house letter style . . . . . . . . . . . . . . . . . . . . . . . . . 356
16.3 A model letter customization . . . . . . . . . . . . . . . . . . 359
Appendices
A The New Font Selection Scheme (NFSS)
367
A.1 Font attributes under NFSS . . . . . . . . . . . . . . . . . . . . 368
A.2 Simplified font selection . . . . . . . . . . . . . . . . . . . . . . 370
A.3 Installing fonts with NFSS . . . . . . . . . . . . . . . . . . . . . 372