将ipython笔记本电脑转换为揭示幻灯片显示时,输出不够宽



我正在绘制笔记本中某些数据范围的头部,它们非常适合笔记本宽度。但是,当用显示示例转换为幻灯片时,桌子在中间切割。

是否有一种方法可以使所产生的幻灯片显示的宽度与笔记本的宽度相同?或其他任何其他原因为什么要确保笔记本的单元格输出将完全显示在幻灯片中?

为了避免后来解析HTML,更简化的解决方案将是制作揭示模板的副本,

对模板进行更改,例如以下,有关配置选项的更多详细信息可以在devale.js#essingation-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模板路径中(您可以通过键入jupyter --path找到它)

例如,在Linux上,您可以将其放入~/.local/share/jupyter/templates

将其保存为slides_wide.tpl

然后您可以使用以下方式调用NBConvert

jupyter nbconvert --template slides_wide.tpl --to slides yournotebook.ipynb

这是如何修复它的方法:

在CMD上 - 创建演示文稿html:

ipython nbconvert --to slides yournotebook.ipynb将创建一个HTML文件。打开HTML文件,然后转到drabe.Initilize()部分。在其中,输入演示文稿的所需宽度,以使其适合数据框的宽度,例如:

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,  
});

最新更新