Autogenerated book TOC numbering problems
Hi,
I'm trying to add numbering to the autogenerated TOC in pdf-book output. Using css classes a.pdf-toc-level-2 and a.pdf-toc-level-3. I'm able to style the two levels of the toc (not sure why level-2 is the main chapters and where level-1 is, but that's not an issue). Counter for the main chapters (level2) is fine, but I need to reset the numbering of lvl3 for each main-chapter to display correct numbers.
What I want:
1 - ChapterA
1 - subchapterAA
2 - subchaterAB
2 - ChapterB
1 - subchapterBA
2 - subchapterBB
3 - subchapterBC
3 - ChapterC
1 - subchapterCA
What I get:
1 - ChapterA
1 - subchapterAA
2 - subchaterAB
2 - ChapterB
3 - subchapterBA
4 - subchapterBB
5 - subchapterBC
3 - ChapterC
6 - subchapterCA
I can't use nested counters that would work for classic <ol><li> lists since this TOC doesn't have this hierarchy, or at least I didn't find any by testing different styles. I think it's all just separate <a> lines? Counter-reset is scoped, so it doesn't work for this case. I've tried to use the counter-set attribute which works in most browsers and snippets, but the Robohelp shows it in red when editing and ignores it in output. I assume that Robohelp export does not support this? Does anyone have any experience styling and numbering the auto-generated TOC for book style output or any idea how should I go about this?
Fiddle test: https://jsfiddle.net/z52brmn9/
My css:
body {
counter-reset: a-toc-level-2 0 a-toc-level-3 0;
}
a.pdf-toc-level-2:before {
counter-increment: a-toc-level-2;
content: counter(a-toc-level-2, decimal);
padding-right: 0.5rem;
counter-set: a-toc-level-3 0;
}
a.pdf-toc-level-3:before {
counter-increment: a-toc-level-3;
content: counter(a-toc-level-3, decimal);
padding-right: 0.5rem;
}
