Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider including caption addition as in pander #328

Closed
r-cheologist opened this issue Jul 23, 2019 · 1 comment
Closed

Consider including caption addition as in pander #328

r-cheologist opened this issue Jul 23, 2019 · 1 comment

Comments

@r-cheologist
Copy link

gt greatly facilitates the table generation and formatting in my rmarkdown/bookdown reports. Adding corresponding captions, however, is not straight forward and I haven't yet figured out how to

  1. add a caption that is nicely represented in (pdf)LaTeX output

  2. linked to the table object and

  3. integrated into bookdowns cross referencing infrastructure.

panderas well as knitr::kable offer caption arguments for this purpose (which may be wrangled into bookdown-compatibility in the first case).

I'd appreciate if gt would provide something equivalent - like gt::tab_caption.

@billdenney
Copy link
Contributor

billdenney commented Nov 17, 2019

When adding captions, it would be nice if the captions supported the LaTeX feature of short and long captions. The short caption is what shows up in the list of tables at the top while the long caption is what is used immediately adjacent to the table itself.

The LaTeX to accomplish this is:

sprintf("\caption[%s]{%s}", short, long)

I've done this in my personal (not on CRAN) topiclongtable package here: https://github.com/billdenney/TopicLongTableR/blob/master/R/topic_long_table_caption.R

That code will not likely be the final code chosen, but it does provide several helpful features that I use often like:

  • Integrated short and long captions.
  • The option to combine the short and long captions (so that the short caption shows up as the first part of the long caption without the minor but tedious task of pasting them together each time).
  • Integration of a label.
  • Extraction of a caption attribute from the input object so that many tables can be generated as data.frames and then they can be run through the table generation code separately while only tracking what will be the caption at the initial data.frame stage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants