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

longtable=T incompatible with full_width=T when knitting to PDF #760

Open
raffaem opened this issue Jul 17, 2023 · 6 comments
Open

longtable=T incompatible with full_width=T when knitting to PDF #760

raffaem opened this issue Jul 17, 2023 · 6 comments

Comments

@raffaem
Copy link

raffaem commented Jul 17, 2023

Source file:

---
title: "Title Here"
output: pdf_document
---

## Title

```{r}
rm(list=ls(all.names = TRUE))
library(kableExtra)
kbl(mtcars, longtable=T) %>% kable_styling(full_width = T)
```

Error when knitting to PDF:

output file: test_kable2.knit.md

! Dimension too large.
\LT@max@sel #1#2->{\ifdim #2=\wd \tw@ 
                                      #1\else \number \c@LT@chunks \fi }{\th...
l.208 \end{longtabu}

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

Notice that knitting to HTML file works, as well as running the code in the console works.

It looks like the intermediate LaTeX file is invalid.

@r-scotti
Copy link

r-scotti commented Aug 8, 2023

I have a one cell table like the following:
my_tbl <- tibble(Title = paste(paste(lorem:::ipsum(paragraphs = 20),
collapse = " NEXT "), " *** END ***"))
Producing the pdf table with kbl(), if I do not add %>% kable_styling(full_width = T), a single line extending out of the page margin is printed.
If I specify %>% kable_styling(full_width = T) and omit longtable = T, the printout is truncated.
With:
kbl(my_tbl, longtable = T) %>% kable_styling(full_width = T)
I get your same error.
Hope someone can help!
Many thanks

@dmurdoch
Copy link
Collaborator

dmurdoch commented Dec 2, 2023

This looks to me like a problem in the longtable LaTeX package, not in the code that kableExtra is producing. Do you have a suggestion to fix the LaTeX code that kableExtra should be using?

@r-scotti
Copy link

r-scotti commented Dec 2, 2023

Actually I do not have any suggestion at that level.

@dmurdoch
Copy link
Collaborator

dmurdoch commented Dec 3, 2023

Okay. I'll leave this issue open for now, but I don't think we can address it.

@r-scotti
Copy link

r-scotti commented Dec 4, 2023

I will try to share a commented Quarto file to understand and reproduce the problem.

---
title: "Untitled"
format: pdf
editor: visual
---

```{r}
library(tidyverse)
library(kableExtra)
my_tbl <- tibble(Title = paste(paste(lorem:::ipsum(paragraphs = 20),  
                             collapse = " NEXT "), " *** END ***"))
# kbl(my_tbl, longtable = T) %>%  kable_styling(full_width = T)
# The line above produces the following error:
# ** compilation failed- error
# ** Dimension too large.
# ** \LT@max@sel #1#2->{\ifdim #2=\wd \tw@ 
# **                                       #1\else \number \c@LT@chunks \fi }{\th...
# ** l.260 \end{longtabu}
kbl(my_tbl)  %>%  kable_styling(full_width = T)
# The line above produces a table but, obviously, 
#   the printout continues beyond the page margin!

Is the problem clear?

@dmurdoch
Copy link
Collaborator

dmurdoch commented Dec 4, 2023

I don't use Quarto, so I'll leave this for someone else.

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

No branches or pull requests

3 participants