[net.sources] Neat little alias & technique to facilite troff

peters@cubsvax.UUCP (Peter S. Shenkin) (01/14/87)

How many times have you gotten confused when troff-ing a file, forgetting
whether "eqn" or "tbl" need be invoked, or which macro package should be used?
Here's a neat little alias and technique which help me greatly.

First I put this alias in my .login:
	alias roff 'sed -e 1s/\.\.// -e 1s/@/!*/ -e 2,\$d !* | sh &'

Then I begin each troff source file with a line like:
	..eqn @ | ltroff -me

The initial .. introduces a troff comment, so that the line is 
transparent to troff.  The rest of the line is the command to
troff the file, just as you would type it at your terminal, except that
the @-sign goes where the file name would go.  ("ltroff" is our local
shell-script to troff & send the output to the LaserWriter.)

The alias uses sed to strip the leading ".." off the first line,
substitute the @ with the file-name, delete the rest of the lines in
the file, and pass the resulting command to /bin/sh for execution.

The advantage to this over, say, a Makefile approach is that if the
file is copied to another one with another name, all the necessary info
goes with it.  (Of course, this can be used in conjunction with "make"
if there are real inter-file dependencies in a large document.)
Guess it's no good for multiple files, though, as in "troff f1 f2 ...."

To typeset a document, simply say:
	roff fname

Enjoy!

Peter S. Shenkin	 Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters		cubsvax!peters@columbia.ARPA