ipython notebook: How to split large cell output to multiple slides when generating reveal.js slideshow

1.2k Views Asked by At

Basically I have a cell which loops through my data and makes various plots. When I use nbconvert to create a reveal.js slideshow, this cell and its output is made as a single long slide that vertically scrolls to show all plots.

I noticed on the nbconvert github issues page some discussion on this topic but I did not see any alternative solutions offered.

Ideally I would like to be able to split this set of plot outputs into individual slides, any idea's on how this can be done or if it is supported?

Thanks.

1

There are 1 best solutions below

1
On

This start to be on the limit of what nbconvert does and might require some work. Basically you will have to understand IPython/nbconvert/templates/skeleton/null.tpl. No need to change the file itself as you can redefine it and give nbconvert other path to search for it if you need more logic. You will have to make a template that overwrite the right blocks In particular you are interested in this section that loops through each output.

{%- block output_group -%}
     {%- block output_prompt -%}{%- endblock output_prompt -%}
          {%- block outputs scoped -%}
                {%- for output in cell.outputs -%}
                .... some stuff
 ... closing blocks

Second problem is that the metadata does not support asking where to split output. But I guess you can probably always make a new output on a new slide on your case. As for "is it supported" the answer will be that you can overwrite almost everything you like, but we try to keep a bare minimum in IPython itself.

I know the doc is missing on that and we'll try to fix that up. If you're ready to hack for a day or two I think what you ask is doable, but will need some deep diving into how nbconvert works.

Note that there is a IPython wiki page where we should put example of custom templates that hasn't be filled yet.