rdatasculptor
rdatasculptor

Reputation: 8447

How to force bookdown to render document with xelatex engine instead of pdflatex?

I use bookdown to render html books. How can render the same book using LaTeX enging xelatex instead of pdflatex?

This is the main code I use:

bookdown::render_book('index.Rmd', output_file='mybook.pdf','bookdown::pdf_book')

It keeps on saying ! Sorry, but C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\pdflatex.exe did not succeed.. Because when rendering other kinds of pdf documents I use xelatex as an enging, I know it should be available in my system. How can I force bookdown to use xelatex?

Here this answer seemed to be asked before, but I have no idea how to use the mentioned solution: pandoc_options(args = c("--latex-engine", "xelatex")).

When I do something like this:

bookdown::render_book('index.Rmd', output_file='mybook.pdf','bookdown::pdf_book',pandoc_options(latex_engine = 'xelatex'))

There is an error: Error in pandoc_options(latex_engine = "xelatex") : argument "to" is missing, with no default

Does anyone know how to deal with this problem?

Upvotes: 0

Views: 626

Answers (1)

user13653858
user13653858

Reputation:

You can try to insert this into _output.yml general configuration file (for bookdown, as seen in the documentation):

bookdown::pdf_book:
  latex_engine: xelatex

This usually worked in my cases.

If you want to use pandoc_options(), you'll probably have to pass to argument as well (I haven't tried this):

bookdown::render_book(
  'index.Rmd',
  output_file = 'mybook.pdf',
  'bookdown::pdf_book',
  pandoc_options(
    to = "pdf",
    latex_engine = "xelatex"
  )
)

Upvotes: 4

Related Questions