Chapter 9. Previewing

$Revision: 1.1 $

$Date: 2002/08/23 14:31:13 $


Because TeX is not interactive, most TeX documents are developed iteratively. After adding a significant amount of text or changing the format of a document, you'll want to see what the document looks like. Then you can add more text or try different formats. Then, it's helpful to see it again $…$

You could print the document, but that's wasteful and slow (not to mention environmentally unfriendly). This is where screen previewers enter the picture. They allow you to look at your document on a video display.

Accurate previewing is more difficult than printing your document for several reasons. Screen displays are much more diverse than printers (previewing on a PC is very different from previewing on a workstation running X11 even though printing to a LaserJet printer is essentially the same from both places). Also, it's very difficult to preview documents that use printer-specific features. For example, if you use a PostScript figure in your document, it will be very easy to print on a PostScript printer, but on most platforms it is much more difficult to preview that document on the screen (two exceptions are the Amiga and NeXT which have integrated support for displaying PostScript images).

In the following sections I'll explore options for previewing on several platforms. The X Window System is usually associated with unix workstations, but several PC implementations (running under both MS-DOS and OS/2) are now available. The X11 previewers described here may be available for those systems, but I haven't seen them. Ghostscript is another previewing option that is available on several platforms so it is described in its own section.

Table Table 9.1 summarizes the previewers described here.

Table 9.1. Common Previewers

\bf Previewer \bf Supplier \bf OS \bf Comments
\program{xdvi} Free (xdvi) Unix/DesqView X11
\XTeX Free (\XTeX) Unix X11
Ghostscript Free (gs) most PostScript
Ghostview Free (Ghostview) Unix, Windows PostScript
dviscr Free (emTeX) MS-DOS, OS/2  
dvipm Free (emTeX) OS/2 Presentation Manager
dvivga Free (dvivga) MS-DOS EGA/VGA
TeX Preview ArborText MS-DOS, Unix  
dvideo Kinch Software MS-DOS EGA
PTI View Personal TeX MS-DOS  
dvimswin Free (dvimswin) MS-DOS Windows
dviwin Free (dviwin) MS-DOS Windows
wdviwin Kinch Software MS-DOS Windows
DVIWindo Y&Y MS-DOS Windows
dvi2tty Free (dvi2tty) Most ASCII
dvigt/dvitovdu Free Most  
crudetype Free VMS ASCII

Previewing Under X11

The three most common X11 previewers are xdvi, \XTeX, and Ghostview (really a PostScript previewer). Ghostview runs on top of Ghostscript and is described in the “the section called “Previewing Under X11”” section of this chapter.

Previewing with xdvi

You can retrieve xdvi from the CTAN archives in the directory dviware/xdvi.

Figure  Figure 9.1 shows the preview process under xdvi. xdvi reads the DVI file and loads the PK files for any fonts that are required. If xdvi cannot find a requested font, it will run \MakeTeXPK to create the font. \MakeTeXPK is a shell script (or a batch file called maketexp under MS-DOS) that tries to use MetaFont or ps2pk to build the font.

Figure 9.1. How Previewing with xdvi Works

After forming each page, xdvi passes it off to the X11 Window Manager to be displayed. Previewing under xdvi is shown in Figure Figure 9.2.

Figure 9.2. Previewing with xdvi

Screen resolution is typically much lower than printer resolution. Because xdvi uses the PK files at printer resolution, it must scale them before using them for display purposes. The scaling process allows xdvi to use anti-aliasing to improve image quality on color displays. Anti-aliasing is a technique used to improve the appearance of scaled images by using colored pixels around the edges of the image to provide the illusion of partial pixels. This can dramatically improve the readability of the displayed text. If the \ps font files are available, xdvi can display documents that use \ps fonts; otherwise, it performs font substitution.

A recent addition to xdvi is the ability to preview documents that include PostScript figures. The figures are rendered behind the scenes by Ghostscript and displayed by xdvi. In my opinion, this addition really makes xdvi one of the finest X11 previewers available. It is fast, uses printer fonts, has anti-aliasing for superb readability on color displays, and can include PostScript figures.

Previewing with \xtex

