rust-lang / mdBook

Create book from markdown files. Like Gitbook but implemented in Rust
https://rust-lang.github.io/mdBook/
Mozilla Public License 2.0
17.69k stars 1.61k forks source link

Numbering in section headings #723

Open thejpster opened 6 years ago

thejpster commented 6 years ago

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.

martinjaeger commented 5 years ago

I agree that this would be a nice feature.

your-diary commented 2 years ago

Any updates?

your-diary commented 1 year ago

OK, I could customize general.css.

  1. mdbook init --theme to create a new book.

  2. Move theme/ to your existing book directory.

  3. 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) ": ";
}
  1. Build