Troff in Technicolor

Someone asked on 9fans today how one goes about getting coloured troff graph/charts/&c. Sape Mullender graciously provided how he does this.

From: Sape Mullender sape@pla... Subject: where to get color troff? Date: Tue, 12 Apr 2011 09:33:47 +0200

I use these macros for generating color:

.de CL
\\X'PS \\$1 \\$2 \\$3 setrgbcolor'\\c
..
.de BK
\\X'PS 0 0 0 setrgbcolor'\\c
..
.de EM
\\$3\\X'PS 1 0 0 setrgbcolor'\\$1\\X'PS 0 0 0 setrgbcolor'\\$2
..

They only work if you generate postscript (you can, of course, turn that into pdf as well).

.CL r g b

sets the color to the rgb values (0 0 0 being black, 1 1 1 being white,

0.5 0.5 0.5 being middle grey)
.BK

sets the color to black.

.EM "string1" "string2" "string3"

(emphasis), where strings 2 and 3 are optional prints string3 in the current color, followed by string1 in red and string2 in black (with no space between strings 3, 1 and 2 — they work as .B or .I in the .ms macro package.

Sape

9fans post


To post a comment you need to login first.