Please help me to understand why TeXstudio does not like my syntax below although it was able to compile correctly??

screen capture




\Rightarrow y_1 = y_0 + \frac{f(x_0, y_0) + f(x_1, y^*_1)}{ 2} h &=& 1 + \frac{f(0, 1) + f(0.1, \textcolor[rgb]{0.00,0.00,1.00}{1.1})}{ 2} \cdot 0.1\\
& =& 1 + \frac{1 + 1.2}{ 2} \cdot 0.1 = 1.11

  • i don't understand your question. the pink highlights are merely indicating "basic" commands and special "math" characters in the input. commands that are defined by extra packages, like \textcolor and \frac, aren't recognized, so they aren't highlighted. and this question has nothing to do with biblatex, so i've retagged it "texstudio". Commented Aug 17, 2016 at 19:28
  • 2
    There's no problem for me. Just two observations: needless to load xcolor with the [usenames] option: it's the default. More importantly: don't use eqnarray, it gives bas spacing around the alignment points. Use align from amsmath instead. I'll add the syntax is simpler (only one &).
    – Bernard
    Commented Aug 17, 2016 at 19:32
  • @CarLaTeX If you go over the red text you will see "math command outside math env", so Texstudio knows them, but it does not recognise eqnarray*. If you change it to eqnarray or to gather* TexStudio understands the math env Commented Jul 4, 2019 at 8:59
  • @JoKalliauer Thank you for the explanation
    – CarLaTeX
    Commented Jul 4, 2019 at 13:13

2 Answers 2


TeXstudio tries to help you with finding errors in your syntax. You have noticed that some commands get recognized and some don't. Additionally, TeXstudio will warn you in case you use obviously wrong syntax.

First of all: Your code compiles, you get some nice output, and most probably, there is nothing wrong in the .log-file (warnings and errors). This should be your main concern.

Now let's take a look on the code: First of all, we reduce it as much as we can in order to see, what is causing which behaviour. This always helps you and us to debug quickly.

% arara: pdflatex


    \Rightarrow y_1 = y_0 + \frac{f(x_0, y_0) + f(x_1, y^*_1)}{ 2} h &=& 1 + \frac{f(0, 1) + f(0.1, \textcolor[rgb]{0.00,0.00,1.00}{1.1})}{ 2} \cdot 0.1\\
    & =& 1 + \frac{1 + 1.2}{ 2} \cdot 0.1 = 1.11

I have kicked out all packages which are not needed here. The picture is still the same as in your screen-shot. As noticed by Bernard, I have kicked out the redundant option usenames as well.

Now you can go into your coding area and hover over the highlighted "erroneous" parts. TeXstudio makes a great job and tells you, what the problem is (or appears to be).

In my version (TeXstudio 2.10.8, several custom tweaks in highlighting already) I see three different cases:

  • "unrecognized command" for \begin{eqnarray*} and \end{eqnarray}
  • "tabular command outside tabular env[ironment]" for the ampersands
  • "math command outside math env[ironment]" for \Rightarrow, the underbar, the circumflex, and \cdot

Well, as all four last commands are clearly math commands and the surrounding environment seems to be not recognized, we should take a look on this part first. A second indication is that the ampersand does not feel cosy in this environment as well.

In this case, there are three options. 1. The used environment is wrong or bad style or outdated, 2. TeXstudio does not know this environment (in this case, please search this site on my posts regarding .cwl-files), or 3. you have bad settings in "Options->Configure TeXstudio...->Completion" (or "Syntax Highlighting").

In your case, a quick google would lead you to Bernards second concern: eqnarray is outdated. You should not use it. When getting rid of the asterisk, all highlights vanish. So TeXstudio (what a pity) does see eqnarray* as unknown but eqnarray as correct. I will report this when I find time. Maybe this could disappear in some future version.

As we have googled about eqnarray* we have found out that we should replace this by align*. Doing so will fix all your highlighted issues. I've replaced amsmath by the slightly more complete mathtools and here you go with your new MWE:

% arara: pdflatex


    \Rightarrow y_1 = y_0 + \frac{f(x_0, y_0) + f(x_1, y^*_1)}{ 2} h &= 1 + \frac{f(0, 1) + f(0.1, \textcolor[rgb]{0.00,0.00,1.00}{1.1})}{ 2} \cdot 0.1\\
    &= 1 + \frac{1 + 1.2}{ 2} \cdot 0.1 = 1.11

I hope that helped. Please let me know, if you get stuck with wrongly highlighted commands.

  • Than you! Such detailed explanation! I have learned (probably too much) for the day :)
    – hochoi
    Commented Aug 17, 2016 at 21:00
  • @hochoi you are very welcome.
    – LaRiFaRi
    Commented Aug 18, 2016 at 8:40

TeXstudio does not recognise \begin{eqnarray*} ... \end{eqnarray*} as math env, therfore all math commands will be marked as "math command outside math env", this is known wont-fix TeXstudio-Bug, but as described on https://sourceforge.net/p/texstudio/bugs/1500/ you can avoid this bug with "activate latex-l2tabu.cwl in option/completion":

enter image description here (Picture: CC-BY-SA 3.0 by Johannes Kalliauer)

You must log in to answer this question.

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