* Force new page on exporting @ 2014-06-30 23:37 York Zhao 2014-07-01 0:49 ` Thomas S. Dye 0 siblings, 1 reply; 14+ messages in thread From: York Zhao @ 2014-06-30 23:37 UTC (permalink / raw) To: emacs-orgmode I'm selectively exporting some subtree of an org-mode buffer, like this: * Headline1 :export: * Headline2 * Headline3 :export: Question is: how do I force Headline3 to be on a new page while exporting to LaTeX? Thanks in advance ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-06-30 23:37 Force new page on exporting York Zhao @ 2014-07-01 0:49 ` Thomas S. Dye 2014-07-01 2:13 ` York Zhao 0 siblings, 1 reply; 14+ messages in thread From: Thomas S. Dye @ 2014-07-01 0:49 UTC (permalink / raw) To: York Zhao; +Cc: emacs-orgmode Aloha York, York Zhao <gtdplatform@gmail.com> writes: > I'm selectively exporting some subtree of an org-mode buffer, like this: > > * Headline1 :export: #+latex: \newpage > * Headline2 > * Headline3 :export: > > Question is: how do I force Headline3 to be on a new page while exporting to > LaTeX? hth, Tom -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 0:49 ` Thomas S. Dye @ 2014-07-01 2:13 ` York Zhao 2014-07-01 4:00 ` Thomas S. Dye 0 siblings, 1 reply; 14+ messages in thread From: York Zhao @ 2014-07-01 2:13 UTC (permalink / raw) To: Thomas S. Dye; +Cc: emacs-orgmode Thanks Thomas. This works but is not an ideal approach because in a complex file it may not be so easy to find out the location to insert the "\newpage" instruction. Plus, each time when inserting new exported tree between "Headline1" and "Headline2" you would have to remember to move the "\newpage" to the end of the new tree. On Mon, Jun 30, 2014 at 8:49 PM, Thomas S. Dye <tsd@tsdye.com> wrote: > Aloha York, > > York Zhao <gtdplatform@gmail.com> writes: > >> I'm selectively exporting some subtree of an org-mode buffer, like this: >> >> * Headline1 :export: > > #+latex: \newpage > >> * Headline2 >> * Headline3 :export: >> >> Question is: how do I force Headline3 to be on a new page while exporting to >> LaTeX? > > hth, > Tom > > -- > Thomas S. Dye > http://www.tsdye.com ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 2:13 ` York Zhao @ 2014-07-01 4:00 ` Thomas S. Dye 2014-07-01 14:45 ` York Zhao 2014-07-01 15:06 ` John Hendy 0 siblings, 2 replies; 14+ messages in thread From: Thomas S. Dye @ 2014-07-01 4:00 UTC (permalink / raw) To: York Zhao; +Cc: emacs-orgmode Aloha York, York Zhao <gtdplatform@gmail.com> writes: > Thanks Thomas. This works but is not an ideal approach because in a complex file > it may not be so easy to find out the location to insert the "\newpage" > instruction. Plus, each time when inserting new exported tree between > "Headline1" and "Headline2" you would have to remember to move the "\newpage" to > the end of the new tree. Agreed. Something like this is more visible. * Latex New Page :ignoreheading: #+latex: \newpage Also, see the LaTeX commands \pagebreak and \clearpage, which do generally the same thing but in slightly different ways. hth, Tom > > On Mon, Jun 30, 2014 at 8:49 PM, Thomas S. Dye <tsd@tsdye.com> wrote: >> Aloha York, >> >> York Zhao <gtdplatform@gmail.com> writes: >> >>> I'm selectively exporting some subtree of an org-mode buffer, like this: >>> >>> * Headline1 :export: >> >> #+latex: \newpage >> >>> * Headline2 >>> * Headline3 :export: >>> >>> Question is: how do I force Headline3 to be on a new page while exporting to >>> LaTeX? >> >> hth, >> Tom >> >> -- >> Thomas S. Dye >> http://www.tsdye.com > > -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 4:00 ` Thomas S. Dye @ 2014-07-01 14:45 ` York Zhao 2014-07-01 15:30 ` Nick Dokos 2014-07-01 16:12 ` Thomas S. Dye 2014-07-01 15:06 ` John Hendy 1 sibling, 2 replies; 14+ messages in thread From: York Zhao @ 2014-07-01 14:45 UTC (permalink / raw) To: Thomas S. Dye; +Cc: emacs-orgmode > * Latex New Page :ignoreheading: > #+latex: \newpage This should work, but didn't, I will figure out why when I have some time. > Also, see the LaTeX commands \pagebreak and \clearpage, which do generally the > same thing but in slightly different ways. I was aware of these, but if \newpage doesn't work I don't think these will work. But thank you very much anyway. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 14:45 ` York Zhao @ 2014-07-01 15:30 ` Nick Dokos 2014-07-01 15:52 ` York Zhao 2014-07-01 16:12 ` Thomas S. Dye 1 sibling, 1 reply; 14+ messages in thread From: Nick Dokos @ 2014-07-01 15:30 UTC (permalink / raw) To: emacs-orgmode York Zhao <gtdplatform@gmail.com> writes: >> * Latex New Page :ignoreheading: >> #+latex: \newpage > > This should work, but didn't, I will figure out why when I have some time. > My understanding is that you need extra machinery to implement "ignoreheading": some sort of a filter[fn:1] is necessary, is this correct? Maybe that's what you are missing. Nick Footnotes: [fn:1] à la Suvayu or otherwise - there was some ML discussion recently that I glanced over briefly, but I skipped over most of it. Apologies if I've misunderstoof. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 15:30 ` Nick Dokos @ 2014-07-01 15:52 ` York Zhao 2014-07-01 16:21 ` Nick Dokos 0 siblings, 1 reply; 14+ messages in thread From: York Zhao @ 2014-07-01 15:52 UTC (permalink / raw) To: Nick Dokos; +Cc: emacs-orgmode > My understanding is that you need extra machinery to implement "ignoreheading" I had implemented machinery the "ignoreheading" and posted the code in the post "Wrong numbering after removal of headline". But anyways here's my code: (defun yz/org-export-process-heading-removal (backend) "Ignore headlines with tag `ignoreheading'." (save-excursion (let ((org-allow-promoting-top-level-subtree t)) (org-map-entries (lambda () (when (member "removeheading" (org-get-local-tags)) (org-promote-subtree) (delete-region (line-beginning-position) (progn (forward-line) (point))))))))) (add-hook 'org-export-before-parsing-hook #'yz/org-export-process-heading-removal) This code worked for ignoring the headline with tag "removeheading", and did re-numbering all the headlines properly. But: * Latex New Page :ignoreheading: #+latex: \newpage Still didn't work which I have no idea at this moment yet. Any idea? ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 15:52 ` York Zhao @ 2014-07-01 16:21 ` Nick Dokos 2014-07-01 16:59 ` York Zhao 0 siblings, 1 reply; 14+ messages in thread From: Nick Dokos @ 2014-07-01 16:21 UTC (permalink / raw) To: emacs-orgmode York Zhao <gtdplatform@gmail.com> writes: >> My understanding is that you need extra machinery to implement "ignoreheading" > > I had implemented machinery the "ignoreheading" and posted the code in the post > "Wrong numbering after removal of headline". But anyways here's my code: > > (defun yz/org-export-process-heading-removal (backend) > "Ignore headlines with tag `ignoreheading'." > (save-excursion > (let ((org-allow-promoting-top-level-subtree t)) > (org-map-entries > (lambda () > (when (member "removeheading" (org-get-local-tags)) > (org-promote-subtree) > (delete-region (line-beginning-position) > (progn (forward-line) (point))))))))) > > (add-hook 'org-export-before-parsing-hook > #'yz/org-export-process-heading-removal) > > This code worked for ignoring the headline with tag "removeheading", and did > re-numbering all the headlines properly. But: > > * Latex New Page :ignoreheading: > #+latex: \newpage > > Still didn't work which I have no idea at this moment yet. Any idea? So before parsing, you are getting rid of the "ignoreheading" [fn:1] headline (first, "promoting" it to a comment and then deleting the region), so the #+latex: \newpage line now belongs to headline 2 which is then parsed and discarded. I think you need a filter after parsing (which of course conflicts with your need in the "Wrong numbering..." thread). Footnotes: [fn:1] there is a "removeheading" vs "ignoreheading" inconsistency, btw. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 16:21 ` Nick Dokos @ 2014-07-01 16:59 ` York Zhao 2014-07-01 18:22 ` York Zhao 0 siblings, 1 reply; 14+ messages in thread From: York Zhao @ 2014-07-01 16:59 UTC (permalink / raw) To: Nick Dokos; +Cc: emacs-orgmode > So before parsing, you are getting rid of the "ignoreheading" headline (first, > "promoting" it to a comment and then deleting the region), so the #+latex: > \newpage line now belongs to headline 2 which is then parsed and discarded. Really great catch Nick, exactly as what you pointed out. Saved me some time on investigating, thanks. > I think you need a filter after parsing (which of course conflicts with > your need in the "Wrong numbering..." thread). Yes, like you said before, using filter is too late because the contents is already LaTeX content and it's impossible to prompt the tree any more. > [fn:1] there is a "removeheading" vs "ignoreheading" inconsistency, btw. I'm sorry for the confusion. I changed the tag name from "ignoreheadline" to "remomeheading" in my implementation. @Thomas, I was using `org-export-filter-headline-functions' before but like Nick and I said, it was not capable of promoting the subtree after removing the headline, which is why I discarded it and used my implementation. Maybe I will implement some addition machinery in the "org-export-before-parsing-hook" when I get some time to handle this new page thing. I will update here once that gets done. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 16:59 ` York Zhao @ 2014-07-01 18:22 ` York Zhao 2014-07-03 16:55 ` York Zhao 0 siblings, 1 reply; 14+ messages in thread From: York Zhao @ 2014-07-01 18:22 UTC (permalink / raw) To: Nick Dokos; +Cc: emacs-orgmode OK, hacked `org-export-filter-headline-functions' and added the facility to force exporting a headline on new page by adding a new tag "newpage" to the headline. Here is the code: (defun yz/org-export-headline-on-new-page (contents backend info) "Export headlines with tag `newpage' on new pages." (when (org-export-derived-backend-p backend 'latex) (with-temp-buffer (insert contents) (goto-char (point-min)) (let ((case-fold-search t)) (when (re-search-forward "^\\\\section{.*\\(\\\\.*{newpage}\\).*\n" nil 'noerror) (replace-match "" nil nil nil 1) ; Delete the "newpage" tag (forward-line -1) (insert "\\newpage\n") (setq contents (buffer-substring (point-min) (point-max)))))))) (add-to-list 'org-export-filter-headline-functions #'yz/org-export-headline-on-new-page) ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 18:22 ` York Zhao @ 2014-07-03 16:55 ` York Zhao 0 siblings, 0 replies; 14+ messages in thread From: York Zhao @ 2014-07-03 16:55 UTC (permalink / raw) To: Nick Dokos; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 728 bytes --] Thought I should post an update to fix a regexp problem, hopfully somebody else will find it useful. (defun yz/org-export-headline-on-new-page (contents backend info) "Export headlines with tag `newpage' on new pages." (when (org-export-derived-backend-p backend 'latex) (with-temp-buffer (insert contents) (goto-char (point-min)) (let ((case-fold-search t)) (when (re-search-forward "^\\\\\\(?:sub\\)?section{.*\\(\\\\.*{newpage}\\).*$" nil 'noerror) (replace-match "" nil nil nil 1) ; Delete the "newpage" tag (forward-line -1) (insert "\\newpage\n") (setq contents (buffer-substring (point-min) (point-max)))))))) York [-- Attachment #2: Type: text/html, Size: 992 bytes --] ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 14:45 ` York Zhao 2014-07-01 15:30 ` Nick Dokos @ 2014-07-01 16:12 ` Thomas S. Dye 1 sibling, 0 replies; 14+ messages in thread From: Thomas S. Dye @ 2014-07-01 16:12 UTC (permalink / raw) To: York Zhao; +Cc: emacs-orgmode Aloha York, York Zhao <gtdplatform@gmail.com> writes: >> * Latex New Page :ignoreheading: >> #+latex: \newpage > > This should work, but didn't, I will figure out why when I have some time. > >> Also, see the LaTeX commands \pagebreak and \clearpage, which do generally the >> same thing but in slightly different ways. > > I was aware of these, but if \newpage doesn't work I don't think these will > work. But thank you very much anyway. This works for me. I'm using Suvayu Ali's function to ignore the headline: #+name: ignoreheading-on-export #+BEGIN_SRC emacs-lisp :results silent (defun sa-ignore-headline (contents backend info) "Ignore headlines with tag `ignoreheading'." (when (and (org-export-derived-backend-p backend 'latex 'html 'ascii) (string-match "\\`.*ignoreheading.*\n" (downcase contents))) (replace-match "" nil nil contents))) (add-to-list 'org-export-filter-headline-functions 'sa-ignore-headline) #+END_SRC hth, Tom -- T.S. Dye & Colleagues, Archaeologists 735 Bishop St, Suite 315, Honolulu, HI 96813 Tel: 808-529-0866, Fax: 808-529-0884 http://www.tsdye.com ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 4:00 ` Thomas S. Dye 2014-07-01 14:45 ` York Zhao @ 2014-07-01 15:06 ` John Hendy 2014-07-01 16:31 ` Thomas S. Dye 1 sibling, 1 reply; 14+ messages in thread From: John Hendy @ 2014-07-01 15:06 UTC (permalink / raw) To: Thomas S. Dye; +Cc: York Zhao, emacs-orgmode On Mon, Jun 30, 2014 at 11:00 PM, Thomas S. Dye <tsd@tsdye.com> wrote: > Aloha York, > > York Zhao <gtdplatform@gmail.com> writes: > >> Thanks Thomas. This works but is not an ideal approach because in a complex file >> it may not be so easy to find out the location to insert the "\newpage" >> instruction. Plus, each time when inserting new exported tree between >> "Headline1" and "Headline2" you would have to remember to move the "\newpage" to >> the end of the new tree. > > > Agreed. Something like this is more visible. > > * Latex New Page :ignoreheading: > #+latex: \newpage > Clever! I was trying to think of a way to do it within headline 3, but get it to break before the actual section heading... this much better. One question, say the following occurs: * Heading 1 :export: ... * Heading 2 * Latex New Page :ignoreheading:export: #+latex: \newpage * Heading 3 :export: ... Say that with \maketitle and possible TOC, Heading 1 ends exactly on the last line of page 1. Won't the \newpage command create a full blank page on page 2, with Heading 3 starting on page 3? Rare situation, but just thought I'd inquire about the possibility. John > Also, see the LaTeX commands \pagebreak and \clearpage, which do > generally the same thing but in slightly different ways. > > hth, > Tom > >> >> On Mon, Jun 30, 2014 at 8:49 PM, Thomas S. Dye <tsd@tsdye.com> wrote: >>> Aloha York, >>> >>> York Zhao <gtdplatform@gmail.com> writes: >>> >>>> I'm selectively exporting some subtree of an org-mode buffer, like this: >>>> >>>> * Headline1 :export: >>> >>> #+latex: \newpage >>> >>>> * Headline2 >>>> * Headline3 :export: >>>> >>>> Question is: how do I force Headline3 to be on a new page while exporting to >>>> LaTeX? >>> >>> hth, >>> Tom >>> >>> -- >>> Thomas S. Dye >>> http://www.tsdye.com >> >> > > -- > Thomas S. Dye > http://www.tsdye.com > ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Force new page on exporting 2014-07-01 15:06 ` John Hendy @ 2014-07-01 16:31 ` Thomas S. Dye 0 siblings, 0 replies; 14+ messages in thread From: Thomas S. Dye @ 2014-07-01 16:31 UTC (permalink / raw) To: John Hendy; +Cc: York Zhao, emacs-orgmode Aloha John, John Hendy <jw.hendy@gmail.com> writes: > On Mon, Jun 30, 2014 at 11:00 PM, Thomas S. Dye <tsd@tsdye.com> wrote: >> Aloha York, >> >> York Zhao <gtdplatform@gmail.com> writes: >> >>> Thanks Thomas. This works but is not an ideal approach because in a complex file >>> it may not be so easy to find out the location to insert the "\newpage" >>> instruction. Plus, each time when inserting new exported tree between >>> "Headline1" and "Headline2" you would have to remember to move the "\newpage" to >>> the end of the new tree. >> >> >> Agreed. Something like this is more visible. >> >> * Latex New Page :ignoreheading: >> #+latex: \newpage >> > > Clever! I was trying to think of a way to do it within headline 3, but > get it to break before the actual section heading... this much better. > One question, say the following occurs: > > * Heading 1 :export: ... > * Heading 2 > * Latex New Page :ignoreheading:export: > #+latex: \newpage > > * Heading 3 :export: ... > > Say that with \maketitle and possible TOC, Heading 1 ends exactly on > the last line of page 1. Won't the \newpage command create a full > blank page on page 2, with Heading 3 starting on page 3? > > Rare situation, but just thought I'd inquire about the possibility. I don't think this is a problem. The LaTeX \newpage command requires some content on the page before it will work. If it is the first thing on the page, then no new page is created. All the best, Tom -- Thomas S. Dye http://www.tsdye.com ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-07-03 16:55 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-06-30 23:37 Force new page on exporting York Zhao 2014-07-01 0:49 ` Thomas S. Dye 2014-07-01 2:13 ` York Zhao 2014-07-01 4:00 ` Thomas S. Dye 2014-07-01 14:45 ` York Zhao 2014-07-01 15:30 ` Nick Dokos 2014-07-01 15:52 ` York Zhao 2014-07-01 16:21 ` Nick Dokos 2014-07-01 16:59 ` York Zhao 2014-07-01 18:22 ` York Zhao 2014-07-03 16:55 ` York Zhao 2014-07-01 16:12 ` Thomas S. Dye 2014-07-01 15:06 ` John Hendy 2014-07-01 16:31 ` Thomas S. Dye
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).