Learn R Programming

captioner (version 2.2.3)

captioner: Captioner function

Description

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

Usage

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 .

Value

A captioner function.

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:

  • full or f is the default and shows the entire caption with prefix and number
  • cite or c displays just the prefix and number, without the caption
  • num or n displays just the number

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.

Examples

Run this code
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.")

Run the code above in your browser using DataLab