[tex-k] dvitomp update: support \Black, \Red, and similar colordvi commands

Hartmut Henkel hartmut_henkel at gmx.de
Sat Aug 28 00:31:47 CEST 2004

Hi Eddie,

by accident I stumbled over your patch (in the teTeX-beta-2.96.7
distribution), which provides a colorstack to dvitomp. It's a funny and
quite useful feature. Just to re-iterate, one can say "btex
\special{color push Lavender}Hello\special{color pop} etex" and gets a
colored text, since dvitomp writes out an .mpx file containing
"withcolor R G B" strings. It's also compatible with colordvi.sty.

While checking what your patch does (seems one needs to read the source
code to understand what's going on, as I couldn't find other
documentation), it appears that you have hardcoded 67 RGB colors into
the source code of dvitomp, like:

> def_named_color('Cerulean', 0.0600122, 0.889988, 1.0);

IMHO special things like colors with RGB values should be under user
control (e. g. if one wants to extend the color list), and are misplaced
in program sourcecode. They should instead end up in some separate
driver or data file (as done by dvips). Also I could not find a way how
one could extend the set of colors in dvitomp other than adding to the
source and recompiling. In particular, it seems not to be possible to
define a new color in metapost so that it gets accessible within
btex...etex, vice versa.

The whole mechanism seems to be built to be compatible with the ancient
LaTeX 2.09 file colordvi.sty. Which is IMHO fixating an obsolete thing
(if this colordvi.sty is senseful for nowadays applications, it should
be updated to the newest LaTeX version, e. g. namespace reserved for
these specials).

While playing with dvitomp, I found that your color stack seems to work
equally well, if the colors are handled only by name and not by their
RGB values. The conversion between names and RGB values seems not needed
in dvitomp as it can be left to metapost. E. g. you could define a color
in the metapost source, then access this color in a btex...etex section,
and finally metapost replaces the name given to it by dvitomp with the
RGB value. Then I tried a raw patch, where I threw out any dependency on
color names and RGB values from dvitomp. You find a dvitomp.ch version
compatible with the current teTeX-beta-2.96.7 dvitomp.ch file at


and a test file:


The patch allows to define any RGB color in metapost, and these are then
accessible in the btex...etex sections by your \special{color push NAME}
mechanism. It's still compatible with colordvi.sty, you only need to
define the colors (e. g. "Red = red;") in metapost to make them
accessible. BTW the source code actually got a lot simpler, as any R G B
stack operations vanished. And the color list has gone. The changes were
more or less just throwing things out.

Hope you like the modification to your patch. What do you think?

Best Regards


On Sun, 22 Feb 2004, Eddie Kohler wrote:

> Attached is an update to dvitomp that I find extremely useful for
> colored metapost diagrams.  It supports colored text in "btex .. etex"
> blocks, by parsing the "color" specials generated by the colordvi
> package...

More information about the tex-k mailing list