Welcome to the world of TeX ! TeX is a system for the production of papers which include significant sections of mathematical text -- subscripts, Greek letters, and so on. The NIU Math Department recommends this for students in Math 360 (and for lifelong use!). This short file will explain what TeX is and how to use it. I. WHY TEX? You are welcome to ignore our advice and use another document preparation system. The most common student choice is Microsoft Word. Word has a number of advantages, principal among them being that it is widely available (it can be found on most of the modern computers you touch), it incorporates spell-checking and grammar-checking if you wish, it can be used easily in non-mathematical contexts, and it allows you to put lots of bells and whistles into your documents -- silly pictures, fonts, and so on. But Word has a number of disadvantages: * It is very tedious to use the Equation Editor to include mathematical symbolism. * It produces really ugly mathematical text unless you are quite expert. * Word files are very big, stored in a proprietary (and ever-changing) binary format, which makes them very unwelcome in non-Microsoft settings. * We are the Borg. Prepare to be assimilated. TeX was designed around 1980 and has been stable for decades; many people have been using it, without any change, for all this time -- the documents prepared in 1980 would be prepared in exactly the same way now, with exactly the same result. It is absolutely free. Versions exist for essentially every known kind of computer and operating system, and the files are identical. TeX files are compact, flat-text (ASCII) documents which can easily be machine-scanned for content. It is the lingua franca of mathematicians who wish to share papers, or to communicate mathematics easily by email; it is also very popular in other disciplines such as physics and economics. It's very easy to type ordinary TeX files quickly -- you never have to reach for the mouse at all, for example. With very little intervention by the user, TeX will produce very consistently attractive and easy-to-read documents. TeX also has some disadvantages. Most people report that it takes a little while to get used to the production cycle (see below). It's not particularly easy to include figures or pictures. And it assumes that you are thinking about your document LOGICALLY rather than GRAPHICALLY, which is not the way some people think. You may decide not to use TeX for your mathematical documents. But as a person who is communicating mathematics, you need to give TeX a try and be ready to accept TeX documents from someone who is trying to talk mathematics with you. Like me... II. HOW TO USE TEX. The easiest way to think about the TeX document cycle is to think about how you program a computer to do something, say in C or in Fortran. You use an EDITOR to create an ordinary text file, maybe something called "myprogram.c". This you have to feed somehow to a COMPILER, which reads your document line by line only to create another file, perhaps "myprogram.exe". That's the "executable file" -- the one that actually does something like print "Hello, world!" on your screen. So you run that program and decide whether it did what you want it to or not. If ---oops!--- the program prints "Hello, word!" on your screen, you have to go back and edit the first file, "myprogram.c" and then go through the steps again. You also have to do that if the compiler reports that it can't figure out what you meant, that is, if there is a syntax error in your file "myprogram.c". That's more or less the way TeX works. You use an EDITOR to create a file called, say, "mydocument.tex". You feed this file to a COMPILER which reads your file and produces another one called, say, "mydocument.pdf". That's the one that you can actually look at. You can for example feed that last file to Adobe's Acrobat Reader and see if the image looks the way you want it to. If so, fine: you can print the document or do whatever else you want. (You should make sure to save the original "mydocument.tex" file, since that's the one that you will start with later if you decide to edit.) If you don't like what you see in the PDF file, or if the compiler objects because of a syntax error, then you have to go back and edit the file "mydocument.tex". You don't have to worry too much about what an EDITOR is. You can use any method you've ever used for typing documents, such as Notepad or even Word on a Microsoft machine. The only thing you need to be able to do is to save the document as a "plain text" or "ASCII" file. For example, you should be able to open up a new file and type 1234567890 into it and save it in such a way that the resulting file is only about 10 bytes long. However it is that you do that is up to you; that's how you will prepare the files whose names end in ".tex". (Many TeX aficionados use something like a program called The TeXNic Center for this, because it has some features that help you enter the magic stuff you need for subscripts and so on.) The unit I'm calling the COMPILER here is the TeX program itself. There are many variants which people have designed which, for example, might run faster or be more informative with error messages or whatever. A popular choice for Windows systems is the program MikTeX, which we make available for our students. You can use other TeX "compilers" if you want; they should all accept the very same "mydocument.tex" files you create with your editor, and they should all produce identical-looking documents. Got that? Your steps again are: 1. Create a document "something.tex" with your text editor 2. Process the file with e.g. MikTeX 3. View the output and go back to step #1 if necessary. Otherwise, 4. Print the PDF file and save the TeX file. Now for some details. In step #1, you just type what you want to say. Don't worry about fonts or margins or anything else. Just type, for now. You just have to be aware of a couple of things the compiler is expecting: a. New paragraphs are indicated by skipping a line (i.e. by including a blank line.) b. Things that are supposed to be parts of a mathematical equation are surrounded by dollar signs, like this: $ f(x) $ . If you want the equation displayed on a line of its own, use double dollar signs, like this: $$ f(x) $$ . Both the single and double dollar signs surround what TeX calls "math mode" parts of your stuff. c. Inside math mode, you can denote subscripts like this: $ x_1 $ superscripts like this: $ x^n + y^n = z^n $ and Greek letters like this: $ \alpha + 1 = \beta $. Other symbols are treated the same way: the "congruent-to" symbol is $\cong$, the less-than-or equal-to symbol is $\le$, and so on. If you want more than one symbol in a subscript or superscript, use braces: $C_{ij}$. (If you really want a brace to appear, you need to use $\{$ or $\}$.) d. End your document by saying \end . This much will get you through 90% of your mathematical typing. You can raise that to 99% by reading through the first couple of chapters of a TeX book, such as (ahem) "The TeXbook", written by TeX's author, the eminent computer scientist/mathematician Don Knuth. (Oops -- I should also tell you that the TeX compiler will view the "%" symbol as a comment within your file; it ignores everything which appears after this symbol until you hit the "Enter" key. If you really want a percent-symbol to be displayed in your document, type this: \% .) Now, as for using the compiler, there's really only one important thing you need to know: TeX documents can be prepared in a couple of different flavors, and the compiler probably needs to know which one you've used. The instructions above are for preparing "Plain TeX" files. That's probably the easiest one to describe for a casual TeX user. If you expect to be doing more TeX documents, you should get used to a format called "LaTeX", which puts more overhead into the document, but then allows the document author to switch easily from getting a presentation suitable for a book chapter, to a presentation suitable for overhead transparencies, or whatever. Your TeX compiler can probably produce different types of output, too. The PDF format is very popular because there are PDF readers for so many different machines. You can experiment with PostScript or other formats if you prefer; if you don't understand any of that, just pick PDF. If your document has even the slightest bit of mathematics in it, you will probably find that your very first run through the TeX cycle will cause the compiler to choke and report that you've made an error. For example, a single dollar sign by itself will confuse TeX; it will search all the way to the end of the paragraph looking for the dollar sign's mate. If there is none, it will quit and produce no beautiful document for you. Do not be discouraged if this happens! It happens to all of us and most of the reported errors are easy to fix. You will probably find it easiest to ignore the whole compiling process until you've got a cup of coffee and some time to kill. That is, you should just type everything you want to say (and save your work!) and then track all the errors at once. There will probably be many of them in a long document. The compiler will find them one at a time. If you can't figure out what the problem is, or how to fix it, or if you can't decide how you even would begin to create some mathematical symbolism, then probably the easiest thing to do is to "comment out" the problem and just move on. The TeX compiler will ignore everything in a line starting from the moment it encounters a percent sign (%). Just quarantine the messy stuff and make sure the rest of your document compiles OK. You won't get the printed output you wanted, of course (so don't print anything yet!) but you can send the hard passages to your instructor by email and get some help. Here's a sample: You can prepare a document that reads Thus we let $a=1$ and $b=2$ and compute the integral of the function % How do I draw the integral symbol? I want to integrate x^2 dx . from $a$ to $b$. and TeX will process this without reporting errors. It will show the word "from" right next to the word "function". So it's not what you want, but at least it will compile correctly and move on to the next paragraph. View the rest of the document if you like, but don't print anything yet. Then you send those three lines (say) to your instructor and you will get a response like this: You get the symbol by typing " \int ". You can also get a little extra space before the dx by typing " \, ". By the way, you got an A on yesterday's exam. Congratulations! and now you can edit your original document. The edited section should now read something like Thus we let $a=1$ and $b=2$ and compute the integral of the function $\int x^2 \, dx$ from $a$ to $b$. and now TeX will process this correctly and the integral will appear between the words "function" and "from". III. NOW WHAT? Now you should try this! Go through the steps needed to create a simple TeX document. Just get used to the editing, compiling, and viewing steps. Included with the file you are reading is another file, called model0.tex . This is the actual Plain-TeX file used to create the handout used (by some instructors) at the beginning of our Math 360 course. Use this to get some answers to your "How can I get TeX to..." questions just to get started. You'll notice lots of things preceded by a backslash "\"; these are instructions to the compiler to do something (which you can usually guess). You'll notice lots of blank space; multiple blanks are just ignored by the compiler but they're there for the benefit of the human being who's reading the file. You'll notice little things which are not so important but which improve the look of your document; for example the double-quote character is printed as two comma-shaped marks, so if you want the little marks turned the other way you have to type two of the backward single-quotes: ` Also included in this website is an actual mathematics paper, which is named paper.tex here. This one is written in LaTeX. This one probably looks more intimidating, but you shouldn't be too put off by that: as you will see when you print the final output, it's a very technical-looking document, so of course the authors had to take advantage of many more TeX operations. Also, the fact that it is a LaTeX document (rather than Plain-TeX) means that there is a lot of topmatter inserted before the actual text begins. But the authors probably did not type that; they just selected a "template" in their institution's computer files which included those lines at the beginning. You can do the same, just substituting your title where it says "\title" and so on. So those are two possible input files you can play with. Try feeding them to your "compiler": you have only to connect the .tex file with the executable which is expecting such files (be sure to know which tools expect Plain Tex input and which ones expect LaTeX input files). There should be no errors in the compilation. (There may be warnings and lots of other messages spewing across your screen but you can ignore them for now.) At the end of this operation you should have a document called model0.pdf (or paper.pdf) or model0.dvi (or paper.dvi) or something. Take a look at that output file and be impressed! (You will also produce other files --- something.log and maybe something.aux and so on. You may delete these but they are small and may prove useful so most people let them sit around until they're really done with the current typesetting project.) IV . CONCLUDING REMARKS TeX is an extremely well-designed system. Its author went to tremendous pains to incorporate all the design features which printers (meaning PEOPLE who print for a living!) have developed for centuries to make really fine-looking text. You can learn to take advantage of these features over time, but at the beginning you shouldn't worry about them -- just appreciate them when you see them in your document! If you would like to learn more about TeX, visit the website TUG.org : that's the site of the TeX Users' Group, which you may wish to join. The web site has oodles of TeX code for you to download and incorporate into your documents, in addition to offering various programs such as different editors, compilers, viewing and printing software, and so on. NIU students may direct TeX questions to Dr Rusin, rusin@math.niu.edu Good luck and welcome to the world of TeX !