emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Collapse LaTeX source before start of main document?
@ 2011-05-04 15:36 Chris Malone
  2011-05-04 16:18 ` Matt Lundin
  2011-05-04 22:25 ` Suvayu Ali
  0 siblings, 2 replies; 18+ messages in thread
From: Chris Malone @ 2011-05-04 15:36 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1864 bytes --]

Hi All,

I'm working on using org mode for my PhD thesis.  I'd like to do this in one
large file where each headline is a single chapter.  Naturally in a thesis
there needs to be a lot of front matter: title page, abstract, signature
page, etc.  Right now, I'm doing this with something like:

----------------------------------------------------------------------------------------------------------
#+begin_latex


\doublespacing


\pagenumbering{roman}




\maketitle


\makeapproval




\begin{abstract}

     blah blah blah....

\end{abstract}




\tableofcontents




\pagestyle{thesis}


\newpage


\pagenumbering{arabic}

#+end_latex

* Test Chapter 1
This is a test.
----------------------------------------------------------------------------------------------------------

When I include the actual contents of my abstract, this preliminary material
section (the #+begin ... #+end block) is rather large.  I'd like to be able
to put this material into a headline so that I could collapse it - but I
don't want this headline exported as content of the main document.

In other words, is there a property or tag that I can add to a headline that
causes LaTeX export to ignore the fact that it is a headline (i.e. \chapter,
\section, \subsection, etc.), but still export its contents?  Something
like:

----------------------------------------------------------------------------------------------------------
* This is just preliminary material             :prelim:
#+begin_latex


\doublespacing


\pagenumbering{roman}




\maketitle


\makeapproval




\begin{abstract}

     blah blah blah....

\end{abstract}




\tableofcontents




\pagestyle{thesis}


\newpage


\pagenumbering{arabic}

#+end_latex

* Test Chapter 1
This is a test.
----------------------------------------------------------------------------------------------------------

Chris

[-- Attachment #2: Type: text/html, Size: 7105 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-04 15:36 Collapse LaTeX source before start of main document? Chris Malone
@ 2011-05-04 16:18 ` Matt Lundin
  2011-05-04 18:05   ` Chris Malone
  2014-06-06 17:03   ` Eric Schulte
  2011-05-04 22:25 ` Suvayu Ali
  1 sibling, 2 replies; 18+ messages in thread
From: Matt Lundin @ 2011-05-04 16:18 UTC (permalink / raw)
  To: Chris Malone; +Cc: emacs-orgmode

Chris Malone <chris.m.malone@gmail.com> writes:

(Note: When using gmail, please adjust the settings to send your
messages as plain text only instead of multipart/alternative.)

> When I include the actual contents of my abstract, this preliminary material
> section (the #+begin ... #+end block) is rather large.  I'd like to be able
> to put this material into a headline so that I could collapse it - but I
> don't want this headline exported as content of the main document.
>
> In other words, is there a property or tag that I can add to a headline that
> causes LaTeX export to ignore the fact that it is a headline (i.e. \chapter,
> \section, \subsection, etc.), but still export its contents?  Something
> like:

You could add a hook to remove headlines with a "prelim" tag:

--8<---------------cut here---------------start------------->8---
(defun my-org-export-remove-tagged-headlines (tag)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward (concat ":" tag ":") nil t)
      (delete-region (point-at-bol) (point-at-eol)))))

