emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to export a single subtree but include document preamble?
@ 2024-04-03 19:00 Richard H. Stanton
  2024-04-03 21:13 ` Scott Randby
  0 siblings, 1 reply; 5+ messages in thread
From: Richard H. Stanton @ 2024-04-03 19:00 UTC (permalink / raw)
  To: emacs-orgmode

I just tried to export a single subtree from an org document to a PDF file:

1) Type  C-c C-e [org-export-dispatch]
2) C-s to narrow to subtree
3) l -> o to export to PDF via LaTeX

However, instead of exporting the portion of the file I want, I get the error message

Undefined Org macro: newline; aborting

That macro is defined in a setup file that is #+included at the top of the file, so exporting the entire file works fine.

I assume the problem is that when I export only one subtree, the setup file is not #+included, and I can see it sort of makes sense, but it would be nice if there were an option to include one or more lines from the preamble when exporting just a subtree, since otherwise exporting a subtree doesn’t actually work! Is there a simple way to do this?

Thanks.

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

* Re: How to export a single subtree but include document preamble?
  2024-04-03 19:00 How to export a single subtree but include document preamble? Richard H. Stanton
@ 2024-04-03 21:13 ` Scott Randby
  0 siblings, 0 replies; 5+ messages in thread
From: Scott Randby @ 2024-04-03 21:13 UTC (permalink / raw)
  To: emacs-orgmode

On 4/3/24 15:00, Richard H. Stanton wrote:
> I just tried to export a single subtree from an org document to a PDF file:
> 
> 1) Type  C-c C-e [org-export-dispatch]
> 2) C-s to narrow to subtree
> 3) l -> o to export to PDF via LaTeX
> 
> However, instead of exporting the portion of the file I want, I get the error message
> 
> Undefined Org macro: newline; aborting
> 
> That macro is defined in a setup file that is #+included at the top of the file, so exporting the entire file works fine.
> 
> I assume the problem is that when I export only one subtree, the setup file is not #+included, and I can see it sort of makes sense, but it would be nice if there were an option to include one or more lines from the preamble when exporting just a subtree, since otherwise exporting a subtree doesn’t actually work! Is there a simple way to do this?
> 

I don't know if this does what you want, but I use a ‘PROPERTIES’ drawer right below the subtree's headline and in that drawer, I put the following code:

:EXPORT_LATEX_HEADER_EXTRA: \input{latex-preamble.tex}

Scott Randby


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

* Re: How to export a single subtree but include document preamble?
@ 2024-04-04 18:11 Richard Stanton
  2024-04-04 18:32 ` Richard Stanton
  2024-04-04 18:42 ` Scott Randby
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Stanton @ 2024-04-04 18:11 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: srandby

> I don't know if this does what you want, but I use a ‘PROPERTIES’ drawer right below the subtree's headline and in that drawer, I put the following code:
> 
> :EXPORT_LATEX_HEADER_EXTRA: \input{latex-preamble.tex}
> 
> Scott Randby

Thanks for the suggestion! 

It would still be nice (i.e., you wouldn’t have to do this for every section you ever want to export) to have a way of specifying a line that gets executed for EVERY (say) LaTeX export. Or else an option to do something like include everything in the file before the first section header.




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

* Re: How to export a single subtree but include document preamble?
  2024-04-04 18:11 Richard Stanton
@ 2024-04-04 18:32 ` Richard Stanton
  2024-04-04 18:42 ` Scott Randby
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Stanton @ 2024-04-04 18:32 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: srandby

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

On Apr 4, 2024, at 11:11 AM, Richard Stanton <rhstanton@berkeley.edu> wrote:
> 
>> I don't know if this does what you want, but I use a ‘PROPERTIES’ drawer right below the subtree's headline and in that drawer, I put the following code:
>> 
>> :EXPORT_LATEX_HEADER_EXTRA: \input{latex-preamble.tex}
>> 
>> Scott Randby
> 
> Thanks for the suggestion! 
> 
> It would still be nice (i.e., you wouldn’t have to do this for every section you ever want to export) to have a way of specifying a line that gets executed for EVERY (say) LaTeX export. Or else an option to do something like include everything in the file before the first section header.

That capability does (if you’re careful) seem to exist. In my case, I just had to replace

#+include: setup.org <http://setup.org/>

with 

#+setupfile: setup.org

and now exporting includes the macro definitions in setup.org <http://setup.org/> even when I’m only exporting a subtree.

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

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

* Re: How to export a single subtree but include document preamble?
  2024-04-04 18:11 Richard Stanton
  2024-04-04 18:32 ` Richard Stanton
@ 2024-04-04 18:42 ` Scott Randby
  1 sibling, 0 replies; 5+ messages in thread
From: Scott Randby @ 2024-04-04 18:42 UTC (permalink / raw)
  To: Richard Stanton, emacs-orgmode

> On 4/4/24 14:11, Richard Stanton wrote:
> Thanks for the suggestion!
> 
> It would still be nice (i.e., you wouldn’t have to do this for every section you ever want to export) to have a way of specifying a line that gets executed for EVERY (say) LaTeX export. Or else an option to do something like include everything in the file before the first section header.
> 
> 

That would be a nice feature, but I also like using the 'PROPERTIES' drawer because it enables me to have very fine control over the export of a subtree. A typical drawer I use looks like this:

:PROPERTIES:
:EXPORT_TITLE: *Subtree Title*
:EXPORT_FILE_NAME: Exported-Subtree
:EXPORT_LATEX_HEADER_EXTRA: \input{latex-preamble.tex} \hypersetup{pdftitle={Subtree Title},pdfauthor={Scott Randby},pdfsubject={},pdfkeywords={},pdfproducer={Emacs Org},pdfcreator={pdflatex}} \hypersetup{colorlinks=true,urlcolor=blue,linkcolor=blue} %\pagestyle{empty} % Turn page numbering off
:EXPORT_OPTIONS: h:4 author:nil email:nil date:nil creator:nil timestamp:nil tags:nil num:0 toc:nil
:END:

Scott


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

end of thread, other threads:[~2024-04-04 18:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-03 19:00 How to export a single subtree but include document preamble? Richard H. Stanton
2024-04-03 21:13 ` Scott Randby
  -- strict thread matches above, loose matches on Subject: below --
2024-04-04 18:11 Richard Stanton
2024-04-04 18:32 ` Richard Stanton
2024-04-04 18:42 ` Scott Randby

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