Skip to content

Instantly share code, notes, and snippets.

@kuchaale
Forked from macoj/hide_code_pdf.md
Created March 16, 2018 11:32
Show Gist options
  • Save kuchaale/d96a485bb9037ab330d500db5eff5142 to your computer and use it in GitHub Desktop.
Save kuchaale/d96a485bb9037ab330d500db5eff5142 to your computer and use it in GitHub Desktop.
Hiding code when exporting jupyter notebook to pdf

From here: https://ga7g08.github.io/2015/06/25/ipython-nbconvert-latex-template-to-hide-code/

  1. Create a file named hidecode.tplx in the directory of your notebook with the following content:
((*- extends 'article.tplx' -*))

((* block input_group *))
    ((*- if cell.metadata.get('nbconvert', {}).get('show_code', False) -*))
        ((( super() )))
    ((*- endif -*))
((* endblock input_group *))
  1. Export your jupyter notebook to pdf using the template:
$ jupyter nbconvert --to pdf --template hidecode Notebook.ipynb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment