I'm using TeXstudio and for a while now, every time I write in math mode using $...$
or \[...\]
, it highlights most of the commands as if they were syntax errors although it compiles just fine. For example, it highlights \alpha
, _
or ^
. However, it works properly if I use certain environments such as equation
.
I have noticed that the error appears to be a consecuence of using a .Rnw
file with knitr
:
If i write the following code, \alpha
and _
appear highlighted, but they do not if i omit opts_chunk$set(tidy=TRUE)
.
\documentclass{article}
\usepackage{amsmath,amsthm,amsfonts,amssymb}
\begin{document}
<<setup, include=FALSE>>=
library(knitr)
opts_chunk$set(tidy=TRUE)
@
$\alpha x_1$
\end{document}
\documentclass{...}
and ending with\end{document}
. The easier it is to copy and test your code, the more likely your question will be answered and can help others in a similar situation.