Grabbed from: http://eksl-www.cs.umass.edu/tex/readme.html [20000918]
LaTeX is a program that takes an ascii text file that includes LaTeX commands like \section, and produces what's called a "dvi" file. "dvi" stands for "device independent" and it's a description of where the letters and rectangular blobs of ink are to go on the page. This is then translated into the language understood by various printers, such as ln03 or PostScript. In this department, almost every printer is a PostScript printer, so you almost always do the following.
latex foo.tex dvips foo.dvi lpr foo.psIf you're using BibTeX to do your bibliography, you have to add a few more steps. The first pass through latex writes out (to the .aux file) all the \cite information and the bibliography database files you want searched. Running BibTeX then looks up those citations and writes a .bbl file. Running latex again reads in the .bbl file to create the bibliography. However, the reference numbers of those new entries have to be propagated back to the places in the text where your \cite commands are, which requires a final run of latex. So the complete process is:
latex foo bibtex foo latex foo latex foo dvips foo lpr foo.ps(The extensions are usually optional, since all the programs except lpr know what kind of file they are looking for.) All these steps are necessary if you are starting from scratch. Usually, you've run many drafts through latex and so most of the information has propagated to the right places. LaTeX will warn you if there are citations that are still unknown. The procedure is the same if you are doing an index, except you run the makeindex program instead of the BibTeX program.
If you want to preview your document, there are two options: xdvi and ghostview.
xdvi is a program that reads the .dvi file and displays it on your X server (your terminal). One thing that's nice is that it will re-read your .dvi file when it changes, so if you are doing a number of drafts and previewing, you can save time by "suspending" xdvi while editing instead of killing it. That is, make it a background process and just turn it into an icon while you edit your file and re-run latex. Here's the procedure:
latex foo xdvi foo.dvi & <view foo and then click the button to iconize the window> <edit foo.tex> latex fooA word about PostScript (PS) figures. When you put a PS figure in your document, LaTeX doesn't do anything with it except to pass the buck to dvips. When dvips reads the .dvi file, it finds the little messages left by LaTeX and reads in the appropriate PS file or puts in the PS code or whatever. Consequently, older versions of xdvi didn't show any PS figures you might have; they just showed as whitespace. Newer versions of xdvi will usually run GhostScript to read in PS files, so pictures can also be viewed, but this doesn't always work. If you want to see what the final document will really look like, you have to use ghostview.
Ghostview is a program that executes PS code and displays it on your terminal. Obviously, you have to have run dvips to use it. Therefore, the procedure is
latex foo dvips foo ghostview foo.psGhostview can be made to re-read the .ps file, so you can play the same backgrounding trick that we can with xdvi. Ghostview is slower to use than xdvi, so I usually use xdvi.
lpr -Pwoper foo.psYou can specify many flags here. A useful one is -K2, which prints two-sided. (On woper; other printers can't handle two-sided printing.) If you are sending the file to an unfamiliar printer, you can use the "psprint" command, which gives you a menu of the department's printers.
RCF has packaged up a lot of the preceding procedures into shell files called
latex.sh (for 2.09) and latex2e.sh (for 2e). If you run these on a tex file,
they will run latex and then give you menus for re-running latex, running xdvi,
running BibTeX, running dvips, and running psprint. It can be very convenient.
The only disadvantage is that you can't play the backgrounding tricks I
described.
An important tool for writing is a spelling checker; even excellent spellers
make typing mistakes. If you want a batch of the mistakes, you can do the
following Unix incantation:
Spell Checking
cat foo.tex | ispell -lt | sort | uniq | morePersonally, I prefer the Emacs interface to ispell, which allows you to build up a file-specific dictionary of acceptable words. These words are written into the .tex file, but commented out so that LaTeX won't see them. Here's an excerpt from a paper of mine:
% LocalWords: subst TCL arity cl butlast cdr TSP SPARCstation hereonTo use ispell, you have to put one or two things into your .emacs file. (Actually, I'm not absolutely sure these are necessary, but ispell works for me.) Here's my ispell initialization stuff:
(setq ispell-program-name "/exp/rcf/share/bin/ispell") ;;; This defeats the incorrect regexp for skipping TIB entries. (setq ispell-check-tib t)The necessity of the second thing is strange, but Emacs ispell has a regular expression used for skipping stuff that isn't supposed to be spell-checked, and when I discovered ispell erroneously skipping large chunks of a file one time, I was able to get it to behave by setting this variable.
Once these variables are set, you can just say M-x ispell-buffer (or select "spell" from the "edit" menu). You can spell check a single word with M-$. It takes a moment the first time to run ispell, since it has to start up a process, but after that, it's nearly instantaneous. For those of you who use Emacs to read mail or news, there is the command M-x ispell-message. The ispell commands are:
DIGIT: Replace the word with a digit offered in the *Choices* buffer. SPC: Accept word this time. `i': Accept word and insert into private dictionary. `a': Accept word for this session. `A': Accept word and place in `buffer-local dictionary'. `r': Replace word with typed-in value. Rechecked. `R': Replace word with typed-in value. Query-replaced in buffer. Rechecked. `?': Show these commands. `x': Exit spelling buffer. Move cursor to original point. `X': Exit spelling buffer. Leaves cursor at the current point, and permits the aborted check to be completed later. `q': Quit spelling session (Kills ispell process). `l': Look up typed-in replacement in alternate dictionary. Wildcards okay. `u': Like `i', but the word is lower-cased first. `m': Like `i', but allows one to include dictionary completion information. `C-l': redraws screen `C-r': recursive edit `C-z': suspend emacs or iconify frameYou can get that listing at any time in emacs by C-h d ispell-help.
One cool command is "A," which adds the offending word to the list of acceptable words at the bottom of your file, as I explained above. If you always want a word to be acceptable (your name, for example), you can put it in your private dictionary with the "i" command. Your private dictionary is ~/.ispell_words.
There is an ispell-region command if you just want to check a portion of your file. I have found it convenient to implement an Emacs command that runs ispell from your current location (point) to the end of the buffer. You can do this too by putting the following into your .emacs file:
(defun ispell-rest () "Invokes ispell from current point to end of buffer." (interactive) (ispell-region (point) (point-max)))This can be invoked as a M-x command. I decided to bind this to C-M-$, too, which is done by the following horror. (If anyone knows a better way, please tell me.)
(global-set-key '[12582948] 'ispell-rest) ; C-M-$
What is a "style file"? The idea of LaTeX is "structured markup," where the document uses abstract terms like "section" and something else decides that the visual expression of "section" means skipping half an inch, incrementing the section counter to number the section, setting the section number and heading in large bold, and so forth. This "something else" is the style file. Thus, LaTeX reads "article.sty" and "art10.sty" to know how to typeset 10 point articles. Journals and publishing houses often produce their own style files.
LaTeX works as layers of macros on top of the primitives of the TeX language. Therefore, it's also a weird kind of programming language. People have extended LaTeX to do useful things and they package up their programs into things called "style" files. A good example of this is "cite.sty" by Donald Arseneau. By default, the \cite command can produce [18,13,15,14]. Among other things, cite.sty arranges for such groups of citations to appear as [13--15,18]; that is, they are sorted into increasing order and sequences of citations are elided. Pretty cool.
How do you use a style file? It depends on whether you are using LaTeX 2.09 or LaTeX2e, which is a newer version of LaTeX put out by the LaTeX3 team. In 2.09, you put their names in the square brackets of the documentstyle command:
\documentstyle[artadj,10pt,cite,sda]{article}In 2e, style files are called packages, and you load them via the \usepackage command:
\documentclass[10pt]{article} \usepackage{artadj,cite,sda}(There is a reason for this change; ask me if you want to know.)
There are dozens of useful packages (style files) described in the LaTeX
Companion, a book that EKSL owns a copy of. See Peggy Weston to look at it.
Setting Up
When LaTeX runs and it sees a package or style file that you want to load, it
searches for it in your TEXINPUTS path. RCF has kindly defined a number of
shell files to initialize all the myriad TeX-related shell variables. You load
the one you want as part of your login procedure. I use the bash shell, so my
.bashrc file contains the following line:
source /exp/rcf/common/tex-6.1/SETUP-YOUR-ENVIRONMENT.bashYou would substitute a different file and use a different syntax for loading the file depending on what shell you use. Talk to Westy, me, or RCF if you have trouble. By the way, I use 2e. If you use 2.09, you would find the RCF's setup files in a different directory:
source /exp/rcf/common/tex/SETUP-YOUR-ENVIRONMENT.bashThis defines TEXINPUTS to look in the RCF directories of LaTeX stuff.
Now, suppose you want to load a style file that RCF doesn't provide? You would want to have the TEXINPUTS path include a directory of your own. Again, the following syntax depends on what shell you use, but here's what I do:
source /exp/rcf/common/tex-6.1/SETUP-YOUR-ENVIRONMENT.bash TEXINPUTS=.:~eksl/tex/inputs:~eksl/tex/pstricks/inputs:$TEXINPUTS BIBINPUTS=.:~eksl/tex/bib:$BIBINPUTSThe leading "." tells TeX to always look in my current directory first. Then it will look in two EKSL group directories, and finally in whatever directories RCF has specified (the current value of $TEXINPUTS). The directories where BibTeX looks have been similarly modified. These modifications should work correctly whether you use 2e or 2.09; they do for me.
~eksl/tex/inputs/Another way we can all share and help one another is bibliographic information. I've put all my BibTeX entries in a single long file, "sda.bib," in the EKSL bibliography directory. EKSL's group bibliography files are in that directory, namely:
~eksl/tex/bib/Please add your own BibTeX database files to this directory, because this lets others easily copy references that you have.
find /exp/rcf/common/tex-6.1/inputs/ -name foo.sty -printIf it's there and you use 2e, you can use it.
You might also look in the ~eksl/tex/examples/ directory to see examples of letters, articles, tech reports and so forth.
It's also possible to select PostScript fonts (using the psnfss package, I think). So, if you've always wanted to use LaTeX and the Palantino font, you can. I've never done this, since I've so far been pretty happy with the Computer Modern fonts, but someday I hope to check it out.
One caveat: 2e, in trying to be smarter about fonts, is also more informative. It'll tell you, for example, that it can't find a bold tt font and it's substituting normal weight tt. 2.09 would simply have made the substitution and not told you a thing. Thus, it'll seem like 2e is doing worse than 2.09, because you're getting more warnings, but that's merely an illusion.
Unless you're playing with fonts, 2.09 and 2e are pretty much the same. 2e has a "compatibility mode" which runs 2.09 LaTeX files unchanged; therefore, you give up nothing by using 2e. You get to use some new commands like \emph, which replaces \em. (See, with \em, you were supposed to add an italic correction (\/) to the end of the emphasized text, so that the spacing is correct: {\em like this\/}, but the \emph command takes care of that for you, \emph{like this}.) Using 2e also lets you take advantage of new packages as they are being developed; few people are developing packages for 2.09, and no one is developing packages that are incompatible with 2e. Personally, I use 2e, but make your own decision; I'm not going to be responsible.
LaTeX2e is documented in the new edition of Lamport; EKSL owns a copy of this.
LaTex FTP Sites
I mentioned packages that are being developed. Where do these come from? Most
of them come from CTAN, the Comprehensive TeX Archive Network. These are three
sites (and mirrors) that are repositories of TeX- and LaTeX-related stuff,
including fonts, programs (such as dvips, makeindex, and bibtex as well as tex
and latex), and packages. The three major sites are
ftp.shsu.edu (US) ftp.dante.de (Germany) ftp.tex.ac.uk (England)There are numerous mirror sites. You can find a list by fingering ctan_us@ftp.shsu.edu
The FAQ is in the directory tex-archive/help
The "quote site index
One small warning. Package implementers are starting to use a documentation
system that is combined with the package in a .dtx file. Thus, you
might have to look for "here.dtx" instead of "here.sty." A .dtx file can be
used just like a .sty file, but if you run it through latex by itself:
As always, if you have any problems, you can contact me, and I'll try to help.
Last Update: 3/21/95
ftp> quote site index fancybox.sty
and it'll tell you where it is. Of course, we already have fancybox.sty, but
you get the idea. Put it in the EKSL inputs directory so that we can all use
it. It would be really nice to update the index document, too, to describe
what the new package does.
latex here.dtx
it will produce nicely typeset documentation. I don't know whether .dtx files
will be correctly processed by 2.09; I've always used 2e and not had any
trouble.