0

I am somewhat new to LyX, and while I've been using it for long enough to know my way around it, there is one feature about it that is becoming ever more irritating; as a student, I mainly use it for writing math courses and need to do so as fast as possible to keep up with the pace. The crux of the problem is that, as you know, TeX code in the math editor is triggered by the \ character. Unfortunately, I happen to have being French as a hobby, and consequently my keyboard layout is the standard French one. Turns out, whoever chose \ as the standard character for writing code very much did NOT have french people in mind, as its position on French keyboards is absolutely atrocious. Should you want to know, it is written by the combination AltGr + 8 (Alt Gr being a key just to the right of the spacebar, in case your keyboard doesn't feature it). That is to say, to type every single TeX command, I have to stretch out my right hand as much as possible, while blocking my thumb under the center of my palm. It's awkward, it makes me lose absurd amounts of time, and brings me physical pain due to carpal tunnel syndrom; in short, I hate it with a burning passion (try it, you'll see what I mean).

Which is why I would like to know if there is a way to type \ with some shortcut of my choice, and still have LyX behave as if I typed it as usual. I have tried modifying my .bind files to achieve that, but to no avail; it seems that, while it would be very easy to do with any other character, the unique status of \ (including in .bind files) won't let me do it.

\bind "<My-Shortcut>" "insert-unicode 0x005C" gave me hope for a few seconds, as it does type \ in text mode, but sadly, it doesn't do anything in math mode.

\bind "<My-Shortcut>" "math-insert \\\" prints [\"] in math mode for some reason, which is progress, but not really interesting because of the double quotes (I'm not sure where those come from). The same instruction, with any other number of backslashes, or with 3 but without the final double quotes, only creates an empty math editor box.

Lastly, I would like to mention that changing the language of my keyboard (with Shift+Alt for example) is not really a valid option; admittedly, \ is very conveniently placed on english keyboards, but 1- I would still be writing in French, so I need to have access to accents and 2- my actual, physical keyboard would still be in French, so I would have to memorize the entire english layout which doesn't sound like I'd be saving time.

This being the situation, do you know of any way to achieve that? Thank you very much for your help in advance!

11
  • Depending on your operating system, there are tools which allow you to remap individual keys. You could remap \ to some other key which is located more conveniently. For macOS, I can recommend Karabiner Jun 11, 2023 at 20:51
  • As @samcarter points out, you can rebind keys on GNU Linux too. Here is a tutorial. Changing the working of TeX isn't a great idea. TeX isn't just what you type, it is much more than that running in the background and written in the same language which would collapse if you change parts and pieces of it.
    – Niranjan
    Jun 12, 2023 at 4:50
  • Most probably even worse, but many editors allow also enter the unicode character codes is some way. In Linux is Ctrl+Shift code, therefore 005c character is Ctrl+Shift 5c. I cannot test in other OS but it Windows seems that is Alt+x 5c or so. Other different approaches could be write in Quarto markdown to avoid type LaTeX directly, as far as possible (you can still do that when markdown syntax is not enough), ... or get used to using both hands for this key combination, although you almost have to cross them.
    – Fran
    Jun 12, 2023 at 6:16
  • Ah, I forgot it was for LyX when proposing markdown. Using LyX you should already use LaTeX commands rarely. Many math symbols can be selected fro the math bar, so you can simply select α instead of type \alpha and so on (although I prefer type commands that use the mouse, however...) .
    – Fran
    Jun 12, 2023 at 6:37
  • 1
    Based on other programming languages, I would expect \bind "<My-Shortcut>" "math-insert \\\" to parse the \\\" as \\​ becoming a \​, and then \" becoming ". You claim to have tried other numbers of backslashes, but are you sure you tried \bind "<My-Shortcut>" "math-insert \\" (with two backslashes at the end)?
    – Teepeemm
    Jul 27, 2023 at 14:10

1 Answer 1

0

The LFUN called ert-insert inserts an ERT inset while in the text editor, but in the math editor it starts a macro (inserts \ to the editor).

The default bind of this LFUN is ctrl+L (or command+L).

Note that there is a LFUN for inserting text, it is called self-insert, but for security reasons you can't bind it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .