ipython notebook nbconvert - 如何删除单元格输出左上角的红色“out[N]"文本? [英] ipython notebook nbconvert - how to remove red 'out[N]' text in top left hand corner of cell output?
问题描述
我正在使用 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 ?
谢谢,
约翰
推荐答案
根据您使用的 IPython 版本,有或多或少的黑客方法可以删除 Out[ ] 提示.
Depending on the version of IPython you are using, there are more or less hackish ways to remove the Out[ ] prompts.
假设您使用 latex_article
基础,带有删除输入块的自定义模板 (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 *))
要最终删除提示,您需要使用Sphinx样式的simple
模式,因此像这样使用ipython nbconvert --to 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 中添加了额外的单元格样式,参见例如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屋!