How do I separate slides when exporting an IPython notebook to reveal.js?
Asked Answered
T

3

7

When I execute an IPython notebook to a reveal.js presentation using

ipython nbconvert mynotebook.ipynb --to slides --post serve

I am getting all the content as a single slide. How do I separate my content into several slides?

presentation screenshot

I tried using --- (hinted in this video), \n\n\n and === inside the notebook (as separate cells and before my titles), but it didn't change anything. I know that for a Markdown input file in reveal.js one can set the data-separator option, but the generated html file doesn't seem to include the content as Markdown, but inlines everything using HTML tags, so I don't know how to make IPython generate new slide tags where I want them.

(I'm using IPython 1.1 installed via pip)

Tapestry answered 7/12, 2013 at 13:22 Comment(0)
B
11

In main toolbar, select the "slideshow" cell toolbar. Then select if you want each cell to be a new "slide", "subslide","fragment"...etc

Blanche answered 7/12, 2013 at 13:47 Comment(6)
Excellent, just in time for my PyLadies lightning talk :) Thanks! (btw as a future feature request - it would be cool to be able to mark all cells with h1 titles as new slides automatically e.g. nbconvert nb.ipynb --to slides --separator h1 or --separator "---" for the --- line determining a new slide).Tapestry
That's easy to do with a custom nbconvert preprocessor. We try to keep IPython shipped option as "bare minimal". Still if you can ask for pointer on how to do, and post in wiki cookbook once you've done it :-)Blanche
Good lightning talk also with the Laydies also.Blanche
Ah, I see there are some examples in IPython/nbconvert/preprocessors - material for my next hack, then :) Thanks! I don't know via what social-networking roadtrip it reached you, but it's nice to hear it :DTapestry
I'm subscribed to IPython on StackOverflow, and you can probably find me on IPython repo on github, ping if you need help.Blanche
Thanks for the answer. For anyone who got an AttributeError: slideshow, you need to annotate every cell with one of the slide options. If any cell is left unannotated, the error will occur.Deus
D
8

For IPython 4.0.0

When you start IPython with ipython3 notebook (and I think you have to have https://github.com/damianavila/RISE.git installed), then the cells look like this:

enter image description here

You have to set "Cell Toolbar" (green box) to "Slideshow". Then the toolbar highlighted in red will appear. You can try it with the button highlighted in blue.

Cell-types

I'm not too sure what the cell types mean

  • -: ?
  • Slide: The normal one
  • Sub-Slide: vertically-aligned slides (see example)
  • Fragment: will be on the same slide as the slide before
  • Skip: Don't show this in the presentation. This is nice for configuration / pre-calculation
  • Notes: ?
Disobedience answered 14/11, 2015 at 23:26 Comment(0)
I
6

The correct answer is Matt's answer. You need to use "slideshow" cell and specify the cell type with "slide", "subslide","fragment".

However, reveal.js-3.0.0 is now the latest release, and it doesn't work with IPython Notebook slides. The browser dev tools give ReferenceError: Reveal is not defined

One solution is to specify some older version

ipython nbconvert your_nobetook.ipynb --to slides --reveal-prefix "http://cdn.jsdelivr.net/reveal.js/2.6.2" --post serve

And even better option is to clone the reveal.js repo into directory of your_notobook.ipynb and checkout version 2.6.2 via git

git clone https://github.com/hakimel/reveal.js.git
cd reveal.js
git checkout 2.6.2

afterwards this should work

ipython nbconvert your_notobook.ipynb --to slides --post serve

This solution works offline.

As of this moment Damian is working on this issue

Plaining to update to reveal.js 3.0.0 soon... thanks for the report, I will take ASAP.

Indiscipline answered 30/1, 2015 at 7:22 Comment(1)
You probably want to use a submodule rather than a full clone: git submodule add https://github.com/hakimel/reveal.js.git && cd reveal.js && git checkout 2.6.2Dorsman

© 2022 - 2024 — McMap. All rights reserved.