captioner: Captioner function

Description Usage Arguments Details Value Examples

Description

Creates a function to create numbered captions for figures, tables or other objects

Usage

1
2
captioner(prefix = "Figure", auto_space = TRUE, levels = 1, type = NULL,
  infix = ".")

Arguments

prefix

Character string containing text to go before object number. The default is Figure.

auto_space

Logical indicating whether or not a space should automatically be added following the prefix. Space is added by default.

levels

Logical or number indicating whether or not you want hierarchical numbering, and if so, how many levels. Hierarchical numbering is turned off by default.

type

Vector with same length as levels indicating whether figure numbering should be numeric (n), lowercase character (c), or uppercase character (C). If unspecified, captioner will revert to all numeric values.

infix

Character string containing text to go between figure numbers if hierarchical numbering is on. Default is .

Details

Captioner generates a function with the following parameters

name: Character string containing a unique object name

caption: The object caption

display: Character string (or logical) indicating what display mode you would like:

level: Optional numeric used to bump up the numbering if you have hierarchical numbering. See also bump.

cite: Deprecated. Please use display.

num: Deprecated. Please use display.

And returns a character string containing the prefix and object number with or without a caption. The initial numbering is determined based on the order of caption creation. However, this order is modified based on the citations you use. The first figure to be cited will be moved to the beginning of the list, becoming Figure 1.

Value

A captioner function.

Examples

1
2
3
4
5
6
7
fig_nums <- captioner()
fig_nums("flower_plot", "This plot shows the distribution of flower colors")
fig_nums("flower_plot", display = "cite")
fig_nums("flower_plot")

tables <- captioner(prefix = "Table", levels = 2)
tables("a", "Table of world populations sorted from greatest to least.")

Example output

[1] "Figure  1: This plot shows the distribution of flower colors"
[1] "Figure  1"
[1] "Figure  1: This plot shows the distribution of flower colors"
[1] "Table  1.1: Table of world populations sorted from greatest to least."

captioner documentation built on May 2, 2019, 10:13 a.m.