Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support xelatex in knit2pdf() #131

Closed
yihui opened this issue Feb 10, 2012 · 7 comments
Closed

support xelatex in knit2pdf() #131

yihui opened this issue Feb 10, 2012 · 7 comments
Labels
next Issues/PRs considered for the next release
Milestone

Comments

@yihui
Copy link
Owner

yihui commented Feb 10, 2012

maybe knit2pdf(input, output, compiler) or take a closer look at texi2pdf to see if it supports xelatex by the texi2dvi argument.

@ramnathv
Copy link
Contributor

It is as simple as setting Sys.setenv(PDFLATEX = "xelatex") after starting R. I tried using this in a code chunk,but that did not work. It should be easy to modify knit2pdf so that it runs this command before running texi2pdf.

@yihui
Copy link
Owner Author

yihui commented Feb 10, 2012

Cool. I will test and update it. Thanks!

@ramnathv
Copy link
Contributor

Here is a quick cut on a modified version of knit2pdf.

knit2pdf_v2 <- function (input, compiler = 'pdftex') {
  out = knit(input)
  owd = setwd(dirname(out))
  on.exit(setwd(owd))

  old_compiler = Sys.getenv('PDFLATEX')
  on.exit(Sys.setenv(PDFLATEX = old_compiler))
  if (compiler = 'xelatex'){
     Sys.setenv(PDFLATEX = 'xelatex')
  }
  texi2pdf(basename(out), clean = TRUE)
}

@ramnathv
Copy link
Contributor

I tested the function and it works. We could make it more flexible by allowing for a latex_compiler option that allows the user to pass pdftex, xelatex, or luatex depending on what they want.

@ramnathv
Copy link
Contributor

I just noticed that the latest build of RStudio allows you to choose your pdf driver between pdflatex and xelatex. You might want to add this as a note or a part of the FAQ.

@yihui
Copy link
Owner Author

yihui commented Feb 12, 2012

Yes, sure. Thanks a lot!

@yihui yihui closed this as completed in 08d8c15 Feb 12, 2012
yihui added a commit that referenced this issue Feb 12, 2012
yihui added a commit that referenced this issue Oct 12, 2016
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
next Issues/PRs considered for the next release
Projects
None yet
Development

No branches or pull requests

2 participants