Open rich-iannone opened 2 years ago
I think it is also part of this same issue but this
\captionsetup[table]{labelformat=empty,skip=1pt}
would need to change as this will cause table caption in quarto to have no label (labelformat=empty
)
This above is missing the Table 1:
that is expected as documented in Quarto: https://quarto.org/docs/authoring/tables.html#computations
I am experiencing the same issue with tab_header. It breaks the captioning and cross refs in Quarto. No table is produced in the output.
---
title: "quarto gt"
format: html
---
## Quarto
A table @tbl-gt.
```{r}
#| label: tbl-gt
#| tbl-cap: A Caption
#| echo: false
library(gt)
myTable <- mtcars |>
head() |>
gt() |>
tab_header(title = "mtcars")
## Output
results:
WARNING: Unable to resolve crossref @tbl-gt
and html output:
<section id="quarto" class="level2">
<h2 class="anchored" data-anchor-id="quarto">Quarto</h2>
<p>A table <strong>?@tbl-gt</strong>.</p>
<div id="tbl-gt" class="cell tbl-parent quarto-layout-panel anchored" data-tbl-cap="A Caption">
</div>
</section>
## Session info
packageVersion("gt") [1] ‘0.6.0.9000’
sessionInfo() R version 4.2.1 (2022-06-23) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Monterey 12.4
Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
loaded via a namespace (and not attached):
[1] compiler_4.2.1 fastmap_1.1.0 cli_3.3.0
[4] htmltools_0.5.3 tools_4.2.1 rstudioapi_0.13
[7] yaml_2.3.5 rmarkdown_2.14.2 knitr_1.39
[10] xfun_0.31 digest_0.6.29 rlang_1.0.4
[13] evaluate_0.15
% quarto --version
1.0.37
% quarto pandoc --version
pandoc 2.18
I believe that the normal usage here when combining quarto and gt
should be that gt
only generates the interior of the table and the qmd file does the rest. It's currently hacky to be able to do this, but at least you get control over the float, title, caption, notes, and column widths.
\begin{table}[h]
\caption{Table title with Table 1}
\begin{center}
\begin{tabular}{rlcrrrrll}
`r library(gt); tmp <- exibble |>
gt::gt() |>
gt::as_latex()
tmp[1] <- tmp[1] |>
# remove first and last lines
stringr::str_remove("^.*\n") |>
stringr::str_remove("\\\\end\\{longtable\\}.*$")
tmp
`
\end{tabular}
\end{center}
\tiny These are notes
\label{table:exampletable}
\end{table}
The relevance to this issue is that if, gt decides this should be the standard latex behaviour, any captions, titles, or notes should just be stripped with a warning that potentially gives some content for the user to copy-paste.
Does this conflict with #1800?
If I generate a LaTeX table with a table heading (using
tab_header()
) the resulting LaTeX code generated contains the use of a\caption
command. For example, I could useand get
in the console. The issue is that this use of a caption interferes with the use of an actual figure/table caption used in R Markdown / bookdown / Quarto documents. We ought to use anything other than a caption to typeset a table heading. Then work can be done in Quarto to properly generate a caption based on a number of ways to specify a table caption.