Skip to content

[Bug]: \right) is replaced with exclamation mark when using fontset='cm' #29886

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Mackemania opened this issue Apr 8, 2025 · 7 comments
Closed
Assignees

Comments

@Mackemania
Copy link

Mackemania commented Apr 8, 2025

Bug summary

This is similar to 5210. The right big parenthesis is replaced with an exclamation mark for certain latex code.

Multiple queries were tested as follows.

Code for reproduction

import matplotlib.pyplot as plt

plt.rc('mathtext', fontset='cm')
working_texts = ['\\left(\\int_x \\right)', '\\left(\\int^x \\right)']
bugged_texts = ['\\left(\\int_x^x \\right)', '\\left(\\int_{x}^{x} \\right)']
plt.text(0.5, 0.5, fr'${bugged_texts[0]}$', parse_math=True)
plt.show()

Actual outcome

Actual:
Image

Expected outcome

Expected:
Image
(But with the upper bound of the integral present)

Additional information

I have only tested with mathtext fontset 'cm' and without setting it. The default font does display it correctly.
As far as I've tested it only happens when both upper and lower bound of the integral is set. Using \sum or \iint instead of \int also works correctly with both bounds. \oint however causes the same issue.

Operating system

Windows

Matplotlib Version

3.10.0

Matplotlib Backend

module://backend_interagg

Python version

3.12.5, 3.13

Jupyter version

No response

Installation

pip

@anntzer
Copy link
Contributor

anntzer commented Apr 8, 2025

FWIW I cannot reproduce the issue?

@jklymak
Copy link
Member

jklymak commented Apr 8, 2025

I can't reproduce it either. @oscargus did you get this to happen?

@Mackemania how have you installed LaTeX

@jklymak jklymak added the status: needs clarification Issues that need more information to resolve. label Apr 8, 2025
@oscargus
Copy link
Member

oscargus commented Apr 9, 2025

@oscargus did you get this to happen?

No. (I have some weird installation issue on my Windows laptop, so wasn't able to try it. Just tagged it.)

@2shaar2059
Copy link

I am able to reproduce the issue. My system:

╰─$ pip3 list | grep matplotlib
matplotlib                           3.6.3
matplotlib-inline                    0.1.6

╰─$ python3 --version                      
Python 3.12.3

I'm on 24.04.2 LTS (Noble Numbat)

@davidlowryduda
Copy link
Contributor

I can also reproduce this issue. I have matplotlib 3.10.1 and matplotlib-line 0.1.7, with python 3.12.3.

@davidlowryduda
Copy link
Contributor

Here is some more information. With the following code

import matplotlib.pyplot as plt
plt.rc('mathtext', fontset='cm')
import matplotlib.mathtext
import matplotlib.font_manager as fm

for s in range(10, 35):
    fp = fm.FontProperties(size=s)
    matplotlib.mathtext.math_to_image("$\\left(\\int_x^x \\right) \\quad + 1$", f'example{s}.png', prop=fp)

I get the exclamation point output for sizes 10-14, and 16; but not any of the others. This is very similar behavior to #5210

@QuLogic
Copy link
Member

QuLogic commented Apr 17, 2025

This is in fact a duplicate of #5210.

@QuLogic QuLogic closed this as completed Apr 17, 2025
@QuLogic QuLogic removed the status: needs clarification Issues that need more information to resolve. label Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants