如何解决带有 lualatex 的 matplotlib pgf 后端 - 非数学字体不会改变
我有时需要 lualatex
引擎使用 matplotlib 的 pgf 后端,当产生像 hexbin 这样的“更重”的图时,否则超出 TeX 内存并且 pdflatex
失败。使用 lualatex
时,数学字体似乎根据我的 pgf.preamble
发生变化,但是字体的其余部分没有变化,并且保持为 CM Roman。使用 pdflatex
,字体表现得如我所愿。请注意,如果我转到 www.overleaf.com 并使用相同的前导码并使用 pdflatex
或 lualatex
进行编译,文档会显示我想要的字体,包括数学和正文。
代码:
import matplotlib as mpl
eng = 'lua' # issue with lua only <<<<<<<<
# eng = 'pdf' # no issue here
mpl.use('pgf')
mpl.rc('font',family='serif')
mpl.rcParams.update({
"pgf.rcfonts" : False,"pgf.texsystem": eng + "latex","pgf.preamble" : '\\usepackage[utf8x]{inputenc}\\usepackage[light]{kpfonts}',})
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0,6,100)
x = np.sin(t)
fig,ax = plt.subplots()
ax.plot(t,x,label='A line')
plt.title('A function,$f(x) = \sin(x)$')
plt.legend()
plt.savefig('example.pdf')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。