Deep NumberingEdit online
This section contains information about deep numbering.
Deep Numbering - Built-in CSSEdit online
The CSS file responsible for deep numbering is [PLUGIN_DIR]/css/print/p-optional-numbering-deep.css. The following examples are taken from this file.
For implementing the deep numbering, first the counters for the root element should be reset.
In the following example, the root is the element that has the class attribute set to
map/map. Note that the following selector will also match bookmaps, as they
are derived from maps:
*[class ~= "map/map"] { counter-reset: page 1 toc-chapter 0 toc-section1 0 toc-section2 0 toc-section3 0 toc-section4 0 chapter 0 section1 0 section2 0 section3 0 section4 0 figcount 0 tablecount 0; }
Table of Contents
toc-part), chapters
(toc-chapter) and sections (toc-section1,
toc-section2, toc-section3). *[class ~= "map/topicref"][is-chapter]:not([is-part]) { counter-increment:toc-chapter; counter-reset: toc-section1; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"]{ counter-increment:toc-section1; counter-reset: toc-section2; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"]{ counter-increment:toc-section2; counter-reset: toc-section3; } /* All the parts get a part number. Each chapter gets a chapter number. All other topicrefs following a part do not have a number. */ *[class ~= "map/topicref"][is-part] { counter-reset:toc-chapter !important; counter-increment:toc-part; } /* All other topicrefs that follow a part should not have a number (i.e appendices) */ *[class ~= "map/topicref"][is-part] ~ *[class ~= "map/topicref"]:not([is-part]) > *[class ~= "map/topicmeta"]:before{ content: none !important; counter-increment:none; } *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"]:before { display:none !important; /* In case this CSS is used in cascade with the shallow numbering. */ }
To display the numbers in the table of contents, a pseudo :before element
is used on <topicmeta> (this contains the TOC label and the header
and page number).
*[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before { display:inline; position:static; } *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"] { display:inline !important; } *[class ~= "map/topicref"][is-part] > *[class ~= "map/topicmeta"]:before { left: -1.5em; /* Increase the value of width and left as the depth increases. */ width:1em; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"]:before { left: -1.5em; width:1em; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before { left: -2em; width:2em; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before { left: -2.5em; width:2.5em; }
And now the content for each pseudo element (depending on its depth) is set:
*[class ~= "map/topicref"][is-part] > *[class ~= "map/topicmeta"]:before { content: counter(toc-part, upper-roman) ". "; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"]:before { content: counter(toc-chapter) ". "; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before { content: counter(toc-chapter) "." counter(toc-section1 ". "); } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before { content: counter(toc-chapter) "." counter(toc-section1) "." counter(toc-section2) ". "; } *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicref"] > *[class ~= "map/topicmeta"]:before { content: counter(toc-chapter) "." counter(toc-section1) "." counter(toc-section2) "." counter(toc-section3) ". "; }
/* To hide the "Chapter NN." labels */ *[class ~= "map/topicref"][is-chapter]:not([is-part]) > *[class ~= "map/topicmeta"] > *[class ~= "topic/navtitle"]:before{ content:none !important; }
The Titles of Chapters in the Main Content
part, chapter and
section1/section2/section3 counters are
incremented on the elements that have the class topic/topic:
*[class ~= "topic/topic"][is-part]{ counter-increment:part; counter-reset:chapter; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) { counter-increment: chapter; counter-reset:section1; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] { counter-increment:section1; counter-reset:section2; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/topic"] { counter-increment:section2; counter-reset:section3; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/topic"] > *[class ~= "topic/topic"] { counter-increment:section3; counter-reset:section4; }
<frontmatter>,
<backmatter>, and other topics following the last book part (for
bookmaps).*[class ~= "bookmap/frontmatter"], *[class ~= "bookmap/frontmatter"] *[class ~= "topic/topic"], *[class ~= "bookmap/backmatter"], *[class ~= "bookmap/backmatter"] *[class ~= "topic/topic"], *[class ~= "topic/topic"][is-part] ~ *[class ~= "topic/topic"]:not([is-part]) { counter-increment:none !important; counter-reset: part chapter section1 section2 section3 section4 !important; }
*[class ~= "topic/topic"][is-part] > *[class ~= "topic/title"]:before{ content: counter(part, upper-roman) ". "; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/title"]:before{ content: counter(chapter) ". "; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/title"]:before{ content: counter(chapter) "." counter(section1) ". "; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/topic"] > *[class ~= "topic/title"]:before{ content: counter(chapter) "." counter(section1) "." counter(section2) ". "; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/topic"] > *[class ~= "topic/topic"] > *[class ~= "topic/title"]:before{ content: counter(chapter) "." counter(section1) "." counter(section2) "." counter(section3) ". "; }
Avoid however setting content for <frontamatter>,
<backmatter>, and other topics following the last book part (for
bookmaps).
*[class ~= "bookmap/frontmatter"] > *[class ~= "topic/title"]:before, *[class ~= "bookmap/frontmatter"] *[class ~= "topic/topic"] > *[class ~= "topic/title"]:before, *[class ~= "bookmap/backmatter"] > *[class ~= "topic/title"]:before, *[class ~= "bookmap/backmatter"] *[class ~= "topic/topic"] > *[class ~= "topic/title"]:before, *[class ~= "topic/topic"][is-part] ~ *[class ~= "topic/topic"]:not([is-part]) > *[class ~= "topic/title"]:before, *[class ~= "topic/topic"][is-part] ~ *[class ~= "topic/topic"]:not([is-part]) *[class ~= "topic/topic"] > *[class ~= "topic/title"]:before{ content:none !important; }
Headers
*[class ~= "topic/topic"][is-part] > *[class ~= "topic/title"] { string-set: parttitle " | " counter(part, upper-roman) " - " content(), chaptertitle ""; /* Avoid propagating a past chapter title on a new part */ } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/title"] { string-set: chaptertitle " | " counter(chapter) " - " content(), sectiontitle ""; } *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/title"] { string-set: sectiontitle " | " counter(chapter) "." counter(section1) " - " content(); }
<frontamatter>,
<backmatter>, and other topics following the last book part (for
bookmaps).*[class ~= "bookmap/frontmatter"] > *[class ~= "topic/title"], *[class ~= "bookmap/frontmatter"] *[class ~= "topic/topic"] > *[class ~= "topic/title"], *[class ~= "bookmap/backmatter"] > *[class ~= "topic/title"], *[class ~= "bookmap/backmatter"] *[class ~= "topic/topic"] > *[class ~= "topic/title"], *[class ~= "topic/topic"][is-part] ~ *[class ~= "topic/topic"]:not([is-part]) > *[class ~= "topic/title"], *[class ~= "topic/topic"][is-part] ~ *[class ~= "topic/topic"]:not([is-part]) *[class ~= "topic/topic"] > *[class ~= "topic/title"]{ string-set: parttitle "", chaptertitle "", sectiontitle ""; }
How to Use a Deeper Numbering for SectionsEdit online
If you need a deeper numbering, that goes to the sections and subsections, import the rules defined in the [INSTALLATION_DIRECTORY]/css/print/p-optional-double-side-pagination.css from your customization CSS.