### Bug summary All's in the title. ### Code for reproduction ```python from pylab import *; figtext(.5, .5, r"$a={a$") ``` ### Actual outcome "a = " is printed. ### Expected outcome An exception is thrown. ### Additional information This appears at least as far back as 3.5, so is unlikely to come from the recent mathtext work. ### Operating system macos ### Matplotlib Version 3.8.0.dev1801+g5d5700a99e ### Matplotlib Backend any ### Python version 3.11.3 ### Jupyter version _No response_ ### Installation git checkout