When a gt table, that has a [`rowname_col`](https://gt.rstudio.com/reference/gt.html) specified, is included in a knitr code chunk that *also* has a `tbl-cap` set, rendering the document to PDF fails with the following error:

<details><summary>Terminal output</summary>

```
processing file: t.qmd
  |.......................                                               |  33%
  ordinary text without R code

  |...............................................                       |  67%
label: tbl-one (with options) 
List of 2
 $ tbl-cap: chr "A table"
 $ echo   : chr "fenced"

  |......................................................................| 100%
  ordinary text without R code


output file: t.knit.md

pandoc 
  to: latex
  output-file: t.tex
  standalone: true
  pdf-engine: xelatex
  variables:
    graphics: true
    tables: true
  default-image-extension: pdf
  filters:
    - crossref
  
metadata
  documentclass: scrartcl
  classoption:
    - DIV=11
    - numbers=noendperiod
  papersize: letter
  header-includes:
    - '\KOMAoption{captions}{tableheading}'
  block-headings: true
  keep-md: true
  keep-tex: true
  
running xelatex - 1
  This is XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex)
   restricted \write18 enabled.
  entering extended mode
  
updating tlmgr

updating existing packages

compilation failed- error
Misplaced \noalign.
\caption ->\noalign 
                    {\global \@captionabovetrue }\scr@caption 
l.213 \caption
              {\label{tbl-one}A table }\tabularnewline 

see t.log for more information.
```

</details

Reproducible example (that creates above output):

- Source file: [`t.qmd`](https://salim-b.gitlab.io/adhoc/t.qmd)
- Render command: `quarto render t.qmd --to=pdf --metadata=keep-md:true --metadata=keep-tex:true`
- Intermediate Markdown file: [`t.md`](https://salim-b.gitlab.io/adhoc/t.md)
- Intermediate TeX file: [`t.tex`](https://salim-b.gitlab.io/adhoc/t.tex)
- Log file: [`t.log`](https://salim-b.gitlab.io/adhoc/t.log)

Note that gt sets `rowname_col = "rowname"` by default when a column named `rowname` is present in the input data, so removing the explicit  `rowname_col = "rowname"` in the example above results in the same error. Also `mtcars |> gt::gt(rownames_to_stub = TRUE)` has the same result (since it produces the same table).

When either `rowname_col` is set to an inexistent column name (resulting in ommitting the table stub that would otherwise contain the row names), *or* the `tbl-cap` chunk option is removed, the PDF renders fine.

## System details

- Quarto 0.9.535
- R 4.2.0
- Latest TinyTeX providing `XeTeX, Version 3.141592653-2.6-0.999994 (TeX Live 2022) (preloaded format=xelatex 2022.6.7)`
- Ubuntu 20.04

## Checklist

When filing a _bug report_, please check the boxes below to confirm that you have provided us with the information we need. Have you:

- [x] [formatted your issue](https://yihui.org/issue/#please-format-your-issue-correctly) so it is easier for us to read?

- [x] included a minimal, self-contained, and reproducible example?

- [x] documented the quarto version you're running, by providing the output produced by `quarto check` in a terminal in your issue?

- [x] documented the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?

- [x] documented which operating system you're running? If on Linux, please provide the specific distribution as well.

- [x] upgraded to the latest version, including your versions of R, the RStudio IDE, and relevant R packages?

cderv
2022-06-07T19:54:08Z
salim-b
1.0
closed
gt table with `rowname_col` plus `tbl-cap` fails to render as PDF
https://github.com/quarto-dev/quarto-cli/issues/1093