(add-hook 'org-export-preprocess-hook (lambda () (my-org-export-remove-tagged-headlines "prelim")))
--8<---------------cut here---------------end--------------->8---

Best,
Matt

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-04 16:18 ` Matt Lundin
@ 2011-05-04 18:05   ` Chris Malone
  2011-05-04 22:23     ` Matt Lundin
  2014-06-06 17:03   ` Eric Schulte
  1 sibling, 1 reply; 18+ messages in thread
From: Chris Malone @ 2011-05-04 18:05 UTC (permalink / raw)
  To: Matt Lundin; +Cc: emacs-orgmode

Hi Matt,

Sorry for the non-plain text...

I added your suggestion to my .emacs but upon export it removed the
entire block, which is odd based on the source code for the
function...

Anyway, I found another solution that now seems obvious: the
#+begin...#+end blocks themselves can be folded by either hitting TAB
on the #+begin line, or by setting the =org-hide-block-startup=
variable.

Chris

On Wed, May 4, 2011 at 12:18 PM, Matt Lundin <mdl@imapmail.org> wrote:
>
> Chris Malone <chris.m.malone@gmail.com> writes:
>
> (Note: When using gmail, please adjust the settings to send your
> messages as plain text only instead of multipart/alternative.)
>
> > When I include the actual contents of my abstract, this preliminary material
> > section (the #+begin ... #+end block) is rather large.  I'd like to be able
> > to put this material into a headline so that I could collapse it - but I
> > don't want this headline exported as content of the main document.
> >
> > In other words, is there a property or tag that I can add to a headline that
> > causes LaTeX export to ignore the fact that it is a headline (i.e. \chapter,
> > \section, \subsection, etc.), but still export its contents?  Something
> > like:
>
> You could add a hook to remove headlines with a "prelim" tag:
>
> --8<---------------cut here---------------start------------->8---
> (defun my-org-export-remove-tagged-headlines (tag)
>  (save-excursion
>    (goto-char (point-min))
>    (while (re-search-forward (concat ":" tag ":") nil t)
>      (delete-region (point-at-bol) (point-at-eol)))))
>
> (add-hook 'org-export-preprocess-hook (lambda () (my-org-export-remove-tagged-headlines "prelim")))
> --8<---------------cut here---------------end--------------->8---
>
> Best,
> Matt

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-04 18:05   ` Chris Malone
@ 2011-05-04 22:23     ` Matt Lundin
  2012-09-27  9:07       ` Renier Marchand
  0 siblings, 1 reply; 18+ messages in thread
From: Matt Lundin @ 2011-05-04 22:23 UTC (permalink / raw)
  To: Chris Malone; +Cc: emacs-orgmode

Chris Malone <chris.m.malone@gmail.com> writes:
>
> I added your suggestion to my .emacs but upon export it removed the
> entire block, which is odd based on the source code for the
> function...

Hmm... That's not my experience.

When I export the following file...

--8<---------------cut here---------------start------------->8---
* Preliminary material						     :prelim:

Some preliminary material

* Point one

Text in point one

* Point two							     :prelim:

Text in point two.

* Point three

Text in point three.
--8<---------------cut here---------------end--------------->8---

The resulting html looks like this (rendered in w3m)...

--8<---------------cut here---------------start------------->8---
Some preliminary material

Table of Contents

  * 1 Point one
  * 2 Point three

1 Point one

Text in point one

Text in point two.

2 Point three

Text in point three.

Date: 2011-05-04 18:22:09 EDT

Author: Matt Lundin

Org version 7.5 with Emacs version 24

Validate XHTML 1.0
--8<---------------cut here---------------end--------------->8---

Best,
Matt

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-04 15:36 Collapse LaTeX source before start of main document? Chris Malone
  2011-05-04 16:18 ` Matt Lundin
@ 2011-05-04 22:25 ` Suvayu Ali
  2011-05-05 14:23   ` Chris Malone
  1 sibling, 1 reply; 18+ messages in thread
From: Suvayu Ali @ 2011-05-04 22:25 UTC (permalink / raw)
  To: emacs-orgmode

Hi Chris,

I just finished writing my master's thesis in org-mode.

On Wed, 4 May 2011 11:36:58 -0400
Chris Malone <chris.m.malone@gmail.com> wrote:

> I'm working on using org mode for my PhD thesis.  I'd like to do this
> in one large file where each headline is a single chapter.  Naturally
> in a thesis there needs to be a lot of front matter: title page,
> abstract, signature page, etc.  Right now, I'm doing this with
> something like:

For all formatting stuff, I just used

#+LaTeX_HEADER: \whatever{}
#+LaTeX_HEADER: \usepackage{universitystyle}

For my abstract I used

#+LaTeX_HEADER: \include{abstract}

where abstract.tex is a simple tex file with something like:

\abstract{ My abstract }

If you wish to include this inside the \begin{document}..\end{document}
block then you can use the same latex snippet but without
the "#+LaTeX_HEADER:".

I hope this helps and good luck with the thesis. :)

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-04 22:25 ` Suvayu Ali
@ 2011-05-05 14:23   ` Chris Malone
  2011-05-05 14:46     ` Suvayu Ali
  2011-05-06 12:34     ` Matt Lundin
  0 siblings, 2 replies; 18+ messages in thread
From: Chris Malone @ 2011-05-05 14:23 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: emacs-orgmode

Hi Matt and Suvayu,

@Matt: I can get your example to work fine for html export, but not
LaTeX export where the entire contents of the headline are removed as
well.  =org-version=:  7.5 (release_7.5.105.g8d0c) if that makes any
difference.

@Suvayu: Thanks for the suggestion.  That is essentially what I am
doing now with the #+LaTeX_HEADER lines, but the problem is that I
have a bunch of things which must follow the \begin{document} in
LaTeX.  I know I could put this in a separate file and just \input{}
it; I wanted to see if there was a way to keep everything together in
a single file, but also have the ability to fold this preliminary
stuff.

Chris

On Wed, May 4, 2011 at 6:25 PM, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> Hi Chris,
>
> I just finished writing my master's thesis in org-mode.
>
> On Wed, 4 May 2011 11:36:58 -0400
> Chris Malone <chris.m.malone@gmail.com> wrote:
>
>> I'm working on using org mode for my PhD thesis.  I'd like to do this
>> in one large file where each headline is a single chapter.  Naturally
>> in a thesis there needs to be a lot of front matter: title page,
>> abstract, signature page, etc.  Right now, I'm doing this with
>> something like:
>
> For all formatting stuff, I just used
>
> #+LaTeX_HEADER: \whatever{}
> #+LaTeX_HEADER: \usepackage{universitystyle}
>
> For my abstract I used
>
> #+LaTeX_HEADER: \include{abstract}
>
> where abstract.tex is a simple tex file with something like:
>
> \abstract{ My abstract }
>
> If you wish to include this inside the \begin{document}..\end{document}
> block then you can use the same latex snippet but without
> the "#+LaTeX_HEADER:".
>
> I hope this helps and good luck with the thesis. :)
>
> --
> Suvayu
>
> Open source is the future. It sets us free.
>
>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-05 14:23   ` Chris Malone
@ 2011-05-05 14:46     ` Suvayu Ali
  2011-05-05 15:37       ` Chris Malone
  2011-05-06 12:34     ` Matt Lundin
  1 sibling, 1 reply; 18+ messages in thread
From: Suvayu Ali @ 2011-05-05 14:46 UTC (permalink / raw)
  To: Chris Malone; +Cc: emacs-orgmode

Hi Chris,

On Thu, 5 May 2011 10:23:50 -0400
Chris Malone <chris.m.malone@gmail.com> wrote:

> @Suvayu: Thanks for the suggestion.  That is essentially what I am
> doing now with the #+LaTeX_HEADER lines, but the problem is that I
> have a bunch of things which must follow the \begin{document} in
> LaTeX.  I know I could put this in a separate file and just \input{}
> it; I wanted to see if there was a way to keep everything together in
> a single file, but also have the ability to fold this preliminary
> stuff.
> 

In the last few months I realised it is rather difficult with export
of org files if you deviate from the "everything is an outline
paradigm". The only effective way around the problem seems to be
including from separate files, either org or tex files (for latex
export).

For example for my appendix and bibliography I use the following:

#+INCLUDE: thesis-appendix.org :minlevel 1

\backmatter
\newpage
\addcontentsline{toc}{chapter}{\bibname}

\bibliographystyle{plain}
\bibliography{master}

where thesis-appendix.org looks something like:

\appendix
\appendixpage
\addappheadtotoc

* First appendix

* Second appendix

I wish there was a cleaner solution too. :-/

> Chris

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-05 14:46     ` Suvayu Ali
@ 2011-05-05 15:37       ` Chris Malone
  2011-05-05 17:37         ` Suvayu Ali
  0 siblings, 1 reply; 18+ messages in thread
From: Chris Malone @ 2011-05-05 15:37 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: emacs-orgmode

Hi Suvayu,

Thanks for sharing your use case - I'm interested in a few more details:

> For example for my appendix and bibliography I use the following:
>
> #+INCLUDE: thesis-appendix.org :minlevel 1
>
> \backmatter
> \newpage
> \addcontentsline{toc}{chapter}{\bibname}
>
> \bibliographystyle{plain}
> \bibliography{master}
>
> where thesis-appendix.org looks something like:
>
> \appendix
> \appendixpage
> \addappheadtotoc
>
> * First appendix
>
> * Second appendix
>

Would this #+INCLUDE line come within the last chapter headline?  In
other words did you have something like

-------------------------------------------------------------------------------------------------------
#+INCLUDE: frontmatter.org
* Chapter 1
....
* Chapter 2
...
* Last Chapter
....
#+INCLUDE: thesis-appendix.org :minlevel 1
.
.
.
\bibliography{master}
--------------------------------------------------------------------------------------------------------

With this, it seems that all of the appendix/backmatter gets folded
into the last chapter heading.  That is sort of the way I'm thinking
of working my thesis, but it seems sub-optimal.

Chris

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-05 15:37       ` Chris Malone
@ 2011-05-05 17:37         ` Suvayu Ali
  2011-05-05 17:45           ` chris.m.malone
  0 siblings, 1 reply; 18+ messages in thread
From: Suvayu Ali @ 2011-05-05 17:37 UTC (permalink / raw)
  To: Chris Malone; +Cc: emacs-orgmode

Hello Chris,

Sorry for the delay, had to attend a meeting.

On Thu, 5 May 2011 11:37:41 -0400
Chris Malone <chris.m.malone@gmail.com> wrote:

> Hi Suvayu,
> 
> Thanks for sharing your use case - I'm interested in a few more
> details:
> 
> > For example for my appendix and bibliography I use the following:
> >
> > #+INCLUDE: thesis-appendix.org :minlevel 1

[...]

> 
> Would this #+INCLUDE line come within the last chapter headline?  In
> other words did you have something like
> 
> #+INCLUDE: frontmatter.org
> * Chapter 1
> ....
> * Chapter 2
> ...
> * Last Chapter
> ....
> #+INCLUDE: thesis-appendix.org :minlevel 1
> .
> .
> .
> \bibliography{master}
> 
> With this, it seems that all of the appendix/backmatter gets folded
> into the last chapter heading.  That is sort of the way I'm thinking
> of working my thesis, but it seems sub-optimal.
>

Yes that is correct. It folds into the last chapter, and I too find this
sub-optimal. If there was a way to specify certain headlines were
"special" and needed to be exported according to the sub-tree
properties, that would be ideal. Although I haven't looked into it, I'm
afraid it would require some lisp intervention.

That said, I just found a possible workaround. If you put the appendix
and bibliography and friends under the Footnotes headline, it somewhat
replicates the behaviour I would like to have. Something like this:

* Footnotes

[fn:1] footnote 1
[fn:2] footnote 2


#+INCLUDE: thesis-appendix.org :minlevel 1

#+LaTeX: \backmatter
#+LaTeX: \newpage
#+LaTeX: \addcontentsline{toc}{chapter}{\bibname}

#+LaTeX: \bibliographystyle{plain}
#+LaTeX: \bibliography{master}


After my thesis defence I might actually get around to attempting to
deal with this in lisp. Would be a good learning excercise. :)

