Michael Altfield
Michael Altfield

Reputation: 2777

How to use auto-enumerator in nested lists (reStructuredText)

How do I make the following list in reStructuredText using the auto-enumerator character (#)?

1. one
 a. one_a
 b. one_b
2.two
 a. two_a
  I. one_a_i
 b. two_b

In the above list, the first-level of the list is decimal, the second level is lower-alpha, and the third is upper-roman. I'd like to be able to specify this while also using the auto-enumerator, such that I can easily re-order the items in the list or add a new item in the middle of the list without having to change the values of each item in the list.

Is it possible to tell the auto-numerator which formatting type to use, with distinct types for each nesting level in the list?

Upvotes: 2

Views: 492

Answers (1)

Steve Piercy
Steve Piercy

Reputation: 15045

  1. You must use proper whitespace for nested lists.
  2. You can specify how to display the enumeration of nested lists with custom styles. See also list-style-type.
  3. I recommend using 4 space indentation for clarity.

reST

.. rst-class:: enumlist

#.  one

    #.  one_a
    #.  one_b

#.  two

    #.  two_a

        #. one_a_i

    #.  two_b

CSS

ol.enumlist {
    list-style-type: decimal;
}
ol.enumlist ol {
    list-style-type: lower-alpha;
}
ol.enumlist ol ol {
    list-style-type: upper-roman;
}

HTML Rendering

HTML Rendering

Upvotes: 3

Related Questions