ipython notebook - How to add latex figure captions below jupyter / matplotlib figures -
from within jupyter notebook, there way add latex figure caption below each inline matplotlib figure? desired each figure annotated when running nbconvert --to latex.
but not clear on how position latex relative figure ends in \begin{verbatim} block. can place in markdown cell after plot; but, not wrap figure want.
a bit of workaround following helper function calls plt.close() keep inline figures being displayed leaving generated latex block figure.
bshowinline = true # set = false document generation def makeplot( plt, figlabel, figcaption): figname = figlabel+'.png' plt.savefig(figname) if bshowinline: plt.show() else: plt.close() strlatex=""" \\begin{figure}[b] \centering \includegraphics[totalheight=10.0cm]{%s} \caption{%s} \label{fig:%s} \end{figure}"""%(figname, figcaption, figlabel) return display(latex(strlatex))
is there cleaner way?
Comments
Post a Comment