captioner: Captioner function

Description Usage Arguments Details Value Examples

View source: R/captioner.R

Description

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

Usage

1
2
3
captioner(prefix = "Figure", suffix = ":", auto_space = TRUE,
  style = NULL, style_prefix = FALSE, levels = 1, type = NULL,
  infix = ".", before = FALSE, knitr_op = NULL, css_class = NULL)

Arguments

prefix

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

suffix

Character string containing text to go after object number and before caption. The default is ": ".

auto_space

Logical indicating whether a single space should automatically be added after the prefix and suffx. Default is TRUE.

style

Optional character string indicating md style to use. Possible options: bold b, italic i, or bold+italic bi.

style_prefix

Logical specifying whether the style should be applied to the prefix only (TRUE) or the entire caption. The default is FALSE.

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 .

before

Logical indicating whether to display the caption before or after the figure. Applies only to automatic caption display (e.g. with a hook).

knitr_op

A named list containing any other chunk options desired.

css_class

Assign a css class to the caption. Places the caption into a span html element with a class.

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
8
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.")
  

adletaw/captioner documentation built on Feb. 21, 2020, 10:14 p.m.