Skip to content

Instantly share code, notes, and snippets.

@Emaasit
Forked from macoj/hide_code_pdf.md
Created April 3, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Emaasit/0e233bb9421ca6364285454c5a7db29c to your computer and use it in GitHub Desktop.
Save Emaasit/0e233bb9421ca6364285454c5a7db29c 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