Include tab.cap
in eval.after
and other chunk options (port to knitr)
#2305
Labels
question
Questions (which should belong to forums instead of Github)
Tables are an important part of documents generated using R markdown. Aside from the base
kable
, alternatives to creating tables likeflextable
recommend usingtab.cap=""
in the chunk options to define table captions. Very often, one would like to use inline code to generate elements of the caption, particularly since tables are often used to show data summaries. While this is easily done using a regular R string such asglue::glue("This is my caption, and {value1} is a value")
for thefig.cap
chunk option (after having seteval.after="fig.cap"
, which is now the default), this is currently not possible for tables becausetab.cap
is not an option inknitr
but fromofficer
.There have been previous discussions (feature request) on porting this option over to
knitr
, but I don't think it has been prioritised. Given how frequently tables are generated in R markdown, I think it makes sense to allow the captioning for tables to follow the same format as for figures. My current workaround is to create a new initial chunk which creates the required objects, which are then referenced in-line in the subsequent chunks. But this is not very elegant, and it would be great to have caption options for tables and figures to be implemented in the same way.By filing an issue to this repo, I promise that
xfun::session_info('knitr')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('yihui/knitr')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: