Make your own free website on
Next: 6 Linking Within the Document   Previous: 4 Document Preamble

5 Linking to an External URL

The content of the following sections is also illustrated in example.tex.

With the preamble of Section 4, it is easy to include a hyperlink to a web page, etc., that will work in both the PDF and HTML documents. The code required is \htmladdnormallink{text}{url}, for example,

As a check, this link: should take you there now if you click it in whichever online version of the document you are reading.

The \htmladdnormallink command works pretty well; for example, you can stick one inside a figure caption and the link will still work in both the PDF and HTML versions. Note that we are not using the \href command even though we are also using the hyperref package, as

  • \href's do not successfully pass through LATEX2HTML;
  • Using commands from hyperref makes it harder to prepare the source file to run with LATEX2HTML. See Section 3.1

A Note on Relative URL's

Relative URL's work fine in LATEX2HTML, but they do not work in the PDF document -- they are not really meaningful in that context. Thus it is better to stick to absolute URL's.

One trick to make a set of documents more portable is to define a base url in the preamble, for example:

and to define URL's relative to this, e.g.
\htmladdnormallink{A graphic}{\baseurl/graphics/graph.jpg}

This kind of things works fine with LATEX2HTML and DVIPDFM. To move the website later, just change the value of \baseurl in the code and rebuild all the documents.

Back Home Up Next

Charles Clayton 2000. Please use this information at your own risk.



Hit Counter