Skip to content

Instantly share code, notes, and snippets.

@jchkoch
Last active September 3, 2020 21:00
Show Gist options
  • Save jchkoch/9e592213b7420bb89766c8007a79f885 to your computer and use it in GitHub Desktop.
Save jchkoch/9e592213b7420bb89766c8007a79f885 to your computer and use it in GitHub Desktop.

ox-ipynb and exclude-tags

Notes

This is a minimal working example of a workflow to use :exclude: tags with the ox-ipynb exporter from org-mode to jupyter notebooks. In this workflow, a single org-mode source file is used to generate both \LaTeX Beamer article style handouts and a Jupyter notebook. The issue that I have run into is to include different content in the two output formats. Most often I find that I want to include additional content in the \LaTeX Beamer article PDF file which should not be in the Jupyter notebook.

To do this, I follow the following workflow:

  1. Generate the org-mode source and add the tag beamer on each headline which I want to see only in the PDF version (generated through \LaTex Beamer).
  2. Add the line #+exclude_tag: beamer to the top of the org-mode source file with all of the other org-mode options which are enabled/disabled for the file. See the top of this file as an example.
  3. Export to the desired output format:
    • When exporting to a Beamer PDF, simply remove the word beamer from the line #+exclude_tag: beamer so that this line reads #+exclude_tag: and export using the normal \LaTeX Beamer exporter.
    • When exporting to Jupyter notebooks using ox-ipynb, simply add the line #+exclude_tag: beamer back into the org-mode source file and export using ox-ipynb.

A problem may arise when trying to export to a Jupyter notebook through the ox-ipynb package when this line is not present in the org-mode source file #+exclude_tag: beamer but this line is #+exclude_tag:. To solve add the tag name beamer back into this line and all should work. The next headlines are part of the MWE highlighting this problem.

Some content

This should appear in both export formats (Beamer PDF and Jupyter notebook).

A sub-heading

This too should appear in both export formats. The line #+exclude_tag: beamer should appear in org-mode source file if you are reading this from a PDF file or a Jupyter Notebook.

A second sub-heading

This contains additional redundant information which should not appear in the Jupyter Notebook export format. If you are reading this in a PDF, you should see the line #+exclude_tag: appear in the org-mode source file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment