6 Linking slides from prosper to TEX4ht

This section deals with the issue of creating hypertext links when using the package prosper [5], and more specifically hypertext links to HTML documents created with TEX4ht. This is not meant as a guide to prosper, as the documentation that comes with the package is a good guide in itself, and since it is not very difficult to learn anyway. But we mention that prosper allows you, as a LATEX user, to create high-quality presentation slides merely with simple LATEX code. The pdf file that results from this process is comparable to those created with Microsoft’s PowerPoint. The most important advantages of using prosper, is that it is free and that it supports all typical LATEX structures, such as mathematics. (We all know that PowerPoint is bad at this.)

Why bother with these hyperlinks?

Imagine yourself at a conference, meeting, or whatever, displaying your slides for the audience. Maybe you are presenting your latest findings in time-travel technology or mind transfer serums. Then, at some point, you refer to some of your articles showing detailed calculations or witty quotes. With the hyperlinks inside your slides, you may click on this anchor and, behold, the web browser pops up displaying the exact contents of your article! Neat.

Moreover, with the knowledge of how to put hyperlinks into prosper, you may also link to regular web pages with relevant content. This might also be valuable. (But then, you don’t need most of the material in this section.)

6.1 The hyperref package

The hyperref package provides a flexible interface to hypertext links. It is included when you include prosper. This means that most of the options offered by hyperref is set “behind the curtains,” but for most uses this should not be a hindrance. A thorough description of hyperref is found in [1], and we will only deal with the basics here.

A plain, vanilla hypertext link is inserted with the \href command:

Here, url is the fully expanded URL to the desired page, and text is the anchor shown visually. Note that characters such as # and ~  should not be escaped. Note also that the link must be fully expanded. If not, the link wil typically get a file: in front. This unfortunately makes the document less portable. To overcome this problem a bit, a command \hyperbaseurl is provided.7 Set this to e.g. http://www.something.com/user/ and you can omit the full expansion of the hyperlinks. (You may still expand external links, of course.)

Because of the colorizing parameters being obscured by the early inclusion of hyperref, one has to use other means for creating colored links. One way is

whose usage is the same as the original \href command.

6.2 The missing links inside TEX4ht

Now, we turn to the creation of human readable anchors inside the HTML files generated with TEX4ht. We wish to be able to direct our hypertext links inside the prosper presentation to a given chapter, section or page. In HTML, this is done with <a name='whatnot'> tags; anchor tags. TEX4ht creates such tags by default for internal cross linking between equation references, figure references and so on. Unfortunately, the format of these are not known a priori, and we must supply reliable tags ourselves.

This might seem clumsy at first: why not use the tags already present? The simple implementation we choose and the usage proves the method to be fine, though. Analyzing TEX4ht’s behaviour may be a tedious task, and that’s why we decide on the presented technique.

The main ingredients of the implementation is to exploit TEX4ht’s “hooks.” When the author issues e.g. a sectioning command, configurable hooks generate HTML material in the tex4ht post-processing stage. This allows us to create anchors with literal description of the section. The needed configurations and macros are collected in customlinks.tex, whose usage is described next.

To invoke the custom hooks, simply \input the macro file immediately after the \begin{document} command. On every chapter, section and subsection, a HTML anchor is created. One can also issue custom-made anchors with the commands \customlink and \pagelink:

When using these commands, do not insert empty lines on both sides of them. If you do, it will result in an empty but visible paragraph in the document. (The ancors still work, of course, whether you remember this or not.)

Whenever a custom hook is encountered, the macros issue a message to the log. To extract the interesting messages, issue the command

cat doc.log | grep Customlink >links.txt
to generate a file containing a description of the links. Typically a line reads:
 --- Customlinks says: Link to section 2.1: doc.html#sec2-1
So, when one needs to link to section 2.1, use this link.

The customlinks.tex contains only basic LATEX programming, so extending it to ones own need should be no difficult task. As for now, starred sections are not implemented, for example.

The file customlinks.tex is available alongside this document from [6]. In addition, it is included in the file package described in section 5.

6.3 An example

On the web page [6] you may view an example showing how to link prosper documents to HTML documents and HTML documents created with TEX4ht in particular.

The example consists of several files:

Take a look at the source codes. Hopefully this will in conjunction with the above paragraphs be informative.