Home → LaTeX Quick Reference

LaTeX Quick Reference

Documentation

Standard LaTeX source

Note that the default teTeX paper size is A4. If you want US-letter output then you need to specify it explicitly, both inside the TeX file and on the commandline.

A good working LaTeX template with hyperref and figures is given by:

\documentclass[letterpaper]{article}
\usepackage{amsmath,amsthm,amssymb,latexsym}
\usepackage{graphicx}
\usepackage{hyperref} % load as last package
\begin{document}
\begin{figure}
  \begin{center}
    \includegraphics{fig} % do not include extension
  \end{center}
\end{figure}
\end{document}

By not including the file extension on the figure name, latex will select either fig.eps (if you run latex) or fig.pdf (if you run pdflatex) as appropriate.

Producing PDF files

There are essentially two different ways to produce a PDF file from a TeX or LaTeX file, namely directly with pdflatex, or with a combination of latex, dvips and ps2pdf.

If you use pdflatex then the fonts may work better if you use Times (add a \usepackage{times} near the top of your LaTeX file) rather than the default Computer Modern fonts.

With dvips and ps2pdf you need to run something like:

latex file.tex dvips -t letter -P pdf -o file.ps file.dvi
ps2pdf file.ps

This will ensure that all fonts are embedded into the final PDF file. To use landscape orientation, add the -t landscape option to dvips.

Times character remapping

If you use Times font then there is a problem with ligatures and some unusual characters caused by character remapping. To generate correct ps and pdf files you need to use the -G0 option for dvips. For example:

latex file.tex dvips -t letter -P pdf -G0 -o file.ps file.dvi
ps2pdf file.ps

Using hyperref

If you use the hyperref package to produce hyperlinks within your documents, you need to generate the final PDF file in one of two ways: 1. Load the package with \usepackage{hyperref} and then run:

 latex file.tex dvips -t letter -P pdf -z -o file.ps file.dvi
 ps2pdf file.ps
 
2. Load the package with \usepackage[ps2pdf=true]{hyperref} and then run:
 latex file.tex dvips -t letter -P pdf -o file.ps file.dvi
 ps2pdf file.ps
 

The difference is that with the first method the links are in hypertex format, and so dvips needs the -z option to process them. With the second method the links are in ps2pdf format, which should give better results. See the hyperref manual for more information.

Joining PS or PDF files

To join/concatenate two PDF files into a single file, use the ghostscript command

gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=joined.pdf file1.pdf file2.pdf

The same technique will also work for PS files, but with -sDEVICE=pswrite.

Using inverse-search with xdvi

Inverse-search is the technique whereby clicking with the middle-button on a line of text in the xdvi display will bring up the editor with the cursor placed on the corresponding line of TeX source.

To enable this, produce the dvi files with the command latex -src (assuming teTeX is being used). Then set the environment variable XEDITOR to be the editor that xdvi should load. Example settings for XEDITOR are given at this page.


Page last updated: 2008-09-24 16:32:05