Hierarchical numbering control

I am quite confused by the system for assigning and controlling hierarchical section numbering. I am writing a technical, academic work. My publisher has requested a format similar to the following:

Part 1
Chapter 1
(Section) 1.1
(Subsection) 1.1.1
(Subsubsection) 1.1.1.1
There are no subsubsubsections, as it gets kind of ridiculous to read after that.

I cannot for the life of me figure out how to accomplish this with placeholder tags in the Format pane of the compiler options. My ms is currently laid out as such:

(Folder) Part, with introductory text (sometimes)
-> (Document, containing documents) Chapter, with introductory text
-> -> (Document, which may or may not contain documents) Section, with section text
and so on for subsections and sub subsections.

Is there a way to arrange this? If I simply use the <$hn> tag as the basis for numbering, I’ll get:
Part 1
Chapter 1.1
(Section) 1.1.1
etc.

I have figured out how to use tagged numbering, so I can, for example, make the prefix for chapters “Chapter <$n:chapter>” and the first section prefix into “<$n:chapter>.<$n:section>”, with the appropriate <$rst_section> in the suffix for the chapters so that section numbering starts over with the start of each chapter. However, this approach gets me this:

Part 1
Chapter 1
(section) 2.1
(subsection) 3.2.1
etc.

I think this is because the tagged chapter/section/etc numbers auto increment each time they are used. I could stop this by using a construction like <$n:chapter:chapterNumber> to assign a reference to that particular number, but then I have to go through gyrations to assign a unique reference name to each chapter, section, etc.

One post I saw had a solution like this, using a piece of metadata assigned uniquely for each section: thus, each chapter prefix would look like <$n:chapter:<$custom:chapterName>>. This is a) a terrible kludge, and b) a lot of work to add 325 extra pieces of metadata whose only use is to keep the section numbering in line.

Is there any other (hopefully simple) way to accomplish the numbering scheme I want? I’m kind of at my wit’s end. I’m not sure yet whether I will be compiling to a Word .docx or to MultiMarkdown->LaTeX, so I can’t insert LaTeX tags to accomplish it (and it’s been 20 years since I last used LaTeX).

(A related feature request: a flexible way to accomplish this would be to expand the <$hn> tag so that one can access individual levels of the number, or at least start with individual levels. If the current hierarchical number were" 5.6.7.8," <$hn:3> would produce the number “7,” while something like <$hn:2-> would produce" 6.7.8." If you wanted a slice through the middle of the hierarchical number, you would write <$hn:2-3> to get “6.7.”)

regards,
dan kuespert

There isn’t currently a good way of doing this. The <$hn> tag is very simple, as you’ve noted. It’s not even a proper counter, but rather just reports the numerical “address” of the current context, wherever it appears. So to make this better, it would have to be retooled to understand that it isn’t always working from the root level for addresses, etc. We do have plans to make this area a bit more powerful in the future, including better tools to “build your own” <$hn> style tag. Right now you’d be best off handling the numbering in your word processor or with LaTeX (which it should be noted, can handle part/chapter+technical sectioning with ease, and in fact is the default numbering scheme for the Memoir class. You may note the Scrivener user manual PDF uses a very similar numbering scheme as what you require—I didn’t change anything in LaTeX to get that result). Memoir is a really friendly class to use if your LaTeX is rusty (as mine frequently is, so I understand what that is like). It comes with a massive user manual describing easy to use switches to select between common uses. For example there are around a dozen different chapter heading styles built-in.

Although this won’t help you out for this problem specifically, it may help you in general to know that it is absolutely possible to build compound automatically generating number counters using information from the Binder to establish unique counter tokens. For example:

<$n:chapter:<$title_no_spaces>>

Or:

<$n:chapter-<$position>:<$title_no_spaces>>

The <$position> tag prints the sibling order of the current item, so the above would establish a unique dedicated stream for each chapter. The other token is self-explanatory I’m sure. Check out Help/Placeholder Tags List… for more, particularly in the “Document Variables” section.

Like I say, even with that you won’t be able to build your own <$hn> because you only refer to a parent for automatically generated information. That will likely be improved in the future, too.

I have found a good way to provide numbering and cross referencing:

((((( In following, use text between -----> and <------)))))

For starters, set the formatting prefix to -----> %%<$n:sectNameAbbrev: <------
and suffix to -----> >%%<$rst_tab><$rst_fig>!3~<$hn>~~. <------

Note that in the title you should place an abbreviation for the section name. If you want to use a title instead, put the following into the prefix (leaving suffix blank).
-----> %%<$n:sectNameAbbrev:<$custom:sectionName>>%%<$rst_tab><$rst_fig>!3~<$hn>~~. <------

A little explanation. The ‘sectNameAbbrev’ is a ‘type’ of header so that the one marked with the ID given by the info after the ‘:’. In the first prefix format, that info comes from the title field. In the second it comes from the custom variable for the entry, the custom variable being named sectionName.
Further, there is a “!3~” in the second part of the string. Also, there is a “~~” at the end. Those, as well as the “%%”, all are used to mark find strings for ‘replacement’. Specifically, the “!3~” is used to indicate that the 3rd part of the hierarchical number is to be used for numbering the section. To accomplish this, I put a series of strings in for find and replace:
FIND REPLACE WITH (be sure to check RegEx)

“%%\d+%%” —><---- (nothing used)
!1~(\d+).(\d).(\d)(.(\d))~~ $1
!2~(\d+).
(\d*).(\d).(\d).(\d).(\d).(\d).(\d).(\d)..~~ $2
!3~(\d+).(\d+).(\d+)(.(\d))..?~~ $3
!4~(\d+).(\d+).(\d+).(\d+).
(\d*).(\d).(\d).(\d).(\d)..~~ $4
!5~(\d+).(\d+).(\d+).(\d+).(\d+).(\d).(\d).(\d).(\d)..~~ $5

and so on. Note that the above shows irregularity to provide a couple of alternative structures. The main point is that you want to be sure to have actual digits where you want them, or the strategy breaks.

You can also wrap the find and replacement with some further replacement, so that you can get a string set like I. A. 1. a) i) .

Thanks. I actually just finished editing the galley proofs on the ms I was working on before, but the publisher gave me a contract for a second book, so I’ll have ample opportunity to use your ideas.