Nifty (but these days obscure) #2: using the emTeX graphics driver and DVI previewer (or ‘avoiding the digital dark age’)

So back in the DOS days (1990s), emTeX was a brilliant way to make LaTeX quality documents on DOS. It was a complete solution. In those days of dot matrix printers and VGA screens, PostScript was not really a central part of the DOS ecosystem. It has a fair bit of overhead for systems of that vintage, for one thing, and can render pretty damned slowly. Graphics were more often now-forgotten formats like IBM’s CGM (computer graphics metafile, I think) and PCX. So emTeX’s DVI viewer could not render embedded PostScript graphics. That was not to say they could not be used — dvips existed and could incorporate many kinds of graphics into the final file, if PostScript was your final target.

What emTeX could do was incorporate PCX bitmaps, and render them in its accompanying DVI viewer, dviscr, and then put them in the final printed version. There were not many ways of previewing LaTeX on DOS that did not involve having a cup of tea while an ancient (well, it wasn’t ancient at the time) version of Ghostscript rendered your page (or converted it to some kind of bitmap which you then viewed), or just giving up and printing it — which was fine if you had a PostScript printer, but they were very high-end in those days and often you did not.

The emTeX driver is still in TeXlive, and as a system emTeX is still there on CTAN. We can install it in DOSBox easily enough.

Here is my LaTeX file. You have to specify the image size manually:

\documentclass[emtex,a4paper,12pt]{article}
\usepackage[emtex]{graphicx}
\begin{document}
Here is a little bit of text before the picture; $\varepsilon =
\Delta \left( A B \cos\theta \right) \ldots \mathrm{etc}$

\includegraphics[width=4.2in,height=4.2in]{2.pcx}

Here is some text after the image. \emph{Just to see.}
\end{document}

Now, using emTeX on DOSBox I can process the file. The PCX was made using xFig, and the DVI viewer does not render it, though the old version of dvips (v. 5.83 from 1998) does put it into the PostScript output ok. But what about the DVI viewer that came with emTeX? (DVISCR)

I find that a PCX file that the viewer can deal with has the following properties:

  • PC Paintbrush version 3.0
  • RLE encoded
  • Monochrome

I cannot find a modern open source program to make the requisite monochrome bitmap — they all give too much colour depth. Even using ImageMagick’s convert does not work; the byte that sets the colour depth is wrong! I ask for depth=1 and get 8.

The trick is the magically compact and powerful PICTVIEW DOS image viewer in DOSBox. (And PICTVIEW is modern, it is just very stable!)

It can open most file formats. Some you can then directly reduce the colour depth to 1 bit and save as PCX. Others, you first have to convert to 256 colours, then to 2. But it works. I then call the monochrome PCX file from the LaTeX file, and here is the result.

Looks good, if monochrome
DVI file previewed using the emTeX previewer in DOSBox

Now, using the dvips and ps2pdf (from Ghostscript distribution GS386.exe, version 5.10 ) that came with the old emTeX, I get a perfectly good, though old format, PDF file — here’s a screen grab, viewed in atril:

Looks good in atril

PCX files from the very old  DOS bitmap painting program VGAPaint also work (of course, other old DOS paint programs might work too.)

FWIW, I can copy this DOSBox file tree to Haiku and get LaTeX on Haiku! (DOSBox is in the Haiku Depot.) I believe there are TeXlive binaries out there for Haiku, and you can do TeXlive properly, but this does work! Funny. I can use the native Haiku file editors and image creation tools and suchlike, then use emTeX to create the PDFs, though of course they are old-format PDFs (can run pdf2pdf or similar to update them) and I can only use LaTeX packages that confirm to the DOS 8.3 file name convention.

Looking at the same files on TeXlive on Linux, it compiles fine but xdvi does not render the PCX image.

The graphic comes out too small when I run the modern dvips. But if I recall that I scaled the PCX file while expecting 300 DPI in emTeX, I can do this:

$ dvips -D 300 EMBOX

(where EMBOX.tex is the LaTeX file and EMBOX.dvi is the DVI file) and it looks fine!

What does this tell me?

It says that LaTeX not only offers amazing cross-platform compatibility (DOS, Linux, Windows, Mac, you name it, and almost all versions of these), but also across the decades! Everything from emTeX is from the 1990s. DOS itself, the old versions of dvips, Ghostscript, emTeX. Yet I can create a file in emTeX, including graphics that I can view in the DOS-era previewer, and process the exact same files on a current machine running current LaTeX, and get the same results. Here is a close-up of the PostScript file produced by running modern LaTeX on the ‘old’ file. What digital dark age?

Looks good!Anyway, the emtex driver is really only of use in DOS anyway — you’d never use it on a modern system. If you really want to go minimal with graphics drivers, you’d use bm2font!

Worth nothing.