Scale kable table to fit page width

后端 未结 2 1218
一个人的身影
一个人的身影 2021-02-07 02:36

How do you format a table in pdf using kable function? Because my output table width exceeds the width of the pdf. Here is an example:

---
output: pdf_document
-         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-02-07 03:20

    Note if you are using longtable, this answer says,

    since longtable doesn't support resizebox, you cannot use the "scale_down" option in latex_options.

    However, they suggested using font_size, e.g.,

    kable(df, "latex", longtable = T, booktabs = T) %>%
      kable_styling(font_size = 7)
    

提交回复
热议问题