I know that I can click on File -> Print Preview
and let my browser save the result as a PDF. But that PDF will contain quite a bit of code.
Can I hide parts from the print preview or make a PDF with another tool?
Ideally, there would be magic functions:
%hide
: Hide the cell and its output%hide-code
: Hide only the code of the cell, but show the output of the codeIn JupyterLab, you can hide the cell's input and output by clicking the side bar as demonstrated in the doc. After hiding, you can use the browser's printing menu to generate a PDF. I've tested it on FireFox and expect similar result on Chrome or Edge.
nbconvert
If you aim at a native conversion from ipynb
format to pdf
, the nice old nbconvert
tool is your friend. It usually comes together with Jupyter and can be invoked conveniently in the menu of JupyterLab File->Export Notebook As...->PDF
or, in the classic Jupyter Notebook interface, File->Download as->PDF (via LaTeX)
.
Hiding input/output in cells can be realized by setting the cell's metadata hide_input=true
and installing a nbextension as discussed in issue #155.
Finally to your question
Can I hide parts from the print preview or make a PDF with another tool?
The "print preview" button in the classical Jupyter interface is a shortcut for calling nbconvert
to generate a HTML file and redirect your browser to it. Therefore, similar configuration for nbconvert
to hide input as discussed above (in issue #155) can be used. This feature is implemented by jupyter_contrib_nbextensions
bundle and explained in the doc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With