The TeX FAQ for the UCSD Math Department Last updated 6 June 1997 This is a list of frequently asked questions about TeX designed for the UCSD Math Department. Table o' Contents: (1) What is TeX? (2) What are .tex, .dvi, and .ps files? (3) How do I create a TeX document? (4) What are the differences between TeX, AMS-TeX, LaTeX, and AMS-LaTeX? Which should I use? What about compatibility? (5) I have a .tex file. How do I know what version of TeX it's in? (6) How do I view/print a .tex file? (7) How do I view/print a .dvi file? (8) How do I view/print a .ps file? (9) What are good TeX reference books? (10) What kinds of cool symbols will TeX make and how do I get it to make them? (11) How do I include a picture in a TeX document? (12) How do I include a Mathematica equation in a TeX document? (13) How do I get the header page of my thesis to look like everyone else's? (14) How do I create a TeX document with math department letterhead? (15) How do I make commutative diagrams in TeX? (16) How do I get TeX on my Mac/PC? +---- Look here ----+ | | V V (17) If you had to give me just a few hints about TeX, what would they be? ------------------------------------------------------------------------------- (1) What is TeX? TeX is a language for typesetting mathematics. The beauty of it is that things that typesetters know about making mathematics look good on the printed page are built-in, so that you don't need to worry about them. TeX is sort of a cross between a word processor and a programming language. It is like a word processor in that it makes your text output look good and it is like a programming language in the way you actually use it. Consequently, all the rules for good programming style carry over (see the hints at the end). One thing: TeX isn't pronounced "Tex", like someone from Texas. It's capital Tau-Epsilon-Chi, the Greek word meaning "art". So it's pronounced like "tek". ------------------------------------------------------------------------------- (2) What are .tex, .dvi, and .ps files? .tex files are text files (e.g. something created using vi or emacs) containing something written in TeX. Running the appropriate kind of TeX on them will create a .dvi file (e.g. "amstex foo.tex" produces "foo.dvi"). .dvi files are a relatively standard way of saving data to be printed. The reason that they are created is that TeX was designed to replace an earlier typesetting system called troff, which generated .dvi files. .ps files are PostScript files; they contain instructions in the PostScript language. The printers in the math department know what to do with a PostScript file if you send it to them. ------------------------------------------------------------------------------- (3) How do I create a TeX document? Use your favorite text editor: vi, emacs, whatever. ------------------------------------------------------------------------------- (4) What are the differences between TeX, AMS-TeX, LaTeX, and AMS-LaTeX? Which should I use? What about compatibility? TeX, also known as Plain-TeX, is the foundation on which all versions of TeX are built. Pretty much anything which is done in Plain-TeX will work in the other versions. Unfortunately, Plain-TeX has almost no features, so it sucks to use. AMS-blah just means that this is blah with some nice AMS modifications on it, like more fonts and some more symbols. Also, some of the formatting will be different. The AMS extensions are available as add-ons for a base TeX or LaTeX installation from the AMS at e-math.ams.org or through the Web at http://www.ams.org/ LaTeX's big advantage over regular TeX is that it will do numbering of theorems, chapters, etc. for you. In addition, it can do things like make an index (with an auxiliary program called MakeIndex). ------------------------------------------------------------------------------- (5) I have a .tex file. How do I know what version of TeX it's in? The first thing you should do is look at the very beginning of the file (either using your favorite pager like more or less or by running "head foo.tex"). If it opens with \input amstex \documentstyle{amsppt} it's in AMS-TeX. If the first non-comment, non-blank line is \documentstyle[ some stuff in here ] or \documentclass[ some stuff here ] then it's in some version of LaTeX. If the stuff in the [ ] says something ams... then it's in AMS-LaTeX. If you see control structures like \beginfoo ... \endfoo, it's in some form of LaTeX. If the control structures look like \foo ... \endfoo, it's in AMS-TeX. Another thing is that if you see commands like \newtheorem before the text of the document starts up (i.e. in the preamble), then it's in some kind of LaTeX. ------------------------------------------------------------------------------- (6) How do I view/print a .tex file? If you don't mind reading stuff written in TeX as opposed to looking like an article in a journal, you can just use your favorite pager (e.g. cat, more, less, pg, vi) to look at it. Otherwise, you need to compile it and print it out, so read on: The first step is to figure out what version of TeX it is in. Then run the appropriate version on it. For example, if your file is called "foo.tex", the appropriate command is one of tex foo.tex amstex foo.tex latex foo.tex amslatex foo.tex This will give you a file called "foo.dvi". For the next step see "How do I view/print/convert a .dvi file?". ------------------------------------------------------------------------------- (7) How do I view/print/convert a .dvi file? If you are connected to euclid using X Windows, you may view a .dvi file by typing xdvi foo.dvi If you are using one of the Suns in B432 and your .dvi file is stored locally (i.e. on your Sun), you can use xpreview foo.dvi If you are using a Mac with OzTeX, you can use it to preview .dvi files as well as print them. To print a .dvi file (say "foo.dvi") on your default printer, type lpr -h -d foo.dvi The "-d" tells lpr that the file you're sending it is a .dvi file, because it is too stupid to figure it out for yourself. If you leave off the -d, you'll get a real mess coming out of the printer. Another way to print is to use dvips. dvips foo.dvi dvips converts foo.dvi to a PostScript file and then prints it out. You can convert a .dvi file to a .ps file by doing dvips foo.dvi -o ------------------------------------------------------------------------------- (8) How do I view/print a .ps file? If you are connected to euclid and using X Windows, you can preview a .ps file using Ghostscript by typing gs foo.ps You can print a .ps file (say foo.ps) by sending it straight to your printer with lpr foo.ps ------------------------------------------------------------------------------- (9) What are good TeX reference books? TeX --- Donald Knuth, The TeX Book AMS-TeX ------- Michael Spivak, The Joy of TeX LaTeX ----- Leslie Lamport, The LaTeX Book Helmut Kopka and Patrick W. Daly, A Guide to LaTeX: Document preparation for Beginners and Advanced Users The LaTeX Companion (which also has some things on AMS-LaTeX) AMS-LaTeX --------- There are some publications about AMS-LaTeX by the AMS ------------------------------------------------------------------------------- (10) What kinds of cool symbols will TeX make and how do I get it to make them? Pretty much about any kind of symbol you see in a math book you can make in some version of TeX, including script and regular fraktur characters and a subset of the Hebrew alphabet. The main caveat is that except for the most common symbols, the commands may vary amongst different versions of TeX. For example, in LaTex, to make the normal subgroup symbol, you use \lhd and in AMS-TeX you would use \vartriangleleft. The cool Z, Q, R, and C that people use for the integers, rationals, reals, and complexes are available in AMS versions of TeX as blackboard bold letters (e.g. the command is {\mathbb{Z}} for the integers). If you are using LaTeX and have AMS-LaTeX installed, you can get the blackboard bold fonts by adding the line \usepackage{amsfonts} in your preamble. ------------------------------------------------------------------------------- (11) How do I include a picture in a TeX document? (* Under construction *) ------------------------------------------------------------------------------- (12) How do I include a Mathematica equation in a TeX document? If we call the expression that you want to put into TeX "expr", the command TeXForm[ expr ] >>> foo.tex will append the expression, in TeX, to the end of the file foo.tex. For more complicated output into a TeX file, you can use the Splice command. See the Mathematica book by Steve Wolfram for more details. ------------------------------------------------------------------------------- (13) How do I get the header page of my thesis to look like everyone else's? In the near future there will hopefully be some TeX templates available through http://mathadm.ucsd.edu/ that you can just put the appropriate info into. OGSR will also provide you with a template, but it lacks pretty much any features. The OGSR template is available via ftp at acsftp.ucsd.edu in the directory thesis/ucsd-tex ------------------------------------------------------------------------------- (14) How do I create a TeX document with math department letterhead? The answer on this one isn't fully decided yet. What we do know is that if you include /usr/local/lib/tex/macros/misc/letterheadMATH in your TeX document, then the command \letterheadMATH will put a copy of the letterhead in there. The spacing and placement may be completely wrong though. ------------------------------------------------------------------------------- (15) How do I make commutative diagrams in TeX? --- Built-in --- AMS-TeX and AMS-LaTeX have a limited built in capacity for making commutative diagrams. To find out more, look in the appropriate manuals. If you are using LaTeX, you can add the capability to do AMS-style commutative diagrams by including the line \usepackage{amscd} in the preamble to your document. You can also draw commutative diagrams directly by typesetting it as a matrix where the arrows and objects are all entries in your matrix. --- XY-pic --- You can expand this by using a package called XY-pic, which is currently installed in several places on euclid. --- Cricket draw --- I'm told that the secretaries use a program on the Mac called Cricket draw to do their commutative diagrams. I don't know anything about it. ------------------------------------------------------------------------------- (16) How do I get TeX on my Mac/PC? --- Mac --- The department has a site license for OzTeX and CMacTeX which should be able to handle your TeX needs (including previewing before you print). About TeXtures, perhaps the best known Mac-based previewer: the department doesn't have a site license for it and so it's not supported. OzTeX is shareware and you can get a copy for your Mac via ftp from midway.uchicago.edu (128.135.12.73). --- PC --- You can get emTeX, a free implementation of TeX and LaTeX for the PC developed by the GNU Project, by FTPing to ftp.shshu.edu and downloading everything in the directory tex-archive/systems/msdos/emtex/ Then follow the directions in README.ENG and INSTALL.ENG. The package contains two sets of executable files: one for DOS/Windows and the other for OS/2 2.x or 3.0 (Warp). emTeX contains just about all you'll need for TeX & LaTeX, and you should allow about 30 megs for emTeX if you install everything. Plusses to emTeX: it's free. Minusses: there's no phone support and it may not be easy to install. But then again, it's free. Also, there is an emTeX mailing list to which one can subscribe by sending mail to with the text 'subscribe'. ------------------------------------------------------------------------------- (17) If you had to give me just a few hints about TeX, what would they be? --- 1 --- The first and overarching hint should be some kind of universal law: remember the reason that TeX was designed. That is, it was made so that documents would automatically come out beautiful and well-laid out. Your job as an author is to write the document. TeX is supposed to do the visual appearance work for you. Don't fight it. The non-plain implementations of TeX have built-in formats for things like theorems, definitions, remarks, sections, chapters, and (especially) the opening of a document (the topmatter like the title and authors of a journal article) and the references section. USE THEM. Not only will your output look better, your document will be easier for you to write, your TeX source will be easier to read, and IT WILL ALL BE STANDARD. This is important if you ever want anyone else to look at your work in any other form besides on paper. --- 2 --- In question (1) we said that TeX was a cross between a word processor and a programming language. Speaking about the programming language part, all the things that hold for good programming style in, say, C, hold for TeX as well. Some bigs ones are comments, whitespace, and constants. Comments: If you define a macro for a fairly complicated expression, you might want to put in a comment that says what it is. Or add a comment at the top of your document saying what version of TeX it is in and who wrote it, perhaps. A comment is anything between a % and the end of the line. Whitespace: TeX ignores extraneous spaces. That is, a blank line separates paragraphs, but 5 blank lines still just separate the two paragraphs, there is no extra spacing given. Similarly for spaces between words. Better yet, in formulas, spaces are pretty much ignored, so use them wherever they make the equation look better. For example, \Theta'_q = \otimes_{n=1}^{\infty} \Lambda_{q^n} (V - \dim V) \otimes_{m=1}^{\infty} S_{q^m}(TM-{\dim}M) Looks much better than \Theta'_q=\otimes_{n=1}^{\infty}\Lambda_{q^n}(V-\dim{V})\otimes_{m=1}^{\infty} S_{q^m}(TM-{\dim}M) Constants: If you are writing a program and are going to use the value for pi a lot, you would normally just define a constant PI = 3.141592654 at the start of your program. This would make your code more legible (it's obvious what PI means) and would avoid errors in mistyping 3.141952654... whoops! See what I mean? The same principle holds in TeX. An example that holds for a wide variety of papers is the real numbers, R. If you are going to use the blackboard bold R to denote the reals, instead of typing {\mathbb{R}} everywhere, it's much better to define a macro called, say, \R which is defined to be {\mathbb{R}} (say by \newcommand{\R}{{\mathbb{R}}}), for the same reason as you would define a constant called PI before. Here there is an extra incentive: what if you give your TeX source to a friend and they don't like the blackboard bold R? (Unfortunately, such people exist.) Then it's easier to change, too. Also, defining constants (macros in TeX) also is a handy shorthand. For example, the polynomials in n variables over a field k looks like \Bbbk[x_1, \ldots, \x_n] in TeX. Do you want to have to type that every time you talk about polynomials? --- 3 --- How about dashes? TeX has three kinds of dashes -, --, and ---. "-" is a hyphen, as in "n-tuples" or "self-destruct". "--" is used for a range of numbers, as in "25--78". The biggest one, "---" is the dash used for punctuation in a sentence. ------------------------------------------------------------------------------- Modification history 28 Apr 95 Original by Mike Zabrocki, Skip Garibaldi, and Will Brockman 17 May 95 Location of OGSR thesis templates added (thanks to John Eggers) 19 May 95 OzTeX/emTeX info added by John E. & Skip 5 Jun 95 More info about commutative diagrams added (Skip) 13 Jul 95 emTeX data updated (John Eggers) Where to get OzTeX added (Skip) 28 Dec 95 Revised to reflect better computers for grad students (Skip) 6 Jun 97 Revised and updated slightly (Skip)