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 make 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 ...... 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-.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) . 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 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 . 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. Defining your own commands, environments, one-off things like letters (unless you set great etc. store by beautiful typesetting even for your correspondence), but then true LATEX 4. Use of various contributed packages, etc., devotees use it even for their shopping lists. some in the standard distribution, some you have to download yourself4.

1.7 Summing up 5. “Getting under the bonnet”: redefining A LATEX separates logical structuring from LTEX’s standard commands to do what you • visual formatting. want; creating your own packages and classes, etc. LATEX is particularly good for large-scale • documents which will have a long lifetime of I won’t touch on 5. revisions, and will have to be distributed in various formats and versions. 2.3 Learning to use LATEX While LAT X can provide groovey typesetting, A • E Learning to use LTEX is like learning a that’s no substitute for good organization • language: it is learning a language: and clear expression. – Grammar, vocabulary, idioms,. . . and LATEX, however, can assist greatly by taking practice, practice, practice. • care of a lot of the bookkeeping involved in producing an effectively presented document. What it costs you: • – Some effort in learning and looking 2 Philosophy things up, especially to start with. – A less immediate way of doing things, 2.1 What I can achieve here like making a bowl out of ceramic instead of plasticine: You don’t really LATEX is way too big to cover in just a couple of hours! know how the ceramic bowl will turn out until you’ve fired it in the kiln. Show you how some things work. • What you gain: • Show you how to do some things. • – Much greater expressiveness and control Give you an idea of what’s possible. than with WYSIWYG. • how Point you to some references. – A record of you did things. • 4 Almost everything available in the TEX world is on the Prepare you to learn and experiment on your TEXLive CD [10]. • own.

5 – By looking at other people’s LATEX – viewed using a PostScript viewer, like gv sources, you can find out how they did or GSView (which provide GUIs on top things, and learn how to do it yourself. of Ghostscript), – All the technical and aesthetic benefits – printed on most laser printers, A of LTEX in typography, especially – “distilled” to PDF using mathematics. Distiller, or the free ps2pdf (which – Membership in the global community of comes with Ghostscript). LATEX users. There is also a variant program pdflatex, • LATEX shines most for large documents that which produces PDF directly from LATEX • have to undergo revisions and reformatting source. for different purposes: e.g., chapters of a thesis redone for journal publication. 3.2 Associated files and re-running A good frame of mind to have is that when • There are a number of files associated with the you create a LATEX document, you’re not processing of a . file. Some of the most creating just that one-off document, but important are: you’re creating (or at least preparing for) all the future versions of that document. .aux The auxiliary file, which latex uses to keep track of cross-referencing and similar This can require a little forethought and information. planning. .log The log file, which contains an even more LAT X is very linguistic: you name things E detailed account of processing than is written • rather than point at them. to standard output.

A .toc, .lof, .lot Used for information 3 Basic LTEX respectively for the Table of Contents, List of Figures, and List of Tables. 3.1 Processing .bbl bibtex Starts out with LAT X source file typically The bibliography created by , and E latex • with extension .tex (though .ltx is used by . sometimes used). There are a number of other files associated with E.g., latex foo.tex (or latex foo — latex processing of bibliography, index and glossary. • provides a default extension of .tex if not A few things to note: given). latex is strictly one-pass: To cope with • Main product is the corresponding DVI forward references, like cross-references to • (“device independent”) file, in this case later sections, and page numbers in the table latex foo.dvi. of contents, makes use of information gathered on the previous run in the .aux, The DVI file describes where each character .toc files, etc. • glyph and graphic goes on each page. This means that after a significant change to • The DVI file can be viewed directly using a the document, it can take two runs5 of latex • DVI viewer like xdvi. to get cross-references, etc., perfectly correct. 5 More often, the DVI file is converted to Those theoretically inclined will see that this is a kind • of fixed-point iteration. It’s actually possible to construct PostScript using dvips. A pathological L TEX documents that never converge. I’ve never known this to happen in practice, but constructing The resulting .ps file can be: • such a document is an interesting brain-teaser.

6 (On the first run, latex was still using Paragraph boxes get output onto pages. cross-reference information generated before • In between the boxes goes adjustable space, the change.) • which TEX can stretch or shrink (within Symptoms of this are messages from latex limits) to achieve the best looking output. • like “There were undefined references” or In T X-speak, for historical reasons, these “Cross-references may have changed, rerun • E latex to get cross-references right”. adjustable spaces are called glue, but they’re probably better conceptualized as being like Some people superstitiously always run latex invisible springs. • twice, or make use of scripts (usually called The main unit of T X’s typesetting is the something like makeltx or latexmake), which • E iterate running latex until the paragraph. TEX makes its decisions about cross-references stabilize. See also notes where to break the text of a paragraph into about using latex under make. lines using a quite sophisticated algorithm, which tries to optimize the appearance of the In practice, this is rarely a problem. You entire paragraph, taking into account a • really only need perfectly correct number of typographic factors. cross-references in the final version. When These typographic factors are assigned you’re actively developing a document, it • usually doesn’t matter if the cross-references various numeric weights. TEX has well-chosen A are a little out of synch. default values. Most of LTEX’s layout effects, like centering and flush right, are achieved Which associated files are actually produced not by using a different algorithm, but merely • depends on what features you ask for. For by altering the parameters of TEX’s example, if you don’t have paragraph algorithm. \tableofcontents, then no .toc file is produced. Because of this, a change at the end of a • paragraph can actually affect the line breaking at the beginning, because of the way 3.3 Characters to pages it shifts the balance of the optimization. As the engine underneath LAT X, T X works at a E E This whole-paragraph approach is one of the number of levels to produce the typeset output. • reasons why T X’s typesetting looks so good, To simplify the real story a bit: E but also why it’s difficult to do a proper At the lowest level, T X deals with boxes. WYSIWYG version of TEX or LATEX. • E glyphs One consequence is that the typesetting of a Boxes are mostly the for printed • • characters and symbols, but they may be paragraph is controlled by the settings in other things like graphics. effect at the end of the paragraph (when TEX’s algorithm kicks in). This affects the Most of T X’s work is in creating a use of declarations like \sloppy: the scope of • E hierarchical assemblage of boxes from the the declaration must include the blank line input to produce an aesthetically typeset (or \par) that ends the paragraph. See [7, result. p. 94f] for more details. Character boxes get assembled into word T X’s multi-factor approach can be subtle. • • E boxes. Sometimes you may see TEX produce something that looks like a no-no, like having Word boxes get assembled into line boxes. • a word protrude slightly into the right margin Line boxes get assembled into paragraph when you wanted fully justified text. • boxes. Invariably, this is because the alternative line

