{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# The difference between \\\\dfrac and \\\\frac\n\nIn this example, the differences between the \\\\dfrac and \\\\frac TeX macros are\nillustrated; in particular, the difference between display style and text style\nfractions when using Mathtex.\n\n.. versionadded:: 2.1\n\n

Note

To use \\\\dfrac with the LaTeX engine (text.usetex : True), you need to\n import the amsmath package with the text.latex.preamble rc, which is\n an unsupported feature; therefore, it is probably a better idea to just\n use the \\\\displaystyle option before the \\\\frac macro to get this behavior\n with the LaTeX engine.

\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n\nfig = plt.figure(figsize=(5.25, 0.75))\nfig.text(0.5, 0.3, r'\\dfrac: $\\dfrac{a}{b}$',\n horizontalalignment='center', verticalalignment='center')\nfig.text(0.5, 0.7, r'\\frac: $\\frac{a}{b}$',\n horizontalalignment='center', verticalalignment='center')\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.2" } }, "nbformat": 4, "nbformat_minor": 0 }