Skip to content

Page numbersΒΆ

Number pages, and repeat the website's name and the current section at the top of each page.

A page with a header and a footer

guide/writing/index.pdf

plugins:
  - exporter:
      formats:
        pdf:
          stylesheets:
            - pdf.css
          header:
            left: "{site_name}"
            right: "{section}"
          footer:
            right: "Page {page} of {pages}"
@page {
  size: A4;
  margin: 2.5cm 2cm;

  @top-left {
    color: #3949ab;
    font-weight: 600;
    border-bottom: 1px solid #c5cae9;
  }

  @top-right {
    color: #3949ab;
    border-bottom: 1px solid #c5cae9;
  }
}
  • header and footer place text in the margins of every page, at the left, center or right. Their placeholders are replaced by the website's name ({site_name}), the heading the page starts with ({section}), the page number ({page}) and the number of pages ({pages}).
  • The stylesheet sets the size of pages and their margins, leaving room for the header and the footer.
  • Headers and footers are page margin boxes: the stylesheet styles them with @top-left and @top-right rules, which win over the plugin's own (each box needs a rule of its own).

To number pages without anything else, a footer is enough:

plugins:
  - exporter:
      formats:
        pdf:
          footer:
            center: "{page} / {pages}"

Browse the files of this example