mathnet-symbolics icon indicating copy to clipboard operation
mathnet-symbolics copied to clipboard

Automatically escape special LaTeX characters in symbol names

Open glazjoon opened this issue 5 years ago • 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 avatar Nov 11 '20 13:11 glazjoon

@glazjoon Can you give some examples?

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

FoggyFinder avatar Dec 10 '20 17:12 FoggyFinder

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

glazjoon avatar Dec 11 '20 15:12 glazjoon

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

FoggyFinder avatar Dec 11 '20 21:12 FoggyFinder

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.

cdrnet avatar Jan 10 '21 10:01 cdrnet