tnt*_*tnt 6 latex ipython-notebook jupyter
在 jupyter notebook 中,有没有办法在每个内联 matplotlib 图形下方添加乳胶图形标题?这是需要的,以便在运行 nbconvert --to latex 时对每个数字进行注释。
但我不清楚如何相对于以 \begin{verbatim} 块结束的图形定位 LaTeX。我可以将它放在情节之后的降价单元格中;但是,这并没有像我想要的那样包裹这个数字。
有点解决方法,但以下辅助函数调用 plt.close() 以防止显示内联图形,只留下为图形生成的 LaTeX 块。
bShowInline = True # Set = False for 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))
Run Code Online (Sandbox Code Playgroud)
有更干净的方法吗?