Automatically Numbered Chapters, Headings and Paragraphs #143

Closed
opened 2026-02-04 17:16:37 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @raisoftware on GitHub (Aug 3, 2016).

Desired Feature:
Most technical documentation has chapter, section, sub section and even paragraph numbers for easy referencing of content. Please automatically generate order numbers for all hierarchical content. When the user reorder the chapters update the numbers.

Alternatively, associate such numbers from a unique source, but do not change them when the order is changed, so they can be used as fixed references.

Current status:
the bookmark feature is nice, but users need a clean reference, not a long URL

Originally created by @raisoftware on GitHub (Aug 3, 2016). Desired Feature: Most technical documentation has chapter, section, sub section and even paragraph numbers for easy referencing of content. Please automatically generate order numbers for all hierarchical content. When the user reorder the chapters update the numbers. Alternatively, associate such numbers from a unique source, but do not change them when the order is changed, so they can be used as fixed references. Current status: the bookmark feature is nice, but users need a clean reference, not a long URL
Author
Owner

@ssddanbrown commented on GitHub (Jul 12, 2020):

Thanks for the suggestion.

I'm going to close this off since it's had little support since the request almost four years ago. I think auto-generated numbers may lead to more confusion overall. If static, people will become frustrated with things becoming out-of-order as changes are made. If dynamic, people will be frustrated with the numbers changing as changes are made. Either way, I can only see it leading to further issues. Therefore I'm going to close this request.

@ssddanbrown commented on GitHub (Jul 12, 2020): Thanks for the suggestion. I'm going to close this off since it's had little support since the request almost four years ago. I think auto-generated numbers may lead to more confusion overall. If static, people will become frustrated with things becoming out-of-order as changes are made. If dynamic, people will be frustrated with the numbers changing as changes are made. Either way, I can only see it leading to further issues. Therefore I'm going to close this request.
Author
Owner

@psuter80 commented on GitHub (Jun 22, 2024):

i just started to evaluate BookStack and I needed header numbering. Here is how i've solved that:

go to Settings -> customization -> Custom HTML Head Content and add this CSS style:

<style>
    body {
        counter-reset: h1counter;
    }
    body.page-content.mce-content-body {
        counter-reset: h2counter;
        counter-increment: h1counter;
    }
    .page-content h1:before {
        content: counter(h1counter) ".\0000a0\0000a0";
        counter-increment: h1counter;
    }
    .page-content h1 {
        counter-reset: h2counter;
    }
    
    .page-content h2:before {
        content: counter(h1counter) "." counter(h2counter) ".\0000a0\0000a0";
        counter-increment: h2counter;
    }
    .page-content h2 {
        counter-reset: h3counter;
    }
    
    .page-content h3:before {
        content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) ".\0000a0\0000a0";
        counter-increment: h3counter;
    }
    .page-content h3{
            counter-reset: h4counter;
    }

    .page-content h4:before {
        content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) "." counter(h4counter) ".\0000a0\0000a0";
        counter-increment: h4counter;
    }
    .page-content h4 {
        counter-reset: h5counter;
    }

    .page-content h5:before {
        content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) ".\0000a0\0000a0";
        counter-increment: h5counter;
    }
</style>

for me, this did exactly what i wanted.. now if I export an entire book the book gets numbered all the way through all chapters and pages, If I export only a chapter or a page, that chapter starts at 1 and then continues its numbering from there..
this also means, if you re-organize the order of your pages it will re-number automatically when you export the entire book

what isn't solved with this is cross referencing, as numbers will obviously change as soon as you move stuff around or add sections in between etc. so keep that in mind!

@psuter80 commented on GitHub (Jun 22, 2024): i just started to evaluate BookStack and I needed header numbering. Here is how i've solved that: go to Settings -> customization -> Custom HTML Head Content and add this CSS style: ``` <style> body { counter-reset: h1counter; } body.page-content.mce-content-body { counter-reset: h2counter; counter-increment: h1counter; } .page-content h1:before { content: counter(h1counter) ".\0000a0\0000a0"; counter-increment: h1counter; } .page-content h1 { counter-reset: h2counter; } .page-content h2:before { content: counter(h1counter) "." counter(h2counter) ".\0000a0\0000a0"; counter-increment: h2counter; } .page-content h2 { counter-reset: h3counter; } .page-content h3:before { content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) ".\0000a0\0000a0"; counter-increment: h3counter; } .page-content h3{ counter-reset: h4counter; } .page-content h4:before { content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) "." counter(h4counter) ".\0000a0\0000a0"; counter-increment: h4counter; } .page-content h4 { counter-reset: h5counter; } .page-content h5:before { content: counter(h1counter) "." counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) ".\0000a0\0000a0"; counter-increment: h5counter; } </style> ``` for me, this did exactly what i wanted.. now if I export an entire book the book gets numbered all the way through all chapters and pages, If I export only a chapter or a page, that chapter starts at 1 and then continues its numbering from there.. this also means, if you re-organize the order of your pages it will re-number automatically when you export the entire book what isn't solved with this is cross referencing, as numbers will obviously change as soon as you move stuff around or add sections in between etc. so keep that in mind!
Author
Owner

@Man-in-Black commented on GitHub (Jun 22, 2024):

This looks very promising.
But it also out a number on the title in my case.
So I got the title with number "1" and the first h1 has number "2".
Is there a way to correct this behavior?

@Man-in-Black commented on GitHub (Jun 22, 2024): This looks very promising. But it also out a number on the title in my case. So I got the title with number "1" and the first h1 has number "2". Is there a way to correct this behavior?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#143