From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Thomas S. Dye" Subject: Re: Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook Date: Wed, 08 Feb 2017 10:48:47 -1000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbZAw-0001CO-17 for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 15:49:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbZAr-0004r5-1V for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 15:49:14 -0500 Received: from gproxy9-pub.mail.unifiedlayer.com ([69.89.20.122]:37993 helo=gproxy9.mail.unifiedlayer.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbZAq-0004px-QU for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 15:49:08 -0500 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy9.mail.unifiedlayer.com (Postfix) with ESMTP id EBA351E0804 for ; Wed, 8 Feb 2017 13:48:58 -0700 (MST) In-reply-to: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Joon Ro Cc: "emacs-orgmode@gnu.org" 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