arnog / mathlive

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

One dimensional vectors cause confusion #350

Open Khazuar opened 4 years ago

Khazuar commented 4 years ago

Describe the bug Pressing ENTER within parentheses converts them into a vector. Removing the newline again doesn't convert it back, so you're stuck with a one-dimensional vector.

To Reproduce [Steps to reproduce the behavior, for example:]

  1. mathlive.io and open the code section
  2. Insert (, a
  3. Hit ENTER
  4. Notice how your latex content in the code section shows \begin{pmatrix}a \\ \end{pmatrix} now.
  5. Hit BACKSPACE
  6. Notice your latext content now is \begin{pmatrix}a\end{pmatrix}

Expected behavior I am not quite sure. I'd be great if a one-dimensional vector would be converted back to simple parentheses around the single entry. I am worried though I am asking to introduce lots of complications there. In older versions of mathlive there were no vectors, so I did not encounter the problem previously. I see us using the vectors at some point, too, though, so I'm happy to have that feature. It's just very undiscoverable for users when their parentheses have become matrix-markup and we cannot expect them to inspect the raw latex markup. The main problem there might be that these 1x1-matrices are not visually distinctive from simple parentheses.

arnog commented 4 years ago

I think it's reasonable that in this case once the "row" has been deleted, you get back "(a)" (i.e. no longer a vector).

saivan commented 4 years ago

I think this is the same problem I had with #225. I think the auto vector behaviour is a bit of a problem here. Is there some way to turn it off?

stefnotch commented 4 years ago

Similar editors avoid this in the first place by using [ ] for vectors and matrices instead of ( ). It's less ambiguous that way.

yorologo commented 3 years ago

I have another problem with the vectors. For expression in latex \begin{pmatrix}a & b & c\end{pmatrix} the ASCIIMath output is empty. This problem is the same for vectors of all types and sizes.

arnog commented 3 years ago

@yorologo good catch! That sounds like a different issue, though. Do you want me to open a new issue or would you rather do it?

arnog commented 3 years ago

Issue #654 tracks the ASCIIMath problem