Headings¶
prodockit.headings numbers the headings in your document as sections,
such as 1, 1.1, and 1.2. The numbers update automatically when you add,
remove, or move a heading.
Use it when your document needs numbered sections. Add Cross-references when you also want to link readers to those sections by number and name.
Enable the extension¶
Enable it in zensical.toml:
continuous carries the numbering across the pages in your Zensical
navigation. Use per-document instead when every page should start again at
section 1.
Number headings¶
Each # heading starts a main section (1, 2, and so on). A ## heading
starts a section inside it (1.1, 1.2, and so on):
The rendered result in Table 20.1 shows the number and identifier assigned to each heading.
1. Number headings
| Heading | id | number |
|---|---|---|
| Introduction | introduction |
1 |
| Background | background |
1.1 |
| Scope | scope |
1.2 |
| Method | method |
2 |
The result in Table 20.1 shows the numbering the extension also supplies to Cross-references. The shared prodockit website styles can also show those numbers beside headings and in the page navigation. This reference site has that presentation enabled, so the example headings on this page are visibly numbered.
Calculation and presentation are separate
A site can hide the visible numbers without changing the numbers resolved
by \ref{}. The template-level extra.website_heading_numbering switch
controls the website presentation; extra.heading_numbering controls
whether document-style numbering is enabled for the project and its PDF.
Configure headings¶
Configuration decides whether numbering continues across pages, where a page's counter starts, and which headings are deliberately excluded. The following subsections cover those choices in that order.
Choose how numbering continues¶
The numbering setting accepts two values:
Table 20.2 compares page-by-page numbering with numbering that continues across the site.
2. Choose how numbering continues
| Value | Result |
|---|---|
"continuous" |
Continue the main section numbers across pages in Zensical navigation order. |
"per-document" |
Start each page's main section numbering at 1. This is the extension's default. |
Choose the continuation behaviour from
Table 20.2, then set it in
zensical.toml:
For example, if one page ends at section 3, the next page starts at section 4. This also lets Cross-references show one consistent set of section numbers across the site.
Number appendices¶
Add is_appendix: true to the settings at the top of the page (its
front matter) to use letter-based numbering instead of the normal
numeric sequence - "A", "A.1",
"A.1.1" - once you've enabled
continuous numbering (see
Reference below). An appendix page doesn't consume a number from the
numeric sequence at all, so pages after it aren't left with a gap. Letters
are assigned sequentially in nav order - the first is_appendix page
becomes "A", the second "B", and so on, independent of how many
numbered pages come before them.
For example:
The rendered result in Table 20.3 shows letters used for appendix headings and decimal numbers retained beneath them.
3. Number appendices
| Heading | Number |
|---|---|
| Glossary | A |
| Terms | A.1 |
The appendix result in Table 20.3 is also
used by a prodockit.refs reference to Terms from another page:
renders to (a link to glossary.md#terms, shown here as a code block
since glossary.md isn't a real page on this site):
Glossary's own h1 becomes "A" (the first appendix page in nav) and
its Terms subheading becomes "A.1" - and References, the page after
it, still gets the next plain number in the numeric sequence ("2", not
"3"), exactly as if the appendix page had never consumed one. Only
meaningful under Zensical; ignored otherwise.
Leave a heading unnumbered¶
A heading with an unnumbered class - e.g. a cover page or title slide -
still gets an id, but is skipped when computing section numbers, so it
doesn't consume a counter position:
The rendered result in Table 20.4 shows how an unnumbered heading affects the headings that follow it.
4. Leave a heading unnumbered
| Heading | Number |
|---|---|
| Cover Page | none |
| Introduction | 1 |
In Table 20.4, Introduction is
still numbered 1, as if Cover Page weren't
there at all.
Hide a heading from PDF navigation¶
A PDF built by prodockit.pdf has two tables of contents, and
unnumbered alone only reaches one of them:
- The generated Table of Contents page, built from every heading
Pandoc sees. Add
unlistedto also keep a heading off this page - it still keeps itsidand number (if any), the same asunnumberedabove. Pandoc itself defines this class and honours it viapandoc.structure.table_of_contents(); prodockit doesn't add or change its meaning. - The bookmark outline - the navigation pane a PDF reader shows down
the side. This is built separately by WeasyPrint from every
h1-h6in the document, andunlistedhas no effect on it at all. Addunbookmarkedto also remove a heading from the outline.
This distinction matters because outline nesting follows heading level:
an unlisted (but not unbookmarked) h1 still becomes a top-level
outline node, and every following heading of lower level nests underneath
it instead of under its real chapter - not just one stray entry, but a
misnested chunk of the outline. See
Table of contents and bookmark outline
for the underlying stylesheet rule and worked example.
Reference¶
Use this section to look up id generation and the complete Zensical settings after choosing the numbering behaviour in the worked examples.
Ids¶
An id comes from one of, in order of precedence:
- An explicit id set via
attr_list, e.g.# Introduction {: #custom-id }. - Python-Markdown's own
tocextension, whichprodockit.headingsenables automatically (with its defaults) if you haven't already enabled it yourself - so if you have configuredtoc(e.g. withpermalink: true), that configuration is left untouched and reused. - A minimal built-in slugify fallback, used only if
tocis somehow not registered at all (this should not normally happen, sinceprodockit.headingsenables it).
Zensical settings¶
The numbering modes and their defaults are collected in Table 20.5.
5. Zensical settings
| Setting | Default | What it controls |
|---|---|---|
numbering |
"per-document" |
Use "continuous" to carry main section numbers across pages in Zensical navigation order. |
appendix_attr |
"is_appendix" |
Name of the front matter setting that marks an appendix page. Change this only if your project uses another name. |
source |
"" (detected automatically) |
Advanced: identifies the current page when using the extension outside Zensical. Leave it unset in zensical.toml. |
Cross-page numbering in Zensical¶
Zensical shares heading information across the complete navigation
automatically. With numbering = "continuous", adding or reordering a page
updates later section numbers without a manual starting value.
Give repeated headings explicit ids. If several pages each contain ## Quick
start, their automatically generated ids collide and the build warns; which
page renders first is not a stable way to choose a link target:
For integration with another Markdown renderer, see Extension integration.
Customise with a CSS style sheet¶
prodockit.headings doesn't add any class of its own to a heading - only an
id (see above), the class(es) already on the heading (e.g. unnumbered),
and whatever numbers are consumed by prodockit.refs. There is no
prodockit-heading-style class to hook a stylesheet onto directly.