How can I reuse a text portion with commands in nroff?

119 Views Asked by At

When writing a UNIX manual page, I realized that some phrase occurs multiple times. I'd like to define it once and reuse it (not by copying with the editor). I see that I can use variables (.ds) for multi-line text, but it fails when the phrase includes dot commands (like .B foo). Is there a solution (other than include files and the C preprocessor) for this?

1

There are 1 best solutions below

4
On

You could make your multi-line text into a macro. The downside is that to insert it you must invoke the macro rather than interpolating the string.

.de Us
The usage example is
.B very
important
..

Text text text
.Us
more text more text

If you just need bolding inside your strings, you can include font changes:

.ds Us You can use \fB bold \fR text in your strings \
and it will work fine

text text \*(Us