问题
I am referring to this Suppress automatic figure numbering in pdf output with r markdown/knitr which I don't think was answered fully.
Essentially, I am using knitr::spin and rmarkdown to produce word, pdf and html documents.
For word, there appears to be no numbering when one puts in +fig.1, fig.cap = "Figure name" You only get an output Figure name in the caption. To solve that, I used captioner class. figs = captioner("Figure") That works fine for word
But I am not faced with rewriting the script for pdf document as the caption turns up as figure 1: figure 1: The name
I am using knitr::spin to actually generate the RMD document for forward outputs in word and pdf.
I am not sure I can use hooks in knitr::spin, as I have tried it as advertised but can't get it to work.
I also tried
header-includes: \usepackage{caption} \usepackage{float}
\captionsetup[table]{labelformat=empty} \captionsetup[figure]{labelformat=empty}
as suggested somehere to surpress the prefix for pdf but I get errors from pandoc. It uses pdf2latex.
I am not sure how one would query the output format in knitr::spin to actually produce different actions for different formats which could be a solution although cumbersome.
Thank you so much for your help from a novice.
来源:https://stackoverflow.com/questions/41659348/knitr-spin-and-rmarkdown-fig-cap-figure-caption-producing-double-numbering-pd