Hi Erik, At 2026-08-16T07:21:22+0000, dvalin--- via discussion of the GNU roff typesetting system and related software wrote: > It's not proving as easy as the manual would have it. I've spent > several hours over recent evenings trying to discover how to move page > numbers from the header default to alternating footers, using -ms. In > my hands, both .OF and .EF fail to produce any output, and .OH & .EH > fix \n% at 1 for all pages, when given the attached test input.
Right. You're making the same basic mistake repeatedly.
You need _two_ backslashes before `n%`, because you don't want the page
number register to be interpolated at the time you _call_ these macros,
but later, when the package internals interpolate their contents.
Because ms uses the OH/EH/OF/EH macros and the LH/CH/RH/LF/CF/RF strings
as interfaces to the `tl` request, you can use the latter's bespoke
notation for the page number, and use `%` as a placeholder thereof. The
groff ms manual, attached, notes this (p. 20).
Here's how groff's ms.ms document configures its titles.
$ sed -n 47,62p build/doc/ms.ms
.ds header-title Using \f[I]groff\f[] with the \f[I]ms\f[] macros\"
.ds date July 2026\"
.ND \*[date]
.ds CH \" empty
.ie t \{\
. nr PI 3.5n
. EH '%''\*[date]'
. OH '\*[header-title]''%'
.\}
.el \{\
. nr PI 4n
. ds LH \*[date]\"
. ds CH \*[header-title]\"
. ds RH \\n[%]\"
.\}
.ds CF groff 1.25.0.rc2.35-6cba2-modified\"
I'll annotate your input.
.LP \" Some initialisation up front. No
observable effect.
You don't need that before configuring the titles, and it will work
against you if you want control of the header on the first page.
\".ds CH " " \" Can clobber -ms page numbering default,
but prints a '"'.
What you want there is to define the `CH` string as empty, as ms.ms
does.
.OF ’ ’Pno test’\n%’ \" ### These two lines produce no output,
.EF ’\n%’Pno test’ ’ \" ### with or without .OH &.EH also present.
.OH ’ ’Pno test’\n%’ \" ### These two lines print "Pno test 1",
.EH ’\n%’Pno test’ ’ \" ### on pages 2 & 3. That's not page
numbering.
1. Your delimiters are showing up as characters with high code points.
Until GNU troff has support for intake of UTF-8 directly,[1] I would
use only printable "ASCII" (ISO Basic Latin) characters for such
delimiters.
2. But even were the delimiter changed to `'`, you're interpolating
`\n%` immediately because it is not escaped. That means you're
locking in the numeral `1` into all these titles.
\".ds CF - \n% - \" Heck, this also does nothing.
Does nothing (when uncommented)? Again, you're interpolating `\n%`
immediately at the time you're defining the `CF` string, so its contents
are locked in as `- 1 -`.
You can add `tm` requests to debug your document. The output will go to
the standard error stream.
.tm CF=\*(CF
.LP
Let's see if -ms can number pages in the header or footer, using .OF &
.EF
or .OH & .EH.
.bp
.LP
How hard can it be? After all, it's described in the manual, innit?
.bp
.LP
Oh-oh, not off-by-one, but off-by-n. Fruit-loops!
:!groff -Tpdf -dpaper=a5 -P-pa5 -P-l -ms
/home/erik/misc/typsetting/src/test2.ms > /tmp/groff_test2.pdf
> These results are on: GNU groff version 1.22.4
groff's ms manual has seen extensive revision since then. I'm attaching
a copy that corresponds to Git HEAD. You'll need to disregard the fancy
stuff in red about PDF features--they are forthcoming in groff 1.25.0.
But the rest should be highly applicable.
> as 1.23.0 on the new devuan install gives:
> groff: fatal error: cannot load 'DESC' description file for device
> 'pdf' (That's something else I'll have to figure out along the way.)
I expect the distributor split off parts of groff into another package.
I think Devuan is Debian-based, so make sure you have both the
"groff-base" and "groff" packages installed. Though Debian has patched
its GNU troff to help steer you to the "groff" package when emitting the
foregoing error diagnostic, so maybe Devuan has gone its own way here.
> I'll attach the pdf, as it might squeak through at 7564 bytes.
You could get away with a document up to 100 times larger![2] ;-)
> Any hints on how to hold my mouth right would hopefully reduce the
> number of hair tufts needing to be vacuumed up off the carpet here.
Please let me know if and how the attached document could be improved to
aid you.
Regards,
Branden
[1] https://savannah.gnu.org/bugs/?40720
[2] https://lists.gnu.org/archive/html/groff/2026-07/msg00099.html
ms.pdf
Description: Adobe PDF document
signature.asc
Description: PGP signature
