is there a way to stop the evaluation of the a string while using .Latexise() function
Closed this issue · 11 comments
I am trying to parse a string to Latex, while doing so any given numbers in the string are usually evaluated and turned into one long hard to read number, is there a way to stop that ?
Hi, sure, I will give you a simple one, "0.86 * (WV/190)^2".Latexise(); returns
also for some reason, hyperbolic tan is dealt with in it´s exponential form and messing up the equation badly,
using this code "(0.578)/sqrt(tanh((3.68*Hf)/(D)))".Latexise() gives you what what is given above
the only thing which could lead to such case is evaluating/simplifying the expressions at some point after calling Latexise() function
also for some reason, hyperbolic tan is dealt with in it´s exponential form and messing up the equation badly
Yeah, that's fair. The reason is because we don't have a separate entity for tanh
, so it's just straight substituted, like this
Let me check my code, I will be back.
"Ac * Wc".Latexise() for some reason doesn´t show the multiplication sign
Yeah. The idea was to mimic math notation, where we also often omit it. I agree that it's ambiguous in this case, thanks for the report.
the problem is => Q * Fv * (S1) is written as
regarding the disappearance of the multiplication sign, is there a way to just turn it of ? or force it to always write it?
I'm afraid, no. You can make a workaround the following way:
- Create your own node instead of
Entity.Mulf
, e. g.ExplicitMul
and inherit it fromEntity
- Using method
Replace
you can replace it with your node:
public Entity ReplaceMul(Entity expr) => expr switch
{
Entity.Mulf(var a, var b) => new ExplicitMul(a, b),
var other => other
};
...
var newExpr = expr.Replace(ReplaceMul);
And for your ExplicitMul
, override method Latexise
to always display the multiplication sign. Here's the current implementation of Latexise for Entity.Mulf