#28051·matplotlib

[ENH]: Parse "\limits" in mathtext

Author: ChenZiHong-GavinCreated Apr 9, 2024Updated Sep 10, 2026
LabelsNew featuretopic: text/mathtext

Bug summary

I encountered an issue while using the mathtext module in matplotlib. The problem arises when trying to parse LaTeX expressions containing the "\limits" command. The "\limits" command is used in LaTeX to specify that certain mathematical operators should have their subscripts and superscripts displayed above and below, especially when used with "\int".

For example, \int \limits _ { v } ^ { \mu e } e d A get image and \int_ { v } ^ { \mu e } e d A get image

Code for reproduction

python
from matplotlib import mathtext
latex_text = r"$\int\limits_{ v } ^ { \mu e } e d A$"
mathtext.math_to_image(latex_text, 'test.png')

Actual outcome

ValueError: \int\limits_{ v } ^ { \mu e } e d A ^ ParseFatalException: Unknown symbol: \limits, found '' (at char 4), (line:1, col:5)

Expected outcome

image

Additional information

No response

Operating system

Windows

Matplotlib Version

3.8.4

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.9.13

Jupyter version

1.0.0

Installation

pip