figCapNo: Adds a figure caption number

Description Usage Arguments See Also Examples

View source: R/figCaptionNo.R

Description

The function relies on options("fig_caption_no") in order to keep track of the last number. If you want to force the caption function to skip captions while still using it in the knitr fig.cap option then simply set options(fig_caption_no = FALSE)

Usage

1
2
figCapNo(str, roman = getOption("fig_caption_no_roman", FALSE),
  sprintf_str = getOption("fig_caption_no_sprintf", "Fig. %s: %s"))

Arguments

str

The string that is to be prepended with string

roman

Whether or not to use roman numbers instead of arabic. Can also be set through options(fig_caption_no_roman = TRUE)

sprintf_str

An sprintf formatted string where the first argument is reserved for the string generated by the counter and the second one is for the caption text. Can also be set through options(fig_caption_no_sprintf = TRUE)

See Also

Other figure caption functions: figCapNoLast, figCapNoNext

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
```{r, fig.cap=figCapNo("My nice plot")}
plot(1:10 + rnorm(10), 1:10)
```

## End(Not run)
org_opts <- options(fig_caption_no = 2,
                    fig_caption_no_sprintf = "Figure %s: %s")
figCapNo("A plot with caption number = 3")

org_opts <- options(fig_caption_no = TRUE)
figCapNo("A plot with caption number =  1")

# Use default setting
options(fig_caption_no_sprintf = NULL)
figCapNo("A plot with caption number =  2")

# Return the original settings
options(org_opts)

Gmisc documentation built on Sept. 21, 2018, 6:29 p.m.