4

How can I have org #+INCLUDE: ignore configurations from the included files? I'm thinking of cases where I don't want Latex Classes to be messed up. For example, if I have two org files book.org and chapter.org that look like the following:

book.org

#+LATEX_CLASS: book
* Chapter 1
#+INCLUDE: chapter.org

chapter.org

#+LATEX_CLASS: report
* Results

Then on export (to another Org file) I get the following:

#+LATEX_CLASS: book
* Chapter 1
#+LATEX_CLASS: report
** Results

This is not good because a latex-export may get messed up (the last latex_class takes precedence, so I would end up with a report and not a book). What is the recommended way to avoid these issues?

2 Answers 2

1

Use the include directive's option: :only-contents t (https://orgmode.org/manual/Include-files.html), for example in book.org:

* Chapter 1    
** Results
#+INCLUDE: "chapter.org::*Results" 

Then only the contents below the header Results in chapter.org is included.

If you are specifying your latex class in an export property in chapter.org, like below

:PROPERTIES:
:EXPORT_LaTeX_CLASS: some class
:END:

then you can also include the whole org file

#+include: "chapter.org" :only-contents t
4
  • This does not work. All latex_headers, for example, are included with the file.
    – Daniel
    Feb 26, 2018 at 12:28
  • @dangom you're right, sorry edited my Answer. Feb 26, 2018 at 15:01
  • This solution is not completely satisfactory, as I do not want to select a specific heading, but rather filter out some boilerplate without knowing in advance how much boilerplate it is.
    – Daniel
    Feb 28, 2018 at 1:10
  • @dangom: Then you should change your approach and specify your latex class in a property. Feb 28, 2018 at 6:48
1

I would reorg the files a bit: the chapter1.org and report.org files should not specify any configuration. You can then include them in Book.org:

#+LATEX_CLASS: book

#+INCLUDE: chapter1.org
#+INCLUDE: report.org

or in Report.org (note the capital R: I'm assuming your filesystem is case sensitive):

#+LATEX_CLASS: report

#+INCLUDE: report.org

This requires a bit more effort and discipline, but it is flexible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.