From: Christian Moe <mail@christianmoe.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Christian Moe <mail@christianmoe.com>,
jman <emacs-orgmode@city17.xyz>,
emacs-orgmode@gnu.org
Subject: Re: Understanding Publish (ox-publish.el)
Date: Mon, 21 Oct 2024 09:07:06 +0200 [thread overview]
Message-ID: <874j5526uq.fsf@christianmoe.com> (raw)
In-Reply-To: <87ed4bq62f.fsf@localhost>
Ihor Radchenko <yantar92@posteo.net> writes:
> Christian Moe <mail@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
next prev parent reply other threads:[~2024-10-21 8:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-13 19:25 Understanding Publish (ox-publish.el) jman
2024-10-14 8:37 ` Christian Moe
2024-10-14 15:40 ` jman
2024-10-14 18:47 ` jman
2024-10-14 21:06 ` Christian Moe
2024-10-15 7:13 ` jman
2024-10-15 8:11 ` Christian Moe
2024-10-15 11:54 ` Rens Oliemans
2024-10-20 13:04 ` Ihor Radchenko
2024-10-21 7:07 ` Christian Moe [this message]
2024-10-26 17:38 ` Ihor Radchenko
2024-10-14 10:02 ` Dr. Arne Babenhauserheide
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874j5526uq.fsf@christianmoe.com \
--to=mail@christianmoe.com \
--cc=emacs-orgmode@city17.xyz \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).