\dfrac 和 \frac 之间的区别#

在此示例中,说明了 \dfrac 和 \frac TeX 宏之间的差异;特别是,使用 Mathtex 时显示样式和文本样式分数之间的差异.

在 2.1 版本加入.

备注

要将 \dfrac 与 LaTeX 引擎 (text.usetex : True) 一起使用,您需要使用 text.latex.preamble rc 导入 amsmath 包,这是一个不受支持的功能;因此,最好在使用 LaTeX 引擎时,在 \frac 宏之前使用 \displaystyle 选项来获得此行为.

dfrac demo
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()

Gallery generated by Sphinx-Gallery