When entering a number in the placeholder, it is mandatory to enclose it within curly braces
When I input "1/2", I hope both "1" and "2" can be enclosed in curly braces instead of having the braces automatically removed. I've searched through the documentation but haven't found a solution. There is a property called "removeExtraneousParentheses", but it doesn't work. I expect the result to be "\frac{1}{2}" instead of "\frac12". Is there any way to solve this problem?
Unfortunately, no, there isn't. The braces are not required in LaTeX when the arguments are single digits.
I would like to enforce braces around single arguments so that expressions passed from other libraries (such as react-math-keyboard) like \frac{3}{4} can be compared with MathLive's \frac34. I tried setting removeExtraneousParentheses: false as mentioned in the documentation, hoping it would force MathLive to preserve the braces, but it had no effect. I might be misunderstanding the purpose of this option.
If MathLive does not automatically wrap single arguments in braces, what's the recommended way to determine whether two LaTeX expressions like \frac{3}{4} and \frac34 are equivalent?
I would like these two formulas to be equal:
const latex1 = "\\frac{3}{4}";
const latex2 = "\\frac34";
console.log(latex1 === latex2)
removeExtraneousParentheses has nothing to do with braces. Braces are these characters: {}, parentheses are (). The option will remove parentheses if you paste for example (x+1)/(x-1) so that it becomes \frac{x+1){x-1} instead of \frac{(x+1)}{(x-1)}.
If you want to compare two LaTeX expressions, that can get quite complicated. For example \frac {3} {4} is another valid representation of \frac34. The best way would be to use MathJSON. You can use mf.expression to get a representation of the expression that doesn't depend on typesetting notation or ce.parse() to parse the LaTeX to MathJSON.
You could also try to remove unnecessary braces with a RegEx expression using something like: latex.replace(/{(\d)}/g, "$1").
This an issue \frac34 is 1/34 or 3/4 ? I have to enter 3\codt4^-1 to get the correct value if i want 3/4 ??
The problem is on one digit frac 1/34 yields \frac{1}{34} 8/9 yields \frac89
\frac34 is \frac{3}{4}. That's the way LaTeX works.