Can I create a keyboard shortcut to insert an aligned function?

Hello,

I’m a student in France and I use TeXmacs to take my mathematics lessons.

For several weeks now, I’ve been rather annoyed by the fact that, when I want to insert a function, I have to go to [Insert] > [Mathematics] > [Several equations] (or, more simply, use CTRL+&) and then fill in the middle boxes with the appropriate arrows (which I’d like to automate with (insert “<longmapsto>”) and (insert “<longrightarrow>”)).

If you can’t see what I want to insert, here’s an example, where anything that isn’t an arrow would be completed by the user (me):

I imagine there’s a way, with my-init-texmacs.scm, to create such an array and navigate through it to insert what you want. Unfortunately, I’m having great difficulty understanding the documentation I’ve found here:

I don’t see anywhere where it clearly addresses table navigation, or even table creation.

Any ideas on how to do this? At the moment, my code doesn’t look like anything good, it’s really just the culmination of several failed tests:
(“f o n c” (go-to-path (rcons (table-which-row) (table-which-column) 3) ) )

I don’t really understand what go-to-path does, nor rcons, nor the rest!

Thank you very much in advance,
Milan

(Translated with DeepL)

In this case I would write a macro which stores the template of your construction and leave the variable bits as arguments. Creating macros is quite easy. You start with what you want to obtain. Like so:

image

Then you cut all the construction, go in the preamble of the document, and start writing your macro as shown here:


and you paste the equation array in the position of the cursor:

At this point you have to replace the letters A,B,C,D with the variables \X, \Y, \Z, \W to obtain this:

Now you go out of the preamble and in the regular document and you can just invoke your macro as

and press enter and you will get your template:

which you can fill out:

2 Likes

Hi,

Thank you very much for your comprehensive reply! First of all, I’d like to apologize for not getting back to you sooner (I’ve been very busy with my studies…).

I’ve tried to implement your guide, but unfortunately it doesn’t seem to be working. So if you don’t mind, I’ll list exactly the steps I take.

  1. I open a blank TeXmacs document, which serves as a template for all my documents;

  2. In the Insert > Mathematics menu, I create a Displayed formula ;

  3. From menu Insert > Table, I create a Plain tabular ;

  4. Using the + button with an arrow to the left, I create a row of 5 cells, which I fill as follows:

  5. I press the Enter key to create a second line, which I also fill in:

  6. Since I want the boxes containing A and C to be right-aligned, I select them and choose a Horizontal alignment at Right ;

  7. I exit all active blocks, then select everything I’ve just created, then copy it (cmd + C) :

  8. In the Tools > Macros menu, I open Edit preamble ;
    00

  9. A blank page opens, I write “\assign”, press Enter (what I’ve just written now turns blue):

  10. I then write “func”: the name of the macro I want to create, then, using the right arrow, I go to the last field of assign :

  11. I type “\macro” then Enter ;

  12. I write A, then press the tab key. Repeat until E is reached;

  13. In the field that opens with the last tab, I paste what I copied earlier:

  14. I then replace the letters with what you told me (\A\E):

  15. I save the document (cmd + S) ;

  16. I leave the preamble as I opened it. I then find my model.

  17. I then try to write \func :

  18. When I press Enter, a field opens up. I try not to write anything in it to insert my model, but it doesn’t work:

  19. So I try to write something there, as well as in the successive fields that open up next:

  20. Pressing Enter doesn’t help either:

I guess I did one or more steps wrong. Macros are really new to me, and I’m having trouble understanding how they work.

I notice that in the top toolbar, all my values are associated with A, but I have no idea how to solve this problem.

When I open Edit macros and search for func, I get this:

In Source mode, this becomes (still with the definition of func above, but it doesn’t fit in the window) :

Thank you in advance for your help.

There seems something wrong in your setting. Could you please paste your tm here via fenced code block?

I’m sorry, I didn’t understand what I had to send you exactly. Could you tell me what can help you? I will send it to you with pleasure.

The whole file. You can open it with a text editor, copy all, then paste it here in a code block.

func is (or used to be?) a TeXmacs primitive. What happens if you use a different name?

3 Likes