R/insertFigureCaption.R
, R/insertNumberedCaption.R
, R/insertTableCaption.R
insertNumberedCaption.Rd
These functions can be used to manually insert a numbered caption. These
functions have been designed to work well with setFigCapNumbering()
and
setTabCapNumbering()
. This is useful when
inserting figures or tables in an RMarkdown document when you
use automatic caption numbering for knitr
chunks, but are inserting a
table or figure that isn't produced in a knitr
chunk while
still retaining the automatic numbering. insertNumberedCaption()
is the
general-purpose function; you will typically only use insertFigureCaption()
and insertTableCaption()
.
insertFigureCaption( captionText = "", captionName = "fig.cap", prefix = getOption(paste0(optionName, "_prefix"), "Figure %s: "), suffix = getOption(paste0(optionName, "_suffix"), ""), optionName = paste0("setCaptionNumbering_", captionName), resetCounterTo = NULL ) insertNumberedCaption( captionText = "", captionName = "fig.cap", prefix = getOption(paste0(optionName, "_prefix"), "Figure %s: "), suffix = getOption(paste0(optionName, "_suffix"), ""), optionName = paste0("setCaptionNumbering_", captionName), resetCounterTo = NULL ) insertTableCaption( captionText = "", captionName = "tab.cap", prefix = getOption(paste0(optionName, "_prefix"), "Table %s: "), suffix = getOption(paste0(optionName, "_suffix"), ""), optionName = paste0("setCaptionNumbering_", captionName), resetCounterTo = NULL )
captionText | The text of the caption. |
---|---|
captionName | The name of the caption; by default, for tables,
" |
prefix, suffix | The prefix and suffix texts; |
optionName | The name of the option to use to save the number counter. |
resetCounterTo | If a numeric value, the counter is reset to that value. |
The caption in a character vector.
insertNumberedCaption("First caption"); #> [1] "Figure 1: First caption" insertNumberedCaption("Second caption"); #> [1] "Figure 2: Second caption" sectionNumber <- 12; insertNumberedCaption("Third caption", prefix = paste0("Table ", sectionNumber, ".%s: ")); #> [1] "Table 12.3: Third caption"