arnog / mathlive

A web component for easy math input
https://cortexjs.io/mathlive
MIT License
1.26k stars 260 forks source link

Can't set "\\right)" as latex for virtual keyboard #2381

Closed truebluepl closed 1 month ago

truebluepl commented 1 month ago

Actual Behavior

Setting \\right) as latex for virtual keyboard key causes generating \right) as keycup and the same string is inserted into MathLive field. With \\left( there is no problem.

Expected Behavior

Latex string \\right) should generate just right parenthesis.

arnog commented 1 month ago

This is a difficult one to fix.

The \left and \right commands are currently treated as a single command that begins with \left and ends with \right. So a \right) is not recognized, because there is no matching \left.

I intend to fix that some day.

In the meantime, the workarounds are to use \left.\right) (an "invisible" left followed by a right), or a \big) and variant, or a plain ) (and let smartfence figure out if it should get translated to a \right)).

truebluepl commented 1 month ago

The problem is that putting "(" or ")" differ from "\left(" or "\right)" in the latex syntax. So for example we get: (x+1)2 and \left(x+1\right)2 But I found fix. Changing key string to "[(]" or "[)]" solving problem (in the latex syntax we get "\left(" and "\right)".

arnog commented 1 month ago

Sorry, I should have been clearer. When using a "plain )", I meant to use {key: ")"}: this produces the same effect as if you typed ) on the keyboard, which will insert a \right) if you have smartfence on and there is a matching \left command.

Using "[)]" will work as well, since it's a shortcut for {key: ")"} with some variants added.

truebluepl commented 1 month ago

I'm sure I got different forms. From virtual keyboard with "(" and ")" set : (x+1)2 From real keyboard: \left(x+1\right)2 When I set "[(]" and "[)]" for virtual keyboard it works like a charm.

arnog commented 1 month ago

Did you use the key property?

truebluepl commented 1 month ago

No. Plain property or via latex property. Whatever - you can close thread:) Thank you!

arnog commented 1 month ago

Right, if you use the key property, it will work. Closing now.