TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I defined a new command as:


so to make a new equation I do:

 \eq{equation stuff here}{label here} 

But since I've not used the equation environment explicitly, texstudio highlights every math symbol in the equation. It is really annoying. Is there a way around this?

share|improve this question
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. (I moved my first comment to an answer, since I'm very confident that there is no answer. If someone proves me wrong, I'll be impressed :-). ) – Sean Allred Jul 11 '13 at 19:37
I advise you not doing that, because you lose information. For instance, you can't look for all the labels with a simple find function for \label. Maintenance of compact code is harder. – egreg Jul 11 '13 at 19:38
I suggest you to use the capability of TeXstudio to autocomplete the commands instead of defining new ones. – Sigur Jul 11 '13 at 19:44
egreg, I do prefixes to my labels, e.g. fig: or eq:, so finding them wont be a problem. Vedran, That seems like a reasonable compromise, thanks a lot. P.S. Being a new user, I cannot add comments, so I must post this as an answer. – user33542 Jul 11 '13 at 19:57

Given the nature of TeX's language, I don't think there is a good, reusable solution to this one. Syntax highlighting is something done usually using regular expressions, but TeX is (literally) a class of languages higher than regular expressions can cover. Getting the syntax highlighting right would require some serious umph behind TeXStudio's parser - paramount to including a TeX distribution in-house.

See also Is there a BNF grammar of the TeX language?.

share|improve this answer
I was a bit pessimistic about the problem. I guess I can just turn off the highlighting in texstudio. Thanks for the reply. – user33541 Jul 11 '13 at 19:34

If you're content with replacing the command \eq with the environment eq, this should be doable. Just define your own CWL file with the line


Then include this file in options, under Completition.

More on the CWL format can be found here and the basic info on the file itself is here.

share|improve this answer
Since I don't use TeXStudio anymore, I didn't know about this functionality. Neat! I would note to @Harsh though that environments can also take arguments. So, whether or not it's A Good Idea, you could incorporate the automatic label as an argument in much the same way as you would do in \newcommand. – Sean Allred Jul 11 '13 at 20:32

You can define something like that:



and you have both shorthand and highlighting!

(Read Knuth's TeXbook rather than LaTeX tutorials to know how to define commands properly. ;-) )

Here are some more of my own definitions:




\Align at$${2}
share|improve this answer
using $$ in latex removes the ability to use some useful features that have been provided by the named latex environments, such as \qedhere with amsthm. although ingenious, this is not a practical solution. – barbara beeton May 13 '15 at 16:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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