Ihor Radchenko <yanta...@posteo.net> writes:
> Christian Moe <m...@christianmoe.com> writes: > >> It's due to Latex refusing to commit the typographic crime of leaving a >> heading at the bottom of the page. >> ... > > and is committing another typographic crime :) > I am wondering if this may somehow be addressed. Indeed. The best place to address it would be in Latex, I suppose. Kind of surprising that it hasn't been. I don't suppose there's any way for Org to know beforehand how much space an empty outline will take on the PDF page. But Org could perhaps just check the outline and insert a page break every so often after a run of empty headers? Something like this hook: #+BEGIN_SRC elisp (defvar my/org-latex-pagebreak-every 20 "Number of empty (sub)headings after which to insert pagebreak.") (defun my/org-latex-insert-pagebreaks (backend) "Insert page breaks in an empty outline on LaTeX export. A page break is inserted for every nth consecutive empty (sub)heading, where n is given by `my/org-latex-pagebreak-after', to allow an empty outline to break gracefully in PDF export." (when (eq backend 'latex) (let ((c 0)) (org-map-entries (lambda () ;; if entry is empty (unless (string-match (org-get-entry) "[[:graph:]]") (setq c (1+ c)) (when (= c my/org-latex-pagebreak-every) (setq c 0) ; reset counter (org-end-of-line) (insert "\n\\clearpage\n")))))))) (add-hook 'org-export-before-parsing-functions #'my/org-latex-insert-pagebreaks) #+END_SRC Yours, Christian