dn_counter: Counting figures and tables

dn_counterR Documentation

Counting figures and tables

Description

The counter is configurable and queryable to show what has already been done. It provides an alternative to the bookdown word_document2 format.

Creating the counter

The counter is an R6 object, that can be created with dn_counter$new(). It has the following arguments:

prefix

The text to prefix to the number. Normally one would use "Figure " or "Table " (note the spaces).

space_fill

The character to use to replace " " if using the prefix as part of a file name.

prefix2

A second prefix to add, if you need "S" for supplemental, for example.

link

"yes" or "no". Default is "no".

Using the counter

There is one function to add to the counter, dn_counter$increment("name") increases the count and adds the name to the count for recall later.

dn_counter$label_text("name") returns a text string for use in text, "Figure 1" for example.

dn_counter$label_caption("name") returns a text string to use in a caption.

dn_counter$just_count("name") returns just the count as a string, with prefix2 if it was supplied.

dn_counter$label_file("name") returns a text string for use as part of a file name, "Figure_1" as an example.

dn_counter$rename("old_name", "new_name") replaces the names on the count object so that you can refer to the correct one.

dn_counter$modify_path(oldpath, label) generates a new path filename that incorporates the figure number. This is most useful with knitr::opts_chunk$set(fig.process = my_counter$modify_path).

dn_counter displays the prefix, file replacement text, the current set of counts, and their names.


rmflight/documentNumbering documentation built on Aug. 10, 2024, 2:43 a.m.