使用Table of Content将IPython笔记本编写为HTML或PDF [英] Writing an IPython notebook to HTML or PDF with Table Of Content
问题描述
我试图从我的IPython笔记本创建报告。我使用toc扩展为我的nb创建了一个toc。
我已经将笔记本转换为html,但是toc没有显示,也没有链接到doc的其余部分。有没有办法转换到指定的fromat之一,仍然保持一个可链接(甚至不可链接)的TOC?
Im trying to create a report from my IPython notebook. Im using the toc extension to create a toc for my nb. I already converted the notebook to html, but the toc is not shown and is not linking to the rest of the doc. Is there any way to convert to one of the specified fromat and still keep a link-able (or even non-link-able) TOC?
推荐答案
假设您使用IPython 1.x,您可以使用以下选项将toc包含在 pdf
-
使用latex_book模板
(ipython nbconvert --to = latex --template = latex_book --post = pdf file.ipynb
)扩展latex_article(默认)模板
在工作中创建一个包含以下内容(例如toc_latex.tplx)的文件dir:extend the latex_article (default) template
Create a file with the following content (e.g. toc_latex.tplx) in the working dir:((*- extends 'latex_article.tplx' -*)) ((* block toc *))\tableofcontents((* endblock toc *))
将它用作模板,如
ipython nbconvert --to = latex --template = toc_latex --post = pdf file.ipynb
-
使用latex_report模板
(ipython nbconvert --to = latex --template = latex_report --post = pdf file.ipynb
)
自定义模板可能类似于
((*- extends 'latex_article.tplx' -*)) ((* block abstract *))\tableofcontents((* endblock abstract *))
-
中
这篇关于使用Table of Content将IPython笔记本编写为HTML或PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!