Transcription of LATEX Tutorials
1 LATEX TutorialsA PRIMERI ndian TEX Users GroupTrivandrum, India2003 SeptemberLATEX Tutorials A PRIMERI ndian TEX Users GroupEDITOR:E. KrishnanCOVER:G. S. KrishnaCopyrightc 2002,2003 Indian TEX Users GroupFloorIII,SJPB uildings, Cotton HillsTrivandrum695014, is granted to copy, distribute and/or modify this document under the terms of theGNUFree Documentation License, , with no invariant sections, no front-cover texts, and noback-cover texts. A copy of the license is included in the document is distributed in the hope that it will be useful, but without any warranty; withouteven the implied warranty of merchantability or fitness for a particular by the Indian TEX Users GroupOnline versions of this Tutorials are available at: ideal situation occurs whenthe things that we regard as beau-tiful are also regarded by otherpeople as useful.
2 Donald KnuthFor us who wrote the following pages, TEX is something beautiful and also useful. Weenjoy TEX, sharing the delights of newly discovered secrets amongst ourselves and won-dering ever a new at the infinite variety of the program and the ingenuity of its also lend a helping hand to the new initiates to this art. Then we thought of extend-ing this help to a wider group and The Net being the new medium, we started an onlinetutorial. This was well received and now the Free Software Foundation has decided topublish these lessons as a book. It is a fitting gesture that the organization which upholdsthe rights of the user to study and modify a software publish a book on one of the earliestprograms which allows this reader, read the book, enjoy it and if possible, try to add to TUGI ndiaTutorial Team34 CONTENTSI.
3 The Basics.. is LATEX ? 7 typesetting 8 13 size 15II. The Document.. class 17 style 18 numbering 19 20 of a document 20 the document 21 next? 23 III. Bibliography.. 27 28IV. Bibliographic Databases.. BIBTEX program 33 style files 33 a bibliographicdatabase 34V. Table of contents, Index and Glossary.. of contents 39 41 44VI. Displayed Text.. words 47 in typesetting 48 lists 48 matters 51 and definitions 54 VII. Rows and Columns.. tabs 57 62 VIII. Typesetting Mathematics.. basics 77 commands 81 on mathematics 82 miscellany 89 operators 101 many faces ofmathematics 102 that is not all!
4 103 103IX. Typesetting Theorems.. in LATEX 109 theorems Theamsthmpackage 111 118X. Several Kinds of Boxes.. boxes 119 boxes 121 boxes with specific height 122 boxes 123 boxes 123XI. Floats.. 125 13056 CONTENTSXII. Cross References in LATEX .. cross references? 135 LATEX do it 135 to a page thepackagevarioref 138 outside the packagexr 140 the keys? 140 XIII. Footnotes, Marginpars, and Endnotes.. 143 notes 147 148 TUTORIAL ITHE ISLATEX?The short and simple answer is that LATEX is a typesetting program and is an extensionof the original program TEX written by Donald Knuth. But then what is atypesettingprogram?To answer this, let us look at the various stages in the preparation of a documentusing text isenteredinto the input text isformattedinto lines, paragraphs and output text isdisplayedon the computer final output mostword processorsall these operations are integrated into a single applicationpackage.
5 But a typesetting program like TEX is concerned only with the second stageabove. So to typeset a document using TEX, we type the text of the document and thenecessary formatting commands in atext editor(such asEmacsinGNU/Linux) and thencompile it. After that the document can be viewed using aprevieweror printed using aprinter is also aprogramming language, so that by learning this language, people canwrite code for additional features. In fact LATEX itself is such a (large) collection of extrafeatures. And the collective effort is continuing, with more and more people writing small exampleLet us see LATEX in action by typesetting a short (really short) document. Start yourfavorite text editor and type in the lines belowexactlyas shown\documentclass{article}\begin{docum ent}This is my \emph{first} document prepared in \ LATEX .
6 \end{document}Be especially careful with the\character (called thebackslash) and note that this isdifferent from the more familiar/(theslash) inand/orand save the file onto the harddisk (Instead ofmyfileyou can use any name you wish, but be sure the end as theextension.) The process of compiling this and viewing theoutput depends on your operating system. We describe below the process of doing THEBASICSAt the shell prompt typelatex myfileYou will see a number of lines of text scroll by in the screen and then you get the promptback. To view the output in screen, you must have the X Window running. So, startXifyou have not done so, and in a terminal window, typexdvi myfileA window comes up showing the output belowThis is myfirstdocument prepared in let us take a closer look at thesource file(that is, the file you have typed).
7 The first line\documentclass{article}tells LATEX that what we want to produce is anarticle. If you want to write a book, this must be changed to\documentclass{book}.The whole document we want to typeset should be included between\begin{document}and\end{document} . In our example, this is just one line. Now compare this line in thesource and the output. The first three words are produced as typed. Then\emph{first},becomesfirstin the output (as you have probably noticed, it is a common practice toemphasizewords in print using italic letters). Thus\emphis acommandto LATEX totypeset the text within the braces initalic1. Again, the next three words come out withoutany change in the output.
8 Finally, the input\LaTeXcomes out in the output as our source is a mixture of text to be typeset and a couple of LATEX commands\emphand\ LATEX . The first command changes the input text in a certain way and thesecond one generates new text. Now call up the file again and add one more sentencegiven is my \emph{first} document prepared in \ LATEX . I typed iton \ do you get in the output? What new text does the command\todaygenerate? LATEX ?So, why all this trouble? Why not simply use a word processor? The answer lies in themotivation behind TEX. Donald Knuth says that his aim in creating TEX is tobeautifullytypesettechnical documentsespecially those containinga lot of Mathematics. It is verydifficult (sometimes even impossible) to produce complex mathematical formulas using aword processor.
9 Again, even for ordinary text, if you want your document to lookreallybeautifulthen LATEX is the natural TYPESETTINGWe have seen that to typeset something in LATEX , we type in the text to be typeset togetherwith some LATEX commands. Words must be separated by spaces (does not matter howmany) and lines maybe broken end of a paragraph is specified by ablank linein the input. In other words,whenever you want to start a new paragraph, just leave a blank line and proceed. Forexample, the first two paragraphs above were produced by the input1 This is not really true. For the real story of the command, see the section on SIMPLE TYPESETTING9We have seen that to typeset something in \ LATEX , we type in thetext to be typeset together with some \ LATEX \ must be separated by spaces (does not matter how many)and lines maybe broken end of a paragraph is specified by a \emph{blank line}in the input.
10 In other words, whenever you want to start a newparagraph, just leave a blank line and that the first line of each paragraph starts with anindentationfrom the leftmargin of the text. If you do not want this indentation, just type\noindentat the startof each paragraph for example, in the above input,\noindent We have seen ..and\noindent The end of ..(come on, try it!) There is an easier way to suppress para-graph indentation forallparagraphs of the document in one go, but such tricks can might have noticed that even though the length of the lines of text we type in aparagraph are different, in the output, all lines are of equal length, aligned perfectly onthe right and left. TEX does this by adjusting the space between the traditional typesetting, a little extra space is added to periods which end sentencesand TEX also follows this custom.