2

I have a refcards.org file where I store and maintain tens of tables (each having a specific name, e.g. #+name: key-somename).

I would like to mention and show these tables in some other org files that I am writing.

Let say I'm writing within explanations.org file located in ~/Path2/, and I want to show key-somename table from ~/Path1/refcards.org

How could I do that?

9
  • A link? [[file:refcards.org::key-somename][My table]]
    – NickD
    Jul 16 at 18:06
  • [[file:~/Path1/refcards.org::key-somename][My table]] doesn't show a table, it shows a link.
    – crocefisso
    Jul 16 at 18:28
  • Of course - and when you click the link you get to the table. The question was: is that enough? Or do you really need to see the table in the file?
    – NickD
    Jul 17 at 12:53
  • 1
    Yes, although you could bind it to a key to make it less onerous. What you are really looking for, I guess, is a modified #+INCLUDE that includes a table from a file, instead of the whole file, at that point. But that is a biggger change. You might want to propose it as a feature request on the Org Mode mailing list. It might not be implemented, but people might have additional ideas.
    – NickD
    Jul 17 at 16:49
  • 1
    #+INCLUDE worked LOL, so you found the solution, thanks a lot! Do you want to answer the question or shall I do it?
    – crocefisso
    Jul 17 at 21:39

2 Answers 2

2

The #+INCLUDE mechanism can be used not only to include a file, but also portions of the file (specified by beginning and ending line numbers), and more importantly for this question, headlines and named elements. See the Include Files section of the manual with C-h i g(org)<RET> m Include<TAB><RET>.

So one can say:

#+INCLUDE: "~/Path1/refcards.org::key-somename"

and get the named element (the table in this case) included from the refcards.org file.

2

Use org-transclusion library.

See org-transclusion: Transclude text content via links, and also org-transclusion MANUAL


To get this

Demo of transclusion-mode

Do this

  1. M-x package-refresh-contents RET, and M-x package-install RET org-transclusion RET.

  2. emacs -Q. M-x package-initialize, and optionally put this snippet in your *scratch* and do M-x eval-buffer.

(custom-set-faces
 '(org-transclusion-fringe
   ((t
     (:background "orange"))))
 '(org-transclusion-source-fringe
   ((t
     (:background "green")))))
  1. Create a file with explanations.org with following content
** Animals

These creatures you are domesticated.

#+transclude: [[./refcards.org::animals]]

** Birds

These creatures fly.

#+transclude: [[./refcards.org::birds]]

** Insects

These creatures are a nuisance.

#+transclude: [[./refcards.org::insects]]

  1. Create a file refcards.org with following content
#+CAPTION: Animals
#+NAME: animals
| Cat | Dog     |
| Cow | Buffalo |

#+CAPTION: Birds
#+NAME: birds
| Crow    | Pigeon |
| Peacock | Eagle  |


#+CAPTION: Insects
#+NAME: insects
| Cockroach | Grasshopper |
| Mosquito  | Housefly    |

  1. C-x C-f explanations.org, and do M-x org-transclusion-mode RET.

  2. This is what you will see.

Demo of transclusion-mode

1
  • 1
    Thank you for letting me know about org-transclusion, the package looks great!
    – crocefisso
    Jul 18 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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