knitr
knitr copied to clipboard
Specify figure caption command
I'm updating the AMS template in rticles and AMS's guidelines state that figures and tables in the appendix should be captioned with the \appendcaption
command instead of the usual \caption
. Is there a way of defining the caption command used in a LaTeX figure? For what I see in hook_plot_tex
, \caption
seems to be hard-coded here:
https://github.com/yihui/knitr/blob/8e91c571a6ed0e3a654f497b2557e2af540073a2/R/hooks-latex.R#L131
If it's not overly niche, maybe it could be changed to use some chunk option such as 'fig.cap.command`?
By filing an issue to this repo, I promise that
- [x] I have fully read the issue guide at https://yihui.org/issue/.
- [x] I have provided the necessary information about my issue.
- If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
- If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included
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')
. - If I have posted the same issue elsewhere, I have also mentioned it in this issue.
- [x] I have learned the Github Markdown syntax, and formatted my issue correctly.
I understand that my issue may be closed if I don't fulfill my promises.
You can set your original function for plot hook
knitr::knit_hooks$set(plot = function(x, options) {
...
}
https://yihui.org/knitr/hooks/#output-hooks
Yes, I know, but it's a rather involved process and copypasting all that code just to change a few characters seems wasteful. Not to mention that is not very user-friendly to tell a researcher that they need to copy that code, figure out which functions are internal to knitr and append knitr:::
to them, and then change "caption" to "appendcaption".
I see. I think adding the option is reasonable.
Just for your information, you can add a custom function to rticles
and let the package set the hook function.
Yes, I might have to do that, since the syntax of appendcaption is not exactly the same as the one for caption.
On Tue, 7 Jul 2020, 23:07 atusy, [email protected] wrote:
I see. I think adding the option is reasonable. Just for your information, you can add a custom function to rticles and let the package set the hook function.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yihui/knitr/issues/1872#issuecomment-655237029, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBX46ZVNRVELJU6SPHNOE3R2PIGBANCNFSM4OSB7EEA .
It is indeed a reasonable feature request, but I'd rather wait for a second vote before implementing it since there have already been so many chunk options in knitr, and I tend not to add a chunk option just for a specific journal. I'll close this issue in favor of https://github.com/rstudio/rticles/issues/298 for now, but can reconsider it in the future. Thanks!