The \xtex previewer is very similar to xdvi. The primary difference is that \xtex uses X11 fonts for display. This means that \xtex must build fonts at the appropriate resolution. After the fonts have been built, \xtex is typically a very fast previewer.

You can retrieve \xtex from the CTAN archives in the directory dviware/xtex.

Figure 9.3. How Previewing with xtex Works

Figure  Figure 9.3 shows the preview process under \xtex. Like xdvi, \xtex uses the \MakeTeXPK program to build PK files for fonts that are unavailable. Additionally, \xtex uses the \TeXtoXfont shell script, or batch file, to convert PK fonts into X11 display fonts.

The \xtex previewer relies on the X11 Window Manager to build the display. However, if \ps figures are present in your document, \xtex will attempt to display them. When \xtex is built, you can specify that \ghostscript or another \ps interpreter be used to handle \ps figures.

An example of \xtex's display is shown in Figure Figure 9.4.

Figure 9.4. Previewing with xtex

Previewing with Ghostscript

Previewing with Ghostscript is quite different from previewing with xdvi and \xtex. Most previewers process the DVI file to build the display. \ghostscript is a general-purpose program for displaying \ps files. Under X11, an additional program called \ghostview provides more sophisticated control of previewing.

Ghostscript and Ghostview are products of the Free Software Foundation (FSF). You can retrieve them from the GNU archives on prep.ai.mit.edu in the directory /pub/gnu or from any mirror of those archives.

Ghostscript reads and interprets the \ps file created by a program such as \dvips. It provides its own means of handling font substitution if the appropriate fonts are unavailable. Because \dvips converts the TeX DVI file into \ps, \ghostscript can display all of the elements of the document including \ps figures and other PostScript printer-specific commands.

An example of Ghostview's display is shown in Figure Figure 9.5.

Figure 9.5. Previewing with Ghostview

Previewing with emTeX

Figure  Figure 8.3 in Chapter Chapter 8, Chapter 8, shows the relationship between the various components involved when processing a DVI file with emTeX. Previewing and printing are very similar operations with emTeX. To preview, you use the dviscr driver, and the result is displayed on the screen. To print, use one of the other DVI drivers, and the result is a file that can be sent directly to your printer. Chapter Chapter 13, Chapter 13, discusses emTeX in more detail.

dvidrv runs the appropriate DVI driver: dviscr for previewing, dvihplj for printing to an HP LaserJet printer, or dvidot for printing to other dot matrix printers.

The DVI driver reads the DVI file and loads fonts from PK files or FLI font libraries. If your document uses graphics, they are loaded from PCX or MSP files.

If your document uses a font that is not available, the DVI driver writes the commands necessary to build the font to the MFJ file.[106] Before performing font substitution, the driver will ask if you wish to build the missing fonts. If you elect to build them, the DVI driver stops and returns control to the dvidrv program.

dvidrv notices that the DVI driver stopped because of missing fonts and runs MFjob to build them. After building the fonts, the previewer is run again to display the document.

The dvidrv program is quite simple. With some care, it can be replaced by a batch file that does more work.[107] For example, I have replaced dvidrv with a 4DOS batch file called dvidxx that can automatically build \ps fonts by calling ps2pk in addition to building MetaFont fonts with MFjob. The dvidxx batch file is printed in Example Example D.3 in Appendix Appendix D, Appendix D.

A full-screen preview with dviscr is shown in Figure  Figure 9.6.

Figure 9.6. Previewing with emTeX's dviscr

Under OS/2, the dvipm previewer offers more power. A sample dvipm display is shown in Figure  Figure 9.7 later in this chapter.

Figure 9.7. Previewing with emTeX's dvipm

The dviscr and dvipm previewers use anti-aliasing to obtain better image quality on a color display. However, this translates into a poorer quality image when captured for display in a black-and-white book.

Previewing with dvivga

dvivga is an MS-DOS previewer for EGA and VGA displays. You can retrieve dvivga (and a complete set of the Computer Modern fonts in PK format) from the CTAN archives in the directory dviware/dvivga. dvivga requires PK fonts at screen-resolutions (around 100dpi); that is why a special set of fonts is provided. If you are using a dot-matrix printer with a similar resolution, the special fonts may already be installed on your system.

