在ipython3笔记本(4.0.0)的markdown单元格中,我包含一个与笔记本文件一起放置的svg:
<img src="NewTux.svg"/>
在普通笔记本视图中,它会按预期显示。 但是,当我尝试导出到pdf时,图像不会显示。
让我感到困惑的是,matplotlib图(带有%config InlineBackend.figure_format = 'svg'
)在导出的PDF中完美地显示在屏幕上和显示中。
我如何获得PDF,包括未绘制但仅包含在降价中的数字的svgs? (一种解决方法是在浏览器中打印到pdf,但在代码部分的语法高亮显示中我会错过LaTeX格式,公式和颜色。)
ipython文件的最低工作示例是:
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%config InlineBackend.figure_format = 'svg'\n",
"import numpy as np\n",
"import matplotlib.pyplot as pp\n",
"\n",
"x = np.arange(0,10,0.05)\n",
"y = np.sin(x)\n",
"\n",
"pp.plot(x,y)\n",
"pp.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<img src=\"NewTux.svg\">"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
我从Wikimedia commons下载的NewTux.svg。