Learn R Programming

lazyWeave (version 3.0.2)

lazy.counter: Create and Manage Counters for LaTeX Documents

Description

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

Usage

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"

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.

Examples

Run this code
# NOT RUN {
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")
# }

Run the code above in your browser using DataLab