且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用R markdown/knitr抑制pdf输出中的自动图形编号

更新时间:2021-12-22 09:15:00

是否可以禁止对PDF进行自动编号?

好的.为您的输出格式添加一个format变量,并在figref中为该格式添加一个处理程序.使用RStudio预览版,您可以使用format <- knitr::opts_knit$get("out.format"),但是对于发行版,则需要手动进行设置.
然后在figref()中添加所需的输出...

Sure. Add a format variable for your output format and a handler for that format within figref. With RStudio preview edition you could use format <- knitr::opts_knit$get("out.format") but with the release version you'd need to set it manually.
Then in figref() add whatever you desire for the output...

    if ( format == "latex" ) return( caption )
    if (!missing(caption)) {
    --- >8 ---

我个人将使用预览版和switch语句进行处理.遵循 https://***.com/a/27321367/173985 .

Personally I'd use the preview edition and a switch statement for the handling. Along the lines of https://***.com/a/27321367/173985.