Numbering headings

I am trying to compile and generate headings numbering such as

  1. xxx
    1.1 yyy
    1.2 zzz
  2. aaa
    2.1 bbb
    2.2 ccc
    2.3 ddd

When I use the <$n> on the heading 1 it works. Then on the heading 2 I was trying to use <$n>.<$sn> but it obviously does not work because the <$n> is incremented when I wanted to reuse the level 1 number.

It must be feasible as Scrivener’s own user manual does it.

So what is the trick? I’ve been searching the web for 1 hour, and found nothing - I am ery surprised that such a simple thing is not documented anywhere…

Pierre

<$hn>, i.e. “hierarchical number”.

:slight_smile:

Mr X

Post Edit: But Ioa creates the Scrivener Manual using Multi-Markdown, which I think uses a different system.

Yes, <$hn> is what you’re looking for I think.

You can use numbering tokens without incrementing them, using a slightly more complicated method, by adding a stream name and unique identifier. Using your example you could go with something like this: <$n:chapter:xxx>

If you subsequently use that token in other headings, it will remain ‘1’, and the $n:chapter stream won’t increment until you use a new unique token after the second colon, like the next in the example sequence, <$n:chapter:aaa>. These are also useful for cross-referencing within the text, so using streams for your section names could be useful as well.

If you dig in to the placeholder tag system (check the Help menu for a cheat sheet), there are a lot of really neat tricks like that. You can even abstract these concepts into compound placeholders that use item names to generate stream identifiers, and even stream names themselves. For example:

<$n:chapter:<$title_no_spaces>>.<$n:section_<$parenttitle_no_spaces>:<$title_no_spaces>>

All of that gibberish is suitably generic to be dropped into the Formatting pane as nothing specific to the item it is applied to can be found within it. It uses the name of the chapter to generate a unique ID, then for the section it refers to the parent’s title to create a unique stream name just for that chapter (so it starts at ‘1’ at whenever the chapter changes). The above, if you could stop the compiler half-way through token evaluation, would look like the following:

<$n:chapter:xxx>.<$n:section_xxx:yyy>. yyy

This will ultimately compile to:

1.1. yyy

Again, for this example you’ve provided, I think <$hn> will work fine, but the above may come in handy if you find for some reason it doesn’t.

The user manual does use a different technique. As noted it starts out as MultiMarkdown, but the real document production is done with LaTeX, and that is when things are numbered, all well after I have compiled.