Tazinho / Advanced-R-Solutions

Set of solutions for the Advanced R programming book
https://advanced-r-solutions.rbind.io/
290 stars 118 forks source link

Fix emojis in PDF output #257

Open Tazinho opened 3 years ago

Tazinho commented 3 years ago

The encoding issue in the PDF output (see e.g. S4 emoji exercises), are also in the whole R6 chapter. E.g. the colors (heart, spade, etc.) for my_deck$draw(52) are not correctly rendered.

henningsway commented 3 years ago

just found this commit https://github.com/hadley/adv-r/commit/3915c3a6c144951a6a062ebe1cd497d3887f7eb4, which seems to offer a solution for the emojis in s4.

henningsway commented 3 years ago

I've just applied Hadley's "emoji embedding strategy" for the emojis in S4.

The strategy comes down to creating latex-code to include and inline image of the emoji (which is downloaded automatically), when the output-type is pdf. Because this code is generated by code, it only works as an inline command - otherwise the code will be evaluated.

Because of this is doesn't work for the the R6 emoji. Here, I've instead tried to use the https://github.com/mreq/xelatex-emoji latex-package, but couldn't get it to work (with the rmarkdown). I've replaced the ♠ with SPADE for now etc.

Maybe @hadley has a good suggestion how to fix this. As we've seen in the print it's actually not solved in Advanced R yet also. :nerd_face: