groff (GNU troff)

As these guides are created for groff, I cannot guarantee that they are applicable to troff. If you use troff and can confirm them to work for it – please let me know.

Apart from groff, these guides may include other programs used together with groff, such as eqn, tbl, and so on. I will try to make this clear in the description of each guide.

Collection of papers on troff and its companions

Following is a collection based on troff.org/papers. However, I found that much of the links referenced from that site are dead. I have instead downloaded and compiled pdfs from archive.org. Much of the material available was written at Bell Labs. The CSTR documents below refer to ’Computer Science Technical Reports’, a Bell Labs internal numbering system used in the past.

troff

macro packages

eqn

pic

refer

tbl

indexing

Crossing out expressions in eqn

In the man page of eqn you can read about defining a macro for canceling an expression. This macro draws a line over the expression, as an indication it’s canceled. When using paper and pen I usually use a cross instead, so this is how you do the same in eqn.

.\" define cancel_cross macro for expressions 
.defcolor cancelcolor rgb 0.0f 0.0f 0.0f 
.EQ } 
define cancel_cross ’special Cax’ 
.EN 
.de Cax 
.  ds 0s \ 
\Z’\\*(0s’\ 
\Z’\D’t 0.75p’’\ 
\m[cancelcolor]\ 
\v’\\n(0du’\ 
\D’l \\n(0wu -\\n(0hu-\\n(0du’\ 
\h’-\\n(0wu’\ 
\D’l \\n(0wu \\n(0hu+\\n(0du’\ 
\v’-\\n(0hu-\\n(0du’\ 
\Z’\D’t 0.5p’’\ 
\m[default]\ 
\v’\\n(0hu’ 
.. 

Then use it for example like this: { 4 times 1 } over { 4 times 5 } = { cancel_cross 4 times 1 } over { cancel_cross 4 times 5 }.

You can of course name your macro cancel instead of cancel_cross. The cancelcolor is also optional, and in the case above redundant.

Simplify expressions in eqn

When writing eqn expressions in groff it’s easier to distinguish what is groff and what is eqn using distinct delimiters for eqn. This is simply accomplished this way:

.EQ 
delim ## 
.EN 

Then use it like this:

[...] 
.LP 
Calculate the sum of #-4# and #-7# 
.sp 1 
.RS 
# (-4) + (-7) # 
 
# = -4 - 7 # 
 
# = -11 
.RE 
[...]