Skip to content

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

Closed as duplicate

Description

@Mackemania

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

Activity

  1. anntzer commented on Apr 8, 2025

    @anntzer
    Contributor

    FWIW I cannot reproduce the issue?

  2. jklymak commented on Apr 8, 2025

    @jklymak
    Member

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

    @Mackemania how have you installed LaTeX

  3. oscargus commented on Apr 9, 2025

    @oscargus
    Member

    @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.)

  4. 2shaar commented on Apr 10, 2025

    @2shaar

    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)

  5. davidlowryduda commented on Apr 16, 2025

    @davidlowryduda
    Contributor

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

  6. davidlowryduda commented on Apr 16, 2025

    @davidlowryduda
    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

  7. self-assigned this
    on Apr 17, 2025
  8. QuLogic commented on Apr 17, 2025

    @QuLogic
    Member

    This is in fact a duplicate of #5210.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions