问题描述
我已经阅读了几乎所有关于问题的解决方案/建议的帖子:
运行时错误:无法使用 tex 处理字符串,因为找不到 Latex
但是我还没有能够解决这个问题。
我使用的是 Windows 10,并尝试了以下所有方法:
- 在 Ubuntu 中:
pip install latex
sudo apt-get install dvipng
sudo apt-get install -y texlive texlive-latex-extra texlive-latex-recommended
- 在 Jupyter 中:
pip install latex
conda install -c conda-forge jupyter_latex_envs
conda install -c conda-forge/label/cf201901 jupyter_latex_envs
conda install -c conda-forge/label/cf202003 jupyter_latex_envs
当我在 Jupyter 上运行 latex
时,我在列表中看到 pip list
。
我尝试了上述方法后重新启动了计算机,但无济于事。
我正在尝试的示例非常简单:
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,10,num=50)
fx = np.exp(-x)*np.cos(x)
plt.rc('text',usetex=True)
plt.rc('font',family='serif')
fig,ax = plt.subplots()
ax.plot(x,fx)
ax.legend(['$e^{-x}cos(x)$'])
ax.set_xlabel(r'$x$')
ax.set_ylabel(r'$f(x)$');
我差点没能逃脱:
plt.rcParams['font.serif'] = 'Times New Roman'
plt.rcParams['font.family'] = "serif"
plt.rcParams['mathtext.fontset'] = "cm"
但是“Computer Modern Roman”不起作用,理想情况下我想让 useTex=True
工作。
有人能指教我吗?
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)