Tables in Quarto using kable and longtable package

I have an issue that just 'popped up' yesterday in knitting rmarkdown files with tables using kable and longtable.
The issue in question is when I set 'longtable=TRUE' in the kable function with a "label: tbl-foo". Note that the label is 'label: tbl-x'. Compiling this gives an error (via tlmgr):

Rendering PDF
running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
updating tlmgr

updating existing packages
ERROR: 
compilation failed- error
Missing } inserted.
<inserted text> 
                }
l.291 \end{longtable}

If I change longtable to FALSE in the kable(...) call, the code compiles but the bottom of the table is cutoff rather than going to the next page. If I change the label to "label: tab-x", everything is fine. What's also interesting is that this behavior started after a successful compile with no changes to labels in the quarto code. This behavior is also there with straight R markdown. Is this expected behavior (I ask because the examples in the Quarto.org guide has table chunk labels that are "label: tbl-foo") without any caveats I could find. Here's my MWEx.:

MWEx:

---
title: Intro
format: 
  pdf: default
include-in-header:
  text:
    \usepackage{booktabs}
    \usepackage{longtable}
---

```{r}
#| echo: false 
#| include: true 
#| message: false 
#| label: tbl-x
#| tbl-cap: "My table w/ math"

require(knitr) 
require(kableExtra) 

fmt <- 'latex'
knitr::opts_knit$set(kable.force.latex = TRUE)
# prepare a long table
tab.df <- data.frame('Term' = 1:100,'Description' = rep('Desc',100), 
                     'Units'= rep('mg/L',100),'Chapter' = paste0('Ch ',1:100))

tab.df %>% kable(format=fmt,escape=F, booktabs=T, align='clcl', longtable=T) %>% 
 kable_styling(font_size=10) %>% 
 column_spec(c(1,4),width='.5in') %>% 
 column_spec(2,width='2.75in') %>% 
 column_spec(3,width='0.75in')

Addendum to the longtable issue: What follows went from 'working' to 'not working' between two compilations without making changes to the yaml and only minor text changes to the .qmd file. Undoing the text changes did not reverse these issues, so some permanent change occurred.

In order for Quarto tables to be cross-referenced, the label has to start with tbl- (per the description in Quarto table cross references]. So if the table is small and longtable=F, there will be a conflict.

Another issue is that when using kableExtra::kable_styling(latex_options='striped') an error is thrown during compilation stating that the control sequence that provides the shading for the rows is undefined. I'm not sure where to go from here.

ERROR:
compilation failed- error
Undefined control sequence.
\cellcolor

l.251 \cellcolor
{gray!6}{\uuline{A}} & \cellcolor{gray!6}{discretization m...

I believe this is all fixed with latest Quarto 1.4.

Can you confirm it ?

This topic was automatically closed 45 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.