ipython notebook nbconvert - 如何删除单元格输出左上角的红色'out [N]'文本? [英] ipython notebook nbconvert - how to remove red 'out[N]' text in top left hand corner of cell output?

查看:556
本文介绍了ipython notebook nbconvert - 如何删除单元格输出左上角的红色'out [N]'文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用nbconvert生成尽可能接近抛光期刊文章的内容。

I am using nbconvert to produce something as close as possible to a polished journal article.

我使用自定义nbconvert模板成功隐藏了输入代码。该文档现在看起来非常好。

I have successfully hidden input code using a custom nbconvert template. The doc is now looking very nice.

但我不知道如何抑制输出单元格左上角的亮红色'out [x]'语句。任何人都知道任何能够删除它的设置或黑客吗?

But I don't know how to suppress the bright red 'out[x]' statement in the top left corner of the output cells. Anyone know of any settings or hacks that are able to remove this also ?

谢谢,

John

推荐答案

根据您使用的IPython版本,有一些或多或少的hackish方法可以删除Out []提示。

Depending on the version of IPython you are using, there are more or less hackish ways to remove the Out[ ] prompts.

假设您使用 latex_article base,一个带有删除输入块的自定义模板(sphinx_template.tplx)可能看起来像

Assuming that you use the latex_article base, a custom template (sphinx_template.tplx) with removed input blocks could look like

((* extends 'latex_article.tplx' *))
((* block input *))
((* endblock input *))
((* block output_group *))
   % Add remainer of the document contents below.
   ((* for output in cell.outputs *))
        ((( render_output(output) )))
   ((* endfor *))
((* endblock *))

要最终删除提示,您需要使用 simple Sphinx风格的模式,因此使用它像
ipython nbconvert - 到latex --SphinxTransformer.output_style = simple --template = sphinx_template.tplx test.ipynb

To finally remove the prompt, you need to use the simple mode of the Sphinx style, hence use it like ipython nbconvert --to latex --SphinxTransformer.output_style=simple --template=sphinx_template.tplx test.ipynb

在IPython master中添加了其他单元格样式,请参阅eg PR4112
如何使用这些样式如图所示在 example1 examples2

In IPython master additional cell styles have been added, see e.g. PR4112. How to use these styles is shown e.g. in example1 and examples2.

总结一下,这里是模板(bw_python。 tplx)看起来像(带输入)

To sum up, here the template (bw_python.tplx) could look like (with inputs)

((= This line selects the cell style. =))
((* set cell_style = 'style_bw_python.tplx' *))

((= This line inherits from the built in template that you want to use. =))
((* extends 'latex_article.tplx' *))

这是在没有附加选项的情况下使用的,因此
ipython nbconvert --to = latex --template = bw_python.tplx test.ipynb

This is used without additional options, hence ipython nbconvert --to=latex --template=bw_python.tplx test.ipynb

这篇关于ipython notebook nbconvert - 如何删除单元格输出左上角的红色'out [N]'文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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