Skip to content

Page numbering

::pagenumber{start=1}
::pagenumber{offset=-2}
AttributeValueMeaning
startwhole number ≥ 0This page becomes start; later pages count up
offsetwhole number, may be negativeThis page’s number is shifted by offset; later pages count up

Exactly one of the two is required.

cover-page/document.md
::header[Annual report||2026]
::footer[|Page {page} of {pages}|]
# Annual Report 2026
Prepared for the board.
::pagebreak
::hide{header}
::toc{depth=2}
::pagebreak
::pagenumber{start=1}
## Summary
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
::pagebreak
## Results
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
MDLeaf lays Markdown out on real pages. Paragraphs flow from page to page, and the page view shows exactly what the PDF will contain.
A cover page without header and footer, a contents page, and numbering that restarts at 1 for the first chapter. {pages} counts the displayed numbers.
Download sample (.mdl)

Open it in MDLeaf with Library → Import .mdl. If MDLeaf is installed, you can also open the file directly.

# Report title
::pagebreak
::toc
::pagebreak
::pagenumber{start=1}
# Chapter 1

The cover and contents pages are numbered 1 and 2; the first chapter starts again at 1.

  • The first page is 1. Each page is the previous one plus one, then the page’s ::pagenumber directives apply in order.
  • Numbers can be zero or negative, and are printed as they are. Only Arabic numerals are supported.
  • {pages} is the displayed number of the last page, so restarts change it. The table of contents shows displayed numbers too.
  • ::pagenumber alone, or with both start and offset: directive-attr-invalid.
  • ::pagenumber{start=i} — only whole numbers.