Sunday, March 22, 2009

How to compile LaTeX file

Here are the typical steps to produce DVI, PostScript or PDF file from a LaTeX source file:

  1. Create the LaTeX source file. It must be in the plain ASCII format. Simple text editor like Notepad, VIM or Emacs would be fine. Please do not use word processor like Microsoft Office.

  2. Run LaTeX on the LaTeX source. Any warning or error will be reported, if exists. If the source file contains table of contents, or references, you may need to run the above command several times. If you are lucky, you will get a DVI file, called yourfile.dvi. To view it, use dvi viewer like xdvi or Yap.
    latex yourfile.tex

  3. To convert the DVI file to PostScript format, run
    dvips -Pcmz yourfile.dvi -o

  4. To produce a PDF file, you don't need to do step 1. Just run
    pdflatex yourfile.tex

  5. To produce a PostScript file from a PDF file,
    pdf2ps yourfile.pdf

  6. To produce a PDF file from a PostScript file,
    pdf2ps newfile.pdf