4

If I include \usepackage{Sweavel} in my .rnw file, I get an X11 popup error "It seems you are using the Sweave-specific syntax; you may need Sweave2knitr("IPT-baseline-test.rnw") to convert it to knitr" when I compile in RStudio (Version 0.98.484). The document compiles, but I have to dismiss the error.

(1) Any ideas why \usepackage{Sweavel} triggers the error?

(2) Is there a way to turn off the popup since the document compiles anyway?

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] knitr_1.5

loaded via a namespace (and not attached):
[1] colorspace_1.2-4   dichromat_2.0-0    digest_0.6.3       evaluate_0.5.1    
[5] formatR_0.10       ggplot2_0.9.3.1    grid_3.0.2         gtable_0.1.2      
[9] labeling_0.2       MASS_7.3-29        munsell_0.4.2      plyr_1.8          
[13] proto_0.3-10       RColorBrewer_1.0-5 reshape2_1.2.2     scales_0.2.3      
[17] stringr_0.6.2      tools_3.0.2   
Eric Green
  • 7,385
  • 11
  • 56
  • 102

2 Answers2

2

You shouldn't need to \usepackage{Sweavel} explicitly, I think -- knitr should handle that automatically. If you really want to suppress this false positive , you can rename Sweavel.sty to a file name that doesn't start with Sweave ... the which_sweave() function at https://github.com/yihui/knitr/blob/de7c65c58acfb1f3f5c0ac2f00b92cd2546be943/R/utils-sweave.R shows you what patterns knitr is looking for to detect "old Sweave syntax", specifically in this case the regular expression

regexp <- 
   '^\\s*\\\\(usepackage(\\[.*\\])?\\{Sweave|SweaveInput\\{|SweaveOpts\\{)'

So changing to mySweavel.sty should work ...

grepl(regexp,"\\usepackage{Sweave}")  ## TRUE
grepl(regexp,"\\usepackage{Sweavel}")  ## TRUE
grepl(regexp,"\\usepackage{mySweavel}")  ## FALSE

My guess is that you have a newer version of knitr on your new than on your old machine, and it's trying harder to detect old Sweave syntax.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
  • That is right. `\usepackage{Sweavel}` and `\usepackage{Sweave}` are not necessary for `knitr`, so a warning is issued just to save a few bytes on earth (they can be safely removed) and a few milliseconds for LaTeX. – Yihui Xie Dec 15 '13 at 00:03
  • This is helpful, thanks. @Yihui, knitr used to incorporate `Sweavel.sty`, correct? I started specifying my own file when I wanted to [modify code highlighting](http://stackoverflow.com/a/17509667/841405). Regardless, my takeaway is that I don't need to specify it anymore. If I want to keep it for any reason, I need to change the name. – Eric Green Dec 15 '13 at 16:03
  • I just started getting this message out of the blue. But when I remove \usepackage{Sweavel} I get Environment knitrout undefined. – Frank Harrell Feb 15 '14 at 18:42
0

Removing the Sweave tag in the latex document prevented the warnings. It did not prevent the rendering of the file. Thus, the suggestion made in one of the comments above worked... knit2pdf (in my case) figures it out. - E

Edmund's Echo
  • 766
  • 8
  • 15