How to add latex figure captions below jupyter / matplotlib figures

ipython-notebookjupyterlatex

From within the jupyter notebook, is there a way to add latex figure caption below each inline matplotlib figure? This is desired so that each figure is annotated when running nbconvert –to latex.

But I am not clear on how to position the LaTeX relative to the figure which ends up in \begin{verbatim} block. I can place it in a markdown cell just after the plot; but, that does not wrap the figure as I want.

Best Answer

You can add captions by following the example at Making Publication Ready Notebooks a blog post by a Mr. Julius Schulz. The technique basically boils down to adding the caption as part of the JSON metadata for the cell in which you generate the figure and then providing the right instructions in the template you pass to nbconvert. I have directly copy pasted the section of Julius' template file which draws the figures as I am not too hot on the Jinja templates front. The blog post was very helpful for me.

Related Topic