I spoke too early - if I have two headings with :newpage: tag in a row, my
current code below skips the second heading.
It seems (setq org-map-continue-from (outline-next-heading)) in my code is the
problem .. any help will be appreciated!
(defun org/parse-headings-newpage (backend)
; add \newpage to headings with :newpage: tag
(if (member backend '(latex))
(org-map-entries
(lambda ()
(insert-string "#+LATEX: \\newpage\n")
(if (outline-next-heading)
(setq org-map-continue-from (outline-next-heading)))
)
"+newpage"))
)
(add-hook 'org-export-before-parsing-hook 'org/parse-headings-newpage)
________________________________
From: Emacs-orgmode <[email protected]> on
behalf of Joon Ro <[email protected]>
Sent: Wednesday, February 8, 2017 8:58:40 PM
To: Nick Dokos; [email protected]
Subject: Re: [O] Adding #+LATEX: \newpage before section header using
org-export-before-parsing-hook
> So you'll have to manipulate org-map-continue-from appropriately.
Thanks a lot! Adding (setq org-map-continue-from (outline-next-heading)) after
insert-string seemed to solve the problem.
(I added "newpage" to org-tags-exclude-from-inheritance, so the newpage does
not get applied to subheadings)
(defun org/parse-headings-latex-newpage (backend)
; add \newpage to headings with :newpage: tag
(if (member backend '(latex))
(org-map-entries
(lambda ()
(progn
(insert-string "#+LATEX: \\newpage\n")
(setq org-map-continue-from (outline-next-heading))
))
"+newpage"))
)
(add-hook 'org-export-before-parsing-hook 'org/parse-headings-latex-newpage)
(add-to-list 'org-tags-exclude-from-inheritance '"newpage")
Best,
Joon