Wrong LaTeX syntax in TeXstudio?
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
\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\begin{document}
\begin{eqnarray*}
\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
\end{eqnarray*}
\end{document}
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
\documentclass{article}
\usepackage{mathtools}
\usepackage{xcolor}
\begin{document}
\begin{align*}
\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
\end{align*}
\end{document}
I hope that helped. Please let me know, if you get stuck with wrongly highlighted commands.
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":
(Picture: CC-BY-SA 3.0 by Johannes Kalliauer)