Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

knit to pdf fails when tab_header is specified without a subtitle #197

Closed
tbradley1013 opened this issue Feb 25, 2019 · 3 comments
Closed

Comments

@tbradley1013
Copy link

When trying to include a gt inside of an Rmarkdown document being knit to pdf, the knitting fails if tab_header is specified without a subtitle.

.Rmd file

---
title: "tab header test"
date: "2/25/2019"
output: pdf_document
---

```{r}
library(tidyverse)
library(gt)
```

```{r}
gtcars %>%
  dplyr::select(mfr, model, msrp) %>%
  dplyr::slice(1:5) %>%
  gt() %>%
  tab_header(
    title = md("Data listing from **gtcars**")
    # subtitle = md("`gtcars` is an R dataset")
  )

```

Error

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

Error: Failed to compile test-tab-header.tex. See test-tab-header.log for more info.
Execution halted

If you include the subtitle, the pdf knits correctly.

@ulf85
Copy link

ulf85 commented Mar 6, 2019

Thanks for posting this issue and that skipping subtitle is the problem. I had the same issue.
A workaround for me was to set subtitle to an empty space:
tab_header(title = md("Data listing from **gtcars**"), subtitle = md(" "))

Then there is a little space between the title and the table. For me that was OK.

@microbe
Copy link

microbe commented May 7, 2020

I found this code the LaTeX generated by gt & knitr.
The \small \\ is there even when no subtitle is defined in tab_header.
If I remove it in the LaTeX, then it compiles well.

\begin{longtable}{rrrrrrrrrrr}
\caption*{
\large MT Cars\\ 
\small \\ 
} \\ 

@rich-iannone
Copy link
Member

A recent fix in the development version of the package fixes this. So, closing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants