manpagez: man pages & more
info groff
Home | html | info | man

File: groff.info,  Node: Lists in ms,  Next: Indented regions in ms,  Prev: Typeface and decoration,  Up: ms Body Text

4.6.5.6 Lists
.............

The MARKER argument to the 'IP' macro can be employed to present a
variety of lists; for instance, you can use a bullet glyph ('\[bu]') for
unordered lists, a number (or auto-incrementing register) for numbered
lists, or a word or phrase for glossary-style or definition lists.  If
you set the paragraph indentation register 'PI' before calling 'IP', you
can later reorder the items in the list without having to ensure that a
WIDTH argument remains affixed to the first call.

   The following is an example of a bulleted list.

     .nr PI 2n
     A bulleted list:
     .IP \[bu]
     lawyers
     .IP \[bu]
     guns
     .IP \[bu]
     money

     A bulleted list:

     * lawyers

     * guns

     * money

   The following is an example of a numbered list.

     .nr step 0 1
     .nr PI 3n
     A numbered list:
     .IP \n+[step]
     lawyers
     .IP \n+[step]
     guns
     .IP \n+[step]
     money

     A numbered list:

     1. lawyers

     2. guns

     3. money

   Here we have employed the 'nr' request to create a register of our
own, 'step'.  We initialized it to zero and assigned it an
auto-increment of 1.  Each time we use the escape sequence '\n+[PI]'
(note the plus sign), the formatter applies the increment just before
interpolating the register's value.  Preparing the 'PI' register as well
enables us to rearrange the list without the tedium of updating macro
calls.

   The next example illustrates a glossary-style list.

     A glossary-style list:
     .IP lawyers 0.4i
     Two or more attorneys.
     .IP guns
     Firearms,
     preferably large-caliber.
     .IP money
     Gotta pay for those
     lawyers and guns!

     A glossary-style list:

     lawyers
           Two or more attorneys.

     guns  Firearms, preferably large-caliber.

     money
           Gotta pay for those lawyers and guns!

   In the previous example, observe how the 'IP' macro places the
definition on the same line as the term if it has enough space.  If this
is not what you want, there are a few workarounds we will illustrate by
modifying the example.  First, you can use a 'br' request to force a
break after printing the term or label.

     .IP guns
     .br
     Firearms,

   Second, you could apply the '\p' escape sequence to force a break.
The space following the escape sequence is important; if you omit it,
'groff' prints the first word of the paragraph text on the same line as
the term or label (if it fits) _then_ breaks the line.

     .IP guns
     \p Firearms,

   Finally, you may append a horizontal motion to the marker with the
'\h' escape sequence; using the same amount as the indentation will
ensure that the marker is too wide for 'groff' to treat it as "fitting"
on the same line as the paragraph text.

     .IP guns\h'0.4i'
     Firearms,

   In each case, the result is the same.

     A glossary-style list:

     lawyers
           Two or more attorneys.

     guns
           Firearms, preferably large-caliber.

     money
           Gotta pay for those lawyers and guns!

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.