[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Groff algorithm
From: |
M Douglas McIlroy |
Subject: |
Groff algorithm |
Date: |
Tue, 12 Jan 2021 15:23:16 -0500 |
> I wonder how I can format a nice algorithm in the usual sense in groff.
> I want to write pseudocode...\
It all depends on what you mean by "nice". If it's just a properly indented
listing, most of the standard macro packages have adequate support.
For example, in the -ms package (man 7 groff_ms) bracket the code with
.DS and .DE and use .ta to set tabs. However,. groff will not serve as a
pretty-printer and decide how code should be indented.
It's customary also to use a constant-width font for programs: .ft CW. But
you
may not want to do so for pseudocode.
If you want syntax highlighting, e.g. bold keywords of (heaven forfend)
syntax
colorization. it will be painful, but straightforward: use \f and \m
escapes to
change font and color.
Doug