lazy.counter: Create and Manage Counters for LaTeX Documents

Description Usage Arguments Details Author(s) Examples

Description

Provides the code to create, manipulate, or extract values of counters in a LaTeX or HTML document

Usage

1
2
lazy.counter(counter, value, oldcounter, fn = c("new", "addto", "set", "use",
  "value"))

Arguments

counter

A character(1) giving the name of the counter to be created and/or manipulated

value

An integer. For fn="addto", it is the value by which the counter is to be increased. For fn="set", it is the value to which the counter should be set

oldcounter

character(1). An optional argument for fn="new". It must be a previously named counter. If present, the new counter will be reset whenever oldcounter is incremented

fn

Selects the LaTeX function to be used

Details

Counters are used to provide table, figure, and section numbers. After each use of each command, the counter is incremented so that it can be referred to in later uses. New counters may be defined by users, but several LaTeX environments have default counters that do not need to be defined. These are part, chapter, section, subsection, subsubsection, paragraph, subparagraph, page, equation, figure, table, footnote, mpfootnote. Any of these may be manipulated by lazyWeave.

Referring to and manipulating counters is done using lazy.counter. Different actions are achieved by changing the fn argument.

fn="new" creates a new counter with name counter.

fn="addto" adds value to the current value of counter.

fn="set" changes the current value of counter to value.

fn="use" designates counter for use in the current environment.

fn="value" returns the value of counter. This value isn't printed, but can be useful for doing arithmetic with counter values.

The HTML counters in counter are the defaults and will reference global counters

options("html.counter.table")
options("html.counter.table"
options("html.counter.table"
options("html.counter.table"
options("html.counter.table"
options("html.counter.table"
options("html.counter.table"

Additional and custom counters may be defined if desired, in which case a new option will be defined as options("html.custom.[countername]").

Extracting a current value does not increment the counter–this must be done manually (and is done manually when used in lazy.table, lazy.figure,\ lazy.footnote, and lazy.section.

Author(s)

Benjamin Nutter

Examples

1
2
3
4
5
6
7
lazy.counter("myCounter")
lazy.counter("myCounter", value=3, fn="set")
lazy.counter("myCounter", value=2, fn="addto")
lazy.counter("myCounter", fn="use")
lazy.counter("myCounter", fn="value")

lazy.counter("table", fn="use")

Example output

The functions 'addto' and 'use' are not defined for HTML format.  No action is taken.
The functions 'addto' and 'use' are not defined for HTML format.  No action is taken.
[1] 3
The functions 'addto' and 'use' are not defined for HTML format.  No action is taken.

lazyWeave documentation built on May 2, 2019, 12:35 p.m.