How to change block/tabular into self-defined table macro?

Let’s say I have inserted a table using the block macro. Then the Focus menu will allow me to switch between block, block*, tabular and tabular*. But it won’t allow me to change it to my self-defined table macro. How can I do that?

Hello @Roun and welcome to the forum!

You can go into the “source” view of the Document (Document -> Source -> Edit source tree) and edit the element by putting the cursor right in front of it and then pressing Delete.

If you too many to edit by hand, it’s also possible to write a few lines of Scheme code to do this automatically.

Hi @jeroen, thanks for the reply! This usually works for other macros. But for table macros, TeXmacs seems only allow me to put cursors in the cell macros (or cwith macros if there are any) and does not allow me to put cursors elsewhere in the table (e.g. in front of block/tabular.) Are there any settings or extra actions I need to take to allow this?

Hi @Roun, you are right that editing tables is somewhat restricted. However, the procedure I described does allow me to change the block element to another one. Did you try it with the document entirely in source mode? For some reason it doesn’t work in an inactive* element, which otherwise behaves similarly.

Following up on this suggestion of @jeroen, the following Scheme code places the environment my-tabular in the focus menu

(define-group table-tag (former) my-tabular)

The code has to be inserted in my-init-texmacs.scm

I defined my-tabular as

<assign|my-tabular|<macro|body|<tformat|<arg|body>>>>

to have it behave the same as the standard table macros—this said, I think (it is only an hypothesis) that the effect of the commands in the focus menu is to change the outermost tag of the table environment, so I expect all tags that can accept the same structure as the standard ones in their argument to work.

And: welcome to the forum.

1 Like

Hi @jeroen, yes I am setting the entire document in source mode. Please see my attached screencast. I have tried both mouse clicks and arrow keys, but it does not allow me to put the cursor near the tabular macro. I’m using TeXmacs 2.1.2 on macOS.

I know, that’s why I suggested to put the cursor in front of the element and pressing the Delete key :slightly_smiling_face:

Ah, thanks @jeroen! That works! I’m on a MacBook and got so used to “Backspace” being called “Delete” such that I even “overloaded” the concept of “in front of”… When I used Fn + Delete on the MacBook (which is equivalent to the “forward Delete” on other keyboards), it allows me to change the macro name.

1 Like

And also thank you @pireddag for the tip to add self-defined table macro to the Focus menu!