From: bkph@wheat-chex.ai.mit.edu (Berthold K.P. Horn)
Newsgroups: comp.text.tex
Subject: Re: HyperTeX
Date: 23 Jan 1993 02:27:09 GMT
Organization: MIT Artificial Intelligence Lab
NNTP-Posting-Host: wheat-chex.ai.mit.edu
In-reply-to: alien@essex.ac.uk's message of 18 Jan 93 17:26:26 GMT


In article <ALIEN.93Jan18172626@vulcan.essex.ac.uk> alien@essex.ac.uk ("Adrian F Clark") writes:

	...

   BKH> Hyper text linkage is also supported by DVIWindo on the IBM PC.
   BKH> Great way to add a glossary to a manual, for example.
   BKH> Particularly since it is easy to highlight the words using
   BKH> a different font, different color, or reverse video, or colored 
   BKH> background box.  Hyper text buttons can be anywhere, even behind
   BKH> inserted TIFF images.

   Maybe someone could post definitions for the \specials involved, so
   that we can consider extending existing previewers in a compatible
   way.

   --
    Dr Adrian F. Clark                                   JANET: alien@uk.ac.essex
    INTERNET: alien%uk.ac.essex@nsfnet-relay.ac.uk          FAX: (+44) 206-872900
    BITNET: alien%uk.ac.essex@ac.uk              PHONE: (+44) 206-872432 (direct)
    Dept ESE, University of Essex, Wivenhoe Park, Colchester, Essex, C04 3SQ, UK.

OK, here is a brief summary of some of the relevant \special's supported
by DVIWindo - along with some hype about `electronic publishing' :-*

Some \specials for hyper-text linkage in DVI files:
===================================================

Electronic publishing is upon us.  Many files may rarely if ever be printed.
`Pre'-viewers need to get better in terms of font rendering, faster, and more
interactive --- since often they will be the only way a user interact with a
document.  This attitude to `pre'-viewers leads to the requirement for new
capabilities that would not be thought of if the previewer was in fact merely
there to make sure that there aren't any problems with a document, and that it
is worth wasting paper to print it.

At the minimum, a `pre'-viewer needs to support string search, and have
the ability to display diagrams, figures and image of some sort.  
But more can be done if the user is given some interactive capabilities.
Hyper-text linkage provides such ability.  It makes it possible,
for example, to high-light technical terms in order to alert the user to the
fact that clicking on the word will show the corresponding glossary entry.

Here are some simple \specials for implementing such a capability.
Note that the end user would typically NOT use the \specials `raw', but
via some macro package, as usual.  So, for example, instead of explicitely 
changing text color, there might be macros like

\def\lavender{\special{textcolor: 128 0 128}}
\def\revert{\special{\textcolor: revert}}

which could then be used in text:

... the {\lavender hyper-text \revert} button works by ...


Summary of \specials:
=====================

(*) Hyper-text buttons are set up using:

\special{button: <width> <height> <mark> [<file>]}

This creates a sensitive area of specified width and height, with the
lower left corner at TeX's current point.  The semantics of this is
that if the user clicks the left mouse button in the hypertext button 
area, viewing is transferred to the corresponding labelled mark 
(possibily in another DVI file).  

(*) Hyper-text marks are set using

\special{mark: <label> [<xoff> <yoff>]}

This is place to which control can be transferred.  The optional offsets
specify where the cursor is to appear relative to TeX's current point.

Clicking the right mouse button returns control to the place where the left
mouse button was last pushed.  A limited push down stack of DVI file
positions is maintained.  The right mouse button push can come after the
viewing scale, position or page has been changed.

The hypertext button can be any rectangular area.  Attention can be
drawn to the button using rules, text or inserted TIFF images.  The
ability to control the color of rules and text and bi-level images
is particularly useful in this connection.

In some cases it makes sense for there to be just one (short) page per mark,
particularly in the case of a glossary.

NOTE: all dimensions are in TeX's scaled points (65536 per printer's
point, of which there are 72.27 per inch).  Hence they are easy to create
using the usual dimension notations in TeX, including `pt', `cm', `in' etc.

NOTE: hyper-text `labels' are sequences of non-white space characters --- or
strings delimited by double-quote marks.

