Home

Awesome

pagebreak

This filter converts paragraps containing only the LaTeX \newpage or \pagebreak command into appropriate pagebreak markup for other formats. The command must be the only contents of a raw TeX block in order to be recognized. I.e., for Markdown the following is sufficient:

Paragraph before page break

\newpage

Paragraph after page break

Fully supported output formats are:

ODT is supported, but requires additional settings in the reference document (Configuration).

In all other formats, the page break is represented using the form feed character.

Note that not all input formats support the raw_tex format extension, which is required to use the filter in the default configuration. Enable the break-on.plaintext-command option to use this filter with if raw_tex is unavailable.

Usage

The filter modifies the internal document representation; it can be used with many publishing systems that are based on pandoc.

Plain pandoc

Pass the filter to pandoc via the --lua-filter (or -L) command line option.

pandoc --lua-filter pagebreak.lua ...

Quarto / R Markdown

The use of this filter with either Quarto or R Markdown is discouraged, as both systems ship with their own fork of this extension. Use those instead.

Note also that Quarto allows to use the {{ pagebreak }} short-code to insert page breaks.

Configuration

The filter can be configured through the pagebreak metadata field.

Example config in YAML frontmatter:

---
pagebreak:
  break-on:
    # Treat paragraphs that contain just a form feed
    # character as pagebreak markers.
    form-feed: true
    # Allow plaintext commands, i.e., respect LaTeX newpage
    # commands even if they are not in a raw TeX block.
    plaintext-command: true

  # Use a div with this class instead of hard-coded CSS
  html-class: 'page-break'

  # ODT style used for pagebreak paragraphs
  odt-style: 'Pagebreak'
---

Currently supported options:

Alternative syntax

The form feed character as the only element in a paragraph is supported as an alternative to the LaTeX syntax described above. See Configuration for info on how to enable this feature.