About half a year ago, I wrote a post on the configuration of (pgf)Sweave and LyX, which was intended to save us some efforts in going through all the details during the configuration. Now many things have changed: LyX 2.0 has internal support for Sweave, and fortunately I have been in touch with the developers on this feature (thanks to Gregor); meanwhile, there have also been many changes in the pgfSweave package. In all, we have a number of new features which we should definitely make use of.
A list of new features as far as I can remember:
- support for Sweave in LyX 2.0 is internal, so there is no need to modify the preferences file manually (the converters have been defined internally)
- most importantly, Sweave becomes an independent module now in LyX, which means you can use it with arbitrary layouts!
- we can see the messages during compilation in LyX 2.0 (View–>View Messages), which is really really helpful and I would strongly recommend you to turn on this option when compiling Sweave documents, because you will know which code chunk goes wrong in case of any errors (in the past, you only got an annoying error dialog box which told you almost nothing about the error)
- pgfSweave is faster: it uses the GNU make utility to compile graphics, and you can use multi cores if you like; the compilation becomes 3 steps (pdflatex, make, then pdflatex); other nice features include: the R code is put in an environment Hinput now so you can customize it in LaTeX preamble; there will be no longer a huge gap between the R code and the output (fixed by Liang Qi)…
- tikzDevice has better support for multi-byte characters (using UTF8)
I have been working on improving the Sweave module and adding a new pgfSweave module to LyX, and now I have basically finished what I planned to do. See the ticket #7555 for details. To sum up,
- LaTeX will not complain about not being able to find Sweave.sty; I used several tricks to guarantee this — even in the worst case, LaTeX can still use the hard-coded Sweave style;
- Spaces and dots in path names or filenames will no longer be a problem;
- the pgfSweave module is also working now;
- you can export the reformatted R code in a LyX document with the pgfSweave module;
Try the (pgf)Sweave Module
It seems several people are interested in testing the two modules, and it is actually very easy under Linux. So far I have had no luck with Windows to build LyX from source (I tried once; it took me days to compile and ended up with errors).
- check out the source code of LyX:
svn co svn://svn.lyx.org/lyx/lyx-devel/trunk lyx-devel
cd lyx-devel) apply my patch sweave-patch.diff to the svn source you checked out just now:
patch -p0 -i /path/to/sweave-patch.diff
- build LyX
./autogen.sh ./configure make sudo make install
Currently the patch is still waiting on LyX Trac. If you run into any problems before the developers begin to look at the patch, please let me know and we will try to make the two modules more stable and useful.