> Chris

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-05 17:37         ` Suvayu Ali
@ 2011-05-05 17:45           ` chris.m.malone
  2011-05-05 18:02             ` Suvayu Ali
  0 siblings, 1 reply; 18+ messages in thread
From: chris.m.malone @ 2011-05-05 17:45 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2300 bytes --]

Hi Suvayu,

I think Matt's lisp code /should/ work for doing exactly what we are  
talking about, but for some reason I can't get it to work with LaTeX export.

Anyway, good luck on your defense!

Chris

On May 5, 2011 1:37pm, Suvayu Ali <fatkasuvayu+linux@gmail.com> wrote:
> Hello Chris,



> Sorry for the delay, had to attend a meeting.



> On Thu, 5 May 2011 11:37:41 -0400

> Chris Malone chris.m.malone@gmail.com> wrote:



> > Hi Suvayu,

> >

> > Thanks for sharing your use case - I'm interested in a few more

> > details:

> >

> > > For example for my appendix and bibliography I use the following:

> > >

> > > #+INCLUDE: thesis-appendix.org :minlevel 1



> [...]



> >

> > Would this #+INCLUDE line come within the last chapter headline? In

> > other words did you have something like

> >

> > #+INCLUDE: frontmatter.org

> > * Chapter 1

> > ....

> > * Chapter 2

> > ...

> > * Last Chapter

> > ....

> > #+INCLUDE: thesis-appendix.org :minlevel 1

> > .

> > .

> > .

> > \bibliography{master}

> >

> > With this, it seems that all of the appendix/backmatter gets folded

> > into the last chapter heading. That is sort of the way I'm thinking

> > of working my thesis, but it seems sub-optimal.

> >



> Yes that is correct. It folds into the last chapter, and I too find this

> sub-optimal. If there was a way to specify certain headlines were

> "special" and needed to be exported according to the sub-tree

> properties, that would be ideal. Although I haven't looked into it, I'm

> afraid it would require some lisp intervention.



> That said, I just found a possible workaround. If you put the appendix

> and bibliography and friends under the Footnotes headline, it somewhat

> replicates the behaviour I would like to have. Something like this:



> * Footnotes



> [fn:1] footnote 1

> [fn:2] footnote 2





> #+INCLUDE: thesis-appendix.org :minlevel 1



> #+LaTeX: \backmatter

> #+LaTeX: \newpage

> #+LaTeX: \addcontentsline{toc}{chapter}{\bibname}



> #+LaTeX: \bibliographystyle{plain}

> #+LaTeX: \bibliography{master}





> After my thesis defence I might actually get around to attempting to

> deal with this in lisp. Would be a good learning excercise. :)



> > Chris



> --

> Suvayu



> Open source is the future. It sets us free.




[-- Attachment #2: Type: text/html, Size: 3886 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-05 17:45           ` chris.m.malone
@ 2011-05-05 18:02             ` Suvayu Ali
  2011-05-06 15:41               ` Eric S Fraga
  0 siblings, 1 reply; 18+ messages in thread
