You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a shiny app where the user can download a formatted version of a table as a pdf. I have been able to style the table for my needs using kable and kable_extra, but I have not been able to change the font. This is within shiny, but I believe it should work the same if I were exporting to pdf without using RMarkdown.
See the reproducible example below. I have tried defining the font using the html_font parameter in kable_styling, and using the latex_header_includes parameter in save_kable. The code below shows my latest formatting attempts with both, but I have tried many others.
Can you advise how I can change the font?
df <- data.frame(animal = c("cat", "dog", "horse", "lemur"), lifespan = c(15, 12, 25, 37))
x <- kable(df, "latex", booktabs = T, linesep = c("", "", "", "\\hline"), col.names = NULL) %>%
add_header_above(c("Animal Lifespans" =2), line = F) %>%
kable_styling(font_size = 5, full_width = TRUE, html_font = '"Arial Narrow"')
save_kable(x, "~/Downloads/test.pdf")
# I tried adding the font by adding the code below as a parameter to the save_kable function, but get errors
# latex_header_includes = `c("\\\\usepackage{helvet}", "\\\\renewcommand{\\\\familydefault}{\sfdefault}")`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have created a shiny app where the user can download a formatted version of a table as a pdf. I have been able to style the table for my needs using kable and kable_extra, but I have not been able to change the font. This is within shiny, but I believe it should work the same if I were exporting to pdf without using RMarkdown.
See the reproducible example below. I have tried defining the font using the
html_font
parameter in kable_styling, and using thelatex_header_includes
parameter insave_kable
. The code below shows my latest formatting attempts with both, but I have tried many others.Can you advise how I can change the font?
Beta Was this translation helpful? Give feedback.
All reactions