HOME
 
  INFORMATION
   Curriculum vitae (PDF)
   Publication list
 
  RESEARCH & PROJECTS
   Projects
   Publications
   Teaching
 
  RESOURCES
   TeX & LaTeX
   Linux
 
  LINKS
   VisioWave
   ITS
   MultiMedia SPL
   My alumni ITS page
 
  MISC
   Swiss Train Schedules
 
Created by XEmacs
Valid HTML 4.0!

Producing hyperlinked PDF documents from LaTeX

It is often convenient to generate some hyperlinks on the PDF output from a LaTeX document. Simple hyperlinking can be done from the table of contents to the actual sections, references to floats, index to terms, etc., in an automatic way. Also, URLs can be hyperlinked too, if they are added to the LaTeX source.

For this purpose the LaTeX hyperref package can be used. It is included in most modern LaTeX installations. If you don't have it you can obtain it from CTAN. This package will generate the necessary information so that the output PDF contains the desired hyperlinks. Below I give a quick overview of how to use it, for more information see the manual that is included with the package. It can also be accessed on-line from the Swiss SunSITE, among other places.

For basic use include

\usepackage{hyperref}
at the end of the LaTeX document preamble. It will automatically make table of contents, cross-references, and other things hyperlinked. Then use the '-z' option to dvips, so that the HyperTeX specials are converted to PostScript PDFMarks. Then a PS->PDF converter such as Acrobat Distiller will take those into account and create an hyperlinked PDF file. Note that the hyperlinks are also normally available in xdvi and other DVI previewers.

By default the hyperref package will use the hypertex driver. This will output HyperTeX directives that are then interpreted. Note that you have to give the -z flag to dvips to force it to interpret these directives. Note that these directives are also interpreted by recent versions of xdvi and other DVI previewers.

It is often desirable to use other drivers than the default hypertex one, to take advantage of extra PDF features. One such driver is dvips. With this driver it is possible to set up the PDF title, authors, keywords, bookmarks, etc., in a very simple way. To use the driver, give dvips as an option to the package, or as a global option to the document class.

The bookmarks sets the generation of PDF bookmarks, colorlinks controls whether the hyperlinks appear as colored text or boxed text (boxed text appears only in the PDF viewer and not in the printed copies), pdftitle sets the title of the PDF document, pdfsubject the subject, pdfauthor the authors, pdfkeywords the keywords, etc. For example:

\usepackage[dvips, bookmarks, colorlinks=false, pdftitle={An example PDF file from LaTeX}, pdfauthor={Diego Santa Cruz}, pdfsubject={From LaTeX to PDF}, pdfkeywords={PDF, LaTeX, hyperlinks, hyperref}]{hyperref}

chooses the dvips driver, generation of bookmarks, boxed hyperlinks, sets the PDF title to "An example PDF file from LaTeX", PDF author to "Diego Santa Cruz", PDF subject to "From LaTeX to PDF" and PDF keywords to "PDF, LaTeX, hyperlinks, hyperref".

Note that not all the drivers are able to process all the options and PDF specifics. For example the hypertex driver does not process many of the PDF specific things (e.g., pdftitle). The dvips driver (or its synonym nativepdf) handles all of them. However, it does not use the HyperTeX specials but directly inserts the PDF marks, so DVI previewers and other software will probably not recognize the hyperlinks. On the other hand it is not necessary to give the -z option to the dvips program.

The package also provides a large set of commands that can be used to add other hyperlinks as well as special PDF features. For example the \url{url}{text} command sets a URL hyperlink (e.g., \url{http://itswww.epfl.ch/~dsanta}{my home page}). See the manual for more details.

Last Modified: Wednesday, 06-Apr-2005 20:57:20 W. Europe Daylight Time


Diego Santa Cruz