6
votes

I use org-mode to write both papers and slides. The code to generate tables and figures is placed in source blocks. Most of the time I use the same tables in my slides as in my papers, but a lot of preprocessing code is needed to generate the tables. I'd like to put the generation of these tables in its own org-mode file and just be able to include certain headings in the paper or slide document. For example, I would have an org-mode document called mytables.org:

* Heading 1
** Regressions
#+BEGIN_SRC R
cat("hello world")
#+END_SRC R
* Heading 2

And another document mypaper.org:

* Section 1
#+INCLUDE: "mytables.org" :heading "Heading 1/Regressions"
* Section 2

The content from below the ** Regression headline in mytables.org would be included on export in mypaper.org. It would also be great to be able to follow the INCLUDE to the file with C-c '. Org provides some facilities for these includes, but does not allow for headings ( http://orgmode.org/manual/Include-files.html ). Obviously org does not have the :heading parameter, but any suggestions for a solution to make this work are greatly appreciated.

Thanks.

2
Hi, have you found a good way to solve this? if yes, can you answer this question by yourself? thanks!Leu_Grady
No solution yet. I intend to write some changes to org-mode eventually, but haven't had the chance. I'll update once I do.Rob Richmond

2 Answers

7
votes

Org mode 8.3 supports this (I'm using 8.3beta).

For example:

#+INCLUDE: "./paper.org::*conclusion" :lines 1-20

will include the first 20 lines of the headline named conclusion.

Also, to include a heading by its CUSTOM_ID property (suppose it is Sec: Introduction):

#+INCLUDE: "./paper.org::#Sec: Introduction"

I found :only-contents t works well for my application (I'm including a subtree from another org file for a beamer presentation):

#+INCLUDE: "./paper.org::*conclusion" :only-contents t
1
votes

Why doesn't this do what you want?

** Heading 1/Regressions
#+INCLUDE: my-table.org :minlevel 2

This will nest your file under the heading. If you need selective exports, then tag the sections with :paper: or :presentation:, and use EXPORT_EXCLUDE_TAGS to indicate which one to export.