Blank lines affect use of computed fig.cap with knitr/rmarkdown to PDF

I use the following code to get consistent figure caption numbers when producing HTML and PDF from the same source:

.format <- knitr::opts_knit$get("rmarkdown.pandoc.to")
.tag <- function(N, cap ) ifelse(.format == "html",
                                 paste("Figure ", N, ": ",  cap, sep = ""),
                                 cap)

If preceding text does not leave a blank line, the captions are correct in HTML but not in PDF

x = seq(0, 2*pi, length = 100)
plot(x, sin(x))

But it works with a blank line.

plot(x, sin(x))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.