RE: roff / tex comparison (was Re: OT: Rant)
On 17-Jan-02 dman wrote:
> On Wed, Jan 16, 2002 at 07:25:32PM +0000, Ted Harding wrote:
>
>| I'd like to suggest giving 'groff' a try.
>
>| I reckon it's well up with TeX, and better in some respects.
>
>
> Can you provide a list of the tradeoffs between [gnt]roff and (La)TeX?
>
> I've started with LaTeX; read lshort and now have Lamport's book.
> I've barely seen some snippets of roff source. A prof. I have now
> (Ken Reek) used a roff clone to typeset all of his handouts. They
> look nice too.
>
> I'm interested in knowing the differences and tradeoffs between the
> two systems, and how easy/quick is learning roff?
The comparison could be very lengthy! Both systems involve a
biggish learning phase to become really proficient, though
both are fairly simple (and I reckon groff is simpler) for
elementary use.
Both use the "markup" principle, of course, i.e. in-line
tags which specify formatting requests. In my view,
this is terser and less distracting in troff than in TeX,
and I reckon that working with troff is quicker and
simpler that with TeX.
The main difference in approach to formatting between TeX
and groff is that TeX "buffers" more input before deciding
precisely how to format it: for instance, TeX's line-breaks
and hyphenations are computed in terms of a criterion calculated
for a whole paragraph, and also there is a degree of vertical
justification functionality for a whole page; all this is based
on the "glue" concept. On the other hand, troff's lookahead is
basically only one character, and it really only buffers one
word. This can lead to TeX auto-generating a more pleasing
layout than troff auto-generates; though this difference is
rarely evident, in my experience, and in any case it is always
possible to tweak the layout by hand in troff, once the content
is in its final form. In my experience, you hardly ever regret
using troff rather than TeX for such reasons.
TeX also comes with a much bigger default repertoire of
symbols and such than troff does, but again you can install
TeX fonts in groff, so this difference can be eliminated.
I don't have enough experience of using TeX to give a fair
comparison in terms of capabilities and ease of use, but
I can certainly do what I want in groff (and I sometimes
want very extreme things); and whereas it may be possible
to achieve the same in TeX it is my (limited) experience
that it is much harder to do something non-standard.
This is (at least in part) due to the fact that in troff
you are working "closer to the floor" -- rather similar
to the way "Reveal Codes" in WP gives you access to the
base-level formatting. Sophisticated formatting (paragraphs,
footnotes, ... ) in troff depends on macros. There is
a variety of macro packs available, corresponding to different
styles.
However, the concept of "style" in groff is less central than
in TeX. It is certainly quite easy, when you know what you are
doing, to modify macros to achieve minor changes. For many
purposes, it is not too hard -- when you _really_ know what
you are doing -- to write your own macros according to the
"style" you want to achieve.
One comparison srikes everyone who has used both (and it
is not a criticism of the capabilities of either, though
very important to users): The wide adoption of TeX, initially
by the academic community and later outside, led to the
production of a vast amount of documentation, including
many books, on using TeX and its variants (LaTeX etc.);
and much of this documentation is excellent. Troff/groff,
on the other hand, is very patchily documented, and simply
for this reason can be harder to learn and to use effectively.
Also, TeX is TeX (and LaTeX is LaTeX etc). On the other
hand, during the period (1980s-1990s) when UNIX was being
split into a variety of variously incompatible versions
(usually by commercial developers), this increasing
diversity also took troff with it so that, again, there
are various incompatible versions of "UNIX troff" out there.
GNU groff has attempted to re-unify the situation (while
keeping a "compatibility mode" for those who want to use
it in the same way as they use "UNIX troff" -- though what
the latter precisely means is debatable).
I think the above are the main "strategic" comparisons.
Once one gets down to detail, the list would become enormous
and in any case I don't know enough about TeX to go into
the detail I could go into for groff.
Until a few years ago, I would have said that groff
table-formatting capabilities were better than TeX's;
I believe that TeX has now caught up.
Highly sophisticated line-drawing capabilities have
long meant that groff's diagrammatic capabilities
have been excellent, and they certainly used to be
better than TeX's. I can't answer for an up-to-date
comparison.
Groff also has an "equation editor" (quite similar
to WP's which I suspect was based on troff's). Here
I think TeX does a marginally better job, not only
because of having more symbols etc (but see above)
but also in terms of readily-achievable layout (though
again the troff user can always enhance what troff
can achieve).
Things like tables, equations and diagrams are achieved
by "preprocessor" programs which take the user's typed
descriptions of what he wants, and convert these into
raw troff code which is then passed to the main troff
engine. TeX, as far as I know, handles such things
in an integrated way. One detail is useful: the
"pic" preprocessor, for diagrams, includes a powerful
numerical programming capability; you can exploit this
for in-line mathematical computations needed for the
document. (For example, you can have an independent
file of (x,y) referred to simply by name in your troff
file. Then troff can reads this in at the appropriate
point of fornmatting the document, and get "pic" to:
compute a linear regression and analysis of variance
on the data; draw a labelled graph with the fitted
line; and plant troff code which formats into the
analysis of variance table in the document. If the
data changes, all you need to do is change the data
file; you don't need to touch the troff file itself.
I'm not aware that TeX can do this sort of thing at all.)
It is also straightforward to "program" troff (i.e.
to write macros) which can take output from a database
and format this into tables etc. I don't know how
easy it is to do this with TeX.
A lot of the more "unusual" things you can do with
troff depend on using UNIX filters such as "sed",
"awk", "perl" or the many file utilities. For instance,
it is easy to write an "awk" script which converts
a CSV file exported from Excel into valid troff
which formats into a printout of the spreadsheet.
And I have written "awk" programs which convert
basic troff (including "International" characters,
font changes, etc.) into valid WordPerfect files.
I'm not sure I could do this for TeX...
Clearly I could go on. I'm sorry I'm not fluent
enough with TeX to go into it in depth on that side.
Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 167 1972
Date: 17-Jan-02 Time: 10:02:00
------------------------------ XFMail ------------------------------
Reply to: