[R] Sweave and Textwrangler

Duncan Murdoch murdoch.duncan at gmail.com
Sat Mar 26 20:57:22 CET 2011


On 11-03-26 10:58 AM, Christopher Desjardins wrote:
> Hi,
> I am trying to get TextWrangler to work with LaTeX and Sweave. Ideally
> I would call a script from TextWrangler that would run Sweave on a
> document, then LaTeX (using SyncTeX), and finally
> open the corresponding pdf in Skim. Of course I don't always need to
> run Sweave and would be looking for the option of LaTeX ->  Open.  I
> found this http://www.xs4all.nl/~msneep/latex/ but it doesn't work for
> me as it gives me an error. Something similar to do that would be
> ideal. Additionally the option to use BibTeX would be great too.
>
> Additionally, I tried this
> http://www.stat.umn.edu/~arendahl/computing/index.html
> and Sweave.sh script and trying to alter that (and the *.engine files) to
> work with TextWrangler but to no avail.
>
> Does anyone do this and have a tip they could give me? Sorry if this is
> off-topic (if so please reply to me off the list).

I don't use TextWrangler, but I got TeXShop working pretty nicely with 
Sweave.  The "engine" file simply does this:

Rscript -e "patchDVI::SweavePDF(  '$1' )"

The patchDVI package is on R-forge here:

https://r-forge.r-project.org/R/?group_id=233

This needs a very recent version of Sweave.sty if you have a recent 
pdflatex.

You say you don't want to run Sweave every time, and want to sometimes 
run only Latex.  I don't see how this would be desirable, because your 
edits to the .tex file are lost the next time you run Sweave, but the 
above engine skips Sweave if it is given a .tex file instead of 
something it recognizes as Sweave input.

I gave a little tutorial on this recently; it's online here:

http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/

The last section of the sample document shows how to set up TeXShop.  I 
suspect setting up TextWrangler would be somewhat similar.

Duncan Murdoch



More information about the R-help mailing list