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? Oct 23, 2016 at 10:31
  • 1
    How did you set up "\eq as a trigger for ..."? Oct 23, 2016 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, 2016 at 11:51
  • 1
    @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? Oct 23, 2016 at 12:29
  • 1
    @Bernard is it possible to use backslash as a part of the trigger? As in, I'd like to type \eq instead of just eq Oct 23, 2016 at 13:26

3 Answers 3


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

Inside TexStudio macros one can define commands as well as triggers. So you could add \eq in the "Abbreviation" field, like so: Image of \eq

When writting the command, autocompletion will popup, but the first option will be your newly create command.


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.

  • 3
    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, 2016 at 16:40

You must log in to answer this question.

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