注意
前往末尾以下载完整示例代码。
\dfrac 与 \frac 之间的区别#
本示例阐述了 \dfrac 和 \frac TeX 宏之间的区别;特别是使用 Mathtex 时,显示样式分数与文本样式分数之间的区别。
在 2.1 版本中新增。
注意
要在 LaTeX 引擎(text.usetex : True)中使用 \dfrac,您需要通过 text.latex.preamble rc 导入 amsmath 包,但这是一个不受支持的功能;因此,更好的做法可能是在 \frac 宏之前使用 \displaystyle 选项,以在 LaTeX 引擎中获得此行为。

import matplotlib.pyplot as plt
fig = plt.figure(figsize=(5.25, 0.75))
fig.text(0.5, 0.3, r'\dfrac: $\dfrac{a}{b}$',
horizontalalignment='center', verticalalignment='center')
fig.text(0.5, 0.7, r'\frac: $\frac{a}{b}$',
horizontalalignment='center', verticalalignment='center')
plt.show()