Is it possible to force kableExtra to use UTF-8?

Viewed 93

Does anyone know If you can force kableExtra to save a .tex file as UTF-8 instead of ANSI? Since I have the Swedish letter å, ä, ö in my table, converting my tex-file to pdf won't work unless it is in utf-8 format. If I open up my tex-file and resave it as UTF-8, it works but is not really a solution for me.

I'm not sure it's kableExtra that is the problem. It might also be something with this Rstuido installation that is the problem (recently installed R / Rstudio on a new computer).

This is the command I use to save my table:

kableExtra::save_kable(table, file = "C:/PATH/table.tex")

Heres my sessionInfo:

R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)

Matrix products: default

locale:
[1] LC_COLLATE=Swedish_Sweden.1252  LC_CTYPE=Swedish_Sweden.1252   
[3] LC_MONETARY=Swedish_Sweden.1252 LC_NUMERIC=C                   
[5] LC_TIME=Swedish_Sweden.1252    

Let me know if you need any more info!

EDIT: Here's a small reprex:

library(kableExtra)
library(tidyverse)

test <- lm(mpg ~ cyl + wt, mtcars) %>% tidy() %>%
  kbl(format = "latex") %>% 
  footnote(number = c("Testa å ä ö"))

save_kable(test, file = "plain.tex")

So the plain.tex is ansi, but I want UTF-8.

0 Answers
Related