Skip to content

[ENH]: Parse "\limits" in mathtext #28051

@ChenZiHong-Gavin

Description

@ChenZiHong-Gavin

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

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions