Tuesday, January 18, 2011

Using Latex in ECN

We found that there is no module for doing the Latex in RCAC, so transfer to ECN

In the shell:
$ ssh -X username@bridge.ecn.purdue.edu

Basically, 3 steps for writing a document in TeX or its variants (LaTeX, AmSTeX):

   * Create the "source file" (the tex document).
   * Compile the source file with tex or latex.
   * View or print the compiled file.

As with other programming languages, one usually has to go through this "edit-compile-run" cycle multiple times (a few dozen times or more in case of some longer documents) to fix any bugs and obtain the desired output. In detail the steps are:

-- Create
   * Editing: Use a text editor to create a text file containing the "tex source", and give the file a name with a ".tex" extension, say "paper.tex". The two standard editors on Unix system are emacs and vi. Pico, the editor in pine, is easy to learn, but its capabilities are very limited, and I would recommend that you learn emacs. Both emacs and vi (in the enhanced version "vim") are available in Windows versions.

-- Compiling: tex paper.tex ; latex paper.tex
   * Compiling: Assuming your tex file is "paper.tex", issue the command latex paper to run the file through the latex program. (You can leave off the extension ".tex" in "paper.tex".) (For plain tex or amstex documents, the corresponding commands would be "tex paper" and "amstex paper", though you will likely not need this.) Often there will be error messages, in which case you'll have to exit the compile stage (type "x" at the question mark prompt), re-edit the file, and try again. Once all bugs have been fixed, the latex program will complete its run without error messages and create a file named "paper.dvi" (and some auxiliary files). This is the file that can be viewed on the screen or sent to the printer.

-- Previewing: xdiv paper;  dvips paper -o paper.ps ; pdflatex paper -o paper.pdf
   * Previewing: To view the file on the screen, use xdvi paper. (Again the extension ".dvi" can be left off; be sure, however, not to use the name of the original file "paper.tex" - xdvi operates on the dvi file, not the tex file.)
   * Printing: To send the file to the printer (which, by default, is ah130, unless you have changed it to something else), issue the command dvips paper. In order not to waste paper, you should do this only at the very end of the process, or if there are a large number of errors. Most of the time, you can check a file by previewing it on the screen with xdvi. As the name suggests, dvips converts a dvi file to a postscript (ps) file; by default, the postscript output produced by this program is immediately sent to the printer. If instead, you want to save the postscript onto a file, use dvi with the "-o" option: e.g., dvips paper -o paper.ps saves the postscript output onto a file "paper.ps" (which you can view with "gv").
   * Generating a pdf file: To create a pdf version of your document (e.g., in order to post it on a website), use pdflatex instead of latex to compile the TeX file: pdflatex paper will generate paper.pdf in a single step, without an intermediate dvi file.

No comments:

Post a Comment