6

I'm doing a report that is heavy in R but also would like to use system fonts, so I was hoping to be able to use Sweave and XeLaTeX.

My preferred tex editor is TexShop (Mac 10.7), but it seems to only allow me to select either Sweave or XeLaTeX. I can produce a .tex file from Sweave and then manually run that through the XeLaTeX engine after adjusting the packages/fonts, but it seems like there must be an easier way.

It looked to me like RStudio had this functionality, but when I chose XeLaTeX as the typesetter it yields the error: [object Uint8Array]' is not a valid argument for 'Function.prototype.apply', which looks like some sort of C-based code. The Sweave document that produces that error is:

\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
Text
\end{document}

pdfLatex compiles it fine. Resources I checked on using XeLaTeX and Sweave don't address this issue as far as I've been able to see.

1 Answer 1

8

The easiest way to do this is to make yourself a Sweave-XeLaTeX engine file for TeXShop. To do this, do the following.

  • Using the Go menu in the Finder, navigate to the TeXShop Engines folder by choosing Go and then entering ~/Library/TeXShop/Engines
  • Make a Copy of the Sweave engine and rename it Sweave-XeLaTeX
  • Open the engine in TeXShop and change the line

     pdflatex "${1%.*}"
    

    to

     xelatex "${1%.*}"
    

Save the file, and restart TeXShop. You should now have a Sweave-XeLaTeX engine file in the dropdown menu next to the Typeset button.

You can also access the engine automatically in your .Rnw file by adding

% !TEX TS-program = Sweave-xelatex

as the first line of your file (you can choose this from the Macros -> Program menu item too.)

1
  • Thanks, works great! That's helpful in understanding how the different engines work too.
    – Señor O
    Dec 25, 2012 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.