mathlive icon indicating copy to clipboard operation
mathlive copied to clipboard

[FEATURE] Improved matrix editing UI

Open zwz opened this issue 4 years ago • 9 comments

I am quite new to mathlive. And I find it not intuitive and user-friendly to do matrix editing, such as

  1. adding a column (I get it done by memorizing the keyboard shortcuts)
  2. adding a new row for a multi-column matrix only gets one-column row
  3. very hard to tell how many columns are there already when most columns are blank

So I suggest

  1. add buttons of "new column/row (before/after)" and "remove current column/row" in the virtual keyboard
  2. when a new row is added, it spans into multi-column row
  3. each blank spot shows (DOTTED SQUARE) as a placeholder. This will not only make it easy to tell the column-size, but also help user to locate and fill the spot to make a sparse matrix on a mobile device.

zwz avatar Aug 28 '20 09:08 zwz

I agree that the current handling of matrices could use some improvements.

For what it's worth, here is how some other editors handle this Swiftcalcs (which I think uses a modified version of MathQuill)

  • Add row ,
  • Add column ;
  • Shows placeholders

Mathcha (uses a really good, custom, closed source math editor)

  • Add row and add column Enter and then choosing image
  • Shows placeholders

Mathcad (expensive desktop application)

  • Add row Shift+Space
  • Add column Shift+Enter
  • Shows placeholders

stefnotch avatar Aug 28 '20 10:08 stefnotch

Adding more systems: Mathematica

  • add column after: ctrl+,
  • add row after: ctrl+enter/return (windows/mac)

Also menu entries for them along with a way to span and split them.

Word Not really any keyboard shortcuts (tab adds a row at the bottom in some cases). However, it has several menu entries and ribbon entries to add one or more rows/cols above and below current selection.

Options for merging and splitting

NSoiffer avatar Aug 29 '20 00:08 NSoiffer

To clarify, MathLive by default uses the same shortcuts as Mathematica (Ctrl+, and return to add a column/row). I don't think this issue is about what the shortcuts should be or that MathLive is lacking shortcuts for basic matrix editing.

Note also that it is possible to define a custom virtual keyboard with commands to add/remove columns/rows. If someone wants to submit one, I'd be happy to review it.

The point about having a placeholder visible for empty cells is a good one.

The behavior when inserting a new row could be changed so that a new row has as many columns as the previous one, but note that Latex matrixes are sparse and could have variable number of cells per row. But perhaps that could be not supported when creating a new matrix with MathLive (but still supported if the matrix was pasted into MathLive).

arnog avatar Aug 29 '20 05:08 arnog

I personally would make new rows have as many columns as the previous one, because I don't think that non-square matrices are very common and I also don't think that there should be a distinction between empty (doesn't exist) and empty (placeholder).

stefnotch avatar Aug 29 '20 08:08 stefnotch

@arnog I agree with you that it is not an issue about the shortcuts. IMO, mathlive aims to be picked up quickly for a general new user (no experience on Mathematics) without (much) learning/memorizing. That is why I think the row/column editing buttons should be in the virtual keyboard by default.

zwz avatar Aug 29 '20 12:08 zwz

After further thoughts, while adding some commands in a virtual keyboard panel is a potential solution, it does have the drawback that the virtual keyboard is not always available (it can be turned off on desktop, for example). So, I don't think having the default matrix editing commands in the default virtual keyboard is the best option. Instead, I would suggest a floating editing bar (similar to the pop-over in command mode), which would appear when the caret is inside a matrix and would look something like this:

Screen Shot 2020-08-30 at 9 59 40 AM

The (+) buttons would allow the insertion of a column/row and the (-) buttons would allow the deletion of a row/column, while the other buttons would allow the selection of the "style" of the matrix.

arnog avatar Aug 30 '20 16:08 arnog

I would really love to have something like this, we're currently struggling with enabling good matrix support for our application (via mathlive). Having this built in would make things much easier. I also love the idea to have placeholders for all empty spots when inserting a new row / column via mathlive.

Khazuar avatar Sep 03 '20 08:09 Khazuar

Another option would be to have a contextual menu. On mobile, this could be a floating widget that would show the menu when tapped.

arnog avatar Sep 03 '20 14:09 arnog

Relevant issue https://github.com/arnog/mathlive/issues/225

stefnotch avatar Sep 16 '20 10:09 stefnotch

Working on this this WE. This is what I have - tentatively:

https://user-images.githubusercontent.com/104928632/230780099-e3c8f6af-2991-423e-818b-a59542e59450.MOV

I still need to make some array move commands, as well as options for changing delimiters.

WildYellowfin avatar Apr 09 '23 14:04 WildYellowfin

Excellent! Coincidentally, I'm working on improving the keyboard shortcuts for matrix editing (and creation).

So, you're implementing the UI as a custom keyboard layout?

arnog avatar Apr 09 '23 16:04 arnog

It is basically part of the keyboard, but it shows up as a popover. I’ve modified the updateToolbar to show the popover if in math mode and inside a matrix. The proxy passes the field DOMRect to position the popover, and the environment name is also passed.

A slight annoyance is that I’m using the same scrim as the variants panel, so opening variants closes the matrix popover, but I could work around that.

WildYellowfin avatar Apr 09 '23 20:04 WildYellowfin