Skip to content
Markdown to PDF

How to Add a Page Break in Markdown (for PDF)

Markdown has no page-break syntax. Here’s how to force a new page — \newpage, HTML and CSS, automatic breaks — in PDF exports and in Pandoc for PDF, Word and HTML.

Updated · 4 min read

Plain Markdown has no concept of pages, so there’s no official page-break syntax. When you export to PDF, though, you often need one: a cover page, chapters, an appendix. Here are the options and when to use each.

1. \newpage on its own line

The simplest option, borrowed from LaTeX and Pandoc:

## Chapter 1

Some text.

\newpage

## Chapter 2

The Markdown to PDF editor also accepts \pagebreak, <!-- pagebreak --> and [pagebreak]. In the live preview you’ll see a dashed “Page break” line where the new page starts.

2. An HTML element with CSS

If your tool doesn’t support \newpage, raw HTML usually works because most converters render through a browser:

<div style="break-after: page"></div>

break-after: page is the modern property; older guides use page-break-after: always, which browsers still understand.

3. Automatic breaks before headings

For long documents it’s easier to let headings decide. In the editor, open Style → Document → Start a new page before and choose Each H1 or H1 & H2. The first heading in the document never gets a blank page before it.

With your own CSS (Style → Custom CSS) you can do the same thing:

.doc h2 { break-before: page; }

4. Page breaks in Pandoc

Pandoc handles page breaks differently for each output format:

PDF (through LaTeX). \newpage on its own line works as-is — Pandoc passes raw LaTeX commands straight through to the PDF engine:

pandoc notes.md -o notes.pdf

Word (.docx). Raw LaTeX is dropped for Word output, so \newpage does nothing. Use a raw OpenXML block instead:

```{=openxml}
<w:p><w:r><w:br w:type="page"/></w:r></w:p>
```

HTML and EPUB. Use the HTML element from option 2 (<div style="break-after: page"></div>); it takes effect when the page is printed or paginated.

One syntax for every format. The pagebreak Lua filter from the pandoc-ext project turns \newpage (or \pagebreak) into the right page break for LaTeX, Word, HTML and EPUB — ODT works too with a small style in the reference document — so the same Markdown works everywhere:

pandoc notes.md --lua-filter=pagebreak.lua -o notes.docx

Keeping things together

The opposite problem — content splitting badly — is handled automatically:

  • headings stay with the paragraph that follows them,
  • table rows, short code blocks, diagrams, equations and callouts aren’t split,
  • table headers repeat on every page when a long table continues.

To keep a specific block together, wrap it:

<div style="break-inside: avoid">

…content that must stay on one page…

</div>

Looking for a line across the page rather than a new page? That’s a horizontal rule — see Markdown line breaks and horizontal lines.

Quick reference

You want Use
Force a new page here \newpage
Every chapter on a new page Style → Start a new page before → Each H1
Keep a block on one page <div style="break-inside: avoid">
A cover page Front matter title: + Style → Cover page
A page break in Pandoc → Word A {=openxml} block, or \newpage with the pagebreak filter

Try it on your own document

Free, private and right in your browser — no signup.

Open the editor