I reported the following bug:

https://savannah.gnu.org/bugs/?51782Actually, I have narrowed it down to the formatter that is called inside publish.m. I know that the problem happens somewhere inside __publish_latex_output__.m, specifically in escape_latex.

this is the starting string:

$$e^x = \lim\limits_{n\rightarrow\infty}\left(1+\dfrac{x}{n}\right)^{n}$$

and this is the result after being processed by 'escape_latex':

$$e\^{}x = \lim\limits\_{n\rightarrow\infty}\left(1+\dfrac{x}{n}\right)\^{}{n}$$

why are "_" and "^" being escaped?

In addition, replacing "^" with "\^{}" seems wrong as this doesn't encapsulate the argument that follows.