Ipython notebook nbconvert - how to remove red text from [N] 'in the upper left corner of cell output?

I use nbconvert to create something as close to a polished magazine article as possible.

I successfully hid the input code with a custom nbconvert template. The dock now looks very beautiful.

But I don’t know how to suppress the bright red expression [x] 'in the upper left corner of the output cells. Does anyone know of any settings or hacks that can also remove this?

Thanks,

John

+6
source share
2 answers

Depending on the version of IPython you are using, there are more or less hacker methods for removing Out [] hints.

Ipython 1.x

Assuming you are using latex_article base, a custom template (sphinx_template.tplx) with input blocks removed might 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 *)) 

To permanently delete a prompt, you must use Sphinx's simple style mode, so use it as ipython nbconvert --to latex --SphinxTransformer.output_style=simple --template=sphinx_template.tplx test.ipynb

IPython Wizard

In the IPython class, additional cell styles have been added, see, for example, PR4112 . How to use these styles is shown, for example. in example1 and examples2 .

To summarize, here the template (bw_python.tplx) might look (with input)

 ((= 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' *)) 

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

+3
source

%%HTML <style> div.prompt {display:none} </style>

This will hide the In and Out prompts.

Please note that this is only in your browser, the laptop itself is not modified, and nbconvert will work the same way as before.

If you want to do this in the nbconvert ed code, just put the <style>div.prompt {display:none}</style> in the Raw NBConvert cell.

+4
source

Source: https://habr.com/ru/post/958753/


All Articles