Previous Next Contents

6. Mixing text and graphics with dvips(1).

In general, this section applies to any TeX or LaTeX document which mixes text and graphics. teTeX, like most other TeX distributions, is configured to request Computer Modern fonts by default. When printing documents with Type 1 scalable fonts or graphics, font and graphics imaging is the job of dvips(1). dvips(1) can use either Computer Modern bit mapped fonts or Type 1 scalable fonts, or any combination of the two. First, let's concentrate on printing and previewing some graphics.

In general, you will want to follow this procedure any time a LaTeX source document has the statement

in the document preamble. This statement tells LaTeX to include the text of the graphics.sty package in the source document. There are other commands to perform graphics operations, and the statements in plain-TeX documents may not clue you in whether you need to use dvips(1). The difference will be apparent in the output, though, when the document is printed with missing figures and other graphics.

So, for now, we'll concentrate on printing documents which use the LaTeX graphics.sty package. You might want to take a look at the original TeX input. It isn't included in the teTeX distribution, but it is available at

What the teTeX distribution does include is the .dvi output file, and it is already TeXed for you. There is a reason for this, and it has to do with the necessity of including Type 1 fonts in the output in order for the document to print properly. If you want to LaTeX grfguide.tex, see the next section. For now, however, we'll work on getting usable output using dvips(1).

The file grfguide.dvi is located in the directory

The first step in outputting grfguide.dvi is to translate it to PostScript. The program dvips(1) is used for this. It does just exactly what its name implies. There are many options available for invoking dvips(1), but the simplest (nearly) form is
dvips -f -r <grfguide.dvi >
The -f command switch tells dvips(1) to operate as a filter, reading from standard input and writing to standard output. dvips(1) output can be configured so its output defaults to lpr(1). (Mine does, which allows me to print directly from dvips(1).) Post processors like Ghostscript and printing filters like APSFILTER (see section aps-filter name="APSFILTER"), can be configured for your own needs. If you need to feed the output manually to a post-processor, the -f option is generally the first you should include in the dvips(1) command line. This form also seems to be easier to use in shell scripts.

If you can print PostScript directly to your printer via lpr(1), you can simply type

dvips -r grfguide.dvi
The -r option tells dvips to output the pages in reverse order so they stack correctly when they exit a printer. Use it or not, as appropriate for your output device.

Depending on whether you still have the fonts that dvilj2(1) generated from the last document, dvips(1) and metafont may or may not need to create new fonts needed by grfguide.dvi. Eventually, though, dvips(1) will output a list of the pages translated to PostScript, and you will have your PostScript output ready to be rendered on whatever output device you have available.

If you're lucky (and rich), then you have a PostScript-capable printer already and will be able to print directly. You can either spool the output to the printer using lpr(1). If for some reason your printer software doesn't work right with PostScript files, you can, in a pinch, simply dump the file to printer, with

cat >/dev/lp0
or whichever port your printer is attached to, though this is not recommended for everyday use.

If you want or need to invoke Ghostscript manually, this is the standard procedure for its operation. The first thing you want to do is invoke Ghostscript to view its command line arguments, like this:

gs -help | less
You'll see a list of supported output devices and sundry other commands. Pick the output device which most nearly matches your printer. On Chanel3, because I generally produce black-and-white text, I use the cdjmono driver, which drives a color Deskjet in monochrome (black and white) mode.

The command line I would use is:

gs -dNOPAUSE -sDEVICE=cdjmono -sOutputFile=/tmp/gs.out -c quit
This will produce my HP-compatible output in the /tmp directory. It's a good idea to use a directory like /tmp, because gs(1) can be particular about access permissions, and you can't (and shouldn't) always count on being logged in as root to perform these steps. Now you can print the file:
lpr /tmp/gs.out
Obviously, this can all go into a shell script. On my system, I have two simple scripts written, pv and pr, which simply outputs the PostScript file either to the display or the printer. Screen previewing is possible without X, but it's far from ideal. So, it's definitely worth the effort to install XFree86, or TinyX (which is what I did) to view the output on the screen.

The order of commands in a gs(1) command line is significant, because some of the options tell Ghostscript to look for pieces of PostScript code from its library.

The important thing to remember is that grfguide.dvi makes requests for both Computer Modern bit mapped and Type 1 scaled fonts. If you can mix scalable and bit mapped fonts in a document, you're well on the way to becoming a TeXpert.

Previous Next Contents