mdBook
mdBook copied to clipboard
Numbering in section headings
Is it possible to enable numbering of section headings in the output? Without it, the print preview can be a little confusing as you have to rely entirely on the heading styles to work out which are sub-headings and which are top-level headings.
I agree that this would be a nice feature.
Any updates?
OK, I could customize general.css
.
-
mdbook init --theme
to create a new book. -
Move
theme/
to your existing book directory. -
Append the lines below to
theme/css/general.css
.
body {
counter-reset: section -1;
}
h1 {
counter-reset: subsection 0;
}
h1::before {
counter-increment: section;
content: counter(section) ": ";
}
h2::before {
counter-increment: subsection;
content: counter(section) "." counter(subsection) ": ";
}
- Build