You are on page 1of 214

LaTeX Wikibook

Contents

1 Getting Started 1
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1 What is TeX? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.2 What is LaTeX? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.3 Philosophy of use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.4 Terms regarding TeX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.5 What next? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.1 Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2.2 Custom installation with TeX Live . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2.3 Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2.4 Bibliography management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2.5 Viewers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.6 Tables and graphics tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3 Installing Extra Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3.1 Automatic installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3.2 Manual installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3.3 Checking package status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3.4 Package documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3.5 External resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3.6 See Also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4 Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4.1 The LaTeX syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4.2 Our first document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4.3 Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4.4 Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
1.4.5 And what now? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

2 Common Elements 17
2.1 Document Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.1.1 Global structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.1.2 Preamble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

i

ii CONTENTS

2.1.3 The document environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.1.4 Book structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.1.5 Special pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.1.6 Notes and references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2 Text Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.1 Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.2 Hyphenation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2.3 Quote-marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.4 Diacritics and accents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.5 Margin misalignment and interword spacing . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.6 Ligatures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.7 Slash marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.8 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.9 Formatting macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.10 Text mode superscript and subscript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.11 Text figures (“old style” numerals) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.2.12 Dashes and hyphens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2.13 Ellipsis (…) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2.14 Ready-made strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2.15 Notes and References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3 Paragraph Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.1 Paragraph alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.2 Paragraph indent and break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.3.3 \paragraph line break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3.4 Line spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3.5 Manual breaks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3.6 Special paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3.7 Notes and References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4.1 Adding the color package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4.2 Entering colored text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4.3 Entering colored background for the text . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4.4 Predefined colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4.5 Defining new colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4.6 Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.5 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.5.2 Font families . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
[2]
2.5.3 Available LaTeX Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.5.4 Emphasizing text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.5.5 Font encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

CONTENTS iii

2.5.6 Font styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
2.5.7 Local font selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.5.8 Arbitrary font size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.5.9 Finding fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.5.10 Using arbitrary system fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.5.11 PDF fonts and properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.5.12 Useful websites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.5.13 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.6 List Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
2.6.1 List structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.6.2 Some special lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.6.3 Customizing lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.6.4 Easylist package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
2.7 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.7.1 Input encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
2.7.2 Escaped codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.7.3 Less than < and greater than > . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.7.4 Euro € currency symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.7.5 Degree symbol for temperature and math . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.7.6 Other symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.7.7 In special environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
2.7.8 Unicode keyboard input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.7.9 External links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.7.10 Notes and References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.8 Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.8.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.8.2 Babel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
2.8.3 Multilingual versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.8.4 Specific languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
2.8.5 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.9 Rotations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.9.1 The rotating package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.9.2 The rotfloat package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.10 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.10.1 The tabular environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.10.2 Row specification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.10.3 Spanning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.10.4 Controlling table size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.10.5 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.10.6 Width and stretching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.10.7 Table across several pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

. . . . . . . . . . . . . . . . . . . . . . . . .12. . . . . . . . . . . . . . . . . . page size and rotation of a specific page . .12. .iv CONTENTS 2. . . . . . . . . 52 2. . . . . . . . .12 Page Layout . . . . . .4 Margins .12. . . . . . . .4 A title to be re-used multiple times . . . . . . . . . . . . . . . . . . . .10. .17 Need more complicated features? . . . . . . . . . . . . . . . . . . . . . . . . . . .10. . . . . . . . . .10. . . . . . . . . . . . . . . . . . . . . .8 Partial vertical lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10. . . . . .18 References . .11. . 51 2. . .12. . . . . . . . . . . . . . . . . . . . . . . . . 58 2. . . . . . . 59 2. . . . . . . . . . . . . . . . . . 49 2.8 Page background .1 Importing external graphics . . . . . . . . . . . . . . 48 2. . . . . . . . . . . . . . . . . . .15 Floating with table . . . . . . . . . . . .10 Manual page formatting . . . . 62 2.12. .10. . . . . . . . . . 57 2. . . . .5 Packages for custom titles . . . . . . . . . . . . . . . . . . . . .1 Standard Titles . . . . . . . . . . . . . . . . . . . .12. . . . . .2 Page dimensions .3 Page size . . . . . . . . . . . . .2 The title for journal submission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 2. . .12. . . . . . . . . . . . . . . . .12 Sideways tables . . . . . . . . . . . . . . . . . . . . . . 60 2. . . .10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2. . . . . . . . .11. . . . . . 51 2. . . . . . . . . . . . . . . 50 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 2. . . 58 2. . . . . . . . . . . . .12 Troubleshooting . . . . . . . . . . . . . . . . . . . . .12. . . . 49 2. . . . . . . . . . . . . . . . . .12. . . . . . . . . . .14 Floats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Page styles . . . . . . . . . . . .13. . . . .10 Footnotes in tables . . . . . . . . .3 Third-party graphics tools . . . . . . . . . .5 Page orientation . . . . . . . . . . . . . . . . . . . . . .2 Keeping floats in their place . . . . 58 2. . . . . . . . . . . . 48 2. . . . . . . . . . . . . . . . . . . . . 52 2. . . . . . . . . . . . . . . . . . . . . . .14. .6 Margins. . . . . . . . . . . . . . . . . . . . . . . .11. . . . . . . . . . . . . . . . . . . .3 Create a custom title for a report or book . .13 Importing Graphics . . . . . . . . . . . . . . . . . . . 52 2. . . . . . . . . . . . . . 50 2. . . . . . . . . . . . . . . . . . .10. . . . . . . . . . . . . . .13 Table with legend . . . . . . . . . . 50 2. . . . . .12. . . . . . . . . . . . . . . . . . 58 2. . . . . . . . . . . . . . . . . . .11. . . . . . . . . . . 52 2. . . . 49 2. . . .4 Notes and References .14 The eqparbox package . .11. . . . 49 2. . . . . . . . .10. . . . . . . . 55 2. . .6 More titlepage examples . . . . . .10.7 Notes and References . . . . . . . . . . . . . . . . . . . . . . . . . . . .12.1 Two-sided documents .11 Professional tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Notes and References . . . . 52 2. 49 2. . . . . . . . . . . . .11. . .16 Using spreadsheets and data analysis tools . . . . . . 58 2. . . . . . . 63 . . . . . . . . . . . . 55 2. . . .11 Title Creation . . . . . . . . . . . . . . . . . . . . . 54 2. . . . . . . . . . . . . . . . . . . . .10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 2. . . . . . . . . . . . . . . . . . . . . . . . . . . .13. .14. . . . . . . .2 Converting graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Widows and orphans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13. . . .1 Floats . . . . . . . . . . 62 2. . . . . . . . . . .13. . . . . . . . . . . . . . . . .9 Multi-column pages . . 55 2. . . . . . . . . . . . . . . Figures and Captions . . . . . . . . . . . . . . . 48 2. . . . . . . . . 53 2. .11. . . . . . . . . . . . . . . . . .9 Vertically centered images . . . . . . . . . . . . . . .10. . . . . . . . . . . . . . . . . . . . . . . . . 58 2. . . . . . .12. . . . . . . 50 2. . . .

. . . . . . . . 63 2. . .15. . . .2. . .CONTENTS v 2. . . . . . . . . . . .2 Box lengths . . . . . . . . . . . . . .2 Warnings . . . . . and cleveref . . . . . . . . . . . . . . . . . . . . . . .11 Summary . . . . . . . . . . . . . . . . . . . .2. . . . . . . 64 2. . . . . . . . . . . . . . . . .9 See also . . . . . . . . . . . . . . . .6 Rubber/Stretching lengths . . . . . . . . . . . . . . . . . . . . . . . . . 68 2. . . .3 Captions . . . . .6 Wrapping text around figures . . . . . . . . . . . .1. . . . .1 Units . . . 76 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Labels and cross-referencing . . .2. . . . . . . . . .5 Notes and References . . . . . . . . . . . . .14.4 Software that can check your . . . . . . . . . . . .16. . . . . . . . . . . . . . . . . .3 The varioref package .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16. . 67 2. . . . . . . . . . . . . . . . . . . . . . .4 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Lists of figures and tables . . . . . . . . . . . . . . . . . . . . . . . . . . . .15. . . . . . . . . . . . .14. . . . . . . . . . . . . . . . . . . . . . . . . . . .16. . . . .4 LaTeX default lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16. . . . . . 64 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14. . . . . . . .2. . . . . . . 65 2. . . 74 3. . . . . . . . . . . . . . . . . . . 67 2. . . . . . . . . . . . 74 3. . . . . . 72 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 2.tex Code . . . . . . . . . . . . . . . . . . . . . . . . . .16. . . . 73 2. . . . . . . . . . . . .14. . . . . . . .8 Notes and References . . . 73 2. . . . . . . . . . . . .16. . . . . . . . . . . . 77 3. . . .7 Subfloats . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Examples . . . . . . . . . . . . . . . . . . . . . . . . .9 Custom floats . . . . .12 Notes and references . . . . . . . . . . . . .15 Hyperlinks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Usage . . . . .14. .8 Wide figures in two-column documents . . . . . 76 3. . . . . . . . . . . . . . . . . . . .5 The cleveref package . . .10 Labels in the figures . . . . . . . . . . 66 2. .14. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Error messages . . . 70 2. . . 66 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15. . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . .2. . . . . . . . . . . 77 3. 78 3. . . . . . . . . . . . . . .5 Fixed-length spaces . . . . . . .7 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . .14. . . . . . .16. . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . 76 3. . . . . . . . . . . . . . . . . . . . . . . .1 Errors and Warnings . . . . . . . . . . . . . . . . . . . . . . . . . . 76 3. .6 Interpackage interactions for varioref . . . . . . . . . . . . . . . . 74 3.1 Hyperref . . . . . . . . . . . . . 78 3. . . . . . . . . . . . . . .1. . . . . . .2 Lengths . . . . . . . . . . . . .2 Examples . . . . . . . . . . .15. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 2. . . . . . . . . . . .16. 68 2. . . . . . . . . . . . . . . . . .3 Length manipulation . . . . . . . . . . . 72 2.14. . . .8 References . . 74 3. . . . . . . . . . . . 70 2. . . . . . . . . . . . . . . . . . . . . . . . . . 77 3. . . . . . . . . . . . 67 2. . . . . .1 Introduction . . . . . . . . . . . . . . . . . . . 78 3. . . . . . . . . . . . 67 2. . . . . . . 73 3 Mechanics 74 3. . . . . . .2.16 Labels and Cross-referencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14. . . . . . . . hyperref . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 The hyperref package . . . . . . . . . . . . . . . . . . . . .3 Customization . . . . . . . . . . . . 65 2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 2. . . . . .15. . . . . . . . . . . . . . . . . . . . . . . . 64 2. . . . . . . . . . . . . . .2. . . . . . .7 Examples . . . . . . . . . . . . . . . . 78 . . . . . . . . . . 65 2. . . . . . . . .

.3.14 Plus and minus signs . . . . . . . . . . .1. . . . . 78 3. . . . . . . .1. . . . . . . . . . . . . . . . . . . . .11 fancybox . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . .6 minipage and parbox . . . . . . . . . . 86 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 savebox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 Matrices and arrays . . . . .5 Rules and Struts . . . . . . . . . . . . . . . . . . . . 78 3. . . . . . .7 Custom sectioning . .5. .4. . . .13 Color . . .4. . . . . . . . . . . .1 Mathematics environments . . . . . . . . . . .4 framed . 78 3. . . 80 3. . . . . . . . . . . . . . braces and delimiters . . . . . . .4. .9 colorbox and fcolorbox . .3 framebox . . . . . . . . .3. . . . .4. . . . . . . . . . . . . . . . . . .7 Roots . . . . . . . . . . . . . . . . . . . . . . . . .5 Powers and indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Stretched rules . . . . . . . . 79 3. . . . . . . . . . . 84 4. . . . . . .4 Boxes . . .6 Custom enumerate . . . . . 80 3. . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 LaTeX default counters . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12 Formatting mathematics symbols . . . . . . .2 Struts . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . 80 3. . . . . . . . . . . . . 80 3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 4. . . . . . . . . . . . .1.5. . . . . . . . . . . . . . . . . . . . . . 83 4. . . . . . . .3.1. . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . 81 3. . . . . . . . 82 4. . . . . . . . . . . . . . 79 3. . . . . . .3. . . . . . . . . . . . . . 78 3. . . . . . . . . . . . . . . . . . 80 3. . sections. . . . . .3. . . 86 4. . . . . . . . . .4 Operators . . . . . . . . . . 80 3. . . . . . . .1 Rules . . 85 4. . . . . . .15 Controlling horizontal spacing . . . . .2 Counter access . . . . . . . but no chapters . .1. . . . . .3. . . . . .2 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Greek letters . . . . . . . . . . 79 3. . . . . . . . . . . . . . . . .3 Counter style . . . .5. . . . . . . . . . . . . . . . . . . . . .9 Brackets. . . . . . . . .10 resizebox and scalebox . . . .2 makebox and mbox . . . . . . . . . . . . . . . . . . . . . .4. 81 4 Technical Texts 82 4. . . . . . .5 raisebox . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . 84 4. . .vi CONTENTS 3. .3 Counters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 TeX character boxes . . . . . . . . . . . . . . . . . . 83 4. . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . 83 4. . . . . . . . . . . .1 Counter manipulation . . . . . . . . 79 3. . . . . . . . . . . . . . . . . . . . . . . .8 Sums and integrals . . . . . . . . . . . . . .1. . . . . . . . 85 4. . 86 . . . . . . . . . . . . . . . . . . . 81 3. . . . . . . . . . . . .3. . . . . . 81 3. . . . . . . . .1 Mathematics . . . .1. . . . . . . . . . . 79 3. . . . . . . . . . . . . . . . . . . . . . . . . 81 3. . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 3. . . . . . . . . . . . . . . . . . . . . . . . . 83 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 rotatebox . . . . . . . . . . 81 3. . . . . . . . . . . . . . . . . . . . . . . 79 3. . . . . . . . . .6 Fractions and Binomials . . . . . . . . . . .11 Adding text to equations . . . . . . . . 83 4. . . 80 3. . . . . . . . . .1. . . . . . . . . . . . . . . . 84 4. . . . 86 4.5 Book with parts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . .1. . . .

. . . . . . . . . . . . . . . . 92 4.4 Lewis Structures . . . . . . . . . . . . . . . . . . . . .20 Notes . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . .2 Theorem counters . . . . . . . . . 91 4. . . . . . . . . . . . . . . . . . . . . . . .3. . . . .4. 91 4. . . . 93 4. . . . .7 External links . . . . . . . . . . . . .2. . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 Notes . . . . . . . . . . . .1. . . .3 Rings . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Basic Usage . .4. . . . . . . .22 External links . . . . . . . . . .1 Equation numbering . . . . . . . . . . . . . 91 4. . . . . . . .5 Ions . . .9 Changing font size .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 4.16 Manually Specifying Formula Style . . . . . . . 93 4. . . . . . . . . .11 XyMTeX package . . . . . . . . . . . . . . . 91 4. . . . . . . . . . . . . . . . 88 4. . . . . .6 Custom operators . . . . . . . 93 4.1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Boxed Equations . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . 93 4. . . . . . . . . . . . . . . . . . . . . . . . . . . 88 4. . . . . . . . . . . . . . 88 4. . .4 Page breaks in math environments . .8 Naming Chemical Graphics . . . . .1. . . . . . . . . . . . . . . . . . . . 93 4. . . . . . . . . . . . . . . . . .2. . .3. . . . . . .11 Adjusting vertical white space around displayed math . . . . . . . . . . . . . . . . . . . . .17 Advanced Mathematics: AMS Math package . . . . . . . . . . . . 90 4. . . .4 Chemical Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4. 89 4. . . . . . . . . . . . . . . . . . . . . . . 94 4. . . . . . . . . . . . . . . . .3. 88 4. . . . . . . . . . . . . 87 4. . . . . .21 Further reading . . . . . . . . . . . . 94 4. . . . . .1. . . . . . 92 4. . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 Advanced formatting . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Theorem styles . . . . . . . . . . . 90 4. . . . .2. . . . . . . 88 4. . . . . . . . . . . . . . . . .19 Summary . . . . . . . . . . . . . . . . . 93 4. . . . . . . . . . . . 91 4. . 90 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 4. . . . . . . . . . . . . . . 93 4. . . . . . . . . . . . . . . . . . . . . . . . . 94 4. . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . .1. . . . . . . . .4. . .1 Basic theorems . . . . . . . .12 Notes . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . 87 4. . . . .7 Chemical Reactions . . . . . . . . . . . . . . . . . . .3. . . . .2. . . . . . . . . . . . . . . . . . .3. . . . . . . . .18 List of Mathematical Symbols . . . . . . . . . . .3 Proofs . . . . . . . . . . . . . . . . . . . . . . . 90 4. . . . . . . . . . . . .3. . . . 95 4. .4. . . . . . . .1. . . . . . . . . . . 95 4. . . . . . . . .2. . . . . . . . . . .5 Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 4. . . . . . . . . .6 Resonance Structures and Formal Charges . . . . . . . .10 Chemical Formulae . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Advanced Mathematics . . . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . .3 Theorems . . . . . . . . . . . . 90 4. . . . . . . . . . .8 Text in aligned math display . 88 4. . . . . . . . . . .5 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . 94 4. . . .4. . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 Advanced Graphics . . . . . . . . . . . . . . . . . .2. . .10 Forcing \displaystyle for all math in a document . .1. . .3 Indented Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. .2 Vertically aligning displayed mathematics . . . . . . . . . . . . 91 4. . . . . . . . . . . . . . . . . .CONTENTS vii 4. . . . 94 4. . . . . . . . . . . . .2 Skeletal Diagrams . . . .

. . . . . . . . .2. . . . . . . . . . . . . . . . . . .7. . . . . . . . . . . . . . . . . . . 115 5. . . 112 5. . . . . . . . . . . .5 Using defined terms . . . . . . . . . . . . . . . . . . . . . . . . .3 Glosses . . . . . . . . . . . . . . . . .5. . . . . . . . . . 106 5 Special Pages 107 5. . . . . . . .In Windows with Texmaker . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 4. . . . . . . . . . . . . . . . . . . . 108 5. . . . . . . . 107 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 References . . . . . 112 5. . . 108 5. . . . . . . . . . . . . . . . . . . . . 101 4. . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . 105 4. . . . . . . . . . . . . 113 5. . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . 112 5. .5. . . . . . . . . . . . . . .5 International indices . . . . . . .2 The algorithm environment . . . . . .1 Compile glossary with xindy . . . . . . . . .7 Linguistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .viii CONTENTS 4. . . . . . . . . . . . . . . . . . . . . . .7. . . . . 101 4. . . .1 Typesetting . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . .2. . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . 109 5. . . . . . . .3 Displaying the Glossary .5 Phonological rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . .2 Syntactic trees . . . . . . . .3 References . . . 112 5. . . . . . . . . . . . . . . .5. . . . . 112 5. . . . . . . . . . 113 5. . . . . 106 4. . . . . . 103 4. . . . . . . 112 5. . . . . . 108 5. . . . . . . . . . . . . .4.4. . . . . . . . .2 Document preamble . . . . . . . . . . . . . . . . . . . . 107 5. . . . . . . . . .1 Building your document . . . . . . .1 Jump start . . . . . . .7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7. . . . . . 102 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . .6. . . . 111 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Indexing . . .7 External links . . . . . . . . . . . . . . . . . . . . . . . . 110 5. .2. . . . . . . . . . . . . . 99 4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 4.6. . . . . .4 Example for use in windows with Texmaker . . . . . 102 4. . . . . . . . . . . .4 Adding index to table of contents .3 Glossary definitions . .1. . . . . . . . . . . 99 4. . . . . . . .7. . . . .6 Source Code Listings . . . . . . . . .4. . . . . . .4 Bibliography in the table of contents . . . . . . . . . . . . . . . . . . . . . . .2 Abbreviation list . . 99 4. . . . . . . . . . .6 References . . . . 111 5. . . . . .3 BibTeX . . . . . . . . . . 113 5. .7. . . . . . . . . . . . . . . . .1 Using the listings package . . . . . . . . . . . . . . .5. . . . . . . . .4 IPA characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Embedded system . . . .5. . . . .3 Multiple indices . . . . . . . . .2. . . . . . 122 . . . . . . . .5. . . .1. . . . . . . . . . . 109 5. . . . . . . . . . . . . . . . . . 110 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Citations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Bibliography Management . .4 Defining terms . . . . . . 98 4. . . .2 Using glossaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Include glossary definitions and print glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 The minted package . . . . . . . . .7. . . . . . . . . . . . . .3 Defining glossary entries . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . .1 Using makeidx . . . . . . . . . . . . . . . . . . . . . .5. . . .2 Glossary . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . 110 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 5.1 Enumerated examples . . .3 References . . . . . . . . . . . 106 4. . . . . 109 5. . . . . . . .

. . . . 136 6. . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . .1.3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . 135 6. . . . . . . . . . . . . . . . .3. . . . . .4 References . . . . . . . . . . . . . . . . . . . . . . 127 6. . . . 129 6. . . . . . . . . . . . . . . . . . . . . .2 MetaPost . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 7 Creating Graphics 138 7. . .7 Notes and references . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . .2 The exam class . . . . . . . . .6 More Bibliographies . . . . . . . . . . . . . . . . .2 Presentations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 biblatex . . . . . . . . . .4 Reference: letter. . . . . . . . . . . . . . . .3 Teacher’s Corner . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Curriculum Vitae .4 Citation . . . . . . . . . . . . . . . . . 135 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 References . . . . . . . . . . . . . .1. . .1 Introducing Procedural Graphics . . . . . . . . . . . . . . .1 The letter class . . . . . . . . . . . . . . . . . . . . . . . . .6 Multiple bibliographies . 127 6.1 Overview . . . . . . . . . . 128 6. . . . .cls commands . . . 125 5. . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Letters . . . . . . . . . . . . . . . 139 7. . . . . . . . . . . . . . .1 europecv . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 Simple presentations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 7. . . . 136 6. . . . . . . . 137 6. . . . . . . . . . . . . . 124 5. 125 6 Special Documents 127 6. . . . . . . . . . . . . . . 123 5. . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 6. . . . . . . . . . . . . . . . . . . .3 Picture . . . . . . . . . . . . . . . .4. . . . . . . .3. . . . . . . . . . . . . . . . . . 138 7. . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . .2 The powerdot package . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Intro . . . . . . . . . . . . . . . . . . . . . .3 References . . . . . . . 135 6.2 Line segments . . . . .2. . . . .5. . . .5 Sources .5 Links . .3. . . . . . . . . . 134 6. . . . . . . .2. . . . . . . . . . . . . . . . . . . .3 Natbib . . . . . . . . . . . . .4. . . . . . . . . . . . . . . .2. . . . . . 139 7. . . . . . . . . . . . . . . . . 129 6. . .4 Circles . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . 125 5. . . . . . . . .3 Arrows . . . . . .1 The Beamer package . . . . . . . . . . . . . . . . . . . . 140 . . . . 129 6. 125 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . 125 5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 Text and formulae . . . 139 7. . . .2 Envelopes . . . . . . . . . . . . . . . . 136 6. .1 Basic commands . . . . . .2. . . . . . 138 7. . . . . . . . . . . . . . . . .CONTENTS ix 5. . 135 6. 124 5. . 139 7. . . . . .2 The limits of BibTeX styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . 136 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 7. . . . . . . . . . . . . . . . . . . . . . . . . . . .1 The example data . . . . . . . . . . . . . . . . . .5. . . . . .3. . . . . . . . . . . . . . . . . . . . . . . 135 6. . . . . . . . . . . . . 128 6. . .3 Multilingual support . . . . . . . . . . . . . . . . .2 moderncv . . . . . . .3 Windowed envelopes . . .

. . . . . 140 7. . . . . . . . . . 150 8. 140 7. . . . . . . . .7 Ovals . . . .10 Nodes . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . ellipses . . . . . . . . . . . . . .1 Loading Package. . . . . . . . . . . 140 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 \multiput and \linethickness . . . . . . . . . . . .1. .5 Drawing curved paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . .6 User-defined paths .4. . . . . . . . . . . . . . . . . . . 151 . . 140 7. . .3 Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . .5. . . .11 Examples . . . . .4 Extending the number of arguments . . . . .5. . . . . . . . . . . . . . .3. . . . . . . . . . . . . .7 Circles. . . 140 7. . . . . . . . . . . . .1. . . . . . . . . . 141 7. . . .3. . . . . . . . . . . . . .10 Command-line LaTeX . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 8. . . . Libraries . .1. . . . . . . . . . . . . .4. . . . . . 144 7. . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . .3 Syntax for Paths . . . . . . . . . . . . . . . . . . . . . . . . .9 Quadratic Bézier curves . . . . . . 142 7. . . . . . . . . . . . 141 7. . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 Special curves . . . . . . . . . .5.2 Specifying Coordinates . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . 141 7. . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 8. . . .6 Xy-pic . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 7. . . . . . . . . . . . . . . . . . . .8 Multiple use of predefined picture boxes . .2 New environments . . . . . . . . . . . 142 7. 146 7. . . .1. . . . . . . 143 7. . . . . . . 145 7. . . . . . . .tikzpicture environment . . . . . .4. . . . . . . . . . . . . . . . . 148 8 Programming 149 8. . . . . . . . . . .4. . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . . . . .8 Strings . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . .7 Creating 3D graphics . . . . . .5 Arithmetic . . . . . . . . . . . . . . . . . . . . . . 147 7. . . . 145 7. . . . . . . . . . . . . . . . 149 8. . . . . .x CONTENTS 7. . . .1. . . . . . . . . . . . . .9 LaTeX Hooks . . . . . . . . . . . . . . . . 143 7. . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . .8 Arcs . . . . .6 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 PSTricks . . . . . . . . . . . . 142 7. . . . . . . . . . . . . . . . . . . . .6 Object location . . . . . . . . . . . . . . . . . . . . 150 8. . . . . .1 Macros . . . . . . . 143 7. . . . . 149 8. . . . . . . . . . . .7 The PDFTricks extension . . . . . . . . . . . . . . . . . 151 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 8. . .1. . . . . . . . . . . . . . .4 Grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Plotting graphs . .2 Fundamental objects . . . . . . . . . . . . . . . . 143 7. . . . . . . . . . . . . . . . . . .12 The picture environment and gnuplot . . . . . . . . . . . . . 141 7. . . . . . 148 7. . . . . . .1. .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 PGF/TikZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 Catenary . . . . . . . . . . . . . . .5. . . . . 144 7. . . . . . . . . . . . . . . .5 Generic parameters . . . . . . . . . . .1 New commands . . . . . . . . . . . . . . . . . . . . . . . 144 7. . . . . . . . . . . . . . . .7 Loops . . . . . . . . .3 Declare commands within new environment . 147 7. . . . . . . . . . .4. . . . . . . . . . . . . . . . . . . .4 Drawing straight lines . . . . . . . . . . .1. . . .1. . . . . . . .4. . . . 150 8. . . . . . 140 7. . 150 8. . . . . . . . . . . . . . . .1 The pspicture environment . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5 The main document document. . . .4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 8. . . . . . . . . . . . . . . . .1. . . 158 9 Miscellaneous 159 9. . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . .2. . . . . .2 Package configuration . . . . . . . . . . . . . . 151 8.2. . . . . . . . 151 8.11 Macros defining macros . . . . . . .7 Loops . . . . 151 8. . . . . . . . . 156 8. . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 8. . . . . . . . 156 8. . 159 9. . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Doing nothing . . .2. . . . . . 157 8.2. .4. . . . . . . .6 Subversion really makes the difference . . 162 9. . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 External Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4 Registers . . . . . . . 156 8. . .3 Interchanging Documents . . . . . . . . . . . . . . . . . . . . . . 156 8.2. . . . . . . . .4. .2. . . . . . . . . . . . . . . . . . . . . . . . . .3 Including complete pdf documents or single pages . . . . . .1 Vocabulary . . .4 Themes . . . . . . . . . . . . . . . . . 163 9. . . . . . . . . . . . . . . . . . . . 151 8. . . . . . . . . . . . . . . . . . . . . .12 Notes and References . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . .1. . . . . . . .4. . . . . 163 9. .2. . .3 Creating Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Project structure . . . . . . . . . . . . . . . . . . . . . . . . . . .4 The file mystyle. . 154 8. . . . . . . . . . . . . . . . . . . . . . .1 Abstract . . . . . . . . . . . . . . . . . . . . . . . 162 9. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Catcodes . . . . . . . . . . .5 Hosting LaTeX files in Subversion . . . . . . . . . . . . . .2 Plain TeX . . . . . . . . . . . . . . . . . . . . . . . . 157 8. . . . . . .1. 157 8. . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .CONTENTS xi 8. 164 9. . . . .2 Creating your own package . . . . .6 Conditionals . . . . . . . 157 8. . . . . . . . . . . . . . . . . .3 Creating your own class . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . .10 Verbatim lines and spaces . . . . . . . 153 8. 155 8. . . . . . . . . . . . . . .5 Sectioning . . . . 164 9. .tex . .sty . . . . . . .4 Table of contents . . . . . . . . . . . . . . . . . . . . . .2. . 155 8. . . . . . . . . . . . . . . . .4 The Version Control System Subversion . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Introduction . . . . . 163 9. 165 9. . . . . . . . . . . . . . .11 Notes and References . . . . 155 8. . . . . . . . . . . . . . 156 8. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . . . . . . . . .4 Hooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Modular Documents . .3 Plain TeX macros . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . 162 9. . . . . . . . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . 152 8. . . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 makeatletter and makeatother . . . .3. 164 9. . . . . . .5 Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 8. . . . . . . . . . . . . . . . . .3 Header and footer . . . .6 Notes and References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Getting LaTeX to process multiple files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Introduction . . . . . . . . .2 Collaborative Writing of LaTeX Documents . .9 TeX characters . . . . . . . . . . . . 154 8. .1.2. . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . 154 8. . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . 166 . . . . . . . . . . . . . . . . .2. . .1. . 159 9. . . . . . . . . . .4. . . 159 9. . . . .2. . . . .

. . . .2.3 Grouping Figure/Equation Numbering by Section . . . . . . . . 175 10. . . . . . . . . . . . . . . . 173 10. . . . .3 Simplified special character input . . . . . . . .1. . . . . . . . . . . .1 Always writing LaTeX in roman . . . . . . . . . . . . 171 9. . . . . . 176 . . . . .21 Reducing the size of your LaTeX installation . . . . . . . . . . . . . . . . . . . . . . . . .2 id est and exempli gratia (i. . . 175 10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 10.1 FAQ . . . . . . . . . . . . . . . . . .11 Text stops justifying . . . . . . . . .xii CONTENTS 9. .1 Tools installation . . . . . . . . 175 10. . 176 10. . 173 10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 9. . . . . . . . . . . . .3 Convert to PDF . . . . . . . . .1. . .1. . . . . .8 Conclusion .1. . . . . . . . . . .9 Acknowledgements . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . . . . 175 10.7 Managing collaborative bibliographies . . . 169 9. . . . . . . . . . . . . . . .1 Margins are too wide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . .1. . . . . . . . . . . .2 Avoid excessive double line breaks in source code . . 175 10. . . . . . . . . . . . . . . . . . . . .19 Tables are easier than you think . . . . . . . . . . . . . . . .1. . . . . . . . . . . . . .7 Convert to image formats . . . . . . . . . . . . . . . .1. . . . . . . . . . .1. . . . . . .4 Writing the euro symbol directly .10 The proper way to use figures . . . . . . . . . . . . . . . . .1. . . . . . . . . . . .2. . . . . . . . . . . .g. . . . . . . . . . . . . . . . . . .2 Preview mode . . . . . . . . . . . .5 LaTeX paragraph headings have title and content on the same line . . . . . . . . . . . . . . 176 10. . . .1.2. . . . . . . . . . . . 170 9. . . . . . . . . . . . . . . . . . . . . . . . . . . 176 10. . . . . . . . . . . . . . . . 173 10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 10. . . . 175 10. . . . . . . . . .1. 173 10.2 Tips and Tricks . . . .5 Convert to RTF . . . . . . . . 169 9. . . . . . .13 Compilation fails after a Babel language change . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . 174 10. . . . . . . . . . . . . . . . . . . . . . . . . . 174 10.2. . . . . . . . . . . . . . .7 Manual formatting: use of line breaks and page breaks .8 Always finish commands with {} . . . . . . .15 Non-breaking spaces . . . . . . . . . 171 9. . . . . . . . . . . . . . . . . . . . . . . . . 169 9. . . . . . . . . . . . . . . . . . . .3. .17 Use vector graphics rather than raster images . . . . . . . . . . . 176 10. . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . .10 References . . . . . . . . . . . . 174 10. . . . . . 170 9. . . . . .3. . . . . . . . . . . . .1. . . . . . . . . . .9 Avoid bold and underline . . . . 168 9. . . . .3. . .e. . . . . . . . . . . . . . .8 Convert to plain text . . . . . . . . . .6 Fonts are ugly/jagged/bitmaps or PDF search fails or Copy/paste from PDF is messy . . . . . .2. . . . . . . . . . . .3 Export To Other Formats . . . . . . . . . . .1. . . . . . . . . .20 Relieving cumbersome code (lists and long command names) . . . . . . . . . .1. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3. . . . . . . . . . . . . . .4 Graphics and Graph editors . . . . .2. . . .4 Convert to PostScript . . . . . . . . . . . and e. . . . . . . . . . . . . . . .1. . . . . . . . .14 Learning LaTeX quickly or correctly . . . . . . . . . . . . . . . . . . 167 9. . . . . . . . .3. . 174 10. . 169 9. . . . . .) . . . . . . 170 9. . . . . . . . .12 Rules of punctuation and spacing . . . . . . . . . . . . . . . . . . . . . . . . . .2. . . . . . . . . . . . .6 Convert to HTML . 174 10. . 175 10. . . . . . . . . . . . . . . . . . . . . . . . 173 10. . 173 10. . . . . . . . . . . . . . . . . . . . . .3. . . . . 172 10 Help and Recommendations 173 10. . . . 173 10. . . . . . . . . . . . . . . . .3. . .18 Stretching tables . . . . . . . .1.16 Smart mathematics . . . 173 10.1. . . .

. . . . 183 11. . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20 X . . . . . . . . . . . . .12 P . . . . . . . . 184 11. . . . . . . . . . . . . . . . . . . . . 178 10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6 E . . . . . . . . . . . . . . . . . . . . .4 Sample LaTeX documents . . . .5. . .3 C . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 Hide auxiliary files . . . . . . . .2. . . . . . . . . . . 182 11.5. . . . . . . . . . . . . . . . 184 11. . . . . 183 11. . . . . . . . . . .6 New even page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4. . . . . . . . . . . . 181 11. . . . . . . . . . . . . . . .6. . . 182 11. . . .1 A . . . . . . 181 11. . . . . . . .5. . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 11. . . . . . . . . 181 11.5. . . . . . . 177 10. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 B . . . . . . . . . . . 182 11. . . . . . . .2 A . . . . . . . . . . .1 Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 11. . . . . . . . . . . . . . . . . .13 Q . . . . . . 180 11. . .5. . . . . . . . . . . . . . . . 183 11. . . . . . . . . . . . . . . . . . .5 D . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . .1 Included books . . . .3 Package Reference . . . . . . . . . . 181 11. . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14 R . . . . . . . . . . . . . . . . . . . . 182 11. . . 181 11. . . . . . . .6 Command Glossary . . . . .5 E . . . . . . . . . . . . . . . . .4 D . . . . . . . . 183 11. . . . . . . . . . . . . . . . . . . . . . . . . .1 General examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . .11 M . .5. . . . . . . . . . . . . . . 179 11. . . . . . . . . . . . . . 182 11. . . . . .2. . . . . . . . . . . . . . . . . . .5. . . . . . . . . 183 11. . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 11. . . . .5.5. . . . . . . . . . . .1. . . . . . . . . . 183 11. . . . . . . . . . . . . . . . . . . . . . 182 11. . . . 178 10. . . . . .16 T . 181 11. . . . . . . . . . . . . .5 Spell-checking and Word Counting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 # . . . . . . . . .6. . . . . . . . . .10 L . . . . . . . . . . . . . . . . . . . . . 181 11. . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 11. . . . . . . . . . . . . . . . .19 W . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 I . .7 G . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 11 Appendix 179 11. . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Wiki users . . . . . . . . . . . . . .4 C . . . . . .5 Index . 183 11. . . . . . . .4.5. . . . . . . . . . . .5. . . . . . . . . .2. . 182 11. . . . . . . . . . .17 U .8 H . . . . . . . . . . . . . . . . . . . . . . . . . .5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2 Links . . . .2 Semantics of Programming Languages . . . . . . . . . . . . . . . . . . . . . . 179 11. . . . . . . . . . 182 11. . . . . . . . . . . . . 179 11.2 B . . . . . .5. . . . . .2. . . . . . . . . . . . . . . . . . . . . . . . . . . 184 . . . . . . . .7 Sidebar with information . . . . . . . . . . . . . . . . . . . .18 V . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 11.CONTENTS xiii 10. . . . . . . . . . . . . . . . . .6 F .15 S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5. 181 11. . . . . . . . . . . . . . . . . . . . . . . . . . . .1. . . . 183 11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . .21 U . . . . . . . . . . . . 199 . . . . . .6. . . . . . . . . . . . . . . . . . . . .20 T . . . . . . . . . . . . . . . . . . . . . . 186 11. . .17 Q . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . 185 11. .14 N . . . .6. . . . . . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 O .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . and licenses 188 12. . . . . . . 185 11. . . . .6. . . .7 F . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 R . .22 V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 K . . . . . . . . . . . . . . . . . . . . . . .10 I . . . . . . . . . . . . 187 11. . . . . . . . . . . . . .6. . . . . . . .6. . .19 S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8 G . . . . . . . . . . . 184 11. . . . . .6. . . . .3 Content license . . . . . . . . . . . . . . . . . . . . 186 11. . . . . . 186 11. . . . 185 11. . . . . . . . . . . . . . . . . . . . . . . . .2 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . contributors. . . . . . . . . .16 P . . . 186 11. . . . . . . . . . . . . . . 192 12. . . . . . . . . . . . .6. . . . . . . . . . . .xiv CONTENTS 11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6. 185 11. . . 188 12. . . .6. . . . . . . . . .6. . . . . . . . . . . 184 11. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 H . . . . . . . . . . . . 184 11. . 186 11. . . . . . . . . . . . . . . . 187 12 Text and image sources. .6. . . . . . . . . . . . . . .12 L . . . . . . . . . . . . . . . . 187 11. .1 Text . .13 M . . . .6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

pre-built macros are time saving. ument when editing it. typesetting engine in 1977 to explore the potential of Within the typesetting system. tor and understood. to LaTeX. Fortu. With the release of 8-bit character with most TeX/LaTeX software distributions. more can support in 1989. con. a programming language in the sense that it supports the Since LaTeX comprises a group of TeX commands. epsilon. Many later authors have contributed extensions. its name is formatted as the digital printing equipment that was beginning to in. which LaTeX you would find it very hard to do anything else but type. called ing typographical quality that he saw affecting his own packages or styles. and automate certain repetitive tasks and help reduce user introduced errors. word of technical. unlike the complex binary and sisting of collections of pre-built macros.1 What is TeX? 1. (Donald E. Its purpose is to simplify TeX typesetting. for running on many different kinds of comput. this convenience comes at the cost of complete tents of the document. which is also the root for the document.2 What is LaTeX? LaTeX (pronounced either “Lah-tech” or “Lay-tech”) is TeX is a low-level markup and programming language a macro package based on TeX created by Leslie Lam- created by Donald Knuth to typeset documents attrac. • It can sometimes be difficult to obtain a certain look Greek for both “art” and “craft”. • Document sources can be read with any text edi- nately. TeX development has been essentially be found in the Comprehensive TeX Archive Network frozen with only bug fixes released periodically. are performed while compiling the document).1415926.1. The version numbers In LaTeX: of TeX are converging toward π .1. TeX is (CTAN). On the other hand. to represent the capital Greek letters tau. • You can concentrate purely on the structure and con- however. as TeX is an abbreviation of τέχνη (ΤΕΧΝΗ – technē). • You don't (usually) see the final version of the doc- The name TeX is intended by its developer to be /'tɛx/. and for being virtually bug free. with the final consonant of loch or Bach. ficial layout issues. document preparation systems based on TeX. requiring a significant investment of time to build custom macros for text formatting. gram such as LibreOffice Writer or Microsoft Word. and chi. reads to produce the final document.Chapter 1 Getting Started 1. not get caught up with super- design flexibility. These XML formats used with WYSIWYG programs.. La- if-else construct: you can make calculations with it (that TeX document processing is essentially programming. especially in the hope that he could reverse the trend of deteriorat.1 Introduction ages is called LaTeX. 1. TeX is renowned for being extremely with a WYSIWYG (What You See Is What You Get) pro- stable. there are certain advantages to the La- Programming in TeX generally progresses along a very TeX approach: gradual learning curve. but You create a text file in LaTeX markup. • You generally need to know the necessary com- Knuth. The fine control TeX offers over docu- ment structure and formatting makes it a powerful—and This approach has some disadvantages in comparison formidable—tool. filtrate the publishing industry at that time. Some of these are bundled books and articles. One of the most popular macro pack. LaTeX. do exist. The TeXbook) The letters of the name are meant mands for LaTeX markup. English speakers often pronounce it /'tɛk/. with a current version number of 3. port. ers. 1 . espe- tively and consistently. like the first syllable of technical. etc. setting with it. Knuth started writing the TeX cially for documents containing mathematical formulae.

JPEG. user. It is the first place where Throughout this book you should also utilise other means you should begin searching. The engine by itself only handles the syntax. ting.4 Terms regarding TeX erated easily. with additional markup. or may be found on CTAN. as LaTeX takes care of them automatically. etc. Addition- look at it is that LaTeX is a bundle of macros for TeX that ally. Knuth and LaTeX: A document prepa- In WYSIWYG applications it is often not obvious ration system by L. Distributions The LaTeX document is a plain text file containing the TeX distributions are collections of packages and pro- content of the document.code it can read. tables. This official docu- • The layout. LaTeX natively configure things. Keep in mind tributions usually target specific operating systems. tables and so on are consistent mentation is most commonly installed along your TeX throughout the document.names with a -TeX suffix. Document preparation systems • Since the document source is plain text. So the system is the combination of the language and the macros.be compiled by every engine. PNG. for learning about LaTeX. La- LaTeX way is at least not worse. fonts. Code written for TeX. or use macros developed by others.2 CHAPTER 1. we really urge you to have a look at the package documentation that causes troubles. text sizes. distributions are an easy way to install what you you want to design your document in a very specific way. The engine will determine what kind of source One of the most frustrating things beginners and even ad. fig- ures.1. Good sources are: . engine-specific code (like font for XeTeX) may not aims to carry out everything regarding document format. macros. equations.1. but some- right way.5 What next? problem before may have published their solution as a package. In the next chapter we will proceed to the installation. If you really want flexibility. flexibility regarding the document design and layout. Engines An engine is an executable that can turn your source code 1. If All in all. • Mathematical formulae can be easily typeset. Questions and documentation line heights. the TeXbook by D. it can you to typeset without having to manually fetch files and produce documents in several formats.e. then the times there are restrictions. can be generated programmat. but by using other software you can easily create PostScript. • You are forced to structure your documents cor- rectly. You that LaTeX does the formatting for you. and someone who encountered a similar 1. ically with any language. One way to TeX or ConTeXt are (mostly) not compatible.1. Let’s recap most of the terms ular possibilities of LaTeX. and it might be impossible to copy it directly for use in another Therefore before rushing on your favorite web search en- document. footnotes.1. and can be easily copied to another document. GETTING STARTED • You don't need to manually adjust fonts. If it is not exactly what you desired. • Indexes. the best doc- umentation source remains the official manual for every • In LaTeX the document structure is visible to the specific package. When grams (compilers. so that the writer only needs to care about content. citations and references are gen. TeX and derivative packages. Dis- you may have trouble accomplishing this.. and what format it can output (usually vanced users might encounter using LaTeX is the lack of DVI or PDF). You can build your own in this table. distribution. or text flow for readability. and the reference documentation. gine. supports DVI and PDF. etc. it also needs to load fonts and macros Flexibility and modularity to fully understand the source code and generate output properly. LuaTeX or other One solution to this dilemma is to make use of the mod. how a certain formatting was produced. need to use the engines and the systems you want. When searching for information on LaTeX. Lamport. and mostly the can use different systems on different engines. fonts. CTAN is a good place to find many resources regarding Then we will compile our first LaTeX file. and macro packages) that enable the source file is processed by the macro package. i. Besides internet resources being plentiful. ConTeXt. use plain TeX instead. if not better. you might also stumble upon XeTeX.LaTeX is a document preparation system based on TeX. You are likely not the first person to face some particular format- ting problem.3 Philosophy of use into a printable output format.

you don't even need to install anything. with some of them low. Download Mac- your time). fonts. mended TeX Live as the replacement.[1] bution and an editor. This erating systems are: distribution has advanced features. If this is the first time you are trying out LaTeX. computer. LaTeX requires a bunch of tools. and the LaTeX macro set. ConTeXt. which will help you in writing and 1. When you later feel that you would The easy way to get TeX Live is to use the package man- benefit from having a standalone LaTeX installation. such as default paper sizes. These. It has an easy installer that takes care of setting The recommended distributions for each of the major op.up the environment and downloading core packages. or MacTeX. can return to this chapter and follow the instructions be. • the TeX Stack Exchange Q&A. since they were programmed to be very portable. Live. For quick testing purpose *BSD and GNU/Linux you may just create a user account with an online La- TeX editor and continue this tutorial in the next chap. documents (this is probably where you will spend most of XeTeX and many other core packages. Mac OS X users may use MacTeX. Using ages should be around 200-300 MB.You may wish to install the content of TeX Live more thing. TeX 1. INSTALLATION 3 • the #latex IRC channel on Freenode.Microsoft Windows set without having to manually fetch files and configure things. structions.1. in that it is a sin- gle step installation process that provides (almost) every. In that case you will need to can be used to create LaTeX output. • MiKTeX is a Windows-specific distribution. and simple interfaces to modify • TeX Live is a major TeX distribution for *BSD. being essential. a good text editor and a DVI or PDF viewer. Since Mac OS X is also a Unix-based system. As of May 2006 teTeX is no longer actively main- allowing you to experiment with LaTeX syntax without tained and its former maintainer Thomas Esser recom- having to bother with installing and configuring a distri. TeX distribu- tions are collections of packages and programs (compil- ers. GNU/Linux. More specifically.2.pkg on the MacTeX page. it is a language.If your *BSD or GNU/Linux distribution does not have ually would result in downloading and installing multiple the TeX Live packages. such as PDFs. Distributions help the user in this way. found on the TeX on Mac OS X Wiki.2. AMSTeX. the most common distribution used to be ter. you ager or portage tree coming with your operating system. You might be interested in other programs that are not part of the distribution. Homebrew users should use the official MacTeX installer TeX and LaTeX are available for most computer plat. • MacTeX is a Mac OS-specific distribution based on TeX Live. other optional. and macro packages) that enable you to type. do not necessarily include an editor. and recommended installa. a TeX Live-based dis- tions include an attractive editor to write LaTeX source tribution supporting TeX. you'll need a TeX distribution. however.1 Distributions Live is naturally available through MacPorts and Fink. such as teTeX. settings. Further information for Mac OS X users can be They are most commonly installed using a distribution.because of the unique directory structure used by TeX forms. Acquiring them man. LaTeX. At a minimum. Further information for Mac OS X users can be found on the TeX on Mac OS X Wiki. • and the TeXample. Mac OS X the basic requirement is to have a TeX compiler (which is used to generate output files from source).2 Installation preparing TeX and LaTeX files. unzip it and follow the in- manage references if you use them a lot. and a bibliographic management program to TeX. LaTeX is just a set of macro packages built for Microsoft Windows users can install MiKTeX onto their TeX. • the TeX FAQ. These websites offer collaboration capabilities while teTeX. Optional. The core TeX Live pack- LaTeX is not a program by itself. selectively. MiKTeX. See below. such as automatic in- stallation of packages. TeX download TeX Live yourself and run the installer by hand. There is also a port of TeX Live available for Windows. you should report a wish to programs in order to have a suitable computer system that the bug tracking system. Usually it comes as several packages. . Mac OS X and Windows.net Community. fonts. In the past.

Replace it by ~/. above. Launch install-tl. root. example you may want to hide your personal macro cern. staller. You may still con- sible customizations. like an installation with a 3. or a similar space usage. First test 3.” concepts: (d) install font/macro doc tree: useful if you are a developer. Common distributions might be tedious for the it. Turn • Collections are groups of packages that can always be it off if you want to save space. installed individually. set of several big packages. You may want to change the directory options. group/others read/execute only) In a terminal write to make sure other users will have read-only access to the installed distribution.texmf to hide stallation. otherwise select it. tion to an optical disc. disk space required: 40 MB TeX distribution (i. If it is none of your con. 1.gz and ex. 2. (f) Symlinks are fine by default. ~/texmf by default.2 Custom installation with TeX Live 1. then de- will let you configure the distributions. and you often have to install (b) execution of restricted list of programs: it 300–400 MB for a functional system. You can get the network installer at figure the list afterwards. tug. (e) install font/macro source tree: same as grams and files collection. From extra packages and so on. This installer allows you to select precisely the packages you want to install. mat files are stored in user’s directory trees and ent. tlmgr. or any kind of external media. Otherwise they will be created auto- lowing. you may want to jump to the next section. Leave to default for a traditional installation on the system hard drive. Otherwise it allows the TeX engines to TeX Live features a manual installation with a lot of pos- call any external program. Schemes can only be used at installation time. user caring about disk space. Select the minimal scheme (plain only). Now the options: TeX and packaged TeX Live features hundreds of LaTeX packages. Mac OS X. Open a terminal in the extracted folder and log in as ticed at the end of the installation procedure. install or remove selecting it is better. You can install collec. TeX Live is space. Download the installer at http://mirror. MikTeX and Mac. folder which is located at TEXMFHOME. is recommended to select it for security rea- sons. Change the umask permissions to 022 (user read/write/execute. tract it to a temporary folder. For minimum of disk space usage.ctan. most of them which you will never use. the help menu: “If this option is set. Minimal installation At this point it should display We will give you general guidelines to install a minimal 1 collections out of 85.4 CHAPTER 1.hard disk. This section targets users who want fine-grained control over their TeX distribution. only for plain TeX). but very space consuming. you may have (c) create format files: targetting a minimal disk everything you need for less than 100 MB. You 5. As a result.2. Select portable installation if you install the distribu- can select only one scheme at a time. It is Picky users may wish to have more control over their in. It may matically when needed.. Most (a) use letter size instead of A4 by default: Unix with a package manager will offer TeX Live as a mostly for users from the USA. GETTING STARTED 1. Don't forget to add the binaries to your PATH as it’s no- 2. in some cases have to be re-created when new TeX Live groups features and packages into different packages are installed.e. In fact. tions at any time. • Installation Schemes group collections and packages. $ tex '\empty Hello world!\bye' $ pdftex '\empty Hello world!\bye' # umask 022 You should get a DVI or a PDF file accordingly. except for the Essential pro. It there is only one user on the system. change it if you know what you are doing. GNU/Linux or *BSD are fine. format files are created for system-wide use by the in- You will need a Unix-based operating system for the fol. . 4.org.tar. In the latter case for- work for Windows but the process must be quite differ. the best choice depends on whether then managed through its own package manager.org/ You can now proceed to installation: start installation to systems/texlive/tlnet/install-tl-unx.

tlmgr option Therefore TeX Live can be installed and uninstalled safely You can change the install options: by removing the aforementioned folders. # tlmgr install latex latex-bin latexconfig latex-fonts LibreOffice Writer). Emacs can provide a complete LaTeX edit- For instance. The TeX Live cache is usually stored in the ~/. Dedicated LaTeX editors are more useful than generic plain text editors.and Mac OS with WYSIWYG-like features.2.). You can If you installed a package you do not need anymore. Notepad). Thankfully this is rarely too cumbersome. Only use tex- config when you cannot do what you want with tlmgr. not a word processor (Microsoft Word.texliveYYYY folder (YYYY stands for the year). INSTALLATION 5 Configuration Uninstallation Formerly.texliveYYYY. spell and error are auto-resolved dependencies to LaTeX. extensible text pro- cessing system. Advanced users can program it (in elisp) Hyphenation to make Emacs the best LaTeX environment that will fit their needs. which as it contains only generated data. you may still have hyphenation cache stored also worth trying out for users of GNOME. tlmgr resolves some dependencies. on the right half of the screen[2] . Note that checking and handy macros. tlmgr option srcfiles 1 tlmgr option docfiles 0 tlmgr paper Still. you can still access the tlmgr man page with tlmgr help 1. You may safely remove this folder Gummi Gummi is a LaTeX editor for Linux. . List current installation options: • the user cache goes in ~/. phenation patters. and Linux packages are taken into account.3 Editors Installing LaTeX TeX and LaTeX source documents (as well as related files) are all text files.in almost any text editor. and can be opened and modified Now we have a running plain TeX environment. Depending on your you are going to use. TeX Live distribution is quite proper as it will not write any file out- still features this tool. TeX compilers will compiles the output of pdflatex in realtime and shows it re-generate the cache accordingly on next compilation. ously. TeX Live provides a more convenient way to do this: letter # tlmgr uninstall See the TLMGR(1) man page for more details on its us- You may still have to wipe out the folders if you put un- age. except for the cache (like font cache. GEdit is a in you home folder. table of contents view. They are all packaged individually. but recommends using its own tool side its folder.2. use ing environment with auto-completion. Note that if you have been using another TeX distribution gedit-latex-plugin Gedit with gedit-latex-plugin is beforehand. In turn beginners may prefer using it in com- If you are using Babel for non-English documents. configuration. etc. • the system cache goes in /var/lib/texmf. # tlmgr remove <package> Emacs Emacs is a general purpose. hy- instead: tlmgr. use take an evaluation copy for 28 days. The the texconfig tool from the teTeX distribution. let’s in. # tlmgr install hyphen-{finnish. TeX distributions used to be configured with By default TeX Live will install in /usr/local/texlive. You need to remove it so that the new cross-platform application for Windows. spell-checking.sanskrit} a complete set of keyboard shortcuts. but not all. If you did not install the documents as told previ- tracked files in them. You should use a text editor stall the base packages for LaTeX.g.1. You may need to install dependencies manually. config features are implemented by tlmgr. document preview and many other features. Note that as of January 2013 not all tex. because they usu- In this case you can omit latexconfig latex-fonts as they ally have autocompletion of commands. for finnish and sanskrit hyphenation patterns. Cross-platform Other interesting packages: BaKoMa TeX BaKoMa TeX is an editor for Windows # tlmgr install amsmath babel carlisle ec geometry graph. By default. Mac. It takes care ics hyperref lm marvosym oberdiek parskip graphics-def of compiling the LaTeX source and updating it constantly url to view changes to document almost in real time. (e. you bination with AUCTeX and Reftex (extensions that may need to install the hyphenation patterns for every language be installed into the Emacs program).

Linux and Mac OS. Screenshot of Kile. document structure viewer. TeXworks TeXworks is a dedicated TeX editor that is included in MiKTeX and TeX Live. a console and cus- LaTeX editor forked from Texmaker. Mac OS X and Windows. and thus to make it easier for people in their early days with LaTeX to get to what they want to do: write their documents. In addition. You can install TeXworks with the package manager of your Linux distribution or choose it as an install option in the Windows or Mac installer. The user is mostly iso- lated from the LaTeX code and not in complete control of it. TeXmaker TeXmaker is a cross-platform editor very Kile Kile is a LaTeX editor for KDE (cross platform). with the idea that a simple interface is better than a clut- tered one. Kile is based on Kate editor.3 LyX LyX is a popular document preparation system *BSD and GNU/Linux-only for Windows. How- ever. similar to Kile in features and user interface. has a quick access toolbar for TeXstudio TeXstudio is a cross-platform open source symbols. knowledge of how that works is useful also for a LyX user. LyX1. tomizable build options. It contains formula and table editors and shows vi- sual clues of the final document on the screen enabling users to write LaTeX documents without worrying about the actual syntax.10. GETTING STARTED Screenshot of Gummi. Screenshot of TeXworks on Ubuntu 12. including several popular pack- ages. and gen- erates LaTeX code based on this. as LaTeX is underlying system. and as such LyX is not a normal LaTeX editor. In addition providing a powerful GUI for editing multiple documents it has its own PDF viewer. Vim Vim is another general purpose text editor for a wide variety of platforms including UNIX. It was developed LaTeXila LaTeXila is another text editor for Linux . Kile can be run in all operating systems that can run KDE. A variety of extensions exist including LaTeX Box and Vim-LaTeX. using LaTeX code may be required. TeXworks originally came about precisely because a math professor wanted his students to have a better initial experience with LaTeX.[3] LyX saves its documents in their own markup. It provides a graphi- cal interface to LaTeX. if one wants to do something that is not supported in the GUI.6. LyX calls this a What You See Is What You Mean (WYSIWYM) approach.6 CHAPTER 1. and compiling them with many different TeX compilers.

short LaTeX notes. • ShareLaTeX. outline viewing. spell checking. Its built-in macro helps in compiling TeXShop TeXShop. performs code highlighting and the editing window is cus. version control and Dropbox in- tribution to function. which can be optionally cached lighting. laborative editing. It supports real time tion with sharing services. It includes a built-in LaTeX library. It uses multiple windows. macro support. Start writing with one click (no signup pletion support. user interface. code snippets.2. To get started without needing to install anything. It offers one-click updating of the WinShell WinShell preview and allows easy crossfinding between the code and the preview by using CMD-click along with many features to make editing and typesetting TeX source eas. and one as a con- sole for error messages. distributions side-by-side with MacTex. LEd LEd 1. It also has a Bibliography files (*. auto. figures.2. colour.Online solutions ier. Previews are available in SVG. • Verbosus is a professional Online LaTeX Editor that supports collaboration with other users and is free to use. trol system is entirely based on Git (every article is a Git repository). editor running the open-source editor \BlueLatex. multi-lingual support. editing the source. It has been designed Mac OS X-only and configured to integrate with TeX Systems such as Mi- TeX or TeX Live. Authorea’s frontend allows you to enter text in La- tomisable. customizable syntax high. easy to use online LaTeX ed- Markdown editor designed from the ground up for Mac itor with integrated rapid preview . It also includes a simple GUI for editing tables. WinEdt WinEdt is a powerful and versatile text ed- itor with strong predisposition towards creation of La- TeX/TeX documents for Windows. the unlocked version is a paid download. for LaTeX. you can use a web-hosted service featuring a full TeX distribution TeXnicle TeXnicle is a free editor for Mac OS that in. These graphical user . Archimedes Archimedes is an easy-to-use LaTeX and • Overleaf is a secure. one for the preview. bibliographies and custom styles. PNG. however it can also support other tegration. and a Mac OS native PDF.li is a real-time collaborative LaTeX MacBook’s trackpad or Magic Trackpad. live previews.4 Bibliography management TeXnicCenter TeXnicCenter is a popular free and open source LaTeX editor for Windows. required) and share the link. Archimedes’s Magic Type feature lets users in- sert mathematical symbols just by drawing them on their • publications. to-do list integration. • Authorea is an integrated online framework for the ity to execute detailed word counts on documents. Although Texpad offers a free evaluation period. code com.com is a secure cloud-based LaTeX Texpad Texpad is an integrated editor and viewer for editor offering unlimited free projects. is for Mac OS and is bundled with the PS and also in exporting the document to other mark-up MacTeX distribution. It is in (in LaTeX or MathML). Simi. Merge conflicts can easily resolved by using a built-in merge tool that uses an implementation of Windows-only the diff-algorithm to generate information required for a successful merge.like EtherPad OS X. Texpad requires a working MacTeX dis. one for languages as HTML or XML. TeX or Markdown. and PDF and HTML export preview. ified using a management system. It offers numer- ous features including templates. as well as figures. the model for the TeXworks edi. It also creation of technical documents in collaboration. Authorea’s versioning con- active development. It includes a code library for the swift insertion of code and the abil. INSTALLATION 7 (Gnome). integra.and a web LaTeX editor. and equations background colour of the editing environment.the LaTeX source to the WYSIWYG-like DVI or PDF or tor and previewer. Markdown or shared. permitting the user to select the font.1. and integration. accounts are available for extra features such as col- lar to TeXShop. • SimpleLaTeX is an online editor and previewer for completion. cludes the ability to perform live updates. options.bib) are most easily edited and mod- similar user interface to TeXmaker and Kile. Premium Mac OS with a companion app for iOS devices.

Cross-platform Practically all LaTeX distributions have a DVI viewer for viewing the default output of latex. • Skim (Mac OS X) • JabRef • Sumatra PDF (Windows) • Mendeley • Xpdf (Linux) • Zotero • Zathura (Linux) Mac OS X-only 1.7 References it to. DVI files do not contain embedded fonts and many document viewers are unable to open them. no font change). which 1. It imports references from the internet and For easier and quicker drawings. The drawback is that it will contrast in style with the rest of your document (font. If LaTeX can render beautiful tables in a dynamic and flexible manner. • PDF. and the resulting text produce a PDF file directly. size.g.2.8 CHAPTER 1. you may want to use a makes it easy to organize references using tags and WYSIWYG tool and export the result to a vector for- categories[4] . mat like PDF. but have a steep learning curve and require a lot • BibDesk is a bibliography manager based on a Bib. The graphics topic is a bit different since it is possible to write procedural graphics from within your LaTeX Screenshot of BibDesk document. TeX file.5 Viewers will partially solve this issue. etc. Other tools are better at that. Here follows a list of various PDF viewers. See Tables for more details. but you will rarely want 1. Normally LaTeX saves the final document as a . Procedural graphics produce state-of-the-art results that integrates perfectly to LaTeX (e. See Importing Graphics for more details.of time to draw. 2007) .). you will need a viewer for the files LaTeX out- puts. vert the DVI file to PDF format. or a tool like dvi2pdf to con- file can be used directly by BibTeX.dvi (Device independent file format). where information Usually you will use a LaTeX compiler like pdflatex to is entered for each reference item. Finally. Then you can view the result with any PDF viewer. [1] teTeX Home Page (Retrieved January 31.js (built-in modern browsers) • Evince (Linux GNOME) • Foxit (Windows) • Okular (Linux KDE) • Preview (built-in Mac OS X) Screenshot of JabRef. it does not aim at being a spreadsheet tool nor a vector graphics tool. and export it to LaTeX to get a beautiful table seamlessly integrated to your document. GETTING STARTED interfaces all feature a database form. Some tools have the capability to export to LaTeX. and also tools such as dvi2pdf for converting the result automatically to PDF and PS formats.2.2. The ideal solution is to combine the strength of both tools: build your dynamic table with a spreadsheet. it will not handle the handy features you could get with a spreadsheet like dynamic cells and calcu- lus.6 Tables and graphics tools LaTeX is a document preparation system.

. plaining what the package is for and how to use it.ins. To find out what other 1. you should use the CTAN search page which includes a link to Graham Downloading packages Williams’ comprehensive package catalogue. If you . This will create a . to install [3] LyX something related to internationalization. it is common to have the distribution packed into a few big packages. That bution. any one LaTeX document at the same time. Once you have straight to Step 3. The directory name “texmf” stands for “TEX and METAFONT”.ins file. and (much smaller).dtx file (which is why you must have 1. You should of course read this file first. in this case. In practice there is of the package. Installing a package installed style packages. This will extract all the files needed from the .sty extension. Dozens of these are pre-installed with LaTeX and can If you cannot find the wanted package with any of the be used in your documents immediately. The use of tlmgr is covered in the Installation chapter. but there is a configurable limit to the number that can be used inside Download the package files to a temporary directory.. a LaTeX document (which it is). or if you prefer.3. INSTALLING EXTRA PACKAGES 9 [2] Gummi With TeX Live. Extract the files Run LaTeX on the .3 Installing Extra Packages <package1> <package2> . to get the nient feature. tlmgr install <package1> <package2> .. although it There will often be a readme. As a conve. The main place to look for plicated package you wrote yourself.1. you can often find packages in repositories. names again).dtx file. Add-on features for LaTeX are known as packages. When you try to typeset a document which re- quires a package which is not installed on your system. all be stored in subdirectories of texmf/tex/latex named after each package. type loaded from. cross-references right (just like any other LaTeX docu- installed packages. you might have to install a package like texlive-lang. If style files with . What you need to look for is usually two files.. manage them. use the indexes on any CTAN server to find the is. see the manual installation.cls extension. it means one of two things: as well. There tion in a single file. have (both the ones that were installed along with your version of LaTeX as well as ones you added). no problem in having even a couple of dozen packages active.dtx to pick the package you want individually. With MikTeX there is a package manager that allows you 2. You might need to run it twice or more. See the manual installation. You must always download both files.dvi file of documentation ex- install the missing ones. 1. use tlmgr to manage packages individu- ally. • Either the package is part of a much larger bun- LaTeX will warn you with an error message that it is miss- dle which you shouldn't normally update unless you ing.txt with a brief description depends on how big each package is. There is no • or it’s an older or relatively simple package written limit to the number of packages you can have installed by an author who did not use a .2 Manual installation packages are available and what they do. MikTeX will automatically prompt to ment). one ending A package is a file or collection of files containing ex. upon the compilation of a file requiring non. With TeX Live man- [4] BibDesk ually installed.ins filename in a command window in your temporary directory. open the file in your editor and process it as if it were package you need and the directory where it can be down. tra LaTeX commands and programming which add new which combines the package program and its documenta- styling features or modify those already existing. latex followed by the . You can download updates to packages you already change LaTeXversion of LaTeX. The first is a DOCTeX file.3. The second is the installation routine are two main file types: class files with . in . so you can use the package man- ager of the TeX distribution or the one on your system to There are five steps to installing a LaTeX package. Most LaTeX installations come with a large set of pre. They should previous methods.) identified a package you need that is not in your distri.3. tlmgr remove 1. file.1 Automatic installation both of them present in the temporary directory).dtx and the other in . on your computer (apart from disk space!). skip style packages on the Internet is CTAN. Create the documentation Run LaTeX on the . But many (These steps can also be used on the pieces of a com- more are available on the net. See the automatic installation. Note down or print the names of the files created if there are If on an operating system with a package manager or a a lot of them (read the log file if you want to see their portage tree. For example. There may be ancillary files the two files are not there.

the Program Files directory and update your “local installation directory tree” is a folder and the list of File Name DataBase). and b) with the MiKTex logo. or consult http://www. then run initexmf file is a suitably-named subdirectory of texmf/tex/latex/. or is unable to do uration or other files.10 CHAPTER 1. If you tion to find out which it is. Its location depends on your system: 5. The reason for having the texmf-local directory (called For most fonts on CTAN.) where you may not ous names depending on the LaTeX distribution you use.map file for the fonts. Update font maps If your package installed any True- Type or Type 1 fonts.ommended TDS directory structure.glo you. ple.ist -o name. If you want the index to be created prop- erly. such as old shared Unix systems long in different locations. follow the steps in the indexing section. Install the files While the documentation is printing. You can also have a personal texmf subdirectory in . the foundry is public. In Windows 8 use the keyword This is done to a) prevent your new package acciden- Settings and choose the option of Settings tally overwriting files in the main TeX directories.7 or later versions. 3.not conform to the TDS.map (if you in- stalled the files in a system directory).you have to know this. too. not in the Start -> All Programs -> MikTex -> Set- directory tree containing all the pre-installed packages. • MikTeX: Run initexmf --edit-config-file form to the TeX Directory Structure(TDS). comes with every modern version of TeX and has vari.tree. • MikTeX: initexmf --update-fndb (or use move or copy the package files from your temporary di. The reason this process has not been automated widely Often there is just a . This program are a user on a shared or managed system (Unix.org/ created a .map (if you installed the tory (see http://docs.See http://www. depending on your distribution: • MikTeX: Your local directory tree can be any folder you like. This is why it is a good idea to create a sub. called texmf-local/ or texmf/.html. There are also systems where the directory for the package rather than dump the files into owner. FNDB-button (MikTex will then check For a TDS(TeX Directory Structure)-conformant system. for exam.VMS.local on some systems) is to provide a place for lo- 4. have write-access to the main TeX installation directory (Read the documentation that came with your installa. “Suitably-named” means sensible and meaningful (and probably short). tem where the user cannot write to a protected directory). I'd call the directory texmf/tex/latex/paralist. installed tion directory tree. run your TeX indexer cal modifications or personal updates. especially if you program to update the package database. TeX Live. Sometimes • teTeX. so there is no way packages or font packages will typically have several files for an installation program to guess where to put the files: to install.sty file to move. age author should have included a .glo (glossary) file has been produced. the “right place” for a LaTeX .org/manual/ files in a personal tree) or updmap-sys localadditions.html#fndb): an index.gls name. but in the case of is that there are still thousands of installations which do complex packages there may be more. Your pack- Users/username/Library/texmf/. as long as you then • TeX Live and MacTeX: updmap --enable register it as a user-managed texmf direc- Map=mapfile. texmf. new BibTeX and some Microsoft Windows systems. Packages installed by hand should al- on Windows XP through Windows 7: ways be placed in your “local” directory tree. • Unix-type systems: Usually ~/texmf/. and they may be. The “right place” sometimes causes confusion.org/fonts/fontinstall. The map updating program is usually some variant on up- dmap. For a TDS. Update your index Finally. the GUI) rectory to the right place[s] in your TeX local installa- • MiKTeX 2.tug. Linux. it means that the document contains fonts/fontinstall. user. Windows NT/2000/XP.html#id573803) --enable Map=mapfile. fpTeX: texhash you will see that a . If there are config.sty to the file that opens.idx as well.tug. For example. updmap. In Settings menu avoid your newly-installed files being overwritten when choose the first tab and click on Refresh you next update your version of TeX. After its subfolders. • web2c: mktexlsr Run the following command instead: • MacTeX: MacTeX appears to do this for makeindex -s gglo. The outermost folder should probably be that just verify by clicking 'OK'. tings.miktex. or installer has chosen not to follow the rec- misc along with other unrelated stuff. read the documentation to find out so for political or security reasons (such as a shared sys- if there is a special or preferred location to move them to. etc. For a package like paralist. --mkmaps.map conformant system. add the line “Map mapfile. you need to update the font map- • MacTeX: ping files in addition to updating the index. GETTING STARTED prefer to create PDF then run pdfLaTeX instead. espe- cially if your TeX installation is old or does not con.

The best way to look for LaTeX packages is the already fore the superseded copies in the main texmf tree. If your installation procedure ument structure and presentation. texdoc <package-name> A minimal example looks something like the following (the commands will be explained later): . texmf/doc subdirectory of your installation there should • We will create our first LaTeX document. txt. you can edit texmf/web2c/texmf. • Alphabetic catalogue • With brief descriptions 1. web pages you should read the documentation carefully. but it is your browser that presents it in its full scribes the commands the package makes available. one for every package in- stalled. $ kpsewhich tikz /usr/local/texlive/2012/texmf. not for pack. rectory. LaTeX uses a markup language in order to describe doc- tex/amsmath/amsdoc.3. To find out what commands a package provides (and thus how to use it). Additional resources form modern TeX installations should do this anyway. into a high qual- all be downloaded from CTAN. fonts. be directories full of .3. You can create it it and find out. the package (e. the documentation for amsmath is found at la.4 Basics umentation: tlmgr help This tutorial is aimed at getting familiar with the bare bones of LaTeX. LaTeX converts your has not installed the documentation.cnf yourself.3.with different colours. which de. You can usually automatically open any installed package as well as the commands that tell LaTeX how to typeset documentation with the texdoc command: the text. Before starting. although other packages (such as BibTeX and font packages) are found in other subdirectories in doc. etc. It contains the text of the document.). especially work in a similar way: the HTML is used to describe the the subsection usually called “User Interface”. You glory .g. combined with the markup. pdf.4. • Hierarchical mirroring the CTAN folder hierarchy dist/tex/plain/pgf/frontendlayer/tikz.1. Before using a package.dvi). In the • We will first have a look at the LaTeX syntax. the DVI files can source text. • Finally we will have a look at the file names and The documentation directories have the same name of types. This location is distribution-specific. 1. Your installation must be con. with any text editor.1 The LaTeX syntax name as the package. ity document. but if The TeX Catalogue Online: not.4. which generally have one or more relevant documents in a variety of formats (dvi.dvi files. etc.5 External resources figured to look in these directories first. amsmath). such as postscript or PDF. but is typi- • Then we will take you through how to feed this file cally found in: through the LaTeX system to produce quality out- Generally.1. but there are exceptions (for ex- ample.3 Checking package status • Topical catalogue with packages sorted systemati- The universal way to check if a file is available to TeX cally compilers is the command-line tool kpsewhich. All mentioned CTAN: Search. sizes. document. BASICS 11 your own login directory. ensure you have LaTeX installed on your computer (see Installation for instructions of what you 1. put. 1. It returns the path to the file. cannot just guess and hope it will work: you have to readThe input for LaTeX is a plain text file. The documents generally have the same 1. so that any updates to standard packages will be found there be.6 See Also ages. For the purpose of analogy. you need to read the documentation.3. To consult the doc.4 Package documentation will need).tex kpsewhich will actually search for files only. however. For more details on a specific package use the command-line tool tlmgr (TeX • LaTeX/Package Reference Live only): tlmgr info <package> The tlmgr tool has lot more options. most of the packages are in the latex subdi.

which makes its usage safe (no influence on the other parts of the document). In certain occasions. That’s why you need braces to specify there letter”. are treated uniformly as “space": several consecutive LaTeX groups “spaces” are treated as one. If you enter them directly in your text. Their syntax is: they will normally not print but rather make LaTeX do Between the \begin and the \end you can put other com- things you did not intend. uments all the same by adding a prefix backslash: but this feature is not commonly used and so it will be In some circumstances. For introducing a backslash in math mode. such as [space] or [tab]. also be considered as reserved characters.12 CHAPTER 1. If you mands and environments. You can also use \textasciitilde and \textasciicircum to enter these characters. The internal mechanism #$%^&_{}~\ of environments defines a group. Listings Some commands support optional parameters. a number or any other “non- \~n gives ñ.dvi/. The LaTeX compiler normalises whitespace so that whitespace characters. which will be discussed later in the Some commands need an argument. Environments form an implicit group. while the right-hand side depicts the rendered output (. you can consider using the \verb command.ps).should (almost) never be called outside of any scope. Sometimes a certain state shall be kept local. oth- figure the document appropriately. limit- A double line break (an empty line).pdf/. which are The 'less than' (<) and 'greater than' (>) characters are the added after the command name in square brackets [ ]. • They consist of a backslash \ and exactly one non- letter. A switch typed in directly for most cases. this sequence is used following two formats: for line breaking. This can be done by enclosing the part to end of a paragraph. However you must con. is no letter as argument. the current group or environment. GETTING STARTED Spaces in mathematical formulae or as accents.g. but they usually have effect on a wider part in all the fonts. accents. defines the ing its scope. See Special Characters for an explanation Most standard LaTeX commands have a switch equiva- and a workaround.tex). these characters can be used in your doc- In general. respectively. You can achieve the correct output this way: \command {} [text]. or other commands . We will tackle this issue in Special Characters. and many more can be printed with special commands as Example: . Switches have no arguments but apply on the rest of Non-ASCII characters (e. i. which has to be section on formatting. want to print these directly after some command. The other symbols erwise it will apply on the rest of the document. as they are used Anything in LaTeX can be expressed in terms of com- to give optional parameters to some commands. as [text] will be considered as an option given to \command. you can use \backslash instead. For source code. diacritics) can be the scope. like in this situation: \command [text] it will fail. user’s input (.e. of the document. Reserved Characters LaTeX environments The following symbols are reserved characters that either Environments in LaTeX have a role that is quite similar have a special meaning under LaTeX or are unavailable to commands. only visible ASCII characters (not reserved) that will not The general syntax is: print correctly. see Source Code given between curly braces { } after the command name. LaTeX provides \bgroup rules is presented below: the left-hand side shows the and \egroup to begin and end a group.e. environments can accept arguments as well. • They start with a backslash \ and then have a name The commands \~ and \^ produce respectively a tilde and consisting of letters only. LaTeX commands The backslash character \ cannot be entered by adding LaTeX commands are case sensitive. An example of applying these using braces won't be possible. lent. i. As you will see. as the end of a paragraph. mands and nested environments. If you want to insert text that might contain several par- ticular symbols (such as URIs). however. and take one of the another backslash in front of it (\\). For example minated by a space. and a single line break also yields “space”. “space” opening a line is gen- erally ignored. Command names are ter- a hat which is placed over the next letter. multiple empty lines are also treated be changed locally in curly braces. the bracket characters [ and ] can discussed in more advanced parts of the document.

This process is called compilation. ization files.tex file and creates a . When LaTeX was created.tex file and creates a Refer to multiline comments for simple workarounds. it ignores the rest of the current line. files. later PDF support was added by pdflatex. format.ps file to . PS or PDF file. . When LaTeX encounters a % character while processing an input file. exploit the process of con- version to DVI. On the other hand. which TeX is just a bunch of macros for TeX.pdf 1. there will not show up in the printed version. which is done by an executable file called a compiler. BASICS 13 Comments • pdftex compiler reads a TeX .4. since ate was DVI.dvi file to . provided there is no The output of pdflatex takes direct advantage of modern white space before the percent sign.dvi file to . But as we will see later it is possible to add a sort of ab- straction layer to hide the details of which compiler you're • tex compiler reads a TeX . affect the output of the document. the only format it could cre- mands. There are two main compilers. We will produce not true: if you try to compile a LaTeX source with a TeX the absolute bare minimum that is needed in order to get compiler you will get many errors.dvi. However.4. and pdflatex are simple scripts or symbolic links. while the compiler can handle the translation itself.4. such as PSTricks. but The general concept is to transform a plain text document reemerges when the DVI is converted to another. and all whitespace at the beginning of the next line. make sure it bears a .dvi The core LaTeX language does not have a predefined syn. which are not part of DVI.3 Compilation packages. This is distribution: the LaTeX source.tex file and creates a . emacs. . Some of those packages embed information in the DVI that doesn't appear when the DVI is viewed. and with Ghostscript: What does it all mean? • pspdf and pdfps converts the .pdf.2 Our first document If you compile a Plain TeX document with a LaTeX com- piler (such as pdflatex) it will work while the opposite is Now we can create our first document. • pdflatex executable calls pdftex with LaTeX initial- tax for commenting out regions spanning multiple lines. Comments never PDF files can be created with both pdflatex and dvipdfm.1. vim. the well known Hello World! approach will As a matter of fact. the line These compilers are basically used to compile Plain TeX. are two executables related to the previous compilers: Note that the % character can be used to split long input lines that do not allow whitespace or line breaks.pdf and vice- As we have said before. newer into a publishable format. Most of the programs should be already within your • Open your favorite text-editor.tex. all they tell LaTeX is to ignore the line. and therefore will not work with pdfla- Compilation process tex. • dvips converts the . When picking a name for your file.tex file and creates a . are common programs you expect to find in any LaTeX • Reproduce the following text in your editor. gins with a backslash (\). some output. features of PDF such as hyperlinks and embedded fonts. Notepad++. some 1. mostly a DVI. not LaTeX. using. LaTeX distribution.pdf (dvipdfm is an improved version). each of the LaTeX commands be. • Save your file as hello. Passing through DVI imposes limitations of its older format. following your operating system latex be suitable here. You would write your document slightly differently de- pending on the compiler you are using (latex or pdflatex). This is LaTeX’s way of knowing that whenever it sees a backslash.tex extension. • dvipdf converts the . reads a LaTeX . the others come with Ghostscript. reads a LaTeX .ps (postscript). and other text editors will have syntax which is a free and multi-platform software as well. Here highlighting that will help to write your files. break. versa. There is no such LaTeX compiler since La- This can be used to write notes into the input file. as with • latex executable calls tex with LaTeX initialization Supercalifragilisticexpialidocious above. to expect some com. Comments are not classed as a command.

already are not very common. • PDF needs more disk space and it is slower to cre- and produces either a DVI or PDF file. • DVI needs less disk space and it is faster to create. the blue 1.dvi. which might will be displayed.14 CHAPTER 1.dvi (1 page. Now you may view the DVI file. 5548 bytes). . This will be explained in detail in the next chapters. so here is how links. you displayed in the console will be: should choose the shortest route to reach your target for- mat. the small dark green text under the boxes represents the image formats that are supported. 1. It also supports advanced typographic fea- to coax LaTeX into compiling your input file on a text tures: hanging punctuation. If all went well. Type the command: pdflatex hello (as before. there must be all the necessary It is clearly not going to be the most exciting document fonts installed. the best way is to use only latex for a you can notice that the PDF document is bigger than the DVI output or pdflatex for a PDF output. you saw you can create both DVI and PDF document from the same source. I such as hyperlinks or animated images. so you can consider using it in the directory where hello. It supports internal and external hyper- tems there might be some typing involved. Nowa- computer. so you can consider using it for the final version of your document. It does not support any interactivity you have ever seen. pdflatex latex This means that your source file has been processed and the resulting document is called hello. although you can include it if you wish) About now. It does not include the fonts within the document. Starting from script written on hello. (eps) png.tex extension is not required) use. Therefore. the last two lines decrease the features of your document. since it is just a program that crunches away at your input files.) This way you created the DVI file. but you have to replace the LaTeX source code and the formats you can create the command latex with pdflatex: from it: The boxed red text represents the file formats. DVI viewers am assuming that you are at a command prompt. the last two lines links. Various bits of info about LaTeX and its progress through an arrow you lose some information. GETTING STARTED displayed in the console will be: pdftex tex Output written on hello. On Unix with X11 you can type xdvi foo. This is probably the most convenient way to obtain Output written on hello. Please note: this description assumes that gin kerning resulting in more flexibility available to you already have a working LaTeX installation on your the TeX engine and better looking output. converting to DVI. LaTeX itself for previewing your document while typesetting. The steps The following diagram shows the relationships between are exactly the same as before. jpg) dvipdfm document viewers for many Linux distributions are able to view DVI files. so you will not have any problem of click LaTeX into compiling your input file. which takes up Source formats 1 page and 232 bytes of space. font expansion and mar- based system. This is true. Tran- an output in your desired format anyway. portability.pdf (1 page. Any time you pass 2. but it gets a 2. but with the same source file you can create a PDF document. 232 bytes). are: Chapter Export To Other Formats discusses more about exporting LaTeX source to other file formats. (Now evince and okular.tex extension is not required. a LaTeX source.log. Tran- script written on hello. Some LaTeX ate. but it includes all the necessary fonts within installations feature a graphical front-end where you can the document.tex is stored. days it is the de facto standard for sharing and pub- lishing documents. Output formats on Windows you can use a program called yap (yet an- ps2pdf dvi2ps PDF pdf2ps PostScript DVI other previewer). Various bits of info about LaTeX and its progress bit more complicated if you want to introduce images or will be displayed. If all went well. even if it contains exactly the same information.log. PostScript only when it is necessary to print the docu- The main differences between the DVI and PDF formats ment. but we want to see it nonetheless. the text on the arrows represents the commands you have to .dvi. Type the command: latex hello (the . does not have a GUI (graphical user interface). so Generating the document if you want the document to be viewed properly on another computer. On other sys. the standard (pdf.

So to have an up- Autobuild Systems to-date table of contents. A number of programs exist to auto- data is filename. the temporary file for the table of contents as previously stated. Make filenames as short or as long as on. matically read in a TeX document and run the appropriate compilers the appropriate number of times. If you 1. Stick to lower-case let- ters without accents (a-z).4. refer to the Tips and Tricks page.4. as soon as you start working on more complex documents For example.pdf” See Document Structure and the Common Elements part for all the common features that belong to every type of document. you at which page a specific section is going to be printed.) you will soon find yourself in a maze of files with various extensions and Compressed PDF probably no clue. bibliographies. It stores temporary data into these files and use them for the next compilation. Modular document tension (somewhat similar to the conventions for a good Web URL): it will let you refer to TeX files over the Web See Modular Documents for good recommendations more easily and make your files more portable. See Special Characters and Internationalization. Therefore it’s best not to mix them. which would be useful for the table of con- PDF without any problem. ever use directories (folders) or file names that LaTeX has some nice features for most languages in the contain spaces. tents and references. so only need to run the LaTeX command once. LaTeX needs to be To circumvent this issue. 1. There is no need to re-compile if no section Compiling using only the latex binary can be quite tricky moved. Questions and Issues Ancillary files We highly urge you to read the FAQ if you have issues about basic features. $ latexmk -pdf file.1. some don't. None of these files contains unrecoverable information. others do. including bibli. ease special characters input. It means ommendations. dex.) to separate the file ex. But need to jump use ancillary files which usually have the this will be discussed in the future when it comes up. Although your operating system probably world.tex When you work with various capabilities of LaTeX (in- Note that most editors will take care of it for you. and they will only cause grief the target language. or if you want to read essential rec- The TeX compilers are single-pass processes. Some about the way to organize big projects into multiple files. operating systems do not distinguish between upper-case and lower-case letters. However. . if when the table of contents is printed before the upcoming you begin to create complex documents. same file name as the current document but a different extension. So latex → dvips → ps2pdf will usually be much smaller than pdflatex.4. Indeed the compiler cannot guess Note. you wish. You can tell LaTeX to follow typography rules of supports them. you can use the Ghostscript command: Common Elements $ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite - sOutputFile="Compressed. it cannot set the page numbers. in this instance.toc. etc. and so and tears with TeX. many LaTeX commands which executed multiple times to resolve the references. ographies and cross-references. the digits 0-9. compiling will re- generate them automatically. For the more specific questions and is- that there is no way for a compiler to jump around the sues. you need to compile the docu- ment twice.pdf” “Original. due to the simplicity of the file. For example. you may have noticed that the output PDF file is not always the same size depending on the engine you used to compile the file. and only one full point or period (.5 And what now? want pdflatex features along with a small output file size. glossaries. the hyphen (–). but strictly avoid spaces.4 Files Picking suitable filenames Non-English documents and special characters Never. BASICS 15 but for now assume you can compile in both DVI and document. latexmk can generate a PDF from most TeX files simply: It means you can delete them safely. etc. The following list explains the most common file types you might encounter when working with TeX: For a PDF output.sections.

. GETTING STARTED Macros for the utmost efficiency The full power of LaTeX resides in macros. Working in a team See chapter Collaborative Writing of LaTeX Documents. See the dedicated part.16 CHAPTER 1. They make your documents very dynamic and flexible.

the text of your document is enclosed lot of options in common. the commands Here are some document classes that can be used with The area between \documentclass{. including letters and slides. are built to be fairly generic. Other classes may have differ- between two commands which identify the beginning and ent options (or none at all).A4.. or knowledge to the reader. type of document the author wants to create.} and \be. it expects it to fol. you will probably find that A useful side-effect of marking the end of the document there are some areas where basic LaTeX cannot solve text is that you can store comments or temporary text un- your problem. Thus every input file must contain layout suitable for double sided printing on A4 paper. It then derives the typographical form of the text publishers. Others are provided separately. specified with the \documentclass command. The options have to be separated by commas. which is why they have a After the preamble. if you want a report to be in 12pt type on (where the blank line is in the example above: we'll be us. But and in various style files. Modern TeX distributions come with a large 17 . ommended to put this declaration at the very beginning.1 Document Structure Document classes The main point of writing a text is to convey ideas. The reader will un. ment class. Some packages come 2. It is rec- and will see and feel this structure much better if the typo. you TeX will never try to typeset them: need to enhance the capabilities of LaTeX. The their documents with a variety of hierarchical constructs.2 Preamble with the LaTeX base distribution. LaTeX allows users to structure we'll be happy with the standard article class for now. It is also you just have to tell it the logical and semantical structure possible to create your own. The most common options for the standard document classes You would put your text where the dots are. While writing your document. which tells LaTeX how to format your content. third party classes end of the actual document: come with some documentation to let you know. colored derneath the \end{document} in the knowledge that La- text or source code from a file into your document. who simply provide you with their own class according to the “rules” given in the document class file file. When processing an input file. graphical form reflects the logical and semantic structure Here.Chapter 2 Common Elements 2. It normally The standard document classes that are a part of LaTeX contains commands that affect the entire document.1. as is often done by journal of a text. The LaTeX distribution provides additional classes for LaTeX is different from other typesetting systems in that other documents. LaTeX needs to know the mation. but printed one-sided in draft mode. infor. The reason for marking off the end of your text is to provide a place for LaTeX to be programmed to do extra stuff automatically at the end of the document.1 Global structure which instructs LaTeX to typeset the document as an ar- When LaTeX processes an input file. Packages like making an index. Example: an input file for a LaTeX document could start with the line 2. sections..LaTeX: gin{document} is called the preamble. of the content. and to produce a low a certain structure. options parameter customizes the behavior of the docu- including chapters. Normally. This is derstand the text better if these ideas are well-structured. subsections and paragraphs. Such en- hancements are called packages. If you want to include graphics. you would use: ing this soon).ticle with a base font size of 11 points. class specifies the type of document to be created. The reason are listed in the following table: for marking off the beginning of your text is that LaTeX allows you to insert extra setup specifications before it For example.1.

and share the same structure) are let- which tells LaTeX that it’s complete and it can typeset the tered (A. etc. not subsections or subsubsections etc. you which lets you typeset in colors. and addchap are also available. It can be reset in exactly the same way as secnumdepth. etc. If you only want parts. this document. add the following line numbered. the occurs. TeX allows you to give an optional extra version of the tion within LaTeX is collectively referred to as top matter. By default it title will never be typeset. after the top matter. e. case of chapters. the curly braces. Section numbering Numbering of the sections is per- explanatory.3 The document environment All the titles of the sections are added automatically to Top matter the table of contents (if you decide to insert one).1. but before with an asterisk before the opening curly brace: the main sections of the body. heading text which only gets used in the Table of Con- Although never explicitly specified (there is no \topmat. you can fixed layout.). options is a list of keywords that trigger special features Notice that you do not need to specify section numbers. For example: As most research papers have an abstract. which you almost certainly don't want.18 CHAPTER 2. see change the value of the secnumdepth counter using the the Title Creation section. if you want to change it to “1": A related counter is tocdepth. You al.tex. author name. But if you make manual styling changes to your heading. follow the command name logical order. and also information about the authors. For example. certain commands are appropriate to different those commands by default. example a very long title. for sections. Parts get roman numerals (Part I. Part TeX to write the title automatically).g. You put the title. LaTeX provides 7 levels of depth for defining sections (see table below). so you can turn it off selectively. you would type: do not need to use \begin and \end commands to indicate which content belongs to a given block. a book has chapters but a package is pretty simple: \usepackage: an article doesn't. is set to 3. KOMA classes provide Of course. If you want to create your title freely. This ter command) you are likely to encounter the term within optional alternative heading goes in [square brackets] be- LaTeX documentation. If you want to change it into anything setting of secnumdepth would normally mean it would be else. B. where package is the name of the package and mands found in simple. \setcounter command. chapters. address. \author. Here are some of the structure com- command. COMMON ELEMENTS number of packages pre-installed. which specifies what depth Abstract to take the Table of Contents to. LaTeX will sort that out for you. if they are in effect.graph* have this “starred” version which can be used on By default. email etc. before you begin the abstract environment: If you want the unnumbered section to be in the table of contents anyway. if you omit the \date II. to use the color package. such as tents as well. This should appear in its go into the Table of Contents. You can pass several options to a package. C. The title and them explicitly. The command to use document classes. just insert the heading you want between author are usually compulsory (at least if you want La. \addpart The commands for inserting sections are fairly intuitive. for At the beginning of most documents there will be infor. Also. If you omit \maketitle. use package unnumberedtotoc [1] . 2. This command is available All the divisional commands from \part* to \subpara- for the document classes article and report. Each section in this table is a subsection of the one above it. For example. therefore. For example.. in the package. and \date commands are self. there are pre- defined commands for telling LaTeX which part of the To get an unnumbered section heading which does not content makes up the abstract. and appendices (which are just a special ways finish the top matter with the \maketitle command. All of this type of informa. fore the curly braces: A simple example: The \title. and date in formed automatically by LaTeX. you can only create a title with a numbered. and sections Using this approach. but not book. such as the title and unusual font-play. chapters and sections get decimal numbering like command. tents and any running heads. La- name. title according to the information you have provided and You can change the depth to which section numbering the class (style) you are using. each separated by a comma. giving the depth level you wish. this would appear in the Table of Con- date. .). or some special line-breaks or mation about the document itself. LaTeX uses today’s date by default. LaTeX will use the word “Abstract” as a title special occasions for an unnumbered heading when the for your abstract. It provides the command Sectioning commands which will take care of a proper header as well. “Executive Summary”. so don't bother adding curly braces after the relevant command.

i. Page numbers will inary piece of text like a Foreword or Preface. Furthermore cur- calculated.1. it is barely useful to ToC which is slightly different from the one printed in use the book class. of contents title>} in your document preamble. so they tion headings. The \phantomsection com. The \table. Depth The default ToC will list headings of level 3 and above. Page numbers will be printed in roman numerals. If the hyperref pack. For formatting paragraph indents and spacing between You can change the depth of specific section type. The com- unnumbered section heading command to start a prelim- mand resets the page numbering. \addcontentsline command. and only down to the level defined by the will be numbered 0. DOCUMENT STRUCTURE 19 If you don't want to use package unnumberedtotoc. to force extra or unnumbered section Additionally the class provides macros to change the for- headings to be included. and reproduced the next time you pro.4 Book structure after the Abstract or Summary). We've already seen how to use the optional rent chapter and section will be printed in the header. following sections or chapters are to be numbered as nism to add lines to the List of Figures or List of Tables appendices. Check the Counters chapter for a fix. but you can add extra entries with the numbering. Contents (ToC) automatically.n because there is no chapter tocdepth counter. so you need to re-run LaTeX one extra time to will be two-sided. just add the command \tableof- contents at the point where you want it printed (usually 2. described above with some additions. We will give you some advice on how to use them properly. class too: . you can be printed in arabic numerals. You can use the same mecha. You don't have to print a ToC. • The frontmatter chapters will not be numbered. Appendices can be used for the article by substituting lof or lot for toc. The levels are defined above on this type the text and leave a blank line between paragraphs. and is Com. the body of the document. doc). ofcontents command normally shows only numbered sec.[2] The commands \listoffigures and \listoftables work in ex- actly the same way as \tableofcontents to automatically list all your tables and figures. could be useful for PDF bookmarks (if you are using the hyperref package) : In order to further tune the display or the numbering of Table of contents the table of contents. Frontmatter is not supposed to have sections. matting of some places of the document. you age is used and the link does not point to the correct have to do everything by hand using \addcontentsline and chapter. It is also possible to add extra lines to the ToC. you can make use of the tocvsec2 pack- All auto-numbered headings get entered in the Table of age (CTAN. By default a book cess it. they nor. Simply down to paragraphs. For example if you use an • The mainmatter chapters works as usual. page. To change how deep the table of contents displays automatically the following command can be used in the Ordinary paragraphs preamble: This will make the table of contents include everything Paragraphs of text come after section headings. but if you want to. for instance if the appendix should be less detailed. refer to the Paragraph Formatting section.2. Section number style See Counters. you have to paste this rect place in the document. argument to the sectioning commands to add text to the If you do not make use of chapters. write: This will format an unnumbered ToC entry for “Preface” • The \appendix macro can be used to indicate that in the “subsection” style. Entries for the ToC are recorded each time you process The standard LaTeX book class follows the same layout your document. Note that this solution does not permit changing The blank line means “start a new paragraph here": it the depth dynamically.1. left and right margins will change ensure that all ToC pagenumber references are correctly according to the page number parity. If you use them. with \clearpage or \cleardoublepage can be used (see also Note that if you use PDF bookmarks you will need to add Labels and Cross-referencing): a phantom section so that hyperlinks will lead to the cor. To change the title of the TOC.e. mally go after the \tableofcontents command. The List monly used like this: of Figures (LoF) and List of Tables (LoT) names can be For chapters you will also need to clear the page (this will changed by replacing the \contentsname with \listfigure- also correct page numbering in the ToC): name for LoF and \listtablename for LoT. does not mean you get a blank line in the typeset output. the command \phantomsection in combination \markright{} (or even \markboth{}{}). command \renewcommand{\contentsname}{<New table mand is defined in the hyperref package. which paragraphs.

ISBN.stackexchange. like indices.) [2] http://tex.1. Having said that. Bibliography Any good research paper will have a complete list of ref- • The backmatter behaves like the frontmatter. Information (copyright notice. Title page [1] unnumberedtotoc 4. so it makes the list of possible top- ics quite eclectic: text style. so you simpler. glossaries and bibliographies. letting LaTeX work for you. However. LaTeX is so flexible that we will actually only skim the 2. LaTeX has two ways of inserting your refer- the same issue with section numbering. but it can be time-consuming if you are might consider using only a few. and a document that has been over-done can look and read worse than one with none at 1. spacing. the references you might use and simply link them.com/questions/20538/ what-is-the-right-order-when-using-frontmatter-tableofcontents-mainmatter 5.2. So.1. Formatting tends to refer to most things to do with appearance. If formatting Mainmatter may also refer to paragraphs and to the page layout. formatting is very important. Foot- 1. • you can store them in an external BibTeX file and then link them via a command to your current doc- Page order ument and use a Bibtex style to define how they ap- pear. Bibliography all. Table of contents 2.5 Special pages of having to deal with the physical presentation yourself. considered as an unnumbered chapter. so you need not get too carried away! Comprehensive papers often feature special pages at the end.20 CHAPTER 2. Glossary / Index surface. etc. This way you can create a small database of This is one traditional page order for books. . Dedication if any.1 Spacing dedicated part Special Pages.6 Notes and references 3. 1. Empty 2. Some subordinate chapters notes are useful for providing extra information or clarifi- cation without interrupting the main flow of text. we will focus on the customization of words and sentences 1. Preface chapter niques of the text. as you can have much more control over the pre- sentation of your document if you wish. A lot of formatting techniques are required to differenti- Appendix ate certain elements from the rest of the text. Half-title 2.2 Text Formatting 7. ences into a document: As a general rule you should avoid mixing the command • you can embed them within the document itself. COMMON ELEMENTS Only use the \appendix macro once for all appendices. Frontmatter To learn how to add a bibliography to your document. else empty 6. writing several papers about similar subjects so that Note that the special content like the table of contents is you often have to cite the same books. for these reasons. Since this is quite a complex topic. It’s order. see the Bibliography Management section. one of the purposes of LaTeX is to take away the stress 2. It is often necessary to add emphasis to key words or phrases. etc. we will give you details in the 2. Main topic for now. Nonetheless all commands are optional. List of figures (can be in the backmatter too) This section will guide you through the formatting tech- 8. It has erences. it Backmatter is also very easy to abuse.

for Manual spacing is a matter of macro writing and package initials. A backslash in front of a space generates a mally the lines are not spread. \linespread{1. (2012 list: https://www. Frenchspacing can be algorithm does not find all correct American English hy- turned off later in your document via the \nonfrenchspac. question marks or excla- you can change its value by putting the mation marks.6} for “double” line spacing. tury typewriter styles. between para- for a consistent reading. for units and currencies. since periods command into the preamble of your document. A non-breaking space between two tokens (e.tug. TeX assumes If you want to use larger inter-line spacing in a document. you can remedy the situation by using found in nineteenth century design and in twentieth cen. the extra space added at the end Internationalization. TEXT FORMATTING 21 Line Spacing ing. footnotes. or rather characters that are considered to be nor- which tells LaTeX not to insert more space after a pe. the setspace package provides the environments singlespace. Any exception from these assumptions has to be specified and \linespread{1. graphs. you would put a non. (The practice is phenation points. Hyphen- To get a straight right margin in the output. sections. marks in some languages. LaTeX in. captions): Stretched spaces To change line spacing within the document. Use after uppercase letters normally occur in abbreviations.com/questions/ of a period specifies that this period terminates a sentence 30073/why-is-the-linespread-factor-as-it-is . see a sentence. A tilde ‘~’ character gen- spread factor is 1. phenation points for several words. Although if a period follows an uppercase letter. even when it follows an uppercase letter.2. Non-breaking spaces Similarly you can insert vertical stretched space with \vfill. To set “one and a half” line spacing specified. is determined automat- LaTeX uses the '~' symbol as a non-breaking space. though it is available on most WYSIWYG document pro- cessors. so if you want to have default. etc. LaTeX serts varying amounts of space between the words. You ically by LaTeX. then none of these exceptions need be over line spacing. Additionally. For instance this may be useful in the header. This essential feature is a bit unknown to newcomers. it also inserts slightly more space at the end of correct hyphenation rules for your desired language. care must be exercised so that punctuation marks are not misinterpreted as ends of sentences.g. creation. Nor- by the author. Bringhurst’s Elements of Typographic causes the words listed in the argument to be hyphenated Style.stackexchange. breaking space before all two-parts punctuation marks.2 Hyphenation Space between words and sentences LaTeX hyphenates words whenever necessary.) Most modern typesetters treat the The command end of sentence space the same as the interword space.) document-wide. onehalf- You can insert a horizontal stretched space with \hfill in a space.org/TUGboat/tb33-1/ . words. It is known that the hyphenation riod than after ordinary character. that sentences end with periods. punctuation marks) prevents the processors from Manual spacing inserting a line break between them. It may be useful for special pages. subsections.2. See Lengths for more details.g. (If you are us- The setspace package allows more fine-grained control ing \frenchspacing. a non- breaking space cannot be enlarged. this is not taken as a sentence ending. ation rules will vary for different languages. It is against LaTeX philosophy to insert would usually use non-breaking spaces for punctuation spaces manually and will usually lead to bad formatting. The command \@ in front situations: see http://tex. It is very important The spaces between words and sentences.) The additional space after periods can be disabled only at the points marked by “-”. The argument of the with the command command should only contain words built from normal letters. but not where it is usually unnecessary (e. of sentences is generally considered typographically old. (See for example. the following commands to tell TeX about the exception. By only supports English by default. Examples: 2. al- See Lengths for more details. However. mal letters by LaTeX.3} for “one and a half” line spacing. This may not be ideal in all erates a non-breaking space. so the default line space that will not be enlarged. If the hyphenation algorithm does not find the correct hy- fashioned in English language printing. In French typography. A log of known ex- ing command. nal.2. ceptions is published periodically in the TUGboat jour- If an author wishes to use the wider end-of-sentence spac. etc. doublespace and spacing: line so that the rest gets “pushed” toward the right margin.

and an apostrophe. Example: terpret them accordingly.pdf) word. numbers or URLs may not be hy- phenpenalty=1000.3 Quote-marks ter the \begin{document} and you are using some pack- age for national language support like babel. means that if you place a hyphenation command into the preamble of your document it will influence the English language hyphenation. ac. This also becomes the only point where hyphen. The shortcuts option enables a more compressed to switch languages and quotation styles according to ba- syntax: bel language selections. and sometimes ' ¦ ' or ' | '.4 Diacritics and accents after the L: Most accents and diacritics may be inserted with direct One or more words can be kept together on the one line keyboard input by configuring the preamble properly. If you place the command af. In both cases. but in the latter case. For example adding The hyphenation hints are stored for the language that will widen the text width and reduce the amount of mar- is active when the hyphenation command occurs. For with the standard LaTeX command: symbols unavailable on your keyboard. This command is especially umlaut accent. After load. this symbol is found on the tilde key. No special characters or symbols quotes. shares the key with ' ¬ '. diacritics may be This prevents hyphenation and causes its argument to be added to letters by placing special escaped metacharacters kept together under all circumstances. adjacent to ation” to be hyphenated as well as “Hyphenation”. and it the number 1 key on most keyboards) gives a left quote prevents “FORTRAN”. the " is redefined to produce an ation is allowed in this word. with integration to citation mechanisms of- — as opposed to the words themselves which it leaves to fered by BibTeX.5 Margin misalignment and interword You can change the degree to which LaTeX will hyphen- spacing ate by changing the value of \tolerance=1000 and \hy- Some very long words.g. numbers or URLs approaching the side margin. A document which One solution for this problem is to use sloppypar envi- has a low tolerance value will cause LaTeX not to tol- ronment. “Fortran” and “fortran” from be. LaTeX treats left and right quotes as different entities. because LaTeX does not automati. it will not break 2. then the hy. mark. lead to bad spacing or it being used to produce an um- cented characters). a grave accent.22 CHAPTER 2. instead of electromagnetic-endioscopy: See Fonts for more details on font encoding. simply double the symbols. which tells LaTeX to adjust word spacing less erate uneven spacing between words.2. hyphenating words strictly. ` (on American key- through babel. guages (e. This package allows one for example LaTeX. There are two packages that can add back flexi- bility. To avoid hyphenation altogether. using " for right double quotes will either useful for words containing special characters (e. and LaTeX will in- are allowed in the argument. The apostrophe (') key is to the right of the colon/semicolon LaTeX does not hyphenate compound words that contain key and shares it with the ' @ ' symbol. visible box drawn around the content. German). For example: before the letter that requires the diacritic. .. As a result. Typical usage is as follows. a dash[1] .2. phenation hints will be active in the language activated For single quotes. \fbox is similar to \mbox.g. laut). For double ing hyphenated at all. values to achieve the desired effect. assuming the compressed syn- tax. some spaces between words may be more frequently than in documents with higher toler- a bit too large.2. ances. (Don't use the " for right dou- The command \. Also note that using a higher text width will de- crease the probability of encountering badly hyphenated Another solution is to edit the text to avoid long words. The extdash package also offers features for controlling The package csquotes offers a multilingual solution to the hyphenation of compound words containing dashes quotations. LaTeX can break and hyphenate the constituent words. but in addition there will be a See Special Characters. 2.inserts a discretionary hyphen into a ble quotes: when the babel package is used for some lan- word. You'll have to experiment with the phenated properly and move far beyond the side margin. COMMON ELEMENTS tb103hyf. ' ` ' is left of the ' 1 ' key and cally hyphenate words containing special characters. The right quote is also used for apostrophe in LaTeX This command typesets the dash and then subjects the without trouble. constituent words to automatic hyphenation. For left bottom quote and European quoting style you ing the package: need to use T1 font encoding enabled by: one should write. ' gives a right. boards. This gin overruns. The example below will allow “hyphen. On British keyboards. but long words will be placed properly. the penalty for hyphen- ation can be set to an extreme value: 2. The hyphenat package supplies the \hyp command.

2. This is a similar problem to non-hyphenation of words Many typographers prefer to use titling figures. The use of the / character in LaTeX should be restricted to units. Another solution is to use the cmap package. when they appear in tables.2. 2. One way to times called lining figures. and other font.10 Text mode superscript and sub- help the reader to interpret the ligatures: script Sub and superscripting can be done quite easily using \textsubscript{} and \textsuperscript{}. fontspec package allows for standard ligatures to be See Macros for more details.2.some later stage that you want to use some visual rep- bility. textcomp also al- lows you to use decimal points. you may adapt the previous code listing to . commands.6 Ligatures 2.2. commands like this.2. etc. This combination can be made into a new Some fonts do not have text figures built in.11 Text figures (“old style” numerals) A word after / or \slash is not automatically hyphenated.[2] the slash mark (if needed). because they work in opposition to tures can be prohibited by inserting {} or.text figures from the currently-selected font. within \oldstylenums{}. some- with a dash described under Hyphenation. ackage{textcomp} in your preamble. LaTeX allows this usage through the \old- this. which will 2. Liga. age fixltx2e. The hyphenat package includes an package attempts to remedy this by effectively generating \fshyp which will add a hyphen after the slash like “input/. resentation of danger other than \textit. paragraph. such as “input/output” should be typeset as “in.7 Slash marks The normal typesetting of the / character in LaTeX does not allow following characters to be “broken” onto new lines. which often create “overfull” errors in output (where letters push off the margin). Words that use slash Note: A LaTeX version from 2015 or later.9 Formatting macros Some letter combinations are typeset not just by setting Even if you can easily change the output of your fonts the different letters one after the other. The \DisableLigatures from the microtype package can dis.2. if this does the basic idea of LaTeX. identifying all the oc- Note that this will also disable ligatures such as "--" to currences of \textit and then figuring out for each one "–". see Fonts. TEXT FORMATTING 23 2. such as “mm/year”. turned off as well as fancy swash ligatures to be turned on. These can be set to use text figures by placing some code in your preamble: To change the font family. when numerals are inter- have both a line break and automatic hyphenation in both spersed with full caps. or the pack- marks. {\kern0pt} between the two letters in question. and visual markup of your document. which should not be broken over multiple lines. which is to separate the logical not work.This approach has the advantage that you can decide at able ligatures in the whole document to increase accessi. if you use the same font changing command in several Here is an example: places in order to typeset a special kind of information. emphasize text. properly formatted dollar signs. 2. the other reason. \slash includes a penalty to make a line break there stylenums{} command: less desirable. One common use for text figures is in section.8 Fonts and page numbers. and words is when they appear in equations. Put \usep- output” if the line breaks there. using text figures else- Both / and \slash can be used with a zero \hspace like where. search for "finally” wouldn't find the string "finally”).2. "---" to "—".Should you use additional sectioning or paragraphing related issues. is needed to use text-mode subscripts in all put\slash output”. which allow the line to “break” after contexts. you're better off not using explicit using special symbols (like "ff"). etc. but by actually using those commands.2. the textcomp slash macro if desired. without having to wade through your document.2. This means that This might be necessary with words built from two words. called ligatures. whether it was used for pointing out danger or for some If you are using XeLaTeX and OpenType fonts. you should use \newcommand to define a “logical wrapper Ligatures can interfere with some text-search tools (a command” for the font changing command.

A sequence of three dots is known as an ellipsis. you can use the \textellipsis command class that you use. the first paragraph after a heading follows the only a little space and are set very close to the preceding standard Anglo-American publishers’ practice of no in- letter. will reset the \thepage com- mand back to the original.14 Ready-made strings Whitespace in LaTeX can also be made flexible (what Lamport calls “rubber” lengths). Use \hyp{} macro from hyphenat package instead of hy. It is primarily used for formatting text in floats or for more exotic documents. listed are for use within other environments. For whatever rea- The names for these dashes are: ‘-’(-) hyphen . The commands tween lines. LaTeX knows four kinds of dashes: a hyphen (-).2. you can use the command \justi- 2. p (paragraph) columns in tabular. \pagenumbering{arabic}. i. these characters occupy By default. This will set paragraph indents to 1cm: 2.. In book printing. e. you can use at the beginning of the paragraph.24 CHAPTER 2. 2.3. Therefore.1 Paragraph alignment dashes. which is commonly used to indicate omitted text. ‘---’(—) em-dash and ‘ − ’(−) minus sign.All text between the \begin and \end of the specified en- phen if you want LaTeX to break compound words be. be sure to reinstate 2.3.2. or a minus sign (−). However.com/questions/1013/ how-to-typeset-subscript-in-usual-text-mode Note This page uses material from Andy Roberts’ Getting to grips A subsequent use of the \pagenumbering command.2 Paragraph indent and break a comma or a period takes the same amount of space as any other letter. The size of subsequent paragraph indents is three dots. You can ac- cess three of them with different numbers of consecutive 2. For exam- The commands \textendash and \textemdash are also used ple.son. to produce en-dash (–).g. the beginning .12 Dashes and hyphens academic writing.stackexchange. and also La- have different purposes: TeX command equivalents. flush with both the left and right margins. Instead. and em-dash (—).such as extra vertical space inserted before a paragraph setting special text strings: \parskip can have a default dimension plus an amount of expansion minus an amount of contraction. Thus. you can [1] hyphenat package documentation. \setlength command.2. This is useful on pages in complex documents where not every page may be an exact number of fixed-height lines long. The de- is a special command for these dots.13 Ellipsis (…) fying from package ragged2e. en dash (–). [2] http://tex. there are three environments at hand. They graph. so some give-and-take in vertical space is useful.vironment will be justified appropriately. On a typewriter. respectively.3 Paragraph Formatting your \myThePage definition from the code above: Altering the paragraph formatting is rarely necessary in 2.e. If you want to indent the beginning of every section. this will 2. em dash (—). The fourth sign is actually not a dash at all—it is the mathematical minus sign: Paragraphs in LaTeX are usually fully justified.2. you cannot enter ‘ellipsis’ by just typing dentation. as the spacing would be wrong. It is possible to override it by using the which allows the spacing between the dots to vary.15 Notes and References only have an effect when \parindent is not set to zero. ‘--’(–) en. if you use the \pagenum- bering command in your document. with LaTeX with permission from the author. if you really need to disable one of the above commands locally (for example because you have to use some broken package). COMMON ELEMENTS include them as well. You specify this in a \setlength command like this: If you want to indent a paragraph that is not indented. there determined by a parameter called \parindent. p3 use the indentfirst package: once loaded. It is called \ldots: fault length that this constant holds is set by the document Alternatively. should you wish to alter the justification of a para- dash . Obviously. This means that values There are some very simple LaTeX commands for type.

yet not completely ment can be adjusted by placing a font size command be- equivalent syntax: fore \begin{verbatim}. breaks included. which will specify the line spac- paragraphs in order to make them clear. \be- To indent subsequent lines of a paragraph. as it writes the following text next to the title. Any oth- Simply adding an empty space will do it: ers will be output. All spaces ticle/book. if you decide to set the indent to blespacing. Here is an line break with \\.2. or use ConTeXt or PlainTeX. while making adjustments to the spacing of ing. However. If you use the verbatim en- place. the package provides the following tered in a similar fashion as above.3.6 Special paragraphs 2. More details on manual spaces between paragraphs (such as \bigskip) can be found in Lengths.3 \paragraph line break Verbatim text There are several ways to introduce text that won't be in- Default style for \paragraph may seem odd in the first terpreted by the compiler. This package provides the commands \dou- Be careful. Controlling the breaks should be reserved to macro and To change the indentation of the last line in a paragraph. you can use . If this is a problem. PARAGRAPH FORMATTING 25 of any chapter/section is indented by the usual paragraph 2. To change line spacing in the whole document use the To create a non-indented paragraph. The page breaks are covered in Page Layout. then it means you will need a vertical space between stretch{baselinestretch}.environments in order to change line spacing within the eter is used elsewhere too. this may See the section on customizing lists for information on be changed with the \hangafter command. Any LaTeX used. command will be ignored and handled as plain text.3. break. such as in lists. use the TeX command \parfillskip. If you want both indent and • singlespace: normal line spacing. as the first command of the paragraph. want to use the style of having no indentation with a space between paragraphs. Note: once in the verbatim environment.g. The space be. this param. which is also covered in Text Format- not with a sectioning command. so they don't get too far apart. This space is in ad- should avoid manual breaking as much as possible. follows. use • spacing: customizable line spacing.3.is used. you can use command \linespread covered in Text Formatting. Furthermore. for it dition to the indentation added by \parindent and \hangin- could lead to very bad formatting. use the TeX gin{spacing}{\baselinestretch} . which could be al. use a class other than the traditional ar- commands are processed as if by a typewriter. which means document but not document-wide: you run the risk of making various parts of your docu- ment look very untidy by changing this setting. however. and the text is dis- class in use is really not the way LaTeX is intended to be played in an appropriate fixed-width font. dent. Hacking of the and new lines are reproduced as given. you can use the \usepackage{setspace} in handy when you start a document with body text and package. (While the default behaviour is to apply the hanging indent after the first line. The TeX commands \leftskip and \rightskip add addi- 2. al- lowing the formatting for subsequent paragraphs to differ LaTeX takes care of formatting. package writers. Here follows a quick reference. This might come Alternatively. If vironment. the only com- mand that will be recognized is \end{verbatim}.ing for all sections and paragraphs until another command tween paragraphs is held in \parskip.. 2. If you add a manual is ideal for typesetting program source code. and you may encounter a lot of frustrating issues.3.5 Manual breaks tional space to the left and right sides of each line. which does • onehalfspace: line spacing set to one-and-half spac- this for you. \singlespacing and \set- zero. The font size in the verbatim environ- Alternatively you can use the shorter. \onehalfspacing. LaTeX will complain that example: There’s no line here to end.) An example how to change the line spacing in lists. You from the overall document margins.3. e. If you • doublespace: lines are double spaced. \end{spacing}. command \hangindent. This Anyway. let’s analyse the problem.4 Line spacing indentation. use the parskip package. ting. lists and other structures which use paragraph spacing. everything input between the begin and end you do not like it..

The extra functionality it provides is that it can add line numbers along side the text. you can define a \comment{} command. When using this command through the hyperref package. will show this URL exactly as typed (similar to the \verb Alternatively. remember to add \usepack- the \verb command: age{moreverb} to the document preamble. don't need to use the whole environment. This approach is really time-consuming if you want to insert For more control over formatting. so it may work better to use slashes and full stops. \verb will print verbatim all the text after it until it finds the next delimiter. the only difference is that verbatim text is packages provides the \url command. which means every line will If you just want to introduce a short verbatim phrase. but you can use any character you like Multiline comments except *. not in plain LaTeX+ dvips). change the style. you be numbered). like math for example. which provides a Verbatim envi- ment that you want to improve later. unless you're using ronment (note the capital letter) which lets you draw a an editor that automates this process. It was designed for Then. however. but the \url command also performs a hy- adding the following to the document’s preamble: phenless break at punctuation characters (only in PDFLa- TeX. bered lines (the default is 1. how URLs are displayed to the normal The typical use is . so it understands their syntax and will never This approach can. so you cannot put anything you want in it is not linked to the web when using only the url pack. Bear in mind. however. as will using other non-URL-valid characters. comment out all the rest of the line after itself. Alternatively. the only way LaTeX allows you to add will print \textbf{Hi mate!}. will fail. while the comment is typesets URLs.) A more robust way of making the TeX engine skip some You can put the following code into your preamble to part of the source is to use the TeX \iffalse-conditional. age. which properly introduced within the document. To Listing environment This is also an extension of the write equations within the alltt enviroment. you can use the command \normalfont to get back the normal font. that spaces are forbidden in URLs. to comment out text. The mandatory first line ar- that the standard font has no bold TT font. and it can use an environment called comment that will comment even include entire external files. you rule round the verbatim text. by command). only at the document. The command: \be- When using \textbf{} inside the alltt enviroment. instead of the usual $. COMMON ELEMENTS the alltt package instead. age. Another drawback is that content is still parsed and pos- the URL is “clickable” in the PDF document. to be loaded in the pream- even have typographic effects inside the Verbatim en- ble as usual: vironment. Here is an example: To use verbatim in beamer. that will should have on text. For example. The optional step is the step between num- after \usepackage{alltt}. for example: just dropped. so using spaces in \url arguments Then if you supply only one argument to \comment{}. simply do something like this: Web URLs. out everything within itself. produce unwanted spaces in break midway through an unpunctuated word. (Alternately pdfborder = {0 0 0} might work if the four zeroes do not.(such as LaTeX commands). you can use verbatim environment provided by the moreverb pack- \( and \) to enclose them. the frame needs to be made Note that this won’t work inside complex environments. Also when using the hyperref package. change the font size.26 CHAPTER 2. note gin{listing}[step]{first line}. You may be wondering. but you have To use this environment. to remove the border placed around a URL. and can use the verbatim package. ignoring the effect \textbf comments is by using the special character %. the code: As we have seen. however. The first character following \verb is the delimiter: here we have used "+". you can try long comments or just comment out a part of your docu- the fancyvrb package. whereas it sibly expanded. fragile: \begin{frame}[fragile] . providing an environment with font: the same name: See also Hyperlinks Remember to add \usepackage{alltt} to your preamble to use it though! Within the alltt environment. It can also be used in conjunction with the fancybox package and it can add reference line numbers (you can also use the comment package instead) you can (useful for chunks of data or programming). insert pdfborder = {0 0 Skipping parts of the source 0 0} inside the \hypersetup{}. Txtfonts has gument is for specifying which line the numbering shall bold fonts: just add \renewcommand{\ttdefault}{txtt} commence. this has the desired effect without producing extra spaces. why should I load a package called verbatim to have the pos- sibility to add comments? The answer is straightforward: commented text is interpreted by the compiler just like Typesetting URLs One of either the hyperref or url verbatim text.

imported. such as poetry. white. 2. the same 16 base colors as used in are discussed in the following sections . red.2.4 Colors then: There is also \fcolorbox to make framed background Adding colors to your text is supported by the color pack. magenta. It will work until the end of the current TeX group. and you will need to add your own quota. \\. abstract which gives the reader a quick overview of what to expect. where declared-color is a color that was defined before by verse is for quotations where line breaks are important. 2. and new lines within a stanza are indicated using the newline command. you can use the one you prefer. either margin.2 Entering colored text quotation for use with longer quotations.3. then you may also want to look at ferent types of quotations. The dvipsnames allows you access to more col- ors. lightgray. lime. teal. text If the background color and the text color is changed. or a series of small quotes. The initialization of “table” allows colors to be Quoting text added to tables by placing the color command just before the table. orange. the color package must be let. vio- To make use of these features.3 Entering colored background for the with LaTeX with permission from the author.If you would like a color not pre-defined. one can write: but these should be available on all systems.4. new stanzas are created Another possible way by with a blank line. You can change the background color of the whole page by: 2. HTML. cyan. The \usepackage is obvious. yellow. green. they have small differences and they are aimed for dif. blue. gray.1 Adding the color package black. All of them are indented on adding the x11names to the initialization section as well. There may be other pre-defined colors on your system. Alternatively. brown.4. The package loaded here is the xcolor package. of more than one paragraph. then all sub. because it indents the first line of The simplest way to type colored text is by: each paragraph. this offers more than 300 colors. The provided environments sure your xcolor package is the most recent you can down- are: load.2. The predefined color names are 2. or CMYK.4 Predefined colors ored. text background. Using this package. These options of the default colors. but you need to make tion marks if you want them. you can use one tional commands like usenames allows you to use names of the 68 dvips colors. separated by blank lines. or define your own. You can choose from predefined colors or define your own colors using RGB. darkgray. Hex. you can set the font color. COLORS 27 The \iffalse-conditional is always false. Once in.want.7 Notes and References This page uses material from Andy Roberts’ Getting to grips 2. quote for a short quotation.4. purple. LaTeX provides several environments for quoting text. The difference between \textcolor and \color is the same as that between \texttt and \ttfamily. \definecolor. olive. but the initialization of addi. pink.4.color in yet another color: age. sequent lines are indented until explicitly separated For example: with \\. If you need more colors. another 64. See Document Structure. or page background.4. The \color environment allows the text to run Abstracts over multiple lines and other text environments whereas the text in \textcolor must all be one paragraph and not In scientific publications it is customary to start with an contain other environments. Mathematical formulas can also be col. and svgnames allows access to about 150 colors. If a line that will switch the standard text color to the color you takes up more than one line on the page.

include usenames and dvipsnames options when defining the document class. have an alternative syntax specifying the model in square brackets. follow the following example. you may colors as arguments. which is useful. following this scheme: Smaller. the colors are defined from their respective rgb / hsv / hexadecimal values. and cmyk. and the color specification in curly braces. RGB. but sometimes it is convenient to directly use a color with- If the predefined colors are not adequate. The package colorspace ex- To define a new color. of gray. and is one tor tool. such as the listings package. Creating / Capturing colors (Reason: do so in the preamble. tends xcolor to provide real spot colors. web pages.4. To go around it. • The xcolor manual If you loaded the xcolor package.6 Sources code chunk. HTML.3) percent black and (100-30) percent declare the xcolor package before that. COMMON ELEMENTS The 68 standard colors known to dvips The first specifies 20 percent blue and 80 percent white. etc.28 CHAPTER 2. ((100-20)*0. • The color package documentation . not work. TruMatch or Toyo). • Apple Macs: Hex Color Picker for creating custom • color-spec is the description of the color colors and the built-in DigitalColor Meter for cap- turing colors on screen. Method Image processing suites like the free GIMP suite for Linux/Windows/Mac offer color picker facilities to cap- You need to include the xcolor package in your preamble ture any color on your screen or synthesize colors directly to define new colors.5). otherwise it will green. the green to one half (0. Using color specifications directly 2. To achieve this.4.3) percent option. say: maximum. you can call it as you in repositories) like • Microsoft Windows: The open-source Color Selec- • model is the way you describe the color. you can define colors upon previously defined ones. in an argument of another package that supports ument. you may wish out naming it first.) want to play around with rgb values to create your own custom colors. \color and \textcolor to define your own. Alternatively. the second is a mixture of 20 percent blue and 80 percent Invoke the package with the usenames and dvipsnames black. In the abstract.5 Defining new colors Normally one would predeclare all the colors as above. so that you can already refer to them in the preamble. rgb. by setting the red to the with. free utilities also exist: where: • Linux/BSD: The gcolor2 tool (usually also available • name is the name of the color. They usually re- Examples fer to pre-mixed inks based on a swatchbook (like Pan- tone. Color Models • Online utilities: See here for a Wikipedia article with several external links Among the models you can use to describe the color are the following (several more are described in the xcolor manual): Spot colors Spot colors are customary in printing. They are defined which defines orange for you. and the last one is a mixture of (20*0. For example: Place Define the colors in the preamble of your document. pictures. If you are using tikz or pstricks package you must blue. for in. and the blue to the minimum: The following code should give a similar results to the last 2. You may want to use colors that appear on another doc- stance. xcolor also feature a handy command to define colors This above syntax may result in an error if you are using from color mixes: beamer with tikz.

5. preamble) like the following assignment: Originally TeX was conceived to use its own font system.\usepackage[scaled=0. tex. Standard tex compilers will let you use other fonts. they are required. sans serif (sf) and monospace (tt) (see Typeface for more Serif Fonts details). It is a very complex matter in typography. and the most popular font systems as of this day are switch: Truetype font (ttf) and OpenType font (otf). FONTS 29 2.). three families plus the math fonts. Here are some common exam- ples. are often used to embed bitmap fonts.5 Fonts ables: Fonts are a complex topic. Below are some fonts which are installed by default. Second specify the new default family if it is not rm. Those families can be grouped into three main categories: roman (rm) or serif.5. The three families are defined by their respective vari. there are many ways to specify and control fonts. the Bera Mono (Bit- etc. • \ttdefault The default family is contained in the \familydefault vari- 2. Computer Mod. Typewriter Fonts Furthermore. MetaFont is internally a quite complex font sys. The default is defined (in the The digital fonts have a long and intricate history. This will turn all the part of the document using the de- MetaFont. There are many different font types. If you • \rmfamily want/have to stick with the standard compilers. Mathematical fonts is a more complex matter. such as em. so it is highly Stream Vera Mono) and LuxiMono fonts were designed discouraged to change fonts individually rather than the to look good when used in conjunction with the Com- whole family. Type3 is a superset of Type1 come with a package that will take care of defining all and has more functionalities from Postscript.5. and it is meant to have one of the three aforemen- tioned variables as value. In the TeX world. With mod- ern TeX compilers such as xetex and luatex it is possible • \normalfont to make use of such fonts in LaTeX documents. For common documents. Each font family comes with the default de- sign which falls into one of those categories. 2. In LaTeX. There are many font families e.5. ern.g.2 Font families tug. the afore- mentioned font types must first be converted and made • \sffamily available to LaTeX (e.g. and Courier. and Font encoding are • \sfdefault really needed. Fonts may ing or printing a document. only • \rmdefault Font families. in which case you do not have to load any package. which is Computer for TeX and friends is called Computer Modern. which can easily be seen when zoom. high quality fonts are scalable. converted to Type1 fonts). Bitmap fonts are raster graphics. and have a wide range of Changing font families usually works in two steps: typographical fine tuning capabilities. Below is an example[1] that demonstrates how to change It should be noticed that fonts get generated the first time a specific family. First specify which family you want to change (rm. You can do it by your- bedding raster graphics. Fonts in each family also have different properties (size. puter Modern serif font. such as PostScript sf or tt). Type1 are outline fonts (vector graphics) which are commonly used by pdf. Computer Modern Ro- man is the default font family for LaTeX. Knuth.fault variable should not be confused with their respective tem. 1. These Modern Sans Serif if you did not change the default font.dk/FontCatalogue/. weight. 2. Families are meant to be consistent. Arial. it Sans Serif Fonts is interchangeable among them. Type3 fonts self. The • \ttfamily external links section below has some useful resources. The other sections are more useful to macro writers or for very specific needs. Emphasizing text.85]{beramono} . Times. 2.1 Introduction able. however. shape. The default font family fault font to the default sans serif. hence the long compilation time. designed by D. and usually have very poor quality.2. Type1/Type3 fonts and bitmap fonts.3 Available LaTeX Fonts [2] To choose a font of your liking. please visit http://www. The three default family font variables and the \familyde- However.

which are Computer Modern-like fonts with a page. You will need trying to find when reading the text. and optically scaled font sizes.5.4 Emphasizing text CB bundle contains fonts in LGR encoding for the com- position of Greek text. So it is possible to build a new font family by spec- ifying the font styles of different font families. it will be reverted to the upright font. For lmod- and so on.g. The fontenc package tells LaTeX what font encoding to 2. the glyph. the en. The LH font set contains letters necessary to typeset doc- Mathematical Formula Fonts uments in languages using Cyrillic script. • Extracting ('e. Note that changing the font encoding will have some re- Text may be emphasized more heavily through the use quirements over the fonts being used. the italic version. shapes. loaded automatically if you use T1 encoding. several 8-bit CM-like group for cursive fonts. itly with \textit{text}.All this is not possible with OT1. they will get version. not in ASCII. simplest way is to use the \emph{text} command. and bold). or font properties. Because of the large number of Cyrillic glyphs. various weights and heights. many from ASCII. encoding contains letters and punctuation characters for most of the European languages based on Latin script.30 CHAPTER 2. The default Com- of boldface. It is possible to load A character is a sequence of bytes. to say nothing about letters of non-Latin alphabets. Italics may be specified explic. special characters. it should be used sparingly. T2B.Computer Modern Super (cm-super) or Latin Modern erally read before any other text in a paragraph or even on (lmodern). • Besides. The following table lists the commands you will need to such as Greek or Cyrillic. Bold text can Type3 font such as the Type3 EC.6 Font styles • It stops the automatic hyphenation from working in. and X2. files. you will need to load the package after the T1 en- coding has been set: Upon compilation. There is nothing to change in your document to use CM tations following the used font. it is quite frequent place of italics when using sans-serif typefaces to provide (depends on your TeX installation) that tex chooses a a greater contrast with unemphasized text. they are arranged into four font encodings—T2A. vided some workarounds for hyphenation of words with coding of the original Computer Modern TeX text fonts. When accented characters are required. also known as font styles. So the character 'a' has different represen. Extended Cork (EC) fonts in T1 to the roman family.they provide fonts of CM families in all weights. which is what the reader sees. Font encoding is set with: where encoding is the font encoding.' copy paste) the umlaut 'Ä' via a PDF viewer actually extracts the two characters '"A'. TeX creates them by combining a normal character with an accent. which Another advantage of using new CM-like fonts is that usually italicizes the text. text extraction and searching). for example the upright Super fonts (assuming they are installed). be generated with the \textbf{text} command. It may also be used in T1 support. besides typographic issues. COMMON ELEMENTS Cursive Fonts Since LaTeX has no generic family To overcome these shortcomings. fused with its representation.5. T2C.g. this approach has some caveats. access the typical font shapes: .Each family has its own font characteristics (such as italic side words containing accented characters. to change the font encoding of your document. but fonts like lmodern. The default LaTeX font encoding is OT1. these fonts are usually assigned font sets were created. ern. the improve/enable hyphenation in non-English documents. This is what is called font en. It pro- coding. The package ae (almost European) is obsolete. If you have none of these. The 2. several encodings simultaneously. which is a bitmap font. 2. tex will have to choose the right font glyph for every character.5 Font encoding use. As bold text is gen. particularly for keywords the reader may be puter Modern font does not support T1. that’s why you may want size a word which is already in an emphasized sentence. By using these fonts you can In order to add some emphasis to a word or a phrase.5. and should not be con. Using the ae package leads to text en- leaving out some others and including a number that are coding problems in PDF files generated via pdflatex (e. some of Latin letters could not be created Shapes by combining a normal character with an accent. These are not necessary any more with It contains only 128 characters. Bitmap fonts look rather ugly when zoomed or printed. Note that the \emph command is dynamic: if you empha. While the resulting output looks perfect. Font styles are usually implemented with different font • Searches for words with accents in PDFs will fail.

The \selectfont command is mandatory. with \usepackage[normalem]{ulem}.} along with \usepack..} which delimits the unit. This is because the characters actually get magni- the \end{. There ronment begins. sl=slanted. Although underlining As a technical note.8 Arbitrary font size ever. such as OT1 (TeX age[normalem]{ulem}.5. n=normal. age[normalem]{ulem}. use \uwave{. only some words. than one of these size commands may produce the same You may have noticed the absence of underline.} along with \usepack. better PDF support. rect spacing after the selected font style has ended...0. so font{<encoding>}{<family>}{<series>}{<shape>} for instance {\Large some words} will change the size of command.} along with \usepackage[normalem]{ulem}. the size command should include the blank line or font.\fontshape The shape: it=italic. By default. • To add a wavy underline.You can change font for a specific part of the text. The \tiny.35136 mm. • For a strike-out (strikethrough). The standard point size used in most mod- ality has to be added with the ulem (underline empha.5. otherwise the Some font styles are not compatible one with the other. contents. use \uline{.ern computer programs (known as the desktop publish- sis) package.. it will . Stick \usepackage{ulem} in your pream. for exam. It will work for most parts of the text. m=medium. because underlining is not recommended for typographic Note that the font size definitions are set by the docu- reasons (it weighs the text down). widely used).. FONTS 31 The commands in column two are not entirely equiva.. \fontfamily The font family. If it usually looks correct for medium sizes. This function. use \usepack... part of a formula may be set in a different size by using an \mbox command containing the size command. it may differ for some Document Styles or their options. ple to draw attention to changes. so it is better imately 0.} along \fontseries The series: l=light. These are fixed sizes however. For bold small enclose the command in a group to cleanly return to the capitals. bx=very bold. 2. pends on the Document Style and. You should use emph ment class.document class has unique sizes for all 10 size commands..ing point or PostScript point) has 1 pt equal to approx- ble. This is actual size. \seriesdefault and \shapedefault... font will not be changed.5.. if an entire paragraph or unit is set in a certain ment processors. And not every form of emphasis during the editing process. Alternatively. in some styles. age[normalem]{ulem}. you might want to use: previous font selection when desired. you can use the \use- These commands change the size within a given scope. 2....\Huge commands are often enough for most The new size takes effect immediately after the size com. add \normalem straight after the document envi.American point size in which 1 pt is approximately lined in this way will not break properly. use \sout{. The The actual size produced by these commands also de- commands in column one are therefore in general recom.2. It is highly recommended to But some extra packages will fill this hole. fied.. default) or T1 (extended characters support.are four font properties you can change. this overrides the \emph command with imately 0. text under. However underlining text provides a useful extra font size may differ from that listed above. more mended. • To underline. These commands cannot be used in math mode. You can use all these commands in a row: Sizing text The default values are stored in \encodingdefault. How. sc=small capitals. • For a slash through each individual char. points in TeX follow the standard is available via the \underline{. but lent to the commands in column one: They do not cor. \fam- ilydefault. to stop ulem taking over \emph and simply call the under- line command as and when it is needed. Depending on the document style the actual instead. acter \xout{. Setting back To apply different font sizes.37597151 mm (see: point (typography)).. It is unlikely size (known as the Didot point) had 1 pt equal to approx- that you wish this to be the desired effect.\fontencoding The font encoding.3527 mm while the standard European point the underline rather than the italic style. simply follow the commands the default font properties can be done with on this table: For short. b=bold. and does not affect the font in the rest of the document. you can usually choose any size for any size. The default for \normalsize is 10 point (option 10pt). In most docu- mand.7 Local font selection • To restore the usual \emph formatting.} command.

5. and that you 2.5 glyphs and optical size variants.6 List Structures For example for xelatex Convenient and predictable list formatting is one of the many advantages of using LaTeX.nl/memory/Fonts_in_ LaTeX coded as UTF-8 and load fontspec. Yes. you may get the following message: LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size • How to change fonts in Latex <142. etc. This ensure the characters to list embedded fonts.macfreek. To make your document support both pdflatex and xelatex/lualatex you can use the \ifx- etex/ \ifluatex macro from the ifxetex/ ifluatex package.5. You can projects. simply load the fontspec package and set • Using TrueType fonts with TeX (LaTeX) and pdf- the font: TeX (pdfLaTeX) (for MikTeX) Then compile the document with xelatex or lualatex. XeTeX also allows using OpenType • True Type Fonts with LaTeX under Linux + MiK- technology of modern fonts like specifying alternate TeX 2.26378> not available (Font) size <24. Changing the font size is made by changing the font file. In TeX it is possible to change the magnification of Many PDF viewers have a Properties feature to list em- anything. Also you should not load the inputenc or fontenc package.[2] Taken from http://www. Instead make sure that your document is en. Example: • The Latex Font Catalogue If you are using the default Computer Modern font en. It gin and end. 2.5. are correctly balanced and remain readable at all defined sizes.11 PDF fonts and properties word processors can sometimes be frustrated by the soft- ware’s attempts to determine when they intend lists to be- PDF documents have the capability to embed font files. • LaTeX font commands coding. reason. ness. Windows + MikTeX To use the fonts.12 Useful websites You may choose a particular font size with the \font- size{<size>}{<line space>} command. hence the name Portable Document control over the structure and content of lists.5. Format. but highly discouraged for the aforementioned bedded fonts and document metadata. LaTeX gives more makes them portable.32 CHAPTER 2. . This article shows how and why” 2.13 References need a sufficiently recent TeX distribution (TeX Live 2009 should work for XeTeX and Tex Live 2010 for Lu. Note that you can only generate .5. you can cut corners with font installation use the fix-cm or type1cm packages to allow computer (i. there is a file for every size: cmr10 for Many Unix systems make use of the poppler tool set Computer Modern Roman 10pt. of files and a cleaner TEX installation. ing the basics of fontinst In that case you will notice that the font size is by default • Font installation the shallow way “For one-off restricted to a set of fixed sizes as noted above.88> substi. • Unicode Truetype font installer for LaTeX under sues. fontinst) and end up with a more manageable set modern fonts to be scaled to arbitrary values. • Understanding the world of TEX fonts and master- tuted on input line 103. cmr12 for Computer which features pdfinfo to list PDF metadata. XeTeX also uses Unicode by default. Users of WYSIWYG 2. which will take care of the font encoding. which might be helpful for font is.9 Finding fonts TrueType (ttf) fonts You will find a huge font directory along examples and configurations at TUG Font Catalogue.e. you'll be able to use any font installed in the system effortlessly.[1] found at the Google discussion group latexlovers aTeX).10 Using arbitrary system fonts • A bash script for installing a LaTeX font family (MikTeX / TeXLive) If you use the XeTeX or LuaTeX engine and the fontspec • LaTeX And TrueType Font package. and pdffonts Modern Roman 12pt. As a mark-up language. • Step-by-step guide to manually install a ttf-font for PdfTeX 2.pdf files. COMMON ELEMENTS look odd at extreme sizes because of an unbalanced thick. 2.

the standard lists take up too much space The Margin parameter sets the distance from the left mar- and you want to customize the appearance.6. mand and revert back the customization with \NewList. the labeling environment is handy. gin (Ex: FinalSpace2=1cm).6. their item.1 List structures An example for alignment and the width of the label. preamble. convenient syntax and with infinite nested levels. Please note that the example also shows how to change the Style* parameter sets the style of counters. The Style parameter sets the style of counters and text. eter (Ex: Style3*) then this numbers indicates the level ing noitemsep. played and the possible values are r or R (for lower and In combination with a package like exsheets. you may want to have the list inline.Approximately the format used by the ta- Latex will sort out the layout and any numbering for you. case letters). You their purpose is often to present information in a clear can even define your own lists. The Progressive parameter umitem helps you by providing a simple interface. you can pre- upper case Roman numerals). If you are using a KOMA-script class (or • itemize package scrextend). sets the distance from the left margin of all items in pro- You can change the appearance of lists globally in the portion to their level.The default Sometimes you feel the need to better align the differ- ent list items.3 Customizing lists The FinalMark parameter sets the punctuation of the fi- nal counter (Ex: FinalMark3={)}) while FinalSpace sets Especially when dealing with lists containing of just a few the amount of space between the item and the item’s text.. more levels are to them available using packages). It takes a mandatory argument that contains the longest of You can customize lists with the \ListProperties(. Available styles: Try out the examples below. • booktoc . ble of contents of the book class • articletoc . The parameter Numbers determines the way that the numbers are dis- If you want a horizontal list. l or L (for lower and upper pare exam papers for students.. All lists follow the basic format: Load the package with the control character as optional All three of these types of lists can have multiple para.All items have empty check boxes next into an existing one (up to a depth of four. Simply begin the appropriate environment at the desired point within the current list. LIST STRUCTURES 33 2. Package en. and the the font.Approximately the format used by the table of contents of the article class 2. If there is a number after a param- example where the list on the right is more compact us.6. 2. normal way. If you are on tight space limitations and only have short item descriptions. to see what the lists look like in a real document. especially academic. and z (for Zapf’s Dingbats). with a blank line between each. The Hide = n parameter prevents the first n counters from ment of the environment. a (for Arabic numbers. . Yes.2. • tractatus LaTeX will happily allow you to insert a list environment • checklist . List structures in LaTeX are simply and tasks can be changed differently. Have a look at the following appearing in all levels. • itemize for a bullet list 2. Environments like labeling and concise fashion. It is also very customizable. that’s parentheses for \ListProperties parameters.) com- your labels. details can be found environments which essentially come in three types: in the package documentation respectively. or just for single lists using the optional argu. that it will affect (Ex: Style3=\color{red}). as detail with respect to what can be changed and how.2 Some special lists • enumerate . The documentation of package enumitem goes into more Lists often appear in documents. the default).4 Easylist package • enumerate for an enumerated list and The easylist package allows you to create list using a more • description for a descriptive list. So long as they are still contained within the enclosing environment. package tasks can be handy. argument: graphs per item: just type the additional paragraphs in the The easylist environment will default to enumerations.6. words per item. It features predefined styles which you can set as optional they will automatically be indented to follow underneath argument. Style** parameter sets the style of text.6.

But 128 characters is not your LaTeX source file and compiled it. You should have a look at Fonts on the topic.7 Special Characters might not be able to display directly your input files on their computer. It only defines code points. majority of encodings to have backward compatibility you may get an error. Korean and others. besides the default one. it is not 100% safe. care. value. use the following with ASCII. only that it has to be configured. there are many different input en- avoid LaTeX understanding it as the end of the proper. LaTeX lists do This is actually a big issue. with Latin1 it is encoded as 228. If you try to input these special characters in TeX uses ASCII by default. There is an attempt to unify all the encoding ties list.34 CHAPTER 2. This specific matter you try to open a Latin1-encoded file using a UTF-8 de- will be tackled in Internationalization. It does not mean that the user cannot use an- coding. which is technically superior. ist at all. character encoding.is different. unicode encodings are in charge. What most programs try to do is guess statistically must be marked as fragile: the encoding by analyzing the frequent sequences of bits. Therefore you should consider encoding with This chapter is tightly linked with the font encoding issue. own way to do that with commands for every diacritical A LaTeX source document is a plain text file. many advantages in using Latin1 over UTF-8. For example. Japanese. or more informally charset. For that. There are also several unicode encodings available. This association is called input There are several encodings available to LaTeX: . To circumvent it. we need a code file. Important note: easylist has some drawbacks. or the tabbing environment. This specification is Uni- Spaces in Style parameters are important. Some text editors may not bother guessing the encoding and will just use the OS default encoding. because the default encoding for text file In this chapter we will tackle matters related to input en. in modern Unices. Sadly. There aren't are in text mode. Note that we put the FinalMark argument between {} to For historical reasons. we will refer to special char- OS/2 is encoded as 132. ease document writing. coding. UTF-8 is also becoming the most widely used encoding (on the Web. The following table shows the default encodings for some Some languages usually need a dedicated input system to operating systems. sequence of characters. since if you do not use the not have this problem. This is the case for Arabic. it will show weird charac- To use easylist with Beamer. other encoding. To display a plain text file. by defining the first 128 characters the same commands provided by easylist: way. it will display odd symbols only if you used ac- The rules for producing characters with diacritical marks. The other characters are added using more bits (8 Besides using easylist along with figures may cause some or more). differ somewhat depending whether you encode the classic letters the same way. acters for all symbols other than A-Za-z0-9 and English while in Cyrillic encoding cp1251 this letter does not ex- punctuation marks. UTF-8 be- You can also define custom styles using LaTeX macros: ing one of them. we have to tell TeX that we want to use a different which tells which sequence of bits corresponds to which encoding. right encoding to display a file. A technical matter Most modern computer systems allow you to input letters Dealing with LaTeX of alphabets with non-ASCII characters directly from the keyboard. Chi- UTF-8 and Latin1 are not compatible. TeX has its that they do not get printed at all. Its widespread use has led the vast same control character as the one specified for easylist. A computer marking (see Escaped codes). that is a sequence of bits other special characters to appear directly in the source (0 and 1). codings. But if we want accents and stores data in a binary format. Now we change the default properties to print a with a specification that contains all existent symbols that custom itemize: are known from human history.1 Input encoding etc. COMMON ELEMENTS Example of custom enumerate: encoding. First if you The ASCII encoding is an encoding which defines 128 need to put an easylist inside an environment using the characters on 7 bits. 5 and onward. The Style* code. You should consider that other people 2.). It means that if nese. you may notice enough to support non-english languages. each frame that uses easylist ters.7. typesetting diacritics and special characters. trouble to the layout and the indentation. but not the way symbols are represented in binary parameter acts as a default value and easylist will use a medium dash for level 1. math mode. the German umlaut ä on In the following document. 2. which is a number for a symbol. since both encoding are ASCII superset they such as accents. cents in it.

It only ured as \usepackage[german]{babel}. '¿' respectively.7. This is easy: mands: . See the Fonts section for more informa- tion. supports most characters for latin languages. to achieve eas- The LaTeX support of UTF-8 is fairly specific: it includes ier coding of umlauts.a. then using Extending the support the right configuration allows those characters to be writ- ten directly in the document. Another possiblity is to stick with utf8 and to define the Alternatively. For example. composition of special characters. The following commands may be used only in paragraph (default) or LR (left-right) mode. SPECIAL CHARACTERS 35 • ASCII: the default. TeX sequence is what to print when the char- acter matching the codepoint is met. Only bare english characters are where codepoint is the unicode codepoint of the desired supported in the source file. There are some important steps to specify encoding.tex files is. Both engines support UTF-8 directly and allow the use of TTF and OpenType fonts to support Uni- • Others. you may try need to use the utf8x option ters.k. This is due to the utf8 definition not necessarily having a mapping of all the character glyphs you are able to enter on your keyboard. Codepoints are easy to find on the web.2. This is convenient if your keyboard lacks some desired accents and other dia- • Make sure it saves your file in UTF-8. editors do not make the distinction. the encoding within the document by means of the com- • \"{\i} should be used for i umlaut 'ï'. make sure it is set be placed on any letter. since no backslash will tion where using UTF-8 might result in error: be accepted otherwise. code characters. mand \inputencoding{'encoding name'}. The dotless version of these letters is accom- inputenc [2] package tells LaTeX what the text encoding plished by typing \i and \j. to use UTF-8 by default. you have to configure it. In the following we will assume you want to use UTF-8. This provides the defines those symbols that are known to be available with short hand “o for \"o. Supports With XeTeX and LuaTeX the inputenc package is no the complete Unicode specification. but some do. longer needed. for example. 2. You might encounter a situa- use some text accents in a label. the babel package can be config- only a limited range of unicode input characters. You may find code- • ISO-8859-1 (a.3 Less than < and greater than > ŷŶũŨẽẼĩĨ The two symbols '<' and '>' are actually ASCII charac- In such case. but you may have noticed that they will print '¡' and to define more character combinations. • Tell LaTeX that the source file is UTF-8 encoded. LaTeX supports the 8. such as Notepad++. loaded with the fontenc like csquotes. This is a font encoding issue. The inputenc package allows as well the user to change • \^{\i} should be used for i circumflex 'î'. be found in the Internationalization section. ! Package inputenc Error: Unicode char \u8:ũ not set up More information regarding language configuration can for use with LaTeX. If you want cially supported. PuTTY is not set tilde over a blank space. Most text critics. Some old Unix above a “missing” letter. If a document is to be written completely in a language that requires particular diacritics several times. they can be printed with dedicated com- characters yourself. Such characters are for example 2. How. In addition to direct UTF-8 input. but can be viable in some cases. character. For example: format of your . It points on this site.2 Escaped codes • Make sure your text editor decodes the file in UTF. Latin 1): 8-bits encoding. you will have to use an- ever it might break up compatibility with some packages other font encoding such as T1. Now inputting 'ŷ' will effectively print 'ŷ'.7.. Although 'o' letter is used in most of the examples. See Fonts for more details on font encoding. but Example: that’s it. \~{} produces a terminals may not support UTF-8. Accents may even be placed to support UTF-8 input and output. utf8x is not offi. • UTF-8: a Unicode multi-byte encoding. The following accents may be placed on letters. To place a diacritic on top of an i or a j.7. its dot has to be removed. the accents may • If you are working in a terminal.. This is very useful if one needs to the current font encoding. them to print their real symbol. package.

The following commands may Some keyboard layouts feature the degree symbol. COMMON ELEMENTS 2. Alternatively you can use the marvosym package which also provides the official euro symbol. An official version of the euro symbol is provided by eu- rosym. and later chap. Finally. you can use an appropriate font.7. Now that you have succeeded in printing a euro sign.7 In special environments the textcomp package instead. mand which gives you the euro symbol as supplied by Next. Use 2. The majority of Some of the accent marks used in running text have other them are within the mathematical domain.. For the more created with the following command: common text symbols. use the following commands: Not mentioned in above table.7. you need the euro ingbats font is available thanks to the pifont package. etc.5 Degree symbol for temperature and math The easiest way to print temperature and angle values is to use the \SI{value}{unit} command from the siunitx package. tilde (~) is used in LaTeX • \a' for an acute accent code to produce non-breakable space. you may want the '€' on your keyboard to actually print the euro sign as above. can use it directly if you are using UTF-8 and textcomp. see the documentation of the siu- nitx package. will print the speci- your current text font.4 Euro € currency symbol space ␣ can be created with \textvisiblespace. To get printed tilde sign. And a visible • \a` for a grave accent .g.36 CHAPTER 2. the command \ding{number}. In that case they can be ters will cover how to get access to them. Complete example: 2. either write \~{} or \textasciitilde{}. There is a simple method to do that. Add sign. which works both in text and math mode: For more information. Depending on your chosen font fied symbol.uses in the tabbing environment.7. For better results (font quality) we recommend the use of When applying accents to letters i and j.) you can use a different option: again you can insert the euro symbol with \euro{}. like lmodern: \imath and \jmath to keep the dots from interfering with the accents: 2.7. italics. A common mistake is to use the \circ command. which provides a \textde- gree command. It will not print the correct character (though $^\circ$ will). Here is a table of the available symbols: this may be quite far from the official symbol.6 Other symbols Tabbing environment LaTeX has many symbols at its disposal. bold. you be used only in math mode. The textcomp package features a \texteuro com- the declaration to your preamble: \usepackage{pifont}. Math mode For temperature. you can use the same command or opt for the gensymb package and write Several of the above and some similar accents can also be produced in math mode. For some more interesting symbols. if you want a euro symbol that matches with the current font style (e. the Postscript ZipfD- When writing about money these days. You must make sure you are using UTF-8 encoding along with a working \euro{} or \EUR{}command. Load it in the preamble (optionally with the offi- cial option): then you can insert it with the \euro{} command.

Babel will auto- matically activate the appropriate hyphenation rules for 2.8. It highly bibliographies.7. • A few other LaTeX accents and symbols The following configuration is optimal for many lan- • NASA GISS: Accents guages (most latin languages). The user needs to use language-specific typographic rules. mand. Chinese.2 Babel The babel package by Johannes Braams and Javier Bezos 2. See Font encoding. depends on the selected layout+variant.quite a negative effect on the appearance of the typeset glish. preceeding every key and dead key with the Alt Gr modifier. so that all the other packages you load afterwards will know the language you are using. Example: cial characters directly from the keyboard instead of us- <Ctrl+Shift+u> 20AC <space> ing cumbersome coding (for example.8. see this article you should consider polyglossia). Xorg features advanced keyboard layouts with variants Some of the methods described in this chapter may be that let you enter a lot of characters easily with combina. A 'u' symbol should ap- pear. encoding set. but not always): [2] For a detailed information on the package.7. you can hold Alt and type a <codepoint> to some notes about it. so we suggest you Here is a collection of suggestions about writing a La- to play a bit with your keyboard. vided by various packages • Search LaTeX symbols by drawing them 2. If your LaTeX format does not support hyphenation in the language of your choice.10 Notes and References will take care of everything (with XeTeX and LuaTeX [1] For a quick explanation on character sets. ing properly. Korean). the so-called unicode 3. which has it is used to write documents in languages other than En. 2. Make sure your document is saved using the UTF-8 encoding.9 External links need to set the input encoding and the font encoding prop- erly. We will not tackle this issue here: see the Desktop environments like GNOME and KDE may fea. get a desired character. Most non-english language will need to input special characters very often. INTERNATIONALIZATION 37 • \a= for a macron accent 1. to input any Unicode code point. If you have experience in a language not listed below. <Alt> + 0252 2.7.1 Prerequisites will print the German letter ü. The input of special characters. LaTeX needs to know how to hyphenate the lan- guage(s) to be used. • The Comprehensive LATEX Symbol List For more details check Font encoding and Special Char- • PDF document with a lengthy list of symbols pro. You can load it in your on Joel Spolski’s blog.Special Characters chapter. TeX document in a language other than English. Babel also specifies new commands for some . please add In Windows.2. the Ctrl+Shift+u combination. like Alt Gr. guages using an input system (Arab. This can be done by configuring input encod- will print the euro character. especially for lan- compose key. by typing ä instead of \"{a}). For example. see complete You should place it soon after the \documentclass com- specifications written by the package’s authors.8 Internationalization the language you choose.8. For a convenient writing you will 2. there is a mandatory Some operating systems provide a keyboard combination space before each colon character (:). This has to address three main areas: document. useful when dealing with non-English author names in tion using the aprioriate modifier. providing as an argument name of the language you want to use (usually its English name. In French for example. Many X applications (*BSD and GNU/Linux) support Japanese.8 Unicode keyboard input 2. ba- LaTeX has to be configured and used appropriately when bel will still work but will disable hyphenation.acters. preamble. ture a customizable compose key for more memorizable Some languages require special fonts with the proper font sequences. Type the code point and press enter or space to It is convenient to be able to insert language-specific spe- actually print the character.

Uyghur.8. it can also be used to disallow hyphenation by The Armenian script uses its own characters. Armenian terns used. require you to install a text editor that supports Unicode and will allow you to enter UTF-8 text. For languages which use the Arabic script. Babel will take care of switch- ing to the appropriate font encoding when a different lan- guage is selected within the document. documents are not restricted to a single font without the need of defining own commands.3 Multilingual versions the fontspec package can be used to write in Armenian: or It is possible in LaTeX to typeset the content of one docu- ment in several languages and to choose upon compilation The Sylfaen font lacks italic and bold. These text editors should then be configured these and many other options. or with tex4ht to produce The starred version of this environment typesets the main HTML. which will using the language name 'nohyphenation' (but note select- language* is preferred).7h of babel includes support for the T2* encod- ings and for typesetting Bulgarian. See Armenian Wikibooks for further details. With Cyrillic script You can write: Version 3. to compile using XeLaTeX. Russian and Ukrainian Alternative choice using iflang texts using Cyrillic letters[1] . Here comes a simple ex. which simplify the input of special characters.4 Specific languages On modern operating systems it is beneficial to use Uni- code (utf8 or utf8x) instead of KOI8-RU (koi8-ru) as an Arabic script input encoding for Cyrillic text. This might be convenient to supports them. but DejaVu Serif which language to output. AMS-LaTeX packages should be (Why?) package by Heiko Oberdiek (the built-in feature from the loaded before fontenc and babel . but See Arabi page on CTAN keeps the language specific string for ancillary things like figures. and activating some language . etc. add the ically generated text strings. tive Arabic script encodings. COMMON ELEMENTS languages. This allows to easily distinguish between two languages However. keep a consistent sectioning and formatting across the dif. The babel encoding. 2..In addition to enabling hyphenations.e. Kurdish. 2. the commands above in multilingual documents can be cumbersome. you also need to load mathtext ample: package before fontenc: \IfLanguageName{ngerman}{Hallo}{Hello} Generally. See the ArabTeX Wikipedia article for further details. The envi- ronment hyphenrules switches only the hyphenation pat.8. It is also useful if you make use of mul. Urdu. Using to compile with XeLaTeX. Once the text editor is set up to compile with XeLaTeX. especially ferent languages. and you can use the command You may also use the Arabi package within Babel to type- to change the active language.You can input text in either romanized characters or na- mation.38 CHAPTER 2. and therefore babel provides a way to de- fine shorter names. following code to your preamble: See the sections about languages below for more infor. such as Texmaker The babel manual provides much more information on or WinEdt. on how to configure the Unicode supporting text editors tiple proper nouns and other untranslated content. If you are going to babel package is not reliable). pieces of text in another language: You may use Arabi with LyX. use Cyrillics in mathmode. Pashto. languageB). for the above three languages this is T2A. in the main language of the document. Use any of the following If you call babel with multiple languages: commands and environments to enter in text: then the last language in the option list will be active (i. For multilingual documents using Cyrillic and language is changed by setting Latin-based languages it makes sense to include Latin \selectlanguage{english} font encoding explicitly. You can also add short set Arabic and Persian pieces of text in another language using the command You may also copy and paste from PDF files produced Babel also offers various environments for entering larger with Arabi thanks to the support of the cmap package. text according to the rules of the other language. Persian. babel will automatically choose the default font encoding. including Ara. translating automat- bic. Support for Cyrillic is based on standard LaTeX mechanisms plus the fontenc and The current language can also be tested by using the iflang inputenc packages.

It must fit the desired language. b.) to Finnish. language specific punctuation is (section names. it is advised to Bulgarian or Latin (English) alphabets. the CJK collection is usually Xorg (*BSD and GNU/Linux).pdf or frenchb. If you do not know or do The Bulgarian option of babel provides the commands not really care. traditional Chinese) necessary because currency symbols and other units or not supported in general (that’s not specific to French). and Korean. simplified Chinese) pecially non-breaking spaces before all two-parts punctu- ation marks. Otherwise.dtx and and \crqq to produce left and right quote. This is customizable Czech is fine using using the \frenchbsetup command. For the degree character you will get an error like Put the parts where you want to write chinese characters in a CJK environment.2.dvi. The last argument specifies the font. See Special Characters for more details. and francais for Parisian French. if you have configured See the Bulgarian translation of “The Not So Short Intro. since fonts are different for Chinese. etc. You quotated text inside \uv.g. Czech You will also notice that the layout of lists changes when switching to the French language.on what the frenchb option of babel does and how you can rectly in your text. quotes. c. which allows Chinese you to write French input files more easily. The default be. All enable French hyphenation.0 of babel-french. You will need the T1 font encoding for guillemets to print Make sure your document is saved using the UTF-8 char. INTERNATIONALIZATION 39 specific typographic rules (like \frenchspacing). traditional Chinese) You can use the numprint package along Babel. ! Package inputenc Error: Unicode char \u8:° not set up for use with LaTeX. frenchb. e. directly from the keyboard using a different distribution. Russian. You can place read the produced file frenchb. a.command[3] : tion is to produce letters from the Bulgarian alphabet. we would recommend using frenchb. Check out the following table for inspiration: One possible Chinese support is made available thanks to You may want to typeset guillemets and other French the CJK package collection. there are macros \clqq customize its behavior. you may want to use the in a separate package because of its size (mainly due to oss variant which features some nice shortcuts.Finnish language hyphenation is enabled with: guages. This will also automatically change document language For all three languages.. as of version 3.There are multiple options for typesetting French doc- tal and small letters of Russian or Ukrainian alphabets uments. depending on the flavor of French: french. For more information UTF-8 allows you to have „czech quotation marks“ di. (whichever is the active language of the document). like fonts). but produce capi. If you are using a package characters directly if your keyboard have them. provided: the Cyrillic dash for the text (it is little nar- rower than Latin dash and surrounded by tiny spaces). \today prints the current date in French and so on. or Ukrainian lan. which make \Alph and \alph produce letters of either However. es- • gbsn ( . Running manager or a portage tree. Japanese The textcomp package will fix it for you. A set of new commands also becomes available. Possible choices for Chinese include: The great advantage of Babel for French is that it will handle some elements of French typography for you.choose the language as a global option with the following haviour of \Alph and \alph for the Bulgarian language op. . can get the PDF version on CTAN. All of these also change duction to LaTeX” [2] for a method to type Cyrillic letters all automatic text into French: \chapter prints Chapitre. It will let you print numbers the French way. So now you can write: • gkai ( . babel Finnish provides some commands allowing typesetting according to the standards of Bulgarian.8.your LaTeX system accordingly. simplified Chinese) The non-breaking space before the euro symbol is still • bsmi ( . acter encoding. and acadian and canadien for new-world French. run LaTeX on file frenchb. a dash for direct speech.properly. • bkai ( ..). and commands to facilitate hyphenation: French The Russian and Ukrainian options of babel define the commands You can load French language support with the following command: which act like \Alph and \alph (commands for turning counters into letters.

collection is usually in a separate package because of its This preamble enables hyphenation and changes all au. one can use the commands \text. Korean Hungarian The two most widely used encodings for Korean text files are EUC-KR and its upward compatible extension used in Korean MS-Windows. and punctuation characters for most of the European lan- able. If you This is the preamble you need to write in the Greek lan. which supports vertical typesetting. Packages like ziffer enable input like 0. In case you don't know how to do this. take a look at Texmaker.} described in a previous sec. T1 encoded fonts. latin{english text} and \textgreek{greek text} that both take one argument which is then typeset using the re. the Luatexja documentation : Decimal numbers usually have to be written like 0{.size (mainly due to fonts). “Chapter” becomes only the 128 characters. since fonts are different for Chinese. make sure you use the alatex and the luatex-ja package.}5 You can also use capabilities provided by the Fontspec (not just 0. Check out the table below for inspiration. them differently. the CJK guage. ".5). With inpu- Italian tenc. normal ASCII character similar to other ASCII compat- .5.language. Just add In German books you sometimes find French quotation at the beginning of your document and the output of all marks («guillemets»). Japanese A major problem arises from the use of commands like \flq: If you use the OT1 font encoding (which is the de. Otherwise you can use the com. however.. See Special Characters for more details. This changes text like Part into Hluti. but it contains all automatic text into German. It must fit the desired quested font encoding. Greek Another (but old) possible Japanese support is made available thanks to the CJK package collection. A set of new commands also be.and Korean. which turns a typesetter’s stomach. files more easily. A quote in a German book would look like »this«. A set of new commands also becomes avail. Italian is well supported by LaTeX. all this becomes moot. e. In Use the following lines: these encodings each US-ASCII character represents its More information in hungarian. which allows you to write German input files more guages using Latin script. a LaTeX editor which use UTF-8 by default. tion. package and those provided by Luatexja-fontspec to de- Alternatively.g.The last argument specifies the font. German typesetters.40 CHAPTER 2. quickly even when you don't use the inputenc package. CP949/Windows-949/UHC. In order to temporarily switch to En. Adapted example from T1 encoding. COMMON ELEMENTS German Icelandic and Faroese You can load German language support using either one The following lines can be added to write Icelandic text: of the two following commands.. It makes additional For traditional (“old”) German orthography use commands available: or for reform (“new”) German orthography use To make special characters such as Þ and Æ become available just add: This enables German hyphenation.are using a package manager or a portage tree. Use \euro for the Euro symbol. There is a variant of TeX intended for Japanese named fault) the guillemets will look like the math symbol " ≪ pTeX. but your text also is locked in a particular encoding world.in a CJK environment. tomatic text to Greek. Let us take babel and (globally) set the decimal marker using an example : Use UTF-8 as your encoding. which allows you to write Greek input acter encoding. In the German speaking part of Switzerland. use the commands will be translated properly.Put the parts where you want to write japanese characters glish and vice versa. if you have config- ured your LaTeX system accordingly. typesetters use «guillemets» the same way the French do. on the other hand. So Another possible way to write in japanese is to use Lu- if you are using this type of quote. Japanese mand \selectlanguage{. Note the particular input encoding.Make sure your document is saved using the UTF-8 char- comes available. one can use the \num command from the clare the font you want to use in your paper. The T1 encoding contains letters “Kapitel”. do contain the required symbols. It also changes The default LATEX font encoding is OT1. min is an example for Japanese.

becomes “rozdział". Check out the web site of • HLATEX by UN Koaunghi the Korean TeX User Group (KTUG). you This command turns the Korean localization on.. section. use the following code special Korean fonts as HLATEX. sub- headings of chapters. Big5. Hanjas rean conventions.8. To ensure use Bitstream’s cyberbit True-Type font. Katakanas. It can process illustrated in the corresponding section. there are pairs of post-fix Hiraganas. a subfont mechanism was process. Ω. headers. Polish tent (especially Chinese. The package also provides automatic (Chinese characters as used in Korea). If you plan to use Polish in your UTF-8 encoded docu- fered by HLATEX and it does not come with as many ment. HLA- TEX relieves its users from this boring and error-prone them work for languages with considerably more charac- ters such as Korean or Chinese. you have to use non breakable space: To use the HLATEX package for typesetting your Korean text. put the following declaration into the preamble of your document: Numerals According to Polish grammar rules. there are three widely used packages. or the formatting of the document is changed to follow Ko- Shift_JIS. It divides a single CJK font with thousands or In case you don't need Korean localization features but tens of thousands of glyphs into a set of subfonts with 256 just want to typeset Korean text. etc. sections. EUC-JP. you a good picture. you can put the following glyphs each. so that “chapter” TeX and LaTeX is to get documents typeset in an aes. table of con. . In the FAQ section of KTUG it is recommended to use • hLATEXp by CHA Jaechoon the kotex package • the CJK package by Werner Lemberg Persian script HLATEX and hLATEXp are specific to Korean and pro- vide Korean localization on top of the font support.section. “w”. that LaTeX won't set them as last letter in the line. Hangul syllables. Arguably the most important must remember about. input files in UTF-8 as well as in various CJK encodings including EUC-KR and CP949/Windows-949/UHC. particle selection. Just add the following code to your preamble: CP949/Windows-949/UHC and UTF-8 when used along See XePersian page on CTAN with Λ. “u”. The above code merely allows to use Polish letters and The ultimate purpose of using typesetting programs like translates the automatic text to Polish. Greek and Cyrillic characters and particles grammatically equivalent but different in form. refer to the HLATEX Guide.) Native Korean speakers have no vironment under a non-localized (non-Korean) operating problem picking the right particle. developed. It takes a painstaking effort to place appropriate particles manually every time you add/remove references TeX and LaTeX were originally written for scripts with no more than 256 characters in their alphabet. “z”. The have to put dots after numerals in chapter. but this should give amount of time and effort to set up a Korean-capable en. INTERNATIONALIZATION 41 ible encodings such as ISO-8859-x. XePersian which uses XeLaTeX as the typesetting en- KR. “o”. subsections. In Korean. instead. Hangul Jamos. The CJK package works with a set “a”. The HLATEX distribution includes UHC PostScript fonts of 10 different families and Munhwabu fonts (TrueType) of Connectives Polish has many single letter connectives: 5 different families. For Korean. On the other hand. Arabic script can be used to type Persian as The CJK package is not specific to Korean. grammar and typography of fonts used by earlier versions of HLATEX and it can rules don't allow for them to end a printed line. there is a dedicated package called both can process Korean input text files encoded in EUC. element in typesetting is a set of welldesigned fonts. To make or simply shuffle parts of your document around. MSB set. etc. Until the mid-1990’s.2. line in the preamble. Moreover. For more details on typesetting Korean with HLATEX. Japanese and Korean). There are a few additional things one thetically satisfying way. ment. You can skim through the now much-outdated termined which particle to use for references and other http://jshin. it can be used to typeset documents with multilingual con. it took a considerable (It is a bit more complex than this. The first has its the preceding syllable ends with a vowel or a consonant. HLATEX can even process input files encoded in gine. They For Persian language. other symbols and letters drawn from KS X 1001 are Which of any given pair is correct depends on whether represented by two consecutive octets. tent and table of figures are all translated into Korean and This is achieved by redefining few LaTeX macros.net/faq to get a glimpse of what it was like to automatic text that will change while you edit the docu- use Korean under non-Korean OS in mid-1990’s. The CJK package has no Korean localization such as the one of. “i”. but it cannot be de- system.

The macro \spanishoperators{<list of operators>}{ con- tograficzny (in Polish) for additional information on tains a list of spanish mathematical operators. loading Babel. Spain and Commas in math According to some typography Mexico. This allows different typographical conventions with the same input. as preferences may be quite different from. or before.es- tional space in math mode after a comma (unless there is nolists: some packages and classes are known to collide a space after the comma). Further information Refer the Słownik Or. • mwbk instead of book Slovak • and mwrep instead of report. COMMON ELEMENTS For books: Portuguese For articles: Add the following code to your preamble: Alternatively you can use dedicated document classes: You can substitute the language for brazilian portuguese • the mwart class instead of article. latex2rtf) interact- frowned upon to set pages with hyphenation between ing with LaTeX. Number alignment in tables and different output modes The other commands modify the spanish layout after re supported. The options may be loaded either at the call to Babel. by choosing brazilian or brazil. by defining the com- Indentation It may be customary (depending on pub. umn package. This .pwr. and these options disable the internal workings of Spanish to Unfortunately.archive. More typeset numbers and their according units consistently.org/web/20040609034031/http:// Include the appropriate Babel option: www. use the icomma package. as the latter is a deviation from standard Babel behavior. Simple usage: Spanish Full documentation for those classes is available at http://web.mand \spanishoptions. the command Good extract is available at Zasady Typograficzne only defines sen. not a dot.mands are roughly equivalent: ters: On average. pages than it is customary in American typesetting. quired by the Mexican Official Norm (NOM) of the De- Another alternative is using package siunitx that lets you partment of Economy for labels in foods and goods. To make LaTeX not insert addi. as The alternative is to use the numprint package. 'ť'. fractional parts of numbers should be delimited by a comma. Therefore. One needs to either use dots in columns these options may simplify the way LyX customizes some with numerical data in the source file and make dcolumn features of the Spanish layout from inside the GUI. the former syntax should be preferred. mand \let\spanishoperators\relax disables them all. and the output is typically To adjust penalties for leaving widows and orphans (clubs either a comma or a dot. in TeX nomenclature) use those commands: and the output is typically either «» or “”. but Those classes have much more European typography set- Slovak needs special signs for 'ď'. Spanish also defines shorthands for the dot and << >> so To adjust penalties for hyphenation spanning pages. use that they are used as logical markup: the former is used as this command: decimal marker in math mode.wroc. with Spanish in the way they handle active characters.allow you to overcome these common pitfalls.42 CHAPTER 2. but it is customary. rules. the latter is used for quoted text. and the latter allowing decimal comma.pdf (Polish). be redefined at will.mexico-com provide support for lo- cal custom in Mexico: the former using decimal dot. and Hyphenation and typography It’s much more thus may break other programs (LyX. 'ľ'. and may Polish grammar and typography rules. as re- much less convenient. Basic settings are fine when left the same as Czech. the following com- lisher) to indent the first paragraph in sections and chap. For instance. localizations are in the making. say. The trick is that Spanish has several options and com- mands to control the layout.pl/~{}pmazur/LaTeX/mwclsdoc. To be able to tings but do not require the use of Polish babel settings or type them from keyboard use the following settings: character encoding. Moreover.Two particularly useful options are es-noquoting. Two particularly useful commands are \spanishoperators and \spanishdeactivate.ci. it is partially incompatible with the dcol. the com- Składania Tekstu (in Polish). switch them to commas for display or define the column as follows: The options mexico. overriding all other definitions.

Maksym Polyakov figuresleft In two sided documents all sidewaysfig- ures/sidewaystables are same orientation (left of fig- [2] The Not So Short Introduction to LaTeX.2 The rotfloat package now be loaded as french. Let’s rotate a of trouble if they are redefined by other packages. Note. This is the style 2. Moreover: print beautiful tables of any kind. Mastering the art of you can use three new environments: table construction in LaTeX is therefore necessary to pro- it will rotate the whole argument by 90 degrees counter.dtx two passes). rotfloat package may be used.10. table now bottom of page). Then one can use 2. not as frenchb or francais and preferably as a global option of \documentclass. age documentation for details.0. you can use tables. You can give any Keeping in mind that LaTeX is not a spreadsheet.duce quality papers and with sufficient practice one can clockwise. too taxing. Basic tables are not of text. or Default is sidewaysfigures/sidewaystables are oriented de- the es-noshorthands with \spanishdeactivate{<>. TABLES 43 command supports accented or spaced operators: the or \acute{<letter>} command puts an accent. 2. However.5. whether it is positive or negative. you should not combine the es-noquoting option with \spanishdeactivate{<>}. [1] The Not So Short Introduction to LaTeX. 2.9. The H option can not be used without this package.9 Rotations just like for normal tables. but it will not add any extra space.1 The rotating package 2. Finally. can be very useful. beware that some option preempt the availability of some Options active characters. the follow- ing operators are defined by default. command adds a small space. to keep you out You can also use the \rotatebox command. you might have a look at more advanced packages . Once you have loaded it with the standard command in the preamble: Tables are a common feature in academic writing.5 References preferred by the Chicago Manual of Style (broad- side).10 Tables The package rotating gives you the possibility to rotate any object of an arbitrary angle. The rotating package takes the following options. Once you are comfortable with basic LaTeX also rotated. sense to use a dedicated tool to build tables and then to It will leave the necessary space to avoid any overlapping export these tables into the document. it will turn the argument of 30 degrees."'}. table now at top of page). more advanced packages like turn.2.6 Support for Cyrillic. lation [3] babel-french documentation: “the French language should 2.” location where it appears in the source (. they will be placed on a separate page. in these cases. For instance. Some tol- When it is desirable to place the rotated table at the exact erance still exists in v3. The tabular inside a table for example: candidates for deactivation are the set {<>. though. Bulgarian trans.tex) file. but do not rely on it. and the \. first it is important to know If you want to make a float sideways so that the caption is the basics. but anything more advanced can take a fair bit of construction. More information can be found on figuresright In two sided documents all sidewaysfig- ures/sidewaystables are same orientation (left of fig- ure. If you would like to rotate a TikZ picture you could use sideways together with minipage. the macro \spanishdeactivate{<list of charac- ters>} disables some active characters. Please."}. In particular. to your preamble and use a slightly modified Wylie clockwise In single sided documents turn sidewaysfig- transliteration for input. Refer to the excellent pack. ures/sidewaystables clockwise (default). pending on page number in two sided documents (takes Please check the documentation for Babel or spanish.9.8. Tibetan counterclockwise/anticlockwise In single sided docu- ments turn sidewaysfigures/sidewaystables counter- One option to use Tibetan script in LaTeX is to add clockwise. often used to summarize research results. it makes angle as an argument. for further details. ure.

Thanks you want. the width using any unit supported by LaTeX. and the third aligned to the right and in italic. It becomes relevant only if your table is not in a paragraph of its own. while in the first one we didn't specify any vertical position of the table relative to the baseline of the width. You can pass along the bottom of the box. Expanding upon that by including some vertical lines: and that the next version introduces new syntax that will likely break existing documents. You can use the following letters: To specify a font format (such as bold. it is inferred by looking at the number of arguments pro. or command lengths. In most cases. to add lines between all rows. The situation changed re. The first line of the environment has the form: Text wrapping in tables The table spec argument tells LaTeX the alignment to be LaTeX’s algorithms for formatting tables have a few used in each column and the vertical lines to insert. it is recommended that you use the p columns here. while not following: always being compatible with one another. For example \begin{tabular}{ >{\bfseries}l c >{\itshape}r } will indicate a three col- umn table with the first one aligned to the left and in bold font. toward the middle of the box or the b attribute to align around the text as in a normal paragraph. last column of the second one has a defined width of 5 The optional parameter pos can be used to specify the centimeters. even if it overruns the width of the page. In the first line you have pointed out how many columns . if the text in a column is too wide for the page. You tables with the same code. Nonetheless. the text you want. tabularx and much more. etc. have a look at By default. COMMON ELEMENTS or the export options of your favorite spreadsheet. Once in the environment. the result of this is not obvious from the preview The tabular environment can be used to typeset tables on this web page): with optional horizontal and vertical lines. separating between cells and introduc- For a long time. such as \textwidth. Using p{'width'} Instead of p.of course.[1] To add horizontal lines to the very top and bottom edges of the table: And finally. The commands you have to use are the with dozens of packages doing similar things. use the m attribute to have the lines aligned you can define a special type of column which will wrap. before Basic examples attempting to use this package for the first time it will be beneficial to understand how the classic environment This example shows how to create a simple table in La- works. LaTeX won’t automatically wrap it. as well as 2. or The tabulary package.44 CHAPTER 2. The tabu environment is far less fragile and re- stricted than the older alternatives. the second one aligned in the center and with normal font.For columns that will contain text whose length exceeds vided. the only difference is that the can find a list in chapter Lengths.attribute and specify the desired width of the column (al- scribe the table columns (some of them require that the though it may take some trial-and-error to get the result package array has been loaded): you want). shortcomings. Sometimes Note. It is a three-by-three table.1 The tabular environment centering (notice the use of the center environment .10. any white space inserted between these commands you had to make trade-offs. The tabularx package. LaTeX de- termines the width of the columns automatically. For a more convenient method. you can add >{\format} before you declare the alignment. It is also possible to add vertical lines between the the column’s width. The following code creates two and 'cm'. italic. the whole process can them. The “array” package needs to be activated in the preamble for this to work. but without any lines. you will not need this You get the following output: option. ing new lines. such as 'pt' Here is a simple example. The following symbols are available to de. Note however that TeX. the author of tabu will not fix bugs to the current version. LaTeX tables were quite a chaotic topic. their alignment and the vertical lines to separate to the modular nature of LaTeX. is purely down to one’s preferences. you have to introduce be automated in a fairly comfortable way. I personally add cently (2010) with the release of the tabu package which spaces between to make it easier to read.) for an entire column. Compiling this code: surrounding text. combines the power of longtable. since tabu works the same way. One is that it will not automatically wrap The number of columns does not need to be specified as text in cells.

The column specification can be altered using the array package. rectly balanced when it comes to { and } characters. This can be achieved by doing the following: Here is a table with six centered columns flanked by a The space-suppressing qualities of the @-expression ac- single column on each side: tually make it quite useful for manipulating the horizontal .g. The de. Here the t argument controls the placement of the text inside the box. You may also specify the skip after a line explicitly using glue after the line terminator Here is an example showing the use of both p{. you must define such a box with \newsavebox{\boxname} and then you can define: Space between rows This stores the text in a box and afterwards. This means that >{\bfseries} is valid. To Defining multiple columns add space.fect. fault value is 6pt. you may want to Default value is 1. since the output Column specification using >{\cmd} and <{\cmd} is wider than the page width. TABLES 45 Note that the first table has been cropped..commands to be executed right after each column ele- gorithm when using the p specifier.} and >{\centering} : Note the use of \tabularnewline instead of \\ to avoid a Other environments inside tables Misplaced \noalign error. it is necessary to temporarily store the column text in a box using lrbox. This command kills the inter-column space and replaces it with whatever is between the curly braces.>{\textbf\bgroup}c<{\egroup} produces the intended ef- fault choose very tight columns). As an example: to get a column in math mode en- line breaks by hand. while >{\textbf} will not work and >{\textbf{} is not valid.. In this case it is easiest to use a \par. It typically takes some text as its argument. one can alter the col.) An alternative way to adjust the rule spacing is to This same trick done with \raisebox instead of \underline add \noalign{\smallskip} before or after the \hline and can force all lines in a table to have equal height. math terms or superscripts occur in the text. This works only for some basic LaTeX commands. If you use some LaTeX environments inside table cells. like verbatim or enumerate: @-expressions you might encounter errors similar to The column separator can be specified with the @{. this is not that clear. and when ap- To solve this problem. Admittedly. using the \textbf to produce bold text). such as \underline to underline text. it will automatically insert that text graph” (p. This is done in the argument of the tabular en- Manually broken paragraphs in table cells vironment using >{\command} for commands executed right before each column element and <{\command} for Sometimes it is necessary to not rely on the breaking al.} ! LaTeX Error: Something’s wrong--perhaps a missing construct. (For LaTeX2e. but rather specify the ment. if the Re-define the \arraystretch command to set the space be.2..ter: \begin{tabular}{>{$}c<{$}}. one should use the \bgroup and \egroup commands: To tweak the space between columns (LaTeX will by de.pended to a column.box is needed again one should use \unhcopy instead) and tween rows: passing it to \underline.0.. Other allowed values are c for center and The argument of the > and < specifications must be cor- b for bottom. Another example is box: changing the font: \begin{tabular}{>{\small}c} to print the column in a small font. takes the text out of the box with \unhbox (this destroys the box. and so will require a few It is possible to define many identical columns at once examples to clarify. into each cell in that column before the actual data for that cell. \item.10. This is particularly useful tific tables to have the numbers aligned on the decimal when your table has many columns. use @{\hspace{''width''}}. If there is the need to use the text of the table as an argu- Space between columns ment (for instance. Sometimes. point. m or b). instead of \cline{i-j} commands: the natural varying height that can occur when e. change column specifier to “para. it is desirable in scien- using the *{num}{str} syntax. umn separation: \setlength{\tabcolsep}{5pt}.For other commands. First. use \usebox{\boxname} instead of \unhbox\boxname.

a table of n columns. num_cols is the Aligning columns at decimal points using dcolumn number of subsequent columns to merge. c. This then pro- A negative argument provided for the number of decimal vides the command needed for spanning rows: \mul- places in the new column type allows unlimited decimal tirow{''num_rows’'}{''width''}{''contents’'}. ular to specify the height and width of a table. we take a quick look at how box{width}{height}{object} which can be used with tab- to generate slightly more complex tables. The fol- the commands necessary have to be embedded within the lowing example shows how to resize a table to 8cm width table data itself. We will need tabu instead. A solution to this is to sands in each row (unless \multicolumn is also used). bold characters are wider than their normal counterparts. since we mal point) will be visibly misaligned.p{5.2 Row specification Here is another example exploiting the same ideas to make the familiar and popular “2x2” or double di- It might be convenient to apply the same command over chotomy: every cell of a row. or to have text wrapping specify a width Instead of using @-expressions to build columns of deci. Note that a decimal aligned column is typeset in math The main thing to note when using \multirow is that a mode. the first line of the table itself would be Left&Right&Center&\multicolumn{1}{c}{Decimal}\\ Here is a nontrivial example of how to use spanning in both directions simultaneously and have the borders of the cells drawn correctly: Bold text and dcolumn To draw attention to particular The command \multicolumn{1}{ is just used to draw entries in a table. be adjusted to the number of decimal places specified. or numeric column headings. text in a decimal aligned each subsequent row to be spanned. so the data to be tabulated should the content’s natural width). but fore the decimal separator (assuming there’s no decimal you still need the "&" separating it from the next column’s separator in the text). but a simple way to use dcolumn is as follows. COMMON ELEMENTS spacing between columns. we add \multicolumn{1}{ in the meaning that although the decimals may align nicely. The argu- places. Unfortunately the tabular environment cannot do that by default. which provides the \rowfont option.blank entry must be inserted for each appropriate cell in ing in the example above. While this may be fine for very data. it may be nice to use bold text. and opt out the first column that contains the text “Pow- ers”.4 Controlling table size Resize tables 2. want to be contained within that cell. A simple example: it is possible to center a column on the decimal separator using the dcolumn package. The first thing you need to do is add \usepack- age{multirow} to the preamble[3] . Also.If there is no data for a cell.10. while maintaining the original width/height ratio. which provides a new column specifier for floating point data. The astute reader will already have deduced that for short text. 2.10. Instead we use the command \cline{2-6} bold column type.. column (for example the header) will be right-aligned be. Given a basic table. Unsurprisingly. In addition. And contents is simply the actual data you mals aligned to the decimal point (or equivalent symbol). but may result in rather wide columns. Note that we figures (for more than 2-−3 digits on one side of the deci- cannot just use \hline to draw horizontal lines. hence the use of \mathrm for the column head.Rows spanning multiple columns ing the column descriptions: The command for this looks like this: \multicol- umn{num_cols}{alignment}{contents}. r. 2. but as dcolumn needs to see the deci- cell. use the \multicolumn command described below. the usual still draws vertical borders that only span the first row. It is however possi- do not want the line to be drawn over the text that spans ble to use normal width bold characters and define a new [2] several rows. alignment is either l.}.. and vary. it looks cum. as shown below. spec- ifying a single column and its alignment. Round- ments are pretty simple to deduce (* for the width means ing is not applied. just don't type anything. To compensate for that. just as for column. For exam- ple to center the header Decimal over its column in the Spanning in both directions simultaneously above example.0cm} . .10. See the dcolumn package Columns spanning multiple rows documentation for more information. the following rows spanned by the multirow. it mal point it is rather harder to do. Even when combined with \multirow{2}{*}{. Ordi- vertical borders both on the left and on the right of the narily this is easy. there must always be n − 1 amper- bersome in the example above.46 CHAPTER 2.3 Spanning The graphicx packages features the command \resize- To complete this tutorial.

ments can be created with \newcommand. 2. R (in uppercase). Note that the \multicolumn width (which in this example is 2) should equal the (in this example 1+1) width of the spanned columns: 2. Within it is the \extra- See Fonts for named font sizes. except that the width is calculated automati- ble. otherwise you need also explicitly insert extra column space. It defines a new col- umn specifier. unlike others. \multicolumn. ing the creation of tables.} construct added at the begin- ning of the column description. which may be after the \be. in your tabular. Another option is to use \newcolumntype to format se- or lected columns in a different way. LaTeX has rub- to add a group delimiter.10. an example of this is the following.2.6 Width and stretching In a way analogous to how new commands with argu- We keep providing documentation for tabular* and tab. The table caption font colsep command. The command \rowcol. that may not look quite as intended.. To control the caption font size. you may also apply the \showrowcolors command. by using a rubber length. which. e. LaTeX can dynamically decide how long the lengths should be. . Caption Styles.10. greatly simplify- starts. A fixed width size is not affected. Alternatively. so it may where since there are 4 columns. The command \hiderowcolors is available to deactivate The content provided for the boxes is treated as for a highlighting from a specified row until the end of the ta.10.width specified. TABLES 47 Resizing table including the caption The tabular* environment Alternatively you can use \scalebox{ratio}{object} in the same way but with ratios rather than fixed sizes: This is basically a slight extension on the original tabular version. which requires a width. The ors{<''starting row''>}{<''odd color''>}{<''even color''>} column(s) specified with this specifier will be stretched has to be specified right before the tabular environment to make the table as wide as specified. new column ularx although they are completely eclipsed by the much types with arguments can be created with \newcolumn- more powerful and flexible tabu environment. such as \fill. Highlighting can be reactivated within the table via cally. that it has a new column specifier X (in uppercase). which is similar to the tabular* environment except loaded with the table option.. ber lengths.g. Changing font size However. tables in your document by placing the following code in the preamble: You will notice the @{.5 Colors Alternate row colors in tables The tabularx package The xcolor package provides the necessary commands This package provides a table environment called tabu- to produce tables with alternate row colors. you must gin{table} statement if you use floats. If while using these com. p column. the sum of the \hsize’s be worth it to have an idea how they work. However.5 + 2) must be equal to 4. The default value for tabularx. Actually type as follows: tabu is greatly inspired by those environments. particularly (1 + 0. In this example. The two central columns are posing as one by using the X@{} option. the second and fourth column is adjusted in a different way Colors of individual cells (\raggedleft): Tabularx with rows spanning multiple columns using As above this uses the xcolor package. The A table can be globally switched to a different font size columns are still at their natural width (just wide enough by simply adding the desired size command (here: \foot. If you do not like this default. see could have been used. the columns are automatically spaced evenly.to fit their contents) while the rows are as wide as the table notesize) in the table scope. any >{\cmd} or <{\cmd} command to achieve specific mands you experience “misplaced \noalign errors” then behavior (like \centering. If you use the package array. although it requires an extra argument (before the column descriptions) to specify the preferred width of the table. when larx. are not fixed.5 + 0. or \raggedright\arraybackslash) use the commands at the very beginning or end of a row as described previously. used by tabularx for \hsize is 1. you can change the default font for all the So.

tabulary will try not to exceed it. tabulary allows easy and convenient writing of well balanced tables. The booktabs package is useful for easily providing this 2.10. which have appropriate spacing above and below lines. The first parameter is the maximum width.10. Besides.rule for the lowermost rule. a header for the The following example contrasts the use of booktabs and first page only.10. so you should have a age{dcolumn}. (using \hline\hline or "||"). erly. By using the array package this problem can be the list of tables). \cmidrule LaTeX can do well with long tables: you can specify a can be used for mid-rules that span specified columns. with the additional ca.11 Professional tables Many professionally typeset books and journals feature The tabu environment simple tables.7 Table across several pages professionalism in LaTeX tables. 2. and the third example requires \usepack- look at its documentation if you want to know more. Unfortunately this environ- In brief. set for equal heights. It of the table (such as under the header). The longtabular fixes that. two equivalent normal LaTeX implementations (the sec- ond example requires \usepackage{array} or \usepack- It uses syntax similar to longtable. The problem with tabularx is that it leaves much blank if your cells are almost empty. The X parameter case the use of vertical rules (using "|"). it is not easy to have different column sizes. header that will repeat on every page.10. weight and spacing are acceptable. (or line). both in normal and long ta- bles. an extended and somewhat im- proved version of supertabular. Alternatively you can try one of the following packages supertabular or xtab. The second parameter is the column disposition. This ensures that the rule pability to span multiple pages. . the longtable environment. \midrule for the rules appearing in the middle The tabu packages provides the longtabu environment. and the documentation also provides guidelines on what constitutes a “good” ta- Long tables are natively supported by LaTeX thanks to ble. These are addressed by the ctable 2. In addition.10. contrary to tabularx. It provides the option of a short caption given to be inserted in the list of tables.9 Vertically centered images package. and \bottom- has most of the features of tabu. The ctable uses the booktabs package. and the same for the footer. A raisebox works as well. tabulary is a modified tabular* allowing width of columns Or use a parbox to center the image.10 Footnotes in tables tabulary tries to balance the column widths so that each column has at least its natural width. which are regarded as unnec- essary and distracting in a professionally published form. age{booktabs} in the preamble). amples of LaTeX tables (including this Wikibook) show- to \linewidth specifies the target width. instead of the actual Inserting images into a table row will align it at the top of caption (which may be quite long and inappropriate for the cell. handles footnotes properly. Normal LaTeX Using array 2. Defining a new columntype will keep the image vertically centered. with a caption properly spaced above the table. and double-rules can have an optional span factor. the package uses \toprule for the uppermost rule ment does not support stretching (X columns). plus These are all capitals.48 CHAPTER 2. Many ex- It works pretty much like tabularx. COMMON ELEMENTS The tabulary package solved. but it will not stretch to it if there is Instead of using longtabular we recommend tabu which not enough content. without exceeding The tabular environment does not handle footnotes prop- the maximum length. Possible values are those from the tabular environment.8 Partial vertical lines Using booktabs Adding a partial vertical line to an individual cell: Removing part of a vertical line in a particular cell: Usually the need arises for footnotes under a table (and not at the bottom of the page). also allowing to manually fine- tune the alignment with its first parameter. 2. and almost never use vertical rules.

The table environment initiates a type of float just as the environment figure. one has no idea on which page ysis tools the current text is going to lie. Ex- ample: In the table. Gener- TeX format.. captions. During compi.10. TABLES 49 2. Combined with the array forces LaTeX to place it exactly where you place it (Ex- package. Us- synching up. Let’s sum it up: 2.16 Using spreadsheets and data anal- view of the source code. • matrix2latex: for MATLAB. we used a label. which means that it is by default placed on the command \eqmakebox which is like \makebox but in. so it is hardly possible to guess which page may be appropriate for our table..10. so now we can refer to it just like any other reference: The normal caption is needed for labels and references. • matrix2latex: for Python and MATLAB. contains the widest text and can stretch all \eqmakeboxes You can force LaTeX to use one given position. however. e. The table environment is also useful when you want to have a list of tables at the beginning or end of your doc- 2. etc. we need to put a table environment around the tabular environ. ery row in a table to the natural width of its longest line. La- For complex or dynamic tables. it takes a tag. or by enclosing it with a center envi- tables in the middle of the text.). The following plugins and libraries are avail- ally.. often make it a point to print tables on a dedicated page so that they do not disrupt the flow. one can define a column specifier that justifies cept when it’s really impossible.13 Table with legend • tabular is for the content itself (columns. The following characters are all possible placements. been doing until now. • table is for the location of the table on the document.} state- ment can be added besides the normal \caption{.org Calc spreadsheets. but cannot justify the text. From the point of 2..15 Floating with table Centering the table horizontally works like everything else.10. do not use the table environment. etc. ment.}. You can set the optional parameter position specifier to for instance when one has the same text in two languages and wishes to present these next to each other with lines define the position of the table. To tell LaTeX we want to use our table as a float. • calc2latex: for OpenOffice. but one can choose to control its position also.10.10.. pictures. played. The eqparbox package provides Default is tbp. the top of the page. E. If that’s not possible. chapter.g. the two bear a lot of sim. can be found Tables can also be put on their side within a document us. A tabular environment helps control where lines should break. captions etc. a specific place. it’s placed at stead of a width argument. This is what we have ronment. lines. etc. Again. the bottom if possible. but it will not be placed there if LaTeX thinks it will not look great. you may want to use a TeX can automate this task by abstracting objects such spreadsheet. You might save lots of time by building ta- as tables. it is common to put table environment. [!h] with the same tag to that width. an object that is floated will appear in the vicinity of able for some popular software: its introduction in the source file. In fact.2. • excel2latex: for Microsoft Office Excel. See the documentation of the eqparbox package for more understand it correctly: it urges LaTeX to put the table at details. . it might be necessary to stretch ev. Professional documents.). where it should be placed.10. To add a legend to a table the caption package can be plus caption and label support. used. Figures and Captions. if dis- On rare occasions.in Floats. See the Rotations The environment names may now seem quite confusing. ing the rotating or the rotfloat package.12 Sideways tables ilarities (positioning. to ragged right edges. This abstraction is called a float. With the caption package a \caption*{.14 The eqparbox package ument with the command The captions now show up in the list of tables. 2. or finally with other floating envi- lation it bookkeeps which \eqmakebox with a certain tag ronments on an extra page. which is able to float and add a label and caption. If you really want to place your table manually. using the \centering command just after opening the In WYSIWYG document processors. and deciding for us where they bles using specialized software and exporting them in La- might fit best. which leads ing sequences of it define your “wishlist” to LaTeX. More information about floating environments.g you place a table here the text in all lines: and this place would be the last line on a page).

generate the source code to a separate file which you can [2] D Carlisle. • pgfplotstable: Loads. rounds.10. tabular(*). can generate your complete document (table included) in one command. but longer documents (such as books and reports) often require more involved for- • hhline: do whatever you want with horizontal lines matting. and longtable environments are supported using all features of • xtable: a library for R. • array: gives you more freedom on how to define There are several situations where you might want to cre- columns ate a title in a custom format. exponent and/or rounded to a given number • latex-tools: a Ruby library.1 Standard Titles • ctable: allows for footnotes under table and properly spaced caption above (incorporates booktabs pack. Stackexchange. come with Tex To form a title.18 References [1] http://tex. 2. La- TeX format is directly generated as you type. While it is possible • colortbl: make your table more colorful to change the output of \maketitle.stackexchange.11.com/questions/118458/ decimals-in-table-dont-align-with-dcolumn-when-bolded. see for a tutorial. • diagbox: compatible to slashbox. Not available in Tex ing \date{}.com/questions/121841/ However. mand.11 Title Creation 2. with sepa- rators. the output of \maketitle is often adequate. [3] Package multirow on CTAN See Modular Documents for more details. file. use the . One must specify what to fill it with using these commands placed in the top matter: • slashbox: create 2D tables with the first cell contain- Commonly the date is excluded from the title page by us- ing a description for both axes. copying the generated source code to your doc. or math) in order to use the correct font. rather than in the format natively supported by LaTeX classes. • numprint: print numbers. array. for creating simple tables within the browser.10. and this section both within the table and its caption will show you how to accomplish this. COMMON ELEMENTS • pandas: pandas DataFrame’s have a method to con.17 Need more complicated features? Have a look at one of the following packages: For documents such as basic articles. tabularx. It defaults to \today if omitted in the source Live 2011 or later. is-the-tabu-package-obsolete ument is not convenient at all. you http://tex.50 CHAPTER 2. If you want cells with rounding to have a separate title page for articles as well. while the article document class • rccol: advanced decimal point alignment of numeric will place the title on the top of the first page. If your speadsheet supports command-line. For maximum flexibility. it can be complicated even with minor changes to the title. “Decimals in table don't align input from your main document file with the \input com. We will detail the process here. this will form a separate page.stackexchange. • arydshln: creates dashed horizontal and vertical lines 2. 2. org-mode tables can be • spreadtab: spread sheets allowing the use of formu- used inline in LaTeX documents. For most document classes. formats and postpro- • Online Table generator for LATeX: An online tool cesses numerical tables. of digits. numprint • org-mode: for Emacs users. with dcolumn when bolded”. using a Makefile for example.Many document classes will form a title or a title page age) for you. use Live 2011 or later This should go after the preceding commands after begin- • dcolumn: decimal point alignment of numeric cells ning the document. lae • Emacs align commands: the align commands can • siunitx: alignment of tabular entries clean up a messy LaTeX table. in the current mode (text vert data they contain to latex. • Create LaTeX tables online : Online tool. In such cases it is of- • threeparttable makes it possible to put footnotes ten better to create the title from scratch.

There is no \be- gin{figure} as you would usually use since you don't want it to be floating. \huge. but you can do it: it’s only for the title and your complicated code will be isolated from all the rest within 2. A practical example All these tips might have made ten provide a template which defines the layout. TITLE CREATION 51 documentclass option titlepage command. To ensure this they of. \LARGE. You can start testing right away.11.2 The title for journal submission Journals follow a specific layout. you just want it exactly where want it to be. If you start changing fonts it gets even more com- plicated.2. Master. You need to know very basic LaTeX layout commands in order to get your own title page perfect. \footnotesize. . Usually a custom titlepage does not contain any semantic markup. and you can use the following commands (in order of size): \Huge. \Large. you will ensure that all the following text will be placed at the bottom of the page. affiliation ple.3 Create a custom title for a report or its own file.15\textwidth]{. book The result is shown below The title page of a book or a report is the first thing a reader will see. For example. Filling the page It is dependent on the document class which commands are used in the title generated by \maketitle. \normalsize. Remember. The picture in use comes with package mwe and names. Integrating the title page A title page for a book or So for example: a report to get a university degree {Bachelor. Here are some of the most often needed things: Alignment If you want to center some text just use \centering. Keep that in mind when preparing your title page. one may add even if it is a bit of text on a single line. {like this}. Follow the tion. end it with \par. remember that it is considered like a big box by the TeX engine. If you put it within the page. Here is a practical and compilable exam- is available for the title (for example emails. The \thanks command can also be used in the \title. every- thing is hand crafted.11. Referring to The command \vfill as the last item of your content will the documentation will lead to trusted information. If they don't you As you can see. add empty space until the page is full. \large. What you confused. When handling it. as well. if you have a block of text in a different size. 2. the code looks “dirtier” than standard La- should use the most basic concepts of LaTeX titles de- TeX source because you have to take care of the output scribed above. Text size If you want to change the size of some text just place it within braces. keywords) heavily depends on the template and should be available with every complete LaTeX installa- highly differs between different journals.11. If you want to align it differently you can use the environment \raggedleft for right-alignment and \raggedright for left- alignment. template if the journal provides one./logo}. \small. \tiny. Images The command for including images (a logo for example) is the following : \includegraph- ics[width=0.

To and columns. LaTeX and the document class will normally take care of page layout issues for you. As a starting point. \topmargin = 20pt title pages.SE has a collection of titlepages. cept into account. departments and companies have strict that you may wish to change: margins. 2.[2] Frontespizio package webpage on CTAN tle page is required to have completely different margins compared to the rest of the document.27pt in an inch or 1pt ≈ Package authblk [3] provides new means to typeset the 0. the person creating the package should are by default one-sided. books are two-sided. It will later be hidden from the Documents can be either one. authors. This is especially helpful for journal submissions without an available template. It defines a frontispiece as used in Italia. though it is not much.sty is generated that defines the 2. Which to make the article class two-sided. Look around what happens if you leave one or the other For one-sided document. All sizes are given package[2] . to name but three. etc. Two- maintain it for a long time.12 Page Layout tlepage2016. ment of the page.3515mm.12.A page in LaTeX is defined by many internal parame- ting of the \maketitle and \thanks commands.11. \headsep = 25pt .12.11. Articles end user. you can include it quite simply. If you want user can set the variables for title and the like. TeX. They are referred to as even and odd. let’s pretend it is called reportTi. and which might be class[twoside]{article}.52 CHAPTER 2. The purpose of this tu- ensure the very same output for all reports.ter.2.1 Two-sided documents complete title matter. COMMON ELEMENTS Ph. a redefiniton torial is to show you how to configure your pages. 1.. Each parameter corresponds to the length of an ele- for small changes to the standard output. The table effect can be seen in page margins. \headheight = 12pt Another small collection can be found on Github. for example. This is really useful. this entire topic will be out of your hands. 6. Here you can see a diagram show- Italian users may also want to use the frontespizio ing all the variables defining the page. if the ti. it doesn't really change over 2. one inch + \hoffset 2. It is useful ters. as 2. \paperheight is the physi- cal height of the page. \oddsidemargin = 31pt The titlepages package presents many different styles for 4. Here is a short document setup. Ideally. A sim.2 Page dimensions The titling package[1] provides control over the typeset.11.) is quite static. page orientation rules how a title page of a report should look like. whereas one-sided do not.4 A title to be re-used multiple times the publishers want to control the presentation.7 Notes and References time. a LaTeX package called columbidaeTitle. You can prepare the titlepage in its own little doc- ument and prepare a one page pdf that you later include [1] Titling package webpage on CTAN into your real document. It also saves com. there are some obvious settings Some universities. You should have a look at Lengths for comprehensive ple example follows. For submission to an academic publication. (odd) pages. We will often have to deal with TeX lengths in this chap- This is best done by an experienced LaTeX user. for your own documents. omissible should be written in a documentation that is Many commands and variables in LaTeX take this con- bundled with the package. of the \maketitle command is recommended. 5. variables will be in effect. in TeX points (pt). Assuming you have done the title page of your report in an extra document.D. as usual there is no real limit with details on the topic. create an accompanying sided documents differentiate the left (even) and right documentation and ensure user support.or two-sided. there are 72.6 More titlepage examples 3. use \document- commands are actually available.11. one inch + \voffset 2.5 Packages for custom titles 2.pdf.[3] authblk package webpage on CTAN pile time. respect to complexity. However. only the odd commands and command out. The most no- This package can be loaded within a usual document.

.2. cations. \textheight = 592pt • legalpaper.3 Page size 4 2 5 Header It will not have been immediately obvious .that the de- 6 fault page size for all standard document classes is US let- ter. \textwidth = 390pt • executivepaper.. and you may end up with a PDF which has not . 7.. \marginparsep = 10pt To explicitly change the paper dimensions using the ge- 10.. For example: 11. 8 to set the page size.12. Some of these tools do not have the same interpretation of the DVI. b1paper. built in. While this is not a serious issue (most printers will print the doc- ument without any problems). \marginparwidth = 35pt ometry package.12.pdf # PS → PDF you are currently working on. PS and PDF specifi- to the document. Others include: 1 • a0paper. and slightly wider by 8 mm (about 1/4 inch). \footskip = 30pt Page size issues • \marginparpush = 7pt (not shown) If you intend to get a PDF in the end. the paperwidth and paperheight options can be used. For A4 format: Margin notes Body 7 More size options with geometry 9 10 One of the most versatile packages for page layout is 3 the geometry package. \layout{} latex myfile # TeX → DVI dvips myfile -o myfile. there are basically • \hoffset = 0pt three ways: • \voffset = 0pt • TeX → PDF • \paperwidth = 597pt pdflatex myfile # TeX → PDF • \paperheight = 845pt • TeX → DVI → PDF The current details plus the layout shape can be printed latex myfile # TeX → DVI dvipdf myfile # DVI → PDF from a LaTeX document itself.ps myfile. it is possible to specify al- ternative sizes as class option. . The immediate advantage of this package is that it lets you customize the page size even with classes that do not support the options. • letterpaper. add the following to your preamble: 11 The geometry package has many pre-defined page sizes.. For instance. 8.. a6paper.. b6paper. • TeX → DVI → PS → PDF age{layout} .ps # To render a frame marking the margins of a document DVI → PS ps2pdf myfile. add Sadly the PDF output page size may not be completely re- \usepackage{showframe} spectful of your settings. PAGE LAYOUT 53 2..because it doesn't really cause any serious problems . compared to A4 (which is the standard in almost all the rest of the world). a1paper. Footer like a4paper.. This is shorter by 18 mm (about 3/4 inch). 9. Use the layout pack- age and the command of the same name: \usepack. • b0paper.

In order to create PDF documents with duces the margins. leaving about 60% of the page with A4 document size with smaller margins. the fullpage package has a cm to the processors used during output generation: option (around 1. used for the inside and outside margins respectively.. Use geometry package instead ies have shown[2][3] that it’s easier to read text when there like this: are 60–70 characters per line—and it would seem that 66 is the optimal number. 1. Stud. geometry package. not only must the text field may not need to specify anything... • One older approach is to use the fullpage package etry usually works. this command provides more conven- the paper size used by the Supreme Court of the United tional margins. Another op. 2. page..297mm by 8. Thus. These values are and margins be adjusted. so must the page size. there are many ways to do so: • For pdflatex to work fine. # On Win. for somewhat standardized smaller margins (around an inch).e.g. If you relative to the edge of paper (0in) and go inward. replace 210mm. better using the vertical space of the States.5cm). mands. For instance. Note that by default ital devices need to create documents without the ex. 441pt by 666pt (or 6. (i. also have aliases inner and outer. consider following For example. [1] what is considered readable: If you want US Letter instead. page size appropriately.4 Margins It can also recreate the behavior of the fullpage package using Readers used to perusing typical physical literature are You can combine the margin options with the page size probably wondering why there is so much white space options seen in this paragraph. See the Lengths chapter. about double dows: ps2pdf -sPAPERSIZE#a4 . ters for letter-sized paper and slightly less when us- the font required by the Supreme Court. For example. It is width for text. the options left and right are taken by print magazines because it provides both read.54 CHAPTER 2. obsolete and buggy. the page margins are set to ensure optimal readability. Therefore. the line lengths are about 88 charac- this is too wide for fonts other than Century Schoolbook. COMMON ELEMENTS exactly the right size.11in and a4paper by letter. The reason is improved readability.. Sometimes. but tion is used. Also replace a4 by • A more modern and flexible approach is to use the letter in command-line parameters. using the package geom. If you wish to avoid excessive white space. above. Use cm for centimeters and in for inches after each Those who want to read on tablets or other handheld dig.25 inches). rather than Odd and even margins changing the margins. without any options) this package already re- tra whitespace.5in. without creating the dramatically long lines of which looks great on tablets.. Thankfully there is a solution to without changing the margins is to increase the font size that: the \special command lets the user pass PostScript using the 12pt option to the document class. sumption that the document will be bound. consider instead using a two- column (or more) layout.125 inches by 9. which can be used here to set the If you wish to change the margins of your document. the easiest way to tion for reducing the amount of whitespace on the page handle different margins for odd and even pages is to give . or PDF parameters. You could also use the the fullpage package (if the 11pt documentclass op- Supreme Court’s text field size of 297 pt by 513 pt. on A4 paper a doc- ument will typically have 44 mm margin widths on the • You should not use the a4wide package for a page left and right of the page. the safest way to always acters per line at with the 10pt default font size (and get the right paper size in the end is to add about 90 if the 12pt documentclass option is used): to the tex file. This package allows you to spec- ify the 4 margins without needing to remember the particular page dimensions commands. but it creates lines of more than 100 char- • For the DVI and PS ways. They able line lengths and good use of the page. which results in about 120 char- dvips -t a4 . You can en- Page size for tablets ter the measures in centimeters and inches as well. are looking for a sensible dimension. value (e. and to append the appropriate parameters For even narrower margins. This approach is the one usually Using the geometry package. surrounding the text.acters per line at the 10pt default font size.54cm).0in or 2.12. using the \addtolength and \setlength com- this white space is left in the inner margin with the as. so for a 'standard layout' you optimal handheld viewing. ps2pdf -sPAPERSIZE=a4 . ing a4paper). and excessive margin • Edit individual page dimension variables described white space is tolerated as a consequence.

which is itself inside the land- for the large margin is chosen opposite to the side where scape environment. you still want the consistency of possible styles are: . as one could scaped page.12. option). but the one we prefer is the geometry package. The macro can be fixed using a few lines of extra Top margin above Chapter code in the preamble[4] . page size and rotation of a means changing to landscape mode. to get a table to appear correctly centered on a land- oddsidemargin in the two-sided layout. and page numbers. chapter string all the options together. fix this you need the package rotating. the value of evensidemargin is larger than Also. No actual page dimensions are changed.7 Page styles package. For instance it should look like this: pages are joined together. while the rest half of odd’s default: will be left in portrait orientation. rotated. the landscape-environment unfortunately does not pay attention to the different layout of even and odd pages.approach is more applicable to books or reports than to typical academic publications.12. you can use the same class options: Standard page styles Change orientation of specific part The possibilities of changing the headers in plain La- tex are actually quite limited. you will see that the table is of a chapter is changed. The scape page. 2. and \this- diagram or table that would be displayed better on a land. separating with a comma: or section numbers/names. Using pdflscape instead of try will remove the difference between the margins. It will not be floated! To can be omitted.5 Page orientation When you talk about changing page orientation. but you have some contents. PAGE LAYOUT 55 the twoside option in the document class command and your headers and footers appearing the same place as the specify the margins as usually. one must place the tabular environment in- wish to write notes on the side of the page. See the Rotations chapter. This will result in a value of 4cm on all inner margins (left The lscape package is for this very purpose. simply These headers typically contain document titles.12. We shall introduce two slightly different styles of changing orientation. There are various packages available to achieve this. However. All you need to do is call the 2.6 Margins. pagestyle{''style''} will only affect the current page. size. since portrait is the specific page default. It supplies margin for odd number pages and right margin for even a landscape environment. Although. In case of a section this command inserted where it is in the code. if you intend to use geometry to set your paper but to the running headers and footers of a document.12. This Setting the same value for the inner and outer for geome. it usually 2. An- other quick way to eliminate the difference in position lscape when generating a PDF document will make the between even and odd numbered pages would be setting page appear right side up when viewed: the single page the values to evensidemargin and oddsidemargin to the that is in landscape format will be rotated. the geometry package comes in Change orientation of the whole document handy for specifying new margins for a single page only. Using standard LaTeX classes. available: \pagestyle{''style''} will apply the specified ment in portrait. Example: Change orientation of floating environment The command \titleformat must be used when the spacing If you use the above code. For books (and in general documents using the twoside See the Lengths. The side side a table environment. like a large style to the current and all subsequent pages. By default. The top margin above a chapter can be changed using the titlesec package. Again. Note that order matters! The first is for when you want all of your document to be in landscape from the very beginning. other pages. If you need to rotate the page so that the figure fits. There are two commands The second method is for when you are writing a docu. don't add the \usepackage commands twice. with landscape as an option: Page styles in Latex terms refers not to page dimensions. the chances are good that you need to scale the margins and the font size too. and anything inside is basically pages) and 2cm margin on outer margins.2.

so that \thispagestyle{} cannot be applied to that Style customization The styles can be customized page. Now \leftmark and \rightmark will just print the name of the chapter and section. • Use fancyhdr as described below. For ultimate header and \fancyfoot for footer. new section commands with \thispagestyle{empty}. you might header and footer lines of your document. and stage approach. respectively. use them differently. Both the header and footer comprise three elements each Plain pages issue An issue to look out for is that the according to its horizontal position (left. are to be updated. The follow. The \part command. major sectioning commands (\part. otherwise you will get a warning and possibly formatting issues. then the style command at each section will override your initial rule. Choose the one you like most. This package will make \pagestyle{plain} have To set header and footer style. the package titleps). So. or \sub- ment will set the header of all pages (one-sided) to contain sectionmark) that is responsible for redefining \rightmark “John Smith” top left. cause it sets the page style. They all provide the same features. Note that these redefinitions must Customizing with fancyhdr be inserted after the first call of \pagestyle{fancy}. • You can use the following six commands. but for absolutely all pages. but also advances to the next page. mand: • fancyhdr will handle the process its own way. Note that \leftmark and \rightmark convert the names to Again. the \chapter command and its friends do not re- to set the content of the headings by hand. \chapter or \maketi. complete guide. l. Two solutions: with fancyhdr specific commands. with the following commands you can define documentation. add the following lines to your preamble: and the footer: You can now observe a new style in your document. be. The tricky problem when customizing headers and foot- ers is to get things like running section and chapter names Hopefully. page number top right: \markboth{Chapter/Section name}{} must be used in- There are special commands containing details on the side the sectioning command if header and footer lines running page of the document. without number and without af- fecting the formatting. whichever was the formatting of the text. the author of the package produced this Moreover. The values of these two commands are overwritten whenever • You can also use the command \fancyhead for a chapter or section command is processed. In the header and footer definition.The styles supported by fancyhdr: tle) specify a \thispagestyle{plain}. To achieve the intended result one can follow the style pages such as chapters and titlepage. COMMON ELEMENTS The commands \markright and \markboth can be used flexibility. one can use the package fancyhdr written by Piet van Oostrum. the current section and chapter heading. the behaviour of the above commands is fairly in there. beginning of your document. centre or right). it affects the head etc. The \headheight needs to be 13. several packages provide a solution: uppercase. The standard book formatting of the \chaptermark is: To get better control over the headers.need to make a call to the \fancypagestyle command.56 CHAPTER 2. • fancyplain is the same. They work in the .define \rightmark and \leftmark themselves. ble. centre and right respec- use the commands \rightmark and \leftmark to represent tively. however. Standard LaTeX accomplishes this with a two. you just suppressing page numbering when it is used. the second for the footer.6pt or more. you obviously. except if they are starred -. For a more see overlapping text. \sectionmark. “On page styles” centered and theand \leftmark. It pro- Watch out: if you provide long text in two different vides several commands that allow you to customize the “parts” only in the footer or only in the header. c and r means left. Those two styles may be configured directly. fancyhdr provides three the same effect as \pagestyle{empty}. The first line for the header. Setting it to zero means that there will be no line. If you want them to print the actual name of the chapter • an alternative one-stage mechanism is provided by without converting it to uppercase use the following com. for those pages • fancy defines a new header for all pages but plain- only. whereas for LaTeX styles you • simply write \usepackage{nopageno} in the pream. intuitive: if it has head in it. They call yet ing commands placed at the beginning of an article docu-another command (\chaptermark.in such a case. the thickness of the decorative lines on both the header To begin. effectively interfaces. if you wish to suppress all styles by inserting a \pagestyle{empty} at the • the four LaTeX styles. cannot be fixed this way.

Using \fancyhf can make it shorter: • multicol outputs balanced columns.ground of every page or individual pages. plainstyle command. Here’s a somewhat complicated example for a two-sided book style: You can use multiple selectors optionally separated by a comma. which will give the desired effect. outer. add a backslash after \thep- age to ensure adequate space between the page number and 'of'. like article. and titleps. PAGE LAYOUT 57 same way. have to run LaTeX an extra time to resolve the cross- To customize LaTeX default style you need the \fancy. but you will get empty header and footer in the title and at the Using the twocolumn optional class argument beginning of chapters. Plain pages There are two ways to change the style of 2. very simi- will just delete the current heading/footer configuration. And recall. you tend to think in terms of inner possible to mix the number of columns within a doc- and outer. However. and current page number is bottom other environments..references. For a clean customization. mand applies to the current page only. for ex... is: This is effectively saying author name is top outer. Alternative packages Providing empty values will make the field blank. An example is the following: While this approach is useful. The can simply pass the optional argument twocolumn to the command to use is \fancypagestyle{plain}{.. • Can support up to ten columns. Alternatively you could redefine the plain style. So Other packages for page styles are scrpage2. For instance: 2. that you These commands will only work for fancy and fancyplain. in all the other cases it will use the second argument.}. so we'll explain only the first one. when using references. such as figure. If you do so. Examples For two-sided. There are two additional selectors the lastpage package to find the total number of pages. First you can use the fancyplain style. it’s common to mirror the • Implements a multicols environment. Note the capital letters. . without having to use \leftmark or \rightmark. it has limitations. etc.} and the ar. document class: \documentclass[twocolumn]{article} gument can contain all the commands explained before. Also. whereby the Here is the complete code of a possible style you could columns on the final page will be of roughly equal use for a two-sided document: length. it is style of opposite pages. So. The mul- In that case you can use any style but fancyplain because ticol package provides the following advantages: it would override your redefinition. lar to fancyhdr. you The eso-pic package will let you print content in the back- can use the command \fancyplain{. proach. • Additionally. cess to the current page number.12.RO will refer to the center of the even pages and Page n of m to the right side of the odd pages. Some people like to put the current page number in con- text with the whole document. the same example as above for two-sided ument.2. it will insert the first argument of \fancyplain. you ample to have a really plain page when you want.. H and F to specify the header or the footer. See below for examples. we recommend you start from scratch. hdr commands like \lhead{..8 Page background plain pages like chapters and titlepage.12. to. the environment can be nested inside day’s date is top inner.. To do so you should erase the current pagestyle.}{. The selectors are the following: so CE. The Using \fancypagestyle one can additionally define multi- syntax is: ple styles for one’s document that are easy to switch be- tween. The starred-version of the \AddToShipoutPicture com- When LaTeX wants to create a page with an empty style. respec- like this: tively. you can use hence the name.12.} inside fancy. If you omit the H and the F. which takes a one-stage ap- so you can make your own. therefore. LaTeX only provides ac- • \fancyhf is a merge of \fancyhead and \fancyfoot.9 Multi-column pages It has the same behavior of the previous code.. it will set the fields for both. Using a standard Latex document class.

\includegraphics[height=3cm]{example-image- LaTeX has a parameter for 'penalty' for widows and or. which is quite nar.12. LaTeX itself treats the image like normal text. It can only cope if you use the starred forms of the float com- 2.serve some lines and thus to prevent page breaking for ings of twocolumn and provides the multicol environ. However. be necessary to manually tweak the page formatting.12..com/questions/4982219/ how-to-make-landscape-mode-rotate-properly-in-a-twoside-book/ There may be instances. you can use the needspace package to re- The multicol package overcomes some of the shortcom.1.2 [3] http://baymard.12. it is not recommended to set this value too high. which can be set using \setlength: and complicated by padding whitespace.age does not show any wombats ments.those lines.10 Manual page formatting [4] https://stackoverflow.10000 forbids LaTeX from doing this altogether.com/blog/line-length-readability 2. The most important command is \includegraphics. the major page elements. With the \includegraphics[height=3cm]{example-image-a} greater penalty LaTeX will try more to avoid widows \includegraphics[width=5cm]{example-image-b} . It may.1 Importing external graphics You can import external graphics using package graph- 2. might result in strange behavior. It also helps to have rubber band values for the space be- Using multicol package tween paragraphs: Alternatively.net/2.e. since floats to turn on the showframe option in the geometry pack- of the same width as a column may be too small.12 Troubleshooting mands (e. sets the width of the vertical rule between columns and defaults to 0pt 2. as setting it to • Column environments can be easily customised lo. to a maximum of 10000. therefore. row [1] How to use Ghostscript To force a break in a column. ment. which cally or globally. you should only do this at the very final stage of producing your document. you can try increasing these values • Vertical rules between columns can be customised. i. You can try to increase these penalties by columns. LaTeX offers the following: 2. but there’s also an automatic solution. that LaTeX will not get all page breaks looking as good as it could.12. This is not hugely problematic. COMMON ELEMENTS • Use multicols* environment for unbalanced and orphans.a}\includegraphics[width=5cm]{example-image-b} phans ('club lines’ in LaTeX terminology). [2] http://webtypography. You can try to deal with them using manual page \includegraphics[height=\baselineskip]{example- formatting.g. it’s not desirable to have single lines box of certain height and width. It draws bounding boxes around tion for a more detailed discussion.with LaTeX with permission from the author. especially in very long docu.13 Notes and References • \columnsep. See this sec- age described above). even more. image}. • \columnseprule. \begin{figure*} ) which makes the float span A very useful troubleshooting and designing technique is all columns.13. the command \columnbreak is used.13 Importing Graphics course. If this does not help.11 Widows and orphans icx. once all the content is com- plete. In typesetting such sit. such as books. as a In professional books.58 CHAPTER 2. which can be helpful because The multicol package has two important parameters the boundaries of various regions are usually invisible. sets the horizontal space between This page uses material from Andy Roberts’ Getting to grips columns and the defaults to 10pt. To create a typical two-column layout: Floats are not fully supported by this environment. 5320962#5320962 ments.\documentclass{article} \usepackage{graphicx} uations are called 'widows’ and 'orphans’. whereby each column is completely filled putting following commands in your document preamble: before starting with the next column. and you age (which has the same effect as the showframe pack- would probably want to span them anyway. Normally it is \begin{document} The following im- possible that widows and orphans appear in LaTeX docu. Of 2. at the beginning or end of a page.

the fonts are NOT converted to lines. IMPORTING GRAPHICS 59 \end{document} included in package of the same name.13. imgtops imgtops is a lightweight graphics utility for conversions between raster graphics (JPG. which reduces the quality of the fonts.13. 2. However. In Windows. done LaTeX in dvi-mode supports only eps-files. eps2eps When all of the above fails. $ for i in *.eps to crop final PDF.eps) do epstopdf %%f which can then be run from the command line. You can batch convert files using the command-line. as well as others.eps This will convert all the fonts to pre-drawn images. do epstopdf "$i". . This height.bat extension) in the same directory as the images: for %%f in (*.eps or try using ps2pdf utility which should be installed with Ghostscript (required for any TeX distribution). process is completely invisible to the user.eps.2.. For You should also take a look at Export To Other Formats instance. to obtain a PDF from a SVG image you can do: for other possibilities. If epstopdf produces whole page with your small graphics somewhere on it. Modern installations of LaTeX can use Bourne Shell (Unix) this can be done by: eps files as well.eps input-e2.pdf epstopdf It is possible to run this from within a LaTeX file.) and EPS/PS files. png and jpg. You can convert EPS to PDF with the epstopdf utility.. $ ps2pdf -dEPSCrop foo.2 Converting graphics Inkscape Note Inkscape can also convert files from and to several for- mats. but instead to bitmaps. In Using pdflatex several graphics formats are supported: pdf.svg --export-pdf=output. on the downside. the Template:LaTeX/package package (when running . either from the GUI or from the command-line. but indirectly. by using the eps2eps tool (also see next section): $ eps2eps input. This tool is actu- ally called by pdflatex to convert EPS files to PDF in the The package documentation list the options width and background when the graphicx package is loaded. which is sometimes desirable when submitting manuscripts for publication. use $ epstopdf --gsopt=-dEPSCrop foo. one can simplify the EPS file before attempting other conversions. multiple files can be converted by placing the following line in a batch file (a text file with a . PNG. $ inkscape -z -D --file=input.

Dia Raster graphics converters Dia is a cross platform diagramming utility which can export eps images.Vector graphics gram). fered by Xfig. $ pstoedit -f plot-svg input. EPS and PDF.eps input-e2. example too. This can be achieved with the eps2eps of the Ghostscript package and programs: pstoedit $ eps2eps input. PDFCreator is an open source software to convert them before importing them. Diagrams of any sort should be vectors.48. Sam2p how.. COMMON ELEMENTS (pdf)latex with the --shell-escape option) can do this us. Raster graphics should only be used in case Sometimes pstoedit fails to create the target format (for of photos. PDFCreator • PNG and JPG for raster graphics. ping the alpha channel. It works with Scalable Vector Graph- ics (SVG) files. Sometimes color EPS figures need to be converted to TeX? -. . Converting a color EPS to grayscale ing Inkscape’s pdf+tex export option.svg You should prefer vector graphics over raster graphics for their quality. It can run natively under Windows. For instance. You can solve this problem by drop.3 Third-party graphics tools $ pstoedit -f fig input. See Introducing Procedural tool like Inkscape) you can do: Graphics for that.60 CHAPTER 2.[1] . such as can convert between most graphics formats. ments. • Sam2p (convert) or Inkscape • ImageMagick (convert) or Another program for creating vector graphics is Inkscape. • GraphicsMagick (gm convert).eps To properly edit an EPS file.fig We will not tackle the topic of procedural graphics cre- ated from within LaTeX code here (TikZ. that can create PDF as well as EPS files.” entry in their menu (virtually any pro. PSTricks.. There are instructions on how to save your vector images in a PDF format understood by LaTeX and have LaTeX manage the text styles and sizes in the im- PNG alpha channel age automatically.13. LaTeX handles tion).As we have seen before. similar to that of- both the best quality and to result in the smallest files. although it can export to many for- These three programs operate much the same way. or generate tex drawn using the tikz package.png ical notation or LaTeX fonts into graphics (which may then be imported into LaTeX documents).eps output. Linux or Mac OS X (with X11). you may want Under Windows. If some tools cannot save in those formats.eps output. or a simple macro can be used. do: 2.eps input-gray. You may have a look at this extended with alpha channel.Stackexchange See Export To Other Formats for black-and-white or grayscale to meet publication require- more details. which can import convert from the ImageMagick program: LaTeX objects. you can convert it to an ed- itable format using pstoedit. On Linux it can be achieved with An extremely useful plug-in is textext. and mats that can be included in LaTeX files. From version 0. It installs a virtual printer that can be accessed from other software having a “print. And to get an SVG file (editable with any vector graphics MetaPost and friends). example when the EPS file contains clipping informa.eps $ pscol −0gray input- e2. This can be used for inserting mathemat- convert -alpha off input. to get an Xfig- editable file. there is a combined ever is the most recent of the three and seems to offer PDF/EPS/PS+LaTeX output option. See How to include SVG diagrams in La. • EPS and PDF for vector graphics.png output. Today there is the svg package[2] which provides an \includesvg command to convert and Acrobat Reader sometimes has problems with displaying include svg-graphics directly in your LaTeX document colors correctly if you include graphics in PNG format using Inkscape.

Xfig can only be in- stalled using Cygwin-X. on the other hand. however. the file It is also possible to export vector graphics to EPS format extension to include would be . etc. In your LaTeX document. Ipe represents LaTeX fonts in their correct size on those textboxes. such as a mathematical formula. It can be installed on products are limited to Windows and Mac OS X plat- Unix platforms. It can save to EPS.Server”.. where the picture should which allows TeX annotations to imported graphics.pdf_t. GIMP There are many ways to use xfig to create graphics for La- GIMP.Generic Mapping Tools (GMT). forms. lines. use the following. . example.2. Generic Mapping Tools (GMT) Exporting a file as PDF/LaTeX or PS/LaTeX. This method. lines with arrows can Plots and Charts only be drawn at angles that are multiples of 45 degrees. we use \input. used and can read and write EPS figures. however. If the export was into PS/LaTeX. Wherever you need La- TeX text. you need to first start the “Start X . Create the drawing in xfig. Alternatively. then launch “xterm” to Adobe Photoshop bring up a terminal. where “test” is replaced by the Labels in the figures. Geometric objects are saved into . such as Adobe Illustrator. maps and a wide range ing. Use the Edit tool to open the properties of each of Xfig. with the \usepackage command right below TpX the \documentclass command. Make sure to include packages graphicx and color in the file. the For more details on using xfig with LaTeX. lpic depending on whether you are using pdflatex or ps- latex to compile your file.TpX file to be processed by LaTeX. and it is multi- TeX documents. name of the image: Observe that this is just like including a picture. Unlike 2. User of the xfig User Manual may prove helpful. and FreeHand are commonly Xfig is a basic program that can produce vector graphics. several curves are not supported. This tells LaTeX to inter- the right spot. and change the option on the “Spe- the screen which makes it easier to place text labels at cial Flag” field to Special. 5. Here’s how it’s done: of highly customisable plots. With Cygwin. CorelDRAW. Yet another solution is provided by the lpic packages . this chapter rest is saved in . enter a The Ipe extensible drawing editor is a free vector graphics LaTeX string in a textbox.TpX}.PDF file. offers a good deal more flexibility in draw. One method is to export the drawing as platform. In this terminal type “xfig” (without the quotation marks) and press return. ex- LibreOffice cept that rather than using \includegraphics. which is an open source office . WinFIG is an attempt to achieve the func- tionality of xfig on Windows computers. Linux and Mac. just create the graphics in TpX editor and calls the . See be.pstex_t instead of using LibreOffice Draw. suite available for Windows. or intersections) that can be used for geometric constructions.TpX file from latex file by command \input{. Other tools Xfig Commercial vector graphics software. snapping to points. these which can be exported to LaTeX. Ipe also has various snapping modes (for pret these textboxes when it opens the figure. has a graphical user interface. a LaTeX document. this will require a fast internet connection and about 2 gigabytes of space on Raster graphics your computer.13. like this: Vector editor TpX separates geometric objects from text And you're done! objects. 4. 3. On Microsoft Windows systems. suffers from various drawbacks: lines can be drawn only at angles that are multiples of 30 and 45 degrees. However. It can save to EPS and PDF. IMPORTING GRAPHICS 61 Ipe 1. editor for creating figures in PDF or EPS format. Go to File -> Export and export the file as PDF/LaTeX (both parts) or PS/LaTeX (both parts).. to run Xfig.

bottom. and to be able to cross- reference. http: To create a figure that floats. If there is R. This approach also for easier editing.1 Floats want to make mathematical plots. There are some tricks to be able to import formats Floats are not part of the normal stream of text. [1] Johan B.13. middle. In since it is formatted as ASCII. The morefloats package lifts such limit.pdf. but sepa- other than EPS into your DVI document. graphics content can be imported into LaTeX from outside programs as EPS files. the float is moved to the top of the next page. You can get best results when used along Floats are containers for things in a document that can- PGF/TikZ. LaTeX by default recognizes “table” and “figure” floats. LaTeX automatically floats R Tables and Figures. mirrorcatalogs.org. If you 2. COMMON ELEMENTS Gnumeric want a way of adding captions.62 CHAPTER 2. PDF export would also be good if LaTeX could apply principles sim- ilar to when it arranges text to look its best to arranging pictures as well. ctan. not be broken over a page. http://ctan. Gnuplot Gnuplot. “How to include an SVG image in LATEX”. On the other hand there is a PGF export also. //www. but you can define new ones of matplotlib your own (see Custom floats below). spreadsheets has SVG.ctan. with PDF object here just now. left. right. the number of floats. What we need is a way of defining figures. you can this case. set pages.14. or by adjusting some of the parameters which control automatic floating. nor on the visual balance of the type- subsequent editing. statistical and scientific figures. Engelen. An EPS file can be edited with any text editor posed to fit on the page and still leave room for text. changing gether if possible. As described above. This can be changed by moving the Table or Figure definition to an earlier or later point Editing EPS graphics in the text. just having a picture stuck in between para. there may be times when 2. use the figure environment.degree of control over where certain floats are placed. but anything in protest.com/info/svg-inkscape/ Figures InkscapePDFLaTeX. then Gnuplot can save in any format. They always have a caption describing them and they are always numbered so they can be referred to from elsewhere in the text. and to help when you really don't want the matplotlib. EPS. but they're very rate entities. In a text editor. “The svg package on CTAN”. there exist limitations on the original EPS image. not enough room on the current page. depending on how much space is left on the page at the point that they are processed.mirrorcatalogs. However. The placement specifier parameter exists as a The previous chapter introduced importing graphics. positioned in a part of the page to themselves complicated. LaTeX stacks them all up and prints them to- achieve simple operations like replacing strings. so that they intrude neither on the thread of your argu- like Inkscape. producing scientific graphics since 1986.14 Floats. Figures and Captions you disagree. or wherever the designer EPS is very simple. graphs does not look professional. On the other hand. But Authors sometimes have many floats occurring in rapid sometimes you want to edit or retouch these graphics succession. so it’s not worth considering them.com. and a typical example is with its positioning of figures. plotting library written in python. LaTeX by default can cope with maximum 18 floats and a symptomatic error is: 2. However. To start with. It Gnumeric. the importing process may occasionally modify As with various other entities.4 Notes and References ! LaTeX Error: Too many unprocessed floats.org/tex-archive/graphics/svg. we What you do with these placement permissions is to list . or moving items slightly. [2] Philip Ilten. while maintaining the best possible presentation. Floats are there to deal with the problem of the object that won't fit on the present page. converting any image to (top. may also be able to import EPS files for ment or discussion. The previous section mentioned how floats are used to allow LaTeX to handle figures. or leaves them to the end of the chapter the bounding box. which raises the problem of how they are sup- files. and EPS export. C. The skill is to space them out within your text further becomes cumbersome. specifies). and its purpose is to give the author a greater However. Vector graphics editors. This is where floats come into play. compromise.

it may encounter further Package caption provides the command \cap- floats.. so you do not need to Use \listoffigures to add a list of the figures in the be. Tables Side captions Floating tables are covered in a separate chapter. Frank Mittelbach de. This can be set by • Once a page has finished. rier.2 Keeping floats in their place • if this succeeds.e. In the process.g. LaTeX will automatically keep other than centered for a float that sits alone in one page[3] .include this within the caption text. it will next try to place the remaining floats into top and The flafter package can be used to force floats to appear bottom areas. \FloatBarrier may also be useful ble.age[section]{placeins}). if one needs to specify an alignment need to do is use the \caption{''text''} command within the float environment. used to place all floats at the end of a document. • After that. However. which can be used to prevent floats from being • if this does not succeed. relaxes all restrictive float conditions. it starts processing document material for this page. The tabular environment that side of a float. Try out the fol- around all figures. use \renewcom. and the endfloat package can be either places them or defers them to a later page (i. If you place it before. it is up to you to therefore insert the cap- tion command after the actual contents of the float (but still within the environment).14. tions are necessary.14. Use \listoftables to add a list of the tables in the beginning scribes the algorithm[2] : of the document. be useful at the be- float into a holding queue to be reconsidered ginning of each section. LaTeX starts a new page. This can. It looks at all the remaining floats and after they are defined. this is very simple in LaTeX. which completely stops them from floating. FLOATS. an option to change the definition of \section to auto- matically include a \FloatBarrier. the float is placed and that de. All you sary. table. for tables you wish to float.} flips its content The border will not include the caption.. tionof{<type>}{<caption text>} that lets you typeset a caption without a floating environment. The sidecap was used to construct the tables is not a float by default. Let’s It is sometimes desirable to have a caption appear on the give a quick reminder here. Fortunately. plied specifiers it thinks is best.2. wrap the tabular or table. 2. and LaTeX will de. To change the name used in the caption from Figure to Example. package can be used to place a caption beside a figure Therefore. but such distinc- TeX. then LaTeX places the moved over it. For this it will first try to generate as many float to prevent floats intruding on lists created using itemize pages as possible (in the hope of getting floats off or enumerate. FIGURES AND CAPTIONS 63 which of the options you wish to make available to La. LaTeX attempts to place it immediately according to its rules (detailed later) 2. rather than above or below. track of the numbering of figures. These are simply possibilities. the queue). and outputs all floats in the holding queue by placing them on float page(s).The placeins package provides the command \FloatBar- cision is never changed.3 Captions In some special cases LaTeX won't follow these position-It is always good practice to add a caption to any figure or ing parameters and additional commands will be neces.. because you may not want all tables cide when typesetting your document which of your sup. You may feel that it is a bit long winded. to be treated as a float.. The following example demonstrates this for a environment within a table environment. like this: figure by using a SCfigure environment in place of the . horizontally. e. re-adding them to the holding queue once more). ginning of the document. float. Once this possibility is exhausted. • If a float is encountered. then Figures with borders It’s possible to get a thin border the caption will appear above the float. The package even provides when the next page is started (but not earlier). You have the • If the end of the document has been reached or if a full and absolute control about the placement of your \clearpage is encountered. You have to write the following once lowing example to demonstrate this effect: at the beginning of the document: Note that the command \reflectbox{. figures and captions. for example.The location of the caption is traditionally underneath the mand{\figurename}{Example} in the figure contents.14. LaTeX examines this loading the package with the option [section] (\usepack- holding queue and tries to empty it as best as possi. The float package provides the H option to floating envi- ronments.

6 Wrapping text around figures You can use intextsep parameter to control additional space above and below the figure: An author may prefer that some floats do not break the \setlength\intextsep{0pt} flow of text. If the label picks up the section or list number instead The wrapfig package can also be used with user-defined of the figure number. See below in the section on cus- ensure correct numbering.64 CHAPTER 2. these lists. and page num. Note that easy to suppress by just placing the caption text in the fig. In such a question is significantly narrower than the text width. of them works perfectly..see the Labels and Cross-referencing sec.wrapfig may not come with the default installation of ure environment. Before you make the choice of including figures with text wrapping in your document. The LaTeX calculation is manually overridden by entering the num- 2. however means that there is no caption available for in. and itemize environments To use wrapfig. you must first add this to the preamble: Renaming table caption prefix This then gives you access to: The lineheight is expressed as the number of lines of text In case you want to rename your table caption from “Ta- the figure spans. ures that look ugly (with too much spacing). This option can't be entered in pt. it may not be desirable for figure captions to start Figure:. and the long description will be by setting the width to 0pt. For example. \begin{wrapfigure}{l}{0pt} placed beside the figure or table. cm etc. This is Anyway. use \protect in front of the \la- bel command. This LaTeX.5 Labels and cross-referencing will not return any strange warning and you will have a small white frame between the image and the surround- Labels and cross-references work fairly similarly to the ing text. so the compiler 2.4 Lists of figures and tables ber of lines you would like the figure to span. Tip for figures with too much white space 2.. without enclosing it in a caption. (Ob. COMMON ELEMENTS figure environment.The uppercase-character allows the figure to[4]float..you don't keep the image smaller than the “wrap”.) case. It specifies the height of the figure in num- require a lot of manual adjustment of your document. you can simply make use of the optional argument A word of warning: Wrapping figures in LaTeX will [lineheight].14.14. We did it age: in terms of the text width: it is always better to use rela- tive sizes in LaTeX. The caption used for each figure will appear in the lowercase version means “exactly here”. ber of lines of text. make sure you have considered all the options. This is particularly use- ful if the caption is long.There are overall eight possible positioning targets: port in a “List of Tables” or a “List of Figures” section by using the \listoftables or \listoffigures commands. You can change it to get a better result. you might need to install additional packages. ample: bles or List of Figures. label is inside the caption. you could use a layout with two columns for your documents and have no text-wrapping at all. Captions can be listed at the beginning of a paper or re. An ex- \caption[''short'']{''long''} which is used for the List of Ta. put the label inside the caption to floats with float package. we will look at the package wrapfig. In some types of document (such as presentations)..Noted also. The width is. Also remember that the environment .The overhang of the figure can be manually set using the bers that they appear on. the width of the figure. mm etc. The \caption command also has an optional parameter.It happens that you'll generate figures with too much (or viously. For ex- Unnumbered captions ample. The floatrow package is newer and There are several packages available for the task. Here is an example of this us. of course. wrapfig is incompatible with the enumerate clusion in a list of figures. re. LaTeX will automatically calculate the ble” to something else. environment and the image we have included. and only a “one-liner” is desired Note that we have specified a size for both the wrapfigure in the figure/table listing. this effect only looks decent when the figure in too little) white space on the top or bottom. you tion for more information. but if general case . while spectively. but instead allow text to wrap around it.14. will see the image over the text. you can use the \captionsetup value if this option is left blank but this can result in fig- command. If you get an error when the tom floats. overhang option in pt. but none has more capabilities. let LaTeX do the work for you! The “wrap” is slightly bigger than the picture. along with the figure numbers. Typically the short description is You can also allow LaTeX to assign a width to the wrap for the caption listing.

and \. h. so you will get packages are deprecated. width of a column (using a LaTeX notation. In general. the problem is the use of \begin{center} to center the image.5\textwidth). you started your document with something like \docu- To remove the white space from a figure once for all. and an optional global the preamble in order to alleviate this problem with regard caption. by putting the newline command (\\) before the figure you gument. The package float . using the subcaption package: optional specifier [b].2. you might have noticed should refer to the program pdfcrop. but they will be as wide as the page.9 Custom floats If tables and figures are not adequate for your needs. \. any space at all: let LaTeX do the formatting work! • Math spaces: \qquad.g..} command.14.A bad point of those environments is that they can be Tran and ACM SIG) that are not compatible with subcap. it is best not to add the subfigs. then You will notice that the figure environment is set up as you always have the option to create your own! Exam- usual. the package fixltx2e [5] should be used (e. IEEE. These packages give the author the ability to have you try to specify their position using modifiers like b or subfigures within figures. including pt. one mentclass[twocolumn]{article}).14. Default is [tbp]. where the label is inserted. For each subfloat. If tion. This effect can be added manually.8 Wide figures in two-column docu- hand tuning. or bles.. environment will provide the global caption. Here is an example using the \vspace command.e. FLOATS. thus removing some wish to move to a newline. \usepack- age{fixltx2e}). however they are useful alter. or subtables within table floats. To prevent the figures from being placed out-of-order with respect to their “non-starred” counterparts. etc. see wish to create a float named program. it will automatically the space you want to add. which are placed in between \be- not. shift subfloats below. However. otherwise. If you provide a negative ar.. the gin{subfigure} and \end{subfigure}: code is exactly the one of the previous case. the only solution is to use the “starred” variants of the floating environments. otherwise you will see the image overlap- ping with text. \quad. FIGURES AND CAPTIONS 65 center adds some extra white space at its top and bottom. The argument is the size of providing they can fit. one might therefore If you intend to cross-reference any of the subfloats. in. natives when used in-conjunction with LaTeX templates (i. If you are writing a document using two columns (i. If you really have to use such wide ele- 2. white space. h still does not work. you can use any unit you want. which uses ble*}. 2. (In this case. it will add a negative space. You may also use a table environment for subta.no overlapping. mm.ples of such instances could be source code examples. wider than 0. Another possibility is adding space within the float using subcaption will arrange the figures or tables side-by-side the \vspace{. but you can manage ple above) can be used to insert a space in between spaces the way you like. we just added some negative vertical spaces to shrink everything up: • A non-breaking space (specified by ~ as in the exam- In this case it may look too shrunk. they will be ignored.7 Subfloats ments. Add \usepackage{dblfloatfix} to Subfloats have their own caption. that are {figure*} and {ta- A useful extension is the subcaption package. An example will best illustrate the usage of the to placing these floats at the bottom of a page.14. \caption outside the subfigure- consider using the command \centering instead. For a program float example. The center environment adds extra • Generic space: \hspace{''length''} space that can be avoided if \centering is used instead. you need to use: maps.placed only at the top of the page or on their own page.) • Automatically expanding/contracting space: \hfill Alternatively you might use the picins package instead of the wrapfig package which produces a correct version without the excess white space out of the box without any 2. included in most that you can't use floating elements that are wider than the TeX installations.e templates for journals from Springer and IOP. The subfigure and subfig ones.14. Using \vspace tends to move the caption Horizontal spaces between figures are controlled by one relative to the float while the [lineheight] argument does of several commands. ments There is also an alternative to wrapfig: the package floatflt . Those “starred” versions work like the standard subfloats within a single float.

You will source code.See this page for more information on counters. However these definitions have limited indicates that the counter associated with this effect on newly created float environments with the wrap- new float should depend on outer counter. that was the hard work and tweak the page layouts in order to get made just for it. . and allows for drawing a white background under the typeset material to over- • plaintop . for labels. must be inserted before There is a LaTeX package lpic to put LaTeX on top of \newfloat to be effective). but if you want to introduce a lot of code hopefully see how much easier it is to let LaTeX do all you might consider using the listings package. If you wish to alter this. The verbatim environment is an environment that is al- ready part of LaTeX. Add \usepackage{float} to the preamble of your Newly created floats with \newfloat can also be used in document combination with the wrapfig package from above. It is a better alternative for labels but the caption is always above the content. E. in the text on the right side of the page and is complete where: with caption. Although not introduced so far.t. which floats \newfloat{type}{placement}{ext}[outer counter]. for fig package. Then is pinlabel . It is good for That concludes all the fundamentals of floats. A much more complicated package which can be used in the same way is TikZ. and all LaTeX power is available and the caption is printed below.the file name extension of an auxiliary file and bold: for the list of figures (or whatever).the new name you wish to call your float. LaTeX The KOMA script packages have their own caption cus- writes the captions to this file. and not within may occur. The link given also points to the packages the float contents.the presence of this parameter and \setcapwidth. when rescaling pictures. 2. with rules immediately above and below. instance). or h (as previously de- scribed in Placement).66 CHAPTER 2. As always.the normal style for LaTeX floats. One solution might be to use the [H] option the document.lob and a customization of the float’s visual layout: • type . including new lines. therefore. where letters enumer- To change the appearance of captions. with somewhat different syntax.14. It can be used to label figures by adding text An example document using a new program float type: nodes on top of an image node.a box is drawn that surrounds the float. you can redefine the \thefigure command: 3. thus allowing to add TeX annotations • plain . spaces. name{type}{floatname} 4. Finally. For example.the normal style for LaTeX floats. Caption styles • placement . the fact that While this is useful. package. 1. put TeX over included graphics. p. Alternatively.10 Labels in the figures commands. COMMON ELEMENTS is your friend for this task.the caption appears above the float. you do not have to change text size • boxed . use \float. example 'chapter'. All commands to set up the not in outer par mode new float must be placed in the preamble. Declare your new float using: the following code creates a floating text box. In particular. numbering.14. but to imported graphics. • ruled . 'program'. tal rule. The default name that appears at the start of the cap.g. its 2.note that the caption2 package has long been deprecated. inside of graphics. one should be careful when embed. as this option “pins” the inner float to the outer one. tomizing features with e.11 Summary name is fairly intuitive! LaTeX will reproduce everything you give it. \captionabove. in this instance. TikZ is a front-end to a draw- Float styles can also be customized as the second example ing library called pgf (which is used to make beamer for below illustrates. the error is a great time saver. to make all caption labels small • ext . Changing float style can be issued with \float- style{style} (Works on all subsequent \newfloat 2. \captionformat • outer counter . followed by a final horizon. included graphics. use the caption ate permitted placements. It defines a convenient interface to the caption is always below the content. etc. your figures in the best place. (not any other) on the inner float. shadow the graphics.g. A very similar package. an index file with the extension .psfrag and overpic.LaTeX takes care of all caption and reference numbering ding the float within another float. b. tion is the type.

1. sible to create PDF files directly from the LaTeX source. too. and the hyperlinks can be fol. Following http://tex. In particular PDF supports hyperlinks.org/tex-archive/macros/latex/contrib/ The package provides some useful commands for insert- float/ ing links pointing outside the document. if the reader 2.. 2.15. Local file Files can also be linked using the url or the come links and you will be able to click on them to be href commands.1 Hyperref hidden. HYPERLINKS 67 2. useful when the It will show the string description using standard docu- resulting format is PDF.tex. with hyperref those “connections” will be. your browser will be lowed. note that the \nolinkurl command This will automatically turn all your internal references is fragile and if the hyperlink is inside of a moving argu- into hyperlinks. while in the second case the URL will be 2.stackexchange. Here is an example: Both point at the same page.uk/cgi-bin/texfaq2html?label= for avoiding nested hyperlinks. and PDF supports more features than DVI. you will have the possibility to include interac- tive external links and all your internal references will be Apart from linking to websites discussed above.ctan. Just load the package in the preamble: When using this form.15 Hyperlinks \href Usage: LaTeX enables typesetting of hyperlinks. your browser will be opened pointing at it. etc. documents: just keep on using the standard \label-\ref system (discussed in the chapter on Labels and Cross- referencing). PDF can contain other information about a document such as the title. the E-mail address A possible way to insert email links is author. It won't affect the way to write your ment. but in the first case the URL will be shown. . [2] Float environment positioning. and links to anywhere within the PDF output file.12 Notes and references Commands [1] http://www. It works with pdflatex and also with standard “latex” used with dvips and ghostscript or dvipdfm to build a PDF file. It will show the URL using a mono-spaced font and. opened pointing at my_url. 2colfltorder \url Usage: This page uses material from Andy Roberts’ Getting to grips with LaTeX with permission from the author. at the beginning of the link string: tents.pdf was number 4. The two can be combined. if you click on it.com/questions/ perlinks.1 the following example would result in with the hyperlink as expected.2 Usage clicks on it. The hyperlinks will not show-up if you are 46488/link-to-local-pdf-file the version with url does working in draft mode.15.univie.abilities into the displayed text. if you click on it. links to local files. You simply have to add the string run: redirected to the right page. instead.ment font but. but href does. Note the "*" after \ref [5] http://www. (s)he can easily send you an email. Note that. to incorporate the url package’s formatting and line breaking [2] The basic usage with the standard settings is straightfor.at/packages/tex/macros/latex/ contrib/wrapfig/wrapfig-doc. Moreover the table of con. use ward.stackexchange. Or. the link stored using \href will not be shown anywhere in the doc- The package hyperref[1] provides LaTeX the ability to ument. list of figures/tables and index will be made of hy.14. if you print your document. not always work. Moreover. can be used to provide mailto links. If the lemma labelled as mainlemma [4] http://ftp. by It just shows your email address (so people can know it even if the document is printed on paper) but. by Frank Mittelbach \hyperref Usage: [3] http://tex.15. it must be preceeded by a \protect command. hyperref turned to hyperlinks.ac. create hyperlinks within the document. It does so using the package hyperref.2. If you Other possibilities load it. The compiler pdflatex makes it pos. which can be edited using this same package.com/questions/28556/ This will have the same effect as \ref{label_name} but how-to-place-a-float-at-the-top-of-a-floats-only-page will make the text link text a full link.ac.

the command \maketitle. use: appear.8 Big list at hyperref-manual at tug./ is the current di.The best solution is to give each page a unique name by ument Info section of the PDF file. use the standard Unix-like notation (. when you have made something like and to link to it.68 CHAPTER 2. You can use color frames. as well as enabling using the \pagenumbering command: back references inside bibliography: Another solution is to use \pagenumbering{alph} before By default.tifier (name{page. \label{lst:program01}. but this will cause the page links in the index or make links black: to stop working. 2.1.a.e. nored while the others may only assigned to named colors (which you can define your own. . destined for printing. for example by to speed up your customization process.30}) has been already used.different from the erroneous line. see the official documentation).). But as the preface ables. which are not printed: names=false. duplicate ig- lowed for the border colors (like linkbordercolor etc.document class.. work).Problems with Links and Equations 1 rectory. making it difficult even more radical solution is to use the option hypertex- to read.15. The Problems with Links and Pages default values are written in an upright font: Messages like the following: Checkout 3. hence the notice that If you don't need such a high customization. Options have to be in the form: Note: The same error appears if you use a colon ":" as part of a label.15.” The counter measure con- some smaller but useful examples. see Colors).7.) Messages like the following ! pdfTeX warning (ext4): destination with the same iden- Hyperlink and Hypertarget It is also possible to cre. Some text to the package. Replacing that exactly the same format has to be used if you pass those will help. in order to do so. like this: Here is a list of the possible variables you can change (for the complete list. i. In order appear when a counter gets reinitialized. you can use this: won't make a difference to the output. When creating PDFs sists of putting plainpages=false into the hyperref options. Since the page number is suppressed. Possible solution: Place the amsmath package before the hyperref package. options to the package while loading it. it the same style of the rest of the text. that is also possible.4 Troubleshooting the location of your current document. COMMON ELEMENTS It is possible to use relative paths to link documents near 2. To create an anchor. here are “duplicate has been ignored. An they end up in gray in the final output. Options can be passed as an argument of from your document here (\ref {re\ETC. that explicit RGB specification is only al.3 Customization Problems with Links and Equations 2 The standard settings should be fine for most users. Copy it in your doc. tively. . lows: Possible solution: Add the following to your preamble: you can pass as many options as you want.tifier (name{ equation. if you use instead this form: where the target caption and link caption are the text that Beware that the shown line number is often completely is displayed at the target location and link location respec.1}) has been already used. There are several variables and two methods to pass those ! Runaway argument? {\@firstoffive }\fi )./ is the previous directory. use: The error disappears. URLs are printed using mono-spaced fonts. there is a short explanations of their meaning: of the book also has a page number 1 all links to “page 1” would not be unique anymore. Next to the vari. separate them with a comma. appear when you use \label inside an align environment. Latex Error: the package when it is loaded (the standard way packages Paragraph ended before \Hy@setref@link was complete. It resets the page number counter to 1 ument and make the changes you want. here is a list with using the command \mainmatter provided by the book the variables with their default value. but Messages like the following if you want to change something. which will give the title page If you don't like it and you want them to be printed with the label page.org ! pdfTeX warning (ext4): destination with the same iden- Please note. or the \hypersetup command can be used as fol.7. etc. ate an anchor anywhere in the document (with or without duplicate ignored caption) and to link to it. When you just want to provide information for the Doc.prior to the first chapter of the book. colored links are not a good thing as This unfortunately only helps with the page counter.

v. e. upon clicking the user will be characters in bookmarks. Color changes also do not travel well into bookmarks: See the relevant section. In this case. in- selection of characters to pick from when using \texor. The solution to the ing text: problem is to delete all the files that latex uses to get ref- Math expressions are a prime candidate for this kind of erences right and typeset again. One Package hyperref Warning: Token not allowed in a PDF. which. and remove the now unnecessary There is an issue when using \listoffigures with hyper- \nonumber commands. stead of using . . c. \be. the pages would be numbered a. ble itself will not be visible upon clicking the link[4] . 2. In this case. or other similar packages scheme. \end{eqnarray*} (which is an unnum- bered equation array). the figure or ta- page will have a unique name. lines. The important scribed.15. try the captions (or the titles) are longer than the page width using the breakurl package to split the url over multiple (about 7-9 words depending on your settings). b. You can now work around this problem by providing a when the document is typeset with hyperref for the first text string for the bookmarks.can therefore encounter errors like DocEncoded string: ! Argument of \Hy@setref@link has an extra }. 4.you need to use the option breaklinks when first declar- ronment where the line width is greatly shortened. use the *'ed form instead.Problems with footnotes and special characters mark area. 1.2. each caption is usually below a figure or table.. A Another more flexible approach is to set the counter to workaround exists by using the package hypcap with: something negative: Be sure to call this package after loading hyperref.lof and similar like you expect it to look.g.. which will give the first pages a unique negative number.g. Problems with bookmarks The text displayed by bookmarks does not always look Problems with already existing . \pagestyle{plain}. ing: This will then cause the links in the \listoffigures to word wrap properly. HYPERLINKS 69 By changing the page numbering every time before the pdfstring. produces the string “redRed!". i. Problems with long caption and \listoffigures or long ment. ually include \capstart in those environments. you will need to man- algorithms will be duplicates of the first. title gin{eqnarray*} . A simple work around exists. counter is reset. Since the point is that although the numbers are not visible. Hyperref will normally no-The format of some of the auxilliary files generated by la- tice such problems and put up a warning: tex changes when you include the hyperref package. ref for long captions or long titles. This will give you a much larger sent to the first frame. The links created by hyperref point to the label created ble (for example. iv. If you Problems with Beamer use: the result will be much more legible. If you use the wrapfig package[5] mentioned in the The problem can also occur with the algorithms package: "Wrapping text around figures" section of the “Floats. the line identifiers for the second and follow-on that define their own environments.toc. Using the command If you write your document in unicode and use the uni. This happens when If your url’s are too long and running off of the page. Instead of sending the code option for the hyperref package you can use unicode user to the desired label. Because bookmarks are “just files text”.. Problems with tables and figures If you don't want the page numbers to be visi. ii. must always be set after the caption. much fewer characters are available for bookmarks than for normal LaTeX text.. 3. which replaces the offend.. each page gets a unique name. use within the float environment. as previously de- \pagestyle{empty} . e. The command \textcolor gets ignored but its argument (red) gets printed. This is especially important in a multicolumn envi. because each algorithm uses the same line-numbering Figures and Captions” chapter.time and these files already exist. is broken when pointed at a label. To fix this. during the front matter part). problem: which turns \section{$E=mc^2$} to E=mc2 in the book.: The problem occurs with equation identifiers if you use \nonumber on every line of an eqnarray environ. 5.. . iii.

For more information see the Packages sec- object will not be shown anywhere in the document.1 Introduction you have introduced a lot of references. 71a5a7c7bfceb3cb?lnk=gst&q=email+url+hyperref# Rerun to get cross-references right. You could write some- thing like: [6] Hyperref . If you ref- erence a marker that does not exist. Retrieved 2008. and LaTeX will such as fancyref.step process: first the compiler has to store the labels with nal=true” option in the following initialization of the hy. you will not have to rename all your labels and their ref- \pageref{marker} It will print the number of the page erences.org/tex-archive/macros/latex/contrib/ hyperref/README Using the command \pageref{} you can help the reader to find the referenced object by providing also the page [5] Wrapfig package webpage in CTAN number where it can be found.google. Some packages. updating it whenever necessary. signed to the object.15. this can be very useful while developing your in the document.16. url packages”. once. you can use the showkeys LaTeX will calculate the right numbering for the objects package. if you change the order of the objects. Another suggestion: try to avoid using numbers within \ref{marker} you can reference the object you have labels. or any. figures.5 Notes and References of the compilation: [1] Hyperref package webpage in CTAN [2] “Email link with hyperref. the compilation of the document will be successful but LaTeX will return a Problems with draft mode warning: LaTeX Warning: There were undefined references.16 Labels and Cross-referencing Since you can use exactly the same commands to refer- ence almost anything. is numbered (sections. just after the package was included: replace the \ref with the right number. [3] Other possible values are defined in the hyperref manual [4] http://www. rely on this meta information. you can see it like a name. an example: The commands to be used do not depend on what you are Following this convention. 2.ctan. Here is take care of numbering. the marker you have used to label the document. where the object is.it will be easy to find in the document).. you have to compile your document A good source of further options for the hyperref package twice to see the proper output.. ful as your document grows in size. comp.tex User Group. and they are: like \label{fig:my_figure}. Then tion. COMMON ELEMENTS to label your frames. .Hyperlinks With LaTeX Page See figure~\ref{fig:test} on page~\pageref{fig:test}. LaTeX will use the older information it collected in previous compilations (that might be outdated).the right number to be used for referencing. you might get a bit confused after 2. then it has to perref package. WARNING! Please note that if you have activated the “draft"-option in your \documentclass declaration the hy. it is a two- The hyperlinks can be re-enabled by using the “fi. If you compile it only can be found here [6] . You can use any string as an argument \label{marker} you give the object you want to reference of \label{.70 CHAPTER 2. formulas).and it will replace "\ref{unknown-marker}" with "??" (so perlinks will not show up in the table of contents. This prints the number that was as- about. If you want to be able to see the markers you are using in the output document as well. the label of a figure will look referencing. 71a5a7c7bfceb3cb. It is common practice among LaTeX users to add a few letters to the la- In LaTeX you can easily reference almost anything that bel to describe what you are referencing. You are not obligated to use these prefixes. when you use references. text. but the compiler will inform you printing on the screen at the end 2. That is why. use LaTeX will replace the string "\ref{marker}" with the and reference it with right number that was assigned to the object. etc.text.}. You are better off describing what the object is marked before. where else for that matter!!! As you may have noticed reading how it works. This way. but these prefixes become increasingly use- a marker. http://groups.com/group/comp.tex/browse_thread/thread/ae160fd2fc5680a5/ LaTeX Warning: Label(s) may have changed.

if it is above the pointer and one has to the marker starts with sec:. the \sqrt{25 .} will return the respective fig/table number. LABELS AND CROSS-REFERENCING 71 2. \begin{figure} \centering \includegraph- ics[width=0. it is better to place it table or figure itself[1] .. caption of the table or figure. tended. Most ..\sqrt{25 . but you will notice that \caption{Close-up of a gull\label{fig:gull}} they are all the same because they all use the same com- mands.2. In order to reference a formula. Sections Fixing wrong labels The command \label must ap- \section{Greetings} \label{sec:greetings} Hello! pear after (or inside) \caption. the caption package: \usepackage{caption} % hypcap is true by de- fault so [hypcap=true] is optional in \usepack- Pictures age[hypcap=true]{caption} You can reference a picture by inserting it in the figure floating environment. as suggested before.5 x + 6 = shows a photograph of a gull. in order to avoid confusion. scroll up in order to see it.4 \times 6}}{2} = 2 \end{equation} and so we have solved equation~\ref{eq:solve} \ref{. the links to tables or figures will point to the You could place the label anywhere in the section. To be completely safe. but it As you can see. Formulae \begin{figure} \centering \includegraph- ics[width=0. See the Floats. the you have to use an environment that adds numbers.16. The tilde (~) the top of the image you can give the option hypcap to indicates a non-breaking space. it ning of the math mode. how. as in Here are some practical examples.5\textwidth]{gull} \caption{Close-up of a Here is an example showing how to reference formulae: gull} \label{fig:gull} \end{figure} Figure \ref{fig:gull} \begin{equation} \label{eq:solve} x^2 . The la. it will pick up \section{Referencing} I greeted in section~\ref{sec: the current section or list number instead of what you in- greetings}.16. Note how not be visible. Otherwise. will give the section number. 0 \end{equation} \begin{equation} x_1 = \frac{5 + When a label is declared within a float environment. the label is placed soon after the begin- must occur after the caption.5\textwidth]{gull} \caption{Close-up of a gull} \label{fig:gull} \end{figure} Issues with links to tables and figures handled by hyperref In case you use the package hyperref to cre- ate a PDF. When declared outside.2 Examples label for any picture or table can go within the \caption{} command. If you want the link point to bel is then referenced in a different section. Figures and Captions section for more about the figure and related environments. which is always below the ever.4 \times 6}}{2} = 3 \end{equation} \be- gin{equation} x_2 = \frac{5 . Therefore the table or figure will immediately after the beginning of the section.

and n is the current section number. of course. For example. Note that thing like “5 on page 25”. but it adds parentheses so that. but it is on both. it can use more refined perref. Its output can be changed as desired. For example. but since the capitalization of autoref names was chosen by the package author. if the object is far away it will print some- protect\char"007B\relaxsec:intro}}. You could think that this hap- are using amsmath or not.72 CHAPTER 2. which produce multi-case \def\sectionautorefname{Section} equations with a separate equation number and a separate equation number plus a letter. for instance. or similar (the full list of numberwithin The amsmath package adds the default names can be found here). but the label an object on page 23 and the \vref output happens name will refer to the previous environment with a to stay between page 23 and 24. if you put a label after closing it would print like the basic ref. and then making adjustments \ref{}. It is normally better with additional text corresponding to the target’s type. . Assuming used before. it a figure. this may cause some strange errors at compiling time that that is the best choice for one-line formulae. so situations like these are likely to happen. whether you are very hard to be fixed. For example \number.4”. it will print (5). \autoref{}. if you write a long docu- label. according to the context and the document class. the com- bers might offer a useful work-around. Let’s make an example. respectively. sentences). COMMON ELEMENTS of the times you will be using the equation environment. such as a table or two different pages. to use labels.countera. \tag{\ref{eqn:before}}. on which would print “on the previous page”. no alternative \Autoref command is defined to produce within{equation}{section} in the preamble will prepend capitalized versions (useful. ment it is not uncommon to have hundreds of references.3 The varioref package • If you would like a hyperlink reference. If it were on page 23. it works relaxAppendix~{}\char"005C\relax{}ref*\ just like \ref. autoref tag The \tag{eqnno} command is used to manually set The hyperref package introduces another useful com- equation numbers where eqnno is the arbitrary text string mand. If as \hyperref[sec:intro{]}\protect\char"007B\ the object to be referenced is in the same page. If the object is close. This command creates a reference you want to appear in the document. This can be useful to help the reader distinguish between formulae and other things. provides. you can do this with a command such but it has a different output according to the context. if it were on page 24. it is \eqref{}. without the need to repeat the word “formula” be- fore any reference. that this label is pointing to a section. it adds the page number au- you can disable the creation of hyperlinks in hy- tomatically. instead of printing to fix possible problems. One way to avoid problems during development is to use the standard eqref The amsmath package adds a new command for ref all the time. and just use these commands for automatic sentences like “on the next page” or “on the facing page” text. In this case.g. (useful if the label is on the same page as the reference). while there’s \numberwithin{countera}{counterb} command which an \autoref* command that produces an unlinked prefix replaces the simple countera by a more sophisti. 2. counter. for each case. so it may happen its output falls on an environment with a counter.16. the algorithm can get a figure.4 The hyperref package for more information see the amsmath documentation. i. you can customize the prefixed text by redefining \typeautorefname to the prefix cases The cases package adds the \numcases and you want. This command has to be used very carefully. a plain number as 5. the hyperlink would contain the text “section 3. This command is used exactly like the basic \ref. It outputs • Keep in mind that the \label must be placed inside more than one word. the label will still say “figure n”. It works exactly like is close to its final version. 2. and convert it to vref when the document referencing formulae. This may for in- mand \autoref{sec:intro} would create a hyperlink to the stance be useful if you want to repeat an equation that is \label{sec:intro} command. Otherwise. wherever it is. Note that. not only the number will refer confused and cause a loop. as in: the \subnumcases commands. cated counterb. when starting the section number to all equation numbers. but The varioref package introduces a new command called do not want the predefined text that \autoref{} \vref{}. You to the current section. unfortunately. automatically. e.e. Note also the eq: prefix in the pens very rarely. but sometimes hard-coded equation num- all of which will be a hyperlink. This renaming trick can. be used for other pur- poses as well.16. as mentioned above.

This can be achieved with the command \phantomsection as in this example: %The link location will be placed on the line below.16. com/questions/139459/vref-and-input-command Anchor manual positioning When you define a \label outside a figure.5 The cleveref package The cleveref package introduces the new command \cref{} which includes the type of referenced object like \autoref{} does. The format can be specified in the preamble. using hyperref. It is similar to \autoref{}. Input: • LaTeX/Glossary \section{MyFirstSection} \label{sec:marker} \sec- tion{MySecondSection} In section~\nameref{sec: 2. The \crefrange{}{} and \cpagerefrange{} commands ex- pect a start and end label in either order and provide a natural language (babel enabled) range. References to pages are handled by the \cpageref{} command.8 Notes and References marker} we defined. varioref . \phantomsection \label{the_label} 2. a table.16. 2. or other floating objects. this behavior is not what you'd like and you'd prefer the generated link to point to the line where the \label is defined. it will sort them and group into ranges auto- matically. LABELS AND CROSS-REFERENCING 73 nameref 2.2.[2] The following order generally seems to work: 1. and a similarly named command. but inserts text corresponding to 2. hyperref The hyperref package also automatically includes the 3.hyperref. and cleveref redefine the same commands. hyperref .16.16. they can produce unexpected results when their \usepackage commands appear in the preamble in the wrong order.16. In some cases. and cleveref Because varioref.7 See also the section name.ctan.. cleveref[2] nameref package. If labels are enu- merated as a comma-separated list with the usual \cref{} command. the label points to the current section. [1] http://www.. for example. [2] Tests done under report class http://tex.stackexchange..6 Interpackage interactions for vari- oref . For example. The alternate \labelcref{} command works more like standard \ref{}.org/tex-archive/macros/latex/contrib/ Output: hyperref/README In section MyFirstSection we defined..varioref. then cleveref can cause \vref{} to fail as though the marker were undefined.

and you can then run La- 3. that the place where LaTeX spots and reports an error ror messages begin with an exclamation mark at the start may be later in the file than the place where it actually of the line.2 Warnings The reason LaTeX thinks there are too many }'s here is Warnings don't begin with an exclamation mark: they are that the opening curly brace is missing after the \date con- just comments by LaTeX about things you might want trol sequence and before the word December. so LaTeX of which you can ignore until later).1. and give a description of the error. caused by unusual hyphenations. cannot possibly guess that you've missed out the opening which try to hide unevennesses in the text (usually unsuc. It may also you will almost never get a warning about badly-fitting display warnings for less serious conditions. lines or pages. This disappears after Some systems (Emacs is one example) run LaTeX with a few days as you get used to them. followed occurred.1. While it is certainly possible to set LaTeX’s it encounters something it doesn't understand or can't do. a “nonstop” switch turned on. parameters so that the spacing is sufficiently sloppy that it will display a message saying what is wrong. forget curly braces. but be aware The format of an error message is always the same. and it’s not clear 3. and other typographical niceties (most command apart from a date in curly braces. l. LaTeX takes the view that the author or editor should be able to LaTeX describes what it is typesetting while it does it. If contribute. ask for help. so it will always process through to the end of the file.Chapter 3 Mechanics 3.1 Error messages what you should do. l.6 \tableofcotnetns or look like. curly brace until it finds a closing one! 74 . most likely to be encountered by beginners. In fact. Unlike other systems. or until a limit is reached. Here’s an exam. type a forward slash instead of a backslash. LaTeX won't report this until the line-number in your document file which LaTeX was something else occurs which can't happen until the curly processing when the error was spotted. so the clos- to look into. Too many }'s ! Too many }'s. brace is encountered (e.3 Examples TeX again to check you have fixed everything. there are other things which can follow the \date ning short or long. For example if you forget to close a curly brace by another line starting with the number. the end of the document!) ple. say. italics. it displays the error Newcomers should remember to check the list of special message and pauses.g. to mistype or misspell commands. or use a spe- cial character by mistake. You must type one of the following characters: a very large number of errors when you are letters to continue: learning LaTeX are due to accidentally typing a special character when you didn't mean to.1. you will almost certainly just be delaying matters until you start to get complaints from your readers Don't panic if you see error messages: it is very common or publishers. Some of Only a few common error messages are given here: those the most common errors are described in next sections. showing that the user mistyped the \tableofcontents Some errors can only be righted by humans who can read command: and understand what the document is supposed to mean ! Undefined control sequence. regardless of errors.6 \date December 2004} 3.1 Errors and Warnings cessfully) by interfering with the letter spacing. Most error messages are self-explanatory. pages run. such as overlong or underrun lines (often ing curly brace is seen as one too many (which it is!). Errors are easily spotted and easily corrected in your editor. which refers to which encloses. If you find another error message not shown here. When LaTeX finds an error like this. Er. for example).

pro- LaTeX knows is that \dtae is not a command it knows viding full paragraphs to ragged text. but with the minimum allowed age[utf8]{inputenc}" or using iso8859-1 without "\usep. Mistypings are the most common necessary to pull the linebreak up one line to the end of source of errors. and which makes the line go over ackage[latin1]{inputenc}".. and the number in square brackets is the number of the page onto which the of- ! Undefined control sequence. indicates how severe this is (here you can probably ignore you can make latex add a black bar where a line is too a badness of 1394). such as page while LaTeX is still expecting more text for the date! “input/output”. and you need \_ justification problem: moving the last word on the line to get an underscore character. It’s the opposite of the error of too many }'s.1.3. without making the spacing bigger than its Easily spotting overfull hboxes in the document To currently permitted maximum. ages. If you did graph at lines 860-−861 []\LY1/brm/m/n/10 Windows. The line on this example is too long by a shade over 9pt. Obviously it’s This comes up if you force a linebreak. In this example. or the flexibility settings need changing. except that it can form the end paragraph has ended but \date is not yet finished. e. word is left on the line. for example using utf8 without "\usepack. then use $. l. ERRORS AND WARNINGS 75 Undefined control sequence typesetting when it found this. RJ: \LY1/brm/m/n/10 Ac-count-ing in Busi. The use of \slash has the same effect this is detected and LaTeX complains that the previous as using the "/" character. and it results in \maketitle trying to format the title If the “overfull” word includes a forward slash. In this case. to the next line would make the spaces in the line wider than the current limit. The badness (0-10. again> \par l.the error is shown at the end of the line (Win-). \includegraph- Not in Mathematics Mode ics[width=\textwidth]{image_name} ! Missing $ inserted A character that can only be used in the mathematics was Overfull hbox inserted in normal text. then perhaps you are \LY1/brm/m/it/10 see \LY1/brm/m/n/10 X Win- trying to use a special character that needs to be entered in a different way.[94] This is a warning that LaTeX cannot stretch the line wide enough to fit. keeping the word on the line would This can also happen if you use the wrong character make the spaces smaller than the current limit. It says what lines of your file it was wide: . which may be used to avoid these errors.11617pt too wide) in para- use the 'quick math mode': \ensuremath{.g. Some editors allow common commands the previous sentence.. such as “mm/year” character. e. encoding formats. not intend to use mathematics mode. which should not be Underfull hbox broken over multiple lines.. so the encoding.000) easily find the location of overfull hbox in your document. and a manual cor- rection needs making (such as a change to the hyphen- In this error. from the date.\end{math} or [101] Overfull \hbox (9.. and environments to be inserted using drop-down menus This warning may also appear when inserting im- or icons. LaTeX is complaining that it has no such command (“control sequence”) as \dtae.. The codes separated by slashes 2004} are the typeface and font style and size used in the line. Normally TeX ignores linebreaks. Line num- graph ended before \date was complete. but only a human can detect that fact: all a return before it. If you intended to use mathemat- ics mode.8 9pt is too much to ignore (over 3mm).6 \dtae {December fending line was printed. −30 [][]\LY1/brm/b/n/10 Bull.. put\slash output”. It can be avoided by using the \textwidth or possibly \linewidth options.}.. this should be properly typeset as “in- As \maketitle creates new paragraphs on the title page. of a line (with the following words appearing at the start of the next line). The warning is given so that you can find the line in the code that originates the problem (in this case: 860-861) Runaway argument and fix it. The "/" character is typically used in units. space between words. the closing curly brace has been omitted ation). and have been mistyped. make sure to pick the right one. In this case it is about: it’s undefined. The chosen hyphenation point which minimizes Runaway argument? {December 2004 \maketitle ! Para. The warning can also be issued when the \end{document} Underfull \hbox (badness 1394) in paragraph at lines 28- tag was not included or was deleted. Ignore them for the moment. <to be read bers and page numbers are given as before. there are several character the edge.g. for example _ will be interpreted as a An overfull \hbox means that there is a hyphenation or subscript operator in mathematics mode.$ or \begin{math}. \\.

just install the used language in your LaTeX distribution.aux file. where babel defined your language. Package babel Warning: No hyphenation patterns were loaded for the language X Although this is a warning from the Babel package and 3. However. Type X to quit or <RETURN> to proceed. First. If you don't want to affect the global installation of the machine.ev-en. this error is very common and (can) give some strange hyphenation (word breaking) problems in In TeX.1 Units The solution is not difficult. if you get the name right.2. LaTeX/Internationalization) \usepackage[latin]{babel} 3.org/tex-archive/macros/latex/ easy to fix. It is available as source code or compiling. The answer lies in the . If not.1.76 CHAPTER 3.4 Software that can check your . so it’s • nag (www. as there is obviously no error in your code if you did not change anything. with the aim of finding errors or highlighting bad practice. you will need indicate the use of obsolete commands. TeX to use a certain package. • a floating point factor followed by a macro that ex- This can happen after the usage of: (see pands to a length.sty. we introduce the LaTeX measurement units. Wrong hyphenation rules can decrease the neatness of your document. • depth • height No error message. loaded for (babel) the language `Latin' (babel) I will use the patterns loaded for \language=0 instead.ctan. but the contrib/nag) is a LaTeX package designed to package is not installed on your machine. you will get this error. Here are the most com- mon ones.2 Lengths not from LaTeX. or enter new name. and then decided Here are some less common units. The point is the default unit and 1pt is the default length.2 Box lengths file. but won't compile • width One common cause of (pdf)LaTeX getting stuck is for- getting to include \end{document} See Boxes. it will look for a file with the specified name and the filetype . .sty' not found. and providing more help to (particularly novice) When you use the \usepackage command to request La- users than the built-in error messages. to download and install it before continuing.sty file lacheck) is a consistency checker intended to spot and put it in the same folder of the document you are mistakes in code. you • lacheck (www.2. If you try the compilation a second time. In this case the user has mistyped the name of the paralist package.ctan.org/proj/chktex/) is a LaTeX semantic checker available as source code for Unix- like systems. MECHANICS Missing package 3.aux 3. You can choose from a variety of units. to switch to Y.[1] Package babel Error: You haven't loaded the option X yet. delete A box in TeX is characterized by three lengths: the . [2] If you previously set the X language. a length is your document. This may seem awkward. optionally Package babel Warning: No hyphenation patterns were followed by a stretching value. There are several programs capable of checking LaTeX (Default extension: sty) Enter file name: source. then everything will work as usual. All other units are converted to the point by a fixed ratio. • a floating point number followed by a unit. it should work.tex Code ! LaTeX Error: File `paralisy. All LaTeX units are two-letter abbreviations.org/tex-archive/support/ can simply download from Internet the necessary . compiled for Windows and OS/2 • chktex (baruch.

Common length macros are: \bigskip Inserts a big space in vertical mode (between two paragraphs). it will raise the length up to a maximum of 15pt. Example: To insert a fixed-length space. of these commands: \textheight The height of text on the page. If you want to add space To print a length. instead of \vspace. then you may use It’s important you use the \vspace* command instead of Plain TeX \vspace. it is the same as with LaTeX.2. the start of a line. space. like paragraphs to build a page.\hspace stands for horizontal space. boxes “horizontally”.4 LaTeX default lengths tween two paragraphs). fore minus. You may wish to look at the example below to see how you can use these. set a new value for an existing length variable: \paperheight The height of the page. But LaTeX also provides \savebox to avoid this \unitlength Units of length in picture environment. \medskip Inserts a medium space in vertical mode (be- 3. acters. plus must be placed be.2. You can create your own length with the command. using the command \smallskip Inserts a small space in vertical mode (be- \the. if it is overfull. use: It means that tex will try to use a length of 10pt. The vertical mode is during the process of assembling boxes “vertically”. You can change the values of the variables defining the page layout with two commands. you may duplicate the text \topmargin The size of the top margin. See Boxes for more details. Note that it is not mandatory to specify both the plus and If the space should be preserved at the top or at the bot- the minus values. \vspace*. \columnwidth The width of the column. The calc package provides also the function \settototal- height{\mylength}{some text} \textwidth The width of the text on the page.3. use \hspace* instead.2. tween two paragraphs). LENGTHS 77 3.tom of a page. To create a new length: TeX features some macros for fixed-length spacing. without anything else written before.5 Fixed-length spaces is a length preceded by plus or minus to specify to what extent tex is authorized to change the length. With this one you can \paperwidth The width of the page. . use the starred version of the command. horizontal mode is during the process of assembling \columnsep The distance between columns. that you want to use as reference if you plan to also dis- play it. The \baselinestretch Multiplies \baselineskip. dle of a paragraph. When using these commands. You can also define stretched values.2. you must create a new length before you attempt to set it: \tabcolsep The default separation between columns in a You may also set a length from the size of a text with one tabular environment. To set a length: To view. \vspace for vertical derfull. \baselineskip The normal vertical distance between lines in a paragraph. and \parskip The extra vertical space between paragraphs. otherwise LaTeX can silently ignore the extra space. if it is un. The fact they are vertical mode commands mean they will \evensidemargin The margin for 'even' pages (think of be ignored (or fail) in horizontal mode such as in the mid- a printed booklet). duplication. it will lower the length up to a minimum If such a space should be kept even if it falls at the end or of 7pt. The first token next the a double line- break is still in vertical mode if it does not expand to char- \linewidth The width of a line in the local environment. you can use the \the command: at the beginning of the document.3 Length manipulation \oddsidemargin The margin for 'odd' pages (think of a printed booklet). A stretching value 3. but if you do. like letters to build a word or words to build a paragraph. with this other one. you can add a value to the existing one: \parindent The normal paragraph indentation.

3. To that end each counter stores on a line is filled up. LaTeX counters are not introduced by git/tree/texk/web2c/pdftexdir/pdftex. i. use: To add to an existing counter another counter causing a reset when increased. ing to the stretch factor. [2] http://anonscm. The same way. to control the numbering mechanism of everything (sec- possibly a float. Such LaTeX formats are specified using internal LaTeX commands: . • \hrulefill will produce a rule..2.2. in connection with \pagebreak. captions. MECHANICS 3. In LaTeX it is fairly easy to create new counters and even The \stretch command. but not the others.6 Rubber/Stretching lengths 3. they grow accord. It stretches until all the remaining space tions. from commands are issued on the same line.37493-5#n10460 plainTeX equivalents \count and \newcounter\mycounter do abide by the backslash rule. either use Several macros allow filling the rest of the line -.1 Counter manipulation You can also use \fill instead of \stretch{1}. If you want the counter to be reset to zero every time Example: another counter is increased. with \stretch{1} or \fill): \hfill and \vfill. center text vertically on a page. or to is increased (think subsection in a section for example). or here the number can also be negative. lists. 3.e. counters that reset automatically when another counter can be used to typeset text on the last line of a page.debian. It is not a formatted string. 2015. Strangely enough. 3. To set the counter value explicitly. 1 (i. • \arabic{NameOfTheNewCounter} will print the formatted counter using arabic numbers. you can stretch vertically: 3.html used as a value too. even with the \the command. use • \dotfill will produce dots. 3.2.2.3 Counter style • University of Cambridge > Engineering Department Each counter also has a default format that dictates how > computing help > LaTeX > Squeezing Space in it is displayed whenever LaTeX needs to print it.2 Counter access There are several ways to get access to a counter.8 References Note that \arabic{NameOfTheNewCounter} may be [1] http://www.3. Make distance between items larger (inside an itemize en- vironment) : • \value{NameOfTheNewCounter} will return the counter value which can be used by other counters Use of \savebox to resize an image to the height of the or for calculations.giss.9 See also 3.3.web?h=debian/ a backslash in any case. 3.nasa. so it text: cannot be used in text. use: Fill the rest of the line To increase the counter. −231 to 231 − 1 .7 Examples • \theNameOfTheNewCounter will print the format- ted string related to the counter (note the “the” be- Resize an image to take exactly half the text width : fore the actual name of the counter). With the command There are 'shortcut commands’ for stretching with factor you create a new counter that is automatically set to zero.3 Counters The command: Counters are an essential part of LaTeX: they allow you generates a special rubber space where factor is a number. etc.). setting you need to use \stepcounter.or or stretching parts of the line -.e. If two \hspace{\stretch{factor}} an integer value in the range of long integer. For automatic re- • \hfill will produce empty space.20150524.78 CHAPTER 3.org/cgit/debian-tex/texlive-bin.in different manners.gov/tools/latex/ltx-86.

7 Custom sectioning can be used to prevent LaTeX from breaking two words. Here is an example for recreating something similar to a these horizontal box packers give you ultimate flexibility. but the point is that TeX operates with glue and boxes.) As you can put boxes inside boxes. Letters are not the only things that can • paragraph be boxes. We already know one of them. For the eqnarray environment: • The width is the width of the box. • subsection Admittedly. this is a very simplistic description of what • subsubsection really happens. At first. it’s called \mbox. and 3. commands that operates only on horizontally aligned ma- terial.4 LaTeX default counters 3. including other boxes. For the enumerate environment: 3. each letter is a little box. al- though they weren't described as such. Boxes have three dimensional properties: • enumii • enumiii • The height is the length between the baseline and the top of the box.htm .3. both produce a box.5 Book with parts.4.4 Boxes • part LaTeX builds up its pages by pushing around boxes.3. This means it can be smaller than the material . which is elastic so that a • section series of words can be squeezed or stretched as to exactly fill a line on the page. These are again glued to other words. • enumiv • The depth is the length between the baseline and the bottom of the box.3.personal. A general overview about different box com- mands can be found here: http://www.6 Custom enumerate While \parbox packs up a whole paragraph doing line breaking and everything.2 makebox and mbox 3. but no chapters in the book class : 3. for example.hu/ • mpfootnote tex/spacebox. The tabular en- • figure vironment and the \includegraphics. One can put virtually everything into a box. there is also a class of boxing See the List Structures chapter. You just have to make sure that their combined width is not larger than the \tex- • footnote twidth. BOXES 79 3. sections. which is then glued to other • chapter letters to form words.1 TeX character boxes • enumi TeX characters are stored in boxes like every printed el- ement. (See Hyphenation.4. • equation 3.4.ceu.width defines the width of the resulting box as seen from TeX: the outside. but no chapters Here follows an example where we want to use parts and sections. but with special glue. Each box will then be handled by • subparagraph LaTeX as if it were a single letter. section and subsection counter that already exist in La. This means that one can easily arrange • table two tables or images side by side.3. • page The past chapters have already dealt with some boxes. It simply packs up a series of boxes into another one.3.

9 colorbox and fcolorbox graphs.3. MECHANICS inside the box. 3. storing a text.4. Most standard LaTeX boxes are not long com- mands. \height. parameter is the height of the parbox or minipage.80 CHAPTER 3. However you can pack a paragraph of your choice into a box with either the \par. the obvious next step repeatedly. but it draws a box around the text. You can tweak the following frame lengths. top. otherwise you will The following example shows you some things you could put the following \fbox in another paragraph on another do with the \makebox and \framebox commands: line. Paragraphs in all boxes • \fboxsep: the distance between the frame and the content. \depth and \totalheight or bottom to control the vertical alignment of the box.4 framed an optional argument that specifies the vertical position of the text: An alternative to these approaches is the usage of the framed environment (you will need to include the framed The valid values are b (bottom).7 savebox 3. in the width parameter.4. contentpos parameter is the position of the content and flushleft. the surrounding boxes. You can use it as a way to print or manipulate something Now that we control the horizontal. and parbox to embed paragraphs in non-long boxes.8 rotatebox 3. This shows the box frame of a letter. If package to use it). in order to act upon the size of the thing in the document. . and c (center). No problem for LaTeX. The command \framebox works exactly the same as This should print 3 boxes on the same line.5 raisebox A \savebox is a reference to a box filled with contents. and does not display any- first three parameters. You can make use of the long capabilities of minipage • \fboxrule: the thickness of the rule. is to go for the vertical.4.See Colors. or spread the text to fill the box. and \usebox recalls the content of box inside the text argument. The The pos parameter takes a one letter value: center. width takes a length argument specifying the width of the box. \fcolorbox can also be tweaked with \fboxsep box[pos][height][contentpos]{width}{text} command or and \fboxrule. You can even set the width to 0pt so that the \begin{minipage}[pos][height][contentpos]{width} the text inside the box will be typeset without influencing text \end{minipage} environment. \depth and \totalheight in the fied text in this placeholder.3 framebox you cannot use all commands and environments inside a parbox.4. i. eters set for the height and depth of the raisebox.4.e.4. they do not support breaks nor para. can be one of center. The height by measuring the typeset text. the command \savebox stores the speci- You can use \width.6 minipage and parbox See Rotations. top you can also use \width. 3. For instance: This prints a thick and more distant frame: This prevents the overfull badness. flushright. t (top). For instance you can observe the difference when embedded in a framebox. bottom or spread. The two optional param- the placeholder into the document.4. The The command \newsavebox creates a placeholder for command lets you define the vertical properties of a box. The main difference between a minipage and a \parbox is that 3. the paragraph within a document: text will be wrapped: You can do it manually with a parbox. You can also use from the pbox package which will create a box of minimal size around the text. This provides an easy way to box a you specify a length in the first (required) argument. \height. while almost anything is possible in a minipage. The pos parameter can take one of the letters center. another linebreak between the \fbox. Besides the length expressions. They are set from values obtained relative to the baseline of the surrounding text. Do not put \makebox. Note that the \pbox command takes 3.

.5 Rules and Struts 3. RULES AND STRUTS 81 3.3. You could use it in a tabular environment or in boxes to make sure a row has a certain minimum height. In professional typesetting.5.5.4. you can optionally raise or lower the produced rule above or below the baseline. It is used to guarantee that an element on a page has a certain min- imal height.3 Stretched rules LaTeX provides the \hrulefill command. this is called a strut.1 Rules The \rule command in normal use produces a simple black box: The parameter thickness determines the height. 3. See the Lengths chapter. which work like a stretched horizontal space. whereas width determines the width of the produced rule.5.2 Struts A special case is a rule with no width but a certain height.4.11 fancybox The fancybox package provides additional boxes. Here is an example (the thin lines are located at the base- line): This is useful for drawing vertical and horizontal lines. With the optional parameter raise. • \doublebox • \ovalbox • \shadowbox 3.5.10 resizebox and scalebox The graphicx package features additional boxes. 3. In LaTeX a strut is defined as 3.

.1 Mathematics • displayed — displayed formulas are separate from the main text. like in equations (This 82 .messages may not be helpful. Each letter is considered to be the name of a variable to \usepackage{amsmath} in the preamble if mathtools and will be typeset as such..$). as it of LaTeX’s greatest strengths. plain LaTeX has most of the tools that The equation* and displaymath environments are func- you will need. should a problem occur.ple. 4. This is because LaTeX typesets maths notation differently from In order for some operators.[2] To use either package. as all spaces are either derived logically from the mathematical expressions.that has some differences compared to the text mode: ronments to amsmath. symbols. The mathtools package loads the amsmath package and hence there is no need 3.. it might be convenient to write the \displaystyle two categories depending on how they are presented: class inside the environment.. Furthermore. particularly with the AMS-LaTeX to the existence of so much mathematical notation. Therefore. The mathtools package fixes some amsmath ematical environments. macros.$$ should be avoided.1 Mathematics environments LaTeX needs to know beforehand that the subsequent Inserting “Displayed” maths inside blocks of text text does indeed contain mathematical elements. ical formulas. in the preamble of the document. quirks and adds some useful settings. They can be distinguished into $.. but will cause exponents and indices to be • text — text formulas are displayed inline. such as \lim or \sum to be normal text. there are some handy shorthands to declaring your why TeX (and later on. It is also a large topic due may cause problems. Empty lines are not allowed. \sum$ will print a bigger one . while looking professional when the standard way. and envi. or have to be speci- or fied with special commands such as \quad \usepackage{mathtools} 2. I can say that a + a = 2a within this sentence. Doing so might cause the line to be taller. LaTeX) became so popular within formulas.Chapter 4 Technical Texts 4. The fact that he succeeded was most probably ever. how- printed. but while you are typing within one of those math- by LaTeX. If you want to typeset is used. For exam- within the body of text where it is declared.. you are said to be in text are more powerful and flexible than the ones provided mode. for ex. that contains numerous complicated formulas. Unlike most other environments. displayed correctly for some math operators. One of the greatest motivating forces for Donald Knuth when he began developing the original TeX system was As math requires special environments.1. Most spaces and line breaks do not have any signifi- cance. If you are writing a scientific document tionally equivalent. The following table summarizes them: the scientific community. Only one paragraph per formula. there are natu- to create something that allowed simple construction of rally the appropriate environment names you can use in mathematical formulae. normal text within a formula (normal upright font and normal spacing) then you have to enter the text using dedicated commands. the $\sum$ will print a smaller ∑ Σ and $\displaystyle ample. the error If your document requires only a few simple mathemat. include: \usepackage{amsmath} 1.. special environments have been displayed correctly inside some math environments (read declared for this purpose. the ams- math package[1] introduces several new commands that If you are typing text normally. Typesetting mathematics is one Suggestion: Using the $$. that is. you are said to be in math mode.

1.2 Symbols Powers and indices are equivalent to superscripts and sub- scripts in normal text mode.A fraction is created using the TeX Symbol List” in the external links section below. \textstyle and \dis- then you will get an uppercase letter. usage of xfrac package is recommended. cos. distinct commands must be issued in order to display the desired symbols. the nicefrac package provides the \nicefrac \bmod and \pmod: command. surround the power with {}. using the package alone will result in er- commands: rors about certain font shapes not being available. kappa. or variant. tan). phi. limits (lim). set and relations denote evaluation using subscript notation in mathemat- symbols. There are An underscore (_) can be used with a vertical bar ( | ) to many examples such as Greek letters. binary operators. Look for 4. The alternate.1. If you use them throughout the document. Lowercase epsilon.g. so they are not typeset the binomial coefficient. trigonometric functions (sin. $x^{\sfrac{1}{2}}$ % no error terminant (tr. played mathematics. whose usage is similar to \sfrac. . the subscript is case. exp). and You can embed fractions within fractions: they are very easy to type in math mode. Usage: 4. the binomial 4. a tightened ver- Scroll down to #List of Mathematical Symbols for a com. Beyond those listed above. 4.e.sion can be defined by inserting some negative space plete list of Greek symbols. rho.4.g.the circumflex accent) character is used to raise some- ficult aspects of learning LaTeX is remembering how to thing. you will get a lowercase Greek letter. For relatively simple fractions. (for those who need their memories refreshed. provided by LaTeX (e. which is useful in longer documents. Similarly.6 Fractions and Binomials “Detexify” in the external links section below. It is also possi. uppercase Alpha and Beta are just “A” and “B” respectively).4 Operators If fractions are used as an exponent curly braces have to be used around the \sfrac command: An operator is a function that is written as a word: e. a fraction is noticeably smaller than in dis- letter is lowercase. version is created indices: by adding “var” before the name of the letter: If this looks a little “loose” (overspaced). The \tfrac and \dfrac commands[3] if the first letter is uppercase (and only the first letter). Another option would be to look in the “The Comprehensive La. det). and sigma are provided in two differ. etc. especially within the text. For the modular operator there are two commands: Alternatively. they should be can be accessed directly from the keyboard: grouped using curly braces ({ and }). theta. In that For certain operators such as limits. such as argmax. as well as trace and de. $x^\frac{1}{2}$ % no error $x^\sfrac{1}{2}$ % error ponentials (log. that’s the top and bottom respectively!). If more produce symbols. The caret (^. and the underscore (_) is for lowering. or in type the name of the letter after a backslash: if the first inline text ab . Note that some up- playstyle. also known as Mathematics has many symbols! One of the most dif. There is of course a set of symbols that than one expression is raised or lowered. MATHEMATICS 83 only works with AMSMATH package). LaTeX has many of these defined as In some cases. the \tbinom and \dbinom commands percase Greek letters look like Latin ones. You just have to Note that when appearing inside another fraction. arrows. \frac{numerator}{denominator} command.1. ics: For example: Fortunately. it may be more aesthetically pleasing to use powers and ent versions. logarithms and ex. Likewise. ble to force this behaviour for all math environments by see custom operators declaring \everymath{\displaystyle} at the very beginning (i.To use operators that are not pre-defined.3 Greek letters coefficient (aka the Choose function) may be written using the \binom command[3] : Greek letters are commonly used in mathematics. pi.1. the lmodern and fix-cm packages need to be added placed underneath the operator: as well.1. there’s a tool that can greatly simplify the search for the command for a specific symbol. force the use of the respective styles. This package provides \sfrac command to create slanted fractions. before \begin{document}). +-=! /()[]<>|': For powers with more than one digit.1.5 Powers and indices 4.

8 Sums and integrals these: The \sum and \int commands insert the sum and integral Curly braces are defined differently by using \left\{ and symbols respectively. you [4] may use personal declarations. Unfortunately this code won't work There are a variety of delimiters available for use in La- √ if you want to use multiple roots: if you try to write b a as \sqrt[b]{a} after TeX: you used the code above. or you may simply want There are many other “big” commands which operate in finer control over the delimiter sizes. where \lbrack and \rbrack may be used in place of [ and In other words. The typical notation for sums is: If a delimiter on only one side of an expression is re- or quired. then an invisible delimiter on the other side may be denoted using a period (. special types of mathematical structures. and \middle commands. Also. you can redefine the square root this way ]. It accepts an optional argument specified in For bigger integrals. which is attained with the \.In certain cases. An alternative piece of TeX code that does allow multiple Automatic sizing roots is However this requires the \usepackage{letltxmacro} Very often mathematical features will differ in size. a similar manner: \Big.). in package which case the delimiters surrounding the expression should vary accordingly. This can be done automatically using the \left. The new square root can be seen in the as matrices. compared to the old one on the right. such something more. but How to use braces in multi line equations is described in the if you still want to change the output of the square root.1.84 CHAPTER 4. it is numbers written one below the other. com. square brackets ([ and ]) to change magnitude: or the bigints package . \right.7 Roots other parameters to amsmath package related to them are described in Advanced Mathematics chapter. This method arguably makes it more 4. and with a small space separating it from the integrand. use the \limits com- To make multiplication visually similar to a fraction.1. braces and delimiters clear what is in the scope of the root sign. The \sqrt command creates a square root surrounding an expression. the sizing produced by the \left and \right mand. commands may not be desirable. In this case. then redefines \sqrt in terms of the old one. which in math mode is obtained through the Manual sizing \mathrm{} command. TECHNICAL TEXTS Continued fractions For more integral symbols. command[3] : The \substack command[3] allows the use of \\ to write the limits over multiple lines: Multiplication of two numbers If you want the limits of an integral to be specified above and below the symbol (like the sum).9 Brackets. adding ous. you'll just get a wrong output. Some people prefer writing the square root “closing” it over its content. for example multiplication of However if you want this to apply to ALL integrals. Just add the following code in the preamble of your document: The use of delimiters such as brackets soon becomes im- portant when dealing with anything but the most trivial This TeX code first renames the \sqrt command as \old- equations. \bigg and \Bigg modifier commands may be used: . with limits specified using the caret \right\}. Advanced Mathematics chapter. Any of the previous delimiters may be used in combination with 4. a mand: nested array can be used.1. typically rely on delimiters to enclose them. (^) and underscore (_). This habit is not normally used while writing with the computer. It’s also important to represent the integration variables with an upright d. try the esint Continued fractions should be written using \cfrac package. Without them. the \big. The limits for the integrals follow the same notation. formulas can become ambigu- sqrt. LaTeX gives you this possibility. preferable to specify the intlimits option when loading the amsmath package: Subscripts and superscripts in other contexts as well as 4. picture on the left. including those not included by default in the Computer Modern font. only if you are not going to use multiple roots in the whole document.

use smallmatrix environment: To denote open and half-open intervals. (a. The added benefit columns be pre-specified: here is that you can have better control over the font for- You may see that the AMS matrix class of environments matting. Let’s see what happens when the above version[5] : equation code is adapted: The alignment by default is c but it can be any column The text looks better. trails off the end of the page.1. tween the numbers and the words.} with a double backslash (\\) command [3] (a similar command is \mbox{.. but for the sake \right commands. and each charac- ter is a separate element (so are not positioned as closely A basic matrix may be created using the matrix as normal text). and not increase leading in the Typesetting intervals line containing it.1. If the 4. These commands are equally valid within sion of the tabular environment. Unfortunately. the notations ]a. or want to insert lines be. However.1. environment[3] : in common with other table-like struc- tures.10 Matrices and arrays mathematics according to its own rules). vertical and diagonal triplets of dots (known as ellipses) to fill in certain columns and Formatted text rows. add additional leading space large. This can be achieved using the format the argument accordingly.b[. this may lead to wrong de- limiter sizes. To fix this. in that it treats it as a math- ematical expression: spaces are ignored (LaTeX spaces 4.. Here is an example of trying negative number. ]a. \textbf{bold text} array environment. To insert a small matrix. [a. . and must be sepa. with the optional parameter to the \\ command: rated into two lines using an align command.gives bold text. which is essentially a math-mode ver. you However matrices are usually enclosed in delimiters of are required to explicitly add these. then the number including its minus. For example. This can M =  65 0 16  be difficult to read... Similarly. when typesetting tions resulting in output similar to this: 5 1  we notice that the \left and \right commands produce the 6 6 0 same size delimiters as those nested within it. and the letters are italicized operation.. There are many ways some kind.such as \textrm. \textbf. MATHEMATICS 85 These commands are primarily useful when dealing with doesn't leave enough space when used together with frac- nested delimiters. it is com- mon to use horizontal. Both issues are simply artifacts of the maths mode. Although If you need “border” or “indexes” on your matrix. then the interval must be put between curly braces ({ and }) in order to have correct The math environment differs from the text environment spacing. plain the commands \left. These can be specified using the \cdots. and has a less de- To specify alignment of columns in the table. These commands tween columns or rows. alignment within each column. we write 0 65 16 Manual sizing can also be useful when an equation is too To counteract this problem.4. e. which requires that the a maths environment to include text. there are no gaps be- type valid in array environment.There are a number of ways that text can be added prop- rated using an ampersand (&) and a new rows separated erly. can be used to balance TeX provides the macro \bordermatrix the delimiters on each line. if a (half-)open interval starts with a in the representation of text. so that There are two noticeable problems: there are no spaces LaTeX understands that the minus-symbol is the unary between words or numbers.11 Adding text to equations square bracket notation is used. manual sizing can be used to avoid overly large delimiters if an \underbrace or a similar Matrices in running text command appears between the delimiters. use starred scriptive name). though this causes problems with subscripts. Compare: and more spaced out than normal. there is an alternative that offers a little more flexibility. The typical way is to wrap the text with the \text{. \vdots and \ddots respectively: Using the \text is fine and gets the basic result.b]. Yet.g. (a. When writing down arbitrary sized matrices. rather than the standard text achieved with \text. of simplicity we may simply insert space characters into vironments which automatically include delimiters: the \text commands. Furthermore. \textit. and \right. and while it is possible to use the \left and to add spaces between maths elements.b]. there are various other predefined en. with columns sepa.b[ and [a. etc. to represent text within the math environment: symbol must also be put between curly brackets.b).}. You In some cases you may want to have finer control of the may recall the introduction of font formatting commands.b) are used. entries are specified by row.

it priate element to show their association. In these events. A good example would be dis- maths elements appear on either side of the sign. LaTeX deals with the + and − signs in two possible ways.operator. 4. it is playing the simple equation for the indefinite integral of assumed to be a binary operator.9 and does not yield the results seen on the right. This can be useful if you are writing multiple-line formulas. The alternative way y dx is a sign designation. for example.) The \qquad gives twice that amount. \quads were used to add some 4.15 Controlling horizontal spacing except that they are specifically aimed at text in math mode (requires amsfonts) LaTeX is obviously pretty good at typesetting maths—it These formatting commands can be wrapped around the was one of the chief aims of the core TeX system that entire equation. start with a = or a +. As you can see from the code from the above example. and as such. This If you were to try this.) The package xcolor. and uppercase Greek. These are mans bold): this prints multiple versions of the charac. The result tends to be slightly incorrect \boldsymbol command[3] . In this doesn't respect the white-space left in the code to signify instance. To fix this. LaTeX assumed to be positive unless a − is prefixed to it. to add a comment of some kind. ter slightly offset against each other. necessary. this doesn't give the correct result. Accents This code produces errors with Miktex 2. However.14 Plus and minus signs separation between the maths and the text. TECHNICAL TEXTS 4. of course.1. it is preferable to ensure there is a decent amount of space between the maths and the text. since . we enclose A \quad is a space equal to the current font size. OK. see correctly. described in Colors. if you it in a \mathbin environment.1. w:Help:Displaying a formula#Alphabets strange alignments adding the invisible character where and typefaces and w:Wikipedia:LaTeX sym. you may write: is common for the latter. For example. A \quad would clearly be overkill a − with nothing before it but you want it to be handled in this situation—what is needed are some small spaces to like a binary operator you can add an invisible character be utilized in this type of instance. isfactory. in the following equation.generally very subtle adjustments. When two ginning of the document. then the space provided by \quad This process is described here. and to accurately interpret formulas in the way you did.13 Color amsmath package described in Advanced Mathematics chapter. will also be 11pt (horizontally. This is when you state whether a mathematical quantity is either positive or negative. It other math commands are unaffected. For example. then you can fix some bols. are using an 11pt font. There are other occasions where LaTeX has done its job To change the size of the fonts in math mode. but you just want to add some space. and a new line could See also: w:Mathematical Alphanumeric Sym. yet any perfectionists will no doubt wish to fine- As a last resort there is the \pmb command[3] (poor tune their formulas to ensure spacing is correct. maybe Changing font size. what about formatting mathe- matical expressions? There are a set of formatting com- mands very similar to the font formatting ones just used. allows us to add LaTeX has defined two commands that can be used any- color to our equations.86 CHAPTER 4. the output is still sat- exists a bold version of the symbol in the current font. and not just on the textual elements: they LaTeX extends. you want the sign to appear close to the appro. Well the next step is to use accents: (Note that this particular example can be expressed in more elegant code by the cases construct provided by the 4. and that’s what LaTeX . allocates y with respect to x: ∫ some space either side of the sign. it can't always be relied upon only format letters.1. So. this will only work if there horizontal spacing. bols#Fonts A plus-minus sign is written as: Similarly.1. so back to the fine tuning as mentioned at the be- The most common is as a binary operator. If you put a + or lumps them altogether. as in maths. has to make certain assumptions when there are ambigu- To bold lowercase Greek or other symbols use the ous expressions.12 Formatting mathematics symbols before the operator using {}. Use \mathrm instead So what to do when you run out of symbols and fonts? of just \text. there exists also a minus-plus sign: We can now format text. that the y and the dx are independent entities.is a binary operator. where in documents (not just maths) to insert some hor- The only problem is that this disrupts the default LaTeX izontal space. such elements are However. They are \quad and \qquad formatting around the . numbers. Instead.

4.1. MATHEMATICS 87

provides: 4.1.17 Advanced Mathematics: AMS
NB you can use more than one command in a sequence Math package
to achieve a greater space if necessary.
The AMS (American Mathematical Society) mathemat-
So, to rectify the current problem: ics package is a powerful package that creates a higher
The negative space may seem like an odd thing to use, layer of abstraction over mathematical LaTeX language;
however, it wouldn't be there if it didn't have some use! if you use it it will make your life easier. Some com-
Take the following example: mands amsmath introduces will make other plain LaTeX
commands obsolete: in order to keep consistency in the
The matrix-like expression for representing binomial co-
final output you'd better use amsmath commands when-
efficients is too padded. There is too much space between
ever possible. If you do so, you will get an elegant out-
the brackets and the actual contents within. This can eas-
put without worrying about alignment and other details,
ily be corrected by adding a few negative spaces after the
keeping your source code readable. If you want to use it,
left bracket and before the right bracket.
you have to add this in the preamble:
In any case, adding some spaces manually should be
avoided whenever possible: it makes the source code
more complex and it’s against the basic principles of Introducing dots in formulas
a What You See is What You Mean approach. The
best thing to do is to define some commands using all amsmath defines also the \dots command, that is a gen-
the spaces you want and then, when you use your com- eralization of the existing \ldots. You can use \dots in
mand, you don't have to add any other space. Later, if both text and math mode and LaTeX will replace it with
you change your mind about the length of the horizontal three dots "…" but it will decide according to the context
space, you can easily change it modifying only the com- whether to put it on the bottom (like \ldots) or centered
mand you defined before. Let us use an example: you (like \cdots).
want the d of a dx in an integral to be in roman font and
a small space away from the rest. If you want to type
an integral like \int x \, \mathrm{d} x, you can define a Dots
command like this:
LaTeX gives you several commands to insert dots (el-
in the preamble of your document. We have chosen \dd lipses) in your formulae. This can be particularly useful
just because it reminds the “d” it replaces and it is fast to if you have to type big matrices omitting elements. First
type. Doing so, the code for your integral becomes \int x of all, here are the main dots-related commands LaTeX
\dd x. Now, whenever you write an integral, you just have provides:
to use the \dd instead of the “d”, and all your integrals will
have the same style. If you change your mind, you just Instead of using \ldots and \cdots, you should use the se-
have to change the definition in the preamble, and all your mantically oriented commands. It makes it possible to
integrals will be changed accordingly. adapt your document to different conventions on the fly,
in case (for example) you have to submit it to a publisher
who insists on following house tradition in this respect.
The default treatment for the various kinds follows Amer-
ican Mathematical Society conventions.
4.1.16 Manually Specifying Formula Style
Write an equation with the align environment
To manually display a fragment of a formula using text
style, surround the fragment with curly braces and pre- How to write an equation with the align environment with
fix the fragment with \textstyle. The braces are required the amsmath package is described in Advanced Mathe-
because the \textstyle macro changes the state of the ren- matics.
derer, rendering all subsequent mathematics in text style.
The braces limit this change of state to just the fragment
enclosed within. For example, to use text style for just 4.1.18 List of Mathematical Symbols
the summation symbol in a sum, one would enter
All the pre-defined mathematical symbols from the \TeX\
The same thing as a command would look like this: package are listed below. More symbols are available
Note the extra braces. Just one set around the expression from extra packages.
won't be enough. That would cause all math after \tsum Note: To use the Greek Letters in LaTeX that have the
k to be displayed using text style. same appearance as their Roman equivalent, just use the
To display part of a formula using display style, do the Roman form: e.g., A instead of Alpha, B instead of Beta,
same thing, but use \displaystyle instead. etc.

88 CHAPTER 4. TECHNICAL TEXTS

*Not predefined in LATEX 2. Use one of the pack- 4.2 Advanced Mathematics
ages latexsym, amsfonts, amssymb, txfonts, pxfonts, or
wasysym This page outlines some more advanced uses of math-
If LaTeX does not include a command for the mathemati- ematics markup using LaTeX. In particular it makes
cal operator you want to use, for example \cis (cosine plus heavy use of the AMS-LaTeX packages supplied by the
i times sine), add to your preamble: American Mathematical Society.
\DeclareMathOperator\cis{cis}
You can then use \cis in the document just like \cos or
4.2.1 Equation numbering
any other mathematical operator.
The equation environment automatically numbers your
equation:
4.1.19 Summary
You can also use the \label and \ref (or \eqref from
As you begin to see, typesetting math can be tricky at the amsmath package) commands to label and reference
times. However, because LaTeX provides so much con- equations, respectively. For equation number 1, \ref re-
trol, you can get professional quality mathematics type- sults in 1 and \eqref results in (1) :
setting with relatively little effort (once you've had a bit of Further information is provided in the labels and cross-
practice, of course!). It would be possible to keep going referencing chapter.
and going with math topics because it seems potentially
To have the enumeration follow from your section or sub-
limitless. However, with this tutorial, you should be able
section heading, you must use the amsmath package or
to get along sufficiently.
use AMS class documents. Then enter
to the preamble to get enumeration at the section level or
4.1.20 Notes to have the enumeration go to the subsection level.
If the style you follow requires putting dots after ordi-
[1] http://www.ams.org/publications/authors/tex/amslatex
nals (as it is required at least in Polish typography), the
\numberwithin{equation}{subsection} command in the
[2] http://www.ctan.org/tex-archive/macros/latex/contrib/
preamble will result in the equation number in the above
mathtools/mathtools.pdf
example being rendered as follows: (1.1..1).
[3] requires the amsmath package To remove the duplicate dot, add the following command
immediately after \numberwithin{equation}{section}:
[4] http://hdl.handle.net/2268/6219
For a numbering scheme using \number-
within{equation}{subsection}, use:
[5] requires the mathtools package
in the preamble of the document.
Note: Although it may look like the \renewcommand
4.1.21 Further reading works by itself, it won't reset the equation number with
each new section. It must be used together with manual
• meta:Help:Displaying a formula: Wikimedia uses a equation number resetting after each new section begin-
subset of LaTeX commands. ning, or with the much cleaner \numberwithin.

4.1.22 External links Subordinate equation numbering

• detexify: applet for looking up LaTeX symbols by To number subordinate equations in a numbered equation
drawing them environment, place the part of document containing them
in a subequations environment:
• amsmath documentation Referencing subordinate equations can be done using
either of two methods: adding a label after the \be-
• LaTeX - The Student Room gin{subequations} command, which will reference the
main equation (1.1 above), or adding a label at the end
• The Comprehensive LaTeX Symbol List of each line, before the \\ command, which will refer-
ence the sub-equation (1.1a or 1.1b above). It is possible
• MathLex - LaTeX math translator and equation to add both labels in case both types of references are
builder needed.

4.2. ADVANCED MATHEMATICS 89

4.2.2 Vertically aligning displayed mathe- align* suppresses numbering. To force numbering on a
matics specific line, use the \tag{...} command before the line
break.
A problem often encountered with displayed environ- align is similar, but automatically numbers each line like
ments (displaymath and equation) is the lack of any abil- the equation environment. Individual lines may be re-
ity to span multiple lines. While it is possible to define ferred to by placing a \label{...} before the line break.
lines individually, these will not be aligned. The \nonumber or \notag command can be used to sup-
press the number for a given line:
Above and below Notice that we've added some indenting on the second
line. Also, we need to insert the double braces ({}) before
The \overset and \underset commands[1] typeset symbols the + sign, otherwise latex won't create the correct spac-
above and below expressions. Without AmsTex the same ing after the + sign. The reason for this is that without
result of \overset can be obtained with \stackrel. This can the braces, latex interprets the + sign as a unary operator,
be particularly useful for creating new binary relations: instead of the binary operator that it really is.
or to show usage of L'Hôpital’s rule: More complicated alignments are possible, with addi-
tional &'s on a single line specifying multiple “equation
It is convenient to define a new operator that will set the
columns”, each of which is aligned. The following exam-
equals sign with H and the provided fraction:
ple illustrates the alignment rule of align*:
which reduces the above example to:
If the purpose is to make comments on particular parts of Braces spanning multiple lines
an equation, the \overbrace and \underbrace commands
may be more useful. However, they have a different syn- If you want a brace to continue across a new line, do the
tax (and can be aligned with the \vphantom command): following:
Sometimes the comments are longer than the formula be- In this construction, the sizes of the left and right braces
ing commented on, which can cause spacing problems. are not automatically equal, in spite of the use of \left\{
These can be removed using the \mathclap command[2] : and \right\}. This is because each line is typeset as a com-
Alternatively, to use brackets instead of braces use \un- pletely separate equation —notice the use of \right. and
derbracket and \overbracket commands[2] : \left. so there are no unpaired \left and \right commands
within a line (these aren't needed if the formula is on one
The optional arguments set the rule thickness and bracket
line). You can control the size of the braces manually
height respectively:
with the \big, \Big, \bigg, and \Bigg commands.
The \xleftarrow and \xrightarrow commands[1] produce
Alternatively, the height of the taller equation can be
arrows which extend to the length of the text. Yet again,
replicated in the other using the \vphantom command:
the syntax is different: the optional argument (using [ and
]) specifies the subscript, and the mandatory argument
(using { and }) specifies the superscript (which can be Using aligned braces for piecewise functions You
left empty by inserting a blank space). can also use \left\{ and \right. to typeset piecewise func-
For more extensible arrows, you must use the mathtools tions:
package:
and for harpoons: The cases environment

The cases environment[1] allows the writing of piecewise
align and align* functions:

The align and align* environments, available through the LaTeX will then take care of defining and or aligning the
amsmath package, are used for arranging equations of columns.
multiple lines. As with matrices and tables, \\ specifies Within cases, text style math is used with results such as:
a line break, and & is used to indicate the point at which {∫
the lines should be aligned. x dx
a=
b2
The align* environment is used like the displaymath or
equation* environment: Display style may be used instead, by using the dcases
[2]
Note that the align environment must not be nested inside environment from mathtools:
an equation (or similar) environment. Instead, align is a Often the second column consists mostly of normal text.
replacement for such environments; the contents inside To set it in the normal Roman font of the document, the
an align are automatically placed in math mode. dcases* environment may be used:[2]

90 CHAPTER 4. TECHNICAL TEXTS

Other environments There is also the mathtools \Aboxed{} which is able to
box across alignment marks:
Although align and align* are the most useful, there are
several other environments that may also be of interest:
4.2.6 Custom operators
There are also a few environments that don't form a math
environment by themselves and can be used as building Although many common operators are available in La-
blocks for more elaborate structures: TeX, sometimes you will need to write your own, e.g. to
For example: typeset the argmax operator. The \operatorname and \op-
eratorname* commands[1] display custom operators; the
* version sets the underscored option underneath like the
4.2.3 Indented Equations \lim operator:
However, if the operator is frequently used, it is prefer-
To indent an equation, you can set fleqn in the document able to define a new operator that can be used through-
class and then specify a certain value for the \mathindent out the entire document. The \DeclareMathOperator and
variable: \DeclareMathOperator* commands[1] are specified in the
header of the document:

4.2.4 Page breaks in math environments This defines a new command which may be referred to in
the body:
To suggest that LaTeX insert a page break inside an ams-
math environment, you may use the \displaybreak com- 4.2.7 Advanced formatting
mand before the line break. Just as with \pagebreak,
\displaybreak can take an optional argument between 0 Limits
and 4 denoting the level of desirability of a page break.
Whereas 0 means “it is permissible to break here”, 4 There are defaults for placement of subscripts and super-
forces a break. No argument means the same as 4. scripts. For example, limits for the lim operator are usu-
Alternatively, you may enable automatic page breaks in ally placed below the symbol:
math environments with \allowdisplaybreaks. It too can To override this behavior, use the \nolimits operator:
have an optional argument denoting the priority of page
breaks in equations. Similarly, 1 means “allow page A lim in running text (inside $...$) will have its limits
breaks but avoid them” and 4 means “break whenever you placed on the side, so that additional leading won't be re-
want”. You can prohibit a page break after a given line quired. To override this behavior, use the \limits com-
using \\*. mand.

LaTeX will insert a page break into a long equation if it Similarly one can put subscripts under a symbol that usu-
has additional text added using \intertext{} without any ally has them on the side:
additional commands. Limits below and under:
Specific usage may look like this: To change the default placement of summation-type sym-
Page breaks before display maths (of all various forms) bols to the side for every case, add the nosumlimits option
are controlled by \predisplaypenalty. Its default 10000 to the amsmath package. To change the placement for in-
means never break immediately before a display. Knuth tegral symbols, add intlimits to the options. nonamelimits
(TeXbook chapter 19) explains this as a printers’ tradition can be used to change the default for named operators like
not to have a displayed equation at the start of a page. It det, min, lim, etc.
can be relaxed with To produce one-sided limits, use \underset as follows:
Sometimes an equation might look best kept together pre-
ceding text by a higher penalty, for example a single-line Subscripts and superscripts
paragraph about a single-line equation, especially at the
end of a section. You can place symbols in subscript or superscript (in
summation style symbols) with \nolimits:

4.2.5 Boxed Equations It’s impossible to mix them with typical usage of such
symbols:
For a single equation or alignment building block, with To add both a prime and a limit to a symbol, one might
the tag outside the box, use \boxed{}: use the \sideset command:
If you want the entire line or several equations to be It is very flexible: for example, to put letters in each cor-
boxed, use a minipage inside an \fbox{}: ner of the symbol use this command:

g.2. they get smaller will let you easily define any theorem-like enunciation. use the \substack com. as it can only be used in the document preamble. If you want to change its state. the command \shortinter- space around displayed math: text{} from the mathtools package could have been used instead of intertext to reduce the amount of vertical white Short skips are used if the preceding line ends. whereas you may prefer to have it displayed larger.11 Adjusting vertical white space Note that any usage of this command does not change the around displayed math alignment.4. text and with sequential numbers next to it. e. First of all. These parameters must be set after . as the fractions continue. by default a simple fraction will look like this: ab [1] Requires amsmath package . you could declare each 4. be used for anything.3 Theorems maths elements: A classic example to see this in use is typesetting con.Put mand: before to force all math to 4. etc.point (pt) size. LaTeX provides a command that As you can see. 4.9 Changing font size There may be a time when you would prefer to have some 4. but still keeping it in-line. make it another math operator if you want. using text-mode maths. tally. You can preamble. (although they will not get any smaller than in this exam- ple. before the formula.2.1 Basic theorems fraction to use the display style instead. The easiest is the following: But it’s fairly easy to use: \DeclareMath.g. ts is .2. To add small interjections in math environments. and then you can have limits and then limits again.12 Notes control over the font size. There are four parameters that control the vertical white Also. horizon- space added between the lines. where they have reached the \scriptstyle limit).abled: mand to select your preferred sizes. The values you input are assumed to be symbol. For example.\newtheorem{name}{Printed output} Sizes{ds}{ts}{ss}{sss}.10 Forcing \displaystyle for all math in Multiline subscripts a document To produce multiline subscript.\usepackage{amsthm} side is that this command sets the global maths sizes. like this: [2] requires the mathtools package a .2. THEOREMS 91 If you wish to place them on the corners of an arbitrary the text size. If you want to keep the size consistent. Note that the changes only take place if the value in the But a simple grouping can also solve the problem: first argument matches the current document text size. where ds is the display size. This approach stead of the method provided below). simply group it. you should use \fourIdx from the fouridx pack. but can provides an example. in the above example. It is therefore common to see a set of declarations in the since a math operator can be used with limits or no limits. make sure you have the amsthm package en- Another approach is to use the \DeclareMathSizes com. b A simple approach is to utilize the predefined sizes for 4.. You can only define sizes for \displaystyle. use the \intertext command: 4. \textstyle. etc. One potential down. in the event of the main font being changed.3. age.8 Text in aligned math display . 4.3. The following code is commonly used for theorems in mathematics. E. like when in display mode.2. With "theorem" we can mean any kind of labelled enun- tinued fractions (though it’s better to use the \cfrac ciation that we want to look separated from the rest of the command[1] described in the Mathematics chapter in.

E.: 3pt {spacebelow}% measure of space to leave below the theorem. E. The basic usage is: normal interword space {headspec}% Manually specify \begin{proof} Here is my proof \end{proof} head . E. For instance. symbol.3” refers to the 3rd theorem in the 2nd section of a document.) at which the numbering is to take \renewcommand{\qedsymbol}{} place. Custom styles \newtheorem*{mydef}{Definition} To define your own style. redefine the \qedsymbol command.the argument is the style you want to use. quently defined theorems will use this style.3. The \newtheorem command may have at most one op.D. \newtheorem{name}{Printed output}[numberby] To use a custom Q.3. Usu. TECHNICAL TEXTS put it in the preamble. symbol. just use babel with the right argument and the word Proof printed in the output will be translated accordingly. \begin{mydef} Here is a new definition \end{mydef} If you would like to manually name the proof. LaTeX will print whenever you use it.g. rede- fine it to be blank: where numberby is the name of the section level (sec- tion/subsection/etc. symbol at the end of the last line.2 Theorem counters \begin{proof} Here is my proof: \[ a^2 + b^2 = c^2 \qedhere \] \end{proof} Often the counters are determined by section.D. Q.g.E. if you use it like this: source the name of the environment remains proof.3 Proofs measure of space to indent {headfont}% name of head font {headpunctuation}% punctuation between head and The proof environment[1] can be used for adding the body {headspace}% space after theorem head. The first argument is the name you It just adds Proof in italics at the beginning of the text will use to reference it.used {spaceabove}% measure of space to leave above the age. To put the Q. use the \newtheoremstyle command[1] : defines the mydef environment. use the \qedhere command: 4.4 Theorem styles Lemmas and Corollaries) to share a counter. To hide the Q. Use align* instead. symbol will appear on a subsequent empty line. define subsequent theorems as: It adds the possibility to change the output of the environ- \newtheorem{name}[counter]{Printed output} ments defined by \newtheorem using the \theoremstyle command[1] in the header: where counter is the name of the counter to be used. anyway.3. In this case. for exam- ple “Theorem 2. in the will define the mydef environment. In this case. symbol altogether.D. " " = proof of a theorem. Here is a list of the possible pre-defined styles: You can also create a theorem environment that is not numbered by using the newtheorem* command[1] . By default. For example: also known as a tombstone) at the end of it.\theoremstyle{stylename} ally this will be the name of the master theorem.D. All subse- tional argument.D. each theorem uses its own counter.g. which will generate def. This requires amsthm pack. specify the theorem The method above does not work with the deprecated en- as follows: vironment eqnarray*. 4.E.: 3pt {bodyfont}% name of font to use in the body of the theorem {indent}% 4. include the name in square brackets: It will look like this: \begin{proof}[Proof of important theorem] Here is my important proof \end{proof} Definition 3 Here is a new definition If the last line of the proof is displayed math then the with line breaks separating it from the rest of the text. the second argument is the output given as argument and a white square (Q. Theorems. However it is common for similar types of theorems (e.\newtheoremstyle{stylename}% name of the style to be initions without numbering.E. If you are \newtheorem{mydef}{Definition} writing in another language than English. theorem.E.92 CHAPTER 4.

By default.4. which in this case is Topology.<atom>}.4. 0 to 360.<ni>. and predefined. can be produced with \newenvironment{thm}{\claim}{\endclaim} the following code: Linear molecules (such as methane) are a weak example In this case theorem looks like: of this.. There are three types of angles: absolute.<coeff>.<tikz Definition 2: Topology code>]<atom2>} for the following: \begin{definition}[Topology].4 Chemical Graphics Lewis structures use the syntax chemfig is a package used to draw 2D chemical struc.will be multiplied.) or colon (:) adding the following to the preamble: after a number will display single and paired electrons \usepackage{chemfig} respectively. Here is an example headspec: \thmname{#1}\thmnumber{ #2}:\thmnote{ #3} The primary command used in this package is \chem- fig{}: which would look something like: \chemfig{<atom1><bond type>[<angle>. <angle> is the bond angle between two atoms (or nodes).3.. relative. for example the following way: <bond type> describes the bond attaching <atom1> and <atom2>. where <ni> is a tures. though they can also be negative). Lewis structures can also be included within \chemfig{}. is ally. where “n” 4. \lewis{<n1><n2>. #1. Fi- nally. It is an alternative to ochem.3. \begin{thm}{Claim}\label{lyt-prob} Let it be. Then you know. These are produced 4.4. chemfig uses the the electrons. and are always optional. the electrons are represented tikz package to produce its graphics.3. angles require the syntax [::<relative angle>] and produce an angle relative to the angle of the preceding bond.\arabic{section}..4.sented in the diagram below.5 Conflicts with the syntax [< predefined angle>]. A work around is to re- define theorem. but molecules are formed in chemfig by nesting. . for instance..4 Lewis Structures 4. Relative specify it as above in the head spec).\arabic{thm}} <tikz code> includes additional options regarding the \def\claim#1{\par\medskip\noindent\refstepcounter{thm}\hbox{\bf color or style of the bond. CHEMICAL GRAPHICS 93 (Any arguments that are left blank will assume their de.4. Appending a period (.} \it\ %\ignorespaces } \def\endclaim{ \par\medskip} A methane molecule.7 External links indicates the number of sides in the ring and “code” repre- sents the specific content of each ring (bonds and atoms). for example wrapfigure. The predefined angles and their corresponding absolute angles are repre- The theorem environment conflicts with other environ. but will not appear by default unless you represented with the syntax [:<absolute angle>]. \arabic{chapter}.1 Basic Usage fault value). Whereas ochem re. chemfig is used by by a dash (-). ments.2 Skeletal Diagrams Skeleton diagrams can be produced as follows: 4.6 Notes [1] Requires the amsthm package 4. • amsthm documentation 4. There are 9 different bond types: % Fix latex \def\smallskip{\vskip\smallskipamount} \def\medskip{\vskip\medskipamount} \chemfig{C(-[:0]H)(-[:90]H)(-[:180]H)(-[:270]H)} \def\bigskip{\vskip\bigskipamount} % Hand <coeff> represents the factor by which the bond’s length made theorem \newcounter{thm}[section] \re. \end{thm} 4. newcommand{\thethm}{\thesection.3 Rings Rings follow the syntax <atom>*<n>(code).\arabic{thm}. Absolute angles give a precise angle (gener- (The note argument. number between 0 and 7 representing the position of quires Perl to draw chemical structures.4.4. predefined angles are whole numbers from 0 to 7 indicating intervals of 45 degrees.

graphic for the first molecule in the reaction (carboxylic N(-[:60]O)=[:300]O}\right\}$ acid) extends deeper than the rest of the molecules. allowing the name to span multiple lines.8 Naming Chemical Graphics For example.5 Ions 4. A different result is produced by putting the alcohol first: \schemestart \chemname{\chemfig{R’OH}}{Alcohol} \+ \chemname{\chemfig{R-C(- 4.4. respectively. \chemname{} inserts 1. TECHNICAL TEXTS 4. consult the Part IV “Re.4. In \chemrel{}.7 Chemical Reactions [:−30]OH)=[:30]O}}{Carboxylic acid} \arrow{->} \chemname{\chemfig{R-C(- Commands \chemrel and \chemsign were removed from [:−30]OR’)=[:30]O}}{Ester} \+ \chem- chemfig package in latest versions.molecule and their respective names. . where a more thorough and complete introduction to the package can be found. one must instead use respectively \arrow and \+ commands in a block surrounded with \schemestart and \schemestop.4.4. This is because the [:300]O}\right\} \Longleftrightarrow \left\{\chemfig{O. \chemname[<dim>]{\chemfig{<code of the ion charges can be added as superscripts (one caveat: a molecule>}}{<name>} negative ion requires that the minus sign be enclosed in brackets.6 Resonance Structures and Formal [:−30]OH)=[:30]O}}{Carboxylic acid} \+ \chemname{\chemfig{R’OH}}{Alcohol} Charges \arrow{->} \chemname{\chemfig{R-C(- Resonance structures require a few math commands: [:−30]OR’)=[:30]O}}{Ester} \+ \chem- name{\chemfig{H_2O}}{Water} \schemestop % see “Advanced Mathematics” for use of \left and \right % add to preamble: % \usep- ackage{mathtools} % \Longleftrightarrow In the reaction above. \schemestart \chemname{\chemfig{R-C(- 4. <dim> is inserted between the bottom of the molecule The charge of an ion can be circled by using \oplus and and the top of the name defined by <name>. Alternatively. There are four types of arrows that can be produced with 4. charges can be placed above ions using <name> will be centered relative to the molecule it de- \chemabove{}{}: scribes. It is 1. refer to the A\chemrel{<->}B\par A\chemrel{<>}B chemfig manual. so in order to draw name{\chemfig{H_2O}}{Water} \schemestop chemical reactions.94 CHAPTER 4. adding \\ in <name> will produce a line-break.C(-[:−30]OH)=[:30]O}} \chem- action schemes” of the chemfig documentation file.5ex plus the $\left\{\chemfig{O-N(=[:60]O)-[:300]O}\right\} depth of the carboxylic acid molecule in between each \Longleftrightarrow \left\{\chemfig{O=N(-[:60]O).5ex \ominus: by default.4. This is fixed by adding \chemnameinit{<deepest molecule>} before the first instance of \chemname{} There are a few types of arrows that can be drawn with in a reaction and by adding \chemnameinit{} after the the \arrow command: reaction: For more details on the \arrow command and chemical \schemestart \chemnameinit{\chemfig{R- reactions in chemfig in general. consider an acetate ion: Molecules can be named with the command Because the chemfig commands enters the math mode. <arg1> and <arg2> represent text placed above and below the arrow. name{\chemfig{R’OH}}{Alcohol} \+ \chemname{\chemfig{R-C(- [:−30]OH)=[:30]O}}{Carboxylic acid} Older versions \arrow{->} \chemname{\chemfig{R-C(- Chemical reactions can be created with the following [:−30]OR’)=[:30]O}}{Ester} \+ \chem- commands: name{\chemfig{H_2O}}{Water} \chemnameinit{} \schemestop \chemrel[<arg1>][<arg2>]{<arrow code>} \chemsign+ % produces a + Lastly. as in the example).9 Advanced Graphics \chemrel{}: A\chemrel{->}B\par A\chemrel{<-}B\par For advanced commands and examples.

As well as typeset basic 2D chemical gin{document} \begin{picture}(1000.500) structures.</ce>. written in a real programming language. the mhchem package is also avail- able in TeX in MediaWiki sites like Wikipedia. For example \ce{3H2O} \\ \ce{1/2H2O} \\ \ce{AgCl2-} \\ \ce{H2_{(aq)}} \\ renders: For more examples. The phase is not automatically subscripted and needs Corticosterone as rendered by XyMTeX to be enclosed in parenthesis preceded with a _ as in \ce{H2_{(aq)}.1==OH}{cdef}} \usepackage[version=4]{mhchem} \end{picture} \end{document} Chemical species are included using the \ce command. They provide stylistic enhance- Package chemformula ments over a uniform style (i.{{13}}==\lm preamble: \put(684. The 2 in \ce{H2O} is automatically subscripted without requiring additional commands.4. algorithm2e. A few things here are automatically typeset. add the following to your \put(0. you have the choice between two very good packages: mhchem and chemmacros. the syntax is almost the same.e.11 XyMTeX package The following code produces the image for corticosterone Package mhchem below.4. ALGORITHMS 95 4. If the charge is neither 1 or −1. The pseudocode is usually put istry bundel used to typeset chemical formulae and equa. 4. Package chemmacros will be of great interest to people doing chemistry related work.1 Typesetting \usepackage{chemformula} There are four notable packages algorithmic. This is not compatible . The charge in \ce{AgCl2-} is automatically superscripted. a ^ will superscript it.{{10}}==\lmoiety{H$_{3}$C}. consider the list- The package uses a slightly different syntax compared to ings package described in Source Code Listings.0){\steroid[d]{3D==O. Chemical species are included using the \ch command.5 Algorithms tag <ce>.. all in typewriter font) so that constructs such as loops or conditionals are visually chemformula is a package from a much bigger chem. To use this package.5. For typesetting real code. see meta:Help:Displaying a for- mula#Chemistry 2. For example Typesetting using the algorithmic package \ch{3 H2O} \\ \ch{1/2 H2O} \\ \ch{AgCl2-} \\ \ch{H2_{(aq)}} \\ The algorithmic package uses a different set of commands than the algorithmicx package.606){\sixunitv{}{2D==O. separated from other text. LaTeX has several packages for typesetting algorithms in form of "pseudocode".4. The amount of the species pre- cedes the formula.. in an algorithm environment..5.10 Chemical Formulae renders: As you can see. To use this package. tions. Since February 2016. If you need to typeset chemical formulae. \documentclass{letter} \usepack- mhchem is a package used to typeset chemical formu- age{epic. add the following to your preamble: 4. algorithmicx.carom} \pagestyle{empty} \be- lae and equations. and program. As well as typeset basic 2D chemical structures. as in \ce{AgCl2- }. mhchem. using the 4. 1/2 and other fractional amounts are automatically typeset as in \ce{1/2H2O}.

layout controls. ment (\usepackage{algorithm}) to wrap your al- Like algorithmic. title.96 CHAPTER 4. Put \usep- Typesetting using the algorithm2e package ackage{algpseudocode} in the preamble to use the algorithmic environment to write algorithm pseu- The algorithm2e package (first released 1995. \usepackage[]{algorithm2e} however.g.. \eIf{understand}{ go to next section\. affect the final layout in the document.. \TO. This will not.\end{algorithmic}). Basic commands are: \STATE <text> \IF{<condition>} \STATE {<text>} and a simple example. }{ go back to the beginning of \FORALL{<condition>} \STATE{<text>} \ENDFOR current section\. \While{not at end of this document}{ read \STATE {<text>} \ENDFOR \FOR{<condition> current\. } } \caption{How to write algorithms} \WHILE{<condition>} \STATE{<text>} \ENDWHILE \end{algorithm} \REPEAT \STATE{<text>} \UNTIL{<condition>} \LOOP \STATE{<text>} \ENDLOOP \REQUIRE <text> \ENSURE <text> \RETURN <text> \PRINT which produces <text> \COMMENT{<text>} \AND.0 manual) al. Writing the main steps of the algorithm.01 manual. Most commands are similar to the algorithmicx equivalents. TECHNICAL TEXTS with revtex4-1. Declaring a set of keywords(to typeset as func. is \ELSE \STATE{<text>} \ENDIF \IF{<condition>} \begin{algorithm}[H] \KwData{this text} \KwRe- \STATE {<text>} \ELSIF{<condition>} sult{how to write algorithm with \LaTeX2e } initial- \STATE{<text>} \ENDIF \FOR{<condition>} ization\. The CTAN-manual tional argument of a positive integer. the usage between \begin{algorithm} and mic environment and number every fifth line. The algorithmic package is suggested for IEEE journals as it is a part of their default style sheet. describes both the algorithmic environment (for typesetting algorithms) and the algorithm floating wrapper (see below) which is de- signed to wrap around the algorithmic environment. latest up. taken from the v4. algorithm2e provides a relatively environment with numbered algorithms. You might want to use the algorithm environ- lows typesetting algorithms with a lot of customization.. \XOR.using the algorithmicx package (remember to add the tions/operators). dated January 2013 according to the v5. this package is also not compatible with gorithmic code in an algorithm environment (\be- Revtex-4. The package algorithms bundle at the ctan repository. ger.. \TRUE. How to rename require/ensure to input/output: \floatname{algorithm}{Procedure} \renewcom- mand{\algorithmicrequire}{\textbf{Input:}} \re- Typesetting using the algorithmicx package newcommand{\algorithmicensure}{\textbf{Output:}} The algorithmicx package provides a number of popular constructs for algorithm designs. header \usepackage{algpseudocode} statement to your docu- text (which appears before the algorithm’s main steps e. The LaTeX source can be written to a format familiar The package is loaded like to programmers so that it is easy to read.[2] gin{algorithm}. dated 2009-08-24. . which if given will provides a comprehensible list of examples and full set of cause line numbering to occur at multiples of that inte- controls.g. \NOT. \EndIf \EndIf \end{algorithmic} This may be taken in analogy with writing a latex- preamble before we start the actual document. huge number of customization options to the algorithm The command \begin{algorithmic} can be given the op- suiting to the needs of various users.: ment preamble): Input. docode (\begin{algorithmic}. current \TO <condition> } \STATE {<text>} \ENDFOR section becomes this one\.\end{algorithm}) to produce a floating Unlike algorithmic. with each step 0$ \Else \If {$i+k\leq maxval$} \State $i\gets i+k$ ending with a \. but with dif- ferent capitalization. E. \begin{algorithmic}[5] will enter the algorith- Typically.1. \OR. caption.[1] More details are in the manual hosted on the ctan website. \end{algorithm} would be Below is an example of typesetting a basic algorithm 1.Output) \begin{algorithmic} \If {$i\geq maxval$} \State $i\gets 2. \FALSE Complete documentation is listed at .

The com- mands \A. eg \S‘‘. \P. The algorithmicx package allows you to define your own environments. defx[NAME]{}{OTHEREND}% [1]{Until (#1)} Loops: \begin{algorithmic} \Start \Start \START[One]{x} \END \START{0} \OTHEREND{\texttt{True}} \End \For{<condition>} <text> \EndFor \Start \End \End \end{algorithmic} \ForAll{<condition>} <text> \EndFor \While{<condition>} <text> \EndWhile \Repeat <text> \Until{<condition>} More advanced customization and other constructions are \Loop <text> \EndLoop described in the algorithmicx manual: http://mirror.and postcondition: \Require <text> Typesetting using the program package \Ensure <text> The program package provides macros for typesetting al- Functions gorithms. In the text the n-th param- \State $x\gets <value>$ eter is referenced by #n. To define blocks beginning with a starting command and ending with an ending command. The notation \Function{<name>}{<params>} <body> \EndFunction |variable_name| can be used within normal text. The text displayed by them is Basic commands have the following syntax: \textbf{<start>} and \textbf{<end>}. \T and \Z typeset the cor- This command will usually be used in conjunction with a responding bold letter with the next object as a subscript \State command as follows: (eg \S1 typesets {\bf S$_1$} etc). \B. \DO \IF |odd|(n) \THEN \EXIT \FI.pdf Pre. Note that it is \ElsIf and not \ElseIf. Use \Call{<name>}{<params>} \origbar to get a normal | symbol in a program.i). org/macros/latex/contrib/algorithmicx/algorithmicx. \R. \Function{Increment}{$a$} \State $a \gets a+1$ \State \Return $a$ \EndFunction Below is an example of typesetting a basic algorithm us- ing the program package (remember to add the \usepa- ckage{program} statement to your document preamble): Comments: \begin{program} \mbox{A fast exponentiation proce- \Comment{<text>} dure:} \BEGIN \\ % \FOR i:=1 \TO 10 \STEP 1 \DO |expt|(2. so all the inden- tation and spacing is done automatically. can also be used in With \algblockdefx you can give the text to be output by front of other commands) the starting and ending command and the number of pa- rameters for these commands. \S. use \algblock[<block>]{<start>}{<end>} This defines two commands \<start> and \<end> which have no parameters.ctan. \\ |newline|() \OD % \rcomment{This text Note to users who switched from the old algorithmic will be set flush to the right margin} \WHERE \PROC package: comments may be placed everywhere in the |expt|(x. Primes work normally. \Q. \COMMENT{This . \DO \IF n=0 \THEN \EXIT \FI.n) \BODY z:=1.5. maths \Return <text> expressions or programs to indicate a variable name.4. Statement (\State causes a new line. there are no limitations as in the old algorithmic package. Each line is set in math mode.known]{Start #1(#2)}% {Ending} \algblock- quired. \algblockdefx[<block>]{<start>}{<end>} [<startparam- Three forms of if-statements: count>][<default value>]{<start text>} [<endparam- \If{<condition>} <text> \EndIf count>][<default value>]{<end text>} \If{<condition>} <text> \Else <text> \EndIf \If{<condition>} <text> \ElsIf{<condition>} <text> Example: \Else <text> \EndIf \algblock[Name]{Start}{End} \algblock- defx[NAME]{START}{END}% [2][Un- The third form accepts as many \ElsIf{} clauses as re. ALGORITHMS 97 source.

i := i+1. subsubsection or noth- ''}.environment> \end{algorithmic} \end{algorithm} bar x \AND x>0 \AR x:= x/2 \BAR \NOT 2 \origbar x \AR x:= \modbar{x+3} \OD \end{program} Algorithm numbering Loops with multiple exits: \begin{program} \DO \DO \IF \B1 \THEN \EXIT \FI. The legal values for this option are: \begin{program} \VAR \seq{m := 0. \CALL |inhere| \FI . |line| := |item|[i]. z:=z*x \OD. i := i+1 \OD . \end{program} \CALL Z \ENDACTION \ENDACTIONS \END \end{program} And here’s the transformed and corrected version: \begin{program} \seq{|line| := `` ''. \IF \B1 \THEN is to number algorithms sequentially. you can add a list of them TIONEQ % \IF (m=1) \THEN p := |number|[i]. section. Just put . i := 1}.2 The algorithm environment single box in a formula. The algorithm en- \[ \( \ACTIONS A: A \EQ \IF \B{} \THEN \S{}. \IF (i=(n+1)) \THEN \CALL |alldone| \FI . m := 0. i := 1}. |last| := `` part. A \ELSE \CALL Z \FI \QE \ENDACTIONS \) \EQT \( Include it by adding the \WHILE \B{} \DO \S{} \OD \) \] \usepackage{algorithm} to your document’s preamble. so an algorithm can appear as a 4. |line| := |line| \concat `` '' \concat p. n:=n/2. Lines can be numbered by setting \NumberProgramstrue and numbering turned off with \NumberProgramsfalse Package page Package documentation The commands \( and \) are redefined to typeset an al- gorithm in a minipage. \ACTIONS |prog|: |prog| \ACTIONEQ % \seq{|line| ing (default). \IF \B2 \THEN \EXIT(2) \FI \OD. |write|(|line|) \OD \end{program} The package also provides a macro for typesetting a set like this: \set{x \in N | x > 0}. |print|(z) \ENDPROC \END l \ENDACTION |alldone| \ACTIONEQ |write|(|line|). \WHILE i \neq n+1 \AND |item|[i] = |item|[i-1] \DO |line| := |line| \concat ``. \IF |item|[i] \neq |last| \THEN |write|(|line|). It is entered into by Dijkstra conditionals and loops: \begin{algorithm} \caption{<your caption for this \begin{program} \IF x = 1 \AR y:=y+1 \BAR algorithm>} \label{<your label for references later in x = 2 \AR y:=y^2 \utdots \BAR x = n \AR your document>} \begin{algorithmic} <algorithmic y:=\displaystyle\sum_{i=1}^n y_i \FI \DO 2 \orig. |line| := `` ''. the document component within which numbering should Here’s the original program: be recommenced. m := 0. chapter. x:=x*x \OD. This is often not de- \EXIT \FI \OD \end{program} sirable. \CALL vironment provides this and a few other useful features. For example. n:=n-1. When you use figures or tables. subsection. |last| := |item|[i]. TECHNICAL TEXTS is a comment statement}.98 CHAPTER 4. The default numbering system for the algorithm package \S1. The numbering of algorithms can be influenced by providing the name of A Reverse Engineering Example. m := 1. \CALL |inhere| \ENDACTION l \usepackage[chapter]{algorithm} \ACTIONEQ % i := i+1. '' \concat p \FI . |line| := close to the table of contents. particularly in large documents where numbering according to chapter is more appropriate. \WHILE i \neq n+1 \DO |line| := |item|[i] \concat `` '' \concat |number|[i]. \CALL \}. '' \concat |num- ber|[i]). p := 0. \CALL |more| \ENDACTION |inhere| \ACTIONEQ % List of algorithms p := |number|[i]. \CALL |more| \ENDACTION |more| \AC. \{ n>0 |line| \concat ``. to state that a par- ticular action system is equivalent to a WHILE loop you It is often useful for the algorithm produced by algorith- can write: mic to be “floated” to the optimal point in the document to avoid it being split across pages.5. For example: := `` ''. the algorithm package pro- vides a similar command.

Mizar.3 References [1] [2] http://tex. http://mirrors. to include the source code of any programming language Cobol4 . C#5 . Basic2. make4 . common languages and it is highly customizable.4 . R. RSL. Reduce.1$ \ENDIF \ENDWHILE \end{algorithmic} \documentclass{article} \usepackage{listings} % \end{algorithm} Include the listings-package \begin{document} \lst- set{language=Pascal} % Set your language (you can change the language for each code-block optionally) The official manual is located at http://mirrors. but it doesn't ual. \begin{lstlisting}[frame=single] % Start your code- org/macros/latex/contrib/algorithms/algorithms. is to corresponding page and the caption.5. JVMIS. or algorithms.6. Clean. Rogério Brito (2009). Caml4 . You may also \STATE $N \Leftarrow n$ \ENDIF \WHILE{$N \neq omit the firstline or lastline parameter: it means every- 0$} \IF{$N$ is even} \STATE $X \Leftarrow X \times thing up to or starting from this point. SOURCE CODE LISTINGS 99 \listofalgorithms just want to write code within your document the package provides the lstlisting environment: anywhere in the document. NAS- To use the package. Haskell. Promela. Scilab. you just have to recompile the LaTeX code and your document will be updated. Eiffel. erlang. Ruby. Rexx. Prolog. p. It will be considered plain text and it \begin{algorithm} % enter the algorithm environment will be highlighted according to your settings. C++4 . POV. Assembler2.ctan.'). Ada4 .6 Source Code Listings Supported languages 4.com/questions/70181/ revtex4-1-and-algorithm2e-indentation-clash • The official manual for the algorithms pack- age.14) matter: you can include any file but you have to write the full file name. Eu- within your document. IDL4 . Miranda. Lua2 . PL/I. caption \label{alg1} % and a label for \ref{} commands You can specify the language while including the file with later in the document \begin{algorithmic} % enter the the following command: algorithmic environment \REQUIRE $n \geq 0 \vee x \neq 0$ \ENSURE $y = x^n$ \STATE $y \Leftarrow You can also specify a scope for the file. GCL. Mercury. Logo.4.1 Using the listings package It supports the following programming languages: Using the package listings you can add non-formatted text ABAP2. that means \caption{Calculate $y = x^n$} % give the algorithm a it doesn't recognize the programming language by itself. Write('Pascal keywords. OCL4 . Fortran4 . Comal. SAS. C4 . The command An example from the manual is: This is an example taken from the manual (official man. Lisp4 . HTML. ksh. that is very useful if you created a the “algorithm” environments in the document with the program on several files and you are still editing it. ACSL.4 . Modelica3 . Plasm. Ant. Elan.4 . import the code from the source itself.in the example there is a Python source. PHP. . MuPAD.This is a basic example for some Pascal code: arrow N . if you modify the source. ML. The listings package supports highlighting of all the most Pascal4 . you may find Algorithms and Pseudocode inform. Oberon-2. Gnuplot. If you Python. pdf Write('Case insensitive '). Mathematica1.stackexchange. Java4 . MetaPost. Objective C5 . This way.4 .6. X$ \STATE $N \Leftarrow N / 2$ \ELSE[$N$ is odd] \STATE $y \Leftarrow y \times X$ \STATE $N \Left. and LaTeX will print a list of Another possibility. Modula-2. If you wish to include pseudocode phoria. S4 . Delphi. you need: TRAN. block for i:=maxint to 0 do begin { do nothing } end. bash. Oz. as you would do with \begin{verbatim} but its main aim is Awk4 . \end{lstlisting} \end{document} 4. Matlab. useful also. Octave.pdf 4. csh.org/ macros/latex/contrib/algorithms/algorithms. 1$ \IF{$n < 0$} \STATE $X \Leftarrow 1 / x$ \STATE This comes in handy if you are sure that the file will not $N \Leftarrow -n$ \ELSE \STATE $X \Leftarrow x$ change (at least before the specified lines). Perl. Algol4 .ctan.

i.NB files showstringspaces=false. frame=L. escapeinside 4.}.0.0. SQL. % if you want to add more For some of them. See p. right) num- with the package. For these languages.0} \define- color{mygray}{rgb}{0.6. % choose the back. into LaTeX code. check the official docu- mentation. Objective and The escapeinside line needs an explanation.0. TeX4 . identi- delete keywords from the given language escapein. \usepackage{listings} \usepackage{color} \de- finecolor{mygreen}{rgb}{0.0. % the style that is used for the line-numbers rulecolor=\color{black}. each line will be numbered stringstyle=\color{mymauve}. In the example above. it overrides 'showstringspaces’ in plain text format. also try caption instead of title } 3. % lets you use non. comments (green here)) showspaces=false. % sets default tabsize to 2 spaces tory for these languages (e. % if you want to mentstyle=\itshape\color{purple!40!black}. \usepackage{xcolor}. step between two line-numbers.fierstyle=\color{blue}. possible values are (none.}. C. the comments for Octave start with %.e. and they are going to be printed in the doc- Settings ument unless they start with %*. \lstinputlisting. % sets automatic line xleftmargin=\parindent. code morekeywords={*... basicstyle=\footnotesize\ttfamily. You can't include *. If it’s 1. whitespace breaklines=true.g. % keeps spaces in mentstyle=\itshape\color{purple!40!black}. side={\%*}{*)}. in which case they are read as LaTeX (with all LaTeX commands fulfilled) un- You can modify several parameters that will affect how til they're closed with another *). Defined as a dialect of another language and “B” will be parsed as LaTeX over the current listings style. The meaning is explained next to any line. language=[x86masm]Assembler. You can put the following code any.100 CHAPTER 4. lan- title=\lstname % show the filename of files included with guage={[x86masm]Assembler}).g. for 8-bits encodings only.5. % string 2..0. not work with UTF-8 frame=single. you must add \usepackage{color} or a set of settings. \lstdefinestyle{customc}{ belowcaption- % sets if automatic breaks should only happen at skip=1\baselineskip. Simula4 . Handel.5} \define. The option Sharp.58. has ANSI. % the size of the fonts Example that are used for the code breakatwhitespace=false. com- around the code keepspaces=true. SHELXL.paragraph.tionskip=1\baselineskip. xleftmar- ASCII characters.. There are many more options. does gin=\parindent.dvi. % com.strings only showtabs=false. % show spaces everywhere adding 1. % the language of the ilog. but Mathematica can export in adding particular underscores stepnumber=2. % adds a frame basicstyle=\footnotesize\ttfamily.. Ver. it should be within your distribution bersep=5pt. code numberstyle=\tiny\color{mygray}. show- breaking captionpos=b.} as you could with any other pro. should come as last argument basicstyle=\footnotesize. 12 of the listings manual for an escapeinside={A}{B} will define delimiters for escaping overview. } \lst- text. % . several dialects are supported. % sets the caption-position stringspaces=false. It supports Mathematica code only if you are typing particular underscores. % how far the line-numbers are from the under the name listings-*. useful for keeping indentation of code (possibly set{escapechar=@. language=C.keyword style language=Octave.Style definition color{mymauve}{rgb}{0. % show tabs within strings gramming language. left. % where to put the more information. change it according to your needs. VRML4 . tcl4 .82} \lstset{ % backgroundcolor=\color{white}. i.style=customc} needs columns=flexible) keywordstyle=\color{blue}. % if you want to add LaTeX within } \lstdefinestyle{customasm}{ belowcap- your code extendedchars=true. Specification of the dialect is manda- literal style tabsize=2. VHDL4 . com- ment style deletekeywords={. to bottom commentstyle=\color{mygreen}.keywordstyle=\bfseries\color{green!40!black}. stringstyle=\color{orange}. multiple dialects are supported. refer to the documentation that comes line-numbers. XML. % if not set. all the code between the string “A” 5.5. for example. VBScript.. For keywords to the set numbers=left. If you add the above the code is shown. XSLT. breaklines=true. Modelica is supported via the dtsyntax package available here.. TECHNICAL TEXTS sh. profiles specifying ground color. frame=L.The package lets you define styles. the frame-color may be changed on line-breaks Notes within not-black text (e.e. the following can be used to alter the settings where in the document (it doesn't matter whether before within the code: or after \begin{document}). % the a pretty-formatted LaTeX source. % underline spaces within \lstinputlisting{.

. Usage: {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1 {à}{{\`a}}1 \begin{lstlisting} #include <stdio. All listings will have their name as caption: we do not have 4. This is where macros show their real power. Another possibility is to replace \usepackage{listings} (in the preamble) with \usepackage{listingsutf8}. Customizing captions You can have fancy captions (or titles) for your listings Automating file inclusion using the caption package.s} % .01 }{ \parbox{\textwidth}{\hspace{15pt}#1#2#3} } \newcommand{\includecode}[2][c]{\lstinputlisting[caption=#2. } return {ö}{{\"o}}1 {ü}{{\"u}}1 {Ä}{{\"A}}1 {Ë}{{\"E}}1 0. which as of Nov 2014 boasts over 300 supported languages and text formats.35. for (i = 0.3 References To handle UTF-8. If you have a bunch of source files you want to include. For a more detailed explanation of the usage of the literate option check section 6. } \end{lstlisting} \lstinputlisting[caption=Scheduler. 4. we create one command to ease source code inclusion. Here is an example for listings. \lstinputlist- \lstlistoflistings ing[caption=My caption]{sourcefile. cludecode{sched. \usepackage{caption} \usepackage{listings} \Declare- you may find yourself doing the same thing over and over CaptionFont{white}{ \color{white} } \DeclareCaption- again. font={bf.6. Finally we list all listings with this command from the listings minted is an alternative to listings which has become pop- package... It uses the external Python library Pygments for See Macros for more details.h> #define N 10 /* {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1 Block * comment */ int main() { int i. so please have a look at their GitHub repo and their manual.. code highlighting. i++) { {Ù}{{\`U}}1 {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 puts(“LaTeX is also great for programmers!")..6. By default.}.4. ular.lang} In this example. you should tell listings how to interpret the special characters by defining them like so A lot more detailed information can be found in a PDF \lstset{literate= {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 by Carsten Heinz and Brooks Moses. // Line com.. 0. {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1 {â}{{\^a}}1 style=customc]{hello. } \captionsetup[lstlisting]{ format=listing. margin=0pt. label- escapechar=.{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 ment. style=custom#1]{#2}<!---->} % . singlelinecheck=false.c} \includecode[asm]{sched.43. \in- font=white. SOURCE CODE LISTINGS 101 In our example.. Format{listing}{ \colorbox[cmyk]{0.4 in the Listings Doc- umentation.6. listings does not support multi-byte encoding for source code.footnotesize} } % . We set the default style to be customc. 0. but this will only work for \lstinputlisting{..2 The minted package to write the file name twice thanks to the macro. As the package relies on external Python code. the setup Encoding issue require a few more steps than a usual LaTeX package. textfont=white. i < N.c} {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1 {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1 {œ}{{\oe}}1 {Œ}{{\OE}}1 The C part will print as {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1 {ű}{{\H{u}}}1 {Ű}{{\H{U}}}1 {ő}{{\H{o}}}1 {Ő}{{\H{O}}}1 {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1 {€}{{\euro}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1 {»}{{\guille- motright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1 } The above table will cover most characters in latin lan- guages.0. The extendedchar option only works for 8-bits encodings such as latin1.. puts(“Hello world!").35.{ó}{{\'o}}1 {ú}{{\'u}}1 {Á}{{\'A}}1 {É}{{\'E}}1 fault style and the escape character. we only set two options globally: the de.

Some packages such as the tipa package are Examples for this package are placed within the exe en- effectively standard within the field. • The xy package itself has a steep learning curve. and each will have its own number. the corresponding sentence must be sur- rounded by braces. • Attribute-Value Matrices (AVMs): avm For notating acceptability judgments. \begin{exe} \ex This is the first example. \ex This is a second sub-example. produces: • IPA symbols: tipa. and many other ap. syntactic trees. but allows a lot of control. the xlist enviroment is • tikz-qtree has the same syntax as qtree.1 Enumerated examples \begin{exe} \ex This sentence is grammatical English. \end{exe} • Glosses: gb4e or Covington.7. you may get exceeded parameter stack size error. while others will vary vironment. command.7 Linguistics \usepackage{gb4e} There are a number of LaTeX packages available for writing linguistics papers. let it be the last created for enumerated examples. \end{exe} • Alternatively. • Syntactic trees: qtree + tree-dvips (for drawing ar.102 CHAPTER 4. produces: . The gb4e package[2] is called with: 4. \end{xlist} \end{xlist} \end{exe} • The TikZ-dependency package provides produces: a high-level. TECHNICAL TEXTS Details and documentation about the Listings package gb4e can be found at its CTAN website. the \ex command can take an optional argument. plications. but uses PGF/TikZ. for sim- plest trees use the xymatrix feature and arrows. When including a judg- • John Frampton’s expex: expex ment marker. Multiple examples can be included within the environ- • OT Tableaux: OTtablx. and each example is introduced with the \ex by author preference. \ex This is the rows). It is based on PGF/TikZ but does not require prior knowledge of TikZ in order to be used productively. etc. Some recommended packages:[1] \begin{exe} \ex This is an example. convenient interface to draw dependency graphs. which allows more options for drawing arrows. \ex This is a second • Dependency trees and bubble parses: sub-sub-example. To create nested lists of examples. OT \usepackage call in the document’s preamble.} There are several commonly used packages for creating \end{exe} the kinds of numbered examples that are used in linguis- tics publications. Various packages have been IMPORTANT: If you use gb4e package. IPA fonts. Otherwise tableaux. \begin{exe} \ex \begin{xlist} \ex This is a sub-example. used. second example. feature matrices. \ex \begin{xlist} \ex This is a sub-sub-example. ment. \ex[*] {This sentence English in ungrammatical is. 4. \ex This is the third. xyling is very powerful but produces: not as user friendly as qtree.

the following code while the latter command is used for nested examples. sentence. Unfortunately. but (\ref{ex2}) Constituent trees contains only one. leaf nodes are simply ex- uses two main commands. linguists will have to illustrate the syntactic struc- ture of a sentence. \begin{exe} \ex\label{ex1} Godzilla destroyed the city.7. qtree Drawing trees with qtree is relatively straightfor- ward. the qtree package has to be included in the document’s preamble: \usepackage{qtree} lingmacros A new tree is started using the \Tree command. See the labeling and cross- in different grammar formalisms. LINGUISTICS 103 4. qtree centers syntactic trees on the page. By default. \ex\label{ex2} Godzilla roared.} \enumsentence{This is the third. First. \item This is a second sub-sub-example. This package )tree is always preceded by a .} produces this syntactic tree as output: \enumsentence{This is the first example.7.4.V is ] [.2 Syntactic trees Often. \eenumsentence{\item This is a sub-example.NP fun ] ] ] \enumsentence{This is an example.. This behaviour can be turned off by either specifying the be- haviour when loading the package \usepackage[nocenter]{qtree} % do not center trees Full documentation can be found here. The former is used for singleton examples. .} Multiply nested examples make use of the normal LaTeX list environments. While there are several packages for drawing syntactic trees available for LaTeX. The root of a (sub- [3] alternate method for example numbering. this article focuses on the qtree Further details can be found in the full documentation and xyling packages. and different LaTeX referencing section for more details.NP LaTeX ] [.S [. available here. \Tree [. \end{enumerate} } produces: Note that the spaces before the closing brackets are mandatory. \item \begin{enumerate} \item This is sub-sub-example. For example.VP [. packages are suited for different formalisms. \end{exe} Sentence (\ref{ex1}) contains two arguments.} \enumsen- tence{This is the second example. One device for doing this is through Referencing examples in text works as it does in nor- syntactic trees. \item This is a second sub-example. each The lingmacros package created by Emma Pease is an (sub-)tree is indicated by brackets [ ].pressed by their labels. \enumsentence and \eenum. trees look very different mal LaTeX documents.

V is ] [. \end{tikzpicture} which gives you the following drawing: TikZ has the advantage that it allows for generating PDF default. let it be the last The above code changes the default orientation for all \usepackage call in the document’s preamble. some of qtree’s advanced features are implemented in a different way. \begin{tikzpicture} % all changes only affect trees To use the tikz-qtree package for drawing trees. \Tree [. namely xyling.NP fun ] ] ] IMPORTANT: If you use gb4e package. use the following code: anywhere in the document.change the direction of a single tree. without need for any de- ronment: tour of compiling to DVI using latex.5cm] child { node {an} } child { node {example} } child { node {. tikz-qtree provides the \qtreecenterfalse % do not center trees from here on \tikzset command.NP LaTeX ] [.S [. Alter- natively. Latter is the case of another package based on the package xy.V is ] [.NP fun ] ] ] Note that. tikz-qtree is another easy-to-use alternative for drawing syntactic trees.NP LaTeX ] [. On the trees that are defined after \tikzset commands. trees are not centered by Dependency Trees Dependency trees can take multiple visual forms. it has to be put into trolling the direction of the tree’s growth (top to bottom.S [. like so: % In the preamble: \usepackage{tikz} % In the docu- ment: \begin{tikzpicture} \node (is-root) {is} [sibling distance=3cm] child { node {this} } child { node {tree} [sibling distance=1.V is ] [.5\tikzleveldistance) node {\textit{This is an example tree. Com- monly. For simple trees.VP [.NP LaTeX ] [. \path (is-root) +(0. Otherwise you may get exceeded parameter stack size error. To only other hand.NP fun ] ] ] \end{center} ps2pdf.style={anchor=base west}} % allign nodes of the tree to the left (west) \Tree [. For example. they quite resemble phrase structure trees.NP LaTeX ] [. To center them.} } child[missing] }. Two-dimensional Dependency Trees These can be either achieved using the fairly universal drawing package TikZ. put the within this environment \tikzset{grow'=right} % following into the document’s preamble: make trees grow from left to right \tikzset{every tree \usepackage{tikz} \usepackage{tikz-qtree} node/.−2.VP [.) or different styles for edges. tikz-qtree Using the same syntax as qtree.S [.V is ] ing to PDF probably via PS using tools such as dvips and [. other than for qtree. they can be captured by brackets drawn above running text.NP fun ] ] ] \end{tikzpicture} The syntax of tikz-qtree and result when drawing a simple tree is the same as for qtree. tikz-qtree is completely interchangable with qtree.}}.104 CHAPTER 4.style={anchor=base \qtreecentertrue % center trees from here on west}} % allign nodes of the tree to the left (west) \Tree [. to make a tree grow from left to right instead of from top to bottom.VP [. However. The effect of the latter can be \tikzset{grow'=right} % make trees grow from left undone by using the command to right \tikzset{every tree node/. a \tikzpicture environment: left to right etc. put them into a centered envi. . TECHNICAL TEXTS or via the command For setting the style of trees. or not at all.S [.VP [. and then convert- \begin{center} \Tree [. tikz-qtree provides other features such as con.directly from the LaTeX source.

U){−2}"_{\small det}" &~~~& \xybarnode{.7. LINGUISTICS 105 &~~~& \xybarnode{Mary} &~~~& \xybarn- ode{bought} \xybarconnect[8](UL.U){−2}"_{\small Below is how to make glossed examples with different conj}" \xybarconnect(UR.U){4}"^{\small obj}" &~~~& \xybarnode{a} &~~~& \xybarnode{car} \xybarconnect(UL. It gives you fairly good control of how the brackets are typeset but requires compiling A dependency tree drawn with TikZ-dependency.7.} sentence within the deptext environment and use depedge commands to draw the edges. write the text of the example tree. \\ \end{deptext} \deproot{3}{ROOT} \depedge{2}{1}{ATT} \depedge[edge start x offset=−6pt]{2}{5}{ATT} \depedge{3}{2}{SBJ} \depedge{3}{9}{PU} \depedge{3}{4}{VC} \depedge{4}{8}{TMP} \depedge{5}{7}{PC} \depedge[arc an- gle=50]{7}{6}{ATT} \end{dependency} This code snippet would produce the following result: A dependency tree created using xyling Dependency Trees as Brackets above Text One way to typeset dependency brackets above running text is us- ing the package xytree.4. Global and local optional which gives you a drawing like this: parameters can be used to style and fine tune the looks of the graph. as shown in the following example: % In the preamble: \usepackage{tikz-dependency} % In the document: \begin{dependency}[theme = simple] \begin{deptext}[column sep=1em] A \& hearing \& is \& scheduled \& on \& the \& issue \& today \& . you only need to \K{example} && \K{.U){−4}"_{\small subj}" \xybarconnect[13]{6}"^{\small punct}" \xybarconnect[8](UR. the LaTeX code to DVI (and perhaps converting to PDF using the tools dvips and ps2pdf later).U){2}"^{\small conj}" packages.} } \medskip \textit{This is an create a dependency environment. .3 Glosses document: \xytext{ \xybarnode{Peter} &~~~& \xy- barnode{and} \xybarconnect(UL.} } results in: A dependency tree created using TikZ A dependency tree above running text created using xytree The code for a similar tree using xyling might look like: % In the preamble: \usepackage{xyling} % In the Dependency Trees using TikZ-dependency The document: \Tree{ & \K{is}\B{dl}\B{drr} \\ \K{this} package provides high level commands to design and style &&& \K{tree}\B{dll}\B{dl}\B{dr} \\ & \K{an} & dependency graphs. An example code: % In the preamble: \usepackage{xytree} % In the 4. To draw a graph.

using a character map or an IPA keyboard.106 CHAPTER 4.NOM however capital letters are rendered differently. command is similar to other font typesetting commands. eat.SG. Vertically aligned glosses are separated by spaces. But after the \ex tag. it’s necessary to include a space in part the gloss.7. \begin{exe} \ex \gll Pekka pel\"astyi karhusta.7. some of which are listed here. The \. Numerals and @ also have variants in the IPA environ- The code will produce the following output: ment. 4.} {Pekka & became afraid & bear.7. The fourth ar- gument is the translation. so if The \: macro produces retroflex symbols.4 IPA characters [6] The package on CTAN. rendered as usual. TECHNICAL TEXTS With gb4e Basic symbols To create a glossed example.[5] With lingmacros 4. see SIL . Alternatively. This command takes four of the phonrule package.\\ Pekka {became afraid} bear. In addition. The second and third arguments give the text and package: its gloss respectively.[6] arguments and builds off the normal tabular environment. use the normal exe environ. macro preceding a capital letter produces a small caps version of the letter. Lower case letters are gloss using \gll and the translation after it with \trans tag.3. The tipa package is the standard LaTeX package for In- ternational Phonetic Alphabet symbols.7. .PRS sour-cream. 4.'} } [3] The lingmacros package on CTAN [4] TIPA manual [5] For more information on IPA keyboards. This • The gb4e package page on CTAN. simply enclose the connected parts inside braces. The first way is to use the IPA environment. introduce the example and its into corresponding IPA symbols. there are a number of special macros for representing symbols that don't have other associations. • LaTeX for Linguists This method is useful for long stretches of text that need • The qtree package for drawing syntactic trees. to be in IPA. \begin{exe} \ex \gll Кот ест сметану\\ cat. For a complete list see the official TIPA Manual[4] . Its first argument specifies the number of columns in the Following is an example of what you can achieve with the gloss.ELA\\ \trans `Pekka became afraid because of the/a bear. 4.' \end{exe} XeLaTeX Another way of inputting IPA symbols in a document is to use XeTeX as the compiler and insert the symbols di- rectly. and items within each column are divided by the usual & tabular separator.5 Phonological rules The lingmacros package uses the \shortex command to in- troduce glossed examples inside the \enumsentence and Typesetting phonological rules can be done with the help \eenumsentence commands.The IPA format works by translating ASCII characters ment. there is the \textipa command that will format the text in its argument into IPA.ELA} [2] The gb4e package on CTAN {`Pekka became afraid because of the/a bear.7 External links There are two methods for getting IPA symbols into a document. The \! macro produces implosive symbols and the bilabial click.ACC\\ \trans `The cat eats Punctuation marks that are normally used in LaTeX are sour cream' \end{exe} also rendered faithfully in the IPA environment.6 References \enumsentence{\shortex{3} {Pekka & pel\"astyi & [1] LaTeX for Linguists presentation karhu-sta.

Chapter 5

Special Pages

5.1 Indexing Compiling indices

When the input file is processed with LaTeX, each \in-
Especially useful in printed books, an index is an alpha- dex command writes an appropriate index entry, together
betical list of words and expressions with the pages of with the current page number, to a special file. The file
the book upon which they are to be found. LaTeX sup- has the same name as the LaTeX input file, but a different
ports the creation of indices with its package makeidx, extension (.idx). This .idx file can then be processed with
and its support program makeindex, called on some sys- the makeindex program. Type in the command line:
tems makeidx.
makeindex filename
Note that filename is without extension: the program will
look for filename.idx and use that. You can optionally
pass filename.idx directly to the program as an argument.
The makeindex program generates a sorted index with the
5.1.1 Using makeidx same base file name, but this time with the extension .ind.
If now the LaTeX input file is processed again, this sorted
index gets included into the document at the point where
To enable the indexing feature of LaTeX, the makeidx LaTeX finds \printindex.
package must be loaded in the preamble with:
The index created by latex with the default options may
and the special indexing commands must be enabled by not look as nice or as suitable as you would like it. To im-
putting the prove the looks of the index makeindex comes with a set
command into the input file preamble. This should be of style files, usually located somewhere in the tex direc-
done within the preamble, since it tells LaTeX to create tory structure, usually below the makeindex subdirectory.
the files needed for indexing. To tell LaTeX what to in- To tell makeindex to use a specific style file, run it with
dex, use the command line option:

where key is the index entry and does not appear in the makeindex -s [style file] filename
final layout. You enter the index commands at the points If you use a GUI for compiling latex and index files, you
in the text that you want to be referenced in the index, may have to set this in the options. Here are some con-
likely near the reason for the key. For example, the text figuration tips for typical tools:
can be re-written as
to create an entry called 'Fourier Series’ with a reference
to the target page. Multiple uses of \index with the same MakeIndex settings in WinEdt Say you want to add
key on different pages will add those target pages to the an index style file named simpleidx.ist
same index entry.
To show the index within the document, merely use the
command • Texify/PDFTexify: Options→Execution
Modes→Accessories→PDFTeXify, add to the
It is common to place it at the end of the document. The
Switches: --mkidx-option="-s simpleidx.ist”
default index format is two columns.
The showidx package that comes with LaTeX prints out
all index entries in the right margin of the text. This is • MakeIndex alone: Options→Execution
quite useful for proofreading a document and verifying Modes→Accessories→MakeIndex, add to com-
the index. mand line: -s simpleidx.ist

107

108 CHAPTER 5. SPECIAL PAGES

Sophisticated indexing saries package described in the Glossary chapter. An-
other option is the package acronym .
Below are examples of \index entries:
To enable the Nomenclature feature of LaTeX, the
nomencl package must be loaded in the preamble with:
Subentries If some entry has subsections, these can be Issue the \nomencla-
marked off with !. For example, ture[⟨prefix⟩]{⟨symbol⟩}{⟨description⟩} command
would create an index entry with 'cp850' categorized un- for each symbol you want to have included in the
der 'input' (which itself is categorized into 'encodings’). nomenclature list. The best place for this command is
These are called subsubentries and subentries in makeidx immediately after you introduce the symbol for the first
terminology. time. Put \printnomenclature at the place you want to
have your nomenclature list.

Controlling sorting In order to determine how an in- Run LaTeX 2 times then
dex key is sorted, place a value to sort by before the key makeindex filename.nlo -s nomencl.ist -o filename.nls
with the @ as a separator. This is useful if there is any
followed by running LaTeX once again.
formatting or math mode, so one example may be
To add the abbreviation list to the table of content, intoc
so that the entry in the index will show as ' F⃗ ' but be
option can be used when declare the nomencl package,
sorted as 'F'.
i.e.
To combine with the above feature for subentries, you
instead of using the code in Adding Index to Table Of
should style the appropriate component(s):
Contents section.
The title of the list can be changed using the following
Changing page number style To change the format- command:
ting of a page number, append a | and the name of some
command which does the formatting. This command
should only accept one argument. 5.1.3 Multiple indices
For example, if on page 3 of a book you introduce bull-
dogs and include the command If you need multiple indices you can use the package
multind . However, this package does not work.
and on page 10 of the same book you wish to show the
main section on bulldogs with a bold page number, use This package provides the same commands as makeidx,
but now you also have to pass a name as the first argument
This will appear in the index as bulldog, 3, 10 to every command.
If you use texindy in place of makeindex, the classified
entries will be sorted too, such that all the bolded entries
will be placed before all others by default. 5.1.4 Adding index to table of contents
By default, Index won't show in Table Of Contents, so
Multiple pages To perform multi-page indexing, add you have to add it manually.
a |( and |) to the end of the \index command, as in To add index as a chapter, use these commands:
The entry in the index for the subentry 'History' will be If you use the book class, you may want to start it on an
the range of pages between the two \index commands. odd page by using \cleardoublepage.

Using special characters In order to place values with
!, @, or |, which are otherwise escape characters, in the
5.1.5 International indices
index, one must quote these characters in the \index com-
If you want to sort entries that have international charac-
mand by putting a double quotation mark (") in front of
ters (such as ő, ą, ó, ç, etc.) you may find that the sort-
them, and one can only place a " in the index by quoting
ing “is not quite right”. In most cases the characters are
it (i.e., a key for " would be \index{""}).
treated as special characters and end up in the same group
This rule does not hold for \", so to put the letter ä in the as @, ¶ or µ. In most languages that use Latin alphabet
index, one may still use \index{a@\"{a}}. it’s not correct.

5.1.2 Abbreviation list Generating index

You can make a list of abbreviations with the package Unfortunately, current version of xindy and hyperref
nomencl . You may also be interested in using the glos- are incompatible. When you use textbf or textit mod-

5.2. GLOSSARY 109

ifiers, texindy will print error message:unknown cross- iconv -f latin2 -t utf8 latin2.xdy >utf8.xdy
reference-class `hyperindexformat'! (ignored) and won't in folder
add those pages to index. Work-around for this bug is
described on the talk page. /usr/share/xindy/tex/inputenc
To generate international index file you have to use (You must have root privileges)
texindy instead of makeindex.
xindy is a much more extensible and robust indexing sys- xindy in kile To use texindy instead of makeindex in
tem than the makeindex system. kile, you have to either redefine the MakeIndex tool in
For example, one does not need to write: Settings → Configure Kile... → Tools → Build, or define
new tool and redefine other tools to use it (for example by
to get the Lin entry after LAN and before LZA, instead,
adding it to QuickBuild).
it’s enough to write
The xindy definition should look similar to this:
But what is much more important, it can properly sort
index files in many languages, not only English. General: Command: texindy Options: -L polish -M
lang/polish/utf8 -I latex '%S.idx' Advanced: Type: Run
Unfortunately, generating indices ready to use by LaTeX
Outside of Kile Class: Compile Source extension: idx
using xindy is a bit more complicated than with makein-
Target extension: ind Target file: <empty> Relative dir:
dex.
<empty> State: Editor Menu: Add tool to Build menu:
First, we need to know in what encoding the .tex project Compile Icon: the one you like
file is saved. In most cases it will be UTF-8 or ISO-8859-
1, though if you live, for example in Poland it may be ISO-
8859-2 or CP-1250. Check the parameter to the inputenc
package. 5.2 Glossary
Second, we need to know which language is prominently
Many technical documents use terms or acronyms un-
used in our document. xindy can natively sort indices
known to the general population. It is common practice
in Albanian, Belarusian, Bulgarian, Croatian, Czech,
to add a glossary to make such documents more accessi-
Danish, Dutch, English, Esperanto, Estonian, Finnish,
ble.
French, Georgian, German, Greek, Gypsy, Hausa, He-
brew, Hungarian, Icelandic, Italian, Klingon, Kurdish, The glossaries package can be used to create glossaries.
Latin, Latvian, Lithuanian, Macedonian, Mongolian, It supports multiple glossaries, acronyms, and symbols.
Norwegian, Polish, Portuguese, Romanian, Russian, Ser- This package replaces the glossary package and can be
bian Slovak, Slovenian, Sorbian, Spanish, Swedish, Turk- used instead of the nomencl package.[1] Users requir-
ish, Ukrainian and Vietnamese, ing a simpler solution should consider hand-coding their
entries by using the description environment, or the
I don't know if other languages have similar problems,
longtabu environment provided by the tabu package.
but with Polish, if your .tex is saved using UTF-8, the
.ind produced by texindy will be encoded in ISO-8859-2
if you use only -L polish. While it’s not a problem for
entries containing polish letters, as LaTeX internally en- 5.2.1 Jump start
codes all letters to plain ASCII, it is for accented letters at
beginning of words, they create new index entry groups, Place \usepackage{glossaries} and \makeglossaries in
if you have, for example an "średnia” entry, you'll get a your preamble (after \usepackage{hyperref} if present).
"Ś" encoded in ISO-8859-2 .ind file. LaTeX doesn't like Then define any number of \newglossaryentry and
if part of the file is in UTF-8 and part is in ISO-8859- \newacronym glossary and acronym entries in your
2. The obvious solution (adding -C utf8) doesn't work, preamble (recommended) or before first use in your doc-
texindy stops with ument proper. Finally add a \printglossaries call to locate
the glossaries list within your document structure. Then
ERROR: Could not find file “tex/inputenc/utf8.xdy” pepper your writing with \gls{mylabel} macros (and sim-
error. The fix this, you have to load the definiton style for ilar) to simultaneously insert your predefined text and
the headings using -M switch: build the associated glossary. File processing must now
include a call to makeglossaries followed by at least one
-M lang/polish/utf8 further invocation of latex or pdflatex.
In the end we have to run such command:
texindy -L polish -M lang/polish/utf8 filename.idx
5.2.2 Using glossaries
Additional way to fix this problem is use “iconv” to create
utf8.xdy from latin2.xdy To use the glossaries package, you have to load it explic-
itly:

110 CHAPTER 5. SPECIAL PAGES

if you wish to use xindy (recommended) for the indexing This will avoid the wrong long plural: Frame per Seconds.
phase, as opposed to makeindex (the default), you need So far, the glossary entries have been defined as key-value
to specify the xindy option: lists. Sometimes, a description is more complex than just
For the glossary to show up in your Table of Contents, a paragraph. For example, you may want to have multiple
you need to specify the toc option: paragraphs, itemized lists, figures, tables, etc. For such
See also Custom Name at the bottom of this page. glossary entries use the command longnewglossaryentry
in which the description follows the key-value list. The
Finally, place the following command in your document computer entry then looks like this:
preamble in order to generate the glossary:
Any links in resulting glossary will not be “clickable” un-
Defining symbols
less you load the glossaries package after the hyperref
package.
Defined entries can also be symbols:
In addition, users who wish to make use of makeglos-
You can also define both a name and a symbol:
saries will need to have Perl installed — this is not nor-
mally present by default on Microsoft Windows plat- Note that not all glossary styles show defined symbols.
forms. That said, makeglossaries simply provides a con-
venient interface to makeindex and xindy and is not es-
Defining acronyms
sential.
To define a new acronym you use the \newacronym
5.2.3 Defining glossary entries macro:
where <label> is the unique label identifying the
To use an entry from a glossary you first need to define it. acronym, <abbrv> is the abbreviated form of the
There are few ways to define an entry depending on what acronym and <full> is the expanded text. For example:
you define and how it is going to be used.
Defined acronyms can be put in separate list if you use
Note that a defined entry won't be included in the printed acronym package option:
glossary unless it is used in the document. This enables
you to create a glossary of general terms and just \include
it in all your documents. 5.2.5 Using defined terms
When you have defined a term, you can use it in a docu-
5.2.4 Defining terms ment. There are many different commands used to refer
to glossary terms.
To define a term in glossary you use the \newglossaryentry
macro:
<label> is a unique label used to identify an entry in glos- General references
sary, <settings> are comma separated key=value pairs
A general reference is used with \gls command. If, for
used to define an entry.
example, you have glossary entries defined as those above,
For example, to define a computer entry: you might use it in this way:
The above example defines an entry that has the same la- Description of commands used in above example:
bel and entry name. This is not always the case as the
next entry will show: This command prints the term associated with <label>
passed as its argument. If the hyperref package was
When you define terms, you need to remember that they loaded before glossaries it will also be hyperlinked to the
will be sorted by makeindex or xindy. While xindy is entry in glossary.
a bit more LaTeX aware, it does it by omitting latex
macros (\"{\i}) thus incorrectly sorting the above exam- This command prints the plural of the defined term, other
than that it behaves in the same way as gls.
ple as nave. makeindex won't fare much better, because it
doesn't understand TeX macros, it will interpret the word This command prints the singular form of the term with
exactly as it was defined, putting it inside symbol class, the first character converted to upper case.
before words beginning with naa. Therefore it’s needed This command prints the plural form with first letter of
to extend our example and specify how to sort the word: the term converted to upper case.
You can also specify plural forms, if they are not formed This command creates the link as usual, but typesets the
by adding “s” (we will learn how to use them in next sec- alternate text instead. It can also take several options
tion): which changes its default behavior (see the documenta-
Or, for acronyms: tion).

5.3. DISPLAYING THE GLOSSARY 111

This command prints what ever is defined in \newglos- Syntax: \newdualentry[glossary options][acronym op-
saryentry{<label>}{symbol={Output of glssymbol}, ...} tions]{label}{abbrv}{long}{description}
This command prints what ever is defined in \newglos- then, define new (dual) entries for glossary and acronym
saryentry{<label>}{description={Output of glsdesc}, list like this:
...}

Custom Name
Referring acronyms
The name of the glossary section can be replaced with a
Acronyms behave a bit differently than normal glossary custom name or translated to a different language. Add
terms. On first use the \gls command will display "<full> the option title to \printglossary to specify the glossary’s
(<abbrv>)". On subsequent uses only the abbreviation title. Add the option toctitle to specify a the title used in
will be displayed. the table of content (if not used, title is used as default).
[4]
To reset the first use of an acronym, use the command:
or, if you want to reset the use status of all acronyms:
Remove the point
If you just want to print the long version of an acronym
without the abbreviation "<full>", use :
To omit the dot at the end of each description, use this
If you just want to print the long version of an acronym code:
with the abbreviation "<full> (<abbrv>)", use :
If you just want to print the abbreviation "<abbrv>", use
Changing Glossary Entry Presentation Using Glos-
:
sary Styles

A number of pre-built styles are available, and can be
5.3 Displaying the Glossary changed easily using
Commonly used styles include list
To display the sorted list of terms you need to add:
My Term Has some long description 7, 9
at the place you want the glossary and the list of acronyms
altlist (inserts newline after term and indents description)
to appear.
My Term Has some long description 7, 9
If all entries are to be printed the command
altlistgroup or listgroup (group adds grouping based on
can be inserted before \printglossaries. You may also
the first letters of the terms)
want to use \usepackage[nonumberlist]{glossaries} to
suppress the location list within the glossary. M My First Term Has some long description 7, 9 My
Second Term Has some long description 7, 9
altlisthypergroup or listhypergroup (hyper adds an hyper-
Separate Glossary and List of Acronyms
linked 'index' at the top of each glossary to jump to a
group)
\printglossaries will display all the glossaries in the order
in which they were defined.[2] If no custom glossaries are A|B|C|D|F|G|I|M|O|R|S|C|D|G|M|P A A First term Has
defined, the default glossary and the list of acronyms will some long description 7, 9 B Barely missed first Has
be displayed. some long description 7, 9
The glossary and the list of acronyms can be displayed
separately in different places[3] :
5.3.1 Building your document

Dual entries with reference to a glossary entry from Building your document and its glossary requires three
an acronym It may be useful to have both an acronym steps:
and a glossary entry for the same term. To link these two,
define the acronym with a reference to the glossary entry 1. build your LaTeX document — this will also gener-
like this: ate the files needed by makeglossaries
Refer to acronym with \gls{OWD} and the glossary with 2. invoke makeglossaries — a script which selects the
\gls{gls-OWD} correct character encodings and language settings
To make this easier, we can use this command (modified and which will also run xindy or makeindex if these
from example in the official docs): are specified in your document file

In Windows with Texmaker Include glossary definitions in the preamble (Before "\be- gin{document}") In TeX Live and since June 2015 in MikTeX xindy is \loadglsentries[main]{INP-00-glossary} % or using already included.4. Alexa 488} doc is the name of your LaTeX master file.toc]{glossaries} % nomain.. http://tug. Nicola L. glossaries FAQ \usepackage[nomain.ctan. that is. and you use \include{INP-00-glossary} \makeglossaries \usepa. Command = makeglossaries % [3] http://mirror.html#dx1-35001 2.ox.uk/sites/ctan. If you encounter problems.ox.ac. 2.3 Glossary definitions document with glossary entries Write all your glossaries/acronyms in a file: Ex: INP-00- Thus: glossary. view the doc.4 Include glossary definitions and print glossary 5. and emission)}.uk/sites/ctan. in the following order: 1.4. in Texmaker. the option -d contrib/glossaries/glossaries-user. Nicola L. try{kdeac}{name=\glslink{R0}{\ensuremath{k_{DEAC}}}. distance.log and doc.1 Compile glossary with xindy .4 Example for use in windows with Texmaker 5.}..org/macros/latex/ 1.xindy.stackexchange.acronym. tex-archive/macros/latex/contrib/glossaries/ 5.4. go to User -> User Commands -> 5. Choose command 1 [1] http://www. build your LaTeX document again — to produce a 5.02 as of 2014. 2.tex latex doc makeglossaries doc latex doc \newacronym{ddye}{D$_{\text{dye}}$}{donor where latex is your usual build call (perhaps pdflatex) and dye. \newacronym[description={\glslink{r0}{F\"{o}rster distance}}]{R0}{$R_{0}$}{F\"{o}rster If your entries are interlinked (entries themselves link to distance} \newglossaryen- other entries with \gls calls). hyperref should be loaded before the glossaries): • glossaries FAQ. In preamble should be included (note.html#sec:printglossary <dir> of makeglossaries provides for the subdirectory case.4.4. http://mirror. link .org/macros/latex/ contrib/glossaries/glossaries-user. C.com/questions/ \appendix \bibliographystyle{plainnat} \bibli- 251221/miktex-and-xindy-problems/251801#251801 ography{bibtex} \printindex \printglossaries \end{document} You need to restart Texmaker after installation of xindy.112 CHAPTER 5. to update PATH references to xindy and Perl binaries. while Texmaker does not help there.glg where 50\% .text=F\"{o}rster and 2 twice.ctan. near end of MikTeX containing spaces. Nomenclature. you will need to run steps 1 try{r0}{name=\glslink{R0}{\ensuremath{R_{0}}}. sort=R} \newglossaryen- files in a text editor for clues. for use with the “use build directory” option of Tex. 1. \input: %\input{INP-00-glossary} \begin{document} There is only one issue with path of the install directory Print glossaries.html#dx1-43001 Now push Alt+Shift+F1and then ->F1 Note.org/ Command = makeglossaries -d build % instead. Thank.description={F\"{o}rster distance. [4] User Manual for glossaries. Nicola L. ex. C.C. Talbot. Lists of Symbols and ckage[xindy]{imakeidx} \makeindex Acronyms. sort=k} 5. • Glossaries. if you define glossaries in a file.ac.sty v4.5 References Edit User Commands. It can be solved via the following edit: http://tex.2 Document preamble • Using LaTeX to Write a PhD Thesis.ac.ox.org/macros/latex/ fully. SPECIAL PAGES 3.text=$k_{DE description={is the rate of deactivation from . 3.. Tal- bot.uk/sites/ctan. Then.13 maker: makeglossaries needs to find the aux file. Menuitem = makeglossaries contrib/glossaries/glossaries-user. Hence the Command in this case should be: • The glossaries documentation.org/pkg/nomencl [2] http://mirror.01. Talbot..

you can use the arguments to the \cite com- \begin{thebibliography}{9} \bibitem{lamport94} Leslie mand: Lamport. Go to (b. is that LaTeX looks after the numbering for you. numbers and punctuation symbols (al- and flexible solution is achieved thanks to an auxiliary though not a comma). Referring more specifically that usually means at the very end of your document. thebibliography is space. then input any two-digit num- ber. of the bibitem you wish to cite. This is often more convenient on different lines for readability.Multiple citations ber itself is not the parameter. I have put the dif- TeX document. 215”. The cite_key nately. such as '56' which allows up to 99 references.5. Recently. typesetting systems like case you should consider using the basic and simple bib. you need reference labels of one character in length. then I add letters after. Massachusetts. that the num. 'b'. contained within the file. flat-file database. For any academic/research writing. The mandatory argument. as you would have to re-number all the citations by long time. BibTeX has been succeeded by lamport94). 1994. These linebreaks are ig- than embedding them at the end of every document writ.. but the number of digits is. which I supplied after the begin statement. so there can be a file containing sources con- cerning topic A (a. such as author. once again. Therefore. You need to syntax. I wanted the title to be in italics. is telling LaTeX how wide the item label will be when printed. In this Instead of WYSIWYG editors. so what is going on here? The first thing to notice is end-of-sentence spacing with a non-breakable inter-word the establishment of the environment. title.5. This non-breakable inter-word space is inserted a keyword that LaTeX recognizes as everything between because the end-of-sentence spacing would be too wide. This is pre- erences into a document is an important task. I am effectively telling LaTeX that I will only When a sequence of multiple citations are needed. a much more powerful quence of letters. fixed with the \bibitem{cite_key} command. etc. incorporating ref.2 Citations one wishes. Next is the actual reference entry itself. and use can be linked into the document (perhaps in addition to the following: \cite{cite_key}. figure or theorem in example: a text book. will show up inside the same brackets. Here is a practical If you want to refer to a certain page. many documents as desired (write once. p. type it as you want it to be presented. just before the \end{document} command. then adding or removing a reference would be a real planning on writing more on the same subject for a chore. both of these files the point where you want the citation to appear. reference for a given year.bib). Note the tilde in [p.~215].should use a single \cite{} command.\TeX{} or \LaTeX{} \cite{lamport94} can be used. But. When LaTeX processes the document.5. LaTeX has a variety of features that make dealing should be a unique identifier for that particular reference. Of course. Every- external. Addison Wesley. \emph{\LaTeX: a document preparation \cite[chapter.5 Bibliography Management you want more than nine. BibTeX provides for the storage of all references in an etc.” should not be separated from the page number. bibliographies can be split over as many files as 5. with references much simpler. If it were totally man- If you are writing only one or two documents and aren't ual.bib specific to topic AB). so I ten. which ul. nored by LaTeX. the begin and end tags as being data for the bibliogra- and “p.bib) and another concerning topic B To actually cite a given document is very easy.5. BIBLIOGRAPHY MANAGEMENT 113 5. followed by the last two digits of the year (hence with LaTeX). Note however. the citation will be cross-referenced with the bibitems and replaced with the appropriate number 5.1 Embedded system citation. a tool configurable within LaTeX syntax. where the cite_key is that sources ab. you might not want to waste time creating a hand. phy. a centralized bibliography source can be linked to as used the \emph{} command to achieve this. LaTeX provides an environment called thebibliography that you have to use where you want the bibliography. Fortu. The advantage here. However. which replaces the OK. 'a'. read many!).~215]{citation01} system}. If then separated by commas. When writing about topic AB. (BibLaTeX uses this same thing after the key is the reference itself. Here’s an example: . If that author has produced more than one BibLaTeX. liography support that is embedded within LaTeX. you should do whatever works for you. database of references you are never going to use. “p. The citations are timately means no more than nine references in total.) This database can be referenced in any La. I often use the surname of the first tool called BibTeX (which comes bundled as standard author. and citations made to any record that is ferent parts of the reference. 2nd edition. \end{thebibliography} The argument. including built-in support and is often some sort of mnemonic consisting of any se- for citing references.

e. it is basically a matter of altering the existing \cite commands to display the type of citation you want. you need to change the bibliography style file to plain be used. the format of the abbreviated citation (i.g. depending on the citation style. SPECIAL PAGES \cite{citation01. as Natbib allows the user to easily switch between Harvard or numeric. 2003).114 CHAPTER 5. the marker but not where it is referenced in the main text.. and consist of two parts: If you only want a reference to appear in the bibliography. The latter form allows the citation to be inte. Numbered citations (also known as the all entries from the database. In other disciplines. or a combination thereof[1] .citation02.vard is preferred. tively in order of appearance in the text. keep in mind that you will need to use the nat. By adding an abbrv asterisk (*).citation03} The result will then be shown as citations inside the same brackets. \nocite{*}. but a possible way to get such an output is by the natbib package. No cite ographic references and the citations to them in the text. grated in the sentence it supports. then the that is inserted into the text to identify the entry in the list \nocite{} command can be used...not support \citet* and will automatically choose between bib package to use most of these. There are some other specialized commands that Natbib supports. and consist in Arabic numerals in parentheses (1). such as Har- Below you can see three of the styles available with La. Keep in mind that for instance abbrvnat does However. which is normally fully (Smithsee that each reference is numbered and each citation cor- 2007) or partially enclosed in parenthesis. alpha Bibliography styles There are several different ways to format lists of bibli. the author-year style. in the list of references.e. The numeric style of citation is (2007). listed in the Here are some more often used styles: table here. (Roberts. Natbib tions (also known as the Harvard referencing system) use the author surname and (usually) the year as the abbrevi-Using the standard LaTeX bibliography support. You will also notice how Natbib by default will compress references with three or more authors to the more concise 1st surname et al version. whether they are referenced Vancouver referencing system) are numbered consecu- in the document or not. all authors and et al. which includes full bibliographic \nocite{lamport95}. . you will ated form of the citation. Once done. as in Smith responds to the numbers. A discussion about which is best will TeX: not occur here. you can override this default and list all au- thors associated with that citation. The first job is to add the following to your preamble in order to get LaTeX to use the Natbib package: \usepackage[options]{natbib} Also. Textual cita. details. superscript1 . square brackets [1]. for example: of references) and the format of the corresponding entry Lamport showed in 1995 something. to the basic \cite com- mand.. includes bered or textual. These are called citation styles. Abbreviated citations can be of two main types: num- A special version of the command. In fact. so edit the appropriate line at the bottom of the file so that it reads: \bibliographystyle{plainnat}. Customization The main commands simply add a t for 'textual' or p for 'parenthesized'. it can supersede La- TeX’s own citation commands. quite common in scientific writing.

bib file. since the closing brace will tell BibTeX that there are no more attributes for this I have previously introduced the idea of embedding ref. or the BibTeX key. curly braces have other roles. it’s a short document and you can learn need to use braces when there are umlauts to consider. I want to do a little better than this method. This is the scheme that I use in this tutorial. I have referred to an article The command requires six mandatory parameters. followed by an equals sign (=) where the value for that field is then placed. I have put the fol. The symbol for the opening bracket. although you won't get an error if you do. But as you will soon see. and so can be viewed and edited easily. Next. BibTeX expects you to explicitly la- 6. If you want an extra space. The symbol for the closing bracket.~}.quotation marks ("). entry: + Required fields. It is this identifier that 3.numerical superscript style.tex source file can get round this. as it’s are required or optional. You do not need to 5. arti- \bibpunct{(}{)}{. ö. but there is a loose standard in which you use • n . as the So as you can see.bib file with- as you can easily switch between different citation styles out any need for special markup.3 BibTeX add a comma to the last attribute. The 5. since their notation is in is loaded.}{a}{.. however. so I prefer not to use them for this job as they can get more confus- Some of the options controlled by \bibpunct are also ac. etc). Do have a look at the format to be kept throughout the . all the fields. This allows a consistent by changing a single parameter. year = “1993”. this package is quite flexible. '}'). the author’s surname. type. Using \usepackage[utf8]{inputenc} in the preamble to the . the reference. In this tuto. This key must be unique for all entries in your bibliography. and can be seen in the one opening the field.author-year style. you also have the option sky 1956. you must have a left curly brace '{' to sig- 1.5. nify the beginning of the reference attributes. volume = “14”. tation key. there is in- proceedings. which is the ci- 2.numerical style. The symbol that appears between multiple citations. A notable exception is when you want to use char- cessible by passing options to the natbib package when it acters with umlauts (ü. title = “The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})". O Optional fields @article{greenwade93. 1957). erences at the end of the document. even more about how to use it. “342-−351” } tomizing its citation style. you will use within your document to cross-reference it to this entry. An example of a BibTeX peated in the following table for your convenience. Green- wade”. For example. etc). and for papers presented at conferences. in the form of @type. e. within a journal. It is up to you as to how you wish to label each 4. and the quotation mark will close the the bibliography to be controlled. in multiple ci.bel the beginning and end of each value. avoiding the Natbib manual. vant fields and data for that particular reference. I personally use tations when there is a common author. There is a command called \bibpunct that can be used to override the defaults and Each entry begins with the declaration of the reference change certain settings. then of using curly braces ('{'. common ones are: book. \cite command to cite them within the text. Much of the information contained therein is re- of the file is also quite simple.entry.ing. BIBLIOGRAPHY MANAGEMENT 115 The final area that I wish to cover about Natbib is cus.g. After the type.}{. number = “3”.and what fields each type has available (and which ones rial. The first one follows immediately after the brace. So.bib file. it should be clear that what follows are the rele- • any other letter . author = “George D. I will concentrate on using reference and also this field reference for descriptions of BibTeX. within attributes. especially accented characters can just be stored in the . followed by the year of publication. pages = . BibTeX knows of practically lowing in the preamble: all types you can think of.5. These options also allow some other aspect of the format \"{o}. and then using the It can take a while to learn what the reference types are. • s .} cle. The punctuation used between years. (Chom. look at this entry type not as flexible as it could be. It may be worth bookmarking or printing A BibTeX database is stored as a . The punctuation to appear between the author and field names on the left are BibTeX keywords. causing an error in the parsing of table (right). This argument takes a letter: reference. journal = “TUGBoat”. They are the year (in parenthetical case only). Remember that each attribute must be followed by a comma to delimit one from another. The structure them. you need {. It is a plain text these pages so that they are easily at hand when you need file. In this example.5.

month. organization. title = "". Of course. pub- month. You must therefore manually tell dress. %note = "". pages. %month with the surname. I personally use the former. %series = "". year. %volume = "". %address = the order you input them (or any data within an entry for "". %address = "". ad- dress. there will only be an 'and' between the penultimate @inbook A section of a book without its own title. • Required fields: author. journal = "".bib file. type. %editor = "". } booktitle = "". %volume = "". %type = "". %edition = "". %note = "". %note = "". volume/number. note. year. As we can see from another example: • Optional fields: editor. This is very simply @conference Equal to inproceedings done by putting the keyword and in between every author. Secondly. author = "". forename. year = “XXXX”. year. • Required fields: author/editor. %volume = @book A published book "". the % sign @inbook{Xinbook. %edition= "". year = "". %year = “XXXX”. address = “Reading. month. title. booktitle. %note that matter) is customizable and so you can get BibTeX = "". . } to manipulate the input and then output it however you like. Massachusetts” @conference{Xconference. %address= "". edition. type. %month = "". title = "". note. SPECIAL PAGES Authors • Optional fields: volume/number. title = "". year. since you have a comma to = "". %note = "". %number = "". mann”. number. BibTeX to keep the 'von' and 'Neumann' together. } @incollection{Xincollection. publisher. series. for example “John von Neu. • Optional fields: author. %address = "". %month = "". month. BibTeX assumes that the last word • Required fields: title. month. ries. and last authors. but within the . This is achieved easily using curly braces. It can accept names in forename surname or surname. @book{Xbook. %number = "". address. but remember that %volume = "". title. booktitle= "". there is the issue of how to tell BibTeX when a reference has more than one author.116 CHAPTER 5. note. • Required fields: author/editor. • Optional fields: editor. entry. booktitle. publisher= "". publisher = "". title = "". and everything before is the forename. is the surname. Standard templates address. year = "". %publisher= "". In this form. ad- plus any middle names. title = lisher. year = “1993”. • Optional fields: volume/number. author = "". note. when BibTeX processes and outputs this. author = "". @incollection A section of a book having its own title. %author = "". %pages = "". where there @booklet A bound work without a named publisher or are compound surnames. title. Be careful if you copy the following templates. publisher= "". year. publisher. se- @book{goossens93. • Required fields: author. “The LaTeX Companion”. chapter and/or pages. you have to put it outside the %number = "". then you must be careful with a few special names. address. edition. pages = "". journal. sponsor. publisher = “Addison-Wesley”. } @article An article from a magazine or a journal. title. year = month. This is easily avoided lished = "". year = “XXXX”. it needs the ands so that it can keep track of the individual authors. se- @article{Xarticle. howpublished. %series = "". title = "". %volume = "". title. series. pages. %address= "". note. } separate the surname from the forename. %pages = "". is not valid to comment out lines in bibtex files. chapter. edition. %howpub- would be “John {von Neumann}". %chapter= "". %type = "". So the final result @booklet{Xbooklet. lisher. title = "". %number = "". author = "". %series = "". editor = "". BibTeX can be quite clever with names of authors. author = “Michel Goossens and ries. • Required fields: author. want to comment out a line. • Optional fields: volume. %editor = "". %month = "". pages. } year. %number = "". note. %edition= "". %month = "". pub- Frank Mittelbach and Alexander Samarin”. %note = "". “XXXX”. If you use the forename surname method. name. If you chapter = "". author = "". } This book has three authors. %series = "". volume/number. fore. %month = "". and each is separated as de- scribed. %pages = "".

keywords. %volume = "". organization.5. %month = "". %organi. • Optional fields: month. school = In the event that BibTeX has been set by the chosen style "". title. thesis. pages. %address = "". %note = "". %address = "".D. note. %note = "". title = "". author = "". title. se- • Optional fields: editor. note = "". (see Cite Patents with Bibtex for an alternative) month. year.org papers in a @phdthesis Ph. @mastersthesis{Xthesis. • Optional fields: author. • Required fields: title. %note = "". organization. or acronyms. • Required fields: author. %year = “XXXX”. title %volume = "". address. @inproceedings{Xinproceedings. %note = "". use the good . To tell BibTeX to keep them. year. month. %series = "". institution. note. especially if you are referring to proper nouns. address. author = "". • Optional fields: type (eg. } = "". Preserving case of letters @phdthesis{Xphdthesis. %type = “diploma thesis”. “diploma thesis”). %note = "". month. title = "". %author = "". year = "".@proceedings The proceedings of a conference. %publisher = "". } %month = "". address.5. • Required fields: author. book. } @techreport Technical report from educational. ings. com- mercial or standardization institution. month. address. • Optional fields: author. title = "". author = "". year = "". note. BIBLIOGRAPHY MANAGEMENT 117 @inproceedings An article in a conference proceed. %month = "". %organization = "". publisher. } @electronic @Unpublished For citing arXiv. ries. author = "". year = "". %address = "". school. %address = "". @unpublished{Xunpublished.= "". %author = "". @collection @misc{Xmisc. @techreport{Xtreport. %howpub- lished = "". year = zation = "". %month = "". organization. thesis REVTEX-style article • Required fields: author. title. “XXXX”. %edition = "". %type = "". title = "". title = "". %keywords not to preserve all capitalization within titles. %organization = "". note. month. %series = "". } Not standard templates @misc Template useful for other kinds of publication @patent BiBTeX entries can be exported from Google • Required fields: none Patents. %month = "". %address = "". @proceedings{Xproceedings. pub. month. title. } = "". year = "". %note = "". } @unpublished An unpublished article. %number = "". %number = "". %note = "". %address %month = "". year. se. school. note. • Optional fields: editor. year. ries. = "". title. %publisher = "". %month = "". year. problems = "". %number = "". institution @manual{Xmanual. year. %editor = "". volume/number. howpublished. %editor = "". @mastersthesis Master’s thesis etc. booktitle. volume/number. note. lisher. note. (see REVTEX Author’s guide) • Optional fields: address. author = "". title. %title = "". address. booktitle = "". @manual Technical manual • Required fields: author. • Required fields: title. • Optional fields: type. number. title = "". month. year = “XXXX”. • Required fields: author. school %year = "". %month = "". year. } can occur. year. edition. %pages = "". note.

.htm" }. As an alternative. publisher="Eggs title = "{The LaTeX Companion}".fermentas. ref_key2. T. Using curly braces around single letters is also to of whitespace between the commas and the next bib file.samplen} % Note the lack sions. avoid putting the whole title in curly braces. url = ample if a chemical formula is used in a style that sets a "http://www. such as for journal submis. author="Rabbert Klein”.bib file title = {{The LaTeX Companion}}. for ex.. do the following: ample: \cite{ref_key1. after the content. Despite its authors in the Surname. and Mosig. year = “2008”. as it may mess up the kerning. if your “7499-−7506” }. author = “Fermentas if it’s an acronym) and all will be well! It is even possible Inc. for example that the corresponding is- sue of the journal has yet to appear: However. Elizabeth and Carlson. The note field comes in handy if you need to add unstruc- title = “The {LaTeX} Companion”.”. but once again. C. journal="Theoretical Easter Physics”. which may help when writing scientific ar- ticles for different magazines. for all your research). tured information. rectory of the . month = “November”.\bibliographystyle{plain} \bibliogra- der the control of a publisher. trivial. note="(to appear)" } For convenience though. The style file in this instance is plain. year = “1994” }. actually citing the references is fairly Eric S. author . tension. the . journal = “Applied and En. style that capitalises all first letters.. be avoided if possible.. Jim D. conferences with different BibTex styles that do sometimes keep and sometimes not keep the capital letters: Getting current LaTeX document to use your . year="2010”. Firstname format. and Hyman.”.. @incollection{Abedon1994. Gisela and Hall. pages = rectory as the LaTeX document too. Lindsay Now that LaTeX and BibTeX know where to look for the W. The approach of putting only relevant text in lowing commands: curly brackets is the most feasible if using a template un. (or letters.bib file is in the parent di- W. and Kutter. editor = “Karam. T.118 CHAPTER 5. John ography{. you don't include the file ex- to bacterial availability”.”.than one reference at the same time. . Karam and Drake.[1] so the first step should generally be to enclose single words in braces. booktitle = “Molecular biology of bacteriophage well. try other BibTex styles or modify the but before \end{document}). The ones I created for this year = “2003”.”. S. ref_keyN}.. The first one covers the case of multiple when using this command. the plain style does a pretty good job (look at the ond one deals with the incollection case. Ltd. . Washington DC”. The \cite{ref_key} is the command you need. and Kreuzer. output of this tutorial to see what I mean). Eleanor”. Frederick A.g \bibliography{/some/where/sample} or \bibli- T4”. es- pecially with biblatex. appropriate files. and Thomas.. ti- it will look odd if a different capitalization format is used: tle="Black Holes and Their Relation to Hiding Eggs”. you need to specify the path as −405”. .tex document that calls it). SPECIAL PAGES old curly braces around the letter in question. as @article{blackholes. many people simply put double curly braces.bib. You do not need to add the .bib file when processed for output. and the sec.bst (which comes as standard Below you will find a few additional examples of bibliog.with BibTeX). title = “Experimental examination of tutorial were called sample1. At the moment.bib file. the . @misc{website:fermentas-lambda. @article{AbedonHymanThomas2003.bib. you need to place the fol- existing. publisher = “ASM Press.. .name. Dwight and Eiserling. making sure that the ref_key corresponds exactly to one of the entries in the . However. title = “Phage Lambda: description \& restriction that lower-case letters may need to be preserved . e.for ex. sam- bacteriophage latent-period evolution as a response plen. Karin and Miller..sample2. If you wish to cite more If you have to cite a website you can use @misc. map”. Bibliography styles are files recognized by BibTeX that tell it how to format the information stored in the .com/techinfo/nucleicacids/ title in all caps or small caps.bst extension raphy entries. volume = “69”.bib file is in the same di- vironmental Microbiology”. title = “Lysis and the interaction tend to maintain a centralized database of references between free phages and infected cells”.bib file was elsewhere (which makes sense if you in- = “Abedon.bib. and Spicer.bib file you wish to use. as it is assumed. .phy{sample1. sample2. and Black. At the end of your LaTeX file (that is. author = The second command is the one that actually specifies “Abedon. or if “pH” is to be used in a maplambda. And so the first command A few additional examples listed above is declaring which style file to use. P./sample1} (if the . S. Kenneth N. pages = “397.

tex 2.tex pdflatex latex_source_code. it’s almost complete. latex latex_source_code. bibtex latex_source_code.bib simply create a Makefile and use vim’s make command or use make in shell. without further problems. there is no field for URLs. which is invoking LaTeX for the second this: time will see more errors like “LaTeX Warning: Label(s) may have changed. Then you can plain. I couldn't open file name 'current_file.example. :! pdflatex % The addition of BibTeX adds extra complexity for the 2. and run LaTeX bibtex latex_source_code.5.Another option exists if you are running Unix/Linux or level auxiliary file: latex_source_code. :! pdflatex % After the first LaTeX run. if you put them note that the bibtex command takes the AUX file as input. automatically executed to compile the document. @book: 2.tex la- Don't be alarmed.bib pdflatex latex_source_code. @article.read the excellent Beginner’s Tutorial for more about the lowing: many clever shortcuts Vim-LaTeX provides. LaTeX Warning: There were not in insert mode.tex all you have to do is follow its instructions.bib file) to then define all the references one of the many nice features of Vim-LaTeX. and the document will be output as tex_source_code. To pro- resolve all the citation references. :! bibtex % processing of the source to the desired output. 1.com" tempt to use command mode and the current file shortcut You need to use \usepackage{url} in the first case or (%) to process the document like this: \usepackage{hyperref} in the second case.99c (Web2C 7.1) The top.tex. . (Extensions are optional.bst Database file #1: sample. pdflatex latex_source_code.tex Note the usage of \url command to ensure proper appear- 4. pdflatex latex_source_code.”. . The Makefile would then look like The third step.3. Vim- The next step is to run bibtex on that same LaTeX source LaTeX even detects how many times it has to run pdfla- (or more precisely the corresponding AUX file.pdf: latex_source_code. it is much easier to install the Vim-LaTeX plu- LaTeX Warning: Citation `lamport94' on page 1 unde.) 4.aux pdflatex la- for the third time. Note that if you are editing your source in vim and at. you ac..aux The style file: any other platform where you have make. One possibility 1.tex is to include Internet addresses in howpublished field of @misc or note field of @techreport.) raphy style recognise it. you will see errors such as: However. it looks for the 4. Each It appears that the file extension is included by default pass will perform a particular task until it has managed to when the current file command (%) is executed. you can within that document. latex latex_source_code.aux howpublished = "\url{http://www. however tex. and all the appropriate commands are undefined references.tex AUX file as mentioned above) 3. BIBLIOGRAPHY MANAGEMENT 119 Why won't LaTeX generate any output? 1. You should see output like the fol. as is shown below: 1. bibtex latex_source_code. As you can guess. if you put them note that the Another way is to use special field url and make bibliog- bibtex command takes the AUX file as input. but because of all the com. latex_source_code.url = "http://www. You will get an error similar to this: plexity of the referencing of citations from your source LaTeX file to the database entries in another file.tex 2.gin from here. This is largely hidden from the user..tex expected. and whether or not it has to run bibtex. This is BibTeX. :! pdflatex % 3. pdflatex latex_source_code. Here’s what you need cess your document from within vim. tex_source_code. This is just not on the actual . Rerun to get cross-references right.5. This allows you to simply type \ll when fined on input line 21. Version 0. :! bibtex %:r (without file extension.example.com}" 3.tex ance of URLs. :! pdflatex % (Extensions are optional.aux 1. you must explicitly to type (into command line): name the file without the file extension for bibtex to work.aux' tually need multiple passes to accomplish the task. If you want a pdf output instead of a dvi output you can Including URLs in bibliography use pdflatex instead of latex as follows: As you can see. latex latex_source_code. This means you have to run LaTeX a number of times.

abbrv and alpha) reflected in the \bibliographystyle{style} command (but are provided with urlbst. and. Also. be turned on in the settings page. cally found in the directories that they are installed. @article{mueller08. babplai3. babalpha. especially that come bundled with LaTeX . bababbrv. It’s possible to make uncited entries It should be installed with the LaTeX distribution (other- visible: wise. type: \nocite{Name89} % Show Bibliography entry of Name89 \nocite{*} % Show all Bib-entries latex makebst LaTeX will find the relevant file and the questioning pro- cess will begin. And if you require further guidance. is the ability to graphic layout. You will have to answer quite a few (al- though. to layout the bibliography in German. Unfor.120 CHAPTER 5. in older entries. This concerns One of the main advantages of BibTeX. Localizing bibliography appearance When writing documents in languages other than English. Customizing bibliography appearance you may find it desirable to adapt the appearance of your bibliography to the document language. If you need more help about URLs in bibliography. For example. Modi. add a given publication.one of babplain. The language of an entry is specified as an additional field This is a common theme in LaTeX in general. but nothing about style.bst file based on your needs. a bibliography style supported tuation to use in between particular attributes etc. I'd recommend ex. it is important One should be alert to the fact that bibliographic that LaTeX can find it! So. The babelbib package can be used here. and bababbr3 . babunsrt.bib \usepackage{babelbib} database. then there BibTeX-Format. unless you are using tions of automatic processing. visit FAQ of UK List of TeX. where it in the BibTeX entry: tries as much as possible to keep content and presenta- tion separate. you can layout each bibliography entry ac- do all the hard work for you. other styles can be modified using urlbst program. cording to the language of the cited document: It can achieve this because of the nature of the . don't include the . and actually asks you a series of questions about your preferences. the following to the header: lications tend to have their own style of formatting ref- erences. it is fairly straight. or in as well as a proper typo- people who write many research papers. what punc. Once Showing unused items complete. customize your bibliography to suit the requirements of For example.these will be automati. established journals and guage{german} conference organizers often will have created their own bibliography style (. to Alternatively. However. Tex code is prone to a variety of minor errors. Usually LaTeX only displays the entries which are re- ferred to with \cite. . note that the default answers are pretty sensible). At the command line. and so the resulting Bib- one of the standard style files (such as plain or plainnat. making it easy to build your own is a comprehensive manual available. by it .must be used: Which is why Makebst (also known as custom-bib) is the \bibliographystyle{babplain} \bibliography{sample} tool we need. creating such a style by hand is not a trivial task. make sure the name of the . it will then output the appropriate style file for you to use. For babelbib to take effect. make sure it’s in the same databases are frequently the product of several genera- directory as the LaTeX source file.bst file you want to use is fications of three standard styles (plain. Makebst can be used to automatically generate a . to which authors must adhere if they want their \usepackage[fixlanguage]{babelbib} \selectbiblan- manuscripts published. Getting bibliographic data which means it would be impractical to go through an example in this tutorial.. It is very simple. SPECIAL PAGES Styles provided by Natbib (see below) handle this field. If you are using a custom built . Many online databases provide bibliographic data in forward.bst file) for those users of BibTeX. you can download it) and it’s very simple to initiate.bst) will tell LaTeX how to for- mat each attribute. Google Scholar offers the op- perimenting with it and seeing what the results are when tion to return properly formatted output. where all the information about your references is stored in a structured format. % .bst extension!). which can also applied to a LaTeX document. tunately.. what order to put them in. database. especially for words such as editors. language = {german} } A bibliography style file (. You will notice how different pub.bst file. In fact.

Works together with MS Word and Open Literatur-Generator Office Writer. journal Web pages. .5. Moreover plug ins for browsers and Acrobat Reader exist to automatically include refer- ences to your project. KBibTeX can be tion management system based on BibTeX. • BibTeXSearch BibTeXSearch is a free searchable • Literatur-Generator is a German-language online BibTeX database spanning millions of academic tool for creating a bibliography (Bibtex. • Bibtex Editor . Based on BiBTeX. or unstandardized bibliographic ref- erences from email alerts. and slightly different UI. • DokuWiki Bibtex is a DokuWiki plugin that allows for the inclusion of bibtex formatted citations in DokuWiki pages and displays them in APA format. Features in- ager for Mac OS X. using KDE’s KParts technology.org/plugin:bibtex JabRef • Ebib — a BibTeX database manager for Emacs. • KBib Another BibTeX editor for KDE. BIBLIOGRAPHY MANAGEMENT 121 Helpful tools • Bibwiki Bibwiki is a Specialpage for MediaWiki to manage BibTeX bibliographies. and PDF files. Features include BibTeX reference generation from PDF files. It can export citations in BibTeX format. arXiv and a BibDesk number of other services are also supported. It features a very usable user in- clude comfortable input masks. . Note: This Plugins is vulnerable to an XSS attack -> http://www. It has simi- lar capabilities. Google or PubMed) and exporting to PDF. and can “scrape” BibTeX data from many popular websites. Citeseer. PubMer. folders based on keywords and live tex display. plain text. • JabRef is a Java program (under the GPL license) which lets you search many bibliographic databases such as Medline. IEEEXplore and arXiv and feed and manage your BibTeX local databases with your selected articles. Web queries to Google Scholar. • Citavi Commercial software (with size-limited free demo version) which even searches libraries for ci- tations and keeps all your knowledge in a database. RTF and XML/HTML. phy in Open Office and read BibTeX. It offers a straight- forward way to import and export bibliographic records. well resolved and never more than a few keystrokes away. starting web queries terface and provides a number of features like smart (e.). • CiteULike CiteULike is a free online service to or- ganise academic papers. DOI. arXiv & PubMed IDs. embedded into Kile or Konqueror. • cb2Bib The cb2Bib is a tool for rapidly extracting unformatted. JabRef can export in many other output formats such as html. • KBibTeX KBibTeX is a BibTeX editor for KDE to • BibDesk BibDesk is a bibliographic reference man- edit bibliographies used with LaTeX.5. records..dokuwiki. PostScript. Din 1505. MS Word or EndNote. Endnote. As KBibTeX is • BibSonomy — A free social bookmark and publica. g..An online BibTeX entry generator • Mendeley Mendeley is cost-free academic software and bibliography management system. Export of the database to all kinds of formats is possible. Possible to for managing PDFs which can manage a bibliogra- import and export Bibtex files.

document structure etc. record the info as described and the current page number. and then no more lines just before the thebibliography environment: hassle! \clearpage% or cleardoublepage \addcon- Having all your references in one place can be a big ad. Simply include this code in the preamble of your • Referencer Referencer is a Gnome application to or. and allow you're writing an article) you to view them in a more efficient manner.document: ganise documents or references. capable of importing and exporting bib files. online bibliography databases.5. your references will be saved If you use hyperref package. as well as sort them and check for errors. toc). • Synapsen — Hypertextual Card Index / Reference This will include the Bibliography in the Table of Con- Manager with special support for BiBTeX / biblatex. If you want to have proper written in Java. And having them in a structured form. \bibliographystyle{plain} \bibliography{mybibtexfile} \clearpage% or cleardoublepage \phantomsection \add- contentsline{toc}{chapter}{Bibliography} Both of these examples will create a chapter-like (or section-like) output showing all your references. age tocbibind that works with many standard document classes. or a survey of relevant works within a given topic. but you are some information \bibitem{bib:one_article} other free to write whatever you like. If you are using separate information \end{thebibliography} bib file. See the tocbibind CTAN page for detailed documenta- tion. you'll likely insert your line in the Table of Contents. It’s not uncommon to find . When LaTeX finds the code above. The second line will add a line in the Table of Contents (first option. but it can work section. Although it can take a little time to get to grips with Bib- TeX. you As unnumbered item If you want your bibliography often find BibTeX versions of publications. SPECIAL PAGES • Qiqqa Qiqqa is a free research manager that has Using tocbibind built-in support for automatically associating Bib- TeX records with your PDFs and a 'BibTeX Snif. tentsline{toc}{chapter}{Bibliography} vantage. here Bibliography was cho- bibliography using something like: sen because it’s the same text the thebibliography environ- \begin{thebibliography}{99} \bibitem{bib:one_book} ment will automatically write when you use it. and the third argument will be printed on the corresponding If you are writing a book or report. It has many options for num- Summary bering. just add the following two cut-and-paste into your own . it’s an efficient way to handle your references.bib files on web- sites that people compile as a list of their own publica.bib file. There are a vari. numbering.4 Bibliography in the table of contents ones created by chapters (second option. The most comfortable way of adding your bibliography fer' for helping you semi-automatically find BibTeX to the table of contents is to use the dedicated pack- records. List of Tables and the Table of Contents itself in the Table of Contents. (OR \addcontentsline{toc}{section}{Bibliography} if ety of free utilities that can load your . that al- lows customizable output is another one. add these lines between \bibliographystyle and \bibliography. But even This trick is particularly useful when you have to insert though the resulting “References” looks like a chapter or the bibliography in the Table of Contents. in the long term. tents without numbering. Or. so it’s a quick to be in the table of contents. it will appear in the Table of Contents. use \cleardoublepage to match the style used.122 CHAPTER 5. chapter). if you are using BibTeX. include the following code in the preamble: \usepackage[nottoc. and ultimately gen- \usepackage[nottoc]{tocbibind} erate a BibTeX bibliography file. it will be like the 5. . The tocbibind package can also handle including the List of Figures. The first line just terminates the current paragraph and page. and your TeX document will include the tomsection command to enable hyperlinking from the ta- bibliography by these commands: ble of contents to bibliography.bib files. If you are writing a book. Or in those huge. etc.Other methods tions.bib file. to fit almost any scenario. you should also use \phan- in a .numbib]{tocbibind} • Zotero Zotero is a free and open reference manager working as a Firefox plugin or standalone applica- tion. it will not be handled quite the same: it will not for anything.

• addendum. shorthand. to place the anchor in the correct page. and the book or report class. but will never be used in standard styles: gin{thebibliography}{99} . % • @mvcollection = @mvreference because the bibliography will start on its own page. A date can either be given in parts or full. • label If you are using BibTeX. the \bibliography command. • nameaddon \renewcommand{\bibname}{\section{Sources}} % Re- define bibname \bibliographystyle{IEEEtran} % Set any • origdate. \end{thebibliography} • abstract.. page references are provided as ranges and certain special fields contain verbatim code. shortseries shorttitle As we said before. doi . All physical (print) entry types share further optional field There are many kinds of titles.. biblatex is widely considered the `suc.manner. reprinttitle. it is more configurable in its output and provides a which of author and editor they expect or whether they multitude of new styles (for output) and fields (for the can use both. All en- cessor' of BibTeX.5... Some field types can optionally be used database) that can be used in a document.. you'll likely use this • @inbook = @bookinbook = @suppbook way: • @collection = @reference \cleardoublepage % This is needed if the book class is used. indextitle • pagination. \section{Bibliography} % .. 5.. Intended as a full replacement for Bib.bib files • language The following table shows most field types. origpublisher options you want \bibliography{your_bib_file_names} % Build the bibliography • origtitle. so you can. • urldate some keys are necessary. note Entry and field types in . • @article is the same as hypothetic *@inperiodical and therefore encompasses existing @suppperiodi- cal As numbered item If you instead want bibliography to be numbered section or chapter.5. This the \renewcommand block: is either because they depend on another field being set \renewcommand{\refname}{\section{Sources}} % to be useful or they can always be used in a user-defined Using “Sources” as the title of the section \be. bookpagination • shortauthor. \be- • @thesis = @mastersthesis = @phdthesis gin{thebibliography}{99} . types: Some entry types are hard to distinguish and are treated the same by standard styles: • url. For now. try types also require either date or year and they specify TeX. you will need to redefine • library \bibname instead of \refname like so. shorthandintro. but the documentation does Another even easier solution is to use \section inside of not say which entry types they can be used with. either lists of person names.5 biblatex shortjournal. Some field • pubstate types are lists. others are literal lists.5..place a normal • @report = @techreport section heading before the bibliography entries. origlocation. shorteditor. refer with any entry type: to its comprehensive documentation on CTAN. \end{thebibliography} Some field types are defined. annotation You may wish to use • entrysubtype \renewcommand*{\refname}{\vspace*{−1em}} followed by \vspace*{−1em} to counteract the extra • file space the blank \refname inserts. is title. The only field that is always mandatory. % • @incollection = @suppcollection = @inreference Use \clearpage instead if the document class uses the “oneside” argument \renewcommand*{\refname}{} % • @online = @electronic = @www This will define heading of bibliography to be empty. BIBLIOGRAPHY MANAGEMENT 123 inserting a new line in the Contents page.

In ad- • @artwork dition we add a main heading for the bibliographies and add that to the table of contents. such as entrysubtype. For example. SPECIAL PAGES • eprint.bib is used. the arti- Presuming we have defined our references in a file called cles.bib. If [3] http://ctan.6 Multiple bibliographies Using multibib and legal entry types This package is for multiple Bibliographies for different • @commentary sections in your work.5.124 CHAPTER 5. you can generate a • @jurisdiction bibliography for each chapter. \begin{document} \bibliographystyle{alpha} The entry types @bibnote.This page uses material from Andy Roberts’ Getting to grips sources}. and the listing is in plain-format instead references. b and c. and an ar- ticle: \cite{RouxSmart:95}.7 Notes and references Printing separate bibliographies We want to sepa- rate the bibliography into papers. . books and others [1] The biblatex manual If the bib entries are located in multiple files we can add [2] http://ctan.org/pkg/bibtopic we define our online resources like this: we filter with \printbibliography[title={Online re. You can find information about the package on CTAN[2] • @legislation • @legal Using bibtopic • @letter • @review The bibtopic-Package[3] is created to differ the citations on more files. \begin{btSect}[plain]{articles} lowing to the preamble: \section{References from articles} \btPrintCited \sec- \addbibresource{references. we also add \phantomsection before printing each bibliography • @movie To add each of the bibliographies to the table of contents • @music as sub-sections to the main Bibliography. • @audio To make Hyperref links point to the correct bibliography • @image section. • @video • @software 5.bib is used for Printing bibliography this listing: \begin{btSect}{books} \section{References from books} \btPrintCited \end{btSect} Here.org/pkg/multibib them like this: We can also filter on other fields. eprintclass. it can be useful to also separate the bibli- ographies using prefixnumbers such as a. File books. replace head- • @performance ing=subbibliography with heading=subbibintoc. but not yet supported (well).of the standard alpha. we add this to biblatex by adding the fol. subtype=inet] with LaTeX with permission from the author.5. \section{Testing} Let’s cite all the books: \cite{ColBenh:93} and \cite{Munt:93}. subheadings and table of contents As the numbering of the bibliographies are Multimedia entry types independent.bib} tion{Articles not cited} \btPrintNotCited \end{btSect} Just print all entries here with \btPrintAll \be- gin{btSect}[plain]{internet} \section{References from Print the bibiography with this macro (usually at the end the internet} \btPrintAll \end{btSect} \end{document} of the document body): \printbibliography 5. so that you can divide the bibliography into • @standard more parts. @set and @xdata are special. \documentclass[11pt]{article} \usepackage{bibtopic} are defined. eprinttype Example with prefix keys.

The “plain” versions of these commands as well as the numerical styles handled by BibTeX. .6. which correspond to the three styles available by default Here are the \citep* versions in BibTeX where you have a plain numbered style. It is associated with an al- phabetical reference list secondarily ordered on date. jour- nal={Difficult Maths Today}. use the commands \citet or \citep in or default author-year format citations and bibliographies your document.6 More Bibliographies \citet[]{} This is a gentle introduction to using some of the bib. These are the creation of the bibliography or reference list. each of which has a number of variants. we turn to commands to provide flexible citation formats.6.for ex- ample the often mentioned. that is to say that author names appear in styles are required. MORE BIBLIOGRAPHIES 125 5.2 The limits of BibTeX styles will be achieved via examples below.1 The example data \documentclass[]{article} \usepackage[round]{natbib} The database used for my examples contains just the fol. But author-date styles . the text outside of the parenthetical reference to the date liography styles: of publication. Natbib provides three associated bib.\begin{document} Document body text with citations. produced abbreviated lists in the case of multiple authors but both have * variants which result in full author listings. is a citation style. for example. year={1930}.are not so easy. We assume the use of the round option in these examples. pages={30} } Options Options available with Natbib can be specified in the brackets on the \usepackage command.6. So.bst 5.5.6. Alongside these new styles is an extended set of citation Having dealt with basic varieties of citation.6. This introduction won't be discussing how to create new styles or packages but rather how to use some existing ones. lowing \bibliographystyle{plainnat} \bibliography{myrefs} \end{document} @article{Erdos65. a skeleton LaTeX file with Nat- bib might look like this: 5. page numbers etc. some bibliography styles. This command can take options for chap- ter.sty package when author-date citation tual citations. It is worth noting that Harvard. All Natbib styles require that you load the package in your document preamble. Among them are: Clearly some of these options require explanation but that 5. For now. \citet and \citet* The \citet command is used for tex- ment for the cite. Here are examples • plainnat Here are the \citet* versions • abbrvnat \citep and \citep* The \citep command is used where • unsrtnat the author name is to appear inside the parentheses along- side the date.bib files and has sophisticated functionality for producing custom To cite with Natbib.3 Natbib Natbib is a package created by Patrick Daly as a replace. title = {Some very hard sums}. It’s true that you can download some .4 Citation files from CTAN that will handle some variants but using them is not always straightforward. never defined “Harvard” . author={Paul Erd\H{o}s and Arend Heyting and Luitzen Egbertus Brouwer}.sty and BibTeX makes it very easy to produce the preamble of your LaTeX file. but The Preamble the only strictly defined element of Harvard style is the citation in author-date format. and liography functionality available to LaTeX users beyond \citep[]{} the BibTeX basics. we just note that they can be passed through \usepackage[]{} in Using cite. This guide deals with Basic Citation Commands Natbib a supplementary package that can access . 5. an abbreviated numbered style and an unsorted numbered The Reference List style.

of course.sty which pro- vides a slighly different set of author-date citation func- tions. What more is there? This covers the basic functionality provided by the pack- age Natbib.sty is my next rainy day project.bib) and insert the rel- evant data here. There are two essential commands - \bibliography{mybibliographydatabase} which LaTeX interprets as an instruction to read a bibli- ographic database file (eg myrefs. how these citations would appear in plainnat. and \bibliographystyle{plainnat} which specifies how the data are to be presented. . Providing a gentle guide to harvard. Let us imagine documents bearing citations as in the section about citation above. provide what you are looking for. Above the three basic Natbib styles were mentioned as analogues of the partially homonymous styles in BibTeX.126 CHAPTER 5. Here is. If you don't find what you want here then you should probably next investigate harvard. It may not. approx- imately. SPECIAL PAGES Inserting a correct and correctly formatted bibliography when using Natbib is no different than when using plain BibTeX.

2. upset % the typesetting of the document. However. user-friendly templates. Thankfully.S. You can find the full text of GFDL nature{Joe Bloggs} \address{21 Bridge Street \\ license at \url{http://www. with little hassle.1 The letter class To write letters use the standard document class letter.org/copyleft/fdl. to ask for permission to use your copyrighted material. encyclopaedia in an entirely open manner.} or \opening{Dear Kate. naturally enough. LaTeX al- lows for very quick letter writing. You can leave recipient blank.Chapter 6 Special Documents 6. If that is the case. Main body (written as usual in LaTeX). you may want to con- sider putting the entire body in a new command like \newcommand{\BODY}{actual body} and then us- ing \BODY in all the letters. knowledge for everyone. 3. Sir or Madam:} I am writing to you on behalf of ing for your hand-written signature.1 Letters Sometimes the mundane things are the most painful.} \ps P. Road \\ Newport \\ Ipswich IP3 5RT} \opening{Dear LaTeX will leave some space after clos.org/). carbon copy and \ldots command produces dots in a way that will not list of enclosures. could you kindly fill in the The output letter will look like this: attached form and post it back to me? We shall greatly appreciate it. Each letter consists of four parts. \ldots That said. Faithfully. Additional elements: post scripta. you have to declare them first signa. If you want the same body in all the letters. Thank you for your time and consider- Here is the example’s code: ation. A sample letter. it will put your name and surname. address and telephone number to used to the noble end of providing a free collection of appear in the letter. Opening (like \opening{Dear Sir or Madam. \closing{Yours \documentclass{letter} \usepackage{hyperref} \sig. if you an endeavour to build a fully-fledged multilingual have declared them.1. I look forward to your reply. address and telephone. only if you ture. 1.start each one with \begin{letter}{''recipient''} and end with \end{letter}. allow me to reiterate that your material will be If you want your name. % The 4.gnu. You can write multiple letters in one LaTeX file . 6. it doesn't have to be that way because of evolved. Smallville \\ Dunwich DU3 4WE} \begin{document} \encl{Copyright permission form} \end{letter} \begin{letter}{Director \\ Doe \& Co \\ 35 Anthony \end{document} 127 . then the Wikipedia project (http://www.}). Closing (like \closing{Yours sincerely.}).wikipedia. agree.html}.

128 CHAPTER 6. document which includes the letter and a business-size It supports additional features like folding marks and the (#10) envelope on the following page.fromfax=false} itself).125in envelope.ps (PostScript) file. you may find the following commands useful for printing the The output is generated via envelope. C5 or C6. If that A sample envelope to be printed in landscape mode. adjusted to the correct page style. \closing{Yours Faith- fully.ps placed into standardized windowed envelopes DIN C6/5.1.html}.gnu. \setkomavar{subject}{Wikipedia} \setko- mavar{customer}{2342} \opening{Dear Sir or Madam. Thank you for your time and consideration.2 Envelopes Using the envlab package The envlab package provides customization to the \make. An alternative to separately printing addresses on en- ginning your LaTeX file the following way produces a velopes is to use the letter class from the KOMA package. Us- ing the scrlttr2 document class from the KOMA package Refer to the envlab user guide for more information about the example letter code is: this capable package. be. could you kindly fill in the attached form and post it back to me? We shall greatly appreciate it.tex && dvips -t unknown -T To move the closing and signature parts to the left. correct address placement for windowed envelopes.tex $ pdf2ps envelope. The amount of space to the left can be adjusted by in. \usepackage{lmodern} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[english]{babel} \usepackage{url} \setkomavar{fromname}{Joe Bloggs} Using the geometry package \setkomavar{fromaddress}{21 Bridge Street \\ Smallville \\ Dunwich DU3 4WE} \setkomavar{fromphone}{0123 Here is a relatively simple envelope which uses the ge. only if you agree. to ask for permission to use your copyrighted material. naturally enough.dvi file pro.pdf according the folding marks it can be landscape envelope.org/}). These settings depend on the printer filter you are using and in CUPS might be available on the lpr command line.\end{document} atively painless.} I am writing to you on behalf of the Wikipedia project (\url{http://www. C4.org/copyleft/fdl. In the second predefined format definitions for different standardized line. the KOMA-package includes duced by latex into a . $ pdflatex koma_env Folding the print of the resulting $ pdflatex envelope. In the first line.ps \longindentation=0pt It is reported that pdflatex creates the right page size but not dvips despite what it says in the geometry manual.4. Alternatively. Note that the envlab package has issues displaying characters outside the base ASCII char.45679} \begin{document} \begin{letter}{Director \\ ometry package which is used because it vastly simplifies Doe \& Co \\ 35 Anthony Road \\ Newport \\ Ipswich IP3 the task of rearranging things on the page (and the page 5RT} \KOMAoptions{fromphone=true. is the case. You can find the full text of GFDL The above will certainly take care of the spacing but the license at \url{http://www. allow me to reiterate that your material will be used to the noble end of providing a free collection of knowledge for everyone.5in. For example. One user \encl{Copyright permission form} \end{letter} reports that printing envelopes created with envlab is rel.It will never work though unless your printer settings are creasing the 0pt. I Printing look forward to your reply.In addition to the default. SPECIAL DOCUMENTS $ latex envelope.3 Windowed envelopes labels command.S.tex \documentclass[a4paper]{scrlttr2} acter set. \ldots That said.% koma_env.} actual printing is between you and your printer.dvi $ lpr -o landscape enve- the following before \begin{document}: lope. an endeavour to build a fully-fledged multilingual encyclopaedia in an entirely open manner. see this bug report for more information. allowing the user to print on any of an assortment of labels or envelope sizes.} \ps{P. dvips command converts the . DL. 6. .pdf $ lpr -o file koma_env. Swiss and Japanese letter formats. the PostScript file is sent to the printer. insert 9.wikipedia. you can use the latex dvi output driver. If you use the geometry package. 6.1.

mathserif.6.2 Presentations LaTeX can be used for creating presentations. the- orem. enumerate.. detail. including the beamer pack- age.For the actual talk. The frametitle command specifies the title for each slide (see image): \begin{document} \begin{frame} \frametitle{This is the first slide} %Content goes here \end{frame} \be- gin{frame} \frametitle{This is the second slide} \frame- subtitle{A bit more information about this} %More content goes here \end{frame} % etc \end{document} A sample letter with folding marks ready for standardized win- dowed envelopes.2. and let LaTeX download all wanted packages automati.[1] to navigate in your presentation. The usual environments (itemize. Also.cls commands 6. equation. etc. 6. the fullscreen mode.Trick: Instead of using \begin{frame}. There are several packages for the task. butions.\end{frame}. TeX. You can also have a look at the PracTex article such as Okular.) may be used. . The documentation explains the features in great then you could use a pdf reader with a fullscreen mode. 6. If you want Beamer by Example. you can use the almost The beamer package also loads many useful packages in.. Evince or Adobe Reader. proof.1 The Beamer package Inside frames.1. if title and author are set.}.. you can use environments like block..invisible links in the bottom right corner without leaving cluding hyperref.2. all you have to do is to include the beamer package you can also use \frame{. .5 Sources • KOMA-Script . If you use Mik.. but is also available from CTAN. PRESENTATIONS 129 Introductory example The beamer package is loaded by calling the beamer class: \documentclass{beamer} The usual header information may then be specified. if you can compile it with pdflatex cally.frontpage. multiple frame envi- ronments specify the content to be put on each slide.serif]{beamer} Inside the document environment. \maketitle is possible to create the The beamer package is provided with most LaTeX distri. Note that if you are compiling with XeTeX then you should use \documentclass[xetex.The Guide 6.1..4 Reference: letter.

it is possible to structure the document using Other possible types of bibliography items.style=numeric- comp. 2(1):50-−100.~Jemand. Those who wish to use natbib. online . \newblock Klein-Verlag. the reference slide will divide \frame{\titlepage} into two slides and so on. The different types of referenced work are indicated with This can be done automatically at the beginning of each a little symbol (e. with the cur.~Anders\inst{2}} gin{thebibliography}{10} \beamertemplatebook- \institute[Universities Here and There] % (optional) { bibitems \bibitem{Autor1990} A. They will modify the Table of contents with of the . you give informa. for multiple tle<presentation>{Further Reading} \be- authors) {F.bib file.~Autor. with ref_bib an item frames. Anders] % (optional. a book.tation call is simply \cite.this and that.bib} \begin{frame} \frametitle{Title} Those commands have to be put before and between A reference~\footfullcite{ref_bib}. \end{frame} the optional argument.Klein-Verlag. \subsection[Subsection]{My subsection} use the \footfullcite. is displayed by: customization of the way references are presented (see the manual).~Autor. The argument in brackets will be written on the slide. \newblock On this and that. Beamer also supports limited rent section highlighted. you add the title page : As the reference list grows.g. 2004} \sub. The Symbol section using the following code in the preamble: is set with the commands beamertemplatebookbibitems \AtBeginSection[] { \begin{frame} \frametitle{Table of and beamertemplatearticlebibitems .handout. 1990. only for long titles) {The Economics of Financial Crisis} \subtitle{Evidence from \begin{frame}[allowframebreaks] \frameti- India} \author[Author. The tion about authors. \end{thebibliography} \end{frame} Then. It is also possible to have user defined bibliography items by including a graphic. like so } \begin{frame}[allowframebreaks] \frameti- tle<presentation>{Further Reading} \be- Or for subsections: gin{thebibliography}{10} \setbeamertem- plate{bibliography item}[book] \bibitem{Autor1990} \AtBeginSubsection[] { \begin{frame} \fram- A. 2000. 2(1):50- −100. \newblock {\em Introduction to Giv- etitle{Table of Contents} \tableofcon- ing Presentations}.pdf 3. through use of the allowframe- breaks option.english]{beamer} and \usepackage[english]{babel} \subsubsection[Subsubsection]{My subsubsection} \usepackage[backend=biber. It is also possible to Contents} \tableofcontents[currentsection] \end{frame} use setbeamertemplate directly. \newblock {\em Journal of This and That}.currentsubsection] \end{frame} \setbeamertemplate{bibliography item}[article] \bib- } item{Jemand2000} S. depending on the theme used. \end{thebibliography} \end{frame} Sections and subsections As in all other LaTeX files. \begin{frame} \frametitle{Table of Contents} \tableof. Individual items can be cited after adding an 'optional' label to the relevant bibitem stanza. 1990.sorting=none]{biblatex} \addbibre- source{biblio. include e. . an article.12).g. following example shows a references slide containing two entries: \title[Crisis] % (optional. For example.~Author\inst{1} \and S.partly set “by hand” (see beameruserguide. SPECIAL DOCUMENTS Document Structure References (Beamer) Beamer does not officially sup- port BibTeX. in the document. besides book \section[Section]{My section} and article . tents[currentsection. 2000.~Jemand. titles and dates in the preamble. etc.with Beamer may need to troubleshoot both their docu- contents[currentsection] \end{frame} ment setup and the relevant BibTeX style file. \beamertemplatearticlebibitems phy\\ University There } \date[KPT 2004] % (optional) \bibitem{Jemand2000} S.130 CHAPTER 6. for example. Instead bibliography items will need to be Title page and information First. \newblock \inst{1}% Institute of Computer Science\\ University {\em Introduction to Giving Presentations}. \newblock Here \and \inst{2}% Institute of Theoretical Philoso.). \newblock {\em Journal of This and ject{Computer Science} That}. If one wants to have full references appear as foot notes. it is possible to use \documentclass[10pt. \newblock On {Conference on Presentation Techniques. The ci- Table of Contents The table of contents. triangle and text . .

fg. line}{} \setbeamercolor{sidebar}{bg=red} \setbeam- \useoutertheme{infolines} ercolor{sidebar}{parent=palette primary} \setbeam- ercolor{structure}{bg=black.g.2.fg} \setbeamercolor{section in The do it yourself solution First you can specify the sidebar}{fg=brown} \setbeamercolor{section in side- outertheme. You can define the color of every element: The Built-in solution To the preamble you can add \setbeamercolor{alerted text}{fg=orange} \setbeam- the following line: ercolor{background canvas}{bg=white} \setbeamer- color{block body alerted}{bg=normal text. The second solution is to • rounded specify colors.fg=normal text.fg=structure. PRESENTATIONS 131 Style • circles • inmargin Themes The first solution is to use a built-in theme such as Warsaw. color{block title alerted}{use={normal text. ample}{bg=normal text. color{normal text}{bg=black.example text}. beamercolor{frametitle}{fg=brown} \setbeam- The full list of themes is: ercolor{item projected}{fg=black} \setbeamer- Color themes.bg!75!black} cluded in your distribution of beamer.bg!90!black} \setbeamercolor{block body ex- to use the “Warsaw” theme.fg=structure.bg!90!black} \setbeamer- many of which are named after cities (e.33} • sidebar • smoothbars Block styles can also be defined: \setbeamertemplate{blocks}[rounded][shadow=true] • smoothtree \setbeamertemplate{background canvas}[vertical • split shading][bottom=white.top=structure.fg=yellow} \set- ified with beamercolor{palette sidebar primary}{use=normal text. can be spec.fg=alerted text. Berlin.fg!25] \set- beamertemplate{sidebar canvas left}[horizontal shad- • tree ing][left=white!40!black. fg=green} \setbeamer- color{subsection in sidebar}{fg=brown} \setbeam- Here is a list of all available outer themes: ercolor{subsection in sidebar shaded}{fg=grey} \setbeamercolor{title}{fg=brown} \setbeamer- • infolines color{titlelike}{fg=brown} • miniframes Colors can be defined as usual: • shadow \definecolor{chocolate}{RGB}{33. typically with animal names.fg} \setbeamercolor{palette \usecolortheme{beaver} sidebar quaternary}{use=structure. etc.bg!75!black} \setbeamercolor{block ti- This Theme Matrix contains the various theme and color tle}{bg=blue} \setbeamercolor{block title exam- combinations included with beamer. Berlin. Beamer has several themes.fg!75!normal text. The outertheme defines the head and the bar shaded}{fg=grey} \setbeamercolor{separation footline of each slide.fg!75!normal text. particularly the \setbeamercolor{fine separation line}{} \set- part Change the way it looks.33.fg.fg=normal text.6.).right=black] Then you can add the innertheme: You can also suppress the navigation bar: \useinnertheme{rectangles} \beamertemplatenavigationsymbolsempty Here is a list of all available inner themes: Fonts You may also change the fonts for particular el- • rectangles ements. etc. Frankfurt.bg!90!black} \usetheme{Warsaw} \setbeamercolor{block body}{bg=normal text. have a look to the official documentation in- text. For more customiz- ple}{use={normal text.bg=normal text.fg=example ing options.fg} \setbeamercolor{palette sidebar sec- The full list of color themes is: ondary}{use=structure. If you wanted the title of the presentation as ren- .fg} \setbeam- ercolor{palette sidebar tertiary}{use=normal text.bg=normal text. inner themes and outer themes.alerted Madrid. text}.

the form fragile=singleslide is usable use \begin{itemize}[<+->]. for example in If you want to include lots of text on a slide. By default the beamer class adds navigation buttons in the \setbeamerfont{title}{family=\rm\addfontfeatures{Scale=1.in the preamble. \end{frame} Frames Options Text or figures after \pause will display after one of the The plain option. first concept we introduce originates with Erd\H os. return 0. One quick fix for this is to Animations use at the beginning of the file the option mathserif \documentclass[mathserif]{beamer} The following is merely an introduction to the possibili- ties in beamer. SPECIAL DOCUMENTS dered by \frame{\titlepage} to occur in a serif font instead \end{frame} of the default sanserif. \end{itemize} you should pass the option fragile to the frame environ- ment. you would use: \setbeamerfont{title}{family=\rm} Hyperlink navigation You could take this a step further if you are using Open- Type fonts with Xe(La)TeX and specify a serif font with Internal and external hyperlinks can be used in beamer increased size and oldstyle proportional alternate number to assist navigation. Chapter 8 of the beamer manual provides much more detail. } played for (inclusive). Usually. Others have proposed to use the command Making items appear on a slide is possible by simply using \usefonttheme[onlymath]{serif} the \pause statement: \begin{frame} \frametitle{Some background} We but it is not clear if this works for absolutely every math start our discussion with some concepts. ance and disappearance of text by using <a-b> where a and b are the numbers of the events the item is to be dis- \frame[shrink]{ % . } 1> {This one is shown at the first time.. but it will hide soon (on the next event after the slide loads). (for details see the manual). \frame[plain]{ % . Note that the fragile option \begin{frame} \frametitle{`Hidden higher-order con- may not be used with \frame commands since it expects cepts?'} \begin{itemize}[<+->] \item The truths of to encounter a \end{frame}.} Before using any verbatim environment (like listings). Proportional}}} bottom right corner. \pause The character. on many more features.. To remove them one can place \beamertemplatenavigationsymbolsempty Math Fonts The default settings for beamer use a dif. ferent set of math fonts than one would expect from cre- ating a simple math article. concepts’??? \item `Truths gin{lstlisting}[caption=First C example] int main() in the language of arithmetic which \ldots \item That sug- { printf(“Hello World!"). } Text animations For text animations.. return or page down on the keyboard. use the shrink the itemize environment.132 CHAPTER 6. } \end{lstlisting} gests stronger version of Isaacson’s thesis. Sometimes you need to include a large following events (which may vary between PDF viewers): figure or a large table and you don't want to have the bot. which should be alone on a arithmetic which are independent of PA in some sense single line. as soon as the slide loads) \item<2-> if there is too much content to be displayed on one. A simpler approach for revealing one item per click is to ferently. themselves `{contain} essentially {\color{blue}{hidden \begin{frame}[fragile] \frametitle{Source code} \be. use the plain using the mouse to scroll down or click the next slide but- option: ton. it is possible to specify appear- option. Clean looking buttons can also be glyphs: added. Pause can be used within \itemize etc. For example: \begin{itemize} \item This one is always shown \item<1- The allowframebreaks option will auto-create new frames > The first time (i... \end{itemize} . or infinitary. or tom and the top off the slides. The second time \item<1-> Also the first time \only<1- \frame[allowframebreaks]{ % . as verbatim environments need to be typeset dif.higher-order}}..e. pressing space. In that case. Numbers={Lining.18.

handout.handout]{beamer} \documentclass[12pt. the default mode is presentation which \documentclass[12pt.Columns and Blocks out statement to have the following: \only<1| handout:1>{\includegraphics{pic1. printable version).. you can add a statement to spec. ify precisely the behavior when dealing with only com. you may need to copy the .eps}} in another mode before. Important: the notes=only mode is literally doing only mands in handout mode. for them to have both the slides with command.. but the second one show the first one Columns Example plus some other graphs and you don't need the first one to\begin{frame}{Example of columns 1} \be- appear in the handout. (The order matters. you can add an option to the class calling. the full syntax for a frame is backtrack through the sequence. and “columns” which divides a slide (vertically) into columns. scrolling up. If you use separate files for a \only<2>{\includegraphics{pic2. you want them both in the handout.aux file from the handout compilation with the slides (w/o the notes).5\textwidth} Contents split \\ into two lines \end{columns} \end{frame} \begin{frame}{Example of columns 2} \begin{columns}[T] % contents are The command can also be used to hide frames. e. or click. However.} \note{. \end{frame} \note{. you can write graphics[height=3cm]{graphic. if you have written a frame that you don't want native top-align that’s better for graphics \include- anymore but maybe you will need it later. \begin{frame} . you can work in a different mode that is called handout by setting this option when calling the class: or \documentclass[12pt. pressing page up. Don't put handout:0|beamer:0 or it won't work. Using this. Note that the 'handout' option in the \documentclass line If you want to solve this.eps}} designated by a command Contents of the first column \only<2>{\includegraphics{pic2.) In all these cases.eps}} There are two handy environments for structuring a \only<2| handout:2>{\includegraphics{pic2. and you can write your notes about a frame in the field Handout mode note (many of them if needed).. Suppose you have a code like the notes.6.png} \end{column} \begin{frame}<0| handout:0> \end{columns} \end{frame} .5\textwidth} % column \only<1| handout:0>{\includegraphics{pic1.eps}} \column{. Nev.g. This means there will be no output file but the this DVI. PRESENTATIONS 133 \end{frame} and this will hide your slide in both modes. top vertically aligned \begin{column}[T]{5cm} \begin{frame}<handout:0> % each column can also be its own environment Contents of first column \\ split into two lines \end{column} \begin{column}[T]{5cm} % alter- or even. be given to those who have followed your presentation or ertheless.. These pictures being completely different. or figures at a time and not all of them together. because its purpose is to have only some text what you said. You can thus precise the handout gin{columns}[c] % the “c” option specifies center mode not to include some only commands by: vertical alignment \column{. Now imagine you still have your two pictures with the only statements.} . picture. which divide the slide (horizontally) into headed sections.eps}} slide: “blocks”.. making any \itemize[<+->] environments have only the notes you need.. this makes an issue when working with the only those who missed it. Thus it requires you to have run the compilation \only<1>{\includegraphics{pic1..notes=only]{beamer} makes the slides.eps}} better distinction between the modes.A last word about the handout mode is about the notes. but they cannot be both on the same slide since they are large. while the second one could visible all at once (for instance. The solution is to add the hand.. suppress all the animations.2.notes=show]{beamer} This mode is useful to see each slide only one time with all The first one is useful when you make a presentation to its stuff on it. Blocks and columns can be This will ensure the handout will make a slide for each used inside each other. ing the previous slide button in the navigation bar will Actually.handout. either In beamer class.

re- serve) slides are included in the total count despite them not being intended to be public until a “hard” question is asked. This allows to visually distinguish parts of a slide \addtocounter{framenumber}{−1} easily. and the appendix or so-called “backup” (aka appendix. Or alternatively this: Simple \setcounter{framenumber}{0} or \set- \begin{frame} \begin{block}{This is a Block} counter{framenumber}{1} This is important information \end{block} \be- gin{alertblock}{This is an Alert block} This is an impor- tant alert \end{alertblock} \begin{exampleblock}{This • The first of the above applies to section slides to is an Example block} This is an example avoid counting them. headed block of text (a blank heading can be used).134 CHAPTER 6. Inside the usual document environment. Their for- matting depends on the theme being used. this poses two problems for some presentation authors: the title slide is numbered as the first one. multiple slide en- You can specify the default options of your PDF. There are three basic types of block. SPECIAL DOCUMENTS \hypersetup{pdfstartview={Fit}} % fits the presentation to the window when first displayed Numbering slides It is possible to number slides using this snippet: \insertframenumber/\inserttotalframenumber However. The powerdot package is loaded by calling the powerdot class: \documentclass{powerdot} PDF options The usual header information may then be specified. For instance. this may be inserted at the title slide to avoid counting it: Blocks Enclosing text in the block environment creates a distinct. The documentation explains the features in great detail. \end{exampleblock} \end{frame} • This stuff works around the problem of counting the backup slides: % (Thanks. David Gleich!) % All your regular slides % After your last numbered slide \appendix \newcounter{finalframe} \set- counter{finalframe}{\value{framenumber}} % Backup frames \setcounter{framenumber}{\value{finalframe}} \end{document} 6. It is available from CTAN.[2] vironments specify the content to be put on each slide.2 The powerdot package The powerdot package is an alternative to beamer. .2.[3] This is where two features come in: • Ability to reset the frames counter at any slide.

The macro \numpoints gives the total num- ber of points.3. We present the \numpoints.2. Interested people could also have a The backslash after \numquestion prevents the macro look at the probsoln package[2] . For a very simple presentation.4 References Here is an example : [1] Andrew Mertz and William Slough. . \maketitle \begin{slide}{slide title} This is just some text \begin{itemize} \item Wombat \item Capybara \item • The number of points is specified in squared brack- Mara \end{itemize} \end{slide} \begin{slide}{Wombat ets.2. 6. The exam class is well suited % etc \end{document} to design exams with solutions.3. You can replace the 3 first lines with the following : \documentclass[paper=160mm:90mm. would.DIV=16]{scrartcl} \usepackage{lmodern} \pagestyle{empty} \renewcommand{\familydefault}{\sfdefault} Document \newenvironment{slide}[1]{\clearpage {\LARGE\bfseries#1\par}\vspace{\baselineskip} • The exam is included in the questions environment.2. The total number of points is LaTeX has specific features for teachers.1 Intro \begin{minipage}{.2 The exam class %Content goes here \end{slide} \begin{slide}{This is the second slide} %More content goes here \end{slide} We present the exam class. It appears only if \printanswers or answers as an option of the \documentclass are specified in the preamble.fontsize=10pt. }{} \usepackage{enumitem} \setlist{noitemsep} \ti- tle{XeTaL} \author{Carl Capybara} \begin{document} • The command \question introduces a new question.3 Simple presentations Preamble The beamer class is very powerful and provides lots of features. You just have to specify in the preamble if you want the solutions to be printed or not. the mathexm document from gobbling the following whitespace as it normally class[3] .6. 6. a class based on In the preamble you can specify the following lines : article can be used. TEACHER’S CORNER 135 \begin{document} \begin{slide}{This is the first slide} 6. Beamer by Example \begin{questions} % Begins the questions environment [2] Other possible values are defined in the hyperref manual \question[2] What is the solution? % Introduces a new question which is worth 2 points \begin{solution} [3] Appendix Slides in Beamer: Controlling frame numbers Here is the solution \end{solution} \question[5] What is your opinion? \begin{solution} This is my opinion \end{solution} \end{questions} 6. 6. \ifprintanswers Only if answers are printed \else Only if • Beamer user guide (pdf) from CTAN answers are not printed \fi • The powerdot class (pdf) from CTAN • A tutorial for creating presentations using beamer Introduction The macro \numquestions gives the total number of 6. \end{minipage} exam class[1] which is useful for designing exams and ex- ercises with solutions. You can also count the number of points. title} This is just some different text \end{slide} \end{document} • The solution is given in the solution environment.5 Links It is also possible to add stuff only if answers are printed • Wikipedia:Beamer (LaTeX) using the \ifprintanswers command. or the exsheets package[4] .8\textwidth} This exam includes \numquestions\ questions.3 Teacher’s Corner questions.3.

Best results will be achieved when doing a CV from scratch. etc. the fonts.3. Other- wise. LaTeX is def- initely a document processor of choice to write a CV. SPECIAL DOCUMENTS 6. . Thanks to its strong typographical stance.136 CHAPTER 6. but also the layout. It is fairly customizable. you may want to use a dedicated class for that task. that is nearly impossible to customize. This way. using list environments and tabulars. First document • Banking black theme Most commands are self-explanatory. Of course you can design your own CV by hand.1 europecv 6. This is a great example of cases where the power of LaTeX comes to the front. You should really have a look at the templates for more details. ⇐ A full list of CV packages is available at CTAN. is extremely hard. and you are done.2 moderncv From CTAN: Moderncv provides a documentclass for typesetting modern curriculums vitae.4. allowing you to define your own style by changing the colours. While filling out a form is very easy. both in a classic and in a casual style.cls which is still used by some people.4. It is a very old class. Only very experi- enced users should use res.3 References Theme previews [1] examdoc Using the exam document class [2] Probsoln Creating problem sheets optionally with solu- tions [3] mathexm documentation [4] exsheets documentation Create exercise sheets and exams 6. You can find those tem- plates in your distribution (if documentation is installed along packages) or ultimately on CTAN.cls. We will not repeat the templates here. ⇒ Be aware of res. 6. so we will only provide a crash course. writing a CV in LaTeX is as simple as filling the forms. changing a layout that is supposed to be fixed.4 Curriculum Vitae A curriculum vitæ or résumé has a universal requirement: • Themes its formatting must be flawless. The important thing to mention is that a class or package not only defines the syntax of the form to be filled out. The official package provides some well commented tem- plates which may be a good start.

6. LaTeX with appropriate macros provide a comfortable way to manage it. CURRICULUM VITAE 137 • Classic green theme 6. See Internationalization.4.).4.4 References . etc. since many parts are shared among versions (personal data.3 Multilingual support It is especially convenient for résumés to have only one document for several output languages.4. structure. 6.

Contrary to METAFONT. especially for more advanced diagrams. you shows: have to go from TeX to DVI to PDF. it are “small” with respect to bytes. there are rather se. which can be imported in LaTeX. One of them is XY-pic. eepic or pstricks enhance the original picture environment. In this chapter. The power of pstricks stems or embed graphics directly in a LaTeX document. meaning quadratic. pstricks or metapost) focus on the how to draw. described at approach is more time consuming. the twin of Donald E. Furthermore. Many frequently-used curves such TikZ and Asymptote focus more on the what to draw.1 Overview ates bitmaps. ellipses.the end of this chapter.1 Introducing Procedural tional graphics files to be dragged along. as circles. and there are no addi- 138 . see A User’s Manual for MetaPost. as the following example of embedded graphics such. losing hyperlinks. this specific purposes. and microtypographic features of pdflatex in graphics directly in LaTeX. but leads to much bet. METAFONT. If a programming mended to use one of these if your LaTeX distribution language like Java is used to generate \qbezier blocks of includes it. described in the following sections. For an introduc- The picture environment allows programming pictures tion. epic. MetaPost generates encapsulated PostScript files. The documents thus produced In many cases. as mulas. Unfortunately it has one big for typesetting bold text or creating mathematical for.LaTeX is MetaPost. tem which integrates seamlessly with (La)TeX. On the other hand. the picture environment becomes quite on external software. While the previous systems (pic- of LaTeX2e brings with it the \qbezier command. A wide variety of these packages ter results. If using Although programming pictures directly in LaTeX is Asymptote. you learned that you power of LaTeX.While the former two packages just enhance the picture ics that you have created in another program or obtained environment. can import or link graphics into LaTeX. See the Importing Graphics for more details on graphics Perhaps the most powerful graphical tool related with importation and some attempts to circumvent to integra. In addition. TikZ is a pure (La)TeX system. there are the compilation steps. numerous packages have been written for Compared to WYSIWIG tools like Xfig or Inkscape. the pstricks package has its own drawing elsewhere. you will learn how to create environment. it is very helpful to use latexmk to manage severely restricted.shortcoming: it doesn't work together with pdfLaTeX.discussion of LaTeX and TEX strategies for graphics (and vere constraints. It’s recom- may require some mathematical toil. such as graph. Graphics Packages like epic. To generate a PDF document from TeX source. and often rather tiresome. xy-Pic and the process. while Asymptote is an external sys- powerful. A very thorough directly in LaTeX.Chapter 7 Creating Graphics 7. and catenaries can be satisfactorily One could say that TikZ and Asymptote are to drawing approximated by quadratic Bézier curves.1. “q” ture. ion (not to be confused with The LaTeX Companion). On the one hand. The from the fact that this package makes extensive use of graphics is marked up using commands similar to those PostScript possibilities. as the radii of circles are restricted to a narrow choice The last but certainly not least are the PGF/TikZ and of values.are described in detail in The LaTeX Graphics Compan- grated to your document (no contrast in size nor fonts). pspicture. the picture environment Asymptote systems. still reasons for doing so. including picture. MetaPost has the very powerful and mathematically sophisticated programming language of METAFONT. There are several packages supporting the creation of metadata. which gener- 7. as the slopes of line segments as well fonts) can be found in TEX Unbound. and greatly strengthen the graphical In the Importing Graphics chapter. PGF/TikZ. the output is flawlessly inte. Knuth’s tion issue. although this in LaTeX as LaTeX is to digital typesetting. not reliant LaTeX input files.

line segments.. . a direction vector. even more narrowly restricted than for line segments. x0. as the slopes of line segments as well as the radii of circles are restricted to a narrow choice 2. PICTURE 139 may be easier to draw the graphics using external vector Bézier curves are an exception. 5. 4).2 MetaPost Line segments are drawn with the command: 7. “q” other cases the horizontal distance of the line. See Graphics in LaTeX2e for examples and Java or source files. affects the reservation. and then import the file into the doc.3 Arrows are “small” with respect to bytes.1 Basic commands arrows pointing to the upper left. As in the case of angle. (x. The \circle* ordinates to the bottom left corner of the reserved rect. which can result in not suitable and inconsistent tive to \unitlength.3. one may have to resort to additional pack- The numbers x. However most With the package picture absolute dimension (like 15pt) software does not support LaTeX fonts or mathematical and expression are allowed. namely to the integers (−4.3. They are drawn with the graphics software.low this limit. Many frequently-used curves such than the length of the segment itself). Components also have to be coprime (no common divisor except 1). not all diameters are possible. epic. which can be reset any time (but not There is another possibility within the picture environ- within a picture environment) with a command such as ment. . although this The components of the direction vector are restricted to may require some mathematical toil. eepic or pstricks enhance the original picture environment.2 Line segments 7. The length is relative to \unitlength. (x0 .4 Circles mands or The command The first pair. and there are no addi- tional graphics files to be dragged along. pstricks.. units of \unitlength. there are still reasons for doing so. . 3.3. and greatly strengthen the For arrows. assigns arbitrary co. without the need of loading any external package. powerful. graphics. Notice the effect of the \thicklines command on the two 7.7.. such as eepic. specified by diameter. the picture environment length in the case of a vertical line segment and in all of LaTeX2e brings with it the \qbezier command. there are rather se- vere constraints.3. command ument (see LaTeX/Importing_Graphics). Although programming pictures directly in LaTeX is severely restricted. −5. within the draws a circle with center (x. The picture environment only ad- mits diameters up to approximately 14mm. and even be- The optional second pair. . rather meaning quadratic. y) . or tikz. a “length” (sort of: this argument is the vertical of values. The figure below LaTeX input files. y0 ) ..3 Picture The \line command has two arguments: The picture environment allows programming pictures 1. the components of the direction vector are graphical power of LaTeX. −3. in addition to numbers rela- notation. y0 are numbers (lengths) in the ages. ellipses. On the other hand. The documents thus produced 7. If one is not afraid of doing the necessary calcula- The default value of \unitlength is 1pt. On the one hand. y) and diameter (not radius) document. the picture environment becomes quite illustrates all 25 possible slope values in the first quadrant. 7.command produces disks (filled circles).3. and often rather tiresome. . This environment is created with one of the two com. If a programming the integers (−6. arbitrary circles and ellipses can be patched together from quadratic Bézier Most drawing commands have one of the two forms curves. directly in LaTeX. and catenaries can be satisfactorily approximated by quadratic Bézier curves. 6) and they have to be co- language like Java is used to generate \qbezier blocks of prime (no common divisor except 1). A picture environment is available in any LaTeX distri- bution. There are several solutions to this problem. Arrows are drawn with the command Packages like pict2e. of rectangular space for the picture. y. as circles. tions (or leaving them to a program).7.

r refer to “top”.9 Quadratic Bézier curves As this example shows. “left”. and can be combined. The \linethickness command ap- plies to horizontal and vertical line segments. can be obtained from the 7. and of the \thinlines and the \thicklines commands on The command oblique line segments. y) and having width w and height h. The name argument refers to a LaTeX storage bin and The control points of the two Bézier curves were calcu- therefore is of a command nature (which accounts for the lated with formulas (*).3. It also shows that both kinds of or commands affect quadratic Bézier curves. The crosses indicate points of the real catenary. While \linethickness{''length''} applies only to horizontal In this figure. 2.3. Boxed pictures can mined by P1 = (0. and S = (x. It does. l. y1 ) . and the lower left as the \line command does not work if the segment length corner is assigned the mathematical coordinates (−3.6269. splitting up a circle into 4 quadratic Bézier curves is not satisfactory.25). The positive branch is deter- backslashes in the current example). m1 = 1 and P2 = (2. whereas by the command then defined by its lower left corner (marked by the black disk) is assigned and finally arbitrarily often be drawn by the coordinates (−2. to circles and ovals. nor to circles. As this example illustrates. m1 and m2 . 2 gives same solution) the object to be drawn. but neither to oblique line segments.10 Catenary the one hand. Using again equation (*). produces an oval centered at (x. \thinlines and \thicklines on the other. way: P2 = (x2 .140 CHAPTER 7. the translation vector x = m2 x2 −m 1 x1 −(y2 −y1 ) m2 −m1 from one object to the next. tanh 2) be nested: In this example. The picture is defined in A picture box can be declared by the command convenient “mathematical” coordinates.6 \multiput and \linethickness equations The command { has 4 arguments: the starting point. being less than one percent.11 Plotting graphs top and right. The other position specifiers are 7. y) denotes the intermediate control point. \thinlines cosh x − 1 is approximated by a quadratic Bézier curve. we can calculate the intermediate control points.−0. The figure again shows the effect of the 7. each command overriding all previous ones. In the example it is set to “bl” which puts the anchor point into the bottom left corner of the savebox. the slope there having the value m = 3. each symmetric half of the catenary y = and vertical lines (and quadratic Bézier curves). See Graphics in LaTeX2e for a Java program which gen- apply to quadratic Bézier curves! erates the necessary \qbezier command line. The error 7.2384. (black disk). (i = 1. . y2 ) denote the end points.3.3.5. The optional position arguments b. CREATING GRAPHICS 7.7622). Again. \foldera is used within the .−2) is less than about 3 mm.2384. At least 8 are needed.8 Multiple use of predefined picture is barely noticeable.3. Line thickness can be controlled by two kinds of commands: \linethickness{''length''} on 7. and \thicklines apply to oblique line segments as well as The right half of the curve ends in the point (2. and y = yi + mi (x − xi ). however. t. 0) and (−1. 0). m2 = 1/ cosh2 2 . as the example illustrates.3. This boxes example points out the use of the optional argument of the \begin{picture} command.3. The optional position parameter has the effect of defining the “anchor point” of the savebox.7 Ovals \linethickness command on horizontal or vertical lines. text and formulae can be written The command in the environment with the \put command in the usual draws a quadratic bezier curve where P1 = (x1 . 0) . “right”. the picture is defined in definition of \folderb. the number of objects. They turn out to be (1.5 Text and formulae 7. The \oval command had to be used mathematically convenient coordinates. The respective tangent slopes. “bottom”.

e. “shadows”.de/tex-archive/help/Catalogue/bytopic. It’s rec. “calendar”. making the use of PGF easier. trary TEX dimension either using Cartesian coordinates ommended to use it if your LaTeX distribution includes (comma separated). See [] for a tutorial. 7. \usetikzlibrary{⟨list of libraries separated by commas⟩} Examples for libraries are “arrows”. The powerful scientific plotting package gnuplot has the capability to output directly to a LaTeX picture environ.g.the pgf package. While the previous systems (picture. or different for height and width. “trees”. N. “spy”.4. This will automatically load array of commands.xscale=2.1 Loading Package.g. It is often far more convenient to plot directly to tikzpicture environment LaTeX. “petri”. the option mechanism is similar to PsTricks syntax.dante.5. ered such that the height ⟨dimension⟩ is on the baseline. since this saves having to deal with potentially troublesome postscript files.net/tikz/ scale=⟨factor⟩ PGF (“portable graphics format”) is the basic layer. “automata”.B. (1cm. A full discussion of gnuplot lies be. e. “back- 7. Libraries - ment. “chains”. “patterns”. Note the slightly translucent top layer. “shapes. Plotting scientific data (or.3.5 tend layer with a special syntax. TikZ can produce portable graphics in both you can specify that the picture should be raised or low- PDF and PostScript formats using either plain (pdf)TEX.texample. (pdf)Latex or ConTEXt. Such pictures can \usepackage{tikz} then be added to a document by an \include{} command.4 PGF/TikZ grounds”. Drawing commands have to be enclosed in an tikzpicture environment \begin{tikzpicture}[⟨options⟩] ⟨tikz commands⟩ \end{tikzpicture} or alternatively \tikz[⟨options⟩]{⟨tikz commands⟩} One possible option useful for inlined graphics is baseline=⟨dimension⟩ Example of graphics done with Tikz. and of course typesetting ability. 1cm in .geometric”.2pt) for drawing electrical circuits) can be found here: http://ftp.g: and TikZ (“TikZ ist kein Zeichenprogramm”) is the fron.4. TikZ commands are prevalently similar to Meta- font. “matrix”.12 The picture environment and gnu. To load further libraries use yond the scope of this note. epic. PGF/TIKZ 141 7. than is available from other means (such as postscript). e. Coordinates are specified in round brackets in an arbi- ing in LaTeX as LaTeX is to digital typesetting.. Without that option the lower end of the picture is put on One way to draw graphics directly with TeX commands the baseline of the surrounding text. Using TikZ in a LaTeX document requires loading the indeed. “mindmap”. gnuplot is a powerful piece of software with a vast somewhere in the preamble.g.2 Specifying Coordinates metapost) focus on the how to draw.4. pro- viding a set of basic commands for producing graphics. It comes with very good Another option to scale the entire picture is documentation and an extensive collection of examples: http://www. 1cm in the x direction and 2pt it. Using this option. is PGF/TikZ.misc”. pstricks or 7. mathematical figures) this way gives much greater tikz package: control.html#pgftikzsection plot In the following some basics of TikZ are presented. One could say that TikZ is to draw. TikZ focuses more on the what to draw.7. or using polar coordinates (colon separated). in the y direction Other packages building on top of TikZ (e. “shapes. yscale=0.

by adding one or two plus signs in front of the coordinate. line join options: “line cap=<type: round. will not be important for the picture size). “very thick” for 1. One instruction can spread over several lines. with one or two control olive. "\filldraw”.2pt. Without specifying a unit (1. with "+" the previous point stays the current path Line end position. This drawings up to the end of the current scope are clipped is followed by a series of “path extension operations”. “very thin” for 0. blue. points. “pat- instructions can be put on one line. tern=<name>". The instruction has to end with Line pattern options: “dash pattern=<dash pattern>" (e. Example: 2 standard units to the right of the last point used: Line end. Straight lines are given by coordinates separated by a dou- tern”. bevel. A connected path can be closed using the "--cycle” oper- "\shade”.0) straight line to (2.0). black.1) straight line to (2. magenta. “shade” (a variation on filling that changes col. “dashed”. purple. phase=⟨dash phase⟩".4. or several Options for filling paths are e. “yscale=<factor>". which is not connected to the pre- Geometric path actions vious part of the path. or miter>". “solid”. For a connection that is first hor- “xscale=<factor>".4pt (the default width). lightgray. “semithick” for 0.. The "\path” command with these options can The same path with some drawing options: be combined to: "\draw”.142 CHAPTER 7. “scale=<factor>". “fill=<fill color>".8pt. "\useasboundingbox” . “rounded corners”.3 Syntax for Paths Line pattern A path is a series of straight and curved line segments (in a simplified explanation). “clip” (all subsequent The first coordinate represents a move-to operation. “loosely dotted”.()" command.1): Geometric path options: “rotate=<angle in degree>".2cm). brown. . “arrows=<start arrow kind>-<end arrow kind>". or butt>". “rounded corners=<size>".1pt.g.4 Drawing straight lines Options for path actions are e. ors smoothly from one to another). “densely dotted”. "\pattern”.5 Drawing curved paths “draw=<line color>". “pattern color=<color>" Path actions 7. horizontal and vertical. cyan .controls() . “use as bound- ing box”. Here: Move to (0. “dash pattern=on 2pt off 3pt on 4pt off 4pt”). With "++" the last point of the path becomes the current position.g: “draw”. “thick” for 0. CREATING GRAPHICS 30 degree direction Line width (30:1cm) Line width options: “line width=<dimension>". "\clip”. izontal and then vertical.2pt.(coordinates)". the ".6pt. the standard one is cm “thin” for 0. green. "\fill”. use or first vertical then horizontal. a semicolon..g. ble minus. “pat. ation: A further move-to operation in an existing path starts a new part of the path. lime. orange. (1cm. gray.0) rect.6pt. pink. “dash \path[<options>]⟨specification⟩. “line join=<type: round. “yshift=<length>". move to (0.4. “dotted”.4. darkgray. “fill”.2). “dash- dotted”. “ultra thick” for Relative coordinates to the previous given point are given 1. 7. violet and white. ++(2. like against the current path and the size of subsequent paths "-. “opacity=<factor>". 7. and ab- breviations “ultra thin” for 0. teal. "\shadedraw”. “double”. Two points can be connected by straight lines that are only “xshift=<length>". Curved paths using a Bezier curve can be created using yellow. Following colors are predefined: red. use Color Color options for drawing paths: “color=<color name>".

log2(\x).125”. “outer sep=<dimension>". If you only want to name a certain position without center then using the “circle command” either with one writing text there are two possibilities: length as radius of a circle or with two lengths as semi- axes of an ellipse. pow(\x. User-defined paths can be created using the “to” oper. “sin”. tan(x). “midway” for “pos=0. “font=". {function}). including factorial(\x).7 Circles. “text=<color>". . “very near end” for “pos=0. E. and pi. “minimum size=<dimension>". abs(\x). ceil(\x). press x in radians follow it with the notation “r”. to ex- “out” and “in” option a curved path can created. “in- Or in an alternative syntax: ner sep=<dimension>".y). ation. they are added to the picture rent point. which is equal to 3. An example with two functions: (The syntax for a bend to the right may seem a little counter-intuitive. \draw [domain=<xmin>:<xmax>] plot (\x. Com- There are many more predefined commands for special binations are also possible. “pos=0. floor(\x).g. Using the metric functions assume that x is in degrees.π/2]).g. "[out=135. where fraction is a float- ing point number between 0 representing the previous To add arrow tips there are simple options for the drawing coordinate and 1 representing the current coordinate. “cos” (sine or cosine “below left”. curve in the interval [0.y).75”. log10(\x). not as saying that the path curves 7. command: There exist some abbreviations: “at start” for “pos=0”.y). and max(\x..4. exp(\x). The fill color “green!20!white” means 20% green and Inside a path operation use the following syntax after a 80% white mixed together.718281828. \draw (0.25”.5”. exactly like the double minus command. start angle= 0. round(\x). Often it would be better to have the node placed beside the actual coordinate: Right (“right” or “anchor=west”).g. sin(\x). min(\x. e. “shape as- \draw (0. sqrt(\x). like “grid”. The “sloped” option causes the node to be rotated to be- come a tangent to the curve. “pos=<fraction>" option.10 Nodes to the right throughout its length. Think of it as an instruction to veer to the right at the beginning of the path and then smoothly curve to the end point. y radius = 1cm.141592654. Two useful constants are e. A loop can be realized by "\foreach ⟨variable⟩ in {⟨list of “very near start” for “pos=0. The trigono- line.in=45]" causes the path to leave at an angle of sin(\x r). which is equal to 135 degree at the first coordinate and arrive at an angle 2. end angle= 315]. after the path has been drawn. above (“above” or “an- chor=south”). To place nodes on a line or a curve use the The option “help lines” denotes “fine gray”. “near end” for PGF also has a math engine which enables you to plot “pos=0. start angle= 0.0) arc[x radius = 1. a node is eration to one corner and after “rectangle” the coordinates just some text that is placed at some coordinate.7. “near start” for values⟩} ⟨commands⟩".9 Special curves left (“left” or “anchor=east”). node[<options>](<name>){} coordi- nate[<options>](<name>) 7. ln(\x).875”. Use a move-to op- shape with some text on it. end angle= pect=<aspect ratio>". The last one becomes the new cur- are not part of the path itself.8 Arcs Writing text along a given path using the node command is shown as a simple example: The command “arc” creates a part of a circle or an ellipse: Possible options for the node command are e.y. PGF/TIKZ 143 7. A node is centered at the current coordinate by default. of 45 degree at the second coordinate. 7.75cm.4. Nodes of the diagonal corner. “align=<left_right_center>".). mod(\x.0) arc[radius = 8mm. 270].6 User-defined paths Many functions are possible.) A node is typically a rectangle or circle or another simple For rectangles a special syntax exists.4. In the simplest case. given coordinate: node[<options>](<name>){<text>} 7. “parabola”. “at end” functions: for “pos=1”.4.4.4. Without an option it corresponds to a straight cos(\x). below (“below” or “anchor=north”). like “anchor=north east” or paths. ellipses The "(<name>)" is a name for later reference and it is op- Circles and ellipses paths are defined beginning with their tional.

1)(1.0) node(x) {} (3.5. such that the path starts at the border of the node’s shape and not from the node’s center. The de- line is indicated by double backslash "\\".1) node(y) {}.arrows=->](0. as in \psset{unit=1bp}.144 CHAPTER 7.y1) % . Thus you cannot use the pdftex or pdflatex compilers.y1) Example 3: A Torus You can add as many points as you want to get a polyline: \psline(x0." ordinates of the upper-right corner of the picture. Equivalent to It is also possible to specify the coordinates (x0.2. 7.1) is no need to load it manually.0) and is placed at the refer- at (3. It is still possible to get PDF from PS files thanks to ps2pdf.1). or The xcolor extension gets loaded along PSTricks.<anchor>)".0).. this can be you have to specify the alignment using the node option changed with \psset. \end{pspicture} One can connect nodes using the nodes’ labels as coordi.y1)(x2.1) got the name "(y)". \begin{pspicture}(x0. vironment.1) PSTricks is a set of extensions.y1) \psframe*(x0. Use the fol- However. CREATING GRAPHICS Since nodes are often the only path operation on paths.1 The pspicture environment there are special commands for creating paths containing only a node.2](x0.4..0) got the name "(x)" and the one bottom-left corner is at (0. so there \psline[linearc=0. you can use anchors as defined above relative to (x) as "(x.y0) of the \coordinate (x) at (0. A new Thus the size of the picture is (x1-x0)x(y1-y0). add an arrow as parameter: Example 2 \psline{->}(x0. \coordinate[<options>](<name>) at (<coordinate>). the second without: PSTricks commands are usually placed in a pspicture en- \node[<options>](<name>) at (<coordinate>){<text>}. ence point of the next character in the LaTeX document. you will need to use Rectangles dvips to get your proper document.y0)(x1. if you have installed the package xetex-pstricks. Path construction operations try to be clever. The base package is pstricks. . the first with text ouput. The defined.y0)(x1. Any TeX “align=".y3)…(xn.2 Fundamental objects Once the node x has been defined.0)(2. PSTricks has one technical specification: it uses PostScript internally.2]{->}(0. like "(x.north)".11 Examples \psline(x0.\psframe[framearc=0. Having "\path(0. Lines and polylines A simple line gets printed with 7. The first argument between parentheses specifies the co- nates. which makes \psframe(x0. \coordinate (y) at (3.y0)(x1.yn) Example 4: Some functions To get rounded corners. other packages may be loaded when required. \begin{pspicture}(x1. the node at (0. \end{pspicture} Multiline text can be included inside a node. There is also the possibility to use the PDFTricks extension.y1) Example 1 To get a vector. The starred version prints a filled rectangle. hence the name. lowing parameter to get rounded corners: you can use pstricks with xetex or xelatex without modi.5 PSTricks \psline[linearc=0.y0)(x1. add the following option: 7.5. \draw bottom-left corner: (x) -.y0)(x1.y0)(x1. Here an example: dimension is allowed. 7.y0)(x1.. but additionally fault unit for coordinates is centimeters (cm).0)(2.y1) it feasible to use pdflatex together with PSTricks com- mands.(y).y1) fication of source file.y1) % .1)(1..

.. \pscircle(x.yn) • b.y1) Using the pst-text extension. tr: top center. bl. You can specify parameters: You can provide the anchor of the text which will be at • \psgrid(xmax. And the linearc=0. \uput{distance}[angle](x.0)}{triangle text} \end{pspicture} 7.y){r}{angle1}{angle2} • \psovalbox{text}: oval. will print a symmetric parabola with vertical asymptote.1)(2. Finally.y){text} 7. \rput{angle}(x. a grid all over the pspicture. As for rectangles.0) to the specified coordinate. vertex (x1. Use the showpoints=true option to print the con.5){\psdiabox*[fillcolor=green]{text}} \psparabola(x0.2 (i. \psline: • t. append the starting and • \psshadowbox{text}: shaded rectangle.ymax).ymax): prints a grid from (xmin. PSTricks features several frame style for text. Bl. it is possible to draw a text path. with a spacing of 0.(xn. gin{pspicture}(5.ymin)(xmax. PSTRICKS 145 Polygons Available anchors: Polygons are always closed.5.e.y){r} • \psdblframebox{text}: double rectangle. left and right. br: bottom center. you need to provide center coordinates and radius: • \psframebox{text}: rectangle. For circles.vertical_axis) • \pstribox{text}: triangle. (xmax.5. Example: Curves \rput(5. Arcs have at most 4 control To print a text following a path without printing the path.y){text} Circles.ymin) to (xmax.y1)(x2.. \usepackage{pst-text} % . \psellipse(x.5) \psset{linestyle=none} \ps- textpath{\psline(0. \pspolygon(x0.. the starred version prints a filled poly- gon.y0).ymax). Example: Use \pscurve to print the interpolation of the given points. points.There is also the \uput command with further options: ners.y2).y1) and ending at (x0.y0)(x1.y)(horizontal_axis. the \psgrid command will print to print text.y0)(x1. left and right. arc and ellipses The distance parameter is the distance from the coordi- nate. \rput[t]{45}(5. left and right. ending angles in trigonometric notation: • \pscirclebox{text}: circle. The syntax is the same as for • B. To restrict the drawing to an arc.7.5){text} • \psgrid(xmin.you need to use \psset{linestyle=none}. \pstextpath{shape}{text} Use \psbezier to print a Bézier curve with an arbitrary number of control points. Starred version fills the shape. tl.3 Text Use \rput(x.y){text} 2mm). trol points and the tangents.0)(1. \psarc(x. ellipses: • \psdiabox{text}: diamond.4 Grids Without any parameter.2 option will print rounded cor..ymax): prints a grid from (0. Br: baseline center. \be- The \psecurve command omits the first and the last arcs.5. Provide an angle to rotate the text.

• linestyle=value: value is one of dashed. • linecolor=color: color is as defined by the xcolor- package.linestyle=dashed. diamond* • triangle.5) • diamond. but val.7. • dotstyle=value where value is among: • *: disc Example • o: circle • +.5 Generic parameters graduations.ymin) and (xmax.ymax)..2. then the default unit is used.linecolor=blue} being the intersection.2. • subgriddiv=value: number of subgraduations be- tween two main graduations.linestyle=dashed. dashed. {->} adds arrows on axes. • unit=value • comma lets you use the comma as decimal separa- • xunit=value and yunit=value tor.y0)(xmin. subgriddiv=0.−1)(5. squarre*: starred version is filled.dotted.. • doubleline=true. value is a number with or without unit. dotted.ymax) being the extreme. triangle* Axis • etc.3) \end{pspicture} • griddots=value: the full line of the main graduations is replaced by a dotted line.ymin)(xmax. val- uepos for positive coordinates.ymax) \psaxes(x0. CREATING GRAPHICS • \psgrid(x0. All shapes • gridcolor=color. one of the . • gridlabels=value: size of the label numbers.0)(3. • gridwidth=value.y0).ymin)(xmax.5.5]{->}(0.5.subgridcolor=color: color of gradu- ations and sub-graduations.5) node is at (x0. ueneg specifies the size for negative coordinates.linecolor=blue](0. This is useful for huge graduations (i.ymin)(xmax.subgridwidth=value: width of the lines. If you want to add axes.y0) \psset{linewidth=0. • As for lines.0){1} Options This command also lets you change the default unit for lengths. • subgriddots=value: same as griddots but for sub.ymax): prints a \usepackage{pstricks-add} % grid from (xmin. one of solid. gridlabels=0pt](−1. The value is the number of dots per graduation.x: cross \psgrid[griddots=5. • showpoints=true: highlights points. • square. use the pstricks-add extension For example with the following commands: \pscircle[linewidth=0.146 CHAPTER 7. This changes the scale of the drawings. • ticklinestyle=value: self-explanatory. • Dx=value and Dy=value defines the spacing be- tween graduations.−1)(5.y0)(xmin. \begin{pspicture}(−1. • ticksize=value: self-explanatory. (x0.0){1} \psaxes(xmin.Dy=0. ticksize is high). but will not change the width of Example lines.e. . \psaxes[comma.ymax) To apply parameters globally: (xmin. • linewidth=value: if value is without unit. \pscircle(0.Dx=0. • ticksize=valueneg valuepos: same as above.ymin) to (xmax. value may be • dotscale=value specifies the size of the points. These are to be added between square brackets.

y0)(xoffset. vlines. crosshatch*. you can use the \mul- • *: centered disk.0){1} \documentclass{article} \usepackage{pdftricks} \begin{psinputs} \usepackage{pstricks} \usepack- age{multido} \end{psinputs} % .5) \psline{->}(0.0)(10.. yoffset){times}{object} • |*: centered bar. \begin{document} 7.5.] \end{pspicture} The \rput and \uput commands can be used to move any \end{pdfpic} % . • fillstyle=value: pattern. tips command: \multips(x0. vlines*. hlines*. There is a decent list of available symbols.1)} \end{pspicture} You can define the extreme of an open shape (line.. It is required for PDFTricks to run.fillstyle=vlines](0. • Declare the PDFTricks packages in the preamble. vironment.0)(1. tips{angle}(x0.yoffset){times}{object} • cc: rounded extreme.y0)(xoffset. arc. The -shell-escape parameter enables shell command calls.. • c: centered rounded extreme. \multirput(x0. yoff- • o: centered circle.y0)(xoffset. Example Example: \pscircle[hatchcolor=blue.10) [. \multirput[reference]{angle}(x0. • hatchangle=value.y0)(x1.7 The PDFTricks extension Example: \psline{|->>}(x0.1) \psline{- >}(1. Closed shapes Usage For closed shape you may define the fillstyle. You can use the same options as for \rput: • oo: circle. set){times}{object} • **: disk. • << or >>: double arrow. You can repeat the operation with \multirput: • |: bar. Another way to use PSTricks with pdflatex is the pst-pdf Example package.1) \rput(1.. etc.. poly- line.2) \end{pspicture} • < or >: arrow.6 Object location % .y0)(xoffset. • hatchcolor=color.1){\psline{->}(0. PSTRICKS 147 Open shapes \begin{pspicture}(5. hlines. • Compile with pdflatex -shell-escape <file>. With no text but with graphics only. \end{document} object. but thankfully PDFTricks allows us to bypass this limitation. \begin{pspicture}(5. • Place all PSTricks extensions in a psinputs environ- ment.. • hatchsep=value. \begin{pdfpic} \psset{unit=\linewidth} \be- gin{pspicture}(0.) with an optional parameter {symbol1- or symbol2}.1)(2. • hatchwidth=value.7.0)(1. Possible values: crosshatch. .y1) The original PSTricks package does not work with pdfla- tex. 7.5) \psline{->}(0.5..5.0)(1. solid. yoffset){times}{object} \mul- • |< or >|: arrow plus bar.. place all PSTricks commands in a pdfpic en- • fillcolor=color.

In some situations. Xy-pic offers many ways to influence the drawing of curves. In fact. there is basic functionality in the PGF/TikZ package. suitable for developing the kind of diagrams discussed here. To make this matrix a diagram we just add directed arrows using the \ar command. for more information. where “all” means you want to load a large standard set of functions from Xy-pic.6 Xy-pic that are covered by other surfaces and should be excluded from the rendered image. we use the common su- perscript and subscript operators.. just use more than one direction. we specified two lines and two columns. check the Xy- pic documentation..solides3d package. use \ar[. the vertical bar: | It causes text to be placed in the arrow. although drawing 3D graphics with PGF/TikZ is very non-flexible. There is a third operator. mainly because it lacks functionality for identifying the surfaces . As shown. and subscript means “under the arrow”. down. To make diagonals. If you are interested in a more thorough introduction then consult the Xy-pic Home Page.7 Creating 3D graphics For creating three-dimensional graphics. 7. To use it. The only difference is that that superscript means “on top of the arrow”. you use these operators as in math mode. The arguments are the direction the arrow should point to (up.]|\hole. right and left). you can repeat directions to make bigger arrows. CREATING GRAPHICS 7. We can draw even more interesting diagrams by adding labels to the arrows. it is important to distinguish between dif- ferent types of arrows. which contains links to several other tutorials as well as the reference documen- tation. ument: Another way to create 3D graphics is to use Asymptote. To draw an arrow with a hole in it. where each diagram element is placed in a matrix slot: The \xymatrix command must be used in math mode. Here. To do this. This can be done by putting labels on them. The primary way to draw Xy-pic diagrams is over a matrix-oriented canvas. xy is a special package for drawing diagrams.148 CHAPTER 7. The arrow command is placed on the origin cell for the arrow. A package that can handle this correctly is the pst- simply add the following line to the preamble of your doc. or changing their appearance Notice the difference between the following two dia- grams: The modifiers between the slashes define how the curves are drawn. \usepackage[all]{xy} Yet another way to create 3D graphics is to use Sketch.

programming. If you wanted to use more vectors to look differently you just have to change the than one argument. and the definition of the command. mand. the command requires two argu- ments: the name of the command you want to create. then all on Plain TeX and will explain advanced techniques for of the arguments are required.. It uses the same syntax as the \newcommand com- make them easy to read and pleasant to look at. no argument allowed. these arguments are definition of your \myvec{. use #2 and so on. nore the new command. If missing it defaults to 0. In this chapter. people like to add an arrow over it ( ⃗a ).1 Macros digits cannot be used to name macros — invalid charac- ters will error out at compile-time. Documents produced with the commands you have LaTeX will not allow you to create a new command that learned up to this point will look acceptable to a large would overwrite an existing one.e. LaTeX will silently ig- meet your requirements. Let us assume you want to write your vectors idea. then add the following line in \wbal that will print “The Wikibook about LaTeX”. ever you can: this will save you a lot of time and increase Name your new command \wbalTwo and not \wbal2 as the consistency of your document. we will try to give some hints on how to With LaTex2e. or command command. Then. Such your mystyle. some takes (up to 9 are possible). used in many books.1 New commands Note When the command is used with an explicit first parameter it is given enclosed with brackets (here To add your own commands. The first example defines a new command called with an arrow over them. use the "[lots of users]"). but you'd better choose The next example illustrates how to define a new com.. 8. as Here is a common example: if you are writing a book you like. you have and specifies the number of arguments the new command to decide how they will look. another common version is to write it The following two examples should help you to get the bold (a).1.sty. there are situations where LaTeX does not provide In certain cases you might also want to use the \provide- a command or environment that matches your needs. Basically. But there is a special audience. i.. How. ever.} com- mand. If the default parameter of \newcommand is present. Use this approach when- added in an extra set of brackets. The #1 tag gets replaced ten. Note that the com- mand name can but need not be enclosed in braces. The num argument in square brackets is optionalabout Mathematics and you have to use vectors. and write your vectors inside the new \myvec{. There are several different standards. You can call it as you wish. The next chapter will focus optional with a default value of default.. While they are not fancy-looking. if you change your mind and you want your by the argument you specify. command. a command could come in handy if you had to write the title of this book over and over again.Chapter 8 Programming 8. they obey command in case you explicitly want this: \renewcom- all the established rules of good typesetting. other people write it underlined (a). which will mand. 149 . It works like \newcommand. it is also possible to add a default param- teach LaTeX new tricks and how to make it produce out- eter to a command with the following syntax: put that looks different from what is provided by default.}.a short name because you will probably write it very of- mand that takes one argument. If a is a vector. but if the output produced by some existing command may not the command is already defined. then LaTeX is a fairly high-level language compared to Plain the first of the number of arguments specified by num is TeX and thus is more limited. if absent.

which can potentially mand. If you ever The calc package provides the common infix notation. well as the one on the following paragraph.6 Conditionals LaTeX can use conditionals thanks to the ifthen package. you can use the \renewenvironment command.Let’s provide a simple example : gument gets processed when the \end{name} command (which ends the environment) is encountered. PROGRAMMING DeclareRobustCommand 8. In the fol- clareRobustCommand{\MyCommand}.3 Declare commands within new envi- ronment Some commands are fragile. The example below illustrates the usage of the \newenvi- ronment command: 8. With the 8. make sure there is no space • extracting substrings between the beginning. From CTAN: Also. 8. title environment which suppresses its own indentation as you may instead use the pgffor package directly. The end block is a bit more tricky as special pro- cessing occurs at the end of an environment. will make it ignore any space after executing the begin block. example) a figure caption.The xkeyval packages will let you define key/value op- ronment command uses the following syntax: tions for commands. The material in the after ar. lowing example.5 Arithmetic The num argument is used the same way as in the \new- command command. want to change an existing environment. produce text that is written to a .1. you can use the fp[2] the \newenvironment command. with a nested command: panded. It uses the same syntax as For high-precision computations. if you're still having problems with extra space be- • testing a string’s contents ing appended at the end of your environment when using the \input for external source.haustive. a new environment is declared along ble. the following error message will be thrown: ! Illegal parameter number in definition of \topics. and end of the environ- ment. the arguments passed to the \topics macro are defined with a single # character. define an environment that already exists. when ex. declaration with \De.2 New environments 8.1. The package is quite complete and documentation is ex- When the \begin{name} command (which starts the en.4 Extending the number of arguments Just as with the \newcommand command.1.. If. The \newenvi. [1] vironment gets processed.. have fatal effects. For example when you want to create a If you are only using \foreach and not drawing graphics.8 Strings \ignorespacesafterend LaTeX will issue an \ignorespaces after the special ‘end’ processing has occurred. the material specified in the it.1.aux file. We recommend that package developers read vironment) is encountered. The \ignores- paces command in the begin block of the environment Alternatively you can check out the multido package. If a macro works in body text but not in (for New commands can be declared within newenvironment. Again \newenvironment can have an optional argument. their arguments by doubling the # character.1.1. package. LaTeX makes sure that you do not LaTeX can manipulate numbers. Extra space 8. xstring provides a lot of features.. by mistake.150 CHAPTER 8. sourcing.7 Loops When creating a new environment you may easily get The PGF/TikZ extension provides the \foreach com- bitten by extra spaces creeping in. that is they fail in some en- vironments. there is a com- mand to create your own environments..1. 8. it’s worth trying to replace the Commands declared within the newenvironment refer to \newcommand{\MyCommand}. in the pream. such as: • substitution of substrings or • string length . This is especially true for macros which. before argument is processed before the text in the en.

8.2. 8.com [2] ctan. but we hope that it will do it for now. in classic TeX. • A primitive is a command that is hard coded in the TeX engine. para- the actual file is read with input. See Counters. you might be using Make. you can use the full Plain TeX Examples: language within a valid LaTeX document whereas the op- posite is false. etc. are limited in numbers (256 for each type of register files or any kind of script to build your LaTeX projects.8. of commands that will be executed when \be- gin{document} is met. These hooks can be called several times. according to its type. i. or a group. By setting \blackand. The is not printed as is.1 Vocabulary To avoid confusion it seems necessary to explain some • \AtBeginDocument will let you specify a set terms.9 LaTeX Hooks LaTeX provide two hooks: 8. \ is used to in- you are using every day have been implemented with so troduce a control sequence. a control sequence. • A glue is a certain amount of space that is put be- tween boxes when they are being concatenated.1.2 Catcodes While you play with LaTeX macros. it has much more capabilities at the cost • number of recurrences of a substring of a steep learning curve and complex programming. 8. Now you can call LaTeX like this: See Fonts. . graphs. structure to your document: • A font is a control sequence that refers to a font file. [1] tex. It can be useful to override settings that get executed after the • A control sequence is anything that begins with a \. See Lengths. latex '\providecommand{\blackandwhite}{true}\input{test.10 Command-line LaTeX • A register is the TeX way to handle variables. They If you work on a Unix-like OS.stackexchange. it is not written in Plain TeX.1. Creating Packages. See control sequences. \end{document}. you will notice that it In TeX some characters have a special meaning that is not is quite limited. white to false the color version of the document would be produced. and will not print a backslash little. In that connection it might be interesting to produce dif- ferent versions of the same document by calling LaTeX • A length is a control sequence that contains a length with command-line parameters. You may wonder how all these packages to print the associated glyph. let’s replace the page numbers with old- stylenums: • A command (or function or macro) is a control se- quence that may expand to text. • A group is everything after an opening brace and • \AtEndDocument does the same for before the matching closing brace. It preamble.. See Boxes.tex}' • A box is an object that is made for printing.mackichan.e. • A token is a character. to (re)definition of There are also hooks for classes and packages. 32767 in e-TeX).2. pages.com There may be more terms. 8.11 Notes and References • A counter is a register containing a number. For instance. This gives you some more flexiblity for macros. If you add the following (a number followed by a unit).2. Any- First the command \blackandwhite gets defined and then thing that ends on the paper is a box: letters. Up to a few exceptions.1.. Plain TeX is much more low-level. For example.2 Plain TeX 8. PLAIN TEX 151 • position of a substring most packages use Plain TeX code. it is expanded by the TeX engine commands will be executed in the order they were set. LaTeX is a set of Plain TeX macros and by default. In fact.

you must enclose all the commands accessing private func- However. and #2 matches the first token only. let you change the category code of any characters. In Plain TeX.Solution: add a second separator. as it can make code difficult to read. \makeatletter vious. make sure to revert it back at the just changing the catcode: end of your file. the primitives for macro definition make no Note that an active character needs to be directly followed check on possible shadowing. LaTeX ample. We added the parentheses just ference: all functions are introduced with a @ instead of to highlight the issue here. Itemize If you do not want to play with separators. All they do is class or in a style file. This is not by chance: it actually uses TeX to print possible input sequence that matches the macro defini- the PDF version of the files. i. The syntax is Examples You can use (almost) any sequence of character between arguments.makes use of the catcode to specify a rule: all non-public. What it basically does is in. everytime you expect several parame- ters with specific separators. Thus #1 matches all characters putting texinfo. you are not breaking anything. you may be better off to change the math shift character. Possible implementation: i. think out the last separator. If you redefine catcodes in your document. the '@' should now introduce ev. Macro expansion is not always ob- have encountered those two commands. TeX has another definition command: \edef. That’s why when you need to access LaTeX internals. since there is a \catcode function that will '@' to 12. TeX split them into category codes. A space may seem con- ery command. In the document. This will print (123. LaTeX changes the catcode of language itself.gets shadowed by the new definition. The syntax remains the same: The content gets expanded (but not executed. Example: In TeX the '@' characters belongs to catcode 11 letters by Here the redefinition of \intro will have no effect on \ex- default. this is not recommended.152 CHAPTER 8. otherwise the compilation will fail. There are 16 category codes in TeX. As a general rule. 8. printed) \makeatletter and \makeatother at the point where \edef is used. They check that no existing command Active characters resemble macros: they are single char. and \makeatother. others. For instance let’s write a simple macro that Texinfo will convert the decimal separator from point to comma. It means you can use it for macro names. since there is no separator after it. make sure to do it after the preamble to prevent clashes with package loading. the first character. Each parameter is the shortest a \. With this redefinition.tex which redefines the control sequence up to the first point. which stands for expanded def. character. while the '\' will actually print a backslash venient: character. or catcodes for internal macros that are not supposed to be accessed by short. First try: Texinfo uses a syntax similar to TeX with one major dif.e. tion. Here is a quick way to define a wiki-like itemize: Dollar and math Expanded definitions If you have many 'dollar' symbols to print. . Should you redefine any catcode in a tions with \makeatletter and \makeatother. then Plain TeX macros are used just as LaTeX macros (without default Some may find the LaTeX syntax of list environments a parameter): bit cumbersome. the end-user contains at least one '@' character in their A powerful feature of TeX is its ability to redefine the name. It’s up to you to make sure by a definition. instead of where the de- If you have done a bit of LaTeX hacking. separators included. PROGRAMMING To distinguish between different meanings of the charac. you must fined macro is used.2.e. acters that will expand before any other command..3 Plain TeX macros Active characters \newcommand and \renewcommand are LaTeX-specific control sequences.4)56. ters..

2. The last line will print a sentence depending on the \status. \let<csname><token> is the same as \ex- pandafter\def\expandafter<csname>\expandafter{<content>}.4 Registers • skipped conditional • . The token is usually another • \box255 is used for the contents of a page control sequence. List of reserved registers: It defines a new control sequence name which is equiva- lent to the specified token. PLAIN TEX 153 Global definitions Special control sequence name Definitions are limited to their scope. They are limited in numbers.. • \muskip0-\muskip9 . This is what we call global definitions. after that TeX • \count255 processes the <token1><token2>. For instance the following code will fail: Outer macros are not allowed to appear in: Example: • macro parameters 8. It is useful to consolidate macros and make • lengths them less error-prone because of bad contexts. This command actually does the opposite of \string which Both commands have a shortcut: prints a control sequence name without expanding it: • \gdef for \global\def Controlling expansion • \xdef for \global\edef \expandafter{token1}{token2} will expand token2 be- fore token1.or double line breaks. text containing gets expanded in an \edef. • \count0-\count9 are used for page numbering Note that \let will expand the token one time only... This is the case of macros whose name that remain valid outside the group. • \dimen0-\dimen9 turelet allows you to assign a token while using it right after. ranging from 0 to 255. Example: the document. sequence. i. • . works a bit dif- ferently. so you would be better off not using them.2. hence • registers the name.8. So \fu. It is sometimes needed when token2 expan- Long definitions sion is desired but cannot happen because of token1. con- trary to \edef which will expand recursively until no fur- ther expansion is possible... There are 6 different types: let and futurelet TeX uses some registers internally.. You can also use the \global command with \edef. • catcodes Example: • chardef Outer definitions • font parameters This prefix macro prevent definitions from being used in • internal parameters some context..e. The previous definition commands would not allow you \noexpand is useful to have fine grained control over what to use them over multiple paragraphs. Outer macros are meant to be used outside of any context.. Example: the \par command -. Scratch registers (freely available): Example[1] : • \box0-\box254 \futurelet<csname><token1><token2>. \the control sequence will let you see the content of vari- You can prefix the definition with the \long command to ous TeX types: allow multi-paragraph arguments. and until the end of is made up of macro names. Registers are kind of typed variables. However it might Some macros may have a name that is not directly be convenient sometimes to define a macro inside a group writable as is. token2 is assigned to csname.

other- wise every call to the macro would reserve another regis. With this self de- fined conditionals you can control the output of your code in an elegant way.. You can print a register using the \the command.2. Note that it starts at 0. dimen. 8. The \relax prevents undesired behaviour if a plus or a mi- Example: nus is encounter after the command. Example: These commands can not be used inside macros. Note that there is no false action. If number is equal to the case number. Self defined conditionals You can create new conditionals (as a kind of boolean 8. you have to change the condition or to define a new conditional using \newif. The three main functions: register may be of type count.2.154 CHAPTER 8.\else<defaultcase>\fi. features. use the \setbox command instead. It does not make sense for box nor toks. the previous cases have matched).5 Arithmetic of what you want. muskip or skip. The charcode is actually the byte value. you cannot put an \else between \if* and \repeat. tents. its content will be You may use one of the following reservation macro to printed..You can define control sequence to expand to a tional.8. ber><case0>\or<case1>\or. There is two commands for that: \relax and \empty. For sion for group A the other one for the rest of people (i. content and true action are arbitrary TeX con- use the \box command. al- though this base suffice to extend it to some interesting The above code will print TeX ten times. A- 1. The best way to illustrate the use of char conditionals is through an example. some replace the non-printable characters from variable). PROGRAMMING • \skip0-\skip9 Case statement Assign register using the '=' control character.command. One ver. The base syntax is Classic example: where \if* is one command among the following. The syntax is \chardef<control se- 3. \if* refers to any of the conditionals.g. ASCII. In some case this will be the opposite 8. For boxes As always. We can print all characters using the \char {charcode} Two versions of a document must be generated.8 Doing nothing Sometimes it may be useful to tell TeX that you want to 8. example not belonging to group A): Most characters correspond to the ASCII value (e. 2.e.2.6 Conditionals do nothing. For The base syntax is counters use the \number command instead.2. We use \newif to define our conditional (i. A full example is: Example: .2.e. The following sequences do the if control structure. Example: The arithmetic capabilities of TeX are very limited.9 TeX characters variables) with the \newif command. In the following way we set a value (true or false) for our conditional that is: chardef and mathchardef depending on which value we want to set in our condi. For box The syntax is \ifcase <num- registers. Now we can use our conditional anywhere after in an quence>=<charcode>. boolean Za-z). The difference between \empty and \relax lies in the ex- pansion: \empty disappears after macro expansion. prevent any clash: \else is used to specify the default case (whenever none of These macros use the following syntax: \new*<csname>. specific char.7 Loops ter. same thing.

The final code is Let’s define a macros that will define language commands for instance. This can be done with and make sure it switches to the appropriate Babel lan. i. with different fonts.are very similar. \#1 gets expanded to two tokens: '#' and '1'.8.2.e.latex '\providecommand\locale{en}\input{mydocument. However provides some commands to preserve the spacing and newlines as you wrote it: will fail because it will redefine \csname to '#1'. it is a good idea to create a LaTeX package name is a variable? In most programming languages that’s or class containing all your command and environment not possible at all. 8. we guage commands as explained in Multilingual versions.\endcsname is used for. and your command: We need to delay the expansion of \def. must be able to set the \locale variable so that the one in where the end user can write the source code is the default value that can be overridden by the one in the command line. it does nothing.. for example to define lan. • The TeXbook.sty files. It will expand {token2} be- 8.3 Creating Packages Since it is hardly possible to write it in LaTeX. They 1. but they get expanded to load only one class per document. Abrahams.2. own verbatim environment. what we want to do is extremely simple: define a bunch of macros like this: [1] From tex.. Think this out.And you can compile with ment is the value of the \locale variable.12 Notes and References Basically. we will use some Plain TeX. This is whitespace as the same type of spacing glue. one entry per line: sequence name.tex}' sponding macro prints its content directly. Berry and Kathryn A. which will 8. . CREATING PACKAGES 155 Font encoding map the \localedef macro first argument because they are in the body of that macro. but that’s not convenient and it makes it impossible to choose the Babel language • TeX by Topic. The solution to problem 1 is simple: use '##1'. Classes are . the main difference being that you can ments of the new macro. Victor Eijkhout from command line. In Another problem arises: how to define a command whose this situation. If you define a lot of new environments and commands. packages are stored in .\providecommand: guage.11 Macros defining macros fore {token1}.stackexchange. • TeX for the Impatient. then to ap- ply \def on it. Karl What we are going to do is to define the language com.. the preamble of your document will get quite long. Hargreaves mands dynamically following the value of the \locale vari- able (or any variable of your choice). 8. The two last '#1' are supposed to refer to the argu. That’s what we want. \en and \fr will print nothing at all. to and then in your tex file: tell tex to expand the \csname stuff first.com: What is the difference be- In the previous snippet of code.. your future documents. It can be made dynamic enough to fit to all It will fail for two reasons. The problem arises when Further reading you want to automate the task.3. It is possible to It is rather confusing to discover (La)TeX treats all tell tex that a specific token is a control sequence. Hence the use of the \equal command from the ifthen package.2. which is not what we want. which means that you will probably need to combine your which will result in an error. Donald Knuth You just have to move the #1. There is a command for that: \ex- pandafter{token1}{token2}. then the corre. and you want to change the language selection.10 Verbatim lines and spaces expand to '#1' when the macro is executed. it is a little bit tricky. only the \de command in tween \let and \edef? going to output its content. What we could be tempted to write is definitions. We can use the above primitive to print the font encoding 2. Otherwise. Paul W. or if you have a lot of languages.cls files. For problem 2.Finally if we want to set language from command line. then tex will encounter \endcsname. Plain TeX what the \csname. and the map. \def command will fail as it requires a valid control Another version. These commands are simple: if the argu. This is useful in some case.

. it is possible to place the 8.3 Creating your own class Your package can be made available in your document It is also possible to create your own class file. • \LoadClass specifies the unique parent class.} specifies which version of • \ProvidesClass is the counterpart of \ProvidesPack- TeX or LaTeX is required at least to run your pack. self. either to protect your mand \usepackage{mypack}. • \DeclareOptions are end-user parameters. LaTeX source you are compiling must be in the same di- rectory.156 CHAPTER 8. • \AtEndOfClass • \ProcessOptions\relax terminates the option pro.3. Actually . we can use it in any doc- should think about which license the package/class has. For a more convenient use. • Write whatever you want in it using all the LaTeX commands you know. Each op- tion is declared by one such command. Let’s write Let’s write a first custom. but without it needing to needed in package or class files. Normally you should define 8. of visual customization offered by the system. By default. be kept updated while developing a package. but not from within an end-user document. thus making it avail- duo \makeatletter and \makeatother. • Next you may write some TeX or LaTeX code like loading package. ble from packages only. you Once your package is ready. This way it is $TEXMFHOME/tex/latex/custom/custom. cessing. age. Version information should in the TeX compiler output. • \PassOptionsToClass and \PassOptionsToPackage are used to automatically invoke the corresponding options when the class or the package is loaded. i. 8.3. if any. cess is similar to the creation of your own package. you mand. be in the same directory as your document.sty file as an example package: a simple example: • \NeedsTeXFormat{. The <version> should begin with a date in the • \ClassWarning will show the corresponding message format YYYY/MM/DD.3. • \AtEndOfPackage • \ExecuteOptions{.1 makeatletter and makeatother package within $TEXMFHOME (which is ~/texmf by default) according to the TeX Directory Structure (TDS). These commands able for use for any document. Newcomers to LaTeX often feel disappointed by the lack • \endinput: this must be the last command.2 Creating your own package 8.4 Themes new commands or import other packages.On Windows '~' is often C:\Users\username. or to make it available for others. <name> • \DeclareOption*: the starred version lets you handle should be identical to the basename of the file it. There are also hooks for classes and packages..They behave as the document hooks.. It will allow you to use only make sense in a regular document.sty possible to protect commands.3. non-implemented options. they are not your package as detailed above. Writing a package basically consists of copying can call your own style file in the preamble of any docu- the contents of your document preamble into a separate ment by the command: file with a name ending in . but write only the bare minimum needed for the package options set below. The pro- just like any other package: using the \usepackage com. The optional date may be used to specify the version more precisely. to make them accessi.4 Hooks • \RequirePackage is equivalent to \usepackage.cls. See LaTeX Hooks. 8. ument.sty. LaTeX will allow the use of the '@' characters That would be for control sequences from within package and class files.. The name of the class file is then myclass. You may have to run texhash (or equivalent) to make your However it is possible to override this security with the TeX distribution index the new file. • \ProvidesPackage{<name>}[<version>] A package introduces itself using this command. The file custom.e.sty and the file. PROGRAMMING After deciding to create an own package or class. age.} tells which are the default. Import your new package with the known com- A license is of great importance.

this is absolutely not a model of typography. We define a color option. THEMES 157 this is done on purpose: the LaTeX philosophy takes a point at doing the formatting while the writer focuses on the content.3 Header and footer • Custom theme (TOC) We use TikZ to draw a filled semicircle. This is more a technogical example to exhibit LaTeX capabilities.1 Introduction In the following we will write the theme.4. In this chapter. 8.4 Table of contents We redefine commands used by \tableofcontents. Defining colors with specific names makes it very flexible.4. 8. so that • Custom theme our document will work with or without the theme. We enclose the com- • Custom theme mand in a group where we set a font size since the space we need is \baselineskip which depends on the font size.4. fancyhdr is used to set header and footer. • needspace is used to prevent page break right after a sectioning command. (red) Note that if it may look eye-candy.5 Sectioning This is definitely the most complex part. We load the required packages.2 Package configuration Nothing much to say here.4. We use \needspace to make sure there is no line break right after a sectioning command. we will show what we can achieve with some efforts. It is not that hard since the code is almost the same for \section. We also use an option to toggle the fancy reflec- tion effect which might be a little too much! 8. • tikz is used to draw the fancy material. 8. 8.4. \subsection and \subsubsection.8. This is a direct application of the Creating Packages chapter. You should not use such theme for serious publications.4. We take care of using the fancy style and to start from scratch by erasing the previous header and footer with \fancyhf{}. a package that will only change the appearance of the document. . you may use as much as you want.

We make sure to end the section printing by a \par command to make sure following text gets printed properly.158 CHAPTER 8. To handle the PDF bookmarks properly we need the fol- lowing lines at the end of the definitions. Finally. PROGRAMMING Starred commands will not set the counters (LaTeX de- tault behaviour).4. since we define and use the \sectionmark- star command. so we call the \sectionmark command. for \section only. We preceed the section printing by a \noindent. Here we changed the behaviour of the starred command over the original LaTeX version. 8. You can choose to handle starred com- mand differently by resetting the counters for instance. we want it to print in the header.6 Notes and References . For \subsection we make use of the mirrors option to change the appearance accordingly.

/document. This is one of the main reasons why LaTeX but you can use the name you prefer) and your own is so good for serious writing! You will thus be dealing package (for example mystyle.2 Getting LaTeX to process multiple a file which contains one or more \input commands. i.sty . If you followed all those steps. create your document (we'll call it document. You can. allows you to call files which themselves call other files. is kept largely separate from format- 3.tex and processes its content in accordance 2. choose base file and write the contents using \input or \include in short names./mystyle. this second file solely with text and very basic commands such as \sec- will help you to keep the code cleaner. keeping a good high-level structure.\include{filename} ument is almost finished. or a full-length force a page break (which makes it ideal for a book’s 159 . Comparing the methods: input vs include 9. however. one for with the formatting commands specified in the base file. nearly!). This means that the important part of your working pro- cess. the other one for images./img/ ways. Since This way you can put all the formatting options in your you'll have to write their name quite often. create a directory only for the project. differs from the first in some important . but you might take inspiration from that to create your own document. These are all just suggestions. \include 9.tex.1 Project structure The differences between these two ways to include files is explained below.with just another kind of complexity! wieldy and confusing. these files should be in The second method of including a file.sty). LaTeX documents. Your document will be uncluttered and much easier to work with. on the other hand.e. but the question is: I want to rate . What they have in common is that Create a clear structure of the whole project this way: they process the contents of filename. ting choices. discrete sections./tex/ . whereas \input. create two other directories inside the root. img.tex file. During this guide we have seen what is possible to do and it makes a lot of sense to write each chapter in a sepa- how this can be achieved. LaTeX makes this very easy thanks to two write a proper text with LaTeX. what to do then? Where commands: should I start from? This is a short step-by-step guide \input{filename} about how to start a document properly. especially if you are writing a long Another important difference is that using \include will article with substantial. writing. A suggestion would be simply tex and the files which contain the actual content of your work. if you are writing a book. \in- your root directory. \emph etc. nothing else. ad infinitum (well.1. using "/" for each directory: clude{filename}. This way it will be very easy to make modifications even when the doc. your LaTeX file can become un. it that in the following parts as the root directory reads filename.Chapter 9 Miscellaneous 9. Please resist the temptation to nest files in this way files simply because the system can do it: you will end up As your work grows. You cannot nest \include statements within a file added via \include. For example. tion. In such cases it is good practice to split your work into several files.tex .1. This is all about organizing your files and using the modular capabilities of LaTeX. We'll refer to and reaches one of the commands \input or \include.tex before continu- ing with the rest of the base file (the file that contains these statements). When the compiler processes your base file 1.1 Modular Documents book.

you refer to the too).tex} Working on discrete parts of your documents has conse- quences for how the base file is compiled.160 CHAPTER 9.and filename with every element specified./documents/useful/foo. Do note./.. A relative path is one producing a full draft or the final version.tex file re- sides./ you refer to example: a directory which is two steps upwards in the filesystem \documentclass{article} \begin{document} %\in- . . called myfiles. inherent in the way in which LaTeX is integrated with modern file systems. however. you would refer to that file by specifying Using different paths \input{. which use backslashes \ in pathnames. not to the directory in which the included (or input) \input{/home/user/documents/useful/foo. are relative to the directory in which the main .tex} with discrete sections. for you. etc. that is the one above the current direc- tory in the file system tree. its full path would be.tex} An absolute path is a full path. OS X and Windows – also feature the UNIX . it will look for it in the same directory. with the figures in each chapter’s folder. they can cause ambiguous behaviour. using absolute paths is inefficient if you are a way which suits your particular set-up. which ensures that your document will be valid across all installations. however. you can in principle refer to any file on your system. in which case relative paths should be used if the compiler on parts of the document to check that an you wish to avoid unnecessary rewriting of path names. and by two dots . in our example of the absolute path above. whereas the \input command does not (which tree. So by . So. (especially standard UNIX notation: with a simple dot . in the file system (or perhaps even on a different server!). which is defined in relation to the current directory./ facil- ity outlined above. LaTeX uses the resolve all the page numbers. an absolute file path is generally used when using \include to read the chapter source into a main La- one has to refer to a file which is quite some way away TeX file in a parent folder. you refer to if you are using bibliographic software such as BiBTeX. previous directory. it is important to note that the paths path./ you refer to the previous directory. a long article \input{. however. you need to include a file which is always kept at a specific When using relative paths within a LaTeX file imported place in your system.tex} file is found. that LaTeX uses \input{/home/user/texfiles/filename.tex} forward slashes / even on Microsoft Windows platforms.. a relative path may simply be a more efficient and writer intended. Writing in turn makes it ideal for use within. by to comment out the command with a percentage sign. you file in the base file. and In practice. page references and You may. too: However.. referring to a file in the current directory. \input{/home/user/texfiles/myfiles/filename. The slash / is used to separate The simplest way to check that one or more of the var- the different components of a pathname: directories and ious components of your work is syntactically robust. This is likely to be an issue if using a folder per chapter. \input{filename./myfiles/filename. Normally LaTeX users only run harddisk). these will be dealt with below./. In such cases. Mac path. If. say. A full run is generally only performed for elegant way of referring to a file. filename.. for . by . in your texfiles directory..tex} This flexibility. which of course are not normally set on a new page). references.tex filename extension is optional. for example. individual chapter is syntactically correct and looks as the Or.tex might have the full Of course.. LaTeX imple- If you had created the directory myfiles for your writing mentations for Windows systems perform this conversion project. MISCELLANEOUS chapters). but if you found it more convenient to put all your files in a sub-directory of your current directory. \input{.tex} When the LaTeX compiler finds a reference to an external Indeed. all commonly used file systems – Linux. need to make your source portable the like will change according to your use of the \input (to another computer or to a different location of your and \include commands. is filenames. One word of warning: do not leave empty spaces in the filenames. could refer to that file relatively. will have exactly the same effect as writing In either case the .. you may refer to it with an absolute by \input or \include. the current directory. using both absolute and relative paths./. When you compile your document./ you refer to the current directory. in our it is invariably necessary to run LaTeX twice or more to case the one which contains the base file. lets you input files in Obviously./filename. Either Compiling the base file leave no spaces or use underscores _ instead.

\documentclass[main.tds. Note that you can have one or more files as the same can be done for parts to appear only if compiled by argument to this command: separate them with a comma.In the main document. It pile sections of a document using the same preamble as provides a means for importing the preamble of child the main document. no spaces. repeating the compiling process as neces.zip from CTAN. Standalone The standalone package is designed for Subfiles The subfiles package provides a way to com.tex file extension: mand{\notinsubfile}[1]{} \begin{document} \re- newcommand{\onlyinsubfile}[1]{} \renewcom- \documentclass{book} \in. page numbers and so on. You can download subfiles. MODULAR DOCUMENTS 161 put{Section_1} %\input{Section_2} %\in. allowing for a flexi- . since it was not included until Separate compilation of child documents TeXLive 2012. Importantly.tex is compiled)} %% from the previous run. The filename should \newcommand{\onlyinsubfile}[1]{#1} \newcom- be written without the .tex ter_1.aux information as possible is compiled (not when chapter1. space characters not permitted \be. Similarly. This package will contain two files subfiles. Move these files to a directory under only the base document can be compiled. the last thing you needed \subfile{filename} to check before sending off to that major journal. plied if the child document is compiled by its \includeonly{filename1.tex]{subfiles} \begin{document} This code would process the base file but only include the %% my chapter 1 content \onlyinsubfile{this only content of the author’s first and fourth chapters (Chap. by defining an “identity” command \newcom- mand{\onlyinsubfile}[1]{#1} in the main document and then overwriting it after \begin{document} using only the files specified between the curly braces will be \renewcommand{\onlyinsubfile}[1]{}.tex]{subfiles} \begin{document} Using \includeonly and end with: Using this command provides more complex. child documents This code will process your base file with the article con- must be loaded as follows: ventions but only the material in the file Section_4.appears if chapter1. before \be.Chapter_4} % compile just \subfile{chapter1} %% more of my document content chapters 1 and 4. the main document. i. If you include the follow- ing command in your preamble. Now you are good to go! main file.sty.1. say.\end{document} gin{document} \include{Chapter_1} % omit the '.tex) looks like: This requires that there are \include commands in the \documentclass{book} \usepackage{subfiles} document which specify these files..tex tive retains as much of the . type in the complete reference. may decide that you work better on individual sections of This still won't make the package available.} own. you would then simply remove all the percentage signs and The child documents must start with the following state- rerun LaTeX. and hence \end{document} more useful possibilities. the package must be loaded as: put{Section_3} \input{Section_4} %\input{Section_5} \usepackage{subfiles} \end{document} Instead of using \input and \include.e.filename2.tex is compiled (not when main.is compiled)} \notinsubfile{this only appears if main. However. If that was. There are a few packages available to address this problem.cls A disadvantage of solely using \input and \include is that and subfiles.tex).tex will be processed..mand{\notinsubfile}[1]{#1} %% my document content cludeonly{Chapter_1. Some linux distributions don't have subfiles package in their latex distributions. this alterna. the base document (main. In summary.tex) looks like: \documentclass[main. so messes up your cross-references more of my chapter 1 content %% \end{document} much less than the makeshift suggestion above.9.moving more of the opposite direction than subfiles.. the texhash text and wish to edit and compile those separate from the program must be executed first.It is possible to add parts that will only be ap- gin{document}. the included.tex' extension \include{Chapter_2} \include{Chapter_3} \include{Chapter_4} \end{document} and Chapter 1 (chapter1. ments: sary to resolve all references. you the name subfiles in the path /usr/share/texmf/tex/latex. documents into the main document. If you are using absolute or relative paths to the files.tex and Chapter_4.

several scripts are available The child documents contain.tex. • enable-survey: Activates survey functionalities. the one you will compile.same style you have used. more information in its documentation. so you'll have exactly the tories. The first command is 9.5 The main document document. see the List of (Experimental.1.that file and include it properly.tex) looks like: • another C script flatten \documentclass{book} \usepackage{standalone} \begin{document} %% my document content \in. For a list of several packages you can use.9. etc. The good point of doing this is that you will just gin{document} %% my chapter 1 content %% %% have to add one single \usepackage in your main. so when you will start another document you'll just have to copy Import The import package allows for relative direc. Write at the beginning of the mystyle.g.ument. Moreover. This is the default. the best way is and Chapter 1 (chapter1.sty:let LaTeX work for you. the Creating your own style is very simple: create a file called \subimport command provides this functionality. an article and a presentation). document.} as you would do normally. is and more pages per one page in any layout (e. the package must be loaded as: \usepackage{standalone} Produce a single . package. need to edit it very often because you will be working on .sty (you could name it as you wish.. it • final: Inserts pages.1. See (e.tex Options for key=val (A comma separated list of options using the key = value syntax) Then create a file called document. self having references relative to its own directory. 2 × 3 change the value of all the variables you want. subject to change.g.) Packages section. whenever you have to take a decision about formatting. for example. even if you shouldn't ments.162 CHAPTER 9. the following statements: • a perl script latexpand \documentclass{standalone} % Load any packages needed for this document \begin{document} % Your • a C script flatex document or picture \end{document} • a python version of the script flatex In summary.1. define your own command for it and add it to your mystyle.. While subfiles fails to have a way of a subfile it.sty put{chapter1} %% more of my document content \end{document} Instead of putting all the packages you need at the be- ginning of your document as you could.4 The file mystyle. mystyle. It is capable of inserting entire pages as command \usepackage{. all the info about your style will be within one file. will work like the code you put here would be copied and The package has several options: pasted within your document. this will be the You can also insert pages of several external PDF docu. but it has to end with ". It ).tex doc- more of my chapter 1 content \end{document} ument.main file. If you do so. MISCELLANEOUS ble way to include text or images in multiple documents Several PDFs can be placed table-like on one page. will be very easy to change it if you change your mind. keeping your code much cleaner. See LaTeX/Macros for more details.3 Including complete pdf documents or single pages \ProvidesPackage{mystyle} There is a great package for including full pages of PDF Then add all the packages you want with the standard files: pdfpages. • draft: Does not insert pages.sty”). Options: While writing.sty file: 9. the base document (main.tex from modular documents If you need to produce a single tex file from a modular Child documents are loaded using \input or \include.tex) looks like: to load all the packages you need inside another dummy package called mystyle you will create just for your doc- \documentclass{standalone} % Preamble \be. In the main document. but prints a box and This is actually the beginning of the process of writing a the filename instead.

tex} \input{.2 Collaborative Writing of La- for a report. and as tex directory. To compile • pdfpages package documentation use the command: ./tex/title. them automatically.1 Abstract put{. then your document starts.org/pracjourn/). How rative preparation of LaTeX documents.tex} \input{.org/).tex} %\maketi. If you Other Methods don't want them. 9. It is strongly rec- 9. data.tug. Arne Henningsen that is published in The PracTeX Jour- gin{document} \input{. you can use synchronous collaborative editors like Gobby. so we are improving the “What You See is What You Mean” na. Works like the Bibliography. Most of them have collabora- files in the tex directory so that you can easily edit them.a4paper]{report} \usepack. SVN.tex} \appendix \in. We are separating our text from the structural code. and ta- (and this will likely happen) you will get really confused. but more automated and therefore especially Once you have created your document.2. unless you want to add other files in the box is not a true versioning control system. that is your of LaTeX documents. tle \tableofcontents \listoffigures \listoftables \in- put{.js plots. but this is not going to happen very often. Then the main part of the document is inserted. d3.tex} % Bibliography: \clearpage \input{. think about a short also features a commenting system and article-based name that can fully explain what is inside the file without chat to ease collaboration and review. the code for it will be in a file called ware tools and LaTeX packages to organise the collabo- title. Then tables of contents.tex you won't need useful for beginning LaTeX users. but in the background ter_01./tex/intro. to write it is explained in the Title Creation section. number 3 (http://www. The presented solution is primar- mystyle. separating it into as previous versions. IPython notebooks. such it does not allow you to roll the article back to Now you can write your document. Authorea performs most of the actions A suggestion: do not give your files names like “chap. COLLABORATIVE WRITING OF LATEX DOCUMENTS 163 other files. it will let you save a lot of time as soon as the document gets larger.tex in the folder called tex we created before. try to avoid using (it is built on Git).9. You import the only package you need. • You can use one of the online solutions listed in the there is no text in document. However. Then //subversion.tex} \end{document} Collaborative writing of documents requires a strong syn- chronisation among authors. ShareLatex. i. bles.tex” or “figure_03.6 External Links ommended that you use utf8 encoding (especially if there are users on multiple operating systems collab- • Subfiles package documentation orating) and a stable network (typically wired net- works). In Gobby you can write your documents in collabo- ration with anyone in real time. is different from the one you gave figures. e. As you can see. many files as you want and adding many pictures without getting confused: thanks to the rigid structure you gave • You can use an online collaborative tool built on top to the project. It should look like this (it’s the sample code 9. being ambiguous. nal 2007. It has 2 ture of LaTeX.png”. Drop- to edit it anymore. just comment out those lines. • As the LaTeX system uses plain text. Note: This Wikibook is based on the article Tools for age{graphicx} % put all the other packages here: Collaborative Writing of Scientific LaTeX Documents by \usepackage{mystyle} \usepackage{hyperref} \be. • Standalone package documentation • TitanPad (or other clones of EtherPad).1. such as Authorea or edits clearly. stop for a second. It allows authors to enter LaTeX numbers in file-names: if the numbering LaTeX gives or Markdown via a GUI with mathematical notation. It is in a separate file. This Wikibook describes Here a lot of code expressed in previous sections has been a possible way to organise the collaborative preparation used./tex/myappendix. figure and tables are inserted./tex/mybibliography. All content is rendered to HTML5. but you might easily change it to article or whatever else): TeX Documents \documentclass[12pt.tex: everything is in other Installation chapter.sty (note that in the code it has to be imported ily based on the version control system Subversion (http: without the extension). tion features.2. Then we can see the appendix and finally GB free storage and versioning system. described in this document./tex/conclusions./tex/main_part. • Another option for collaboration is dropbox. Authorea When naming a file.apache. you will be able to keep track of all your of a versioning control system. The Wikibook describes how Subversion can be used together with several other soft- it inserts the title: we don't like the output of \maketitle so we created our own.

Third.g.software has to be installed on a (single) computer with ever. and tage that common users generally do not have to install then check it back in. firewall policy might prevent the version control system from connecting to the internet. University of Kiel. pad/export/xxxx/latest?format=txt" && (latex A comprehensive list of version control systems can be filename.tex) found at Wikipedia. I describe how the collaborative writ. the changes the user made) so that other users can easily ap- author who has modified the document can easily attach ply those changes to their own local files. Sec- In this Wikibook. and describe how we use them. could be that it has to be installed and configured. make changes. our software tools. First. One possibility is to compose documents by in. how can authors synchronise these files? repository to their working copy. However. sion Subversion (SVN) comes as a successor to the popular 9. In this case.Each user has a local working copy of a remote repos- thors are working at the same time on the same document. The learning curve ferent computers with internet connections. authors who are out of the IP address.9. a permanent internet connection is not The collaborative preparation of documents requires a required. Hence. the net- work administrator has to be asked to open the appro- 9. As version con- such as Fossil. home). a document at the same time.tex "http://titanpad. because virtu. one can use a service like DynDNS to be able building cannot use this method to update/commit their to access the server with a static hostname. I present ferent computers (e. the mod- it’s possible to use Google docs and some scripting to ifications cannot be merged automatically. This coordination can be organised in many different Moreover. itory functions similarly to a library in that it permits terchanging e-mail messages. and the user get automatically generated PDFs on Dropbox from has to resolve the conflict by deciding manually which updates on Google Docs. If many authors modify (something like 'z7rSrfrYcH'). Unfortunately. office.ond. Version control systems keep track where 'xxxx' should be replaced by the pad number of all changes in files in a project. where the best way depends on the specific circum- gle user is working on a project. and Mac OS X overcome this problem. So. This method has the advan.2. user checks in (usually with a message summarizing what ally all authors have an e-mail account.2 Introduction priate port. Department of Agricul. SVN operates on a client- server model in which a central server hosts a project There are many ways to interchange documents among repository that users copy and modify locally.2. the document and explain the changes by e-mail as well. How. Mercurial or Git. Hence. Thus. there is a problem when two or more au. Germany).g. (Division of Agricultural Policy.3 Interchanging Documents version control system CVS. generally the file server can be only accessed from permanent internet access. solution for users looking for control and advanced through TCP/IP connections). mon file server.164 CHAPTER 9. The only drawback of a version control system considerable amount of coordination among the authors. Furthermore. which is available in most departments. they can be used from dif- features like branch and merge.2. In this case. of the changes should be kept. commit changes from their own working copy to the repository. this allows the user to easily switch between dif- tural Economics. • With a dedicated Linux box with LaTeX & Dropbox if multiple authors have modified the same line.) It can run changes. (and possibly revoke) all previous modifications. (If this computer has no static within a department. modern MS Windows. The risk of overwriting each others’ modifications can be To set up a SVN version control system.differences between working copy and repository. users can update changes from the So. how can authors access these platforms. the user can track stances. A restrictive will be steeper than that for a web-based solution. MISCELLANEOUS wget -O filename. For instance. on the version control server). This is the definitive trol systems generally communicate over the internet (e. they will have to use another way to on many Unix.4 The Version Control System Subver- gether with their co-authors. The server records all changes a and learn the usage of any extra software. files? Users do not have to install the SVN server software. this Wikibook provides some ideas and hints that will be useful for other LaTeX users who prepare documents to.g. the SVN server eliminated by locking files that are currently edited. the version control system tries to merge all modifications automatically. users to check out the current project. or (re)view the A second possibility is to provide the document on a com. itory. a version control system is useful even if a sin- ways. but . laptop.com/ep/ A third possibility is to use a version control system. this is a convenient way to have a backup of the files ing of LaTeX documents is organised at our department on other computers (e. A repos- authors. The internet is only used for synchronising the files. Authors can also com- ment their modifications so that the co-authors can eas- • You can use a distributed version control system ily understand the workflow of this file.

red-bean.9.sty).bak.g. *.nlo.red-bean. In this sense. (e. Besides the basic SVN tions. because these files are not nec- mon texmf tree in the 'Roots’ tab of the MiKTeX Options. *. Typically. *. Linux users usually use document belongs to the project.ind. *. All LaTeX classes tug. /etc/texmf/web2c/texmf.bst) generally should be hosted in that are not available in the LaTeX distributions of the the repository of the common texmf tree.idx. Its structure complies with the ments) and all pictures that are inserted in the document TeX Directory Structure guidelines (TDS. = $HOME/texmf). *.pdf files). all files that are automatically use this as their personal texmf tree. Furthermore.html. repository has the three directories /trunk.png.g. figuration file (e. *.org/tds/tds. e.bib). by TEXMFHOME BibTeX) editor (e. This is the unique way to ac.lot. *. because most Linux distributions include layouts follow the recommendations of the 'Subversion it. On the other hand. For instance. *. *.cls). for 9.lof.g. All users have a work- nal) co-authors do not have access to the common texmf ing copy of this repository and have configured LaTeX to tree.aut. these files are regularly files have been modified).tex~ files) generally should be users can add the path of the working copy of the com- not under version control. than for writing source code for software.tps. *. and *. *. *. *. we have one repository for files (the main document and possibly some subdocu- a common texmf tree. If a single text interface for common users. *.g. Generally. http://svnbook. installing. essary for compilation and generally do not include addi- If a new class or style file has been added (but not if these tional information.g. /branches. teTeX created or modified during the compilation process (e.prj. our repository Linux system.tex) On our Subversion server. 'file name data base' (FNDB) before they can use these classes and styles.jpg.kilepr. *.bib~. it is important always to use the Subversion client (and not the tools of the local file system) for these actions.html). This feature has been proven very useful. When creating branches and tags. but they could users.com). Often the question arises. because they were bought or developed for the be included in the respective repository. BibTeX data bases (*. configuring.org/tetex/) users can edit their TeX con- *. these are the LaTeX source code (*. and *. Although branching. LaTeX styles.tug. this document). see figure 1). if some (exter- internal use at our department.out. LaTeX styles (*. *. If the project frontend--with KDiff3 for showing complex differences. and BibTeX styles and BibTeX styles (*. 'Refresh FNDB' in the 'General' tab of the MiKTeX Op- cess the repositories on the server. *. because it provides the most usual The most important directory is /trunk.aux.5 Hosting LaTeX files in Subversion presentation at a conference) can be prepared either in an additional subdirectory of /trunk or in a new subdirec- tory of /branches.bbl.toc files) or by the (LaTeX or copy of the common texmf tree (e. we create a tag in the directory /tags so that it is easy to identify the submitted version of the document at a later date.g.ist.2.blg.gls. *. yields two or more different text documents. merging. http://www. and maintaining book' (http://svnbook. there are very good manuals about SVN freely available on the internet (e.org/links. be- cause this saves disk space on the server and it preserves information about the same history of these documents. *. Ad.glo. *.bix. For instance. *. TortoiseSVN client. In this sense. vides LaTeX classes.pdf. all files that are directly mod- Figure 1: Common texmf tree shown in eSvn's Repository ified by the user and that are necessary for compiling the Browser document should be included in the version control sys- tem. COLLABORATIVE WRITING OF LATEX DOCUMENTS 165 a SVN “client” software. all files and subdirec- SVN utilities from the command-line. /trunk con- tains a subdirectory for each text document. *. and Most MS Windows users access the SVN server by the /tags. *. *.sav. there are several Graphical User In. the variable TEXMFHOME to the path of the working *.tigris. Furthermore.org/) *.cnf) and set *. and tagging is less important for writing text documents At our department. the repository contains manuals explaining terface Tools (GUIs) and plug-ins for accessing the SVN the specific LaTeX software solution at our department server (see http://subversion. command-line client. (*. A slightly different version (a branch) of a text document (e. MiKTeX users have to click on the button . project of our department. *.ilg. This repository pro- (*.nav.tmp.snm.2. *. MiKTeX (http://www. ditionally. and *. which files should be put under version control.tcp.g. the users have to update their modified so that conflicts are very likely.g. The Subversion server hosts a separate repository for each com).dvi.ps. *. (http://www.miktex. each SVN is a very simple task. or eSvn--a GUI tories of this text document are in /trunk.log. we run the SVN server on a GNU. When a text document is submitted to a journal or a conference.eps. teTeX users have to ex- ecute texhash.

An example LaTeX code that is formatted accord. Other. all line breaks of this paragraph might change so that most diff tools indicate the entire para- graph as modified. be easily inspected with a single Subversion command or Furthermore.net/) can assist the user in this to pay for these mistakes when they want to compile the task when it is configured to add a vertical line that marks document. wise. Subversion automatically ment. uments by Arne Henningsen that is published (including http://svnbook. so that each line has about 80 characters.g.166 CHAPTER 9.nl/dwdiff. 'effective' and 'ineffective' modifications. but also in .tug. the LaTeX editor Kile tions to the repository. the co-authors have (http://kile.html) are not affected by the positions of line breaks. their LaTeX editors will probably save the files with different newline (end-of-line) characters (http://en. work on the same file. a specific newline character and configure their editor ing the differences between arbitrary versions of the files. 'ineffective' modifications should be avoided.) We find it very useful to introduce the for version control systems but also for all other ways to additional line breaks at logical breaks of the sentence.props.file-portability. both types of modifications.conflicts (see section Interchanging Documents). the probability that the same line In this sense. version control systems allow a very effec- you want to find a sentence in your LaTeX code that you tive quality assurance measure: all authors should crit- have seen in a compiled (DVI. the position of newline character of the author’s operating system line breaks). to use this newline character.g.6 Subversion really makes the If the authors work on different operating sys- difference tems. automatic line creases with the number of modified lines. or PDF) file or on a ically review their own modifications before they com- printout. In this case. we split long sentences into several lines with one or two clicks in a graphical Subversion client. chapter 3).g. number of 'ineffective' modifications: if several authors Therefore. interchange documents among authors. Software tools for comparing text docu. the source code) in The PracTeX Journal 2007. authors should verify that their code can be rather inconvenient to search for (small) differences in compiled flawlessly before they commit their modifica- long lines. it is very important not to change the posi. their out- put is less clear so that modifications are more difficult to track. all users can agree on thors can easily trace the workflow of a project by view.2. Hence. Moreover. The diff tools wdiff (http://www. Sometimes. these tools cannot be used directly with the Subversion command-line switch --diff-cmd. Another alternative is Authors are primarily interested in 'effective' modifica. because it is Furthermore. ments ('diff tools’) generally cannot differentiate between props. (Note: For instance. it to 'native'. because they compare the files line by line. author) into the contents of the file itself (see e.sourceforge. (http://svnbook. Number it is useful to include these information not only as 3 (http://www. MISCELLANEOUS 9.4/svn. com/posts/show/1033). e.org/pracjourn/2007-3/henningsen/). 'inef- wrapping of the users’ LaTeX editors should be turned fective' modifications unnecessarily increase the risk of off and line breaks should be added manually.advanced. To avoid this A great feature of a version control system is that all au. Note that this has an advantage also beyond version control: if Furthermore. but a small wrapper script has to be used (http://textsnippets. the revision number or the last Tools for Collaborative Writing of Scientific LaTeX Doc.is modified by two or more authors at the same time in- tions of line breaks without cause. A reasonable convention is to add a line break after each Figure 2: Reviewing modifications in KDiff3 sentence and start each new sentence in a new line. PS.red-bean.html#svn.wikipedia. type of 'ineffective' modifications. this directive is not only reasonable the 80th column. to add the subversion property 'svn:eol-style' and set tions of the source code that change the compiled docu.com.g.special. Hence. but not in 'ineffective' modifications that have no converts all newline characters of this file to the native impact on the compiled document (e.ghalkes. However. However. a comment in the LaTeX source code. This considerably increases There is also another important reason for reducing the the effort to find and review the 'effective' modifications. because they compare documents word by word. if a single word in the beginning of a paragraph is added or removed. Otherwise.org/software/ wdiff/) and dwdiff (http://os.org/wiki/Newline). tution' that includes dynamic version information ing to these guidelines is the source code of the article about a file (e.gnu.com/en/1. they highlight eol-style).advanced. before a relative clause or a new part of the sentence Subversion has a feature called 'Keyword Substi- starts.red-bean. The differences sentence and screen for these words on the left border of between the user’s working copy and the repository can your editor window. you can easily identify the first few words of this mit them to the repository (see figure 2).

It also has a wrapper script to support version control systems such as the discussed 2. trol. It also supports a mode similar tems to Changebar which adds a bar in the margin.bib file).org/tex-archive/macros/latex/ ences of two LaTeX files inside a generated document. the users can author the TeX files without a strict ing systems. As different versions of JabRef generally line-breaking policy. PS. where each line can span hundreds of characters (such as All users edit our bibliographic data base with the graph- when each line represents a paragraph). The most important directives for collaborative writing of Changebar comes with a script chbar. Many different BibTeX styles can be found on CTAN (http://www. all users can specify this bibliography by only designed with source code in mind. (A similar rule The program DiffPDF can be used to compare two ex- from older times required lines to be at most 80 char. Hence. COLLABORATIVE WRITING OF LATEX DOCUMENTS 167 the (compiled) DVI.) 9. it is built to using the file name (without the full path) --. Use Subversion's diff feature to critically review on the LaTeX Bibliography Styles Database (http://jo.free. Do not change line breaks without good reason.sh which inserts a LaTeX documents with version control systems are sum.ctan.g. can be found. Put only those files under version control that are phies directly modified by the user. by introduc- . we have a common bibliographic data If the users are willing to let go of the built-in diff utility base in the BibTeX format (.ctan. could not display more than this number of charac- ters per line. nowadays it seems OK not to be too strict about the 80-character rule. Turn off automatic line wrapping of your LaTeX ed. Avoid 'ineffective' modifications. or re- (unnamed) postfix stack language that is used in BibTeX naming files and folders that are under revision con- style files (Patashnik 1988). most desired styles can be conveniently as- sembled with custombib/makebst (http://www. When using a ical BibTeX editor JabRef (http://www. The de- fault is that discarded text is marked as red and added Directives for using LaTeX with version control sys. Start each new sentence in a new line. texdiff allows different styles of visualization. La- marised in the following box. This Visualizing diffs in LaTeX: latexdiff and changebar can be achieved with the LaTeX packages svn (http: //www.jabref.ctan.org) and 8. is written to diff. itor. Add a meaningful and descriptive comment when tex-archive/macros/latex/contrib/custom-bib/).org). reports. contrib/svninfo/). Fenn 2006). however this action requires knowledge of the 10.the citation of all relevant sources.7 Managing collaborative bibliogra- 6. An example on how to use Latexdiff in the Terminal. 3.org/tex-archive/macros/latex/contrib/svn/). accept or decline changes. As diff tool that allows convenient views of files with long JabRef is written in Java. or PDF document. The diff tool that comes with SVN was 1).tex and new.text is marked as blue. Latexd- iff comes with a script latexrevise which can be used to 1. Verify that your code can be compiled flawlessly be. and books requires 7.lent tool for citing references and creating bibliographies tory. your modifications before committing them to the irisson.tex > diff. Fur- committing your modifications to the repository. If no suitable BibTeX style repository. (Markey 2005. it runs on all major operat- lines.tex pdflatex diff. At our department.fr/bstdatabase/). save files in a slightly different way (e.org/tex-archive/macros/latex/contrib/svn-multi/). Split long sentences into several lines so that each showing the changes line has about 80-100 characters.no matter be more useful for files of short lines. The tools latexdiff and changebar can visualize differ- svninfo (http://www. There is also a command line tool acters long for the reason that screens at that time comparepdf based on DiffPDF. This makes it easier to see impact of certain changes ctan.ctan.tex are compared and the file visualizing the changes 4. latexdiff old. As such.2. It resides in our of SVN and use diff tools that are local on their worksta.tex # Files old.tex # Create a PDF 5. Other tools.tex new. Subversion. moving.2. they can put to use such tools that are more tailored Subversion') in the subdirectory /bibtex/bib/ (see figure to text documents. or discuss changes with people not custom to LaTeX.org/ 9. BibTeX style files can be created or modified manually.bar in the margin indicating parts that have changed.common texmf tree (see section 'Hosting LaTeX files in tions. Use the Subversion client for copying. or (preferably) svn-multi (http://www. BibTeX is an excel- fore committing your modifications to the reposi.9.isting PDFs visually. such where the user’s working copy of the common texmf tree as Compare It! allows to conveniently compare text files is located. Writing of scientific articles. thermore.

the user can push the Auto button left of JabRef's Pdf field to automatically add the file name of the PDF file.ctan. but extract the relevant entries with JabRef is highly flexible and can be configured in many the Perl script aux2bib (http://www. where the publication is available mon bibliographic data base. ferent tools for one task is rather challenging for infre- ing Options → Set up general fields and adding the word quent users and users that are not familiar with these tools. The usage of three dif- shelf-mark.bib files that solely originate from using different version of JabRef. we specify the default pattern for BibTeX keys so that JabRef can automatically generate keys in our desired 9. For instance. Therefore. we put all PDF files of publications in a specific subdirectory in our file server. This the version control system Subversion. Now. and a file server for the PDF files of copy and where he has it or the name of a library and the publications in the data base. This field can be added in JabRef by select. there would be many differences between different ver- sions of . MISCELLANEOUS ing line breaks at different positions). all users who have access to the file server can open the PDF file of a publication by simply clicking on JabRef's PDF icon. As JabRef saves the BibTeX data base with the native new- line character of the author’s operating system.This wikibook describes a possible way to efficiently tern in the field Default pattern. and LaTeX packages.org/ texlive/) is available both for Unix and MS Windows op- erating systems. Second.g. we consider to implement an in- .tug. First.2.) Second. configuration of JabRef to simplify our work. our users have different LaTeX distributions that provide a different selection of LaTeX packages and different ver- Figure 4: Set up general fields in JabRef sions of some packages. all users should use the same (e. The presented solution is based on the Subversion first author in lower case and the last two digits of the version control system and several other software tools year of the publication (see figure 3). As the TeX Live distribution (http://www. (Currently. Hence.) as delimiter) somewhere Furthermore. we consider to simplify the solution for a com- tion about the location.g. we plan that all users install the same LaTeX distri- bution. or somebody else who has no access to our Figure 3: Specify default key pattern in JabRef common texmf tree. We make the following changes to the default biblio/bibtex/utils/bibtools/aux2bib). cal users. We solve this problem by pro- viding some packages on our common texmf tree. the probability of conflicts would be much higher (see section 'Subversion really makes the difference'). First. This can be done by selecting Options → Pref- erences → Key pattern and modifying the desired pat.org/tex-archive/ details. Otherwise. publisher. If we send the LaTeX source code of a project to a jour- nal. last stable) version of JabRef. Further- more. it would be hard to find the real differences between the compared documents. If a PDF file of a publication is available. we use organise the collaborative preparation of LaTeX docu- [auth:lower{]}{[}shortyear] to get the last name of the ments. the graphical Bib- field can contain the name of the user who has the hard TeX editor JabRef. we do not include our entire bibli- ographic data base.8 Conclusion format. we might recommend our users to switch to this LaTeX distribution in the future. we add the BibTeX field location for informa. where we use the BibTeX key as file name. We inform JabRef about this subdi- rectory by selecting Options → Preferences → External programs and adding the path of the this subdirectory in the field Main PDF directory (see figure 5). However. a book or a copy of an article). the file server can be only accessed by lo- in the line that starts with General: (see figure 4). there are still a few is- sues that can be improved. location (using the semicolon (.168 CHAPTER 9. it is rec- ommended to add the Subversion property 'svn:eol-style' Figure 5: Specify 'Main PDF directory' in JabRef and set it to 'native' (see section 'Subversion really makes the difference'). Currently it is based on as hard copy (e. Third.

or least the access to the PDF files --. Jürgen (2006): Managing citations and your Unix systems for command line tools.3 Export To Other Formats LaTeX page or of a specific part of the page using the LaTeX package preview. Aigaion (http://www. start by making sure you have preview.pdf.org/tex-archive/ type dvipng info/bibtex/tamethebeast/ttb_en. the ate the PostScript version directly (even if it uses inter- stored PDF files are available not only from within the nally a DVI mid-step. and Christian Henning as well as his colleagues for supporting his intention to establish This chapter features a lot of third-party tools.3. them are installed independently of your TeX distribu- tion. and do not implement all the documents. Arne Henningsen thanks Francisco Reinaldo and Géral- dine Henningsen for comments and suggestions that helped him to improve and clarify this paper. BibTeX.org/tex-archive/info/biblio/ bibtex/contrib/doc/btxhak.3. it is often easier with • Fenn. not only in BibTeX format. The B only): to X of BibTeX. • Tools for collaborative paper-writing 9. (Depending on also possible to create PDF from DVI and vice versa.sourceforge. In particular. they do work. http://www. 4. but also in other formats. http://www. Screenshots are useful. It is department. Nonetheless. the Non-LaTeX users of our department might benefit from format you can generate depends upon the formats of the a server-based solution. most of LaTeX and Subversion at their department. the first one to be supported.ctan. Most of these tools are installable using your package manager or portage tree (Unix only). Some tools may already be installed. these by adding further hints or ideas or by providing further so. documents are produced from software that parses and lutions to the problem of collaborative writing of LaTeX interprets the LaTeX files. more recent.1 Tools installation Heymann for many hints and advices regarding LaTeX. http://www. First. which makes the usage of our data base Some LaTeX IDE will give you the possibility to gener- considerably easier for infrequent users.has you can create it straight away.org/pracjourn/2006-4/fenn/. For instance.10 References Mac OS X).net/). The PracTEX Journal.g. Moreover.tug. but it may be possible to make them work on Windows.2. • PDF using pdflatex. the access to doesn't seem logical to create a file with two steps when the server --. ages. but some users might need to be restricted to members of the department. or easily convert DVI and PDF to other document formats.3.2 Preview mode This section describes how to generate a screenshot of a 9. Some tools are Unix-specific (*BSD. GNU/Linux and 9.aigaion. but throughout the world. a web browser. Other formats can be produced.) Even it because.pdf.ctan. Here you will find sections about different for- software packages. bibliography with BibTeX. Karsten 9.net/). LaTeX source can be used to directly on a presentation using you favorite slideware like Pow- generate two formats: erpoint.3. you can obtain the PostScript version using lution only requires a computer with internet access and software which is included in your LaTeX distribution.9. such as RTF (which can All readers are encouraged to contribute to this wikibook be used in Microsoft Word) and HTML. you can check if dvipng is installed and ready to use (Unix • Markey. you can sourceforge. Nicolas (2005): Tame the BeaST. Using this so. It the copy rights of the stored PDF files. Using other software freely available on Internet. e. and can be crucial tools for collaboration with colleagues who do not edit documents 9. However.2. PNG and JPG this bibliographic data base in (other) word processing for PDF). LaTeX → DVI → PS). for ex- ample.9 Acknowledgements with LaTeX. if you want to include a LaTeX generated formula Strictly speaking. Say you want to take a screenshot of . because it should be easier to use images you want to include (EPS for DVI. as you remember from the first chapters. refBASE (http://refbase. • Oren Patashnik. See Installing Extra Pack- • DVI using latex. features available for the primary DVI and PDF outputs. Designing BibTeX styles. and Subversion. EXPORT TO OTHER FORMATS 169 tegrated server solution like WIKINDX (http://wikindx. Version 1.nl/). If you have the choice. Keynote or LibreOffice Impress. because these servers provide the data mats with description about how to get it.

keywords etc.can be opened by a word processor such as LibreOffice sDEVICE=pdfwrite -sOUTPUTFILE=Merged. provided in the pdfjam bundle by D.pdf 2. To merge one or more files. Linux and BSD. or to produce graphics (e. crop and rearrange their pages using an in. This conversion is done -dBATCH 1. a much simpler option is to use the pdfpages package. more precisely. it has some limited support for packages. This program such as varioref.: This package is also very useful to export specific parts to other format.3. some math tion.5 Convert to RTF LaTeX can be converted into an RTF file.ps from PDF you will get also a file called my_file. put several ronments: pages in one physical sheet (pdfnup) and rotate pages (pdf90). ages are not supported.dvi figuration of hyperref package. DVI to PDF Customization of PDF output in XeTeX (setting docu- ment title.dvi ps2pdf myfile.3 Convert to PDF You can also use XeTeX (or. MISCELLANEOUS Another option to check out is pdftk (or PDF toolkit).170 CHAPTER 9. use: π= 12 .3. inclusion of EPS. you won't get any output. and mimicking the behaviour of the LaTeX pro- 3. ∞ which is a command-line tool that can manipulate PDFs √ ∑ (−3)−k in many ways.pdf 3.PDF documents into a LaTeX document which is com- out any of these two.) is done using the con- dvipdfm my_file. See its Wikipedia entry for more details. using Three simple shell scripts using the pdfpages package are PGF/TikZ) and then including them in other documents.pdf 3.3. with the last mac update being from Using Linux gs -dNOPAUSE -sDEVICE=pdfwrite 2001.pdf -dBATCH 1. latex2rtf supports most of the standard implemen- Alternatively. 2k + 1 k=0 pdftk 1.pdf 2.pdf Write this formula in the preview environment: Note the active option in the package declaration and the Using pdfLaTeX Note: If you are merging external preview environment around the equation’s code.options to merge several pdf files (pdfjoin). As well.pdf gram.tations of LaTeX. One advantage of XeTeX over standard LaTeX is support for Unicode and pdflatex my_file modern typography. They include You can also automate the previewing of specific envi. many other pack- may be available in your Linux distribution’s repository. PDF-Shuffler is a small python-gtk applica. will create my_file. which helps the user to merge or split pdf documents typesetting. piled with pdflatex.pdf cat output 123. such as standard formatting. which in turn Using Windows gswin32 -dNOPAUSE . author.pdf Writer or Microsoft Word.pdf. This will produce a PDF containing only the listing con- tent.g. and natbib. XeTeX 9.tables. Firth.ps that you can delete. . which may run on any computer plat- form.g.pdf source.pdf through latex2rtf. XeLaTeX). The program operates by reading the LaTeX -sOUTPUTFILE=Merged. pdf2ps my_file. which works in the same way as pdflatex: it creates a Directly PDF file directly from LaTeX source.dvi want to merge them into one single PDF file you can use the following command-line command. e. teractive and intuitive graphical interface. Another way is to pass through PS generation: 9. With. PNG or JPG graphics. however is only actively supported on Windows. and and rotate.pdf 2.4 Convert to PostScript dvi2ps myfile. the page layout will depend on the shape of the See also Modular Documents source code. You need to have Ghostscript installed: 9. However.pdf Merging PDF from DVI If you have created different PDF documents and you dvi2ps my_file.

The result of this It is sometimes useful to convert LaTeX output to image conversion will create myfile. because the . SVG is a vector format.pdf> [<output. not only restricted to the PDF generated by La- viewer (for example using LaTeX to typeset a formula for TeX source. • SVG can not embed fonts. LaTeX users can compile the LaTeX source pasting into a presentation). HEVEA So vector graphics are usually preferred.svg for a basic conversion. and can For exporting the BibTeX file only. Vector graphics An introduction by the original author was published in TUGboat . PNG an intermediate file which then will be converted to the is a raster format. pdftocairo TeX4ht There is pdftocairo featured in the poppler toolset.ttf or . SVG is not that great. however it is usually pdf2htmlEX [options] <input. pdf2svg .0. There are two families of graphics: 9. This last method makes LaTeXML the SVG big and slow. pdf2htmlEX So SVG is great for drawings and a small amount of text. be rendered using a local .otf font (which will ment.unicode -split 1 .rtf. pdftocairo also supports various raster graphic formats. JPG is a well known raster formats.exe). The Figure 3 of Multiple formats the paper gives different work-flows of publishing HTML online. The command-line version is offered for all platforms. There are many converters to HTML.3. destination format. such as Wikipedia. More technical details can be found on the paper published on TUGboat: Online pub- lishing via pdf2htmlEX HTML / PDF.bbl files are needed to produce the proper output.aux and . So either the font will nonavigation -noinfo -title “MyDocument” MyDocu. If the input LaTeX file con- tains a lot of text which formatting must be pre- latexmlc paper. Some introductions of pdf2htmlEX can be areas. but pdftocairo -svg latexdoc. or all characters must be turned to vector graphics.7 Convert to image formats run before latex2rtf. latex2html only raster graphics are supported. which is straightforward to use.9.tex mostly change the output).html>] not as good as PNG for text. There is still some cases where raster graphics are used: hevea mylatexfile • The target system does not handle vector graphics. Office.3. be used on an example mypaper.pdf output. The Windows version has a bibtex2html GUI (l2rshell. TeX4ht has many options and possible configurations.latin1.tex file: bibtex2html mybibtexfile latex mypaper bibtex mypaper # if you use bibtex la- tex2rtf mypaper Both latex and (if needed) bibtex commands need to be 9.tex will usually result in a reasonable HTML approximation. and then convert the PDF to HTML via erally have sufficient resolution for whole pages or large pdf2htmlEX. This however will not gen- code to PDF. thus do not suffer from quality loss. PDF files. found on its own wiki page. Some of them use • Raster graphics define every pixel explicitly. It is designed as a general PDF to HTML of a PDF (or PS) file using the tools available in a PDF converter.html served. pdf2htmlEX can convert PDF to HTML without losing In some cases it may be sufficient to simply copy a region text or format. latex2html -html_version 4.3.tex --destination=paper. EXPORT TO OTHER FORMATS 171 latex2rtf is simple to use.6 Convert to HTML • Vector graphics can be scaled to any size. which you may open in formats for use in systems that do not support DVI nor many word processors such as Microsoft Word or Libre. htlatex myfile.

— read Tips and Tricks first. you can try a newer version available on Google Code.txt sOutputFile=document. Alternatively DVI or PDF can be converted to PS as de- scribed before.tex extension).jpg -r300 document. The convert command from the ImageMagick suite can convert both DVI and PDF files to PNG. svg=OUTPUT INPUT Most LaTeX distributions come with detex program.8 Convert to plain text Inkscape is able to convert to SVG.dvi | fmt -u what you see on the screen). ImageMagick this is also possible in Windows.ps If the output from detex does not satisfy you.26 -o foo.27/10. X = 32. then the bash script ps2svg. It will ask you which page plain text converter. Once you the justification. You need to convert this.png One can also use dvisvgm. for in- stance. Example: you want to convert. like catdvi. as PNG for example. If you are thinking of converting to plain text for spell- inkscape --export-area-drawing --export-ps=OUTPUT checking or to count words. which strips LaTeX commands. or use HTML GIMP conversion first and then copy text from your browser.detex yourfile > yourfile. This will output Run ghostscript on the PostScript file created by pdf2ps result to standard output. then the size in dpi corresponds to 231. MISCELLANEOUS Direct conversion from PDF to SVG can be done using This value will be passed to dvipng using the flag -D. dvisvgm convert input. Run latex as usual to generate the dvi file. dvipng A method for DVI files is dvipng.png foo. Try different resolutions to The use of fmt -u (available on most Unices) will remove fit your needs.dvi The flag -T sets the size of the image. where X is measure in pixels. Now. The option tight ps2svg will only include all ink put on the page.optipng verts from DVI to SVG. .pdf output. you can use a DVI-to- Open your file with GIMP. If you want to keep the formating. a step-by-step guide could be written).dvi You can optimize the resulting image using optipng so that it will take up less space. an open source utility that con. have the image within GIMP. but 100 dpi should be enough. To the command line tool pdf2svg.png. Inkscape 9. use echo “quit” | gs -sDEVICE=jpeg . Usage is the same as dvipdfm. It can handle multi-file Raster graphics projects. and other vector graphic formats.172 CHAPTER 9. so all you need is to give one command: detex yourfile JPEG (note the omission of . dvisvgm -n file. whether you want to use anti-aliasing (choose strong if you want to get something similar to catdvi yourfile. The formula is: <dpi> = <font_px>*72.26.svg dvipng -T tight -D 231. we want an X font size formula.3.sh can be used (as all the software used by this script is multiplatform.pdf file. there may be an easier way INPUT inkscape --export-area-page --export-plain. The option -o sends the output to the file name foo. PDF. you can post-process it as you like and save it to any format supported by GIMP. EPS. to dots per inch (dpi). If you want the plain text go to as follows: a file. generate the desired png file run the command as follows: pdf2svg file. If you want.

There are ways to get around the default behavior.3 Simplified special character input need to include the package: See Fonts for an explanation. This is actually Remember the TeX rule: fairly common in a lot of documents and not as weird as it may seem at first.1.1.g. Add the following lines in your preamble: 10.2 Avoid excessive double line breaks in source code 10. The TeX engine is in charge of that.6 Fonts are ugly/jagged/bitmaps or You might be tempted to put blank lines all the time to PDF search fails or Copy/paste from improve the readability of your source code. but this will PDF is messy have an impact on formatting. So long as your computing environment supports UTF-8. you can enter special characters directly rather than enter- ing the TeX commands for diacritics and other extended 10.Chapter 10 Help and Recommendations 10.1 Margins are too wide Avoid using latin1. TeX starts a new paragraph. lem with manual formatting is that it is not dynamic.1. you can easily change them with 10. • If two or more consecutive line breaks are found.1. • If only one linebreak is found. You must be using diacritics (e.5 LaTeX paragraph headings have ti- tle and content on the same line Too many paragraphs of one line or two do not look very good. accents) with OT1 en- This will prevent TeX from seeing another line break— coding (the default).1.g. If you have ugly jagged fonts after the font encoding change. then you have no Type1 compatible fonts avail- Example: able. TeX inserts a space if there is no space directly before or after it. The solution is simple: put a comment at the very beginning of the blank lines.7 Manual formatting: use of line characters. Switch to T1 encoding: all characters up to and including the next line break after a comment are ignored. To use Latin Modern you 10.4 Writing the euro symbol directly See Page Layout. breaks and page breaks This requires that: You should really avoid breaking lines and pages manu- • your text editor supports and is set to save your file ally. see \paragraph line break for more information. how- ever.} writes the title on the same line as the content.1. E. Install Computer Modern Super or Latin Modern (package name may be lm). Some people do not like the way \paragraph{... 10.. See Special Characters. If you still disagree.1. 10. Even 173 . In most cases. The big prob- in UTF-8. this is a preferred default and improves readability. LaTeX’s default margins may seem too large.1 FAQ • you add the \usepackage[utf8]{inputenc} line in the preamble.

1. In English there is no space before a punctua- Typographically speaking. gether with the following word. ually. no extra space will be printed.These commands are switches—they remain active until namically by using the xspace package. See Paragraph Alignment for more • If there is no brace and a space following the com.Wikipedia.} for emphasizing text us- or \cleardoublepage which print currently floating figures ing italics. you are pretty free to do 10.9 Avoid bold and underline what you want. use a pair of braces after the command. Figures are a type of float.. an extra space will be appended. (Technical explanation: a control sequence name can only be composed of characters with catcode 11. • If there are braces.1.for more details. the index. ditional word processors because these two functions are very easily accessible (along with italics). you often read the emphasized part first. but not everything.} because before starting a new page. no space is taken into account. in the source. e. acter(s) are ignored.. HELP AND RECOMMENDATIONS if it looks right the first time. (Actually. If you use \includegraphics without enclosing it in a figure rameter in between or not).not have more weight than normal characters. which helps to prevent cluttering your text with pictures and tables. glos- or chapters (although when you start a new part or chap.There are a lot of rules. it will behave just as in a word processor. and so on. \raggedright or \centering at some point and forgotten to switch it off. parts line is for special parts. or until the end of the document if there is no scope..) Most likely you have used \raggedleft. use bold or underline formats in the middle of a para.g.See Importing Graphics and Floats. the content is likely to ren. such as headers.. Italics are less obvious and do the project). \emph{. Punctuation rules are different for each language. ..information. underlining is rarely used in ter.11 Text stops justifying consecutive spaces have been concatenated into one sin- gle space. 10. This has become a common habit for users of tra. LaTeX will not print any space. Delete the .aux file (or clean ing the order of the ideas. language change graph with a bold word in the middle. The only place where page breaks are recommended is at The original and more appropriate use of bold and under- the upper level of sectioning in your documents. Es- pecially regarding punctuation.This is a limitation of Babel. bold and underline tend to overweight the text 10. When you do professional environments. LaTeX will ordinarily do this for you).10 The proper way to use figures Users used to WYSIWYG document processors like Mi- 10. The answer is simple: a figure is not a picture! TeX has an unintuitive rule that if a control sequence (a command) is not followed by a pair of braces (with a pa.. It is possible to define macros that will insert a space dy. you should use \clearpage LaTeX has a macro \emph{.) manually insert a page break. It should be preferred to \textit{.1. thus spoiling the content and break. that is A.} will correctly print emphasized text inside If you absolutely have to insert line or page breaks man.12 Rules of punctuation and spacing Example: LaTeX does some work for you. and it knows where it ends when it encounters the first token which is not of catcode 11.other italic text in the regular font.1. even LaTeX can put in places other than the exact location it if there are no parameters. When you start reading a para. Since 10. Figures and Captions Z and a-z by default. text. it is usually poor practice to tion mark and one space after it.8 Always finish commands with {} crosoft Word or LibreOffice often get frustrated with fig- ures.1. This character is then skipped. the end of the scope.1. but you can have a quick look at graph.174 CHAPTER 10. so that you don't later have to come back and update it. environment. However. Example: was created.13 Compilation fails after a Babel and distract the reader. so they are der really badly if you change anything before the point usually a better choice for emphasizing small amounts of you manually formatted. you should do it after you are sure you have com- pleted your document otherwise. saries. then the following space char. then try compiling again. mand. and placing the picture right at the spot where it was placed the command (say. 10. quence name start thanks to the backslash. TeX knows where the control se. the TeX or LaTeX logos) are run to. which is a virtual object that To fix this.

10. you put a non- breaking space before all two-parts punctuation marks. if you want to refer to an object A. only the non-breaking space for the some interesting choices.17 Use vector graphics rather than rectly raster images Nowadays it is very common to “learn” on the web by us. 10.1. In you are not using an adequate editor. A non-breaking space between two tokens (e. The time you spend learning is worth it. In the end. You can define aliases to shorten some commands: Here the xspace package comes in handy to avoid swal- 10. LaTeX and other features. sure you read its official documentation. write 10. . FAQ 175 10. See Editors for the above example. For math and a lot of other fields. in French typography.1. in under 100 MB. For instance. including Note that this is different from usual text parentheses. words. this is ument quality. see Tables for more details. initials.1.10. for units and currencies. many You usually use non-breaking spaces for punctuation spreadsheet applications have a LaTeX export feature (or marks in some languages.20 Relieving cumbersome code (lists Example: and long command names) Note that writing French like this might get really painful. For lists you may want to try the easylist package.1. Also. When age. Al- ternatively if you cannot use the tabu package you may try tabularx or tabulary packages See Tables. It is very important reading. non-breaking space. and a lot of frustration. Babel with the frenchb option will take care LaTeX is sometimes cumbersome to write. Raster (bitmap) graphics scale poorly and often create ing a search engine and copying and pasting things here jagged or low-quality results which clash with the doc- and there. Again. it is the same. Inaccurate information might result in causing 10. al- 10. ing vector formats from your drawing or diagramming Most chapters in this book are dedicated to a specific us- tools. EPS.15 Non-breaking spaces This useful feature is unknown to most newcomers. etc. Content found on the web. Now All virtual objects designated by letters. The nice tabu things properly and end up stuck all the time. make over PNG or JPG.1.g. even in this book.1.14 Learning LaTeX quickly or cor.1. so the basics are actually covered very quickly. package will do what you want and even much more.21 Reducing the size of your LaTeX If you want to refer to several objects in a sentence. punctuation marks) prevents processors from in. you can still use the math The Installation article explains in detail how to manu- notation. variables or oth. is rarely as accurate as the official docu- mentation. Thankfully. Some LaTeX editors feature table assistants. generally a poor method which will lead to lack of control. for plugin).18 Stretching tables mistakes without you understanding why.16 Smart mathematics lowed spaces. will produce much higher quality results.writing a list is as simple as ers should use a dedicated formatting. Using vector (line-oriented) graphics instead. it is worth serting a line break between them. possible. ally install a fully functional TeX environment.19 Tables are easier than you think though it is available on most WYSIWYG document pro- cessors. euro symbol must remain. or SVG graphics If you are getting frustrated with a specific package. As with every programming language. particularly when printed.1. Really learn- through LaTeX’s native diagramming tools or by export- ing LaTeX is not that difficult and does not take that long. installation If you refer to a set of objects. you only need to know a few things for consistent reading. especially if of the non-breaking spaces for all punctuation marks. Even though the Tables chapter is quite long. LaTeX uses the '~' symbol as a about the environment of your choice. For example. either unexpected results. the LaTeX math formatting is perfect. which is usually the best source of information. you should prefer PDF. and it quickly Trying to stretch tables with the default tabular environ- makes up for the time you would lose if you don't learn ment will often lead to unexpected results.1. 10.

rated in a . entific images. A very versatile vector image editor is Inkscape.. and add more space be.4 Graphics and Graph editors will output: Vector image editors with LaTeX support TeX capacity exceeded .2.in the picture. Moreover. There are. HELP AND RECOMMENDATIONS 10. sorry [ grouping levels =255]. In early days.. It also gives you some very basic ways of encapsulating LaTeX text and math in the image (setting the text’s 'special flag' to 'special' instead of 'normal'). Using this way text is rendered by the If the command \frenchspacing is used in the preamble.e. including but not limited to mathematical formu- since they are followed by a space. “i. it will be formatted accordingly.