[Tex/LaTex] TeX Studio doesn’t recognize certain amsmath commands even after loading packages

syntax highlightingtexstudio

Here is my code:

code screenshot

As you can see, TeX Studio doesn't recognize the proof environment. Nonetheless, I have activated the amsmath package in the preferences:

preferences screenshot

So why isn't it working? I have tried restarting the PC to see if it would load the package but it didn't work.

I am using the ProTeXt packages. The output file looks fine.

Best Answer

You're actually not describing the problem correctly. When TeXstudio fails to recognize an environment, it is the \begin and \end that are highlighted red. For example if I add an environment foo, I get this:

unrecognized env in TeXstudio

The "unrecognized command" popup comes from hovering the mouse cursor over \begin. (Sorry, it didn't show up in screenshot.)

The problem you're facing is a different one: that you've used math mode-only code outside of math mode. The proof environment does not start math mode. And TeXstudio tells you that this is the case:

TeXstudio: math command outside math env

Additional note

I just saw that you're using $$ ... $$ for displayed math. Don't do this, use \begin{equation*} ... \end{equation*} or \[ .. \] instead, see Why is \[ … \] preferable to $$?

Related Question