J G*_*rif 7 ipython ipython-notebook
我正在使用nbconvert生成尽可能接近抛光期刊文章的东西.
我已成功使用自定义nbconvert模板隐藏输入代码.该文档现在看起来非常好.
但我不知道如何抑制输出单元格左上角的亮红色'out [x]'语句.任何人都知道任何能够删除它的设置或黑客吗?
谢谢,
约翰
%%HTML
<style>
div.prompt {display:none}
</style>
这将同时隐藏In和Out提示
请注意,这仅在您的浏览器中,笔记本本身当然不会被修改,并且nbconvert
将与以前一样工作。
如果您也希望在nbconvert
ed代码中这样做,只需将放在<style>div.prompt {display:none}</style>
Raw NBConvert单元中。
根据您使用的 IPython 版本,有或多或少的黑客方法可以删除 Out[ ] 提示。
假设您使用latex_article
基础模板,删除了输入块的自定义模板 (sphinx_template.tplx) 可能如下所示
((* 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 *))
Run Code Online (Sandbox Code Playgroud)
要最终删除提示,您需要使用simple
Sphinx风格的模式,因此使用它就像
ipython nbconvert --to latex --SphinxTransformer.output_style=simple --template=sphinx_template.tplx test.ipynb
在 IPython master 中添加了额外的单元格样式,请参见PR4112等。如何使用这些样式如example1和Examples2所示。
总而言之,这里的模板(bw_python.tplx)可能看起来像(带有输入)
((= 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' *))
Run Code Online (Sandbox Code Playgroud)
使用此选项时无需附加选项,因此
ipython nbconvert --to=latex --template=bw_python.tplx test.ipynb
归档时间: |
|
查看次数: |
3340 次 |
最近记录: |