打印Jupyter笔记本幻灯片的最佳方式是什么?如何设置分页符? [英] Best way to print Jupyter notebook slides? How to put a page break?

查看:382
本文介绍了打印Jupyter笔记本幻灯片的最佳方式是什么?如何设置分页符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打印我的jupyter笔记本,并与非程序员同事共享硬拷贝。

I want to print my jupyter notebook and share the hardcopy with non-programmer coworkers.

我到目前为止所做的:

  • I've figured out the way to hide the code :How to hide code from cells in ipython notebook visualized with nbviewer?
  • I've figre out the way to convert the notebook to slides(html) Is there a way to print a jupyter/ipython notebook slide presentation? This post also suggests how to convert the html to pdf.

我的问题:
如何放置分页符在每个PDF页面上指定内容?

My question: How to put a page break to specify the contents on each pdf page?

将幻灯片(html)转换为pdf后,文本和图形不在PDF中的预期位置。我希望图形和解释图形的文本位于同一页面中。我是否需要在Jupyter笔记本的降价单元中放置一些分页符?或者如何在pdf的每个页面上指定内容,而不是让浏览器决定

Once I convert the slides(html) to pdf, the text and graph is not at the expected location in pdf. I want the graph and the text explaining the graph to be in the same page. Do I need to put some page breaks in markdown cell of my Jupyter notebook? Or how to specify the content on each page of pdf, instead of letting the browser decide

另外,我试图直接将Jupyter notebok转换为pdf,但遇到问题:将jupyter笔记本转换为pdf:安装pandoc时遇到错误

Also, I'm trying to convert Jupyter notebok directly to pdf, but encounters issues: Convert jupyter notebook to pdf: Error encounters when install pandoc

推荐答案

我发现了几个提到的地方,包括分页单元中的分页符的HTML代码。我得到了这个工作,但只有通过:

I found several places which mentioned including HTML code for the page break in a markdown cell. I got this to work, but only by:


  1. 在分页单元中包含分页符的HTML。使用的代码是< p style =page-break-after:always;>< / p>
  2. 使用 nbconvert 将其导出为HTML。为此,命令行将是 jupyter nbconvert --to html YourNotebook.ipynb
  3. 然后我可以打开该静态HTML文件Chrome。

  4. 最后,从Chrome中选择打印并选择另存为PDF

  1. Include HTML for a page break in a markdown cell. The code used was <p style="page-break-after:always;"></p>
  2. Export it to HTML with nbconvert. For this, the command line would be jupyter nbconvert --to html YourNotebook.ipynb
  3. I could then open that static HTML file with Chrome.
  4. Finally, choose print from within Chrome and choose save as PDF.

在查看 .ipynb 文件或使用 nbconvert 直接转到PDF,但没有任何工作。导出为HTML,然后打开HTML并保存为PDF格式。

I tried other methods such as print when viewing the .ipynb file or using nbconvert to go straight to PDF, but none of that worked. Exporting to HTML and then opening the html and saving as PDF did work.

这篇关于打印Jupyter笔记本幻灯片的最佳方式是什么?如何设置分页符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