groff: Auto-increment
5.8.3 Auto-increment
--------------------
Registers can also be incremented or decremented by a configured amount
at the time they are interpolated. The value of the increment is
specified with a third argument to the 'nr' request, and a special
interpolation syntax is used to alter and then retrieve the register's
Auto-increment-Footnote-1::)
-- Request: .nr ident value incr
Set register IDENT to VALUE and its auto-incrementation amount to
to INCR. The '\R' escape sequence doesn't support an INCR
argument.
Auto-incrementation is not _completely_ automatic; the '\n' escape
sequence in its basic form never alters the value of a register. To
apply auto-incrementation to a register, interpolate it with '\ną'.
-- Escape sequence: \n+i
-- Escape sequence: \n-i
-- Escape sequence: \n+(id
-- Escape sequence: \n-(id
-- Escape sequence: \n+[ident]
-- Escape sequence: \n-[ident]
Increment or decrement IDENT (one-character name I, two-character
name ID) by the register's auto-incrementation value and then
interpolate the new register value. If IDENT has no
auto-incrementation value, interpolate as with '\n'.
.nr a 0 1
.nr xx 0 5
.nr foo 0 -2
\n+a, \n+a, \n+a, \n+a, \n+a
.br
\n-(xx, \n-(xx, \n-(xx, \n-(xx, \n-(xx
.br
\n+[foo], \n+[foo], \n+[foo], \n+[foo], \n+[foo]
=> 1, 2, 3, 4, 5
=> -5, -10, -15, -20, -25
=> -2, -4, -6, -8, -10
To change the increment value without changing the value of a
register, assign the register's value to itself by interpolating it, and
specify the desired increment normally. Apply an increment of '0' to
disable auto-incrementation of the register.