LATEX for Computer Scientists
Total Page:16
File Type:pdf, Size:1020Kb
LATEX for Computer Scientists Les Kitchen The University of Melbourne Department of Computer Science and Software Engineering http://www.cs.mu.oz.au/~ljk/ 15 May 2006 c 2003, 2006, Leslie John Kitchen. You may Contents mak e and distribute unmodified copies of this document in its entirety for non-commercial 1 What is LATEX? 3 purposes. In particular, any copies must include 1.1 A simple example . 3 this copyright notice and the CVS Id string on the 1.2 Well, what is it? . 3 last page. (These conditions are inspired by those 1.3 History . 3 used by the ACM.) 1.4 TEX and LATEX . 4 Please be aware that this document, in its present 1.5 What's good about LATEX? . 4 state, is work in progress. It is provided, as is, in 1.6 What's \bad" about LATEX? . 4 the hope that it will be a useful aid in learning 1.7 Summing up . 5 LATEX. It may still contain errors, and is certainly incomplete and in need of some re-organization. 2 Philosophy 5 See corresponding LAT X source file for details on 2.1 What I can achieve here . 5 E A distribution conditions for source files. The source 2.2 Levels at which you can use LTEX . 5 A files will normally be available via the author's 2.3 Learning to use LTEX . 5 webpage, at the URL given above. Note that the 3 Basic LAT X 6 distribution conditions may change: Do not E 3.1 Processing . 6 assume that distribution conditions for future 3.2 Associated files and re-running . 6 versions will be identical to those for the current 3.3 Characters to pages . 7 version. 3.4 Input conventions . 8 This document is based on a document 3.5 Combinations . 8 called Intermediate LATEX prepared for a 3.6 Commands . 9 School of Graduate Studies course at the 3.7 Environments . 10 beginning of 2003. The main changes are 3.8 After-sentence space . 10 addition of some additional material, and 3.9 Accents and symbols . 11 a change of emphasis towards a 3.10 Declarations, grouping, and scope . 11 Computer Science readership. Having 3.11 Appearance of type . 11 said that, I point out that this document 3.12 Text justification . 13 is now approximately twice the size of the 3.13 Line and page breaks . 14 document it was based on. 3.14 Displays . 15 3.15 Lists . 15 Non-trivial changes since last version are marked 3.16 Overall source document structure . 16 in the margins: small changes by an arrow 3.17 Document class . 16 pointing to the affected text; extended changes by 3.18 Packages . 17 a down-pointing arrow at the beginning of the 3.19 Front stuff . 17 change, and an up-pointing arrow at the end. 1 3.20 Document sectioning . 17 15 Bibliography 33 3.21 Layout of a LATEX source file . 18 15.1 DIY: thebibliography . 33 15.2 Using BibTEX . 33 4 Breaking Up Your Document 1 18 15.3 Running bibtex . 34 4.1 \input . 18 16 Collaborative Document Development 34 5 Roll-Your-Own 19 16.1 Version control|CVS . 34 5.1 Commands . 19 16.2 Build tools|make . 35 5.2 Environments . 21 16.3 Automatic generation of LATEX . 36 5.3 \Theorems" . 21 17 Miscellaneous Topics 37 6 Customization 22 17.1 Index and glossary . 37 6.1 Customization . 22 17.2 Verbatim text . 37 17.3 Multilingual LATEX . 38 7 Cross References 22 17.4 LATEX and the Web . 38 7.1 Labels and references . 22 17.5 PostScript fonts . 38 7.2 Mechanics of cross references . 23 17.6 Page style and headings . 39 17.7 Color . 39 8 Footnotes 23 17.8 Hyphenation . 39 8.1 Footnotes . 23 17.9 Fragile versus robust commands . 40 9 Floats: Tables and Figures 24 17.10Some additional useful free programs 41 A 9.1 Floats . 24 17.11LTEX debugging . 41 17.12More advanced programming features 41 10 Tabulars and Tables 24 17.13Tips'n'tricks . 41 10.1 Tabulars and tables . 24 17.14What's missing? . 45 17.15Learning and getting more . 45 11 Mathematics 26 17.16TEX's limitations . 46 11.1 Math mode . 26 17.17TEXmacs and Lilypond . 46 11.2 Subscripts and superscripts . 27 11.3 A menagerie of symbols and operators 27 A Behind The Scenes: How It's Done 47 11.4 \Large" delimiters . 28 A.1 Listing of ljk-latex.bib . 47 11.5 Arrays . 28 11.6 Equations . 28 12 Boxes, Lengths, Space, Counters 29 12.1 Caveat . 29 12.2 Lengths . 29 12.3 Boxes . 30 12.4 Space and rules . 30 12.5 Counters . 31 13 Graphics: Images and Diagrams 31 13.1 The picture environment . 31 13.2 Graphics operators . 31 13.3 Including graphics . 32 14 Breaking Up Your Document 2: 32 14.1 \include . 32 2 1 What is LATEX? 1.1 A simple example \documentclass[12pt,a4paper]{article} % This is a comment \title{A Simple Example} \author{I. M. Weird\thanks {Nobody you know.}} \begin{document} \maketitle \begin{abstract} You shouldn't read this paper anyway. \end{abstract} \tableofcontents \section{Something Important} {\LARGE Hello world!} \section{Filler} A Simple Example The quick brown fox I. M. Weird∗ jumps over the lazy dog. April 24, 2006 Abstract The quick brown fox You shouldn't read this paper anyway. jumps Contents over the lazy dog. 1 Something Important 1 \end{document} 2 Filler 1 produces after processing the printed or displayed 1 Something Important Hello world! output shown in Figure 1. 2 Filler The quick brown fox jumps over the lazy dog. 1.2 Well, what is it? The quick brown fox jumps over the lazy dog. LATEX is in effect a programming language for creating quality typeset documents, designed so that most of the time you use it like a high-level ∗Nobody you know. (declarative) markup language. 1 It thus has some commonality with other markup languages like HTML, but is intrinsically more powerful and more oriented towards quality typesetting. Figure 1: Sample LAT X output. 1.3 History E Before (electronic) computers, (human) • editors would mark up a manuscript with instructions to the (human) printers on how to typeset the document. Donald Knuth initially developed TEX (along • with MetaFont) in the late 1970s. TEX is basically a high-quality programmable • typesetting engine, combining the text of the 3 document with embedded markup to specify { Scripts can generate LATEX the formatting automatically. automatically. MetaFont is a system for designing new Cross-platform. • fonts. • Stability and compatibility is a major Knuth provided a \format" called plain T X • strength. • E as a layer on top of raw TEX. Largely \declarative". • Plain TEX provided many convenient • Configurable, extensible and programmable. features, but was still somewhat difficult and • unforgiving. Suitable for collaborative document • Leslie Lamport built LAT X on top of T X in development. • E E the early 1980s to provide better, cleaner Can be used with build tools like make. support for document production. • Large, active community of users and That first released version was LAT X 2.09. • • E contributors. A Current version is LTEX 2". Many plug-in packages available. • • A LTEX version 3 is in the offing. Multilingual. • • A Editor support (e.g. latex-mode in emacs). 1.4 TEX and LTEX • LATEX is built on top of TEX. GUI interfaces (TeXshop, WinShell) and • • WYSIWYG front ends (Lyx). These days, pretty much all usage of TEX is • A 1 Non-proprietary. via LTEX. • Free! Almost all features of plain TEX are • • accessible in LAT X, but are generally used E Distributed under a GNU-like2 Free Software only by wizards, and are mostly hidden from • licence. ordinary users. From here I'll speak mainly about LAT X, but 1.6 What's \bad" about LAT X? • E E remember TEX is always in the background. Less immediate feedback compared with • WYSIWYG.3 1.5 What's good about LATEX? Lots of braces to match. All are somewhat inter-related. • { . though syntax-aware editors can help High quality typesetting, especially for a lot. • mathematics. Power of programming can also bring the Simple text representation: • • headache of debugging. { Create and modify with any text editor. 2 A One feature of the L TEX licence is that if you modify a { Suitable for version control (CVS, standard file, you must call it by a different name. This is to avoid compatibility problems where people might think subversion). they're using say a standard package, but are in fact getting 1 a mutant. One notable exception is texinfo, which the GNU 3 WYSIWYG stands for \What You See Is What You project uses to produce \info" documentation from T X E Get", which however also means \What You See Is All sources. You've Got". 4 A lot to learn to fully master LAT X, though I'll concentrate more on what you have to do • E you can do most simple document structures rather than how LATEX does it|though knowing fairly intuitively. how it works can help your understanding. Sometimes default settings are over • fussy|though this is configurable (as is 2.2 Levels at which you can use A almost everything in LATEX). LTEX A Arguably extra typing initially, though this 1. Straight, ordinary LTEX. • cost is in the long term greatly outweighed by 2. Minor customization of ordinary classes and savings in maintenance and modification. packages, via options and parameter settings. Probably not worth the overhead for simple • 3.