I'm new to LaTeX and TexStudio, and I want the environment for equation to be typed in if I type "\eq". So I tried setting \eq as a trigger for:


However, the macro doesn't work as expected. Simply typing "eq" produces the macro. I can't even type the word "equals".

Further, when I type \eq an autocomplete window opens. Autocomplete window

How do I program the macro to produce the equation environment on typing nothing but \eq?

Edit: Here's how I added the macro and set it up:

Macro setup

  • @HeikoOberdiek Thanks a lot, buddy. Can you help me out with my lil problem, sir? – Somenath Sinha Oct 23 '16 at 10:31
  • 1
    How did you set up "\eq as a trigger for ..."? – user36296 Oct 23 '16 at 10:43
  • Try to use a trigger which does not correspond to the beginning of so many commands. Why not use \eqn? – Bernard Oct 23 '16 at 11:51
  • @samcarter added your query to the question – Somenath Sinha Oct 23 '16 at 12:29
  • @Bernard Is it not possible to set up \eq to be a macro as I want it? Note: I WANT to have to type backslash before eq for the macro to work. But even when I don't include the backslash it still works. How do I correct this? – Somenath Sinha Oct 23 '16 at 12:29

There are two issues with your setup:

  1. Triggers are regular expressions. Therefore you need to escape the backslash: \\eq
  2. As written in the manual:

Triggers are inactive while the completer is active. For example you cannot trigger on \\sec if the completer is open suggesting to complete \section.

You cannot use both, a \\-starting trigger and the completer at the same time.

Possible solutions:

  • deactivate Options -> Completion -> Automatically start completer when typing LaTeX commands.

or alternatively:

  • use another trigger, e.g. #eq

Better use this in the preamble \def{\beq}{\begin{equation}} \def{\eeq}{\end{equation}} Now you can write equation between \beq and \eeq Your idea does not work easily.

  • 2
    I disagree, using \beq is far from more readable, in no way better code and no faster (indeed it seems like more key presses) to type. The OP is in my opinion asking for assistance in applying this better practice (so I don't feel that this answers the question) and given they have accepted an answer I assume they have been able to achieve the desired functionality. – Dai Bowen Oct 26 '16 at 16:40

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.