Numbers Figures and Creates Simple Captions

Provides a method for automatically numbering figures, tables, or other objects. Captions can be displayed in full, or as citations. This is especially useful for adding figures and tables to R markdown documents without having to numbering them manually.

Build Status

captioner is an R package for generating figure numbers and captions


to install:

  • install.packages("devtools")
  • devtools::install_github("adletaw/captioner")

or if you want the vignette:

  • devtools::install_github("adletaw/captioner", build_vignettes = TRUE)
  • vignette("using_captioner")


captioner() returns a captioner function for each set of figures, tables, etc. that you want to create. See the help files and vignette for more details.

For example, you can generate a full caption:

fig_nums <- captioner()
fig_nums("my_pretty_figure", "my pretty figure's caption")

Or a figure number for citing:

fig_nums("my_pretty_figure", display = "cite")
#> [1] "Figure  1"

Or you can store the caption and use it in your R code chunk in markdown documents:

my_first_caption <- fig_nums("my pretty_figure", "My pretty figure's caption.")

If you create a new set of captions, perhaps for your tables, the numbering restarts:

table_nums <- captioner(prefix = "Table")
table_nums("cat_table", "A table of cat breeds.")
#> [1] "Table  1: A table of cat breeds."

You can abbreviate in text citations by using partial1 from the package pryr to create a shorter version of the function. For example:

citef <- pryr::partial(fig_nums, display = "cite")
#> [1] "Figure  1"

Take a look at the vignette for many more details.

  1. I learned this from the glorious H Wickham and you can too


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


2.2.3 by Letaw Alathea, 4 years ago

Report a bug at

Browse source code at

Authors: Letaw Alathea [aut, cre]

Documentation:   PDF Manual  

MIT + file LICENSE license

Suggests knitr

Suggested by dynamichazard, ref.ICAR, wCorr.

See at CRAN