I'm trying to create a book with bookdown
as pdf. It works well creating an EPUB file.
My YAML is this:
---
title: "Title Here"
subtitle: "Subtitle here"
author: "me"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
bibliography: [book.bib]
biblio-style: apalike
link-citations: yes
description: "description goes here."
cover-image: "cover.png"
lang: "es"
always_allow_html: true
output:
pdf_document:
latex_engine: xelatex
pdf_document2:
latex_engine: lualatex
---
At some point in chapter 4 I have a Japanese letter, U+305B.
I've tried creating the pdf book with:
bookdown::render_book("index.Rmd", output_format = bookdown::pdf_document2())
and
bookdown::render_book("index.Rmd", output_format = bookdown::pdf_book())
Both of them complain that:
! Package inputenc Error: Unicode character せ (U+305B)
(inputenc) not set up for use with LaTeX.
and recommend me to check this part of the rmarkdown cookbook. From there is where I took the 4 last lines of the YAML preamble.
I couldn't help but noticing that the call to pandoc is taking pdflatex
as the pdf-engine
(see third-to-last line):
/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS myFileName.knit.md --to latex
--from markdown+autolink_bare_uris+tex_math_single_backslash
--output herramientasBasicasMejoramiento.tex
--lua-filter /usr/local/lib/R/site-library/bookdown/rmarkdown/lua/custom-environment.lua
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/pagebreak.lua
--lua-filter /usr/local/lib/R/site-library/rmarkdown/rmarkdown/lua/latex-div.lua
--metadata-file /tmp/RtmpAbwGga/file565f3d087e3c --self-contained
--table-of-contents --toc-depth 2 --number-sections
--highlight-style tango --pdf-engine pdflatex --variable graphics
--wrap preserve --variable tables=yes
--standalone -Mhas-frontmatter=false --citeproc
I'm working in Ubuntu and have installed both texlive and tinytex.
whereis xelatex
xelatex: /home/gp/bin/xelatex /usr/local/texlive/2019/bin/x86_64-linux/xelatex
There is an unanswered question with a problem that looks similar.
What am I doing wrong, and what can I do to make it work?
You need to specify the output format in a way that will see your latex_engine
argument, e.g.
bookdown::render_book("index.Rmd", output_format = "pdf_document2")
(naming one of the output formats from your YAML), or
bookdown::render_book("index.Rmd",
output_format = bookdown::pdf_document2(latex_engine = "xelatex"))
(specifying it independently).