Missing Unicode Greek Characters in Bookdown LaTeX

I spent this morning fighting with Bookdown. I was going through reviewer notes for the R Cookbook 2nd Edition and my coauthor, Paul Teetor, had noted that some of the greek symbols we were using were not showing up in the text when the book was rendered to PDF. Oddly, it looked fine in HTML.

This turned out to be a font issue. I was using XeLeTeX as my \(\LaTeX\) engine specifically because it handles UTF-8 unicode well. But whichever font it defaults to did not contain the UTF-8 Greek characters I was looking for. Oddly neither the mono font nor the body font contained these Greek characters.

I figured this out by pasting a whole host of Greek symbols from this site into my document and then building the book. I found that it all looked grand in HTML but in PDF some of the uppercase Greek letters were fine but none of the lowercase ones showed up.

After some struggling I discoverd that the way to change the font in the PDF output depends on the \(\LaTeX\) engine. The engine is set in the _output.yml file when using Bookdown:
_output.yml file

Figure 1: _output.yml file

Then the font overrides are set in the index.Rmd file:
index.Rmd file

Figure 2: index.Rmd file

It’s possible to not use index.Rmd as the first file in your document. However mine is set that way, as is standard. The files and order of chapters for a bookdown book is set in the bookdown.yml file:
bookdown.yml file

Figure 3: bookdown.yml file

After changing the font settings, my inline Greek Unicode symbols were rendering quite nicely.


comments powered by Disqus