groff

Top Page
Attachments:
Message as email
+ (text/plain)
+ groff_hello.pdf (application/pdf)
+ (text/plain)
Delete this message
Reply to this message
Author: Steve Litt via PLUG-discuss
Date:  
To: plug-discuss
CC: Steve Litt, golugtech
Subject: groff
Hi all,

At last night's Stammtisch, via Big Blue Button, we had a short
discussion of groff (the GNU version of roff, one of the early
typesetting languages). The discussion was led by a very
knowledgeable woman whose name began with V (I don't remember her
name). I'll refer to her as V from now on. Based on what V said, several
of us made "Hello World" type groff documents, and I'm posting mine
here. The actual document input file, groff_hello.in, follows:

==============================================
.ps +5
This is the
beginning
.br
of the thing
.EQ
x sup 2 + 1
.EN
This is almost the end
.PP
This is the end.
==============================================

The PDF output of the preceding Hello World groff input file is
attached to this email. The compilation script for this file follows:

==============================================
#!/bin/sh
rm groff_hello.ps
rm groff_hello.pdf
eqn < groff_hello.in | groff -ms > groff_hello.ps
ps2pdf groff_hello.ps
mupdf groff_hello.pdf
==============================================

If you want to do your own research and experimentation, I suggest you
start by copying my input file and shellscript verbatim (copy and
paste) so you start out with something that works to some degree, and
then start changing things one at a time to better understand how groff
works.

In the preceding, "mupdf" is the name of the PDF reader I use.
Substitute the PDF reader you use. The "eqn" program is a preprocessor
that turns math expressions (like "x sup 2 + 1" which means x squared
plus one) into groff compatible syntax.

In the input file, the first line, ".ps +5" increases the font size.
The ".br" is a linefeed, the same as "<br/>" in HTML or "\n" in C. The
".EQ" begins math mode so a mathematical expression can be formatted
correctly, and the ".EN" ends math mode. The ".PP" starts a new
paragraph, like "<p>" in HTML.

Commands start with either a dot or an ascii single quote, and must
begin a line.

My two hours of research and experimentation tell me that my ".ps +5"
applies only to the current paragraph, so if I wanted to have every
paragraph magnified I'd need to begin every paragraph with lines ".PP"
followed by ".ps +5", which is a hassle if you're looking for a fast
authoring environment.

As far as a comparison of groff to Plain TeX, which was what initiated
the groff discussion, my 2 hours of research and experimentation on
groff tells me that Plain TeX is better for writing long documents,
such as books, than groff, because less typing and less interruption of
writing flow is involved with Plain TeX, especially use of a blank line
instead of a line with .PP to start a new paragraph. Plus the seeming
requirement to repeat all appearance-changing lines such as ".ps +5" in
every new paragraph to maintain the appearance you want.

Additionally, as far as I know, groff has no built-in provision for
paragraph and character styles the way Plain TeX does. I assume you can
build your own styles with groff macros, but haven't confirmed that
yet. An authoring format without styles is worthless for long books.

Nevertheless, there's something elegant in groff's simplicity. It
doesn't take long to learn its rudimentaries especially when starting
with my Hello World.

SteveT

Steve Litt
Autumn 2022 featured book: Thriving in Tough Times
http://www.troubleshooters.com/bookstore/thrive.htm
---------------------------------------------------
PLUG-discuss mailing list:
To subscribe, unsubscribe, or to change your mail settings:
https://lists.phxlinux.org/mailman/listinfo/plug-discuss