<div dir="ltr">Ok, I had time to look a bit more into this and the following does what I want:<div><br></div><div>==></div><div><div>((*- extends 'article.tplx' -*))</div><div><br></div><div><span style="font-size:13px">% Disable input cells</span><br style="font-size:13px"><span style="font-size:13px">((* block input_group *))</span><br style="font-size:13px"><span style="font-size:13px">((* endblock input_group *))</span><br></div><div><br></div><div>((* block execute_result scoped *))</div><div>    ((*- for type in output.data | filter_data_type -*))</div><div>        ((*- if type in ['text/plain']*))</div><div>\begin{Verbatim}[commandchars=\\\{\}]</div><div>((( output.data['text/plain'] | escape_latex )))</div><div>\end{Verbatim}</div><div>        ((* else -*))</div><div>            ((* block data_priority scoped *))</div><div>            ((( super() )))</div><div>            ((* endblock *))</div><div>        ((*- endif -*))</div><div>    ((*- endfor -*))</div><div>((* endblock execute_result *))</div></div><div><==</div><div><br></div><div style>The problem with the previous suggestion was that the call to super() would call the block "execute_result" in style_ipython.tplx, which would re-add the Out[] prompt that had just been stripped. What we really want is to call the "grandparent" instead of the parent block. So copying the execute_result block from templates/latex/base.tplx (which is what style_ipython.tplx inherits from) works.</div><div style><br></div><div style>The other minor problem was that some of the output wasn't formatted correctly. This is because the "add_prompt" filter in style_ipython.tplx doesn't just add the prompt but also wraps the cell contents in \begin{Verbatim} ... \end{Verbatim}. So once I added this to my custom template it also works correctly.</div><div style><br></div><div style>Even though this achieves what I need it's obviously not ideal because it may break if something in the IPython templates changes or gets rearranged. If I find the time I may try to have a look at how they can be refactored so that less copying of template snippets is needed.</div><div style><br></div><div style>Many thanks again to Matthias and Aaron for their help which got me on the right track!</div><div style><br></div><div style>Cheers,</div><div style>Max</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">2015-03-26 11:32 GMT+00:00 Maximilian Albert <span dir="ltr"><<a href="mailto:maximilian.albert@gmail.com" target="_blank">maximilian.albert@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Hi Aaron,<div><br></div><div>Thanks a lot for your suggestion! This is actually exactly what I tried before sending my email to the list, and it does indeed work in certain cases, but some of my notebooks didn't convert correctly with it. I've put up a minimal example here:</div><div><br></div><div>   <a href="https://github.com/maxalbert/nbconvert-templating-issue" target="_blank">https://github.com/maxalbert/nbconvert-templating-issue</a></div><div><br></div><div>If you type "make" it will use different templates to generate three pdf documents from the notebook "minimal_example.ipynb" (more information on what the templates do is in the README of the repo). You will see that for the cell containing the image with the musical note, the "Out[]" prompt is retained. The notebook "sample_notebook.ipynb" has a slightly longer example, comparing with some other types of output cells for which the "Out[]" prompt is indeed removed.</div><div><br></div><div>I won't have time to dig into this before the weekend, and my jinja-fu is almost zero, so if anyone has a quick idea what's going on here I'd appreciate it.</div><div><br></div><div>Many thanks!</div><div>Max</div></div><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2015-03-24 11:27 GMT+00:00 Aaron O'Leary <span dir="ltr"><<a href="mailto:aaron.oleary@gmail.com" target="_blank">aaron.oleary@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div>Sorry, I misread your question! You only want to remove the output prompts, not the whole output.<br><br></div>Try this:<span><br><br>((*- extends 'article.tplx' -*))                                                                                                                                                   <br>                                                                                                                                                                                   <br>% Disable input cells                                                                                                                                                              <br>((* block input_group *))                                                                                                                                                          <br>((* endblock input_group *))                                                                                                                                                       <br>                                                                                                                                                                                   <br></span><span>((* block execute_result scoped *))                                                                                                                                                <br>    ((*- for type in output.data | filter_data_type -*))                                                                                                                           <br>        ((*- if type in ['text/plain']*))                                                                                                                                          <br></span>            ((( output.data['text/plain'] | escape_latex )))                                                                                                                       <br>        ((* else -*))                                                                                                                                                              <br><span>            ((( super() )))                                                                                                                                                        <br>        ((*- endif -*))                                                                                                                                                            <br>    ((*- endfor -*))                                                                                                                                                               <br>((* endblock execute_result *))<br><br></span></div><br></div>i.e. get rid of both the call to add_prompt and the manual prompt creation.<br></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On 24 March 2015 at 10:35, Aaron O'Leary <span dir="ltr"><<a href="mailto:aaron.oleary@gmail.com" target="_blank">aaron.oleary@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>Hi Max,<br><br></div>This is what you need:<br><br>((*- extends 'article.tplx' -*))<br><br>% Disable input cells<br>((* block input_group *))<br>((* endblock input_group *))<br><br>% Disable output cells<br>((* block output_group *))<br>((* endblock output_group *))<br><br><br></div>You need to use 'output_group' instead of 'execute_result'. There are quite a number of elements in the output and 'output_group' is the block that covers all of them.<br><br></div>You can get an overview of the block hierarchy by looking at 'IPython/nbconvert/templates/latex/skeleton/null.tplx'.<span><font color="#888888"><br><br></font></span></div><span><font color="#888888">aaron<br><div><div><div><br></div></div></div></font></span></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On 24 March 2015 at 01:08, Maximilian Albert <span dir="ltr"><<a href="mailto:maximilian.albert@gmail.com" target="_blank">maximilian.albert@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div><div><div dir="ltr"><span><div>2015-03-23 19:06 GMT+00:00 Matthias Bussonnier <span dir="ltr"><<a href="mailto:bussonniermatthias@gmail.com" target="_blank">bussonniermatthias@gmail.com</a>></span>:<br></div></span><div class="gmail_extra"><div class="gmail_quote"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><br>
</span>I guess you need to inherit the following block :<br>
<br>
<br>
((* block execute_result scoped *))<br>
    ((*- for type in output.data | filter_data_type -*))<br>
        ((*- if type in ['text/plain']*))<br>
            ((( add_prompt(output.data['text/plain'] | escape_latex, cell, 'Out', 'outcolor') )))<br>
        ((* else -*))<br>
