5

I am used to typing in Tex (since am a member of math.stackexhange), I decided to use an editor to help my with the typing and based on recommendations I installed LyX (I am very new to this and a search in this forum didn't return a usefull results..).

My question is this : I have words that I constatly type (like \mathbb{R} etc'), can I create some kind of a shortcut so I would only type something like \fR (field R) or any other usefull tricks to not type the same thing over and over again ?

9

One way that might help is to define a math macro for often used symbol combinations. You can define a math macro using Insert > Math > Macro. After you type a name for your macro and the contents of the macro, you can use the new macro throughout your document (as long as it is in math mode). You can read more about math macros in LyX here.

3

Since I use various editors on different platforms I got used to work with shortcut managers

  • Autohotkey on Windows
  • Autokey on Linux
  • Textexpander on Mac OS X

All these tools allow you to define a shortcut like e.g. 's#' that expands to \section{} with the cursor between the curly braces. Since I started using them my TeXing speed greatly increased.

1

You can define a keyboard shortcut to insert the desired.

Go to Tools > Preferences > Editing > Keyboard Shortcuts, then Add New. In the command field, type math-insert \mathbb{R} and assign that a key combination.

Update based on comment below: If you find it annoying that you remain in the mathbb box, you can bind the keyboard shortcut to the function

command-sequence math-insert \mathbb{R}; char-forward; char-forward

If you want to also jump out of the math box, add an additional ; char-forward

  • Thanks for this, it was really helpful, though I suggest first create a macro (as JohnReed suggests) and then create a shortcut for the macro, as a shortcut directly for the code you want like math-insert \mathbb{R} doesn't leave the cursor at the end (so you need to use arrow keys or Esc once or twice before you continue typing); using a macro resolves this. – lukeuser Nov 26 '17 at 20:56
  • Then again, a quick look at this on the Lyx wiki (on 'command sequences') tells me a lot can be achieved purely with shortcuts, probably including solving the 'cursor position problem' I encountered. wiki.lyx.org/Tips/CommandSequences – lukeuser Nov 26 '17 at 21:08
  • 1
    Exactly. 'command-sequence math-insert \mathbb{R}; char-forward; char-forward' should do the requested. – Rasmus Nov 26 '17 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.