So I’ve been looking everywhere for a solution to this: When I export my notes as PDF it puts page breaks wherever, even right after headings, which is really annoying.
How can I prohibit page breaks after headings in PDF export?
Things I have tried
I’ve tried various CSS snippets similar to the one below.
I have tried various combinations of page-break-after and just break-after and different types of selecting the tags, none of which did work.
Also, for some reason when verifying the selectors by using color: chocolate; !important, the headings didn’t get colored, but using page-break-before: always did. Maybe that has something to do with it?
Create a note where a (h2) heading is at the end of a page when exported.
Add the following snippet:
h2 {
break-after: avoid
}
Expected result
I expected the pdf export not to place a page break between the h2 and the text below it.
Actual result
The snippet has no effect.
Environment
Operating system: Linux (PopOS 22.04)
Debug info:
SYSTEM INFO:
Obsidian version: v1.1.16
Installer version: v1.1.15
Operating system: #202302091138~1675975749~22.04~f771a7f SMP PREEMPT_DYNAMIC Thu F 6.1.11-76060111-generic
Login status: logged in
Catalyst license: none
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 1
Restricted mode: off
Plugins installed: 0
Plugins enabled: 0