Re: [O] Force new page on exporting
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
Re: [O] Force new page on exporting
On Mon, Jun 30, 2014 at 11:00 PM, Thomas S. Dye t...@tsdye.com wrote: Aloha York, York Zhao gtdplatf...@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 t...@tsdye.com wrote: Aloha York, York Zhao gtdplatf...@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
Re: [O] Force new page on exporting
York Zhao gtdplatf...@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.
Re: [O] Force new page on exporting
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?
Re: [O] Force new page on exporting
Aloha York, York Zhao gtdplatf...@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
Re: [O] Force new page on exporting
York Zhao gtdplatf...@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.
Re: [O] Force new page on exporting
Aloha John, John Hendy jw.he...@gmail.com writes: On Mon, Jun 30, 2014 at 11:00 PM, Thomas S. Dye t...@tsdye.com wrote: Aloha York, York Zhao gtdplatf...@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
Re: [O] Force new page on exporting
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.
Re: [O] Force new page on exporting
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)
[O] Force new page on exporting
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
Re: [O] Force new page on exporting
Aloha York, York Zhao gtdplatf...@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
Re: [O] Force new page on exporting
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 t...@tsdye.com wrote: Aloha York, York Zhao gtdplatf...@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
Re: [O] Force new page on exporting
Aloha York, York Zhao gtdplatf...@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 t...@tsdye.com wrote: Aloha York, York Zhao gtdplatf...@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