hadley / adv-r

Advanced R: a book
http://adv-r.hadley.nz
Other
2.35k stars 1.71k forks source link

latex error while generating pdf output of the book #1605

Open peranti opened 4 years ago

peranti commented 4 years ago

Did anyone face the below error while generating the pdf version of the book? Package fontspec Error: The font "Inconsolata" cannot be found.

I am using the following command: bookdown::render_book("index.Rmd", output_format = "bookdown::pdf_book")

after installing all the required packages. I am using both the current version of the book and also the version used for second edition release.

Any leads on the error would be helpful, Thanks!

KeFungi commented 4 years ago

Change the font name to lowercase worked for me when compiling with tinytex on macOS.

edit the template ./latex/preamble.tex \setmonofont[Mapping=tex-ansi]{inconsolata}

Another issue I met was that {sidebar} and {base} block in the intermediate _main.tex file is undefined, so I needed to manually remove them and only keep the outer {kframe} blocks. Then move folders in _bookdown_files to project root and compile _main.tex from there so the relative path is correct.

Hope this helps.