我在筆記本中繪製了一些數據框的頭部,並且它們對筆記本寬度也很合適。但當用reveal.js轉換爲幻燈片時,桌子正在中間被切割。將Ipthon筆記本轉換爲顯示幻燈片時輸出不夠寬
有沒有辦法讓結果幻燈片的寬度與筆記本的寬度相同?或者其他任何爲什麼要確保筆記本的單元輸出完全呈現在幻燈片中?
我在筆記本中繪製了一些數據框的頭部,並且它們對筆記本寬度也很合適。但當用reveal.js轉換爲幻燈片時,桌子正在中間被切割。將Ipthon筆記本轉換爲顯示幻燈片時輸出不夠寬
有沒有辦法讓結果幻燈片的寬度與筆記本的寬度相同?或者其他任何爲什麼要確保筆記本的單元輸出完全呈現在幻燈片中?
這裏是如何解決它:
在CMD - 通過創建演示文稿HTML:
ipython nbconvert --to slides yournotebook.ipynb
,這將創建一個HTML文件。打開html文件並轉到reveal.initilize()部分。 在這裏面,enter the desired width of the presentation使得其將適合數據框的寬度,如:
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,
});
爲了避免事後解析HTML,更精簡的解決辦法是讓reveal template的副本,
對模板進行如下更改,有關配置選項的更多詳細信息,請參閱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,
});
,然後將其保存到您的jupyter模板路徑
例如,在Linux(您可以通過鍵入jupyter --path
找到它),你可以把它放在~/.local/share/jupyter/templates
保存爲slides_wide.tpl
那麼你可以打電話給nbconvert使用:
jupyter nbconvert --template slides_wide.tpl --to slides yournotebook.ipynb