1

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}
2
  • Welcome to TeX.SE! I use TeXStudio myself and don't have that problem, atm. Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \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.
    – thymaro
    Apr 15, 2019 at 10:24
  • The problem might lie within TXS, but it might actually be because of something in your code, that's why I ask for it.
    – thymaro
    Apr 15, 2019 at 10:25

1 Answer 1

1

I seem to have found a solution to the problem.

Writing

attach(opts_chunk)
set(tidy=TRUE)

instead of

opts_chunk$set(tidy=TRUE)

seems to work for me.

You must log in to answer this question.

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