mathnet/mathnet-symbolics

Latex formatting

hbadi opened this issue · 2 comments

hbadi commented

Hi,

Is there a way to modify how the latex formatting is done. I'd love to get "\cdot" for the multication operator. And I'd love to force the formatting to respect the order. For exemple :

string expr = "L1*U1+L2";
var latex = Expr.Parse(expr).ToLaTeX();
Gives "L2 + L1U1"

I want "U1\cdot U1 +L2"

Best regards.

I've partially addressed this: symbols with two or more characters will now render with mathrm, and a cdot will be forced if they appear in a product. So this expression would now render as

$$\mathrm{L2} + \mathrm{L1} \cdot \mathrm{U1}$$

Regarding the ordering: Expressions are automatically ordered, with rules such that in a sum, variables always appear before products. That's why it is reordered this way. However, we already have the concept of Visual Expressions, which don't do any automatic ordering nor any simplifications. In order to fully support your use case where you don't want any reordering or simplifications, we need to split the infix parser into infix -> visual expression -> expression (currently it is directly infix -> expression), the same way the formatting side is already split. This is already planned. Then expressions could be bypassed completely, by going infix -> visual expression -> LaTeX.

Seems like the issue should be closed. LaTeX.formatVisual is implemented and available on a latest published version of the NuGet package