Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

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.)

share|improve this answer
    
Thanks, works great! That's helpful in understanding how the different engines work too. –  Señor O Dec 25 '12 at 4:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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