7 breaks would have been worse in the overall The characters @ [ ] can be used in ordinary assessment. • text, but behave specially in certain circumstances. Another consequence of TEX’s approach is • that very little in T X’s typesetting is The characters + - = < > are mainly used in E • absolute. For example, the “unbreakable math mode, and there behave as you’d space” ~ does not actually forbid a line break. expect. They can be used in ordinary text, It merely assigns a very high penalty to but may not always give what you expect in breaking at that point. In normal situations, that in some fonts that character code is TEX’s algorithm will avoid breaking there to assigned to a printed character different from avoid incurring the penalty in the what’s on the keyboard. < > gives ¡ ¿. optimization. As with most programming languages, • whitespace and newlines are used to delimit In doing its job TEX also has to break apart • boxes it has already made. For example, it tokens. Additional whitespace and newlines may need to break a word box to hyphenate a beyond this have no effect, though they can word to get a better line break. Or it may be used for source layout. need to break a paragraph between two lines One exception is that a one or more to get a good page break. • consecutive blank lines indicate a paragraph break.6 3.4 Input conventions A consequence of all this is that you can’t • LATEX input is an ordinary text file, which normally get extra horizontal whitespace on • mixes the content of the document with the page by typing extra spaces into your markup to process it. LATEX source. Nor can you get extra vertical whitespace by putting in extra blank lines. The input conventions are reminiscent of the • These effects have to be achieved by invoking Unix shell (though not the same), in that explicit commands. some characters are “ordinary”, while some are “special” and trigger special treatment. 3.5 Combinations Most characters (letters, numbers, Some combinations of otherwise ordinary • punctuation) are “ordinary”, and represent characters are treated specially: themselves. ‘‘ and ’’ give proper opening and closing The following characters are “special”: • (double) quotation marks, aka “inverted • commas”. (Don’t use ", the typewriter $ Switches T X into math mode. E double quote!)7 \ Indicates a command. Similarly, ‘ and ’ give single quotes. (The Indicate grouping and enclose the actual • { } latter also gives an apostrophe in ordinary arguments of a command. text and a prime in math mode). ~ Unbreakable interword space. 6 A blank line is thus equivalent to the command \par, ^ Indicate respectively subscripts and and in some circumstances it’s clearer to use the explicit superscripts in math mode. \par command. 7In emacs’s latex-mode you can type in ", because that # Used for formal arguments of a command. key is bound to a command that automatically inserts the appropriate LATEX opening or closing quotation marks de- & Separates cells in rows of a table. pending on the . By way of clarification, ‘ is the % Indicates a comment. The comment runs ASCII grave accent, aka “backtick”, top-left on most key- boards; ’ is the “single-quote” or apostrophe, just right of from the % to the end of line (a bit like semicolon on most keyboards. Actually, if you use type- C++ // comments). writer double quote, ", you get a proper closing double quo- tation mark.

8 In ordinary text, - gives an intra-word Command-name delimiting: • hyphen, -- gives an en dash used for ranges • like “17–42”, and --- gives an em – The name of the command runs until dash—used for sentence punctuation. the first non-letter. In math mode - gives a minus sign, as in – Often this will be some punctuation, but x y (produced by $-x-y$), which is may be whitespace. − − different again.8 – If the command name is terminated by whitespace, then all this whitespace is Less obviously, certain combinations, like fi gobbled up. • and fl give proper typographic ligatures: “fi”, “fl”—not “fi”, “fl”. – This creates a problem if we want some white space in the output after the Note that you get the ellipsis “. . . ” by the result of the command. • command \ldots (for “low dots”). Typing – Various solutions are presented later. three dots ... in your source gives dots too close together for English typographic Arguments: conventions, “...”. This is a case where • something you’d expect to be done by a – Most commands take one or more combination isn’t. (There are a number of arguments. other dots commands available only in math – Arguments follow the command name mode.) and are enclosed in braces. – The outer braces just enclose the 3.6 Commands argument and are stripped away before Commands come in two varieties: the argument is actually passed to the • command. 1. \ followed by a single non-letter – Any given command has a fixed arity character (number of arguments that it accepts). 2. \ followed by a sequence of letters But see later point. Examples of the first kind: \$ \& \% \# \ \ – LATEX checks and generally complains if • \ produce respectively $ & % # ; while{ a command is given insufficient \,} produces a “thin” space.9 { } arguments. Additional arguments will not be passed to the command, and in Examples of the second kind: \S, \P and • general will end up being treated as \copyright, which produce respectively the following text that just happens to have section, paragraph and copyright symbols, , been put in grouping braces. and c ; \maketitle, which produces the§ ¶documen t title, and \large which switches to Optional arguments: large font size, and \Large, which switches to • an even larger font size. – Quite a few commands also accept optional arguments. Note that such command names can consist – The optional arguments if supplied are • only of letters (not even digits), and are enclosed in square brackets, and usually case-sensitive. but not always come before the 8 If you look closely, you can see that LATEX puts different obligatory arguments. space around the minus sign depending on whether it’s a unary or binary operator. – If an optional argument is not supplied, 9The thin space is useful for quotes within quotes, to then some default is used. give a little separation between an outer double quote and an inner single quote, like: – There’s the potential problem that some “ ‘Work’ is a four-letter word”, said John. ordinary text with square brackets following the command may be mistaken

9 for an optional argument. The solution So LATEX follows a rule which works correctly is to enclose that text inside grouping • almost all the time, and has the advantage of braces, which protects it from being being simple and predictable, so you can interpreted as an optional argument. easily tell when you need to over-ride LATEX. With rare exceptions, paragraph breaks are If the full stop comes after an upper-case • • not permitted in command arguments. This letter, then LATEX assumes it’s marking is a deliberate safety feature, to catch missing initials (like N.S.W.) and treats the following closing braces on arguments. It triggers space as ordinary interword space. LATEX’s “Runaway argument?” error If the full stop comes after a lower-case letter, messsage. The idea is that command • arguments should generally be fairly small then it’s treated as marking the end of a chunks of material, and if you encounter a sentence, and extra following space is paragraph break it’s more likely because the inserted. argument isn’t properly closed. This extra space isn’t fixed. Like many spaces • in LATEX it’s stretchable (or squashable) as 3.7 Environments needed to optimize the typesetting, but in general it’s larger than an ordinary To provide handling of chunks of material inter-word space. • bigger than can reasonably be passed as A command arguments, LTEX also provides What about when LATEX gets it wrong? enviroments. • – Putting a \ (yes, that’s a backslash Environments are invoked by two matching followed by a space) immediately after • commands, \begin and \end. the full stop puts an ordinary interword space there, even if the preceding letter They each take as argument the name of the was lower case. • environment (no backslash). This is useful for abbreviations inside a The text between the \begin and the sentence. • corrresponding \end is affected by the – Putting a \@ immediately before the full formatting of that environment. stop forces it to be treated as The \begin and \end must nest properly. end-of-sentence punctuation, making the • following space bigger. For some environments, the \begin command • This adjustment may be necessary even when takes additional arguments to control the • formatting of the environment. other punctuation, like parens and quotes, intervenes between the full stop and the Environments provide local scope for following space. • declarations. (That is, the effect of non-global Similarly for other sentence punctuation: declarations made inside an environment are • undone at the end of that environment.) question mark, exclamation mark and colon. Don’t lose too much sleep over this. If you 3.8 After-sentence space • get it wrong, at worst you’ll have a little bit too much or too little space after some In typography (at least in English-speaking punctuation, which probably only a dedicated • countries) it’s conventional to put a little typographer will notice, not your average extra space after punctuation that ends a punter. sentence. (Usually a full stop.) But figuring out what is a sentence is way • beyond a mere program.

10 3.9 Accents and symbols Scope is provided by environments and by • grouping braces.10 There are a relatively small number of • symbols, such as the and already There are, however, a small number of ¶ § mentioned, available in ordinary text. In our • declarations which are global and do not obey Department, \o, which produces ø, comes in these local scoping rules. One of these is handy for names like Søndergaard. \pagestyle, for instance. A huge number of symbols (numbering in the • thousands) are available, but mostly only in 3.11 Appearance of type math mode. LATEX provides a number of ways of changing This is not a serious impediment, since you • the appearance of the type. can always switch temporarily into math Used with judgement (and not overdone) mode to get any symbol as you need it. See • later. such control of appearance can aid understanding, by providing consistent, visual There are a number of commands for putting typographic markers. • various accents on letters, etc., in ordinary Type size: text (and many more in math mode). • For example: \‘ e , \’ e , \^ a , \" o , • \c c produce `e,{´e,} a,ˆ o,¨{ c¸}resp{ectiv} ely{. } {\tiny tiny} { } {\scriptsize scriptsize} To put accents on the letters “i” and “j” you {\footnotesize footnotesize} • need to use the dotless versions, produced by {\small small} the commands \i and \j, respectively like ¯ı {\normalsize normalsize} from \= \i . {\large large} { } {\Large Large} Such commands are adequate for small {\LARGE LARGE} • chunks of non-English text needing accents, {\huge huge} but not for producing whole non-English {\Huge Huge} documents. For that see later. produces 3.10 Declarations, grouping, and scope tiny scriptsize footnotesize small normalsize large Some commands produce some sort of • output, such as the commands to produce Large LARGE huge Huge special symbols or even tables of contents. Note, sizes are relative to the base size of the But many commands just change LAT X’s • E document, which normally can be 10pt state: They are declarations. (default), or 11pt or 12pt, as specified as It’d be a pain if every time you had a option to \documentclass. • declaration you had to later put in another 10Except, of course for the outer braces that enclose a declaration to restore LATEX to its previous command argument, which are stripped away before the ar- state (which you might not even know). gument is passed to the command. The outermost braces around the body of a command definition are likewise outer- Therefore, almost all declarations in LAT X most braces around the arguments of the \newcommand com- • E mand and so are stripped away when the command is de- are local to some scope: They have their fined, and don’t provide scoping. This is necessary so that effect when processed, but only temporarily a command can expand, say, to a declaration and still have — their effects are undone and the original effect. Analogous remarks apply to the two bodies of an state restored on leaving that scope. environment definition.

11 Type style can be done via declarations: It’s subtle, but, in the first line, because of • the oblique italic font the “t” of “text” leans a bit too close to the “b” of “back”. In the {\rm Roman} second and third lines a tiny bit of extra {\it Italic} space is added, either automatically by the {\bf Boldface} \textit command, or explicitly by the italic {\sf Sans Serif} correction \/ command. {\sl Slanted} {\sc Small Caps} However, the declaration forms are more {\tt Teletype or typewriter} • convenient if you’re applying the type-style change to a whole chunk of text, like an produces entire environment. Subject to availability of fonts, these type Roman Italic Boldface Sans Serif Slanted • styles can be combined: Small Caps Teletype or typewriter

Ordinary \textit{italic} Or, usually more conveniently, via commands • or \texttt{typewriter} with an argument. \\ \textbf{Bold \textit{italic} or \texttt{typewriter}} \textrm{Roman} \textit{Italic} produces \textbf{Boldface} \textsf{Sans Serif} \textsl{Slanted} Ordinary italic or typewriter \textsc{Small Caps} Bold italic or typewriter \texttt{Teletype or typewriter} For some font families, not all combinations produces may be available. You really should never use such Roman Italic Boldface Sans Serif Slanted • type-changing commands in the body of your Small Caps Teletype or typewriter document. Rather, if some identifiable part of your Almost always, the command versions are • • preferable, since they take care automatically document needs special typographic of the so-called italic correction: treatment, you should define a command (or environment) for it. (See later.) You do the type changing in the definition of the Normal {\it italic text} back. command, then tag the text in your \\ document that needs the special treatment Normal \textit{italic text} back. with this command. \\ Normal {\it italic text\/} back. An important exception to this is the \emph • command. It is really more like semantic produces markup, indicating that the text is to be emphasized, by the normal convention of putting it in italics. It has the corresponding Normal italic text back. \em declaration, which is useful for Normal italic text back. emphasizing larger blocks of text (like an Normal italic text back. entire environment).

12 There are additional type size and style \emph{The convention is that • features available in math mode. \emph{emphasized} text within emphasized text is set in \emph{roman} style.} 3.12 Text justification Normally, LATEX fully justifies the output produces • text, on left and right.

Other forms of justification can be achieved The convention is that emphasized text • by the center, flushleft, and flushright within emphasized text is set in roman style. environments.

Never use underlining! Underlining was used • to indicate emphasis on limited archaic \par devices like typewriters. It really has no place How to Dominate Men, Subjugate Women, and in proper typesetting, and (depending on how Stupefy Children it’s done) can cause numerous problems. If by the underline is just below the baseline, it can Salvador Dali 11 interfere with descenders and severely affect \par legibility. If the underline is positioned so as to avoid interfering either with descenders (or with ascenders12 on the next line), it requires produces introducing some additional space between the affected lines, which breaks up the visual unity of the paragraph. It’s even worse when How to Dominate Men, Subjugate Women, an underlined word gets hyphenated across and Stupefy Children by Salvador Dali two lines, because then more lines are affected. \begin{flushleft} In normal text, you can use \emph; in How to Dominate Men, mathematics you can use conventions like Subjugate Women, and \boldmath, to indicate things like vectors, Stupefy Children which are conventionally underlined in typed by or handwritten manuscripts. Salvador Dali \end{flushleft} Well, I exaggerate by saying never. There are some rare situations in which it might make produces sense to use underlining. For example, it can provide an additional means of indicating consistent distinctions in mathematics, once How to Dominate Men, Subjugate Women, you’ve used up all you can with changes of and Stupefy Children by Salvador Dali typeface and accents. And perhaps even in ordinary text you might want underlining for some special indicative purpose, with all its \begin{flushright} How to Dominate Men, problems. To this end, LATEX does have some facilities and packages for underlining, both Subjugate Women, and Stupefy Children in ordinary text and in mathematics. by 11A descender is that part of letters, like “g” and “q”, Salvador Dali that goes below the baseline. \end{flushright} 12An ascender is that part of lower-case letters, like “b” and “k”, that goes above the height of a lower-case “x”. produces

13 How to Dominate Men, Subjugate Women, \begin{center} and Stupefy Children by Salvador Dali How to Dominate Men, \\ Subjugate Women, and \\ Stupefy Children \begin{center} \\ by \\ How to Dominate Men, Salvador Dali Subjugate Women, and \end{center} Stupefy Children by Salvador Dali produces \end{center}

produces How to Dominate Men, Subjugate Women, and Stupefy Children How to Dominate Men, Subjugate Women, by and Stupefy Children by Salvador Dali Salvador Dali

The text is a chapter heading from [2]. The \\ command can take an optional length • There are corresponding declarations, argument, which specifies how much • \centering, \raggedright, and additional vertical whitespace to insert after \raggedleft. They aren’t often used, but the line break. come in handy sometimes. There’s also a “starred” form \\*, which • In fact, I’ve come to appreciate their inhibits a page break at the line break. With handiness more recently. The environment care, it can be used to keep separate lines forms, as well as altering TEX’s formatting together on the same page, although there parameters to achieve their effects, also are perhaps better ways of achieving this. introduce some vertical space above and Normally, LAT X does a good job of deciding below the formatted text. In most cases, like • E a hand-formatted centered heading, this is on page breaks, but you can force them if what you want. The declaration forms just necessary: alter the formatting parameters, without \newpage Goes to a new page (new column introducing the extra vertical space. This can in two-column mode). be useful, particularly when you’re defining \clearpage your own formatting environments, when you Goes to a new page. want the layout effects without the space. \cleardoublepage Like \clearpage, but in two-sided printing takes us to an As usual, you should normally avoid using • odd-numbered (right-hand) page, such explicit justification changes in the body inserting a blank left-hand page if of your document. If some identifiable part of necessary. your document needs such special treatment, do it via a user-defined command or Both the “clear” forms also force out any environment. accumulated floats. There are also various commands to 3.13 Line and page breaks • encourage or discourage line or page breaks The \\ command normally gives a line break at a given point: \linebreak, \nolinebreak, • (without starting a new paragraph). It’s \pagebreak, \nopagebeak. They each take particularly handy in centered text, where an optional argument, a number 0 to 4, to usually we want to control the division into specify the degree of encouragement or lines. discouragement.

14 3.14 Displays • Three animals you should Often text needs to be set apart visually, or know about are: • “displayed” \begin{description} \item[gnat] LAT X provides several environments for these • E A small animal, found purposes: in the North Woods, that causes no end of quote For short quotations. trouble. quotation For longer (multi-paragraph) \item[gnu] quotations. A large animal, found in crossword puzzles, verse For verse and poetry. that causes no end of trouble. There are also environments for displaying \item[armadillo] • mathematics, which will be described A medium-sized animal, named after a separately. medium-sized Texas city. \end{description} 3.15 Lists produces LATEX provides a number of environments for • lists of items: Three animals you should know about are: itemize For itemized (bulleted) lists. gnat A small animal, found in the North enumerate For numbered lists. Woods, that causes no end of trouble. description For tagged “description” lists. gnu A large animal, found in crossword puz- Within the list, each item is begun with an zles, that causes no end of trouble. • \item command. armadillo A medium-sized animal, named In a description environment, the optional after a medium-sized Texas city. • argument to \item provides the term to be described. (This example is take from [7].)

• These environments nest gracefully (up to \begin{enumerate} • \item First item, which has a four deep, at least). nested itemized list The “bullets” and number style depend on \begin{itemize} • \item First nested item the level. \item Second nested item As with most things in LAT X, the formatting \end{itemize} • E \item Second item of these environments is highly configurable, \end{enumerate} though the default serves for almost all purposes. produces There are also some lower-level list primitives • for defining your own list structures. 1. First item, which has a nested itemized A list Many standard LTEX environments are • actually defined in this way as trivial, – First nested item one-item lists. – Second nested item

2. Second item

15 3.16 Overall source document Automatically chooses appropriate big structure fonts.14 letter For letters (like you put in an LATEX documents follow a consistent • structure: envelope with a postage stamp). Additional classes have been developed by • various organizations, like publishers and \documentclass[a4paper]{article} preamble professional societies, for specific purposes, \begin{document} like to ensure that all papers submitted to a body particular conference are formatted in a \end{document} consistent way. The class determines the overall formatting of • In the preamble go various declarations to the document, and may make class-specific • load packages, set various document commands and environments available. parameters, and define new commands and Options can be used to modify the standard environments, etc. • settings for that document class. Commonly Nothing in the preamble should generate any used are: • text. 11pt 12pt To set the document with a base In the body goes the actual text of the type size of 11 or 12 points, instead of • document, which may be lengthy and spread the default 10 points. over several files. a4paper To format for A4 paper, instead of the default U.S. Letter size. 3.17 Document class oneside twoside To format respectively for one-sided or two-sided printing. Aside from whitespace and comments, and A • some uncommon constructs we won’t describe In two-sided printing, LTEX uses different margins for odd-numbered here, every LATEX document has to start with a \documentclass declaration.13 (right-hand) and even-numbered (left-hand) pages. In one-sided printing, The \documentclass declaration tells LAT X all pages are treated as right-hand pages. • E what kind of document it is. The standard The default for book is twoside; the document classes are: default for article and report is oneside. article An article, such as a conference paper or journal article. Use this when twocolumn Format for two-column pages. nothing else fits. landscape Format for landscape printing. report For something longer, like a technical Not all options apply to all classes: for report. • example, you can’t have two-column slides. book For a full-scale book. (Well, not via the standard class options.) slides Originally for overhead Options like a4paper, twoside and transparencies. Nowadays probably • landscape usually affect only LAT X’s more useful for producing say PDF E formatting of pages. It will sometimes take “slides” to be displayed on screen. further downstream intervention to get the 13It is actually possible to \input the \documentclass dec- 14There are a number of packages, like texpower, prosper, laration. This can sometimes be useful for automatically and foiltex, designed to support presentations, with some generated documents. support for animations and transitions in the generated PDF.

16 actual printer or on-screen display program definitions. For historical reasons, since they to respect them. were formerly called “styles”, they have extension .sty. If you’re curious, try For would-be wizards: Classes are defined by something like locate color.sty to find • A .cls files, which are just files of LTEX where the standard packages live on your definitions following special conventions. system, so you can take a look at how they’re They are looked up and loaded following the done. Again, beware, they’ll usually contain a same TEXINPUTS path as \input. If you’re lot of low-level TEX. curious, you can look at the standard document classes to see how they’re done. Beware, they’ll usually contain quite a lot of 3.19 Front stuff low-level TEX commands. Try something like \maketitle produces the document’s title in locate article.cls to find out where • the appropriate format for the document they’re stored on your system. class.

3.18 Packages It draws on information from the \title, • \author, and optionally \date declarations LATEX comes with a huge number of standard in the preamble. • and contributed “packages”, which provide extra facilities. The information for separate authors is • separated by \and. As as rule, if you encounter some typographic • Multiple lines for an author (say to give problem, almost always there’s an existing • package to do the job. address) can be obtained by \\. Inside the arguments of \title and \author Packages are loaded with the \usepackage • • command. things like acknowledgements and affiliations can be given by the \thanks command Its arguments are a list of package names, (whose argument will normally end up as a • separated by commas (no spaces), though footnote). usually it’s cleaner to load just a single package with each call. The abstract is produced by the abstract • environment.

The table of contents, list of figures, and list \usepackage{color,graphicx} • of tables are produced, respectively, by the \tableofcontents, \listoffigures and Loads both the color and graphicx \listoftables commands. packages. \usepackage can take an optional argument, 3.20 Document sectioning • which gives a comma-separated list of options A which are passed to the packages. LTEX provides a hierarchical organization of • sectioning commands—from highest to lowest: \usepackage[french]{babel} Command Level \chapter 0 Loads the babel package (which provides \section 1 multilingual support), passing it the french \subsection 2 option, to set French as the default language. \subsubsection 3 For would-be wizards: As with classes, \paragraph 4 • packages are defined by files of LATEX \subparagraph 5

17 To maintain the hierarchy, any sectional unit numbering of sectional units to be suitable • must be contained in the next higher unit. for an appendix. For example, in the article class, the \appendix command changes the However, there is no \chapter command • \section command to number sections by defined in the article class, so for articles letters, “A”, “B”, “C”. . . \section is the highest-level sectioning command. (This is intended to make it easier There is a rarely used, higher-level sectioning to include an article as a chapter of a book.) • command \part at level 1. It’s anomalous in that a new \part doesn−’t reset lower-level Sectional units are normally numbered • counters (\chapter or \section, depending automatically: A sectioning command on the document class). increments the number for that sectioning level, and resets the numbers for lower-level There are two user-settable counters sectional units. “Lower-level” means bigger • secnumdepth and tocdepth, which control (deeper) level numbers. the level at which sectional units are numbered and entered in the table of Sectioning commands take an argument contents. • which provides the heading for the sectional unit, the corresponding entry for the table of contents, and a running head for the page 3.21 Layout of a LATEX source file (for some page styles). Layout (whitespace, indentation, line • A They can also take an optional argument breaking) in the LTEX source file is largely • which is used for the table of contents and ignored. running head for the situations when you However, you should pay attention to layout want it to be different from the heading. • to enhance readability of the LATEX source, as A common reason is that for a long section you would say for a C program. For example, heading, too long to fit in the column width, the layout of the items in an itemized list you might want to introduce a \\ to put the should approximate the indentation of the line break where you want it, but not have final typeset output. the line break in the table of contents or running head. The comment % also magically eats all • leading whitespace from the beginning of the There are also “starred” forms, like next line. This can be very useful to layout • \section*, which are unnumbered, and and indent the LATEX by lines without produce no entry in the table of contents. introducing extra spaces into the output.15

Few documents use the full range: many will Needless to say, a LAT X source file should • E use only say \section and \subsection. • include reasonable comments, as they will help the reader. The table of contents is produced by the • \tableofcontents command. The names of the \paragraph and 4 Breaking Up Your • \subparagraph commands are perhaps Document 1 unfortunate. They are different from LATEX’s notion of a typeset paragraph (as indicated 4.1 \input by blank line or \par command). A Keeping the whole of a large document in a \paragraph sectional unit may actually • consist of several typeset paragraphs. single file can be unwieldy. 15A comment % can’t occur inside a command name. The \appendix command normally doesn’t • produce any output, but it changes the

18 \input file acts as if the contents of file 5 Roll-Your-Own • file app{eared }at this point. 5.1 Commands Analogous to #include in C. • LATEX provides many commands built-in, but If file lacks an extension, .tex is provided • • also provides a facility for users to define \input defns.ltx inputs the file their own commands, which work almost defns.ltx{ } exactly like those built-in. \input defns and \input defns.tex New commands are defined using { } { } both input the file defns.tex • \newcommand, which takes two arguments: The first is the name of the new command The file is searched for first in the current • (with backslash); the second is the body of directory (folder), and then in standard the new command’s definition — what each A LTEX system directories. instance of the new command is replaced (This can be modified using the TEXINPUTS with.16 environment variable.) Something like cross between a #define and • a function definition in C, because (LATEX export TEXINPUTS=.:$(HOME)/tex: being in effect an interpreted language) there’s no distinction between the Two nifty features: The trailing colon means compilation and run-time phases. that LATEX searches the standard LATEX E.g. system directories after those you’ve • specified. If a directory ends with a double slash //, then it’s searched recursively (that \newcommand{\PhoneNo}% is, into subdirectories as well). {+61-3-9234-5678} My phone number is \PhoneNo. Inputted files can also contain \input, and in Note difference between • turn input further files. aa\PhoneNo aa or Main uses aa{\PhoneNo}aa • and – Breaking a large document into aa\PhoneNo\ aa manageable pieces or aa{\PhoneNo} aa – Re-use of chunks of LAT X across E or multiple documents aa\PhoneNo{} aa An important table or complicated ∗ diagram used across several papers produces Especially a file containing your own ∗ command definitions and other My phone number is +61-3-9234-5678. Note personal customizations difference between aa+61-3-9234-5678aa – Division of labor amongst collaborators: or aa+61-3-9234-5678aa and aa+61-3- each can work on own part 9234-5678 aa or aa+61-3-9234-5678 aa or aa+61-3-9234-5678 aa

See also \include in 14 16 • § Underneath, TEX uses a lower-level command-definition facility, the most important part of which is the command \def. It’s sometimes used in package definitions, since it’s more efficient than \newcommand, because it’s at a lower level and does less checking. It’s interesting to note, though, that \def uses a more general pattern-matching mechanism for passing arguments.

19 As mentioned for built-in commands, and it The expected number of arguments is given applies as well to user-defined commands, • as an optional argument after the new when the command name is terminated by a command name. This is what LATEX uses to space, LATEX eats up all the following check that sufficient arguments are provided whitespace, so the following “aa” in the at each call. second instance above comes out right up Command definitions can be put almost against the expansion of the command. If you • really want the space to be there, you need to anywhere in the document, but it’s good use one of the contrivances listed here practice to collect them all together in the (although the xspace package can in most preamble (makes changing easier), and even cases make this unnecessary). Note that you better to put them in separate files of couldn’t have written \PhoneNoaa because definitions, which are inputted in the preamble. LATEX would have treated that as the name of a different, presumably undefined, command. You can define your own commands for • Your own commands can also take (up to convenient abbreviations, e.g., after • nine) arguments: \newcommand{\bi}{\begin{itemize}} \newcommand{\Shout}[1]{\textbf{#1!}} \newcommand{\ei}{\end{itemize}} I shouted ‘‘\Shout{Keep quiet}’’ to the class. \bi They yelled back \item blah ‘‘\Shout{Go away}’’. \item blah blah \ei produces produces I shouted “Keep quiet!” to the class. They yelled back “Go away!”. – blah

\newcommand{\TwoByTwo}[4]% – blah blah % Two-by-two matrix in row order % Works only in math mode! More importantly, user-defined commands {\left(\begin{array}{cc} • provide flexibility and abstraction: #1 & #2 \\ #3 & #4 If your phone number changes, you only need \end{array}\right)% to change it in one place, in your shared file } of definitions. \newcommand{\ct}{\cos\theta} This is the software engineering principle of \newcommand{\st}{\sin\theta} single point of control. \[ R_\theta = Similarly if you needed to change the format \TwoByTwo{\ct}{\st}{-\st}{\ct} for shouting (say to Huge size) or the format \] of matrices (say to use square brackets). Especially important if you’re dealing with produces large documents that may run to hundreds of pages, with LATEX source spread over many files. cos θ sin θ Another use of user-defined commands is Rθ =  sin θ cos θ  • analogous to a “stub” function in C. Suppose −

20 parts of your document need to be typeset in a particular way, but you don’t yet know how \newenvironment{Warning}[1]% to do it. You can invent a command to do {\color{#1} that, provide a temporary, stub definition of \hrule\smallskip \begin{center} that command, then push on with developing \large Warning your document content using that command. \end{center}\em}% The stub definition can be very simple, {\smallskip\hrule} maybe something like \begin{Warning}{red} If you go down to the woods today, you’d better not go \newcommand{\complicated}[4]% alone. {*** #1 * #2 * #3 * #4 ***} \end{Warning}

Later on, you can replace the stub definition produces with the real one, and you shouldn’t need to make any changes to the body of your document. Warning User-defined commands can also have one • optional argument (not covered here). If you go down to the woods today, you’d bet- ter not go alone. \newcommand will give an error if the • command already exists. The environment definition has two • To redefine an existing command, use the brace-enclosed parts: The first part goes in • analogous \renewcommand. This is used front of the environment’s contents; the particularly for document customization. second part goes after it. Note that environment arguments can be Less often used, but still handy to know • • about is \providecommand, which is kind-of used only in the front part. like the opposite of \renewcommand. If the Pretty much everything said above about command doesn’t exist, it gets defined, but if • user-defined commands applies to the command already exists, then nothing user-defined environments. happens. It can be used to make sure a piece of LATEX will work, even in an environment Environments are more appropriate if you’re where you don’t know whether certain • doing things with large chunks of text, or commands it uses have been defined or not. with the few things that aren’t allowed inside The \providecommand provides a “default” command arguments (paragraph breaks and definition, but one which will be over-ridden verbatim text). by an already existing definition. There’s an analogous \renewenvironment for Such commands (however defined) are often • redefining existing environments. • referred to as “macros”, because they’re analogous to macros in other languages and 5.3 “Theorems” applications like spreadsheets. Especially in mathematics, there are • 5.2 Environments identifiable, numbered chunks of material, like theorems, lemmas, corollaries, proofs. . . Analogously, LATEX lets you define your own • environments, for example: In other fields, there may be chunks like • commentaries or recommendations, exercises, or such.

21 LATEX provides the \newtheorem command as By using various classes and packages, and • a convenient way of defining such • setting options to them, e.g., the twocolumn “theorem-like” environments. option supported by almost all document classes. For example, • By redefining various lengths and commands • that LATEX “advertises” can be modified. \newtheorem{rec}{Recommendation} \begin{rec} Do this with respect, though, in that the \label{rec:preamble} • standard settings were generally designed by Put all your command, environment, typographic experts: Your modifications are and theorem definitions in the likely to be less good. preamble. \end{rec} For example, LATEX’s standard page layout \begin{rec}[For mariners] has rather wide margins. People are often \label{rec:chrono} tempted to go for narrower margins, in order Never go to sea with to fit more on a page, and save paper. two chronometers. Unfortunately, the resulting long lines, with \end{rec} many words, can be difficult to read. (This, Recommendations~\ref{rec:preamble} of course, is with one-column layout in mind.) and~\ref{rec:chrono} are completely unrelated. Wizards can delve into LAT X internals and • E redefine the effect of standard LATEX produces constructs. Doing this requires considerable knowledge: Something like the \section command does quite a lot of work behind the Put all your com- Recommendation 1 scenes in terms of layout and formatting, as mand, environment, and theorem definitions well as house-keeping like setting in the preamble. table-of-contents entries and page headers, plus being adaptable to different language Recommendation 2 (For mariners) Never go to sea with two chronometers. environments.

Recommendations 1 and 2 are completely un- related. 7 Cross References

Notice that a \label inside a “theorem” picks 7.1 Labels and references • up its number for cross reference by \ref. You mark a place in your document with • \label.17 Optional arguments to \newtheorem can • control numbering: either within some You refer to that place from elsewhere with sectional unit, or in the same sequence as • \ref to get the section, subsection, figure, another “theorem”. table, item number, etc.

Reference [4, p. 252ff] describes ways to With \pageref to get the page number • customize the presentation of “theorems”. • 17While the labels can be pretty arbitrary strings, it’s con- ventional to prefix a label with some indication of what sort of thing it is. So sec:foo would be a reference to a section. 6 Customization Similarly for eqn:foo, fig:foo, tab:foo, itm:foo, which would, respectively be references to an equation, a figure, 6.1 Customization a table, and a list item. Beware, though, that in certain packages for German, the colon is an active character, and You can customize your documents in various using it in label names can cause problems. ways:

22 E.g. with 7.2 Mechanics of cross references • \ref picks up cross-reference information • \section{Natural History of Gnus} written to the .aux file by \label on the \label{sec:gnus} previous run. Here we describe gnus. So, after a big change, it may take two runs • of LAT X to get cross references exactly right. then elsewhere E But normally, you don’t need to bother, since • you only need exactly correct cross references Information about gnus can be in the final version. found in Section~\ref{sec:gnus} on page~\pageref{sec:gnus}. It may seem that \label magically knows • what kind of thing it’s in (figure, section, produces subsection, etc.). In fact each of these constructs sets some counter to be the current “ref” (using \refstepcounter or equivalent), Information about gnus can be found in Sec- and \label just simple-mindedly picks up tion 3 on page 42. the printed representation of this “ref” counter. The cleverness is in the enclosing \vref of the varioref package provides more construct, not in the \label command itself. • powerful cross-references: includes page One conseqence of this is that if you want to reference only if it’s to a different page. put a cross reference say to a section, then E.g. the corresponding \label command has to be inside that section (i.e., after the \section command), but not inside any lower-level \usepackage{varioref} construct, like a subsection or figure. ... See Table∼\vref{tab:data}. 8 Footnotes can produce (among other variants) 8.1 Footnotes See Table 4.2. We saw gnus\footnote{A gnu is an an animal often found in See Table 4.2 on the previous page. crossword puzzles.} and gnats.

produces See Table 4.2 on the facing page.

We saw gnus1 and gnats. See Table 4.2 on page 66. 1A gnu is an an animal often found in crossword puz- zles. depending on relative position of the referenced table. There are number of customizations and packages The hyperref package can turn cross for changing the placement, numbering, and • references into clickable hyperlinks in PDF formatting of footnotes. (and HTML) output.

23 9 Floats: Tables and Figures 9.1 Floats

With normal text, LATEX inserts page breaks • as needed to produce properly filled pages.

But some things can’t reasonably be split • across page breaks, like images, diagrams, tables, program listings.

Keeping such a thing in sequence with the • normal text could leave a big ugly white patch if it didn’t fit on the current page.

So typographically we use floats, which can Figure 2: View of Daylesford Lake. • “float” through the text to a suitable place where they fit. Both figure and table accept an optional • argument by which you can express your own Standard LATEX provides two kinds of floats, • the figure and table environments. preference for positioning: \begin{figure}[htbp!]. The two float environments work in exactly But until you know what you’re doing, you’re • the same way. The only differences are: far better off accepting LATEX’s standard – Convention: figures are used for positioning rules. diagrams and images; tables are used for There are variant figure* and table* forms, presentation of tabular data. • which give full-width floats even in – Figures and tables are numbered and two-column layout. captioned differently, and have their Normal forms give just single-column width respective \listoffigures and floats. \listoftables. You can define new categories of floats, for E.g. • • things like program listings that don’t really fit in either of the tables or figures categories. \begin{figure} \begin{center} \resizebox{0.5\linewidth}{!} 10 Tabulars and Tables {\includegraphics{daylesford.eps}} \end{center} 10.1 Tabulars and tables \caption{View of Daylesford Lake.} Data laid out in a table can be very \label{fig:daylesford} • important for visual presentation. \end{figure} Since the name “table” is already used for the will float the figure, Figure 2, (in this case an • floating table environment, the name EPS image) to a suitable position. “tabular” is used for the environment that creates tabular data. table is completely analogous, except that • its content is conventionally a tabular A tabular environment creates a TEX box environment. • (just like a big letter) so it might need additional formatting to be wrapped around it.

24 For example, •

A tabular \begin{tabular}[b]{l r} Initials & Age \\ LJK & 52 \\ ACK & 16 \\ \end{tabular} might be set in-line.

produces \begin{table*} \begin{center} Initials Age \begin{tabular} LJK 52 {| l c p{0.25\linewidth} |} A tabular ACK 16 might be set in- \hline line. Name & Formula & Comment \\ \hline The common column specifiers are: Sodium Chloride & • l r c p{}, respectively for left-aligned, NaCl & right-aligned, centered, and paragraph Common salt. (“wrapped”) items. The p specifier takes a Chief solid consistuent of seawater. length argument, which gives the desired \\ Magnesium Sulphate & width. The @{} specifier can be used to Mg${}_2$SO${}_4$ & override the default outside and inter-column Hydrated form is Epsom Salts. space. See the various examples to get an \\ idea of how these work. A vertical bar | Calcium Fluoride & makes a vertical line (either between columns, CaF${}_2$ & or as part of a frame around the table). The Occurs as fluorospar. command \hline puts a horizontal line \\ between rows of a table (across all columns), \hline while \cline c1-c2 puts the horizontal line \end{tabular} across only some{ columns.} \end{center} \caption{Selected salts.} More usually, a tabular is big enough to need \label{tab:salts} • to be set inside a floating table environment. \end{table*} So the LATEX in Figure 3 produces Table 1, floated to a suitable place. Figure 3: LATEX to produce Table 1. There is also tabular* environment, which • takes an additional width argument and stretches the table to fill that width. (But only if the table contains stretchable inter-column space.) There are also additional packages, such as • longtable, supertabular, colortbl, and tabularx, which provide tables with additional features, like tables which span multiple pages, have colored backgrounds, and proportionally assigned column widths.

25 Name Formula Comment Sodium Chloride NaCl Common salt. Chief solid consistuent of seawater. Magnesium Sulphate Mg2SO4 Hydrated form is Epsom Salts. Calcium Fluoride CaF2 Occurs as fluorospar.

Table 1: Selected salts.

There is also a tabbing environment, which • has some limited use. The inline formula $\sum_{i=1}^n x_i^2$ can be displayed as 11 Mathematics \[ \sum_{i=1}^n x_i^2 11.1 Math mode \] Note the difference in Mathematics in TEX/LATEX is processed in a size and formatting. • special mode, math mode. produces Some features, like superscripts, subscripts, • and most special symbols are available only n 2 in math mode. The inline formula i=1 xi can be displayed as P Math comes in two flavors: inline and display n 2 • xi Inline math is delimited by: Xi=1 • $. . . $ Note the difference in size and formatting. \(. . . \) or, more verbosely, by A lot of things work differently in math \begin{math}. . . \end{math} • mode. Most noticeable is that, aside from The $. . . $ notation is inherited from TEX. their use to separate tokens, spaces are It’s convenient, but treacherous, since missing ignored in math mode. (In ordinary text, a a dollar sign can cause a large-scale mess. It space normally gives an inter-word space — it is commonly used, and is probably OK for doesn’t in math mode.) LATEX uses its own simple formulas. spacing rules in math mode, which incorporate a lot of knowledge about Display math is delimited by: • mathematical typesetting (like different \[. . . \] spacing around the same symbol depending \begin{displaymath}. . . \end{displaymath} on whether it’s being used as a unary or And also by a number of other environments binary operator). So $- x - y z$ and which give equation formatting and $-x-yz$ both produce x yz. numbering. − − Best advice is to just write the content of the For example: formula, and leave it to LATEX to determine • the spacing. There are special spacing commands to use in math mode, but generally you should use them only on rare occasions to fine-tune the spacing in the formula, when LATEX’s rules haven’t got the aesthetics quite right.

26 In almost all cases, LATEX knows more about → mathematical typesetting than you do. $\alpha$ $\xi$ $\Xi$ $\theta$ $\phi$ \[ n! = \prod_{k=1}^{n} k 11.2 Subscripts and superscripts \] \[ In math mode, subscripts are indicated by _ \sin^2\theta + \cos^2\theta = 1 • ^ and superscripts by \] Grouping is important: \[ • \log \sqrt[n]{x} = \frac{\log x}{n} \] Note the difference between Compare $log$ with $\log$ $a^n+k_j-1$ and $a^{n+k}_{j-1}$. and with $\mbox{log}$. \\ Compare $difference$ with \emph{difference}. \\ produces Compare $k$ with k.

n Note the difference between a + kj 1 and n+k − produces aj 1 . −

Note: α ξ Ξ θ φ • n n! = k ${}^4_2$He kY=1 sin2 θ + cos2 θ = 1 produces log x log √n x = n 4 Compare log with log and with log. 2He Compare difference with difference. k where we’ve put the subscript and superscript Compare with k. on “nothing”, indicated by the empty pair of grouping braces. Notice that in math mode, a sequence of letters is treated as the mathematical product of single-letter variables. So log in math 11.3 A menagerie of symbols and mode doesn’t get you the name of the log operators function, (which is conventionally typeset in roman type). The best way of doing this is to LATEX supports a huge number of • mathematical symbols and operators, far use the command \log. Similarly for \cos, more than can be mentioned here. \sin, etc. The \mbox command sets its argument in roman type, even inside a mathematical formula, so can be used for “log-like” functions which aren’t pre-defined, and also for introducing a few words of text inside a formula, like “if” and “otherwise”. (The various AMS LATEX packages provide slightly better ways of doing this, though.) This also means that putting a word inside • dollar signs is not a shortcut for emphasizing it via italics. The font used and letter spacing

27 will be different. Conversely, if you refer to a variable from your formula in running text, you need to put it inside dollar signs, so that 1 0 . . . 0 it will be typeset consistently as a  0 1 0  mathematical variable, not as an ordinary I = . . . = (δij )  . .. .  letter.    0 0 . . . 1    11.4 “Large” delimiters 11.6 Equations The equation environment displays a \begin{displaymath} • {\left( \frac{x+1}{x+2} \right)} formula and gives it an equation number, ^ 2 which can be labelled and referred to. \end{displaymath} For example: produces \begin{equation} |x| = \left\lbrace \begin{array}{r l} 2 x & \mbox{if }x \ge 0 \\ x + 1 -x & \mbox{otherwise} x + 2 \end{array} \right. Also works with other “bracketing” delimiters, \label{eqn:abs} like (. . . ), [. . . ], \lbrace. . . \rbrace, |. . . |, \end{equation} \|. . . \|, etc., plus “.” (see how equation 1 in 11.6 below is done). produces § 11.5 Arrays x if x 0 x = ≥ (1) The array environment is analogous to the | |  x otherwise tabular environment, but in math mode. − For example, And elsewhere

\[ Equation~\ref{eqn:abs} defines I = the absolute value. \left( \begin{array}{cccc} produces 1 & 0 & \ldots & 0 \\ 0 & 1 & & 0 \\ \vdots & & \ddots & \vdots \\ Equation 1 defines the absolute value. 0 & 0 & \ldots & 1 \end{array} The eqnarray environment displays \right) • numbered equations aligned in something like = \left(\delta_{ij}\right) a three-column array: \] produces \begin{eqnarray} x & = & at^2 + bt + c \\ y & = & dt^2 \nonumber \\ & & \mbox{} + et + f \end{eqnarray}

28 produces 12.2 Lengths

Lengths in TEX, which LATEX rides upon, are • rather rich; however, to simplify a little: 2 x = at + bt + c (2) Lengths can be rigid, a definite size, for which • y = dt2 a unit must be specified (even if the length is + et + f (3) zero). Some of the units used in TEX are pt for A subtle point is that the empty \mbox is to • printers’ points18, mm for millimeters, cm for • force LATEX to treat the leading plus sign on centimeters, and in for inches. the the line as a binary operator, and space it appropriately. Particularly useful are the printers’ measures • em and ex, being respectively the nominal There is even more support for math layout width of an ‘M’ and the nominal height of an • and symbols in the AMS LATEX packages ‘x’ in the current font. (that’s the American Mathematical Society, These provide lengths that scale up and down like the ACM of mathematics). naturally with the choice of font size.

Lengths can be negative. 12 Boxes, Lengths, Space, • LAT X provides numerous predefined lengths. Counters • E – Some are “read-only”—just for 12.1 Caveat information The concepts and commands described here For example, \linewidth, the width of • can be very powerful tools for low-level the current environment (width of text formatting. on a normal page, width of current column in multicolumn layout or However, you should almost never use them minipage). • in the body of your document. – Most can be modified, for customization. If you have some meaningful piece of your For example • document that needs formatting in a particular way, you should almost always \setlength{\parindent}{0pt} define an appropriate command or environment for that piece. sets the paragraph indent to zero. For example Use the low-level formatting commands only • in the definition of that command or environment. \setlength{\parindent}{2em}

Use the command or environment in the would let the paragraph indent vary • body of your document. with the font. You can create your own new lengths, e.g.: This, in keeping with the general principle, • • insulates the body of your document from formatting changes: separating formatting \newlength{\figwidth} from content. 18There is also pp for PostScript points, which are slightly larger.

29 Lengths can be a multiple of an existing You can also save already typeset material • length, e.g.: • into a named box, and re-use it. Relevant are the \newsavebox, \sbox, \savebox, and \usebox commands, and the lrbox \setlength{\figwidth}{0.5\linewidth} environment. This has a number of uses, for example: would set the length \figwidth to half the current \linewidth. – If you have say a complicated logo generated by internal LATEX commands Length can be rubber, or stretchable. repeated on every page, say as part of • There’s a stretchable length called \fill, the page head, then it will save a lot of and \stretch r , which has r times the processing time if you save the logo into stretchability of{ }\fill. a named box and re-use it, rather than regenerate it every time (as would Stretchable lengths are really more like gas happen if you did it via a command). under pressure: They expand to fill available space, sometimes in competition with other – Similarly, say if you want to put CVS stretchable lengths. keyword expansions into the foot of every page. Because of the dollar signs (and other unpredictable active 12.3 Boxes characters that might appear in file In TEX a box is a rectangle of something. names, like underscores), you have to • capture the CVS keyword inside say a It might be as simple as a single character, or • \verb, but you can’t pass these around. as complicated as table or a diagram. The solution is to make a saved box of the CVS keyword using the lrbox The main work of TEX is to “glue” boxes • environment, and then use this box together into bigger boxes (e.g. letters into 19 words, words into lines, lines into wherever needed. paragraphs), and arrange them properly on the page. 12.4 Space and rules \hspace w produces a horizontal space of As we’ve seen, the tabular environment • { } • makes a box. width w. This space, though, is removed if it’s at the More simply, \mbox makes a box out of its beginning or end of a line. • text argument. The \hspace* form gives space that is never \fbox is like \mbox, but it puts a frame removed. • around its box. \vspace h produces a vertical space of • { } \makebox and \framebox are fancier versions, height h. • which permit specification of width and This space, though, is removed if it’s at the alignment. beginning or end of a page. The \raisebox command can be used to The \vspace* form gives space that is never • raise (or lower) a box and also lie to TEX removed. about how big it is, that is make T X treat it E In either case, the length can be negative as if its size were different from what it really • (brings things closer together, even is. This can be useful for fine-tuning layout. overlapping), or stretchable (useful for The \parbox command and minipage relative placement). • environment set material in a certain width 19There are packages to facilitate tyepsetting of CVS or and make a box out of it subversion keywords.

30 There are various predefined useful spaces of You can create your own counters, • convenient sizes, horizontal: \, (thin space), • manipulate them, and use them to number \quad (1em wide), \qquad (2em wide), your own entities (like say an exam question \hfill (stretchable); vertical: \smallskip, environment). \medskip, \bigskip, \vfill (stretchable). Relevant commands are: \newcounter, • Not quite spaces, but similarly “stretchable” \setcounter, \addtocounter, \value, • and handy are \dotfill and \hrulefill. \stepcounter, \refstepcounter A rule is a rectangular blob of ink. Also \thectr and \arabic, \roman, \Roman, • • \alph \Alph \fnsymbol Among other uses, it can make horizontal , , and vertical lines. For example, to have all your chapter • numbers (and references) be in upper-case Roman numerals, you can say \rule{5em}{1pt} \rule[1ex]{5em}{1pt} \rule[-1ex]{5em}{1pt} \renewcommand{\thechapter}% \rule{2pt}{1.0cm} {\Roman{chapter}}

produces in the preamble. Don’t get carried away with this, though.

13 Graphics: Images and Diagrams A very useful special case is a rule with zero width, called a strut. It is invisible, but takes 13.1 The picture environment up room vertically, and can be used for Standard LATEX provides the picture positioning, especially in places where explicit • environment. vertical spaces can’t be used, such as in mathematical formulas. It’s adequate for simple “box and arrow” • diagrams and has the advantage that it uses only the facilities of LATEX and doesn’t rely \fbox{plain box} on any external drivers. \fbox{\rule[-2ex]{0pt}{4ex}% Some visual GUI diagram editors, like xfig, box with strut} • can export in the form of LATEX picture produces environments. But for most uses, it’s too limited and • cumbersome. plain box box with strut Various packages, like eepic, provide a • picture environment with extended ← Similarly for zero-height rules, though they’re capabilities. probably less useful. 13.2 Graphics operators 12.5 Counters Originally there was the graphics package, Counters are like integer variables: they’re • but now the graphicx package is almost • what LATEX uses behind the scenes to number always used, since it provides additional sections, pages, etc. features.

31 \scalebox See Figure 2 and the LAT X for it on page 24. • • E \resizebox The graphic can be resized and rotated via • • the graphics commands mentioned above, or \rotatebox • via special keyword arguments to the For example, \includegraphics command provided by • graphicx.

sleep \\ If you don’t specify a file extension in • A \scalebox{2}{sleep} \\ \includegraphics, then LTEX searches \scalebox{1}[2]{sleep} \\ through a (configurable) list of possible \resizebox{5em}{2em}{sleep} \\ extensions. \resizebox{5em}{!}{sleep} \\ This means that under some conditions, you \rotatebox{30}{sleep} don’t need to commit to the particular \rotatebox{-30}{sleep} graphics format in your document: For Figure 2, I could have said just produces \includegraphics daylesford , and LATEX would have picked up{ what was }available (in this case EPS). sleep Generally, in order process the graphic sleep • properly LATEX needs access to its “bounding sleep box” (which describes how big it is). Formats like EPS and (encapsulated) PDF store this sleep information in the file in a form that LATEX can access. But for other formats you may sleep have to take additional steps to tell LATEX about the bounding box. sleep sleep 14 Breaking Up Your These rely on capabilities beyond DVI, by • passing “specials” Document 2: They work with dvips and pdflatex, but 14.1 \include • may not work with other drivers. Running latex on a large document can be • The pstricks package provides very powerful very time-consuming, especially when you’re • facilities for creating graphics, but works only developing a document and need to run with PostScript output. latex often to debug your document. In rare cases, a document can be so big that 13.3 Including graphics • it exceeds your computer’s memory capacity Use \includegraphics. to process it all in one go. • You could break up your document into Many graphics and image formats are • • supported: for example, PDF, EPS pieces, and \input these pieces from a (Encapsulated Postscript), PNG, JPEG, GIF. top-level document, then comment-out \inputs for all but the pieces you’re actively EPS requires using a PostScript driver, like working on. But this is cumbersome, and • dvips. messes up cross references. PDF requires the use of pdflatex. •

32 \include provides this capability, but in a You can use it directly, but it’s only really • much more convenient way. • viable for the simplest cases \include acts like \input, but for each file it • reads in, it maintains its cross-referencing 15.2 Using BibTEX information in its own corresponding Much better is to have your bibliography individual .aux file. • automatically generated and formatted. In the preamble, you can put an • Where you want your bibliography, you put \includeonly command, giving it a • \bibliography list of biblio comma-separated list of included files. databases . { } Only those files are processed, but they use The argument is a comma-separated list of (mostly correct) cross-reference and special databases (.bib files) to use for page-number information from the .aux files bibliographic information. from previous runs. Many bibliographic databases are already For example, on the simple top-level available in BibTEX format. They may be a • document: shared resource of a research group. The online database CiteSeer provides BibTEX entries. \documentclass{article} Usually, though, you’ll need to create at least \includeonly{experiments,results} some BibT X entries of your own. \begin{document} E \include{front} You also need to specify \include{introduction} • \bibliographystyle style where style \include{experiments} specifies the style you{want for} your \include{results} \include{conclusions} bibliography. \end{document} LATEX’s standard bibliography styles are plain, unsrt, alpha, and abbrv. latex would process and produce output Plus there are numerous contributed styles, from only the files experiments.tex and including those required for various journals. results.tex. Writing new bibliography styles can be done, One restriction is that the output of an but it’s a job for wizards. More feasible is to • \included file must always start a new page. make small modifications of existing styles. Since \included files almost always are The LATEX book [7] says that the top-level pieces, like chapters, which start on \bibliographystyle declaration can go a new page anyway, this is hardly ever a anywhere after \begin document , but I’ve { } problem in practice. had it work as expected when put in the If the pieces don’t naturally start on a new preamble. page, like sections of an article, then you can For example, \include them during development, and turn them into \input for the final runs. \bibliographystyle{plain} \bibliography{ljk-latex} 15 Bibliography appears towards the end of this document. 15.1 DIY: thebibliography In your document you cite a paper using the • LATEX provides a thebibliography \cite command giving a unique identifier for • environment for formatting bibliographies each paper:

33 1. Run latex once on your document. Stuff about bibliography can be latex will complain about undefined found in~% \cite[\S4.3 \& Appendix~B]% citations and references, but this is {latex-adps}, normal. and in~\cite[Ch.\ 13]{latex-comp}. On this pass latex records the identifiers of the cited papers in the The most important {\LaTeX} book .aux file. is~\cite{latex-adps}. Very useful is~\cite{latex-comp}, while 2. Run bibtex. It reads the .aux file, more specialized books are~% searches the databases for the cited \cite{latex-gracomp,latex-webcomp}. papers, and writes the formatted bibliography to the corresponding .bbl A huge amount of information is file. available on~\cite{texliveCD}, 3. Run latex again. It will pick up the including~% bibliography automatically and put it at \cite{lshort,UKtexfaq,texlive-guide}. the indicated place, but it may still complain about undefined references. produces 4. Run latex a third time, to finally resolve any references to the Stuff about bibliography can be found in [7, bibliography. 4.3 & Appendix B], and in [4, Ch. 13]. Note that it’s probably cleanest if the The§ most important LAT X book is [7]. Very E • command argument is the base of the .tex useful is [4], while more specialized books file, like latex foo and bibtex foo for are [6, 5]. foo.tex—latex looks at the corresponding A huge amount of information is available .tex file, and bibtex looks at the on [10], including [8, 3, 9]. corresponding .aux file.

where the references are to papers in the Of course, you only need to go through this bibliography. • full process if you’re starting from scratch, and you want a final version. \nocite causes a reference to be listed in the • bibliography without putting a citation in the During development you normally only need text. • to run bibtex when you’ve added new The form \nocite * pulls in all the papers citations (or removed old ones). { } from the listed databases. It’s useful for If you just run latex once, at worst your preparing stand-alone bibliographies, though • citation numbers may be temporarily out of biblist perhaps the package is better for synch. This is usually acceptable during this purpose. development. Extended bibliographic facilities are provided • by a number of packages, including natbib, 16 Collaborative Document cite, citesort, overcite, chicago, chapterbib, bibunits. See [4]. Development

15.3 Running bibtex 16.1 Version control—CVS A Getting your bibliography and citations LTEX has two important characteristics: • • completely correct may take up to four steps: 1. Sources are ordinary text files

34 2. A large document can be broken across are binary, not text, then you’ll need to a number of files, using \input, specify -kb on the cvs add command. \include, and \includegraphics.

These make LAT X documents particularly 16.2 Build tools—make • E suited for being put under a version-control Because all the LATEX-related processors, like system like CVS or subversion, with all the • latex, bibtex, dvips, etc., are benefits that brings, such as: shell-invokable programs, it’s very convenient to use a build tool, like make to generate your – Team development: Shared repository final documents. with individual checked-out workspaces, possibly on remote machines. With GNU make, you can write makefile rules • – Version control and branching. like:20 – Tracking and documentation of rationale for changes via log messages. %.dvi : %.tex ; latex $< – Diffs for focussing on changes. %.ps : %.dvi ; dvips -t a4 -o $@ $< %.pdf : %.ps ; ps2pdf $< $@ – . . .

Just a few things to note: Or, if you prefer to go direct to PDF: • – Because CVS diffs are line based, it’s not a good idea to make unnecessary %. : %.tex ; pdflatex $< changes to the line structure of your source, since they make the real diffs If your top-level LAT X document includes • E hard to locate. other files (whether LATEX or graphics), then For example, if you change a few words you can specify them as additional in a paragraph in the source file, it’s not dependencies of the corresponding DVI file a good idea to re-fill that paragraph in (or PDF file if you go straight to PDF). your text editor (say by M-Q in emacs). It is possible to generate such dependencies Some text editors, on Windoze in • automatically. There are a few Perl scripts particular, store text paragraphs as around that purport to do this. I’ve even single long lines, and just wrap them to written one myself. But they aren’t entirely fit for the display. If you change a single satisfactory. Problems: character of that paragraph, the whole paragraph will show up as a diff line, – In C, all #includes are visible in the again making it hard to see the real source file, while in LATEX an \input differences. may result from the expansion of a – Because $ is an active character in user-defined command, which may LATEX, it takes some contrivance to get involve some arbitrary computation. So CVS keyword substitutions, like $Id$ to you can’t completely find out what’s work. Sure, you can easily put them input except by almost fully simulating inside a comment, but getting the CVS latex. stuff to print in the document is trickier. – Having automatically generated .tex It can be done—see how it’s done in the files (such as is done by transfig) can source of this document to get some interact badly with latex’s search along ideas, or use one of the packages its search path given by the environment → providing this facility. 20In most cases, it’s better also to provide the -Ppdf option – Remember, if you’re checking-in other to dvips, so dvips chooses font representations that convert document source files, like images, which better into PDF.

35 variable TEXINPUTS. Suppose you a character in your source file, then save it \input a file that doesn’t exist yet but and remake (you’ll probably be editing it is supposed to be created as needed in anyway). Likewise, have a target to force the current directory. The path search running of bibtex as needed. for dependencies might find another file Another issue is that, even if latex by the same name elsewhere on the • search path, and take that as satisfying encounters errors, it will still usually create a the dependency. And make will therefore DVI file (if only a partial one), “successfully” never trigger creation of that needed from make’s point of view. .tex file. If the target you’re aiming to create is a say a PostScript file using dvips, then even after One better solution to this is to grovel you’ve modified the LATEX sources to fix the through the .log file, and parse out the errors, make will still think that the messages that latex writes there when it PostScript file is up to date with respect to reads a file. An even better solution (though the current DVI file. Again, the pragmatic A still not perfect) would be to redefine LTEX’s solution is to force rebuilding. various input commands so that they write the dependencies to a file in proper makefile As well as using make to control running format. Anyone feel like writing such a • latex, you can also use it to control other package? transformations of files that contribute to A less strenuous solution would be to define your document, for example: your own variant versions of the commands, – Automated conversion of diagrams say \Input, \Include, and produced by xfig into EPS using \Includegraphics, which call the underlying transfig. Much more convenient than A LTEX commands, but also record what file always needing to invoke the “export” has been read. Then always use your variant function in the GUI. versions in your document. Still not a perfect solution. . . – Automated processing of images, say for contrast enhancement for better One aspect of LAT X which make doesn’t presentation using programs from the • E handle well is that LATEX actually entails pbmplus/netpbm or ImageMagick some circular dependencies, which packages. You may need to do different fundamentally violates make’s mode of kinds of enhancement for different operation, which assumes (reasonably enough purposes for all your images. for most compilers) that the dependency graph is acyclic. Most obviously, latex both 16.3 Automatic generation of LAT X needs and produces the .aux files. E Furthermore, latex needs the .bbl file It’s reasonably straightforward to write • produced by bibtex, but bibtex needs the scripts (especially Perl scripts) or programs .aux file produced by latex. to generate LATEX, either complete stand-alone documents, or fragments that can The pragmatic solution is to express just the be inputted into other LAT X documents. “mainstream” dependencies in the makefile, E like of the DVI file on the top-level and This has numerous uses. For example, inputted LATEX and graphics files, and be • prepared occasionally to intervene by hand: – If you have a lot of numeric data, you Use something like make -W foo.tex can write a script to wrap the ↓ foo.dvi to get make to act is if foo.tex had appropriate LATEX around the data to been changed, thus forcing a re-run to resolve format it nicely into a table (using the cross-references. Or remove the DVI file. Or, tabular environment). Be warned, this ↑ less elegant, but simpler, just type and delete often involves a lot of backslashes, since

36 in both C and Perl you need to documentation and boilerplate C++ code to backslash-escape a backslash in order to support some extensions to C++. LATEX/TEX get it printed in the output. was an obvious choice for the first task – Suppose you have certain constants (generating documentation). But then the (numeric or string) that must appear implementors realised they could also use A consistently in both program source LTEX/TEX for the second task: code code and in documentation. (“The generation. (This uses some lower-level maximum length of a address field is 128 features by which TEX can open and read and characters.”) Rather than type them in write files.) This is the only case I know of of twice, with the risk of inconsistencies, an (admittedly simple) compiler written in you can create a simple configuration file TEX! which defines these constants, and then write scripts to generate consistently 17 Miscellaneous Topics both C header files of #defines, and A LTEX input files of \newcommand 17.1 Index and glossary definitions. For example, from something like: For a large work, like a book, a good index is • essential. ADDRMAX 128 LAT X provides support for preparing an • E you’d generate both index: – Put \usepackage makeidx and #define ADDRMAX 128 \makeindex in the{ preamble} for C, and – Attach \index with index entry for each place you want indexed, e.g. \newcommand{\ADDRMAX}{128} A gnat\index{gnat} with for LATEX. gnarled wings gnashed ... Generation of LATEX from XML is mentioned • elsewhere. (From [7, p. 75].) – Put \printindex where you want the There are a number of packages that support index • conditional text in LAT X, conceptually E – You also need to run the makeindex similar to #ifdef in C, without getting into program to process the raw output from full programmability of LAT X (for which see E the \index commands into a formatted below). The optional package is probably index (somewhat analogous to bibtex). the best of these. There are analogous facilities for preparation If you need to produce LAT X documents in a E • of a glossary • number of different formats, rather than continually editing, you can put all your For more information, see [7, 4.5] and [4, content into files to be inputted, and • Ch. 12]. § automatically generate various top-level A LTEX files, each of which say defines various 17.2 Verbatim text different settings in the preamble, and then inputs the content in the body. Sometimes you want LATEX not to interpret • all its special characters. Actually the opposite: For the Image • Understanding Environment, it was necessary, Especially if you want to give computer • from a common description to generate both program listings, or LATEX examples.

37 You can “escape” these characters, but it gets – Allow other characters and accents • tedious. Via special markup, like \"{o} for o¨ ∗ The verbatim environment typsets a chunk (only viable for small usage) • of raw text in typewriter font, obeying lines, Via special transliteration schemes ∗ and treating all characters literally. (as used for some Indian languages). May need auxiliary programs. The \verb command does this for short By accepting other character sets • pieces of text. ∗ and encodings (e.g. Chinese, For example, ). May require a special • version of the latex program.

Ordinary {\LaTeX} See, in particular, the babel package. on a new line? • This is an area in flux. \begin{verbatim} • Ordinary {\LaTeX} on a new line? 17.4 LAT X and the Web \end{verbatim} E \verb+#$_^\{}+ There are several ways of putting LATEX • documents on the Web: produces – As PDF, either produced directly using the variant pdflatex, or via PostScript Ordinary LATEX on a new line? using dvips21 and pdf2ps (free as part of ghostscript) or Acrobat Distiller. Ordinary {\LaTeX} on a new line? – By conversion to HTML using LATEX2HTML or tex4ht (or to XML). #$_^\{} – Via special browser plugins that support (a variant of) LAT X, like IBM’s Because these change the way LATEX reads in E • text, they’re restricted: can’t be passed in Techexplorer. arguments to commands. – All have their pros and cons. . . There is also the alltt environment, which – All have ways of adding clickable • allows some limited LATEX processing. hypertext links to your document, both internal and external (to the Web). Not to be used for visual formatting! • It’s possible to go the other way: from XML For that use say the tabular or tabbing • to generate LAT X automatically for nice environments. E typesetting of information extracted say from The moreverb and fancyverb packages a database. → • provide additional verbatim support, including input from a file and line 17.5 PostScript fonts numbering. By default, LATEX uses the Computer Modern • family of fonts designed by Donald Knuth 17.3 Multilingual LATEX originally for TEX. LAT X can support other languages in a E A • number of ways: These give ordinary LTEX documents a • subtlely distinctive look. – Allowing language specific 21 -Ppdf customization, e.g. \chapter produces As mentioned earlier, best with the option. “Chapitre” in French

38 LATEX can make use of many other kinds of Other packages, like pagestyle and • fonts, but setting it up is technically • fancyheadings provide more facilities, like demanding. three-part titles for the head and foot of each page. However, there are some packages which give • you pretty simple access to a number of PostScript font families (provided they’re 17.7 Color available on your system). \usepackage color • { } This document could be set in the standard Some predefined color names, like red, PostScript Times, Helvetica, and Courier • green, blue. . . fonts by You can define your own named colors, in • RBG, CMYK, or grayscale. \usepackage{times} Use them for text and boxes. Before you do this too freely, keep in mind • • For example, the LAT X input shown in that most of the many mathematical symbols • E are usually available only in one of the Figure 4 produces the following output: Computer Modern fonts. So, even if you choose a different font family for the main Some red text and some blue text. text of your document, any mathematics will Text in SpringGreen still use Computer Modern. This can cause Some text in a pale blue box. some subtle stylistic clashes. Because of the work involved in creating a White on blue in a gray frame • font, many fonts are proprietary and must be Predefined colors: black white red licensed. Still, there are a large number of green blue yellow cyan magenta freely available fonts. Can also set the background color of the page 17.6 Page style and headings • using \pagecolor color . { } Standard LATEX supports a number of page • styles: plain, empty, headings, and 17.8 Hyphenation myheadings (the last used in conjunction with \markright and \markboth commands). If typesetting could only break lines between • words, then it would be very hard to get nice They are set globally with the fully justified paragraphs. • \pagestyle style command. { } So sometimes a word is broken and • The \thispagestyle style sets the page hyphenated at a suitable point. • style temporarily for just{ the}current page. LAT X’s automatic hyphenation algorithm • E The page numbering can be set via the generally works very well, but sometimes it • \pagenumbering num style , where needs help. num style can be{arabic, roman} , Roman, Locally, you can insert the discretionary alph, or Alph. It also resets the page counter • to 1. hyphen command \- into a word that’s giving trouble. This inhibits any other There is also a titlepage environment, hyphenation, so you’ll generally need to put • which produces an “empty” style page. This is for doing title pages more complicated than can be done with \maketitle.

39 multiple \-s into the word, at all reasonable hyphenation points.22 Globally, you can use the \hyphenation • command to declare the allowed hyphenation points for a word whenever it’s used. The argument is a space-separated list of words, \definecolor{paleyellow}% {rgb}{1.0,1.0,0.7} each with hyphens at the allowed \definecolor{paleblue}% hyphenation points. {cmyk}{0.1,0.1,0.0,0.0} \definecolor{midgray}{gray}{0.5} 17.9 Fragile versus robust Some \textcolor{red}{red text} commands and some {\color{blue} blue text}. Things in LATEX (including command \noindent • arguments) are subject to multiple steps of \textcolor[named]{SpringGreen}% processing. {Text in SpringGreen} Some arguments are special—because of the \noindent • way they’re handled, they’re subject to a \colorbox{paleblue}% double dose of processing. {Some text in a pale blue box.} An example is the heading argument to a { sectioning command. It’s processed once by \setlength{\fboxrule}{3pt} the sectioning command, but it’s also stored \setlength{\fboxsep}{5pt} and gets reprocessed over again when inserted \noindent into the table of contents. \fcolorbox{midgray}{blue}% moving {\color{white} Such an argument is called a White on blue in a gray frame} argument. } Most LATEX commands stand up fine to this • double processing—they are called robust. {\large \noindent However, some commands, because of the Predefined colors: • way they’re implemented, don’t work when \textcolor{black}{black} subject to this double processing—they are \colorbox{black}{% fragile \textcolor{white}{white}} called . \textcolor{red}{red} So, you can’t use a fragile command directly \textcolor{green}{green} • in a moving argument. \textcolor{blue}{blue} \textcolor{yellow}{yellow} This means that when reading about a \textcolor{cyan}{cyan} • command you may need to pay attention to \textcolor{magenta}{magenta} whether it’s robust or fragile. } If you do need to use fragile commands in a • moving argument, you can “protect” them by Figure 4: LAT X to produce sample color output. E putting \protect immediately in front of every fragile command (including those that are in arguments to other commands).

22Remember that while the word may now need hyphen- ation only at one point, future changes elsewhere, like chang- ing the wording of the paragraph, or changing margins, may require different hyphenation.

40 Most robust commands are unaffected by utility for creating makefiles to do the • \protect, so if you’re unsure about whether conversions. a command is fragile or robust, there’s usually no harm in putting in the \protect anyway. AbiWord and gnumeric These are respectively a word-processor (like MS Word) and a But more usually, you don’t bother putting in spreadsheet (like MS Excel). They can read • \protect until you need to in response to the corresponding MS formats, and also error messages from LATEX. (Though, coming export LATEX. Unfortunately, by then all the from deep inside LATEX the resulting error semantic markup has been lost (one of the messages are often obscure.) advantages of LATEX). Still, they have some use if you’ve been given a document in some 17.10 Some additional useful free MS format and need to make some use of it A programs in the LTEX world. xdvi X-based DVI viewer. There are many others. . .

Ghostscript (gs) PostScript/PDF interpreter, 17.11 LAT X debugging converter and viewer. The programs gv and E GSView are GUI wrappers around gs. The Making sense of logs, warnings and error Ghostscript package comes with many messages, etc. Postscript-based conversion programs, Sorry, this section still has to be written. PostScript to various image formats, and to In the meantime, refer to [7, Chapter 8]. and from PDF. dvips Converts DVI to PostScript.23 17.12 More advanced programming features pbmplus/netpbm A collection of image conversion and processing utilities. While it’s designed to look most of the time • A ImageMagick is similar, arguably better. like a declarative markup language, LTEX (because it’s built on top of TEX) is in fact a xfig and dia GUI programs for drawing 2D fully fledged programming language. diagrams. Can export to various formats The ifthen package provides control supported by LATEX. • structures like if-then-else and loops. transfig fig2dev Converts xfig’s .fig files A The calc package provides facilities for into various formats supported by LTEX. • Actually, fig2dev is the work-horse, callable making calculations with counters and lengths as a command-line utility (say in makefiles) much easier—it lets you write expressions. to do the conversions, while transfig is a The truly intrepid can delve into the arcane • 23Here is as good a place as any to point out that the underlying programming facilities of TEX. LATEX system does not keep complete information about all its fonts. This would take up too much space. In practice, the full font information is generated as needed (by Meta- 17.13 Tips’n’tricks Font). It is cached, however, and re-used on subsequent runs. So if you’re the first person in a while to use a particu- This section is far from complete. lar font (and size) on your machine, then you’ll see (and have to wait for) MetaFont in action generating the full font de- The main thing is not just to learn the scriptions. It turns out (obvious if you think about it) that particular list of tricks given here, but to LATEX doesn’t need to know all the information about the develop a sense of what’s possible. font, just sufficient to be able to decide where on the page each character can fit. So, it’s only when you run later pro- A grams, like dvips and xdvi, which need this full information 1. When creating a LTEX document for the first (like the actual letter shape), that you might see MetaFont time, it’s a good idea to run latex fairly running. frequently, so that your search for the

41 inevitable errors can be focussed on the new processing of the label. The only exception to stuff you’ve added since the last error-free this is the captions of floating environments run. For this, \includeonly comes in very like figures and tables: Since no page break handy, since only that part of the document can come inside the float, the label can come you’re actively working on needs to be fully anywhere after the caption (even after processed. intervening whitespace). How often you need to run latex depends on In a similar vein, keep in mind that the how complicated is what you’re typing. If it’s references for a figure or table are set by the just simple textual material, you might go on \caption. So, if you mistakenly put the for pages without rerunning latex. For \label before the caption then it will complicated mathematics you might rerun probably pick up the reference to the latex after adding only a few symbols, to surrounding section at time of processing. build up the formula bit by bit. 4. Handy is \ensuremath, which sets its 2. For something really complicated, you might argument in math mode regardless of whether even create a “mini-document”, which you’re already in math mode or not. Its main contains the preamble of your actual purpose is in defining commands which can document, and whose document body be used in or out of math mode. For contains only the difficult piece of LATEX example, if you want to use some math-mode you’re working on. You can re-run latex on feature like a special symbol in ordinary text: this mini-document very quickly, and speed up your development cycle. Then you can cut \newcommand{\love}% and paste the working stuff into your real {$\heartsuit$} document—or better, keep your experimental LATEX in a separate file and use \input to read it into both your mini and real Used in ordinary text, the first dollar sign documents. puts you in math mode, making the \heartsuit symbol available, and the 3. If you put a \label just before the second dollar sign tak♥es you to back to \end document , then the pageref for this { } ordinary text mode (so called “LR”, “left to label will give the number of pages in the right”, mode). But if you happened document. It can then be used, say in unsuspectingly to use this command in math conjunction with the fancyheadings mode, weird things would happen: the first package, to give page numbers like “Page m dollar sign would take you out of math mode, of n”. To get this to work perfectly, you have and you’d get an error, because the to attach the \label to the last non-space \heartsuit symbol is available only in math thing, otherwise there’s a small chance that mode. Defining the command instead as LATEX might put a page break immediately after the non-space thing, before it fully processes the label, so the label might end up \newcommand{\love}% on an extraneous apparently all-blank page of {\ensuremath{\heartsuit}} its own, making the page count one higher than it should be. solves the problem: it would work as intended In fact, this is a special case of a more general in either context. issue. If you want to give a pageref to some construct, say a sectioning command, then 5. The tabular environment is far more useful you need to put the \label immediately after than you might think: don’t think of it as that construct (without any intervening being restricted to conventional tables. space), to ensure that no page break can For example, suppose you want a particular come between the construct and the row/column layout of some images. You

42 make a figure environment so the whole thing can float. The contents of the figure environment is a tabular environment, which gives you the row/column layout inside the top-level figure. The actual cells of the tabular \includegraphics the images. There’s nothing to stop a figure from having multiple captions, so each sub-image can have its own separate caption, though sometimes you need to play tricks with minipage \begin{figure*} environments to make sure LATEX is in the \newcommand{\Img}[1]% correct mode when processing the captions. {\resizebox{#1}{!}% For this sort of thing, the subfigure package {\includegraphics% may be helpful. See [4]. {daylesford.eps}}} \begin{center} 6. The main obvious use of the \multicolumn \begin{tabular}{rlr} command in a tabular is to make a cell that \begin{tabular}{|l r@{$\cdot$}l|} spans multiple columns. But it has many \hline other uses, for example, you can use a \multicolumn{3}{|c|}% one-column \multicolumn to make a centered {\bf Approximations} \\ heading over an otherwise p{} column. $\pi$ & 3&14159254\ldots \\ $e$ & 2&71828\ldots \\ 7. Usually the cleanest way to get a more $e^\pi$ & 23&14069263\ldots \\ complicated tabular arrangement is to use \hline nested tabulars—that is, tabulars whose cells \end{tabular} are in turn tabulars.24 In cases like this it’s & \begin{tabular}{@{}c@{}} generally better if the internal tabulars have \Img{8em} \\ \Img{4em} \\ \Img{2em} @{} at either end of their column \end{tabular} specification to suppress the space that’s & normally put around a free-standing tabular, \begin{tabular}{@{}c@{}} since the inner tabular will already be getting \rotatebox{90}{This extraneous the ordinary intercolumn space from the text is provided by a rotated box.} outer tabular. \end{tabular} \end{tabular} The output shown in Figure 5 is produced by \end{center} A the LTEX shown in Figure 6 (which also \caption{Using nested demonstrates next point). Note that the \texttt{tabular}s for layout.} layout is constructed from a three-column \label{fig:tabular} one-row outer tabular. Each cell is in turn \end{figure*} constructed by a nested tabular: First a fairly simple table of numbers with a trick for aligning the decimal points, then a Figure 6: LATEX to produce Figure 5. one-column, three-row layout of images, last a one-cell tabular containing some rotated text. (You can see that for a one-row tabular, like the outer tabular here, the choice of

24You can play dirty tricks in tabulars with things like struts and negative vertical space to control positioning— like to make something contained in one cell actually print in the cell above it. But this is very messy and fragile, and not recommended unless you have no other choice.

43 x. o b rotated a y b

Approximations π 3 14159254. . . vided e 2·71828. . . pro eπ 23·14069263. . . is · text extraneous This

Figure 5: Using nested tabulars for layout.

column alignments, like l, c, r, doesn’t really \evensidemargin. There are some packages matter, since each cell will completely fill its to simplify the setting of margins and other column width.) page-layout parameters. This strategy is summarized in Les’s LAT X E 10. TEX measures the page from the top left Proverb: (with the 1 inch offsets). PostScript’s Usually, the solution to problems coordinate system is from the bottom left with tabulars is: more tabulars. corner. So to convert properly from DVI to PostScript, a program like dvips needs to 8. One way of getting a column of numbers know the actual height of the page. (Think aligned on their decimal points is to use a about it in terms of the coordinate column specifier like r@{$\cdot$}l: the transformation.) In many (not all) integer parts end up right justified in one installations, the default setup for dvips is column, the decimal fractions left-justified in for U.S. Letter size paper. If you print the the next, and the usual inter-column space is resulting PostScript output on A4 paper, it replaced by the decimal point. See Figure 5. will be wrongly offset on the page. The way There are, of course, other ways. . . to fix this is to set the paper size explicitly using the -t a4 option to dvips, or in your 9. Knuth decreed that the origin for a T X page E own .dvipsrc configuration file. (Read the be 1 inch down and 1 inch in from the top dvips man pages.) left corner of the page. (This was to fit with the common American practice of 1 inch 11. Postscript printing in landscape format will margins all around.) This offset can cause require a -t landscape special option to some confusion. Setting the length dvips. \topmargin to 0pt gives you a 1 inch top margin. To get a smaller top margin, you 12. The packages picinpar, floatfig, and have to make \topmargin a suitable negative wrapfig provide different ways of getting length. Similarly for \oddsidemargin and

44 figures which the text “wraps” around. possible at the same position in the file. This Again, see [4]. means that when you’re developing a document, you surely don’t start up a new 13. The url package provides some commands to xdvi or gv for each edit cycle (which would facilitate typesetting of URLs, similar long typically load afresh at page one); instead, file pathnames, and email addresses. See [3]. you keep the same xdvi or gv process More simply, the TEX command \slash running, and let it reload and redisplay after produces a slash after which TEX can put a each latex run the part of the document line break if it needs to. Useful for constructs you’re currently working on. This isn’t like “and/or”. The \linebreak[0] construct WYSIWYG, but can give you reasonably can also come in handy in similar situations, tight feedback. to give LATEX a hint as to where it might break something that’s too long to fit on a Note that xdvi can display embedded line. PostScript (EPS) figures in a DVI file. It does this by calling gs as what in current 14. Standard LATEX provides for only one-column parlance would be called a “plug-in”. or two-column printing. The multicol package permits more flexible and more 17.14 What’s missing? general multi-column printing (though this should not be taken to extremes). See [4]. Probably quite a lot. . . • 15. Occasionally, the associated files, like .aux . . . but less than there used to be. • can get messed up, creating mysterious errors on the next run. One way in which this can 17.15 Learning and getting more happen is when you’re switching between The file sample2e.tex in the standard LAT X latex and pdflatex. Even though they’re • E A distribution illustrates many features of both LTEX, the two versions write slightly different information to the .aux files, which LATEX. can confuse the other. The solution to this is If you don’t want to spend money on books, .aux just to remove the files and start afresh. • the “Not So Short Introduction to 16. Anything after \end document in the source LATEX 2ε” [8] and the “TEX FAQ” [3] on the file is ignored. It can{provide a}useful place TEXLive CD [10] are very good starting for parking stuff that you don’t want to be points. This document (or future versions) processed, but want to keep around for should be available via possible future use. http://www.cs.mu.oz.au/~ljk/latex.html. There is also another LAT X introduction 17. That environment arguments can be used • E only in the first “front” part of an accessible via the MU-CSA website. (I don’t environment is a consequence of how have the URL handy.) environments are implemented. It ends up The LATEX “Bible” is Leslie Lamport’s LATEX: being more a minor annoyance than a real • A Document Preparation System[7]. defect. If you need variable content in the second “tail” part, you can always store it It covers “standard” LATEX and is probably somehow in the first part (perhaps in a an indispensable reference for regular LATEX named box), then retrieve in the second part. users. The T Xlive CD [10] and CTAN [1] 18. Plug for xdvi and gv: Both xdvi and gv are • E set up to work well in development. When (Comprehensive TEX Archive Network) are their window is exposed/deiconified, they sources for a vast quantity of LATEX check whether the file they’re viewing has distributions, packages, and associated been updated, and if so, reload it, as far as software and documentation.

45 The LATEX Companion [4] is a very helpful However, it corresponds closely with LAT X in • • E reference for those who want to do more that any TEXmacs document can be sophisticated things with LATEX. exported as LATEX, and any reasonable LATEX macs It describes many of the additional packages document can be imported into TEX with only little work (mainly to provide that extend the powers of LATEX, and shows T Xmacs definitions of non-standard how to modify LATEX internals, for example E how to change the formatting of section commands). headings. T Xmacs also uses T X’s font machinery to • E E Reference [6] treats more advanced graphics, produce high-quality typesetting, particularly • including such things as typesetting musical of mathematics. scores and chemical structural formulas. T Xmacs can also be run in batch mode, and • E A has an open external plain-text Reference [5] shows how to put LTEX 25 • documents on the Web. representation, and so has much the same advantages as LATEX in this regard. 17.16 TEX’s limitations A nifty feature of TEXmacs is the ability to • run an interactive terminal session inside a T X was originally developed nearly 30 years E document. This is particularly useful for • ago. That it’s held up so well is a tribute to interacting with a symbolic algebra system, Donald Knuth’s conception. like maxima, with the results of the session However, TEX and thus LATEX do have some incorporated into the document. • intrinsic limitations. The GNU musical typesetting engine, • For example, because of the way they’re Lilypond, is a front-end for LATEX. • internally encoded, T X can use at most 256 E It’s worth mentioning that both T Xmacs different counter variables, and at most 256 E • and Lilypond use Scheme (Guile) as their different dimension variables. Very few internal scripting language. documents, even the size of books, bump into these limits. But very complicated documents that use many packages, [4] is an example, References can run into trouble, and require special techniques. [1] Comprehensive TEX archive network. Central website is http://www.ctan.org; Australian Similarly, T X was set up to use 8-bit • E mirror is characters (leading edge at the time, when http://mirror.aarnet.edu.au/pub/CTAN/. many computers still used 6-bit characters). Handling bigger character sets, like Unicode, [2] Salvador Dali. The Unspeakable Confessions requires special versions of TEX. of Salvador Dali, as told to Andr´e Parinaud. W.H. Allen, London, 1976. Translated from 17.17 TEXmacs and Lilypond the French by Harold J. Salemson. T Xmacs provides similar functionality to [3] The UK TEX FAQ: Your 244 Questions • E LATEX through a scriptable WYSIWYG Answered, 2002. In file interface modelled on emacs. FAQ/english/newfaq.pdf on [10]. 25T Xmacs actually has three different text representa- TEXmacs is different from LATEX: it has its E • tions: TEXmacs’s own representation, which is like XML own representation that overcomes the but much more compact; full XML; and as Scheme list data, historical limitations inherited from TEX. which is very convenient for processing TEXmacs documents in Scheme.

46 [4] Michel Goossens, Frank Mittelbach, and and Frank Mittelbach Alexander Samarin. The LATEX Companion. and Alexander Samarin}, publisher = aw, Addison-Wesley, Boston, 1993. address = "Boston", year = 1993, [5] Michel Goossens and Sebastian Rahtz. The isbn = {0-201-54199-8} LATEX Web Companion: Integrating TEX, } HTML and XML. Addison-Wesley, Reading, Massachusetts, 1999. @book{latex-gracomp, title = {The {\LaTeX} Graphics Companion: [6] Michel Goossens, Sebastian Rahtz, and Frank Illustrating Documents with {\TeX} and PostScript}, A Mittelbach. The LTEX Graphics Companion: author = {Michel Goossens Illustrating Documents with TEX and and Sebastian Rahtz PostScript. Addison-Wesley, Boston, 1997. and Frank Mittelbach}, publisher = aw, [7] Leslie Lamport. LATEX: A Document address = "Boston", Preparation System year = 1997, . Addison-Wesley, isbn = {0-201-85469-4} Reading, Massachusetts, 2nd edition, 1994. } The LATEX “Bible”. @book{latex-webcomp, [8] Tobias Oetiker, Hubert Partl, Irene Hyna, title = {The {\LaTeX} Web Companion: and Elisabeth Schegl. The Not So Short Integrating {\TeX}, HTML and XML}, author = {Michel Goossens A A Introduction to LTEX 2ε: Or LTEX 2ε in 95 and Sebastian Rahtz}, Minutes, 2001. Version 3.20, in file texmf/ publisher = aw, doc/guides/lshort-english/lshort.pdf address = {Reading, Massachusetts}, on [10]. year = 1999, isbn = {0-201-43311-7} } [9] Sebastian Rahtz. The TEX Live Guide, 7th edition, 2002. In directory @manual{UKtexfaq, texmf/doc/tldoc/english/File on [10] in title = {The UK {\TeX} FAQ: PDF and HTML. Your 244~Questions Answered}, editor = {Robin Fairbairns}, [10] T XLive CD. Available from various sources. key = {Fairbairns, Robin}, E year = 2002, mon = may, note = {In file \path{FAQ/english/newfaq.pdf} A Behind The Scenes: How on~\cite{texliveCD}} It’s Done } @manual{lshort, A.1 Listing of ljk-latex.bib title = {The Not So Short Introduction to {\LaTeXe}: @string{aw = "Addison-Wesley"} Or {\LaTeXe} in 95 Minutes}, author = {Tobias Oetiker and Hubert Partl @book{latex-adps, and Irene Hyna and Elisabeth Schegl}, title = {\LaTeX: A Document Preparation year = 2001, mon = aug, System}, note = {Version~3.20, in file author = {Leslie Lamport}, \path{texmf/doc/guides/lshort-english/lshort.pdf} publisher = aw, on~\cite{texliveCD}} address = {Reading, Massachusetts}, } year = 1994, edition = {2nd}, @manual{texlive-guide, note = {The {\LaTeX} ‘‘Bible’’}, title = {The {\TeX} Live Guide}, isbn = {0-201-52983-1} edition = {7th}, } author = {Sebastian Rahtz}, year = 2002, mon = may, @book{latex-comp, note = {In directory title = {The {\LaTeX} Companion}, \path{texmf/doc/tldoc/english/File} author = {Michel Goossens

47 on~\cite{texliveCD} in PDF and HTML} }

@misc{texliveCD, title = {{\TeX}{L}ive {CD}}, key = {TeX Live CD}, note = {Available from various sources.} }

@book{dali, title = {The Unspeakable Confessions of {Salvador} {Dali}, as told to {Andr\’{e}} {Parinaud}}, author = {Salvador Dali}, publisher = {W.H. Allen}, address = {London}, year = 1976, note = {Translated from the French by Harold J.~Salemson.}, isbn = {0-491-01955-6} }

@misc{CTAN, title = {Comprehensive {\TeX} Archive Network}, key = {CTAN}, note = {Central website is \url{http://www.ctan.org}; Australian mirror is \url{http://mirror.aarnet.edu.au/pub/CTAN/}} }

$Id: latex_cs.tex,v 1.22 2006/04/23 15:46:30 ljk Exp $

48