Software: Apache. PHP/8.3.27 uname -a: Linux pdx1-shared-a4-04 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64 uid=6659440(dh_z2jmpm) gid=2086089(pg10499364) groups=2086089(pg10499364) Safe-mode: OFF (not secure) /usr/share/doc/texlive-doc/dvips/ drwxr-xr-x | |
| Viewing file: Select action/file-type: Dvips: A DVI-to-PostScript translatorShort Table of ContentsTable of Contents
DvipsThis manual documents Dvips version 2021.1 (February 2021), a program to translate a DVI file into PostScript. You may freely use, modify and/or distribute this file.
Next: Installation, Previous: Top, Up: Top [Contents][Index] 1 Why use Dvips?The Dvips program has a number of features that set it apart from other PostScript drivers for TeX. This rather long section describes the advantages of using Dvips, and may be skipped if you are just interested in learning how to use the program. See Installation, for details of compilation and installation. The Dvips driver generates excellent, standard PostScript, that can be included in other documents as figures or printed through a variety of spoolers. The generated PostScript requires very little printer memory, so very complex documents with a lot of fonts can easily be printed even on PostScript printers without much memory, such as the original Apple LaserWriter. The PostScript output is also compact, requiring less disk space to store and making it feasible as a transfer format. Even those documents that are too complex to print in their entirety on a particular printer can be printed, since Dvips will automatically split such documents into pieces, reclaiming the printer memory between each piece. The Dvips program supports graphics in a natural way, allowing PostScript graphics to be included and automatically scaled and positioned in a variety of ways. Printers with any resolution are supported, even if they have different resolutions in the horizontal and vertical directions. High resolution output is supported for typesetters, including an option that compresses the bitmap fonts so that typesetter virtual memory is not exhausted. This option also significantly reduces the size of the PostScript file and decoding in the printer is very fast. Missing fonts can be automatically generated if Metafont exists on the system, or fonts can be converted from GF to PK format on demand. If a font cannot be generated, a scaled version of the same font at a different size can be used instead, although Dvips will complain loudly about the poor aesthetics of the resulting output. One of the most important features is the support of virtual fonts, which add an entirely new level of flexibility to TeX. Dvips even comes with its own Afm2tfm program that can create the virtual fonts and TeX font metric files automatically from Adobe font metric files. Source is provided and freely distributable, so adding a site-specific feature is possible. Adding such features is made easier by the highly modular structure of the program. Tom Rokicki wrote and maintains the original Dvips program. Next: Invoking Dvips, Previous: Why Dvips, Up: Top [Contents][Index] 2 InstallationInstalling Dvips is mostly the same as installing any Kpathsea-using program. Therefore, for the basic steps involved, see Installation in Kpathsea. For solutions to common installation problems and information on how to report a bug, see the file kpathsea/BUGS (see Bugs in Kpathsea). For solutions to Dvips-specific problems, see Debug options. Dvips does require some additional installation, detailed in the sections below. Also, to configure color devices, see Color device configuration.
Next: PostScript font installation, Up: Installation [Contents][Index] 2.1 config.ps installationDvips has its own configuration files: a file config.ps for
sitewide defaults, and a file config.printer for each
printer (output device). Since these are site-specific, (These Dvips configuration files are independent of the Kpathsea configuration file texmf.cnf (see Config files in Kpathsea). Dvips configuration files contents and searching are described fully in Config files. The simplest way to create a new configuration file is to copy and modify the file dvipsk/contrib/config.proto, seasoning with options to your taste from Config files. Here is config.proto for your reading pleasure: % Prototype Dvips configuration file. (Public domain.) % How to print, maybe with lp instead lpr, etc. o |lpr % Default resolution of this device, in dots per inch. D 600 % Metafont mode. (This is completely different from the -M command-line % option, which controls whether MakeTeXPK is invoked.) Get % ftp://ftp.tug.org/tex/modes.mf for a list of mode names. This mode % and the D number above must agree, or MakeTeXPK will get confused. M ljfour % Memory available. Download the three-line PostScript file: % %! Hey, we're PostScript % /Times-Roman findfont 30 scalefont setfont 144 432 moveto % vmstatus exch sub 40 string cvs show pop showpage % to determine this number. (It will be the only thing printed.) m 3500000 % Correct printer offset. You can use testpage.tex from the LaTeX % distribution to find these numbers. Print testpage.dvi more than once. O 0pt,0pt % Partially download Type 1 fonts by default. Only reason not to do % this is if you encounter bugs. (Please report them to % [email protected] if you do.) j % Also look for fonts at these resolutions. R 300 600 % With a high resolution and a RISC cpu, better to compress the bitmaps. Z % Uncomment these if you have and want to use PostScript versions of the % fonts. %p +cmfonts.map %p +lafonts.map %p +cyrfonts.map %p +eufonts.map % To include another configuration file here. %c FILENAME % You will also want definitions for alternative paper sizes -- A4, % legal, and such. Examples in contrib/papersize.level2 and % contrib/papersize.simple. Next: Ghostscript installation, Previous: config.ps installation, Up: Installation [Contents][Index] 2.2 PostScript font installationTo use PostScript fonts with TeX and Dvips, you need both metric files (.tfm and .vf) and the outlines (.pfa or .pfb). See Font concepts. Current TeX systems come with support for 35 base PostScript fonts and many more. If you have additional PostScript fonts, you can make them available
to Dvips by (1) giving them appropriate filenames; and
(2) running Afm2tfm (see Making a font available) to make TFM
and VF metrics for TeX and Dvips to use. Also add them to
psfonts.map (see psfonts.map); this file must contain
everything available in the system. The Next: Diagnosing problems, Previous: PostScript font installation, Up: Installation [Contents][Index] 2.3 Ghostscript installationGhostscript is a PostScript interpreter freely available to end-users, originally written by Peter Deutsch. It can read the PostScript produced by Dvips and render it on your monitor, or for another device (e.g., an Epson printer) that does not support PostScript, or in PDF format. The latest version is available via https://ghostscript.com. The program Ghostview, originally written by Johannes Plass and Tim Theisen, provides typical previewing capabilities (next page/previous page, magnification, etc.). It requires Ghostscript to run, and files in structured Postscript, specifically with ‘%%Page’ comments (no ‘N’ in config.ps). The current version is known as GV, and is available from https://www.gnu.org/software/gv. Previous: Ghostscript installation, Up: Installation [Contents][Index] 2.4 Diagnosing problemsYou’ve gone through all the trouble of installing Dvips, carefully read all the instructions in this manual, and still can’t get something to work. The following sections provide some helpful hints if you find yourself in such a situation. For details on effective bug reporting, common installation problems,
and A good first debugging operation is to set the environment variable
Next: No output, Up: Diagnosing problems [Contents][Index] 2.4.1 Debug optionsThe ‘-d’ flag to Dvips helps in tracking down certain errors.
The parameter to this flag is an integer that tells what errors are
currently being tracked. To track a certain class of debug messages,
specify the appropriate number given below; if you wish to track
multiple classes, sum the numbers of the classes you wish to track.
To track all classes, you can use You can also set the environment variable The classes are:
Next: Small or inverted, Previous: Debug options, Up: Diagnosing problems [Contents][Index] 2.4.2 No output at allIf you are not getting any output at all, even from the simplest one-character file (for instance, ‘\ \bye’), then something is very wrong. Practically any file sent to a PostScript laser printer should generate some output, at the very least a page detailing what error occurred, if any. Talk to your system administrator about downloading a PostScript error handler. (Adobe distributes a good one called ‘ehandler.ps’.) It is possible, especially if you are using non-Adobe PostScript, that your PostScript interpreter is broken. Even then it should generate an error message. Dvips tries to work around as many bugs as possible in common non-Adobe PostScript interpreters, but doubtless it misses a few. PowerPage Revision 1, Interpreter Version 20001.001, on a Mitsubishi Shinko CHC-S446i color thermal dye sublimation printer is known to be unable to print with any but builtin fonts. If Dvips gives any strange error messages, or compilation on your machine generated a lot of warnings, perhaps the Dvips program itself is broken. Try using the debug options to determine where the error occurred (see Debug options). It is possible your spooler is broken and is misinterpreting the structured comments. Try the ‘-N’ flag to turn off structured comments and see what happens. Next: Printer errors, Previous: No output, Up: Diagnosing problems [Contents][Index] 2.4.3 Output too small or invertedIf some documents come out inverted or too small, probably your spooler is not supplying an end of job indicator at the end of each file. (This commonly happens on small machines that don’t have spoolers.) You can force Dvips to do this with the ‘-F’ flag (or ‘F’ config file option), but this generates files with a terminating binary character (control-D). You can also try using the ‘-s’ flag (or ‘s’ config file option) to enclose the entire job in a save/restore pair. See Command-line options, and Config files. Next: Long documents fail, Previous: Small or inverted, Up: Diagnosing problems [Contents][Index] 2.4.4 Error messages from printerIf your printer returns error messages, the error message gives very good information on what might be going wrong. One of the most common error messages is ‘bop undefined’. This is caused by old versions of Transcript and other spoolers that do not properly parse the setup section of the PostScript. To fix this, turn off structured comments with the ‘-N’ option, but it’d be best to get your spooling software updated. Another error message is ‘VM exhausted’. Some printers indicate this error by locking up, others quietly reset. This is caused by Dvips thinking that the printer has more memory than it actually does, and then printing a complicated document. To fix this, try lowering the ‘m’ parameter in the configuration file; use the debug option to make sure you adjust the correct file. Other errors may indicate you are trying to include graphics that don’t nest properly in other PostScript documents, among other things. Try the PostScript file on a QMS PS-810 or other Adobe PostScript printer if you have one, or Ghostscript (see Ghostscript installation); it might be a problem with the printer itself. Next: Including graphics fails, Previous: Printer errors, Up: Diagnosing problems [Contents][Index] 2.4.5 Long documents fail to printThis is usually caused by incorrectly specifying the amount of memory the printer has in the configuration file; see the previous section. Previous: Long documents fail, Up: Diagnosing problems [Contents][Index] 2.4.6 Including graphics failsThe most common problem with including graphics is an incorrect bounding box (see Bounding box). Complain to whoever wrote the software that generated the file if the bounding box is indeed incorrect. Another possible problem is that the figure you are trying to include does not nest properly; there are certain rules PostScript applications must follow when generating files to be included. The Dvips program includes work-arounds for such errors in Adobe Illustrator and other programs, but there are certainly applications that haven’t been tested. One possible thing to try is the ‘-K’ flag which strips the comments from an included figure. This might be necessary if the PostScript spooling software does not read the structured comments correctly. Use of this flag will break graphics from some applications, though, since some applications read the PostScript file from the input stream, looking for a particular comment. Any application which generates graphics output containing raw binary (not ASCII hex) will probably fail with Dvips. Next: Paper size and landscape, Previous: Installation, Up: Top [Contents][Index] 3 Invoking DvipsDvips reads a DVI file as output by (for example) TeX, and converts it to PostScript, taking care of builtin or downloaded PostScript fonts, font reencoding, color, etc. These features are described in other chapters in this document. There many ways to control Dvips’ behavior: configuration files, environment variables, and command-line options.
Next: Command-line options, Up: Invoking Dvips [Contents][Index] 3.1 Basic usage of DvipsTo use Dvips at its simplest, simply type dvips foo where foo.dvi is the output of TeX that you want to print. The default output is to a corresponding file foo.ps; Dvips may also have been locally configured to output directly to a printer by default. If you use fonts that have not been used on your system before, they may be automatically generated; this process can take a few minutes, so progress reports appear by default. The next time that document is printed, these fonts will have been saved in the proper directories, so printing will go much faster. (If Dvips tries to endlessly generate the same fonts over and over again, it hasn’t been installed properly. See Unable to generate fonts in Kpathsea.) Many options are available (see the next section). For a brief summary of available options, run dvips --help Next: Environment variables, Previous: Basic usage, Up: Invoking Dvips [Contents][Index] 3.2 Command-line optionsDvips has a plethora of command line options. Reading through this section will give a good idea of the capabilities of the driver.
Next: Option details, Up: Command-line options [Contents][Index] 3.2.1 Option summaryHere is a handy summary of the options; it is printed out when you run Dvips with no arguments or with the standard ‘--help’ option. Usage: dvips [OPTION]... FILENAME[.dvi]
Convert DVI input files to PostScript.
See http://tug.org/dvips/ for the full manual and other information.
Options:
-a* Conserve memory, not time -A Print only odd (TeX) pages
-b # Page copies, for posters e.g. -B Print only even (TeX) pages
-c # Uncollated copies -C # Collated copies
-d # Debugging -D # Resolution
-e # Maxdrift value -E* Try to create EPSF
-f* Run as filter -F* Send control-D at end
-G* Shift low chars to higher pos.
-h f Add header file
-i* Separate file per section
-j* Download fonts partially
-k* Print crop marks -K* Pull comments from inclusions
-l # Last page -L* Last special papersize wins
-m* Manual feed -M* Don't make fonts
-mode s Metafont device name
-n # Maximum number of pages -N* No structured comments
-noomega Disable Omega extensions
-noptex Disable pTeX extensions
-o f Output file -O c Set/change paper offset
-p # First page -P s Load config.$s
-pp l Print only pages listed
-q* Run quietly
-r* Reverse order of pages -R* Run securely
-s* Enclose output in save/restore -S # Max section size in pages
-t s Paper format -T c Specify desired page size
-title s Title in comment
-u s PS mapfile -U* Disable string param trick
-v Print version number and quit -V* Send downloadable PS fonts as PK
-x # Override dvi magnification -X # Horizontal resolution
-y # Multiply by dvi magnification -Y # Vertical resolution
-z* Hyper PS -Z* Compress bitmap fonts
# = number f = file s = string * = suffix, `0' to turn off
c = comma-separated dimension pair (e.g., 3.2in,-32.1cm)
l = comma-separated list of page ranges (e.g., 1-4,7-9)
Email bug reports to [email protected].
Previous: Option summary, Up: Command-line options [Contents][Index] 3.2.2 Option detailsMany of the parameterless options listed here can be turned off by suffixing the option with a zero (‘0’); for instance, to turn off page reversal, use ‘-r0’. Such options are marked with a trailing ‘*’.
Next: Config files, Previous: Command-line options, Up: Invoking Dvips [Contents][Index] 3.3 Environment variablesDvips looks for many environment variables, to define search paths and
other things. The path variables are read as needed, after all
configuration files are read, so they override values in the
configuration files. (Except for See Path specifications in Kpathsea, for details of interpretation of path and other environment variables common to all Kpathsea-using programs. Only the environment variables specific to Dvips are mentioned here.
Previous: Environment variables, Up: Invoking Dvips [Contents][Index] 3.4 Dvips configuration filesThis section describes in detail the Dvips-specific config.* device configuration files (called *.cfg on MS-DOS), which override the texmf.cnf configuration files generic to Kpathsea which Dvips also reads (see Config files in Kpathsea). For information about installing these files, including a prototype file you can copy, see config.ps installation.
Next: Configuration file commands, Up: Config files [Contents][Index] 3.4.1 Configuration file searchingThe Dvips program loads many different configuration files, so that parameters can be set globally across the system, on a per-device basis, or individually by each user.
Because the .dvipsrc file is read before the printer-specific
configuration files, individual users cannot override settings in the
latter. On the other hand, the A few command-line options are treated specially, in that they are not overridden by configuration files:
The purpose of these special cases is to (1) minimize the chance of having a mismatched mode and resolution (which ‘mktexpk’ cannot resolve), and (2) let command-line options override config files where possible. Previous: Configuration file searching, Up: Config files [Contents][Index] 3.4.2 Configuration file commandsMost of the configuration file commands are similar to corresponding command line options, but there are a few exceptions. When they are the same, we omit the description here. As with command line options, many may be turned off by suffixing the letter with a zero (‘0’). Within a configuration file, empty lines, and lines starting with a space, asterisk, equal sign, percent sign, or pound sign are ignored. There is no provision for continuation lines.
Next: Interaction with PostScript, Previous: Invoking Dvips, Up: Top [Contents][Index] 4 Paper size and landscape orientationMost TeX documents at a particular site are designed to use the local standard paper size (letter size in the United States, A4 elsewhere). The Dvips program can be customized either sitewide or for a particular printer. On the other hand, plenty of documents are designed for other paper sizes. For instance, you may want to design a document that has the long edge of the paper horizontal. This can be useful when typesetting booklets, brochures, complex tables, or many other documents. This type of paper orientation is called landscape orientation (the default orientation is called portrait). Alternatively, a document might be designed for ledger or A3 paper. Since the intended paper size in these cases is a document design decision, not a printing decision, such information should be given in the TeX file and not on the Dvips command line. For this reason, Dvips supports a ‘papersize’ special. It is hoped that this special will become standard over time for TeX previewers and other printer drivers. Some LaTeX packages, e.g., ‘hyperref.sty’, write a ‘papersize’ special into the DVI file. In this case, you need not and should not attempt to override it manually.
Next: Config file paper sizes, Up: Paper size and landscape [Contents][Index] 4.1 ‘papersize’ specialThe format of the ‘papersize’ special is \special{papersize=width,height}
width is the horizontal size of the page, and height is the vertical size. The dimensions supported are the same as for TeX; namely, in (inches), cm (centimeters), mm (millimeters), pt (points), sp (scaled points), bp (big points, the same as the default PostScript unit), pc (picas), dd (didot points), and cc (ciceros). For a US letter size landscape document, the ‘papersize’ would be: \special{papersize=11in,8.5in}
An alternate specification of \special{landscape}
This is supported for backward compatibility, but it is hoped that reventually the ‘papersize’ comment will dominate. Of course, such a When using the ‘papersize’ special, you generally should not also
specify The ‘papersize’ special must occur somewhere on the first page of the document. Some packages, notably ‘hyperref’, insert this special. By default, if a DVI file contains multiple ‘papersize’ specials,
the last one wins; this is also the behavior of the Next: Paper trays, Previous: ‘papersize’ special, Up: Paper size and landscape [Contents][Index] 4.2 Configuration file paper size commandThe ‘@’ command in a configuration file sets the paper size defaults and options. The first ‘@’ command defines the default paper size. It has three possible parameters: @ [name [hsize vsize]] If ‘@’ is specified on a line by itself, with no parameters, it instructs Dvips to discard all previous paper size information (possibly from another configuration file). If three parameters are given, with the first parameter being a name and the second and third being a dimension (as in ‘8.5in’ or ‘3.2cc’, just like in the ‘papersize’ special), then the option is interpreted as starting a new paper size description, where name is the name and hsize and vsize define the horizontal and vertical size of the sheet of paper, respectively. For example: @ letterSize 8.5in 11in If both hsize and vsize are zero (you must still specify units!) then any page size will match. If the ‘@’ character is immediately followed by a ‘+’ sign, then the remainder of the line (after skipping any leading blanks) is treated as PostScript code to send to the printer, presumably to select that particular paper size: @ letter 8.5in 11in @+ %%BeginPaperSize: Letter @+ letter @+ %%EndPaperSize After all that, if the first character of the line is an exclamation point, then the line is put in the initial comments section of the final output file; else, it is put in the setup section of the output file. For example: @ legal 8.5in 14in @+ ! %%DocumentPaperSizes: Legal @+ %%BeginPaperSize: Legal @+ legal @+ %%EndPaperSize When Dvips has a paper format name given on the command line, it looks for a match by the name; when it has a ‘papersize’ special, it looks for a match by dimensions. The best match found (from the paper size information in the configuration file) is used. The dimensions must match within 5bp. If nothing matches, a warning is printed and the first paper size with
zero dimensions is used; this should be the Landscape mode for all paper sizes is automatically supported. If your printer has a command to set a special paper size, then give dimensions of ‘0in 0in’; the PostScript code that sets the paper size can refer to the dimensions the user requested as ‘hsize’ and ‘vsize’; these will be macros defined in the PostScript that return the requested size in default PostScript units. Also, some printers want ‘BeginPaperSize’ comments and paper size setting commands; others (such as the NeXT) want ‘PaperSize’ comments and they will handle setting the paper size. So paper size entries should typically specify both. When using a paper size that is not already defined in
config.ps, you probably want to say ‘-t unknown’ on
the command line; the If you want no paper size information in the output at all, use ‘-t nopaper’. This is useful with multi-page output that will be processed further. If you just have a single page document, you can use ‘-E’ to get pure EPSF output. The Perl 5 script contrib/configs/mkdvipspapers in the distribution directory may help in determining appropriate paper size definitions. Notwithstanding the above, the default The Previous: Config file paper sizes, Up: Paper size and landscape [Contents][Index] 4.3 Paper traysSome printers, such as the Hewlett-Packard HP4si, have multiple paper
trays. You can set up Dvips to take advantage of this using the
For example, suppose you have an alternate tray stocked with letterhead
paper; the usual tray has the usual paper. You have a document where
you want the first page printed on letterhead, and the remaining pages
on the usual paper. You can create a header file, say
firstletterhead.PS, with the following (PostScript) code
( /bop-hook { dup 0 eq { alternatetray } { normaltray } ifelse } def
where alternatetray and normaltray are the appropriate commands to select the paper trays. On the 4SI, alternatetray is ‘statusdict begin 1 setpapertray end’ and normaltray is ‘statusdict begin 0 setpapertray end’. Then, include the file with either
Next: PostScript fonts, Previous: Paper size and landscape, Up: Top [Contents][Index] 5 Interaction with PostScriptDvips supports inclusion of PostScript figure files (e.g., Encapsulated PostScript), downloading other header files (e.g., fonts), including literal PostScript code, and hypertext.
Next: Header files, Up: Interaction with PostScript [Contents][Index] 5.1 PostScript figuresScaling and including PostScript graphics is a breeze—if the PostScript file is correctly formed. Even if it is not, however, the file can usually be accommodated with just a little more work.
Next: \includegraphics, Up: PostScript figures [Contents][Index] 5.1.1 The bounding box commentThe most important feature of a good PostScript file from the standpoint of including it in another document is an accurate bounding box comment. Every well-formed PostScript file has a comment describing where on the page the graphic is located, and how big that graphic is. This information is given as the lower left and upper right corners of the box just enclosing the graphic, and is thus referred to as the bounding box. These coordinates are given in the default PostScript units (there are precisely 72 PostScript units to the inch, like TeX big points) with respect to the lower left corner of the sheet of paper. To see if a PostScript file has a bounding box comment, just look at the first few lines of the file. PostScript files are standard ASCII, so you can use any text editor to do this. If within the first few dozen lines there is a line like %%BoundingBox: 25 50 400 300 (with any reasonable numbers), chances are very good that the file is Encapsulated PostScript and will work easily with Dvips. If the file contains instead a line like %%BoundingBox: (atend) the file is still probably Encapsulated PostScript, but the bounding box is given at the end of the file. Dvips needs it at the beginning. You can move it with that same text editor, or a simple script. (The bounding box is given in this way when the program that generated the PostScript couldn’t know the size in advance, or was too lazy to compute it.) If the document lacks a ‘%%BoundingBox:’ altogether, you can determine one in a couple of ways. One is to use the ‘bbfig’ program distributed with Dvips in the contrib directory. This can usually find the correct bounding box automatically; it works best with Ghostscript. If the comment looks like this: %%BoundingBox: 0 0 612 792 the graphic claims to take up an entire sheet of paper. This is usually a symptom of a bug in the program that generated it. The other is to do it yourself: print the file. Now, take a ruler, and make the following measurements (in PostScript units, so measure in inches and multiply by 72): From the left edge of the paper to the leftmost mark on the paper is llx, the first number. From the bottom edge of the paper to the bottommost mark on the paper is lly, the second number. From the left edge of the paper to the rightmost mark on the paper is urx, the third number. The fourth and final number, ury, is the distance from the bottom of the page to the uppermost mark on the paper. Once you have the numbers, add a comment of the following form as the second line of the document. (The first line should already be a line starting with the two characters ‘%!’; if it is not, the file probably isn’t PostScript.) %%BoundingBox: llx lly urx ury Or, if you don’t want to modify the file, you can simply write these numbers down in a convenient place and give them in your TeX document when you import the graphic, as described in the next section. If the document does not have such a bounding box, or if the bounding box is given at the end of the document, or the bounding box is wrong, please complain to the authors of the software package that generated the file. Next: EPSF macros, Previous: Bounding box, Up: PostScript figures [Contents][Index] 5.1.2 The \includegraphics macro for LaTeXOnce the figure file has a bounding box comment (see the previous section) you are ready to import the graphic into a LaTeX document. For LaTeX2e, you can use the epsf, graphics or graphicx packages, but the last is recommended—it has the most flexible syntax, and is briefly described here. Further information can be found in grfguide or epslatex, which should be included in your LaTeX distribution in DVI, PDF, or other formats. (If you are still using LaTeX 2.09, use epsf.sty). Just put the following command into your preamble: \usepackage[dvips]{graphicx}
Depending on your system, a suitable driver setup may already be present, so that LaTeX automatically produces DVI files suitable for Dvips. In this case you can leave out the ‘[dvips]’ parameter. Now, at the point you want to include a file foo.eps, enter a line such as: \includegraphics{foo.eps}
However, it is usually best to omit the file extension and only use \includegraphics{foo}
because then you can process the same LaTeX file with different TeX engines or DVI converters if you also provide suitable graphics files for them, e.g., foo.pdf or foo.png. The \includegraphics command has many options, specified in ‘key=value’ syntax, to allow you to resize, rotate or trim the included graphic—see grfguide or epslatex. If your file does not have a bounding box comment, you can supply the numbers as determined in the previous section, in the same order they would have been in a normal bounding box comment: \includegraphics[bb=100 100 500 500]{foo.ps}
Now, save your changes and run LaTeX and Dvips; the output should have your graphic positioned at precisely the point you indicated, occupying the proper amount of space. PostScript graphics have their origin in the lower left corner. Therefore, in TeX, a graphic will occupy a box that extends far above the line where it is put in, but has depth zero below it. Combining ‘\includegraphics’ with ‘\parbox’ commands or minipages can sometimes be confusing when this is not taken into account. Next: psfile special, Previous: \includegraphics, Up: PostScript figures [Contents][Index] 5.1.3 Using the EPSF macrosIf you are using LaTeX2e, use the ‘graphics’ or ‘graphicx’ package. See \includegraphics. If you are using plain TeX or LaTeX 2.09, you need epsf.tex (for plain TeX) and epsf.sty (for LaTeX). For plain TeX, add a line like this near the top of your input file: \input epsf If you are using LaTeX 2.09, add the ‘epsf’ style option, as in: \documentstyle[12pt,epsf]{article}
In any case, the above only needs to be done once, no matter how many figures you plan to include. Now, at the point you want to include a file, enter a line such as: \epsffile{foo.eps}
If you are using LaTeX, you may need to add \epsffile[100 100 500 500]{foo.ps}
Now, save your changes and run TeX and Dvips; the output should have your graphic positioned at precisely the point you indicated, occupying the proper amount of space. The If you want TeX to report the size of the figure as a message on your terminal when it processes each figure, give the command: \epsfverbosetrue
Next: EPSF clipping, Up: EPSF macros [Contents][Index] 5.1.3.1 EPSF scalingUsually, you will want to scale an EPSF figure to some size appropriate for your document, since its natural size is determined by the creator of the EPS file. The best way to do this is to assign the desired size to the TeX
\epsfxsize=dimen right before the call to \epsfysize=dimen in which case the height will be set and the width scaled proportionally. If you set both, both will be honored, but the aspect ratio of the included graphic may necessarily be distorted, i.e., its contents stretched in one direction or the other. You can resize graphics in a more general way by redefining the
\def\epsfsize#1#2{body}
Some useful definitions of body:
For compatibility with other PostScript drivers, it is possible to turn off the default scaling of included figures by the DVI magnification with the following TeX command: \special{! /magscale false def}
Use of this command is not recommended because it will make the
DVI magnification is not applied to any output from code you write in ‘bop-hook’ or its ilk (see PostScript hooks), Previous: EPSF scaling, Up: EPSF macros [Contents][Index] 5.1.3.2 EPSF clippingBy default, clipping is disabled for included EPSF images. This is because clipping to the bounding box dimensions often cuts off a small portion of the figure, due to slightly inaccurate bounding box arguments. The problem might be subtle; lines around the boundary of the image might be half their intended width, or the tops or bottoms of some text annotations might be sliced off. If you want to turn clipping on, just use the command \epsfclipon and to turn clipping back off, use \epsfclipoff Next: Dynamic creation of graphics, Previous: EPSF macros, Up: PostScript figures [Contents][Index] 5.1.4 ‘psfile’ specialThe basic special for file inclusion is as follows: \special{psfile=filename.ps [key=value] … }
This downloads the PostScript file filename.ps such that the current point will be the origin of the PostScript coordinate system. The optional key=value assignments allow you to specify transformations on the PostScript. The possible keys are:
The offsets and sizes are given in PostScript units (big points). Thus, for example: \special{psfile=foo.ps hoffset=72 hscale=90 vscale=90}
will shift the graphics produced by file foo.ps right by one inch and will draw it at 0.9 times normal size. Offsets are given relative to the point of the special command, and are unaffected by scaling or rotation. Rotation is counterclockwise about the origin. The order of operations is to rotate the figure, scale it, then offset it. For compatibility with older PostScript drivers, it is possible to change the units that ‘hscale’ and ‘vscale’ are given in. This can be done by redefining ‘@scaleunit’ in ‘SDict’ by a TeX command such as \special{! /@scaleunit 1 def}
The ‘@scaleunit’ variable, which is by default 100, is what ‘hscale’ and ‘vscale’ are divided by to yield an absolute scale factor. Next: Fonts in figures, Previous: psfile special, Up: PostScript figures [Contents][Index] 5.1.5 Dynamic creation of PostScript graphics filesPostScript is an excellent page description language—but it does tend to be rather verbose. Compressing PostScript graphics files can reduce them by factor of five or more. For this reason, if the name of an included PostScript file ends with .Z or .gz, Dvips automatically runs ‘gzip -d’. For example: \epsffile[72 72 540 720]{foo.ps.gz}
Since the results of such a command are not accessible to TeX, if you use this facility with the epsf macros, you need to supply the bounding box parameter yourself, as shown. More generally, if the filename parameter to one of the graphics inclusion techniques starts with a left quote (‘`’), the parameter is instead interpreted as a command to execute that will send the actual file to standard output. For example: \special{psfile="`gnuplot foo"}
to include the file foo. Of course, the command to be executed can be anything, including using a file conversion utility such as tek2ps or whatever is appropriate. This feature can be disabled with the ‘-R’ command-line option or ‘R’ configuration option. Previous: Dynamic creation of graphics, Up: PostScript figures [Contents][Index] 5.1.6 Fonts in figuresYou can use any font available to TeX and Dvips within a graphics
file by putting a %*Font: tfmname scaledbp designbp hex-start:hex-bitstring Here is the meaning of each of these elements:
MetaPost’s output figures contain lines like this for bitmap fonts used in a MetaPost label (see MetaPost in Web2c). Next: Literal PS, Previous: PostScript figures, Up: Interaction with PostScript [Contents][Index] 5.2 PostScript header filesHeader files are bits of PostScript included in the output file; generally they provide support for special features, rather than producing any printed output themselves. You can explicitly request downloading header files if necessary for some figure, or to achieve some special effect. Dvips includes some headers on its own initiative, to implement features
such as PostScript font reencoding, bitmap font downloading, handling of
The PostScript dictionary stack will be at the ‘userdict’ level when header files are included.
Next: Including headers from the command line, Up: Header files [Contents][Index] 5.2.1 Including headers from TeXIn order to get a particular graphic file to work, a certain font or
header file might need to be sent first. The Dvips program provides
support for this with the ‘header’ \special{header=foo.ps}
As another example, if you have some PostScript code that uses a PostScript font not built into your printer, you must download it to the printer. If the font isn’t used elsewhere in the document, Dvips can’t know you’ve used it, so you must include it in the same way, as in: \special{header=putr.pfa}
to include the font definition file for Adobe Utopia Roman. The \special{header={foo.ps} pre={pre code} post={post code}}
This will insert This allows, for instance, dynamic headers, where some of the content depends on settings from the user in (La)TeX. Another application is the inclusion of graphics inside the PostScript header, so that they can be reused throughout the document, as with logs. That avoids including the same graphic several times. This is implemented in the graphics/graphicx-psmin package. This extended syntax has one additional feature. When Dvips finds the extended syntax, it will also look in the installed tex/ tree(s) for the header file (foo.ps in our example), and not only in the current directory and dvips tree as the original syntax does. This is because common graphics may well come with packages which are installed in the tex/ tree. Next: Headers and memory usage, Previous: Including headers from TeX, Up: Header files [Contents][Index] 5.2.2 Including headers from the command lineYou can include headers when you run Dvips, as well as from your document (see the previous section). To do this, run Dvips with the option ‘-P header’; this will read the file config.header, which in turn can specify a header file to be downloaded with the ‘h’ option. See Configuration file commands. These files are called header.cfg on MS-DOS. You can arrange for the same file to serve as a ‘-P’ config file and the downloadable header file, by starting the lines of PostScript code with a space, leaving only the ‘h’ line and any comments starting in the first column. As an example, see contrib/volker/config.* (contrib/volker/*.cfg on MS-DOS). (These files also perform useful functions: controlling duplex/simplex mode on duplex printers, and setting various screen frequencies; contrib/volker/README explains further.) Previous: Including headers from the command line, Up: Header files [Contents][Index] 5.2.3 Headers and memory usageDvips tries to avoid overflowing the printer’s memory by splitting the output files into “sections” (see the ‘-i’ option in Option details). Therefore, for all header files, Dvips debits the printer VM budget by some value. If the header file has, in its leading commentary a line of the form %%VMusage: min max then max is used. If there is no Illustrations (figure files) are also checked for Therefore, if your document uses very large fonts or very large included figures, Dvips might take it upon itself to split the output into unwanted sections. If this causes problems, the simplest solution is to use ‘dvips -Pmaxmem’, which reads the Dvips file config.maxmem, which sets Dvips’s idea of the memory available to a very large number. (See the ‘m’ item in Configuration file commands.) Next: Hypertext, Previous: Header files, Up: Interaction with PostScript [Contents][Index] 5.3 Literal PostScriptYou can include literal PostScript code in your document in several ways.
Next: ps special, Up: Literal PS [Contents][Index] 5.3.1
|
| • Hypertext caveats | Font quality, missing character psi. | |
| • Hypertext specials | The details on the specials. |
Next: Hypertext specials, Up: Hypertext [Contents][Index]
If you intend to go all the way to PDF, you may want to use the standard 35 PostScript fonts exclusively, since other fonts are embedded as bitmaps by default. The Adobe PDF readers are extremely slow when dealing with bitmap fonts and the results look terrible on the screen. Printouts will probably look fine, but may not take full advantage of a high-resolution printer. Alternatively, you can have your fonts embedded as Type 1 scalable outlines. The resulting PostScript files may be larger, but can be effectively rasterized at any resolution. They can also be converted to PDF files that can be used effectively at any screen or printer resolution.
To get the TeX fonts embedded in the PostScript file as Type 1 fonts, add ‘-Ppdf’ to the dvips command line switches. The printout for a run should look something like this:
dvips report -Ppdf -o report.ps This is dvips(k) 5.86 Copyright 1999 Radical Eye Software (www.radicaleye.com) ' TeX output 2001.06.15:0837' -> report.ps <tex.pro><alt-rule.pro><texc.pro><texps.pro><special.pro>. <cmbx9.pfb><cmsy6.pfb><cmsy7.pfb><cmr5.pfb><cmex10.pfb><cmr9.pfb> <cmmi7.pfb><cmsy10.pfb><cmmib10.pfb><cmmi10.pfb><cmti10.pfb> <cmr7.pfb><cmbx10.pfb><cmr10.pfb><cmti9.pfb><cmr12.pfb><cmbx12.pfb> [1] [2<mean1.ps>] [3<bounce1-00.ps>] [4]
An entry like "<cmr10.pfb>" indicates success: dvips found the Computer
Modern Roman 10 point font in a PostScript Font Binary file, translated
it to an ASCII encoding, and embedded it. You can confirm this by
examining the PostScript output file, looking for the section starting
%%BeginFont: CMR10 followed by an entry /FontType 1 def.
The ‘-Ppdf’ option requires that the relevant outline
(.pfa or .pfb) files be installed (see Font concepts). For example, the cmr10 file might be in
/usr/share/texmf/fonts/type1/bluesky/cm/cmr10.pfb. Your TeX
distribution may make those fonts available in a separate optional
package (e.g., tetex-extra in Debian). Failing that,
commercial versions of the Computer Modern fonts are available from
Blue Sky; public domain versions, in particular, the lm
and cm-super font families, are available from CTAN and in TeX
distributions.
You can convert a PostScript file to PDF using distill, which
comes with Adobe Acrobat, or ps2pdf, which comes with
Ghostscript. The ps2pdf that comes with Ghostscript
version 6.0 or earlier will not embed Type 1 fonts. Current
recommendations are GNU Ghostscript 6.51 or Aladdin Ghostscript 7.0.
You can check the fonts in a PDF file with Acrobat Reader by selecting
the menu entries ‘File|Document Info|Fonts’.
Also, the Adobe distillers prior to 2.1 drop trailing space characters
(character code 32) from strings. Unfortunately, the PostScript fonts
use this character code for characters other than space (notably the
Greek letter psi in the Symbol font), and so these characters are
dropped. This bug is fixed in version 2.1.
If you can’t upgrade, one workaround is to change all the trailing
blanks in strings to a character code that isn’t in the font. This works
because the default behavior is to substitute a blank for a missing
character, i.e., the distiller is fooled into substituting the right
character. For instance, with the Blue Sky fonts, you can globally
replace ‘ )’ with ‘\200)’ (with sed, for example) and
get the desired result. With the public domain fonts, you will probably
have to use a character code in the range 128 to 191 since these fonts
duplicate the first 32 characters starting at 192 to avoid MS-DOS
problems.
For more information on the use of TeX to produce PDF files, see the article “Creating quality Adobe PDF files from TeX with DVIPS” by Kendall Whitehouse of Adobe. Adobe seems not to offer the article any more, but copies are available elsewhere:
http://www.math.hawaii.edu/~ralph/MathOnWeb/TeXPDF.html http://www.utdallas.edu/~cantrell/online/543e.html
You may also want to check “Notes on converting (La)TeX documents
to robust PDF using Rokicki’s dvips and Acrobat Distiller” by
Timothy P. Van Zandt:
http://www.emrg.com/texpdf.htmlhttp://zandtwerk.insead.fr/tex2pdf.html.
Previous: Hypertext caveats, Up: Hypertext [Contents][Index]
Current support for the World Wide Web in the TeX system does not involve modifying TeX itself. We need only define some specials; Arthur Smith ([email protected]), Tanmoy Bhattacharya, and Paul Ginsparg originally proposed and implemented the following:
html:<a href="xurl"> html:<a name="name"> html:</a> html:<img src="xurl"> html:<base href="xurl">
Like all TeX \special’s, these produce no visible output, and
are uninterpreted by TeX itself. They are instructions to DVI
processors only.
Here, xurl is a standard WWW uniform resource locator (URL), possibly extended with a ‘#type.string’ construct, where type is ‘page’, ‘section’, ‘equation’, ‘reference’ (for bibliographic references), ‘figure’, ‘table’, etc. For example,
\special{html:<a href="http://www.maths.tcd.ie/~tim/ch1.dvi#equation.1.1">}
is a link to equation (1.1) in an example document by Tim Murphy.
See the URL http://www.w3.org/hypertext/WWW/Addressing/Addressing.html for a precise description of base URL’s.
Descriptions of the \special’s:
Creates links in your TeX document. For example:
\special{html:<a href="http://www.tug.org/">}\TeX\ Users
Group\special{html:</a>}
The user will be able to click on the text ‘TeX Users
Group’ while running Xdvi and get to the TUG home page. (By the way,
this is for illustration. In practice, you most likely want to use
macros to insert the \special commands; reference above.)
Defines URL targets in your TeX documents, so links can be resolved. For example:
\special{html:<a name="paradise">}Paradise\special{html:</a>}
is exactly where you are right now.
This will resolve an ‘href="#paradise"’. You’ll also have to change the catcode of ‘#’, etc. It’s usually easiest to use existing macro packages which take care of all the details, such as hyperref for LaTeX. The HyperTeX FAQ has more information.
Links to an arbitrary external file. Interactively, a viewer is spawned to read the file according to the file extension and your mailcap file (see the Xdvi documentation).
Defines a base URL that is prepended to all the name targets.
Typically unnecessary, as the name of the DVI file being read is used by
default.
The ‘img’ and ‘base’ tags are not yet implemented in Dvips or the NeXTSTEP DVI viewer.
Next: Color, Previous: Interaction with PostScript, Up: Top [Contents][Index]
Dvips supports the use of PostScript fonts in TeX documents. To use a PostScript font conveniently, you need to prepare a corresponding virtual font; the program Afm2tfm, supplied with Dvips, helps with that.
All the necessary support for the standard 35 PostScript fonts (‘AvantGarde-Book’ through ‘ZapfDingbats’), plus other freely or commonly available PostScript fonts is available along with Dvips. To use these fonts, you need do nothing beyond what is mentioned in the installation procedure (see Installation). This chapter is therefore relevant only if you are installing new PostScript fonts not supplied with Dvips. (Or if you’re curious.)
| • Font concepts | Metrics, glyphs, virtual fonts, and encodings. | |
| • Making a font available | Installing and using a PostScript font. | |
| • Invoking afm2tfm | Creating TFM and AFM files for a virtual font. | |
| • psfonts.map | Defining available PostScript fonts. |
Next: Making a font available, Up: PostScript fonts [Contents][Index]
The information needed to typeset using a particular font is contained in two files: a metric file that contains shape-independent information and a glyph file that contains the actual shapes of the font’s characters. A virtual font is an optional additional file that can specify special ways to construct the characters. TeX itself (or LaTeX) look only at the metric file, but DVI drivers such as Dvips look at all three of these files.
An encoding file defines the correspondence between the code numbers of the characters in a font and their descriptive names. Two encoding files used together can describe a reencoding that rearranges, i.e., renumbers, the characters of a font.
| • Metric files | Shape-independent font information. | |
| • Glyph files | Character shapes. | |
| • Virtual fonts | Constructing one font from others. | |
| • Encodings | Character codes and character names. | |
| • Bitmap font encodings | Encodings for bitmapped fonts. | |
| • PostScript typesetting | How PostScript typesets a character. |
Next: Glyph files, Up: Font concepts [Contents][Index]
A metric file describes properties of the font that are independent of what the characters actually look like. Aside from general information about the font itself, a metric file has two kinds of information: information about individual characters, organized by character code, and information about sequences of characters.
The per-character information specifies the width, height, depth, and italic correction of each character in the font. Any might be zero.
In addition to information on individual characters, the metric file specifies kerning, i.e., adding or removing space between particular character pairs. It further specifies ligature information: when a sequence of input characters should be typeset as a single (presumably different) “ligature” character. For example, it’s traditional for the input ‘fi’ to be typeset as ‘fi’, not as ‘fi’ (with the dot of the ‘i’ colliding with ‘f’). (In English, the only common ligatures are fi, fl, ff, ffi, and ffl.)
Different typesetting systems use different metric file formats:
TFM files are binary (and hence are typically much smaller than AFM
files). You can use the tftopl program (see tftopl
invocation in Web2c) that comes with TeX to transform a TFM
file into a human-readable “property list” (‘.pl’) file. You can
also edit a PL file and transform it back to a TeX-readable TFM with
the companion program pltotf (see pltotf invocation in Web2c). Editing metrics by hand is not something you’re likely to want
to do often, but the capability is there.
The Afm2tfm program distributed with Dvips converts an AFM file to a TFM file and performs other useful transformations as well. See Invoking afm2tfm.
Next: Virtual fonts, Previous: Metric files, Up: Font concepts [Contents][Index]
Although a metric file (see the previous section) contains information about the spatial and other properties of the character at position 75, say, it contains nothing about what the character at position 75 actually looks like. The glyphs—the actual shapes of the letterforms in a font—are defined by other files, which we call glyph files. TeX itself only reads the TFM file for a font; it does not need to know character shapes.
A glyph file is a file that defines the shapes of the characters in a font. The shapes can be defined either by outlines or by bitmaps.
PostScript fonts are defined as outline fonts: Each character in the font is defined by giving the mathematical curves (lines, arcs, and splines) that define its contours. Different sizes of a character are generated by linearly scaling a single shape. For example, a 10-point ‘A’ is simply half the size of a 20-point ‘A’. Nowadays, outline fonts usually also contain hints—additional information to improve the appearance of the font at small sizes or low resolutions.
Although various kinds of PostScript outline fonts exist, by far the most common, and the only one we will consider, is called Type 1. The glyph files for Postscript Type 1 fonts typically have names ending in ‘.pfa’ (“printer font ASCII”) or ‘.pfb’ (“printer font binary”).
In contrast, glyph files for Computer Modern and the other standard TeX fonts are bitmap fonts, generated from Metafont (‘.mf’) descriptions. The Metafont program distributed with TeX generates bitmaps from these descriptions.
The glyph files for TeX bitmap fonts are usually stored in packed font (PK) files. The names of these files end in ‘.nnnpk’, where nnn is the resolution of the font in dots per inch. For example, cmr10.600pk contains the bitmaps for the ‘cmr10’ font at a resolution of 600dpi. (On DOS filesystems, it’s more likely dpi600\cmr10.pk.)
Metafont actually outputs generic font (GF) files, e.g.,
cmr10.600gf, but the GF files are usually converted immediately
to PK format (using the gftopk utility that comes with TeX)
since PK files are smaller and contain the same information. (The GF
format is a historical artifact.)
Next: Encodings, Previous: Glyph files, Up: Font concepts [Contents][Index]
A virtual font is constructed by extracting characters from one or more existing fonts and rearranging them, or synthesizing new characters in various ways. The explanation in this manual is intended to suffice for understanding enough about virtual fonts to use them with Dvips. It isn’t a reference manual on virtual fonts. For more information: The primary document on virtual fonts is Donald E. Knuth, TUGboat 11(1), Apr. 1990, pp. 13–23, “Virtual Fonts: More Fun for Grand Wizards” (mirror.ctan.org/info/virtual-fonts.knuth). (Don’t be intimidated by the subtitle.)
A virtual font (‘.vf’) file specifies, for each character in the
virtual font, a recipe for typesetting that character. A VF file, like
a TFM file, is in a compressed binary format. The vftovp and
vptovf programs convert a VF file to a human-readable VPL
(virtual property list) format and back again. See vftovp
invocation in Web2c, and vptovf invocation in Web2c.
In the case of a PostScript font f being used in a straightforward way, the recipe says: character i in the VF font is character j in font f. The font f is called a base font. For example, the VF file could remap the characters of the PostScript font to the positions where TeX expects to find them. See Encodings.
Since TeX reads only TFM files, not VF’s, each VF must have a
corresponding TFM for use with TeX. This corresponding TFM is
created when you run vptovf.
You can expand virtual fonts into their base fonts with DVIcopy (see dvicopy invocation in Web2c). This is useful if you are using a DVI translator that doesn’t itself understand vf’s.
If a virtual font has no entry at a given codepoint and the first
MAPFONT designates an (u)pTeX JFM, we designate the glyph of
the same codepoint in the TFM(JFM) with the smallest font ID. This
feature helps to reduce the size of Japanese virtual fonts. For more
information about the extensive support of Japanese in TeX, see
https://github.com/texjporg.
Next: Bitmap font encodings, Previous: Virtual fonts, Up: Font concepts [Contents][Index]
Every font, whatever its type, has an encoding, that specifies the correspondence between “logical” characters and character codes. For example, the ASCII encoding specifies that the character numbered 65 (decimal) is an uppercase ‘A’. The encoding does not specify what the character at that position looks like; there are lots of ways to draw an ‘A’, and a glyph file (see Glyph files) tells how. Nor does it specify how much space that character occupies; that information is in a metric file (see Metric files).
TeX implicitly assumes a particular encoding for the fonts you use
with it. For example, the plain TeX macro \', which typesets
an acute accent over the following letter, assumes the acute accent is
at position 19 (decimal). This happens to be true of standard TeX
fonts such as Computer Modern, as you might expect, but it is not true
of normal PostScript fonts.
It’s possible but painful to change all the macros that assume particular character positions. A better solution is to create a new font with the information for the acute accent at position 19, where TeX expects it to be. See Making a font available.
PostScript represents encodings as a sequence of 256 character names called an encoding vector. An encoding file (‘.enc’) gives such a vector, together with ligature and kerning information (with which we are not concerned at the moment). These encoding files are used by the Afm2tfm program. Encoding files are also downloaded to the PostScript interpreter in your printer if you use one of them in place of the default encoding vector for a particular PostScript font.
Examples of encodings: the dvips.enc encoding file that comes with the Fontname distribution (http://tug.org/fontname) is a good (but not perfect) approximation to the TeX encoding for TeX’s Computer Modern text fonts. This is the encoding of the fonts that originated with Dvips, such as ptmr.tfm. The distribution includes many other encoding files; for example, 8r.enc, which is the base font for the current PostScript font distribution, and three corresponding to the TeX mathematics fonts: texmext.enc for math extensions, texmital.enc for math italics, and texmsym.enc for math symbols.
Next: PostScript typesetting, Previous: Encodings, Up: Font concepts [Contents][Index]
To dvips, bitmapped fonts do not have any notion of linguistics; they are simply a vector of glyphs. By comparison, PostScript fonts are required to contain an encoding vector that at least provides glyph names; these names can permit PostScript and PDF viewers to extract legible text from Postscript and PDF output.
Unlike previous versions, dvips versions 2020 and later add glyph
naming information to Type 3 bitmapped fonts (if they can locate such
information) as an Encoding vector. This provides some support for
search, for copy and paste, and even some limited support for
accessibility. The ‘bitmapfontenc’ command line option
(see Option details and bitmapfontenc configuration option
(see Configuration file commands) enable and disable this
functionality; by default it is set to enabled, without warnings.
To do this, dvips must find encoding information for the bitmapped fonts. It does this by first searching for a font-specific encoding file; for instance, for cmr10, it will search for dvips-cmr10.enc in the standard encoding path. If it does not find such a file, it will search for a dvips-all.enc file which contains a base set of encodings for many fonts.
The specific syntax of an encoding file is unspecified, except that it must be a PostScript fragment that leaves exactly one object on the operand stack. (This is different from the encoding files used to define encodings for PostScript fonts, described earlier). Normally that object is just an array of 256 names; in this case, that array is used as the encoding vector for the font. Alternatively, the object can be a procedure that, when executed, leaves a legal encoding vector on the stack. This second option is made available to support future enhancements that may add additional constructs to the font dictionary to enhance the interpretation of font characters.
The dvips-all.enc file contains encodings for many fonts, and it is loaded by dvips at most once. The format is just a sequence of font names, one per line, each terminated by a colon, followed by the encoding to use for those files.
As part of its operation, to enable heuristics in PostScript and PDF viewers to properly identify word breaks and column gutters, dvips also generates a modified font bounding box and a modified font coordinate system.
Previous: Bitmap font encodings, Up: Font concepts [Contents][Index]
The output of Dvips is a program in the PostScript language that instructs your (presumably PostScript-capable) printer how to typeset your document by transforming it into toner on paper. Your printer, in turn, contains a PostScript interpreter that carries out the instructions in this typesetting program.
The program must include the definition of any PostScript fonts that you use in your document. Fonts built into your printer (probably the standard 35: ‘Times-Roman’, ‘ZapfDingbats’, …) are defined within the interpreter itself. Other fonts must be downloaded as pfa or pfb files (see Glyph files) from your host (the computer on which you’re running Dvips).
You may be wondering exactly how a PostScript interpreter figures out what character to typeset, with this mass of metrics, glyphs, encodings, and other information. (If you’re not wondering, skip this section …)
The basic PostScript operator for imaging characters is
show. Suppose you’ve asked TeX to typeset an ‘S’. This will
eventually wind up in the Dvips output as the equivalent of this
PostScript operation:
(S) show
Here is how PostScript typesets the ‘S’:
PostScript has a notion of “the current font”—whatever font is currently being typeset in.
/S.
/S as a key in a dictionary named
CharStrings, another mandatory entry in a font dictionary.
S in CharStrings is the equivalent of a
series of standard PostScript commands like ‘curveto’,
‘lineto’, ‘fill’, and so on. These commands are executed to
draw the character. There can also be hint information that helps
adapt the character to low-resolution rasters. (See Glyph files.)
The commands are actually represented in a more compact way than
standard PostScript source; see the Type 1 book for details.
This method for typesetting characters is used in both Level 1 and Level 2 PostScript. See the PostScript reference manuals for more information.
Next: Invoking afm2tfm, Previous: Font concepts, Up: PostScript fonts [Contents][Index]
To make a PostScript font available in a TeX document, you need to install the font on your system and then define it within the document. Once you have installed the font, of course, it is available for any document thereafter and you don’t need to reinstall it. You must have an AFM file for any font you install. Unless the font is built into your printer, you must also have a PFA or PFB file.
In the following examples, we use the font ‘Times-Roman’ to illustrate the process. But you should use the prebuilt fonts for Times and the other standard fonts, rather than rebuilding them. The prebuilt fonts are made using a more complicated process than that described here, to make them work as well as possible with TeX. So following the steps in this manual will not generate files identical to the distributed ones. See PostScript font installation, for pointers to the prebuilt fonts.
Installation of a PostScript font proceeds in three steps. See Font concepts, for descriptions of the various files involved.
afm2tfm to create a TFM file for the original font,
and the VPL form of the virtual font:
afm2tfm Times-Roman -v ptmr rptmr
vptovf to generate a VF and TFM file for the virtual font
from the VPL file:
vptovf ptmr.vpl ptmr.vf ptmr.tfm
rptmr Times-Roman <ptmr8a.pfa
cp ptmr.vf fontdir/vf/… cp *ptmr.tfm fontdir/tfm/… cp ptmr.afm fontdir/afm/… cp ptmr.pf? fontdir/type1/…
The simplest invocation of Afm2tfm to make virtual fonts goes something like this:
afm2tfm Times-Roman -v ptmr rptmr
This reads the file Times-Roman.afm, and produces two files as output, namely the virtual property list’file ptmr.vpl, and the “raw” font metric file rptmr.tfm. To use the font in TeX, you first run
vptovf ptmr.vpl ptmr.vf ptmr.tfm
You should then install the virtual font file ptmr.vf where Dvips will see it and install ptmr.tfm and rptmr.tfm where TeX and Dvips will see them.
Using these raw fonts is not recommended; there are no raw fonts in the prebuilt PostScript fonts distributed along with Dvips. But nevertheless, that’s how Afm2tfm presently operates, so that’s what we document here. The ‘r’ prefix convention is likewise historical accident.
You can also make more complex virtual fonts by editing ptmr.vpl before running ‘vptovf’; such editing might add the uppercase Greek characters in the standard TeX positions, for instance. (This has already been done for the prebuilt fonts.)
Once the files have been installed, you’re all set. You can now do things like this in TeX:
\font\myfont = ptmr at 12pt \myfont Hello, I am being typeset in 12-point Times-Roman.
Thus, we have two fonts, one actual (‘rptmr’, which is analogous to the font in the printer) and one virtual (‘ptmr’, which has been remapped to the standard TeX encoding (almost)), and has typesetting know-how added. You could also say
\font\raw = rptmr at 10pt
and typeset directly with that, but then you would have no ligatures or kerning, and you would have to use Adobe character positions for special letters like The virtual font ‘ptmr’ not only has ligatures and kerning, and most of the standard accent conventions of TeX, it also has a few additional features not present in the Computer Modern fonts. For example, it includes all the Adobe characters (such as the Polish ogonek and the French guillemots). The only things you lose from ordinary TeX text fonts are the dotless ‘j’ (which can be hacked into the VPL file with literal PostScript specials if you have the patience) and uppercase Greek letters (which just don’t exist unless you buy them separately). See Reencoding with Afm2tfm.
As a final step you need to record information about both the virtual font and the original font (if you ever might want to use it) in the psfonts.map file (see psfonts.map). For our example, you’d insert the following into psfonts.map:
rptmr Times-Roman <ptmr8a.pfa
Of course, Times-Roman is already built in to most every
printer, so there’s no need to download any Type 1 file for it. But if
you are actually following these instructions for new fonts, most likely
they are not built in to the printer.
These PostScript fonts can be scaled to any size. Go wild! Using PostScript fonts, however, does use up a great deal of the printer’s memory and it does take time. You may find downloading bitmap fonts (possibly compressed, with the ‘Z’ option) to be faster than using the built-in PostScript fonts.
Next: psfonts.map, Previous: Making a font available, Up: PostScript fonts [Contents][Index]
The Afm2tfm program converts an AFM file for a PostScript font to a TFM file and a VPL file for a corresponding virtual font (or, in its simplest form, to a TFM file for the PostScript font itself). The results of the conversion are affected by the command-line options and especially by the reencodings you can specify with those options. You can also obtain special effects such as an oblique font.
Alternatives to Afm2tfm for creating virtual fonts include
fontinst https://ctan.org/pkg/fontinst,
lcdf-typetools, particularly otftotfm
(https://ctan.org/pkg/lcdf-typetools), and afm2pl
(http://tex.aanhet.net/afm2pl/), among others.
| • Changing font encodings | Reencoding with -t, -p, -T. | |
| • Special font effects | Oblique fonts, small caps, and such. | |
| • Afm2tfm options | afm2tfm command-line options. |
Next: Special font effects, Up: Invoking afm2tfm [Contents][Index]
Afm2tfm allows you to specify a different encoding for a PostScript font (for a general introduction to encodings, see Encodings). The ‘-t’ option changes the TeX encoding, ‘-p’ changes the PostScript encoding, and ‘-T’ changes both simultaneously, as detailed in the sections below.
| • Changing TeX encodings | Where TeX finds a character. | |
| • Changing PostScript encodings | Where PostScript finds a character. | |
| • Changing both encodings | One and the same, simultaneously. | |
| • Reencoding with Afm2tfm | Problems with the default encoding. | |
| • Encoding file format | Syntax of an encoding file. |
Next: Changing PostScript encodings, Up: Changing font encodings [Contents][Index]
To build a virtual font with Afm2tfm, you specify the ‘-v’ or ‘-V’ option. You can then specify an encoding for that virtual font with ‘-t tex-enc’. (‘-t’ is ignored if neither ‘-v’ nor ‘-V’ is present.) Any ligature and kerning information you specify in tex-enc will be used in the VPL, in addition to the ligature and kerning information from the AFM file.
If the AFM file has no entry for a character specified in tex-enc, that character will be omitted from the output VPL.
The ‘-t’ option is likely to be needed when you have a PostScript font corresponding to a TeX font other than a normal text font such as Computer Modern. For instance, if you have a PostScript font that contains math symbols, you’d probably want to use the encoding in the texmsym.enc file supplied with Dvips. (For a start; to actually get usable math fonts, you have to define much more than just an encoding.)
Next: Changing both encodings, Previous: Changing TeX encodings, Up: Changing font encodings [Contents][Index]
By default, Afm2tfm uses the encoding it finds in the AFM file. You can specify a different PostScript encoding with ‘-p ps-enc’. This makes the raw TFM file (the one output by Afm2tfm) have the encoding specified in the encoding file ps-enc. Any ligature or kern information specified in ps-enc is ignored by Afm2tfm, since ligkern info is always omitted from the raw TFM.
If you use this option, you must also arrange to download ps-enc as part of any document that uses this font. You do this by adding a line like the following one to psfonts.map (see psfonts.map):
zpopr Optima "MyEncoding ReEncodeFont" <myenc.enc
Using ‘-p’ is the only way to access characters in a PostScript font that are neither encoded in the AFM file nor constructed from other characters. For instance, Adobe’s ‘Times-Roman’ font contains the extra characters ‘trademark’ and ‘registered’ (among others); these can only be accessed through such a PostScript reencoding.
The ‘8r’ base encoding used for the current PostScript font distribution does do this reencoding, for precisely this reason.
Next: Reencoding with Afm2tfm, Previous: Changing PostScript encodings, Up: Changing font encodings [Contents][Index]
The option ‘-T enc-file’ is equivalent to ‘-p enc-file -t enc-file’. If you make regular use of a private non-standard reencoding ‘-T’ is usually a better idea than the individual options, to avoid unexpected inconsistencies in mapping otherwise. An example of when you might use this option is a dingbats font: when you have a TeX encoding that is designed to be used with a particular PostScript font.
Next: Encoding file format, Previous: Changing both encodings, Up: Changing font encodings [Contents][Index]
The Afm2tfm program creates the TFM and VF files for the virtual font corresponding to a PostScript font by reencoding the PostScript font. Afm2tfm generates these files from two encodings: one for TeX and one for PostScript. The TeX encoding is used to map character numbers to character names while the PostScript encoding is used to map each character name to a possibly different number. In combination, you can get access to any character of a PostScript font at any position for TeX typesetting.
In the default case, when you specify none of the -t, -p,
or -T options, Afm2tfm uses a default TeX encoding (which
mostly corresponds to the Computer Modern text fonts) and the PostScript
encoding found in the AFM file being read. The reencoding is also
sometimes called a remapping.
For example, the default encodings reencode the acute accent in two steps: first the default TeX encoding maps the number 19 to the character name ‘acute’; then the default PostScript encoding, as found in the AFM file for an ordinary PostScript font, maps the character name ‘acute’ to the number 194. (The PostScript encoding works in reverse, by looking in the encoding vector for the name and then yielding the corresponding number.) The combined mapping of 19 to 194 shows up explicitly in the VF file and also implicitly in the fact that the properties of PostScript character 194 appear in position 19 of the TFM file for the virtual font.
The default encoding of the distributed fonts (e.g., ptmr.tfm)
mostly follows plain TeX conventions for accents. The exceptions:
the Hungarian umlaut (which is at position 0x7D in ‘cmr10’,
but position 0xCD in ‘ptmr’); the dot accent (at positions
0x5F and 0xC7, respectively); and the Scandinavian A ring
\AA, whose definition needs different tweaking. In order to use
these accents with PostScript fonts or in math mode when
\textfont0 is a PostScript font, you will need to use the
following definitions. These definitions will not work with the
Computer Modern fonts for the relevant accents. They are already part
of the distributed psfonts.sty for use with LaTeX.
\def\H#1{{\accent"CD #1}}
\def\.#1{{\accent"C7 #1}}
\def\dot{\mathaccent"70C7 }
\newdimen\aadimen
\def\AA{\leavevmode\setbox0\hbox{h}\aadimen\ht0
\advance\aadimen-1ex\setbox0\hbox{A}\rlap{\raise.67\aadimen
\hbox to \wd0{\hss\char'27\hss}}A}
As a kind of summary, here are the ‘CODINGSCHEME’s that result from the various possible choices for reencoding.
(CODINGSCHEME TeX text + AdobeStandardEncoding)
(CODINGSCHEME TeX text + DCEncoding)
(CODINGSCHEME DCEncoding + AdobeStandardEncoding)
(CODINGSCHEME DCEncoding + DCEncoding)
The ‘CODINGSCHEME’ line appears in the VPL file but is ignored by Dvips.
Previous: Reencoding with Afm2tfm, Up: Changing font encodings [Contents][Index]
Afm2tfm’s encoding files have the same format as an encoding vector in a PostScript font. Here is a skeletal example:
% Comments are ignored, unless the first word after the percent sign % is ‘LIGKERN’; see below. /MyEncoding [ % exactly 256 entries follow, each with a leading ‘/’ /Alpha /Beta /Gamma /Delta … /A /B … /Z … /.notdef /xfooaccent /yfooaccent /zfooaccent ] def
These encoding files are downloaded as part of changing the encoding at the PostScript level (see the previous section).
Comments, which start with a percent sign and continue until the end of the line, are ignored unless they start with ‘LIGKERN’ (see below).
The first non-comment word of the file must start with a forward slash
‘/’ (i.e., a PostScript literal name) and defines the name of the
encoding. The next word must be an left bracket ‘[’. Following
that must be precisely 256 character names; use ‘/.notdef’ for any
that you want to leave undefined. Then there must be a matching right
bracket ]. A final ‘def’ token is optional. All names are
case-sensitive.
Any ligature or kern information is given as a comment. If the first word after the ‘%’ is ‘LIGKERN’, then the entire rest of the line is parsed for ligature and kern information. This ligature and kern information is given in groups of words: each group is terminated by a space and a semicolon and (unless the semicolon is at the end of a line) another space.
In these LIGKERN statements, three types of information may be
specified. These three types are ligature pairs, kerns to ignore, and
the character value of this font’s boundary character.
Throughout a LIGKERN statement, the boundary character is
specified as ‘||’. To set the font’s boundary character value for
TeX:
% LIGKERN || = 39 ;
To indicate a kern to remove, give the names of the two characters (without the leading slash) separated by ‘{}’, as in ‘one {} one ;’. This is intended to be reminiscent of the way you might use ‘{}’ in a TeX file to turn off ligatures or kerns at a particular location. Either or both of the character names can be given as ‘*’, which is a wild card matching any character; thus, all kerns can be removed with ‘* {} * ;’.
To specify a ligature, specify the names of the pair of characters, followed by the ligature operation (as in Metafont), followed by the replacing character name. Either (but not both) of the first two characters can be ‘||’ to indicate a word boundary.
The most common operation is ‘=:’ meaning that both characters are
removed and replaced by the third character, but by adding the ‘|’
character on either side of the ‘=:’, you can retain either or both
of the two leading characters. In addition, by suffixing the ligature
operation with one or two ‘>’ signs, you can make the ligature
scanning operation skip that many resulting characters before
proceeding. This works just like in Metafont. For example, the ‘fi’
ligature is specified with ‘f i =: fi ;’. A more convoluted
ligature is ‘one one |=:|>> exclam ;’ which separates a pair of
adjacent 1’s with an exclamation point, and then skips over two
of the resulting characters before continuing searching for ligatures
and kerns. You cannot give more >’s than |’s in an ligature
operation, so there are a total of eight possibilities:
=: |=: |=:> =:| =:|> |=:| |=:|> |=:|>>
The default set of ligatures and kerns built in to Afm2tfm is:
% LIGKERN question quoteleft =: questiondown ;
% LIGKERN exclam quoteleft =: exclamdown ;
% LIGKERN hyphen hyphen =: endash ; endash hyphen =: emdash ;
% LIGKERN quoteleft quoteleft =: quotedblleft ;
% LIGKERN quoteright quoteright =: quotedblright ;
% LIGKERN space {} * ; * {} space ; 0 {} * ; * {} 0 ;
% LIGKERN 1 {} * ; * {} 1 ; 2 {} * ; * {} 2 ; 3 {} * ; * {} 3 ;
% LIGKERN 4 {} * ; * {} 4 ; 5 {} * ; * {} 5 ; 6 {} * ; * {} 6 ;
% LIGKERN 7 {} * ; * {} 7 ; 8 {} * ; * {} 8 ; 9 {} * ; * {} 9 ;
Next: Afm2tfm options, Previous: Changing font encodings, Up: Invoking afm2tfm [Contents][Index]
Besides the reencodings described in the previous section, Afm2tfm can do other manipulations. (Again, it’s best to use the prebuilt fonts rather than attempting to remake them.)
‘-s slant’ makes an obliqued variant, as in:
afm2tfm Times-Roman -s .167 -v ptmro rptmro
This creates ptmro.vpl and rptmro.tfm. To use this font, put the line
rptmro Times-Roman ".167 SlantFont"
into psfonts.map. Then ‘rptmro’ (our name for the obliqued
Times) will act as if it were a resident font, although it is actually
constructed from Times-Roman via the PostScript routine SlantFont
(which will slant everything 1/6 to the right, in this case).
Similarly, you can get an expanded font with
afm2tfm Times-Roman -e 1.2 -v ptmrre rptmrre
and by recording the pseudo-resident font
rptmrre Times-Roman "1.2 ExtendFont"
in psfonts.map.
You can also create a small caps font with a command such as
afm2tfm Times-Roman -V ptmrc rptmrc
This will generate a set of pseudo-small caps mapped into the usual lowercase positions and scaled down to 0.8 of the normal cap dimensions. You can also specify the scaling as something other than the default 0.8:
afm2tfm Times-Roman -c 0.7 -V ptmrc rptmrc
It is unfortunately not possible to increase the width of the small caps independently of the rest of the font. If you want a really professional looking set of small caps, you need to acquire a small caps font.
To change the PaintType in a font from filled (0) to outlined
(2), you can add "/PaintType 2 store" to psfonts.map, as
in the following:
rphvrl Helvetica "/PaintType 2 store"
Afm2tfm writes to standard output the line you need to add to psfonts.map to use that font, assuming the font is resident in the printer; if the font is not resident, you must add the ‘<filename’ command to download the font. Each identical line only needs to be specified once in the ‘psfonts.map’ file, even though many different fonts (small caps variants, or ones with different output encodings) may be based on it.
Previous: Special font effects, Up: Invoking afm2tfm [Contents][Index]
Synopsis:
afm2tfm [option]… afmfile[.afm] [tfmfile[.tfm]]
Afm2tfm reads afmfile and writes a corresponding (but “raw”, see below) TFM file. If tfmfile is not supplied, the base name of the AFM file is extended with ‘.tfm’ to get the output filename.
The simplest example:
afm2tfm Times-Roman rptmr
The TFM file thus created is raw because it omits ligature and kern information, and does no character remapping; it contains only the character information in the AFM file in TFM format, which is the form that TeX understands. The characters have the same code in the TFM file as in the AFM file. For text fonts, this means printable ASCII characters will work ok, but little else, because standard PostScript fonts have a different encoding scheme than the one that plain TeX expects (see Encodings). Although the encodings agree for most printable ASCII characters, other characters such as ligatures and accents vary. Thus, in practice, it’s almost always desirable to create a virtual font as well with the ‘-v’ or ‘-V’ option. See Making a font available.
The command line options to Afm2tfm:
By default, Afm2tfm looks for precomposed accented characters, such as
tdieresis, and possibly adjusts the height of the basic letter (t)
upward so that the result of using \accent (as in \"t)
is visually the same as the precomposed characters. The -a
option omits such adjustments, so that all characters’ heights remain
as they are given in the AFM file. (Until Afm2tfm 8.4, released in
2016, heights could also be adjusted downward, but this is no longer
the case.)
See ‘-V’; overrides the default ratio of 0.8 for the scaling of small caps.
Stretch characters horizontally by ratio; if less than 1.0, you get a condensed font.
Output all character codes in the ‘vpl’ file as octal numbers, not names; this is useful for symbol or other special-purpose fonts where character names such as ‘A’ have no meaning.
Use ps-enc for the destination (PostScript) encoding of the font; ps-enc must be mentioned as a header file for the font in ‘psfonts.map’. See Changing PostScript encodings.
Slant characters to the right by slant. If slant is negative, the letters slope to the left (or they might be upright if you start with an italic font).
Use tex-enc for the target (TeX) encoding of the font. Ligature and kern information may also be specified in file. file is not mentioned in psfonts.map.
Use ps-tex-enc for both the PostScript and target TeX encodings of the font. Equivalent to ‘-p file -t file’.
Use only those characters specified in the TeX encoding, and no others. By default, Afm2tfm tries to include all characters in the input font, even those not present in the TeX encoding (it puts them into otherwise-unused positions, arbitrarily).
Output a VPL (virtual property list) file, as well as a TFM file.
Same as ‘-v’, but the virtual font generated is a pseudo small caps font obtained by scaling uppercase letters by 0.8 to typeset lowercase. This font handles accented letters and retains proper kerning.
Previous: Invoking afm2tfm, Up: PostScript fonts [Contents][Index]
The psfonts.map file associates a PostScript font with related files and constructs. Each line has the format:
filename PostScript-name options
For example, the line
rpstrn StoneInformal <StoneInformal.pfb
causes Dvips to download StoneInformal.pfb (just as if it were
a header file, see Header files) if the DVI file (or a virtual
font, see Virtual fonts) references the TFM file ‘rpstrn’.
The PostScript /FontName of the font defined inside the ‘pfb’
file should be StoneInformal.
You can generate transformed fonts with a line like this:
rpstrc StoneInformal <StoneInformal.pfb ".8 ExtendFont"
See Special font effects, for a complete list of font effects.
You can change the encoding of the Type 1 font at the PostScript level with a ‘ReEncodeFont’ instruction, plus the name of the encoding file. This allows you access to characters that may be present in the Type 1 font file, but not encoded by default—most of the preaccented characters, for example. An example:
pstrn8r StoneInformal "TeXBase1Encoding ReEncodeFont" <8r.enc <pstrn8a.pfb
The ‘8r’ encoding mentioned here has been designed to serve as a base for all downloadable fonts; it allows access to all the characters commonly present in a Type 1 font. For more details, see the 8r.enc source file that comes with (and is installed with) Dvips.
You may notice that the same syntax is used for downloading encoding vectors and Type 1 font files. To make your intentions clear, you can also use ‘<[’ to explicitly indicate you are downloading an encoding vector, as in:
pstrn8r StoneInformal "TeXBase1Encoding ReEncodeFont" <[8r.enc <pstrn8a.pfb
If the filename of your encoding vector does not end in ‘.enc’, and you are using partial font downloading, you must use the ‘<[’ syntax, or Dvips will not download the font properly.
Similarly, the name of the Type 1 font file itself must have extension .pfa or .pfb for partial downloading to work properly.
When using PFB files, Dvips is smart enough to unpack the binary PFB format into printable ASCII so there is no need to perform this conversion yourself. In addition, Dvips scans the font to determine its memory usage, just as it does for other header files (see Header files).
If the ‘j’ config file or command-line option is enabled (as it is by default), StoneInformal.pfb will be partially downloaded—only those characters your document actually uses will be extracted and downloaded, and the remainder discarded. See Option details.
Adobe Multiple Master fonts, such as Minion, cannot be partially downloaded. To partially download in general, but avoid partial downloading for individual fonts, use ‘<<’ instead ‘<’:
pmnr8r Minion <<Minion.pfb
Here is a brief summary of how psfonts.map is read:
Next: Index, Previous: PostScript fonts, Up: Top [Contents][Index]
Dvips supports one-pass multi-color printing of TeX documents on any color PostScript device. Initially added by Jim Hafner, IBM Research, [email protected], the color support has gone through many changes by Tomas Rokicki. Besides the source code support itself, there are additional TeX macro files: ‘colordvi.tex’ and ‘blackdvi.tex’, and corresponding ‘.sty’ versions for use with LaTeX.
In this section we describe the use of color from the document preparer’s point of view and then add some instructions on installation for the TeX administrator.
| • Color macro files | TeX macro definitions. | |
| • User-definable colors | Adding your own colors. | |
| • Color subtleties | Subtleties in using color. | |
| • Ted Turner | Printing in black/white after colorizing. | |
| • Color device configuration | Configuring Dvips for color devices. | |
| • Color support details | Color support details |
Next: User-definable colors, Up: Color [Contents][Index]
All the color macro commands are defined in ‘colordvi.tex’ (or ‘colordvi.sty’). To access these macros simply add to the top of your plain TeX file the command:
\input colordvi
For (the obsolete) LaTeX 2.09, add the ‘colordvi’ style option as in:
\documentstyle[12pt,colordvi]{article}
For LaTeX2e, these examples are not applicable. Instead, please see the documentation for the graphics package (https://ctan.org/pkg/graphics), and the epslatex document (https://ctan.org/pkg/epslatex).
These macros provide two basic kinds of color macros: ones for local color changes (a few words, a single symbol) and one for global color changes (the whole document). All the color names use a mixed case scheme to avoid conflicts with other macros. There are 68 predefined colors, with names taken primarily from the Crayola crayon box of 64 colors, and one pair of macros for the user to set his own color pattern (see User-definable colors). You can browse the file ‘colordvi.tex’ for a list of the predefined colors. The comments in this file also show a rough correspondence between the crayon names and Pantones.
A local color command has the form
\ColorName{this is the color ColorName}
where ColorName is the name of a predefined color, e.g., ‘Blue’. As shown, these macros take one argument, the text to print in the specified color. This can be used for nested color changes since it restores the original color state when it completes. For example:
This text is normal but here we are \Red{switching to red,
\Blue{nesting blue}, recovering the red} and back to original.
The color nesting level has no hard limit, but it is not advisable to nest too deeply lest you and the reader lose track of the color history.
The global color command has the form
\textColorName
These macros take no arguments and changes the default color from that point on to ColorName. This of course can be overridden globally by another such command or locally by local color commands. For example, expanding on the example above, we might have
\textGreen
This text is green but here we are \Red{switching to red,
\Blue{nesting blue}, recovering the red} and back to
original green.
\textCyan
The text from here on will be cyan until
\Yellow{locally changed to yellow}. Now we are back to cyan.
The color commands will even work in math mode and across math mode
boundaries. This means that if you have a color before going into math
mode, the mathematics will be set in that color as well. In alignment
environments like \halign, ‘tabular’ or ‘eqnarray’,
local color commands cannot extend beyond the alignment characters.
Because local color commands respect only some environment and delimiter changes besides their own, care must be taken in setting their scope. It is best not to have them stretch too far.
At the present time there are no macros for color environments in LaTeX which might have a larger range. This is primarily to keep the TeX and LaTeX use compatible.
Next: Color subtleties, Previous: Color macro files, Up: Color [Contents][Index]
There are two ways for the user to specify colors not already defined.
For local changes, there is the command \Color which takes two
arguments. The first argument is four numbers between zero and one and
specifies the intensity of cyan, magenta, yellow and black (CMYK) in
that order. The second argument is the text that should appear in the
given color. For example, suppose you want the words “this color is
pretty” to appear in a color which is 50% cyan, 85% magenta, 40% yellow
and 20% black. You would use the command
\Color{.5 .85 .4 .2}{this color is pretty}
For global color changes, there is a command \textColor which
takes one argument, the CMYK quadruple of relative color intensities.
For example, if you want the default color to be as above, then the
command
\textColor{.5 .85 .4 .2}
The text from now on will be this pretty color
will do the trick.
Making a global color change in the midst of nested local colors is highly discouraged. Consequently, Dvips will give you warning message and do its best to recover by discarding the current color history.
Next: Ted Turner, Previous: User-definable colors, Up: Color [Contents][Index]
Color macros are defined via \special keywords. As such, they
are put in the ‘.dvi’ file only as explicit message strings to the
driver. The (unpleasant) result is that certain unprotected regions of
the text can have unwanted color side effects. For example, if a color
region is split by TeX across a page boundary, then the footers of
the current page (e.g., the page number) and the headers of the next
page can inherit that color. To avoid this effect globally, users
should make sure that these special regions of the text are defined with
their own local color commands. For example, to protect the
header and footer in plain TeX, use
\headline{\Black{My Header}}
\footline{\Black{\hss\tenrm\folio\hss}}
This warning also applies to figures and other insertions, so be careful!
Of course, in LaTeX, this is much more difficult to do because of the complexity of the macros that control these regions. This is unfortunate but inevitable, because TeX and LaTeX were not written with color in mind.
Even when writing your own macros, much care must be taken. The macros
that ‘colorize’ a portion of the text work prefix the text work by
outputting one \special command to turn the color on before the
text, and outputting another \special command afterwards to
restore the original color. It is often useful to ensure that TeX is
in horizontal mode before the first special command is issued; this can
be done by prefixing the color command with \leavevmode.
Next: Color device configuration, Previous: Color subtleties, Up: Color [Contents][Index]
If you have a TeX or LaTeX document written with color macros and you want to print it in black and white there are two options. On all (good) PostScript devices, printing a color file will print in corresponding gray levels. This is useful to get a rough idea of the colors without using expensive color printing devices. The second option is to replace the call to input colordvi.tex with ‘blackdvi.tex’ (and similarly for the ‘.sty’ files). So in the above example, replacing the word ‘colordvi’ with ‘blackdvi’ suffices. blackdvi.tex defines the color macros as no-ops, and so will produce normal black/white printing. By this simple mechanism, the user can switch to all black/white printing without having to ferret out the color commands. Also, some device drivers, particularly non-PostScript ones like screen previewers, will simply ignore the color commands and so print in black/white. Hopefully, in the future screen previewers for color displays will be compatible with some form of color support.
Next: Color support details, Previous: Ted Turner, Up: Color [Contents][Index]
To configure Dvips for a particular color device you need to fine tune the color parameters to match your device’s color rendition. To do this, you will need a Pantone chart for your device. The header file ‘color.lpro’ shows a (rough) correspondence between the Crayola crayon names and the Pantone numbers and also defines default CMYK values for each of the colors. Note that these colors must be defined in CMYK terms and not RGB, as Dvips outputs PostScript color commands in CMYK. This header file also defines (if they are not known to the interpreter) the PostScript commands ‘setcmykcolor’ and ‘currentcmykcolor’ in terms of a RGB equivalent so if your device only understands RGB, there should be no problem.
The parameters set in this file were determined by comparing the Pantone chart of a Tektronix Phaser printer with the actual Crayola Crayons. Because these were defined for a particular device, the actual color rendition on your device may be very different. There are two ways to adjust this. One is to use the PAntone chart for your device to rewrite ‘color.lpro’ prior to compilation and installation. A better alternative, which supports multiple devices, is to add a header file option in the configuration file (see Configuration file commands) for each device that defines, in ‘userdict’, the color parameters for those colors that need redefining.
For example, if you need to change the parameters defining ‘Goldenrod’ (approximately Pantone 109 on the Phaser) for your device ‘mycolordev’, do the following. In the Pantone chart for your device, find the CMYK values for Pantone 109. Let’s say they are ‘{\ 0 0.10 0.75 0.03 }’. Then create a header file named ‘mycolordev.pro’ with the commands
userdict begin
/Goldenrod { 0 0.10 0.75 0.03 setcmykcolor} bind def
Finally, in ‘config.mycolordev’ add the line
h mycolordev.pro
This will then define ‘Goldenrod’ in your device’s CMYK values in userdict which is checked before defining it in TeXdict by color.pro. (On MS-DOS, you will have to call this file mycolordev.cfg.)
This mechanism, together with additions to colordvi.tex and blackdvi.tex (and the ‘.sty’ files), can also be used to predefine other colors for your users.
Previous: Color device configuration, Up: Color [Contents][Index]
To support color, Dvips recognizes a certain set of specials. These specials start with the keyword ‘color’ or the keyword ‘background’, followed by a color specification.
| • Color specifications | ||
| • Color specials |
Next: Color specials, Up: Color support details [Contents][Index]
What is a color specification? One of three things. First, it might be a PostScript procedure as defined in a PostScript header file. The color.pro file defines 64 of these, including ‘Maroon’. This PostScript procedure must set the current color to be some value; in this case, ‘Maroon’ is defined as ‘0 0.87 0.68 0.32 setcmykcolor’.
The second possibility is the name of a color model (initially, one of ‘rgb’, ‘hsb’, ‘cmyk’, or ‘gray’) followed by the appropriate number of parameters. When Dvips encounters such a macro, it sends out the parameters first, followed by the string created by prefixing ‘TeXcolor’ to the color model. Thus, the color specification ‘rgb 0.3 0.4 0.5’ would generate the PostScript code ‘0.3 0.4 0.5 TeXrgbcolor’. Note that the case of zero arguments is disallowed, as that is handled by the single keyword case (‘Maroon’) above, where no changes to the name are made before it is sent to the PostScript file.
The third and final type of color specification is a double quote followed by any sequence of PostScript. The double quote is stripped from the output. For instance, the color specification ‘"AggiePattern setpattern’ will set the ‘color’ to the Aggie logo pattern (assuming such exists.)
Previous: Color specifications, Up: Color support details [Contents][Index]
We will describe ‘background’ first, since it is the simplest. The ‘background’ keyword must be followed by a color specification. That color specification is used as a fill color for the background. The last ‘background’ special on a page is the one that gets issued, and it gets issued at the very beginning of the page, before any text or specials are sent. (This is possible because the prescan phase of Dvips notices all of the color specials so that the appropriate information can be written out during the second phase.)
The ‘color’ special itself has three forms. The first is just ‘color’ followed by a color specification. In this case, the current global color is set to that color; the color stack must be empty when such a command is executed.
The second form is ‘color push’ followed by a color specification. This saves the current color on the color stack and sets the color to be that given by the color specification. This is the most common way to set a color.
The final version of the ‘color’ special is just ‘color pop’, with no color specification; this says to pop the color last pushed on the color stack from the color stack and set the current color to be that color.
Dvips correctly handles these color specials across pages, even when the pages are repeated or reversed.
These color specials can be used for things such as patterns or screens as well as simple colors. However, note that in the PostScript, only one color specification can be active at a time. For instance, at the beginning of a page, only the bottommost entry on the color stack is sent; also, when a color is popped, all that is done is that the color specification from the previous stack entry is sent. No ‘gsave’ or ‘grestore’ is used. This means that you cannot easily mix usage of the ‘color’ specials for screens and colors, just one or the other. This may be addressed in the future by adding support for different categories of color-like state.
| Jump to: | !
"
%
(
+
-
.
/
6
8
<
=
@
\
|
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
|---|
| Jump to: | !
"
%
(
+
-
.
/
6
8
<
=
@
\
|
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z |
|---|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.032 ]-- |