dvivga does not support any \special commands for including pictures or figures, but it does support configurable font-substitution for fonts that are unavailable.

Figure Figure 9.8 shows a preview of the sample document from Chapter Chapter 4. This image is from a VGA display.

Figure 9.8. Previewing with dvivga

TeX Preview

TeX Preview\index{TeX Preview previewing@TeX Preview previewing} is the ArborText DVI previewer for MS-DOS. A similar previewer is available for unix workstations running the X Window System (versions for Motif and Open Look environments are also available). The following discussion is based on experiences with TeX Preview version 6.1.2, the MS-DOS implementation of ArborText's TeX previewer.

TeX Preview supports a wide range of graphics adapters, including EGA, VGA, and Hercules adapters as well as the Olivetti Monochrome Graphics adapter, the Tecmar Graphics Master, the Genius VHR Full Page Display Monitor, the ETAP Neftis Monitor, the Toshiba 3100, and the AT&T PC6300 display.

Figure  Figure 9.9 shows a preview of the sample document from Chapter Chapter 4, Chapter 4. This image is from a VGA display. Three additional features of the driver, not exercised in this example, are the ability to scale fonts to any size, display rulers and bitmapped graphics, and a “two-up” mode for viewing two pages at a time.

Figure 9.9. Previewing with ArborText's Previewer

When TeX Preview is displaying a DVI file, you can move around the page and between pages; you can change the magnification, search for text in the DVI file, show the attributes of the character under the cursor (font, dimensions, magnification, etc.), and switch to another file. A configuration file allows you to specify a wide range of options to control how TeX Preview appears when it starts up.

ArborText supplies a full set of Computer Modern Roman PK files at screen resolutions as well as a complete set of Times Roman and Helvetica fonts at screen resolutions. The additional PostScript fonts are derived from official Adobe sources and allow you to preview documents that will be printed on PostScript printers (provided that they use only Times, Helvetica, and Computer Modern fonts). They are designed specifically to work with TFM files provided with DVILASER/PS, ArborText's PostScript DVI driver.

If you want to use additional fonts, for example the \AmS-fonts or Computer Modern fonts at unusual sizes, you may wish to generate PK files at the appropriate resolutions. TeX Preview will perform font substitution for missing fonts (you can control what substitutions are made) and can use the DVI driver metric information, so generating additional fonts is not necessary.

TeX Preview understands the virtual font mechanisms introduced in TeX version 3.0. Several additional utilities provided with TeX Preview allow you to construct virtual fonts. These utilities are summarized in Table Table 9.2 .

Table 9.2. TeX Preview Utilities

\bf Utility \bf Description
\it aftovp Converts VPL from AFM file
\it gftopk\,\x Converts GF files into PK files
\it packpxl Creates packed (byte-aligned) PXL file
\it pktopx\,\x Converts PK files into PXL files
\it pxtopk\,\x Converts PXL files into PK files
\it tftovp Converts VPL from TFM file
\it unpkpxl Creates standard, word-aligned PXL file
\it vftovp\,\x Converts VF files into VPL files
\it vptovf\,\x Converts VPL files into VF files

ArborText's TeX Preview program recognizes \special commands for drawing change bars and for rotating any TeX “box” through a multiple of 90 degrees. These are the same \special commands recognized by other ArborText DVI drivers.

dvideo

The MS-DOS based EGA previewer dvideo is distributed as part of the TurboTeX distribution by the Kinch Computer Company. TurboTeX is described more completely in the section called “the section called “µTeX by ArborText”” in Chapter Chapter 14, Chapter 14. TurboTeX also includes a Microsoft Windows previewer.

Figure  Figure 9.10 shows a dvideo preview of the sample document from Chapter Chapter 4.

Figure 9.10. Previewing with TurboTeX dvideo (using limited selection of fonts)

The preview displayed here uses the default set of fonts distributed with TurboTeX. This does not include several of the large sizes used by this example. In practice, you will have to purchase or build many fonts before you can use TurboTeX.

PTI View

