Solved: how to order indices with spaces on matrices/tensors in TeXmacs

Saw people having this question but couldn’t find an answer so thought I would post it here. One guy has even written a whole package/preamble to address it :’(

If you need to be very clear about the ordering of indices on a matrix/tensor (e.g which one comes first to denote rows vs. columns), you can use the following trick: write the first index (if you want), and then insert an “invisible character” by entering a comma and then pressing tab twice. Then, you can use the ^ or _ keys to put a sub/superscript on that space, and it will have the proper spacing. Then you can repeat by adding another invisible character and putting an additional sub/superscript.

As an example, let’s say I want to write a four-index tensor “R” with the first index downstairs, the second upstairs, the third downstairs, and the fourth upstairs, I would type:

R , [tab] [tab] _\mu , [tab] [tab] ^\nu , [tab] [tab] _\rho , [tab] [tab] ^\sigma

Of course for the first index you can just subscript R itself, and if there are multiple indices in a row up/downstairs you can just keep typing in the superscript, but you get the point that TeXmacs can handle it. Hope this is helpful! Developers, it would be really helpful to add this to the manual or somewhere official since it took me quite some time to think of how to do this properly.

2 Likes

Hi @npittman and welcome to the forum.
It seems very nice but I did not understand it: could you please attach an image showing the typeset result of your input?

Second, I think that everybody would be pleased if you would write a brief post for https://texmacs.github.io/notes/docs/main.html on the topic. You can either submit it via a pull request (https://github.com/texmacs/notes) or I think send it as a TeXmacs document to @mgubi who will publish it.

In The Jolly Writer, it is recommended to add phantoms to achieve the same effect. Please see §7.5.4 for more details. The phantom text is treated similarly to the original text, except that it is rendered using invisible ink. Phantoms can be added using the menu Format → Special → Phantom or the macro \phantom.

I’ve been inserting separating-space but this is certainly a far better approach.

Screenshot%202024-06-24%20134529