More efficient R / Sweave / TeXShop work-flow?

后端 未结 11 943
傲寒
傲寒 2021-01-30 05:28

I\'ve now got everything to work properly on my Mac OS X 10.6 machine so that I can create decent looking LaTeX documents with Sweave that include snippets of R code, output, an

11条回答
  •  无人共我
    2021-01-30 06:20

    One-click Sweaving is easy to do in TeXShop using the Sweave.sh script by Gregor Gorjanc. Get it from http://cran.r-project.org/contrib/extra/scripts/Sweave.sh and put it in your ~/Library/TeXShop/bin/ folder.

    Then add the following files to your ~/Library/TeXShop/engines/ folder:

    As Sweave.engine:

    #!/bin/bash
    ~/Library/TeXShop/bin/Sweave.sh  -ld "$1"
    

    As SweaveNoClean.engine:

    #!/bin/bash
    ~/Library/TeXShop/bin/Sweave.sh  -nc -ld "$1"
    

    You'll have to set the permissions on Sweave.sh and the two engine files to allow execution.

    To Sweave with one click, restart TeXShop after adding these files, open the Sweave document (with Rnw extension) and in the dropdown menu above the document window, change it from LaTeX to Sweave or SweaveNoClean.

    BEWARE: The "Sweave" option wll clean up after itself, deleting all the extra files LaTeX and Sweave creates. If your file is called myfile.Rnw, this will include files called myfile.R and myfile.tex. So a word to the wise: make sure the basename of your Rnw file is unique; then nothing unexpected will be written over and then deleted.

    The SweaveNoClean option does not clean up after itself. This makes sure you don't delete anything unexpected; though it could still write over a file called myfile.tex if you Sweave a myfile.Rnw. This also doesn't delete any graphics that have been created, in case you want to have them separate from your full typeset document.

提交回复
热议问题