-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
Kable table caption as chunk option with tab.cap? #1679
Comments
Haha, there are no "complicated reasons". I have actually thought about this before. The only complication is when there are multiple |
Ah I see - I've never ever had a need for multiple |
Hi, looks the same for plots/figures though - if I put a couple of plots in same chunk the fig.cap disappears. So we'd have a consistent rule for both tab.cap and fig.cap: 1 tab/plot/figure per chunk if you want the chunk's caption, else manage them otherwise. Since kable()'s format=markdown loses the caption=* option, such tab.cap at chunk level would be a solution also for that. Ah, BTW ... is there a reason why kable()'s caption is not latex-scaped like the actual table data? I often mention var names in the caption like they're in row/col names, but knitting chokes when a var name has e.g. a '_' in it and is also in the caption (and I forget to pre-escape the cap text). thx |
I second @mpaolo's comment! |
While understanding this may not be a priority, I would like to respectfully add one more voice that an option to directly caption tables in chunk headers would be useful. One use case I have encountered (in a team migrating to RMarkdown and LaTeX with many Word/Excel users), is that sometimes it'd be helpful to be able to embed an image of an existing table and label it as a table instead of a figure, which currently doesn't seem to be straightforward (workaround option here). While I know it sounds less reproducible, it's been a common ask in our workflow, eg to embed an existing table with complex formatting as an image as part of the introduction or methods section of a project. Thank you! |
This particular use case I think already has a straightforward solution with the chunk option
|
I would also like to request this feature for the use case when printing via
|
I think it's worth noting that David Gohel in his {flextable} package documentation suggests using a |
Thanks @francisbarton. For reference, these options are custom options from officer 📦 They do not exist in knitr but this feature request would surely port them here. |
The chunk option To test it, you can install the development version via remotes::install_github('yihui/knitr') Thanks! And apologies for taking so long to make this simple change (due to my overthinking at that time and then poor memory later). |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
This might be due to 'complicated reasons', but it would be fantastic if the syntax for providing captions to figures and tables was similar.
That is, rather than provide a table caption with
one could provide the caption with
As I was putting together teaching materials for an R Markdown workshop I realised that it seemed strange that
fig.cap
didn't have atab.cap
equivalent.The text was updated successfully, but these errors were encountered: