I have a subtree that I want to export as a latex document. That subtree needs a fairly long preamble specific to it, so I want to compile the preamble into a separate file, which I can then call with \input during export.

Right now, I can get the desired result with this sort of document

* Exporting with a file input for export-latex-header
:EXPORT_LATEX_HEADER: \input{stylefile}

content of the main file

** style file                                                     :noexport:
:EXPORT_FILE_NAME: stylefile

I then perform two exports.

  1. I export the subtree **style file with the body-only option (selected from the export dispatcher), which gives me the file stylefile.tex as output with the two lines of LaTeX.
  2. I export the subtree * Exporting... in the regular way, giving me Main.tex with the correct preamble, and during compilation, the \input'ed lines are compiled correctly.

Is it possible to automate the export process somehow, so that when I export the Main file, org-mode automatically exports the dependency, as well?

FWIW: I've tried defining a macro in org that expands to the desired pre-amble, but macro invocations in :EXPORT_LATEX_HEADER: are treated as verbatim, i.e., not expanded during export.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.