Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax coloring input using Sweave with TeXShop?

Tags:

r

latex

sweave

I've just started using Sweave on TeXShop ( which runs on OSX). Is it possible to have syntax coloring of the source code so that I can distinguish between raw text and R-code?

For example, the following code snippet in my Sweave file is the same as the rest of the text, which makes it harder to read than an R editor that has syntax coloring.

<<reg, fig=TRUE, echo=FALSE>>=
a = c(10,15)
plot(a, a)
@

(I have also tried this out using the wonderful RStudio which does have syntax coloring for both R and Latex, but I think TexShop is superior for LaTeX.)

like image 739
djq Avatar asked Jan 28 '26 16:01

djq


1 Answers

I don't believe TexShop supports mode switching (e.g. highlighting in two different languages--R and LaTeX--within the same file), since it was designed around a single language (LaTeX). Editors that do and therefore properly handle Sweave are to my knowledge:

  • Eclipse with Stat/ET
  • RStudio
  • Emacs with ESS
like image 194
Ari B. Friedman Avatar answered Jan 30 '26 11:01

Ari B. Friedman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!