From: Suvayu Ali @ 2011-05-05 18:02 UTC (permalink / raw)
  To: chris.m.malone; +Cc: emacs-orgmode

On Thu, 05 May 2011 17:45:13 +0000
chris.m.malone@gmail.com wrote:

> Hi Suvayu,
> 
> I think Matt's lisp code /should/ work for doing exactly what we are  
> talking about, but for some reason I can't get it to work with LaTeX
> export.
> 

I just tried Matt's code, worked very smoothly for me. :)

> Anyway, good luck on your defense!

Thank you.

> 
> Chris

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-05 14:23   ` Chris Malone
  2011-05-05 14:46     ` Suvayu Ali
@ 2011-05-06 12:34     ` Matt Lundin
  1 sibling, 0 replies; 18+ messages in thread
From: Matt Lundin @ 2011-05-06 12:34 UTC (permalink / raw)
  To: Chris Malone; +Cc: emacs-orgmode

Chris Malone <chris.m.malone@gmail.com> writes:

> @Matt: I can get your example to work fine for html export, but not
> LaTeX export where the entire contents of the headline are removed as
> well.  =org-version=:  7.5 (release_7.5.105.g8d0c) if that makes any
> difference.

Hmm... I have no idea why the LaTeX backend is removing the content of
that headline as well, as it survives in all other backends.

Best, 
Matt

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-05 18:02             ` Suvayu Ali
@ 2011-05-06 15:41               ` Eric S Fraga
  2011-05-06 17:04                 ` Suvayu Ali
  0 siblings, 1 reply; 18+ messages in thread
From: Eric S Fraga @ 2011-05-06 15:41 UTC (permalink / raw)
  To: Suvayu Ali; +Cc: chris.m.malone, emacs-orgmode

Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:

> On Thu, 05 May 2011 17:45:13 +0000
> chris.m.malone@gmail.com wrote:
>
>> Hi Suvayu,
>> 
>> I think Matt's lisp code /should/ work for doing exactly what we are  
>> talking about, but for some reason I can't get it to work with LaTeX
>> export.
>> 
>
> I just tried Matt's code, worked very smoothly for me. :)

This is strange.  I have tried it just now and it fails for me for a
very simple case.  It works for html and not for latex.  The same bol and
eol values are found in either case (which is as it should be, of
course).

It works, however, if there is at least one headline *before* the one to
be omitted, one that will not be omitted; if the omitted one is the
first headline, the whole block is gone.  Strange.

-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.258.ga173)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-06 15:41               ` Eric S Fraga
@ 2011-05-06 17:04                 ` Suvayu Ali
  0 siblings, 0 replies; 18+ messages in thread
From: Suvayu Ali @ 2011-05-06 17:04 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: chris.m.malone, emacs-orgmode

On Fri, 06 May 2011 16:41:19 +0100
Eric S Fraga <e.fraga@ucl.ac.uk> wrote:

> It works, however, if there is at least one headline *before* the one
> to be omitted, one that will not be omitted; if the omitted one is the
> first headline, the whole block is gone.  Strange.

I can confirm this, when I had tried this it I was ignoring only
headlines at the end. Ignoring the first headline behaves as you and
Chris describe.

-- 
Suvayu

Open source is the future. It sets us free.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-04 22:23     ` Matt Lundin
@ 2012-09-27  9:07       ` Renier Marchand
  2012-09-27 15:33         ` Nick Dokos
  0 siblings, 1 reply; 18+ messages in thread
From: Renier Marchand @ 2012-09-27  9:07 UTC (permalink / raw)
  To: emacs-orgmode

Matt Lundin <mdl <at> imapmail.org> writes:

> 
> Chris Malone <chris.m.malone <at> gmail.com> writes:
> >
> > I added your suggestion to my .emacs but upon export it removed the
> > entire block, which is odd based on the source code for the
> > function...
> 
> Hmm... That's not my experience.
> 
> When I export the following file...
> 
> --8<---------------cut here---------------start------------->8---
> * Preliminary material						     
:prelim:
> 
> Some preliminary material
> 
> * Point one
> 
> Text in point one
> 
> * Point two							     :prelim:
> 
> Text in point two.
> 
> * Point three
> 
> Text in point three.
> --8<---------------cut here---------------end--------------->8---
> 
> The resulting html looks like this (rendered in w3m)...
> 
> --8<---------------cut here---------------start------------->8---
> Some preliminary material
> 
> Table of Contents
> 
>   * 1 Point one
>   * 2 Point three
> 
> 1 Point one
> 
> Text in point one
> 
> Text in point two.
> 
> 2 Point three
> 
> Text in point three.
> 
> Date: 2011-05-04 18:22:09 EDT
> 
> Author: Matt Lundin
> 
> Org version 7.5 with Emacs version 24
> 
> Validate XHTML 1.0
> --8<---------------cut here---------------end--------------->8---
> 
> Best,
> Matt
> 
> 

It seems that the reason this does not work for Chris Malone is that if the 
heading tagged with :prelim: is preceded with a heading tagged with :noexport: 
then the content of the prelim section is in effect not exported. 

For this example

--8<---------------cut here---------------start------------->8---
* My setup							   :noexport:
  Some org-mode setup commands that should not be exported
* Preliminary material						     :prelim:

Some preliminary material

* Point one

Text in point one

* Point two							     :prelim:

Text in point two.

* Point three

Text in point three.
--8<---------------cut here---------------end--------------->8---

The following is exported

--8<---------------cut here---------------start------------->8---
Table of Contents

1 Point one
2 Point three
1 Point one

Text in point one

Text in point two.

2 Point three

Text in point three.

Date: 2012-09-27 11:04:36 SAST

Author: Renier Marchand

Org version 7.6 with Emacs version 23

Validate XHTML 1.0
--8<---------------cut here---------------end--------------->8---

Note the absence of the text before the table of contents.

Hope this clears it up
Renier

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2012-09-27  9:07       ` Renier Marchand
@ 2012-09-27 15:33         ` Nick Dokos
  0 siblings, 0 replies; 18+ messages in thread
From: Nick Dokos @ 2012-09-27 15:33 UTC (permalink / raw)
  To: Renier Marchand; +Cc: emacs-orgmode

Renier Marchand <renierm@gmail.com> wrote:

> 
> It seems that the reason this does not work for Chris Malone is that if the 
> heading tagged with :prelim: is preceded with a heading tagged with :noexport: 
> then the content of the prelim section is in effect not exported. 
> 
> For this example
> 
> * My setup							   :noexport:
>   Some org-mode setup commands that should not be exported
> * Preliminary material						     :prelim:
> 
> Some preliminary material
> 
> * Point one
> 
> Text in point one
> 
> * Point two							     :prelim:
> 
> Text in point two.
> 
> * Point three
> 
> Text in point three.
> 
> The following is exported
> 
> Table of Contents
> 
> 1 Point one
> 2 Point three
> 1 Point one
> 
> Text in point one
> 
> Text in point two.
> 
> 2 Point three
> 
> Text in point three.
> 
> Date: 2012-09-27 11:04:36 SAST
> 
> Author: Renier Marchand
> 
> Org version 7.6 with Emacs version 23
> 
> Validate XHTML 1.0
> 
> Note the absence of the text before the table of contents.
> 

I can't reproduce this. I get correct behavior in all cases I've tried:
with both the old and the new exporter, html, latex and ascii.

What version of org are you using? 

Mine is

Org-mode version 7.9.1 (release_7.9.1-348-gea7baa @ /home/nick/elisp/org-mode/lisp/)

Nick

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2011-05-04 16:18 ` Matt Lundin
  2011-05-04 18:05   ` Chris Malone
@ 2014-06-06 17:03   ` Eric Schulte
  2014-06-07 19:48     ` Eric Schulte
  1 sibling, 1 reply; 18+ messages in thread
From: Eric Schulte @ 2014-06-06 17:03 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Chris Malone, emacs-orgmode

Matt Lundin <mdl@imapmail.org> writes:

> Chris Malone <chris.m.malone@gmail.com> writes:
>
> (Note: When using gmail, please adjust the settings to send your
> messages as plain text only instead of multipart/alternative.)
>
>> When I include the actual contents of my abstract, this preliminary material
>> section (the #+begin ... #+end block) is rather large.  I'd like to be able
>> to put this material into a headline so that I could collapse it - but I
>> don't want this headline exported as content of the main document.
>>
>> In other words, is there a property or tag that I can add to a headline that
>> causes LaTeX export to ignore the fact that it is a headline (i.e. \chapter,
>> \section, \subsection, etc.), but still export its contents?  Something
>> like:
>
> You could add a hook to remove headlines with a "prelim" tag:
>
> --8<---------------cut here---------------start------------->8---
> (defun my-org-export-remove-tagged-headlines (tag)
>   (save-excursion
>     (goto-char (point-min))
>     (while (re-search-forward (concat ":" tag ":") nil t)
>       (delete-region (point-at-bol) (point-at-eol)))))
>
> (add-hook 'org-export-preprocess-hook (lambda () (my-org-export-remove-tagged-headlines "prelim")))
> --8<---------------cut here---------------end--------------->8---
>

I found the very useful but sadly outdated snippet from 2011.  If anyone
is interested, the following snippet implements the same functionality
within the new export framework.

--8<---------------cut here---------------start------------->8---
(defun org-export-remove-prelim-headlines (tree backend info)
  "Remove headlines tagged \"prelim\" while retaining their
contents before any export processing."
  (org-element-map tree org-element-all-elements
    (lambda (object)
      (when (and (equal 'headline (org-element-type object))
                 (member "prelim" (org-element-property :tags object)))
        (mapc (lambda (el)
                (let ((new-object
                       (if (equal 'headline (org-element-type el))
                           (org-element-put-property el
                             :level (1- (org-element-property :level el)))
                         el)))
                  (message "%s level %s"
                           (org-element-property :raw-value new-object)
                           (org-element-property :level new-object))
                  (org-element-insert-before new-object object)))
              (cddr object))
        (org-element-extract-element object)))
    info nil org-element-all-elements)
  tree)

(add-hook 'org-export-filter-parse-tree-functions
          'org-export-remove-prelim-headlines)
--8<---------------cut here---------------end--------------->8---

In addition it promotes all headlines under the removed "prelim"-tagged
headline.  This is useful to support structures like the following.

--8<---------------cut here---------------start------------->8---
* Appendix                                                           :prelim:
#+LaTeX: \begin{appendices}
** Definitions
** Data Sets
** Tooling
#+LaTeX: \end{appendices}
--8<---------------cut here---------------end--------------->8---

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Collapse LaTeX source before start of main document?
  2014-06-06 17:03   ` Eric Schulte
