Skip to content

Numbered table captions broken #1948

@martinschmelzer

Description

@martinschmelzer

Description

Up until lately, using the caption argument of gt::gt() worked to get numbered captions when compiling to bookdown::html_document2.

With gt@0.10.0 the following example delivers the expected caption ("Table 1: Cars"). With gt@0.11.1 however, I get "(#tab:Tab1)Cars".

Reproducible example

---
title: "Test"
output: bookdown::html_document2
date: "2025-01-17"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = F)
library(gt)
```

```{r Tab1}
gt::gt(head(mtcars), caption = gt::html("Cars"))
```

Expected result

A table with caption "Table 1: Cars"

Session info

## R version 4.4.2 (2024-10-31)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.1 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.12.0 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: Europe/Berlin
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] dplyr_1.1.4 gt_0.11.1  
## 
## loaded via a namespace (and not attached):
##  [1] vctrs_0.6.5       cli_3.6.3         knitr_1.49.7      rlang_1.1.5      
##  [5] xfun_0.50         generics_0.1.3    jsonlite_1.8.9    glue_1.8.0       
##  [9] htmltools_0.5.8.1 sass_0.4.9        rmarkdown_2.29.1  evaluate_1.0.3   
## [13] jquerylib_0.1.4   tibble_3.2.1      fastmap_1.2.0     yaml_2.3.10      
## [17] lifecycle_1.0.4   bookdown_0.42.1   compiler_4.4.2    pkgconfig_2.0.3  
## [21] rstudioapi_0.17.1 digest_0.6.37     R6_2.5.1          tidyselect_1.2.1 
## [25] pillar_1.10.1     magrittr_2.0.3    bslib_0.8.0       tools_4.4.2      
## [29] xml2_1.3.6        cachem_1.1.0

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions