How do I knit a pdf containing gt tables?

蓝咒 提交于 2021-02-11 12:41:12

问题


I'm writing up a report in R Markdown and I made some tables using the gt package. However, when I attempt to knit to a pdf or html file, I get this error:

! LaTeX Error: There's no line here to end.

Error: LaTeX failed to compile final_report.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See final_report.log for more info.

Interestingly, I'm able to knit to a Word document. I did do some experimenting to make sure it was the tables that were causing it, just to be sure. If anyone needs to see specific code to help let me know! Thank you in advance!


回答1:


Interestingly, I figured out that it won't knit to pdf if a subtitle is not specified in the tab_header() command. Works now, though! Example:

data %>%
   gt() %>%
   tab_header(title = md("Title"),
              subtitle = md("Subtitle")) # Must be present to knit to pdf


来源:https://stackoverflow.com/questions/65112503/how-do-i-knit-a-pdf-containing-gt-tables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!