How do I separate slides when exporting an IPython

2019-04-07 02:37发布

问题:

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?

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)

回答1:

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



回答2:

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.



回答3:

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:

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: ?