10

I use TexStudio and I want to make a keyboard shortcut that inserts \textrm{param} when I press it where param is a parameter to be filled in (similar to how \frac has the num and den parameters).

Is it possible to apply the shortcut with selected source code as a parameter?

  • You mean something like this? (After all I do not think this is a good idea because I tend to define too much shortcuts and forget them immediately.) – Symbol 1 May 19 '15 at 5:36
  • sorta like that but with a parameter – user2237160 May 19 '15 at 5:49
16

Go to Macros menu and choose Edit Macros

enter image description here

Click on the Add button and insert a new macro, as in the image below (the Name you can choose, of course).

enter image description here

The Type should be Normal and the LaTeX Content should be \textrm{%|%|}. Click on OK and then you can insert the macro from Macros menu or using its shortcut (in my case, Shift+F5).

The macro will insert \textrm{} with the cursor inside the braces {}.

Note 1. You can select some text (foo) first and execute the macro after to obtain \textrm{foo}.

Note 2. You can change its shortcut using Options menu, Configure TeXstudio

enter image description here

and then Shortcuts

enter image description here

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.