Suppress automatic figure numbering in pdf output with r markdown/knitr

后端 未结 1 913
半阙折子戏
半阙折子戏 2020-12-30 08:59

I am writing a document in R markdown (.rmd). I would like to be able to knit both Word and PDF outputs. I am having difficulty with figure numbering. With PDF output, the f

相关标签:
1条回答
  • 2020-12-30 09:37

    Is there a way to suppress the automatic numbering for PDF?

    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 ---
    

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

    0 讨论(0)
提交回复
热议问题