captioner v2.2.3


Monthly downloads



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")
#> [1] "Figure  1: 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

Functions in captioner

Name Description
captioner-package captioner: A package for numbering figures and generating captions
check_class Check the class of an input parameter
bump Captioner bump function
captioner Captioner function
increment Increment function, for incrementing a hierarchical number
No Results!

Vignettes of captioner

No Results!

Last month downloads


Type Package
Date 2015-07-15
License MIT + file LICENSE
VignetteBuilder knitr
NeedsCompilation no
Packaged 2015-07-15 18:43:40 UTC; a
Repository CRAN
Date/Publication 2015-07-16 00:46:21
suggests knitr
Contributors Letaw Alathea

Include our badge in your README