Longtable in beamer presentation not split across slides

I'd like to break a table across beamer slides with the kable option longtable = T. The respective document compiles without error; however, the table is not split across slides.

Here's a MWE:

---
output: beamer_presentation # pdf_document, beamer_presentation
header-includes:
  - \usepackage{longtable}
  - \usepackage{booktabs}
  - \usepackage{makecell}
---

```{r, warning=FALSE, echo=FALSE, message=FALSE}
library(dplyr)
iris %>%
  knitr::kable(format = "latex", booktabs = TRUE, longtable = TRUE) %>%
  kableExtra::column_spec(2, width = "16em")
```

Am I doing something wrong?

I believe you need to tell Beamer than splitting content is allowed.

See Beamer user guide http://mirrors.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf and search for allowframebreaks. You'll see that beamer discourage this so it is not default behavior

With Pandoc, you can put the attributes on slide header See Pandoc - Pandoc User’s Guide

Combining this should work.

---
output: 
  beamer_presentation:
    keep_tex: true 
header-includes:
  - \usepackage{longtable}
  - \usepackage{booktabs}
  - \usepackage{makecell}
---

## Table {.allowframebreaks}

```{r, warning=FALSE, echo=FALSE, message=FALSE}
library(dplyr)
iris %>%
  knitr::kable(format = "latex", booktabs = TRUE, longtable = TRUE) %>%
  kableExtra::column_spec(2, width = "16em")
```
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.