Padding in input cells and bigger output cells jupyter notebook slideshow presentation - jupyter-notebook

I am struggling with jupyter notebook slideshow. At the beginning I made a presentation, everything looked normal. However later I wanted to align some text, move image to the ceneter, adding padding, setting margins etc. I was using html for that.
Now sth changed my settings gloabally and my input and output cells looks bizzare.
exemplary view
I tried to reinstall jupyter.
I tried creating new notebook.
I tried two different browsers with cleaning cache.
I used jt -r command.
I deleted manually custom.css
I have no idea how to make it look as it used to.
I make my presentation by this command in jupyter notebook terminal:
jupyter nbconvert "<test.ipynb" --to slides --post serve

Related

How do you link to a slide in a Jupyter Notebook saved as Reveal.JS?

When I download a Jupyter Notebook as slides, the links are not active (i.e. they don't take you anywhere). How do I link a table of contents page to the respective slides?
Linking to a cell can be done by anchoring it and then calling it later see answer here (e.g. place<a id="another_cell"></a> in the desired cell to jump to and place [Another Cell](#another_cell) where you'd click "Another Cell"). This works fine in an download of the Reveal.JS as a PDF, but not when doing slides.
Current code to publish with nbconvert:
jupyter nbconvert SOME_NOTEBOOK.ipynb
--to slides
--output-dir .\SOME_FOLDER
--SlidesExporter.reveal_theme=serif
--SlidesExporter.reveal_scroll=True
--SlidesExporter.reveal_transition=none
--TemplateExporter.exclude_input=True
--TemplateExporter.exclude_output_prompt=True
--reveal-prefix=./lib/reveal.js-3.8.0
You can try this:
Slide number 2
Note:
The slide count starts after the slide that has the table of contents.

How can I make a presentable PDF from a Jupyter Notebook?

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 code
Print to PDF in the browser
In 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.
Export to PDF with 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.
Print Preview menu in the classical Jupyter
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.
As the above-mentioned answers do not work for me; I found another solution:
I use an additional package notebook-as-pdf.
Read the tutorial here. It uses Chromium and is the only approach that worked for me so far reliably. The "print preview" does still not work. But it produces a clean PDF with no code input.
I do:
pip install -U notebook-as-pdf
pyppeteer-install
jupyter nbconvert --to PDFviaHTML --TemplateExporter.exclude_input=True PATH_TO_YOUR_FILE.ipynb
What did NOT work for me:
The solution above.
All the scripts mentioned in those answers

Is there a way to print a jupyter/ipython notebook slide presentation?

Is there a way to print out a slide deck of a jupyter/ipython notebook slides? Is it possible to do from the nbviewer site (http://nbviewer.ipython.org) ?
I know that I can print a pdf of my notebook, but when I do, it doesn't have the same page breaks and doesn't skip all the code that I would like skipped (for example, the libraries I've imported aren't necessary). I'd like to have it as a backup or a printable handout.
You can try this:
jupyter nbconvert --to slides --post serve /path/to/your/notebook.ipynb
This should fire up your browser and serve the presentation (e.g at http://127.0.0.1:8000/<some-title>.slides.html#/)
change the url to
http://127.0.0.1:8000/<some-title>.slides.html?print-pdf
If you now open the print dialog from your browser, the slides should have the right formatting.
Instead of sending to a printer you should be able to choose to write to a pdf file from the printer menu.
I tested this in chrome on OSX. I assume it works on all systems, but I did not test.

Distribute a slideshow from IPython notebook

so I am adoring the new IPython notebook slideshow feature, however I could not figure out how to distribute such a slideshow in a userfriendly (I am no HTML/JS guy) way.
My usecase is:
I have a somewhat messy notebook which I want to filter by tagging cells as slides/skip/- etc.
In an optimal world there would be a fire-and-forget 'give me a pdf' button somewhere.
So I did already view the slides locally via ipython nbconvert ... --to slides -- post serve
But how do I distribute that to others? Can I get a pdf from such a slideshow easily (I do not care about transition animations etc.)
I hope this is developed further, great features so far!
Currently, there is only a hackish way, see GitHub Issue.
You might also try Slideviewer (in contrast to NBviewer).
$ ipython nbconvert ... --to slides (no serve option necessary) create a standalone html file you should be able to mail, or whatever.
The skip/- logic can be applied to pdf generation too, you just have to write your own extended template (which is not that hard, wild guess ~20 lines)
You can print it as a pdf file from Chrome.
Add "?print-pdf" at the end of your URL.e.g: 127.0.0.1:8000/index.html?print-pdf
Select print menu from Chrome.
Select Save As pdf, then print it out.
buddy, I'm sure this is what you want
https://github.com/damianavila/RISE
for more details, check here
https://conference.scipy.org/scipy2014/schedule/presentation/1718/

Is it possible to exclude some cells from the ipython notebook when using NBConvert

Is there a method to exclude some cells from the NBconvert process
For instance. An embedded video is cool when running to HTML, but when converting the HTML to PDF it creates a problem. So I want to exclude it in some instances.
Found a nice workaround for this, using the 'slides' option of nbconvert:
In your iPython notebook under "Cell Toolbar" select "Slideshow"
Then in the top right of the cells that you don't want to show select Slide Type "skip"
Now run python nbconvert your_notebook.ipynb --to slides
Instead of serving the slide, just open the resulting html in a browser.
And.. It doesn't contain the slides you told it to skip!
Hope this helps.

Resources