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?
Asked
Active
Viewed 87 times
0

U. Windl
- 3,480
- 26
- 54
1 Answers
0
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

evil otto
- 10,348
- 25
- 38
-
The solution looks simple, but doesn't seem to work: I don't get the `very` in output. – U. Windl Sep 29 '17 at 06:26
-
The second one works, but still this is not the solution for my question. – U. Windl Sep 29 '17 at 06:32
-
I tested this and it worked for me using either `man` or `gnroff -man` on a linux box. What's your environment? It's possible that the version of man you have doesn't support defining macros like this, tho that seems unlikely. Do you have a fuller example of what's not working for you? – evil otto Nov 03 '17 at 23:52
-
I'm using openSUSE 42.2 with `groff-1.22.2-8.17.x86_64`. The text output is `Text text text The usage example is important more text more text`. – U. Windl Nov 08 '17 at 08:54