Skip to contents

Define a counter with cnt <- counter("type"). Add cross-referenced label in your document with cnt$set("ref"). Refer to "ref" with cnt$get("ref").

Usage

counter(label, open = NULL, close = NULL, sep = " ", link = FALSE)

Arguments

label

character. Default prefix for the counter.

open

character. Opening bracket such as "(" or "["

close

character. Closing bracket such as ")" or "]"

sep

character. Separator between label and counter.

link

logical. If TRUE, get() method returns a counter surrounded by a tag, linked to the referenced id.

Value

List of functions to set and get counters with label.

Examples

cnt <- counter("Quiz")
cnt$set("aaa")
#> [1] "Quiz 1"
cnt$set()
#> [1] "Quiz 2"
cnt$set("bbb", quiet = TRUE)
cnt$get("aaa")
#> [1] "Quiz 1"
cnt$get("bbb")
#> [1] "Quiz 3"
cnt$get("aaa", type = "bare")
#> [1] "1"
cnt$dump()
#> $aaa
#> [1] 1
#> 
#> [[2]]
#> [1] 2
#> 
#> $bbb
#> [1] 3
#>