Let's say I am trying to write a macro in groff in order to draw a rectangle given some arguments (like width and height for example). For this I need to perform some simple arithmetic, that I would like to store in registers for readability.
How to reproduce
In any normal groff document I can just use:
.nr a 1 \"creates a number register with the name a and the value 1 \n[a] \"prints the content of register a
1 on the document
However when I place it in a macro
MACRO and call it like so:
.de MACRO \"defines a new macro with name MACRO .nr a 1 \"creates a number register with the name a and the value 1 \n[a] \"prints the content of register a .. \"end of MACRO definition .MACRO \"calls MACRO
0, which is the default value for new registers, according to the documentation (
man 7 groff, and
How it is compiled
I compile it using this script:
groff -kep "$file" -Tpdf > "$file.pdf"
What am I doing wrong? Is it even possible to use registers inside of a macro? How should I do it?