Custom CSS: Adding chapter numbers with custom CSS
Using the CSS below in either a Custom Style or in the Style Preferences "Additional CSS" field in Marked 2 will add nested numbers before each heading in your document (e.g. 1, 1.1, 1.2, 1.2.1):
body {
counter-reset: chapter; /* create a chapter counter scope */
}
h1:before {
content: "Chapter " counter(chapter) ". ";
counter-increment: chapter; /* add 1 to chapter */
}
h1 {
counter-reset: subchapter; /* set section to 0 */
}
h2:before {
content: counter(chapter) "." counter(subchapter) " ";
counter-increment: subchapter;
}
h2 {
counter-reset: section;
}
h3:before {
content: counter(chapter) "." counter(subchapter) "." counter(section) " ";
counter-increment: section;
}
h3 {
counter-reset: subsection;
}
h4:before {
content: counter(chapter) "." counter(subchapter) "." counter(section) "." counter(subsection) " ";
counter-increment: subsection;
}
h4 {
counter-reset: subsubsection;
}
h5:before {
content: counter(chapter) "." counter(subchapter) "." counter(section) "." counter(subsection) "." counter(subsubsection) " ";
counter-increment: subsubsection;
}
h5 {
counter-reset: subsubsubsection;
}
h6:before {
content: counter(chapter) "." counter(subchapter) "." counter(section) "." counter(subsection) "." counter(subsubsection) "." counter(subsubsubsection) " ";
counter-increment: subsubsubsection;
}