Wednesday, October 20, 2010

Sweave with Gedit

So, apparently the new cool way to include R code with latex files is using Sweave.

Using the latex plugin with Gedit, it should handle the sweave automatically. However there seems to be a few difficulties that need to worked out to get everything working just right.

My goal here is to layout everything that needs to be done in order to make it work.

Basic command:
"R CMD Sweave 'file.Rnw' "

In Gedit, the latex plugin forgets the "CMD", so to make it work, go edit -> preferences -> plugins -> Gedit Latex Plugin 0.2 rc3 -> configure -> tools -> R Sweave to PDF -> "properties"

Now you can try to edit the command.

For me, this did not work, so to make it work right I did the following,
edit the file
~/.gnome2/gedit/plugins/GeditLaTeXPlugin/tools.xml

There should be a section like

<tool description="Process R Sweave file and create a PDF from the resulting LaTeX source" extensions=".Rnw" id="1" label="R Sweave → PDF">
        <job mustSucceed="true" postProcessor="GenericPostProcessor">R CMD Sweave "$shortname.Rnw"</job>
        <job mustSucceed="true" postProcessor="RubberPostProcessor">rubber --inplace --maxerr -1 --short --force --warn all --pdf "$shortname.tex"</job>
        <job mustSucceed="true" postProcessor="GenericPostProcessor">gnome-open "$shortname.pdf"</job>
    </tool>

In the above section I have already added the "CMD" that was otherwise missing. Then save the file and restart Gedit. (As I was using gedit to modify the file.) And, now it still doesn't work.

Ahh, well command line it is for now.

I'll update it when I finally get it to work.

No comments:

Post a Comment