knitr icon indicating copy to clipboard operation
knitr copied to clipboard

fig.scap usage/rewrite of `hook_plot_tex()`

Open billdenney opened this issue 3 years ago • 0 comments

TL;DR: Would a rewrite of hook_plot_tex() that broke out the different parts and tried to make it more modular be appreciated or considered as too risky to be worth it?

The longer version:

I was trying to figure out how to automatically use short caption functionality via these lines of code:

https://github.com/yihui/knitr/blob/cc711b12bc80659935a7b74641b84c9f51fa44b2/R/hooks-latex.R#L134-L136

And, it wasn't obvious to me how to structure my code and chunk options so that it would work the way I wanted it to. (As an aside to the rest of this message, I thought that fig.cap="[short caption]{long text}" or fig.cap="{short caption;long text}" would be the right chunk option to use. But, that's an aside from the main topic here.)

I was thinking that a rewrite could follow the nesting suggested in the top of hook_plot_tex():

https://github.com/yihui/knitr/blob/8e91c571a6ed0e3a654f497b2557e2af540073a2/R/hooks-latex.R#L45-L56

And, with that, I could also increase its test coverage and documentation of some of the extra features that are less obvious.

The rewrite could also address #1872.


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.

billdenney avatar Apr 21 '22 20:04 billdenney