Nested lists in man page

manroff

I have a command line parameter that takes a number of flags afterwards, which I would like to have as a list inside the parameter list in the man page.

Currently I am simply making lines of Flag - Description (man page), but this is not ideal for the following reasons:

  • Doesn't indent wrapped lines. I can manually indent them but then I have to assume a set console width, which I don't want to do
  • Have to rely on double newlines to go to the next line, I'd rather have something like .TP.

Best Answer

  • Start the list with .RS, end with .RE.
  • Start list items with .IP followed by term. Enclose the term in double quotes if contains multiple words.
  • Put the description text in the next line after the list item start.
  • Is nestable, so the description may contain further lists.
  • Use \fB..\fP for bolding the term instead of .B. (Same for underline – use \fI..\fP instead of .I.)
.RS
.IP \fBA\fP
\- Flag 1
.IP \fBB\fP
\- Flag 2
.IP \fBC\fP
\- A slightly longer flag description that could take up more than the width
of the average console. In fact you'd need a very wide console to read all
this.
.RE

To increase your productivity I suggest to write your man pages in a friendlier format then convert them. Some suitable tools are enumerated in Can I create a man page for a script?.

Related Question