PTI View is the MS-DOS previewer that comes with PCTeX, distributed by Personal TeX, Inc. PCTeX is described in the section called “the section called “PCTeX”” in Chapter Chapter 14, Chapter 14.

Figure  Figure 9.11 shows a PTI View preview of the sample document from Chapter Chapter 4.

Figure 9.11. Previewing with Personal TeX's Previewer

PTI View is distributed with a complete set of the Computer Modern fonts in PK format (PTI View can use the same PK fonts as your printer, regardless of the printer's resolution). It can display the preview in many video modes, including several high-resolution super VGA modes.

Previewing Under Windows

Most MS-DOS previewers are inappropriate for previewing in Windows because they assume that they can control the entire display. Recently, several commercial and free previewers for Windows have become available. They are described in this section.

dvimswin

The dvimswin previewer is a Windows version of dvivga. It uses the same screen-resolution fonts for displaying your DVI file and offers font-substitution for missing fonts.

You can retrieve dvimswin from the CTAN archives in the directory dviware/dvimswin. The dvimswin previewer is shown in Figure Figure 9.12.

Figure 9.12. Previewing with dvimswin

dviwin

The dviwin previewer is another free Microsoft Windows previewer. dviwin can use either screen or printer resolution fonts to display your DVI file. You can retrieve dviwin from the CTAN archives in the directory dviware/dviwin.

What makes dviwin unique is its support for \special commands. dviwin understands \special commands for including pictures and figures, as well as the emTeX and tpic drawing primitives.

dviwin has built-in support for PCX, BMP, and MSP graphic formats. Additionally, it can use any graphics filter installed in your Windows environment. Many commercial programs include additional filters to handle the images that they construct. dviwin also supports emTeX font libraries and customizable automatic font generation. By using dviwin, you can print your DVI files on any Microsoft Windows-supported printer. The dviwin previewer is shown in Figure Figure 9.13.

Figure 9.13. Previewing with dviwin

The dviwin distribution includes two additional utilities: clipmeta for creating MSP graphic files from any image captured in the Windows clipboard, and wbr, a text-file browser.

wdviwin

As mentioned above, the TurboTeX package includes a Windows DVI driver, wdviwin, distributed by the Kinch Computer Company. Sample output from this previewer is shown in Figure  Figure 9.14. This sample shows the status window, the preview window, and a few of the available tools.

Figure 9.14. Previewing with TurboTeX's wdviwin

DVIWindo

The DVIWindo previewer by Y&Y is unique among the previewers used here. DVIWindo has no support for PK fonts; it relies entirely on scalable fonts provided by Microsoft Windows. (This means either PostScript Type 1 fonts rendered by Adobe Type Manager or built-in TrueType font support.) As a result, to use the DVIWindo previewer, you must purchase the Computer Modern fonts in TrueType or Adobe Type 1 format (or not use them at all).

The DVIWindo previewer is shown in Figure  Figure 9.15. The pull-down menu shown in this image is the “TeX Menu,” a new feature of DVIWindo 1.1. This menu, which can be customized to include any programs you wish, allows DVIWindo to function as a TeX shell. Once DVIWindo is running, you can edit files and format documents with TeX directly from this menu.

Figure 9.15. Previewing with Y&Y's DVIWindo

The real advantage of using scalable fonts is that you can resize the image in arbitrary ways.[108] For example, Figure  Figure 9.16 shows a much-enlarged version of the same page. Similar enlargement with non-scalable fonts would require that the PK fonts exist at very high-resolutions (occupying considerable disk space) or produce very jagged output. The jaggedness of the image shown here is the result of magnifying the captured screen image, not the previewer. Several useful information boxes are also shown in these images.

Figure 9.16. DVIWindo preview much enlarged

DVIWindo has several other interesting features:

  • Portions of a document may be copied into the Windows clipboard and then pasted into other applications. This allows you to construct complex mathematics in TeX, for example, and paste them into another Windows application. The pasted material will appear as a single graphical object that can be moved, resized, and cropped. The material is not rendered as a bitmap, so it can be resized without loss of quality!

  • TIFF images are displayed in the document. If you use dvipsone (Y&Y's PostScript printer driver) and create both TIFF and EPS (encapsulated PostScript) versions of an image, DVIWindo will automatically display the TIFF image, and dvipsone will automatically print the EPS image.

  • Colored text and rules can be incorporated into a document with \special commands.

  • You can create “hypertext” buttons in your document. Selecting a button (an area of text or a rule) automatically moves you to a destination marker in the document. These buttons are only meaningful to DVIWindo, but they do allow you to move around quickly in a document while you are writing it. Of course, they could also be very handy if you use DVI files for online documentation.

In addition to the DVIWindo executable, several programs are provided to help you work with PostScript fonts under Windows. They are summarized in Table Table 9.3.

Table 9.3. DVIWindo Utilities

\bf Utility \bf Description
\it pfatopfb\,\x Convert PFA files into PFB files
\it pfbtopfa\,\x Convert PFB files into PFA files
\it tifftags Show the tags used in a TIFF image
\it reencode Change the encoding of a PostScript font
\it afmtotfm\,\x Convert AFM files into TFM files
\it tfmtoafm Convert TFM files into AFM files
\it afmtopfm Convert AFM files into PFM files
\it pfmtoafm Convert PFM files into AFM files
\it safeseac Circumvents problem with accented letters in PS fonts under Windows
\it cleanup Removes inactive Windows from the desktop
\it sysseg Displays information about Windows system memory

Previewing on a TTY

Graphical workstations and personal computers with graphics capabilities are a natural environment for previewing TeX output. Unfortunately, they aren't always available. This section describes several previewers that work in less sophisticated environments.

dvi2tty

The dvi2tty program attempts to convert TeX output into ASCII text. This program is designed to provide an approximation of troff's nroff processor. To get the best results, you will have to reformat your document using a limited subset of TeX's capabilities. A LaTeX style file is included for this purpose. You can retrieve dvi2tty from the CTAN archives in the directory dviware/dvi2tty.

The output from dvi2tty is imperfect in many ways, but it can provide a workable ASCII document. I used it to produce plain ASCII documentation in my Sfware package, for example. dvi2tty also provides a quick-and-dirty method of applying some standard text processing tools, like grep, to TeX output.

dvgt/dvitovdu

These programs share a common history. As a result, they offer an overlapping set of features. The most recent work has been done on the dvgt processor. You can retrieve dvgt from the CTAN archives in the directory dviware/dvgt.

Unlike dvi2tty, which is a conversion program, dvgt is an interactive previewer. One very neat feature of dvgt is its ability to preview TeX output on a number of graphics terminals, including Tektronix 4010, VT240, VT640, Gigi, Regis, VIS500, VIS550, VIS603, and VIS630 terminals. The importance of this feature is that many versions of Kermit and NCSA Telnet (and possibly other communications programs) support one of these terminal types. This means that you can preview documents even when you are away from your workstation, by using dial-up access with either a graphics terminal or plain ASCII.

Even when output is limited to plain ASCII, dvgt attempts to make its output resemble the printed page. To do this, it frequently drops characters out of the middle of words and performs other space-saving abbreviations. The result is a crude, but workable preview, on a plain ASCII terminal.

Figure  Figure 9.17 shows an example of dvgt display in tek4010 emulation. This is a somewhat contrived example since the emulation is being performed by an xterm.

Figure 9.17. Previewing with dvgt under Tektronix 4010 emulation

dvitovdu is an older version of the program. It is available in source code form in both C and Pascal. You can retrieve dvitovdu from the CTAN archives in the directory dviware/dvitovdu.

crudetype

crudetype is another plain-ASCII previewer. It provides features similar to dvgt and dvitovdu. It is written in Web, but it cannot be translated to C with the web2c conversion tool (so you will have to have a Pascal compiler).

The crudetype program was written with VMS in mind, although it may be portable to other systems. You can retrieve crudetype from the CTAN archives in the directory dviware/crudetype.



[106] {Some setup is required to obtain this functionality. By default, the driver asks for the name of a font to substitute in place of the missing font.}

[107] {Particularly in networked environments where dvidrv assures that temporary filenames won't collide between users.}

[108] {Most previewers support resizing, but they are generally limited to the resolutions for which PK fonts are available.}