enumsreportenumerationtypst

Typst Report-Style Enumeration


I would like to modify Typst's #enum function to number every paragraph within my document following a technical report style.

For example

+ Paragraph 1
 + SubParagraph 1
  + Sub-SubParagraph 1
+ Paragraph 2
 + SubParagraph 2
  + Sub-Sub Paragraph 2

Should result in:

1 Paragraph

1.1 Sub Paragraph

1.1.1 Sub-Paragraph

2 Paragraph

2.1 Sub Paragraph

2.1.1 Sub-Paragraph

This can somewhat be accomplished using headings, for example:

= Heading 1
== SubHeading 1
=== Sub-Subheading 1

Results in:

1 Heading

1.1 Subheading

1.1.1 Sub-Subheading

But I would like to enum the paragraphs and not treat everything in my document as a heading.


Solution

  • Use #set enum(full: true), see enum docs.

    When using an enumeration, Typst will, by default, only use the numbering of the current level instead of the full pattern. You can change this by inserting a set rule like the one above before your lists, or by putting it in your template file.

    A minimum working example of this would look like this.

    #set enum(full: true)
    
    + My top-level paragraph is only numbered with a `1.`
    
      + This is a sub-paragraph, so it receives a `1.1.`
    
      + Pay attention that given the right indentation,
        because an enumeration item can contain multiple
        paragraphs.
    
        So you'd need to manually insert a plus in front
        of each paragraph to ensure they all get their own
        number, unlike this one.
      
    + This is the second top-level item
    

    Also make sure to put a blank line between the enumeration items like in the example above, so Typst will insert paragraph spacing instead of enum spacing (which defaults to line spacing). You can learn more about this distinction by looking up tight lists on the docs page linked above.