Question

I'm plotting the head of some dataframes in my notebook, and they fit just fine to the notebook width. But when converting to slides with the reveal.js, the tables are being cut in the middle.

Is there a way to make the width of the resulted slide-show the same as the width of the notebook? Or any other why to make sure the cell output of the notebook will be fully presented in the slides?

Was it helpful?

Solution 2

Here is how to fix it:

on cmd - create the presentation html by:

ipython nbconvert --to slides yournotebook.ipynb that will create an html file. open the html file and go to the reveal.initilize() section. In it, enter the desired width of the presentation such that it will fit the width of the dataframe, e.g.:

Reveal.initialize({

    ...

    // The "normal" size of the presentation, aspect ratio will be preserved
    // when the presentation is scaled to fit different resolutions. Can be
    // specified using percentage units.
    width: 960,
    height: 700,  

});

OTHER TIPS

To avoid parsing the HTML afterwards, a more streamlined solution would be to make a copy of the reveal template,

make the changes to the template such as below, more details on configuration options can be found on reveal.js#presentation-size.

Reveal.initialize({

...

// The "normal" size of the presentation, aspect ratio will be preserved
// when the presentation is scaled to fit different resolutions. Can be
// specified using percentage units.
width: 960,
height: 700,  

});

and then save it into your jupyter templates path (you can find it by typing jupyter --path)

for example, on linux you can put it in ~/.local/share/jupyter/templates

save it as slides_wide.tpl

then you can call nbconvert using:

jupyter nbconvert --template slides_wide.tpl --to slides yournotebook.ipynb
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top