Including the Folder/Chapter number in the Section documents (SOLVED)

My project is structured as two levels. The folders represent chapters, and the sub-documents they contain are sections.
I use <$n> for the chapters and <$sn> for the sections.
Currently it looks like this which is fine:

Chapter 1
Section 1
Section 2
Chapter 2
Section 1
Section 2

What I would like to do is include the current chapter number in each section, eg

Chapter 1
Section 1.1
Section 1.2
Chapter 2
Section 2.1
Section 2.2

I have tried the various compile formats, pored over the placeholder documentation and spend numerous hours trying to achieve the above format, but without success.
I am a software engineer by trade, have programmed using machine code, numerous compilers, C, C++, html, CSS, Javascript and many more… but I am defeated by this one.
I must be missing or overlooking something very simple :blush:
Rudi

Using streams instead of <$n> and <$sn>, there is a placeholder that allows the number to be recalled without increasing its value by the usual +1.

. . . . . . . . . .

You might want to read this thread.
I explain the how to in there.

. . . . . .

I might be wrong about this, but I don’t think it can otherwise be achieved using <$n> and <$sn>.

2 Likes

Yeah, <$hn> is almost always what you want for a scenario like this, where you want clean and simple 1, 1.1, (and potentially 1.1.1, 1.1.1.1) hierarchical numbering. You only need one single token for every level.

<$hn>, right.

In the case of using <$hn>, if the output doesn’t look quite as it should, it is the binder’s structure that needs to be better tuned. (Merge documents if needed.)

Hi Vincent, thank your for your help.

I did try the “<$n:chapter>” format, but I also used it in the section heading.
Instead, I should have used “<$n#chapter>” instead :crazy_face:

In the end this worked perfectly for me:

Chapter title: <$n:chapter>
Section title: <$n#chapter>.<$sn:chapter>

Once again thank you for your help! :smile:

1 Like

Does <$sn:chapter> reset on its own with each <$n:chapter> ?

If it doesn’t and you have to reset it yourself with the reset placeholder, then there is no real purpose to be using it as “sn”. Might as well create a new stream with a name that makes it easier to tell them apart.
Something like <$n:subchapter>.

You can create as many streams as you need, and the name doesn’t matter to the compiler. Could be <$n:scrivenerrocks>, and it would work just the same.

Yes it does!

I will look at your suggestion on using a separate stream for my sections!!!

Ok. Well that’s convenient.

(I asked because some of the numbering placeholders don’t quite always do what is expected in the Windows version… I don’t remember exactly what, but I do recall there was an issue with resetting streams by use of the resetting prefix. <$rst_…>)
→ You have to use <$rst><$n:nameofthestreamthatyouwanttoreset>

That worked perfectly too. (I am on Windows) :+1:
I used the following:

Chapter: <$n:chapter><$rst_subchapter>
Section: <$n#chapter>.<$n:subchapter>

1 Like

That worked ? Ok. Either I recall it wrong, or it got fixed since.

It looks like they have fixed it - I am using the latest version: :innocent:

Version: 3.1.5.1 (2073405) 64-bit - 06 Jul 2023

I think you are refering to our experiments in this thread?

I can still reproduce some of the strange stuff we saw there. Didn´t repeat all tests though. ^^

Yeah. And some of the side experiments too, that ended up gravitating around it.
(And of which most is now comparable to a big mushy blur in my head, not having used any of it since.)

1 Like