This is an extremely useful package. Thanks! In all my reporting with .Rmd files, I use the bookdown file formats pdf_document2 and html_document2, which allow for cross-referencing of tables and figures in text. See here: https://bookdown.org/yihui/bookdown/tables.html
Is there an option available in the gt package that allows for tables to have named captions and numbering, which allows for cross-referencing in text using \@ref(tab:tab1)?
There is no option currently for this, but it seems like this would be a worthwhile LaTeX integration feature, similar to #112. Thanks for filing this issue.
The new changes I pushed in this PR address this issue: https://github.com/rstudio/gt/pull/143
I added a label argument to tab_header because that seemed to make sense, but I'm not sure if that's the design you had in mind.
Currently, label is only inserted in the LaTeX caption, but it would be trivial to use the bookdown html tags.
Auto table numbering and cross-referencing are very useful for academic writing (both LaTex paper and html blogs). Hope those functions could work for both types of file and compatible with bookdown soon. Thank you again for the fantastic package!
+1 Not being able to cross reference blocks writing books and academic articles (and even technical blog posts in many cases probably).
+1 to this.
I have been using the subtitle as "caption" in gt tables. Could a caption argument to tab_header() be setup as an alias for subtitle, in a way that would work with bookdown's html_document2 and pdf_document2? It'd be nice to have some formatting pixie dust too.
gt(head(mtcars)) %>%
tab_header(title="", subtitle="Table 1: Mtcars with gt.") %>%
tab_options(table.width=pct(90),
table.border.top.style=0,
row.padding=px(4)) %>%
tab_style(style=cells_styles(
text_align='left',
text_color='grey'),
locations=cells_title(groups="subtitle"))
Check kable: Captions and Table numbering including cross-referencing for bookdown included. I don't know of any other package that supports it, but not having these two is a no-go for science.
I agree. This needs to be a priority fix for the more widespread use of this package for the creation of reports.
Since cross-referencing is documented confusingly (with or without #?), I have created a cheat-gist sample bookdown file, with a function mcaption that can substitute for the missing features in most cases I am interested in.
https://gist.github.com/dmenne/f8eb291c9e71a5de44764d442e8bdefd
Hi there, just wondering if there is a timeline for this? I love gt, but not being able to reference tables means I won't be able to use it for a lot of my work
Cross referencing in html would make this the undisputed king of table packages!
Tried out the new caption argument. That's a big step toward using this in {bookdown}. Is it possible to add caption.short, similar to knitr::kable()?
Tried out the new
captionargument. That's a big step toward using this in{bookdown}. Is it possible to addcaption.short, similar toknitr::kable()?
Can you please tell me, which function has the caption argument?
Can you please tell me, which function has the
captionargument?
It was a while ago, but I think the gt() function.
Most helpful comment
+1 Not being able to cross reference blocks writing books and academic articles (and even technical blog posts in many cases probably).