There is no visible manifestation of the button itself (except in a mode
designed for debugging hyper text linkage).  This allows the user 
flexibility to show the button using words in some special font, 
colored text, colored rules in the background, or inserted TIFF images.

(*) The color of text is controlled as follows:

\special{textcolor: <r> <g> <b>}   and   \special{textcolor: revert}

where <r> <g> and <b> are numbers in the 0 - 255 range specifying
the amount red, green, and blue components of the color to be used for text.

`textcolor: revert' returns the color to that in force before the previous 
textcolor change.  

Judicious use of a bit of colored text can be a useful adjunct to font
changes in drawing attention.  A good way to mark technical words with
hyper text buttone behind them that lead to a glossary, for example.


(*) The color of rules is controlled as follows:

\special{rulecolor: <r> <g> <b>}  and   \special{rulecolor: revert}

where <r> <g> and <b> are numbers in the 0 - 255 range specifying
the amount red, green, and blue components of the color to be used for rules.

`rulecolor: revert' returns the color to that in force before the previous 
rulecolor change. 

Rules are useful for colored backgrounds behind text, and for delineating
hyper-text buttons.


(*) Text can be shown in reverse video using:

\special{reversevideo: on}  and	 \special{reversevideo: off}

The size of the rectangular area with reversed color on which the 
letter is placed depends on the ascent and descent of the font being used.


(*) TIFF images (or EPSF images with TIFF preview) can be inserted using:

\special{insertimage: <file-name> <width> [<height> [<ifdn>]]}

The image is inserted with the lower left hand corner at TeX's current
point.  The current point is not affected by the image insertion. Here 
<ifdn>, if given, specifies the number of the image in the file.  
If omitted, the first (and often the only) image in the file is shown. 
<width> and <height> specify the space on the page to be used for the image.
The image is scaled isotropically if height is omitted, otherwise it is
stretched as needed. 


(*) In the case of `monochrome'/`bi-level'/`one-bit' images, one can
control the color of the `figure' (1 bits) and the color of the
`background' (0 bits) using:

\special{figurecolor: <r-c> <g-c> <b-c> [<r-b> <g-b> <b-b>]}

where the first three numbers specify the color of the `figure'
and the last three the color of the `background'.  The background
is white (or rather the selected screen background color) if the
background color is omitted.


(*) TPIC specials can also be used to create device independent graphics,
such as polygonal lines (solid, dashed, or dotted),  quadratic splines,
circlular disks and arcs, ellipses, pie slices and so on.  The latter
are particularly useful for drawing attention to hyper-text buttons.


(*) The ten most popular schemes for insertion of EPS figures are also
supported.  If the EPS figure has a preview in EPSF or EPSI format, it
will be shown on screen.  On the IBM PC, most drawing applications create
EPSF files with TIFF preview, for example.  On Unix/NeXT EPSI preview is
more popular.


Some Limitations:
=================

One some display devices text colors will be `rounded' to the nearest 
`solid' color --- for example, one of 20 `system colors' in the case of VGA.
(The colors of rules will not be so `rounded' --- dithered colors will be 
used if necessary).

The push down stacks for saving text color and rule colors is limited.

Positive kerning within a word can introduce gaps in reverse video.  
Often the desired effect can be achieved with better control by first 
using a rule to lay down a rectangular area behind the text in the 
background color and then writing the text over it in the desired 
foreground color. 

TIFF image files are binary and have a complex structure and so cannot be
reliably read using TeX. So it is not possible to extract the number of rows 
and columns (the way BBox'es are read from EPS files) using TeX macros.
Since the aspect ratioof the figure will not be know to TeX, it is safest to
specify only the width of the figure to avoid anistropic scaling.

For page independence, color of text and rules is NOT maintained
across page breaks.  This makes it a challenge to reliably change
the color of a long section of text which may be broken across pages.


Disclaimer: respondent has connections with Y&Y :=]

Berthold K.P. Horn
Cambridge, Massachusetts, USA