如何在python中设置latex包选项?你知道吗
我正在尝试设置siunitx。我不知道如何设置选项。这也直接适用于matplotlibrc
。
以下操作不起作用。你知道吗
import matplotlib as mpl
mpl.rc('text', usetex=True)
mpl.rcParams['text.latex.preamble'] = '\usepackage[range-units = single,range-phrase={-}]{siunitx}'
## using the following instead of the previous line works...
# mpl.rcParams['text.latex.preamble'] = '\usepackage[range-units = single]{siunitx},\sisetup{range-phrase={-}}'
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(1,100,1)
y=x
fig=plt.figure()
ax=fig.add_subplot(111)
ax.plot(x,y,label=r'\SIrange{0}{1}{\metre\per\second}')
ax.legend(loc=0)
既然代码段是有效的,我建议使用逗号。我试过\,
或','
,但运气不好。我在Mac电脑上用jupyter notebook
试了一下。
在默认的matplotlibrc
中
#text.latex.preamble : ## IMPROPER USE OF THIS FEATURE WILL LEAD TO LATEX FAILURES
## AND IS THEREFORE UNSUPPORTED. PLEASE DO NOT ASK FOR HELP
## IF THIS FEATURE DOES NOT DO WHAT YOU EXPECT IT TO.
## preamble is a comma separated list of LaTeX statements
## that are included in the LaTeX document preamble.
## An example:
## text.latex.preamble : \usepackage{bm},\usepackage{euler}
## The following packages are always loaded with usetex, so
## beware of package collisions: color, geometry, graphicx,
## type1cm, textcomp. Adobe Postscript (PSSNFS) font packages
## may also be loaded, depending on your font settings
不幸的是,除了在注释中指定的内容外,我找不到任何关于正确使用此选项的信息。。。你知道吗
有什么想法吗?你知道吗
我希望将前导字符串括在一个列表中会有所帮助。你知道吗
相关问题 更多 >
编程相关推荐