xxxxxx
1.1 xxxx
1.2 xxx
1.3 xxxxxx
A. xxxxxx
B. xxxxx
C. xxx
1.4 xxxxxx
A. xxxxxx
B. xxxxx
C. xxx
xxxxxx
2.1 xxxxx
2.2 xxxxx
2.3 xxxxxx
A. xxxxxx
B. xxxxx
C. xxx
2.4 xxxxxx
A. xxxxxx
B. xxxxx
C. xxx
and so on
I tried the <$hn> place holder to achieve the X.x but kept getting X.x.x (this is do to me using a first layer folder in the draft folder to hold act as title of the document and not involved in the section numbering)
I’ve come pretty close to what I need with this placeholder setup:
∞<$n>
∞<$hn_level1><$rst_aon>
∞<$aon>
the only problem is I get this:
xxxxxx
1.1 xxxx
1.2 xxx
1.1 xxxxxx
A xxxxxx
B. xxxxx
C. xxx
1.1 xxxxxx
A. xxxxxx
B. xxxxx
C. xxx
xxxxxx
2.1 xxxxx
2.2 xxxxx
2.3 xxxxxx
A. xxxxxx
B. xxxxx
C. xxx
1.1 xxxxxx
A. xxxxxx
B. xxxxx
C. xxx
while using <$aon> archives pretty much what I see (without the X.x), I don’t want to lead with the alpha. Is their a placeholder that leads with numbers then alpha? If so I can’t find it.
If you just want a simple alphabetical sequence, the try the Insert ▸ Auto-Number ▸ A, B, C, D, E… command, which will produce the <$L> code. I would also advise just using <$hn> at all numeral levels, since a top level example of that is identical to <$n>, but will produce a more coherent result with less complexity. Here is what a hierarchical use of $hn is like:
1.
1.1
1.2
1.2.3
2.
2.1
...
So all you really need are these codes in two layouts:
I’ve recently bumped up against a constraint with the above code:
the above only works if a proceeding main section has the corresponding subsection. for example:
1 this is the first main heading
1.1 this is the first sub-heading
2. this is the second main heading
2.1 this is the second sub-heading that works fine if the 1.1 heading above is present
however when the first sub-heading is missing (because there was no need for a sub-heading in the proceeding main heading), I get this
1 this is the first main heading
2. this is the second main heading
1.1 this is the second sub-heading that doesn’t work because it is out of sequence
any ideas how I may improve my coding to make the sequence to come out in order regardless?
If I follow correctly, that is why I do not recommend mixing “<$n>” with “<$hn>”. But even so, I’m not getting the same result that you do with these settings, so I might not be doing quite the same thing. If I set up a three-level hierarchy with the three prefixes you refer to, I get:
1. First heading
2. Second heading
1. Subheading
If instead I use a basic “<$hn>” at both the first and second levels, then I get:
1. First heading
2. Second heading
2.1. Subheading
Which I think is what you want, and I also get:
1. First heading
1.1. First subheading
A. First section
2. Second heading
2.1. Second subheading
A. Section section
B. Third section
The attached project shows what I’m trying. Note that when you compile, I’ve excluded some of the subdocuments to test your initial condition. You can turn them back on to see how it works with more content. There are two formats, one is set up the way you describe, the second is set up to get a result like I think you want. hierarchical_numbering_test.scriv.zip (88.9 KB)
Amber » thank you for your timely and comprehensive replay » being able to see how you did things in the project file is great » I’ll roll to this shortly and revert…
Hi Amber,
I think my problem stems from in my formatting environment the heading/sub-heading relationship does not start with heading 1. Instead, it starts with heading 3. This is due to how WordPress forces the use of heading 1 to the main title of the post, and not the first main section of the posted article itself.
As it stands now, regardless which Scrivener prefix coding (your most recent posting or mine) I can only get the second sub-heading to display properly if I include in the compile the first sub-heading. Which of coarse is not optimal.
If it’s not asking too much, I’d like to send you an export compile file to you and have you take a look around to see if you can spot something? I prefer not to post it here. Is there a way to send it you directly? If that works for you?
Wouldn’t that be a matter for the underlying HTML header level depth, rather than any numbering typed (or generated) into the heading? I.e. if you are pushing your outline depth in Scrivener artificially merely to obtain a deeper HTML starting point, and battling against the placeholder system as a result, you definitely can fix that at the HTML output side rather than using unnecessary structure in the binder.
To better advise, I’d need to know what file type you use—the regular “HTML (Web Page)” compile setting, or are you using a Markdown-based approach? It’s a lot easier to offset the heading level with the latter (as this exact problem is quite common, with CMS/blogs establishing existing heading structure before getting to the article content), but it’s possible with both.
I can of course take a look at it. You can send a .zip compressed copy of the project (the File ▸ Back Up ▸ Back Up To… menu command is convenient for that) to our technical support address, and mention the forum thread URL in your message so that whoever gets it can put you in touch with me.
Thanks, I got the message and the attachment. I don’t quite understand how it is meant to be used though. You said this was going to be used with WordPress, but the project is set up to compile to “Print”.
Oh okay! With MultiMarkdown you can add a metadata key to the Metadata tab in compile overview called, “Base Header Level”. Use that to set what a single “#” heading should mean—so if with your post you want the top level to be “h3”, then you would type the number “3” into the field below the metadata key list. The number of hashes will stay the same; this is a virtual offset that can be used for cases like this, without having to restructure the work.
This way you can use a natural “<$hn>” counter at all levels that need hieararchical numbering, without having to force the number of hashes in your compile settings, or adjust the outline structure. That’s how I would approach it anyway (well, I would probably in fact handle the numbering at the CSS level rather than baking them into the titles with Scrivener, but that’s another topic).
You’re in a bit of a strange spot because normally what you’re doing with Markdown headers wouldn’t be a problem—without this placeholder I mean to say, it doesn’t really matter if you use layouts with specific hash settings. It’s just an issue here because “<$hn>” doesn’t expect to be inserted into an outline that is offset like that.
Let me know if this still isn’t making sense, I could try to mock up a simple example and send the compile format for you to play with.
one basic thing I can not seem to get right is if I lead off with “<$hn>” the code scrivener outputs show this to be a subsection “X.x” format instead of the desired “X” » yet, So with that in mind, let me share that here is the under “conventional settings” base code I’m using to get to the:
1.1
1.2
A.
B.
1.3
2.2
2.3
A.
B.
3.1
and so on look I seek. Let me know if this is right?
h1 = <$hn>.
h2 = <$hn_level1><$rst_L>
h3 = <$L>
[note: again the only problem I have is the h1 comes out as X.x instead of just X. Oh and this is confirmed in Bbedit where I’ve set the compile to output.]
Now, under my real world circumstances…
I fully get how setting a Metadata “Base Header Level” shift can shift everything down one level so I can the copy and paste out of Bbedit and into the WordPress Gutenberg editor. I can get this part to work, but I’m still stuck on the above problem…
Now, with all that said, in reference to your:
I’m all ears. Is there a simple CSS code I can use in the WordPress CSS section that this self-taught coder missed?
If so, then if I’m tracking your line of thought I could use the CSS approach for one compile setting headed to wordpress with the CSS and a second compile setting headed for print or other output?
With the example you provided, you are still mixing $hn placeholder types, which I don’t think will produce a good result in most cases. According to the documentation:
So, if you use <$hn_level1> for all levels, then that would provide a consistent numbering that is offset so you don’t get “1.1” to start with. I’ve attached a simple demonstration of a project with four levels of hierarchy, where the first level is intended to be a “container”, outside of that hierarchical numbering.
The first compile format simply uses <$hn> for all numbered levels. As you can see that doesn’t produce the desired result and you get 1.1 for itm “B”. But if you switch to the format that is using <$hn_level1> for all levels that are numbered, then the output looks to me like what you desire, with “1” for “B”.
It’s been a while since I’ve messed with a WordPress installation to get my own custom CSS inserted into the theme, so I don’t have have any modern guidance on how to do that (hopefully such a common thing is well documented).
But as to the technology itself, yeah, CSS has named counters and thus can be used to number documents dynamically based on their structure. In fact this guide I found is working from the same premise you are, for the most part. They wanted to start hierarchical numbering on h2, leaving h1 for the main title. The difference in your scheme is that you want alphabetical at a certain depth, so you wouldn’t have has many lines of CSS as in their example.
Automatic numbering with CSS Counters, by David Storey. This one goes more into the basics, whereas the first is more an example of execution. Note that udner “Styling counters”, you will find how to use different counter types, like alphabetical characters.
Perhaps if Scrivener’s token does well enough for you the above is academic—but of course the advantage of using CSS is that if you ever move your work to another blog and decide on a different heading schema, it’s not all baked in as raw text. Your whole archive can be updated dynamically. That’s the main reason why I go to the trouble of leaving numbering to the export formats.
Yes, each format can do its own thing entirely. If you’re using Scrivener’s built-in print and such then you’ll need to figure out the numbering placeholders anyway, so there is that. For myself, as a 100% MultiMarkdown/Pandoc junkie I would handle print and other output with Markdown as well. For example if I needed hierarchical numbering in a .docx file I would do that in the Word file’s heading stylesheet. With Pandoc you can even create such stylesheet “template files” so that your output is automatically numbered.