Section numbers and titles in headers

Apologies if this has already been asked, but I’m trying to configure compile to headers that contain information like the chapter number and title, and the hierarchical number and title of a second-level deep section, as is the norm in academic books and so on.

<$sectiontitle> appears to be the only header-specific tag that can be used for this, and returns the name of the ‘section’, which for my project, returns the name of folders at the top level of my project. So my question boils down to the possibility of returning section numbers, or any section name further deep than the top-most folder level.


Are you asking for the <$sectiontitle> token to include prefix and suffix information from the Formatting compile option pane? So basically if that pane is printing the binder folder “Topic” as “23 Topic”, you would want “23 Topic” (or 23.5.1 Subsubtopic) printed in the header, instead of just “Topic”? That might be feasible. I’ll check with Keith once he gets back from vacation.

Consider the “Title Adjustments” pane, where Scrivener Links pointing to section names can be customised to include prefix and suffix. If that technology can be applied to the value of <$sectiontitle>, it could work.

Yes, there are two separate issues here. There’s the printing of the relevant section number along with the title of the section that gets output by <$sectiontitle>, so I’m having a look now to see if title adjustments has anything on it. … Turns out there are no options in title adjustments that would include the hierarchical number in the sectiontitle tag.

The other issue is more ambitious and probably not doable in the current release, and that’s having some kind of placeholder tag that would return the section title of the second level section in the binder.

The idea is to have a book’s header formatted so that it looks like this:

23       Chapter 3: Methodology      |      3.2 – Data collection       24

Or templatically:

<$p>          <$sectiontitle>        |        <$subsectiontitle>       <$p>

Looking at the way the placeholder tag <$sectiontitle> works, it appears it returns the name of the section after a page break. This is why there’s no way around it: even if I added a page break before any second level section, the tag would not then be able to differentiate between chapter titles and subsection titles.

I suppose there would be ways of implementing this, but I’m not so fussed that I would want to burden you guys with so much coding work for such a small addition.

Yeah, that won’t quite work as things stand, because it goes back to the problem knowing which page sub-page-break level content falls. The page break spot is easy to handle, because its usage fairly predictably means that now is the time for section breaks, header changes, special page side treatment and so on. Below the level of the page break, it’s all murky.

No worries.

But yeah, it would be great if it were possible to include either the title prefix somehow, or even to have a way of printing out the section number using a different placeholder (my suggestion: <$sectionhn>), which can then be formatted differently from the <$sectiontitle>. I can imagine several different options:

*Chapter <$sectionhn>: <$sectiontitle>*

Coming out as “Chapter 1: Introduction

<$sectionhn> – <$sectiontitle>

“1 – Introduction”

And so forth. Perhaps I should submit this to the wish list…

Thanks, I do actually have something written up for the numbering request already; no need to write a wish list post. Numbering them seems easy enough to me, but ultimately it is up to Keith whether it gets developed.

So, unfortunately adding a number to the <$sectiontitle> token is not possible, given the infrastructure of how things are calculated within the compiler loop. The numbering information just isn’t available at the right point, and getting it at the right point would require redesigning a lot of the core system. Sorry about that!

I’ve moved it to the long-term list as a result. If the compile engine is ever completely re-hauled (not unlikely eventually), it can be thought about at that time.