@ 2014-06-07 19:48     ` Eric Schulte
  0 siblings, 0 replies; 18+ messages in thread
From: Eric Schulte @ 2014-06-07 19:48 UTC (permalink / raw)
  To: Matt Lundin; +Cc: Chris Malone, emacs-orgmode

Eric Schulte <schulte.eric@gmail.com> writes:

> Matt Lundin <mdl@imapmail.org> writes:
>
>> Chris Malone <chris.m.malone@gmail.com> writes:
>>
>> (Note: When using gmail, please adjust the settings to send your
>> messages as plain text only instead of multipart/alternative.)
>>
>>> When I include the actual contents of my abstract, this preliminary material
>>> section (the #+begin ... #+end block) is rather large.  I'd like to be able
>>> to put this material into a headline so that I could collapse it - but I
>>> don't want this headline exported as content of the main document.
>>>
>>> In other words, is there a property or tag that I can add to a headline that
>>> causes LaTeX export to ignore the fact that it is a headline (i.e. \chapter,
>>> \section, \subsection, etc.), but still export its contents?  Something
>>> like:
>>
>> You could add a hook to remove headlines with a "prelim" tag:
>>
>> --8<---------------cut here---------------start------------->8---
>> (defun my-org-export-remove-tagged-headlines (tag)
>>   (save-excursion
>>     (goto-char (point-min))
>>     (while (re-search-forward (concat ":" tag ":") nil t)
>>       (delete-region (point-at-bol) (point-at-eol)))))
>>
>> (add-hook 'org-export-preprocess-hook (lambda () (my-org-export-remove-tagged-headlines "prelim")))
>> --8<---------------cut here---------------end--------------->8---
>>
>
> I found the very useful but sadly outdated snippet from 2011.  If anyone
> is interested, the following snippet implements the same functionality
> within the new export framework.
>
> --8<---------------cut here---------------start------------->8---
> (defun org-export-remove-prelim-headlines (tree backend info)
>   "Remove headlines tagged \"prelim\" while retaining their
> contents before any export processing."
>   (org-element-map tree org-element-all-elements
>     (lambda (object)
>       (when (and (equal 'headline (org-element-type object))
>                  (member "prelim" (org-element-property :tags object)))
>         (mapc (lambda (el)
>                 (let ((new-object
>                        (if (equal 'headline (org-element-type el))
>                            (org-element-put-property el
>                              :level (1- (org-element-property :level el)))
>                          el)))
>                   (message "%s level %s"
>                            (org-element-property :raw-value new-object)
>                            (org-element-property :level new-object))
>                   (org-element-insert-before new-object object)))
>               (cddr object))
>         (org-element-extract-element object)))
>     info nil org-element-all-elements)
>   tree)
>
> (add-hook 'org-export-filter-parse-tree-functions
>           'org-export-remove-prelim-headlines)
> --8<---------------cut here---------------end--------------->8---
>

The following is a slightly improved implementation of the above.
--8<---------------cut here---------------start------------->8---
(defun org-export-remove-prelim-headlines (tree backend info)
  "Remove headlines tagged \"prelim\" while retaining their
contents before any export processing."
  (org-element-map tree org-element-all-elements
    (lambda (object)
      (when (and (equal 'headline (org-element-type object))
                 (member "prelim" (org-element-property :tags object)))
        (mapc (lambda (el)
                ;; recursively promote all nested headlines
                (org-element-map el 'headline
                  (lambda (el)
                    (when (equal 'headline (org-element-type el))
                      (org-element-put-property el
                        :level (1- (org-element-property :level el))))))
                (org-element-insert-before el object))
              (cddr object))
        (org-element-extract-element object)))
    info nil org-element-all-elements)
  tree)
--8<---------------cut here---------------end--------------->8---

Best,

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-06-07 19:49 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 15:36 Collapse LaTeX source before start of main document? Chris Malone
2011-05-04 16:18 ` Matt Lundin
2011-05-04 18:05   ` Chris Malone
2011-05-04 22:23     ` Matt Lundin
2012-09-27  9:07       ` Renier Marchand
2012-09-27 15:33         ` Nick Dokos
2014-06-06 17:03   ` Eric Schulte
2014-06-07 19:48     ` Eric Schulte
2011-05-04 22:25 ` Suvayu Ali
2011-05-05 14:23   ` Chris Malone
2011-05-05 14:46     ` Suvayu Ali
2011-05-05 15:37       ` Chris Malone
2011-05-05 17:37         ` Suvayu Ali
2011-05-05 17:45           ` chris.m.malone
2011-05-05 18:02             ` Suvayu Ali
2011-05-06 15:41               ` Eric S Fraga
2011-05-06 17:04                 ` Suvayu Ali
2011-05-06 12:34     ` Matt Lundin

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).