Edit online

This section contains information about deep numbering.

Edit 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.

Note: This CSS file is not used by default. To use it, you should copy it and then import it from your customization CSS.
Note: This is listed solely for illustration purposes, as the plugin might use something different.

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

There are counters for parts (toc-part), chapters (toc-chapter) and sections (toc-section1, toc-section2, toc-section3).
Note: The parts are also marked as chapters.
*[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) ". ";
}
Tip: When using deep numbering rules, to avoid double numbering in the TOC, override the default labeling behavior defined in the p-numbering-shallow.css file by adding something like the following rule in your customization CSS:
/* 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

The 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;
}
Now avoid incrementing the counters for <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;
}
The following counters are used in the content, before the titles:
*[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

Define the string-sets used in the header and make use of counters:
*[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();
}
Avoid using counters for <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 "";
}

Edit 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.