emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Thomas S. Dye" <tsd@tsdye.com>
To: Joon Ro <joon.ro@outlook.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook
Date: Wed, 08 Feb 2017 10:48:47 -1000	[thread overview]
Message-ID: <m2h944quhc.fsf@tsdye.com> (raw)
In-Reply-To: <CY4PR15MB162257957B23344B1822FF17EB420@CY4PR15MB1622.namprd15.prod.outlook.com>

Aloha Joon,

Joon Ro writes:

> Hi,
>
>
> In latex export, sometimes I want to make sure a section starts in a new page.
>
> It seems I should be able to add a hook to org-export-before-parsing-hook, so if it sees a section with :newpage: tag (for example), it adds #+LATEX: \newpage before the section header so I would get
>
>
> \newpage
>
> \section{Section Name}
>
> in the exported file.
>
> I have a couple of hooks already so in general I'm using the following code:
>
>       (org-map-entries
>        (lambda ()
>          (progn
>
>            ))
>        "+newpage")
>
> but I'm not sure how to add #+LATEX: \newpage before the section header - .
>
> Best Regards,
> Joon

I use this:

**** Ignore headline and/or start newpage on export

#+name: ignoreheading-and-or-newpage-on-export
#+BEGIN_SRC emacs-lisp :results silent
  (defun tsd-ignore-headline-and-or-newpage (contents backend info)
    "Ignore headlines with tag `ignoreheading' and/or start
  headline on LaTeX new page with tag `newpage'."
    (cond ((and (org-export-derived-backend-p backend 'latex 'beamer)
                (string-match "\\`.*newpage.*\n" (downcase contents))
                (string-match "\\`.*ignoreheading.*\n" (downcase contents)))
           (replace-match "\\\\newpage" nil nil contents))
          ((and (org-export-derived-backend-p backend 'latex 'html 'ascii 'beamer)
                (string-match "\\`.*ignoreheading.*\n" (downcase contents)))
           (replace-match "" nil nil contents))
          ((and (org-export-derived-backend-p backend 'latex)
                  (string-match "\\(\\`.*\\)newpage\\(.*\n\\)" (downcase contents)))
           (replace-match "\\\\newpage\\1\\2"  nil nil contents))))
  ;; add function to filter list
  ;; (add-to-list 'org-export-filter-headline-functions
  ;;              'tsd-ignore-headline-and-or-newpage)
#+END_SRC

hth,
Tom


--
Thomas S. Dye
http://www.tsdye.com

  parent reply	other threads:[~2017-02-08 20:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 19:52 Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook Joon Ro
2017-02-08 19:53 ` Joon Ro
2017-02-08 20:48 ` Thomas S. Dye [this message]
2017-02-09  0:01   ` Joon Ro
2017-02-09  1:27     ` Nick Dokos
2017-02-09  1:36       ` Eric Abrahamsen
2017-02-09  2:58       ` Joon Ro
2017-02-11 19:40         ` Joon Ro

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=m2h944quhc.fsf@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=joon.ro@outlook.com \
    /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).