Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

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.