问题
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