Is it possible to #+INCLUDE: config.org when exporting and have only the lines in config.org that start with # be included?

Say you have a file config.org like this:

Formats the style of captions. Adds margin to the caption (hang), makes the font small and puts the name of the caption in bold face.
#+LATEX_HEADER: \usepackage[hang,small,bf]{caption}

Then I'd only want the line with #+LATEX_HEADER to be included. But I'd still want the previous line to remain in the config.org file as an explanation to what the command does.

  • Have a look at SETUPFILE instead of INCLUDE. – Juancho Aug 8 '18 at 14:54
  • @Juancho I appreciate your comment, but the use case that I have does not work with setupfile. I use include to add specific configurations when exporting a subtree, and setupfile works globally. – Guilherme Salomé Aug 8 '18 at 14:57

Put your configuration into a heading and include only the heading.

#+INCLUDE: config.org::*Configuration

If the heading annoys you, add an :ignore: tag to it so that the heading itself is ignored on export. Be sure to eval the following Elisp code to activate the :ignore: feature.

(with-eval-after-load 'ox
    (require 'ox-extra)
    (ox-extras-activate '(ignore-headlines)))
| improve this answer | |
  • That's a good solution, but would require to keep a copy of the comments about the configurations elsewhere, which is what I'm trying to avoid. But it does work, thanks for the suggestion. Just as a side note for other readers, to use ox-extra you actually need the package org-plus-contrib installed. – Guilherme Salomé Aug 8 '18 at 17: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.