
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/text_labels_and_annotations/dfrac_demo.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_text_labels_and_annotations_dfrac_demo.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_text_labels_and_annotations_dfrac_demo.py:


=========================================
The difference between \\dfrac and \\frac
=========================================

In this example, the differences between the \\dfrac and \\frac TeX macros are
illustrated; in particular, the difference between display style and text style
fractions when using Mathtex.

.. versionadded:: 2.1

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

.. GENERATED FROM PYTHON SOURCE LINES 20-29



.. image-sg:: /gallery/text_labels_and_annotations/images/sphx_glr_dfrac_demo_001.png
   :alt: dfrac demo
   :srcset: /gallery/text_labels_and_annotations/images/sphx_glr_dfrac_demo_001.png, /gallery/text_labels_and_annotations/images/sphx_glr_dfrac_demo_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python


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


.. _sphx_glr_download_gallery_text_labels_and_annotations_dfrac_demo.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: dfrac_demo.ipynb <dfrac_demo.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: dfrac_demo.py <dfrac_demo.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: dfrac_demo.zip <dfrac_demo.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
