[Tex/LaTex] TeXStudio doesn’t recognize some commands


I'm starting to use TeXStudio. I'm having some issues, for example with


When i put the point on align* i get a small message unrecognized command, when it is in \sqrt or ^ i get the message math command outside math env, and something similar happens with & when it gives me the message tabular command outside tabular env. These commands are highlighted with an orange background.
I have similar mistakes with \eqref,\implies. Some commands as \title,\author or \sqrt(when it is between dollar signs) don't present any problem.

When i build the PDF, i have no problems at all and it gives me the desired result.
I'd like that TeXStudio recognize these commands

Best Answer

TeXStudio recognises commands that it finds in files ending with .cwl. The \eqref command and the align* environment come from the amsmath package, so you need to make sure that amsmath.cwl is loaded. Under some circumstances, this will happen automatically, but the mechanism isn't foolproof (e.g. it doesn't know that amsmath can be loaded indirectly via \usepackage{mathtools}).

On a Mac, you can ensure that amsmath.cwl is loaded by going to

TeXStudio --> Preferences

selecting Completion on the left and checking the box next to amsmath.cwl. Presumably the procedure is similar on other operating systems. If the other unrecognised commands also come from packages for which TeXStudio has cwl files, activate these as well. Section 1.4 of the TeXStudio manual explains how to add your own cwl file for commands that do not come from standard packages.