mathnet/mathnet-symbolics

Automatically escape special LaTeX characters in symbol names

glazjoon opened this issue · 4 comments

I have situations where my symbol names contain characters that require escaping when using LaTeX, such as underscore. Considering the names are considered valid by MathNet, I sort of expected them to behave correctly in LaTeX generated by it.

Is there any chance you could add automatic escaping of special characters when they are part of a symbol name?

@glazjoon Can you give some examples?

"a_1+a_2" input produces \mathrm{a_{1}} + \mathrm{a_{2}} output. What result would be desirable?

Desired output would be \mathrm{a\_{1}} + \mathrm{a\_{2}}

Since I'm not confident with LaTeX I decided to clarify this moment.

samcarter: Both are valid, just with different output. a_{2} will result in a subscript, a_{2} will give a_2. The question is what the user wants to have

quote is taken from TopTeX chat

Current output looks better to me but probably the best option (for this specific case) would be adding a some property to make it more customizable?

@cdrnet

The rendering of x_10 style symbols as subscript in LaTeX is actually a feature that was requested some time ago (and which I quite like). This is also why it adds braces.

We do have a concept of styles (i.e. configurations) to control aspects like this, maybe we could make it possible to control this that way, so you could disable it.