mbeasle2
mbeasle2

Reputation: 163

How do I knit a pdf containing gt tables?

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!

Upvotes: 1

Views: 2322

Answers (1)

mbeasle2
mbeasle2

Reputation: 163

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

Upvotes: 1

Related Questions