\texttt{\color{outcolor}Out[{\color{outcolor}((( cell.execution_count )))}]:}((( super() )))<br>
        ((*- endif -*))<br>
    ((*- endfor -*))<br>
((* endblock execute_result *))<br>
<br>
<br>
form IPython/nbconvert/templates/latex/style_ipython.tplx<br>
<br>
And replace by what you wish.<br></blockquote><div><br></div></span><div><div><br></div><div>Thanks for the suggestion! That's precisely what I tried, but the problem seems to be that the call to super() somehow adds an additional Out[] prompt. I'll try to dig deeper into this when I get the time (and/or make a minimal example available so that it can easily be reproduced), but if anyone has any quick ideas I'm happy to hear them.</div><div><br></div><div>Cheers,</div><div>Max</div><div><br></div>P.S.: I noticed I forgot to include the link to the StackOverflow question I mentioned in my original email. Here it is:<div><br></div><div>   <a href="http://stackoverflow.com/questions/19524554/suppress-code-in-nbconvert-ipython" target="_blank">http://stackoverflow.com/questions/19524554/suppress-code-in-nbconvert-ipython</a><br></div></div><div><br></div></div></div></div>
<br></div></div><span>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
IPython-dev mailing list<br>
<a href="mailto:IPython-dev@scipy.org" target="_blank">IPython-dev@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-dev" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-dev</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div></div>