## 2.1.3 Counters

It is possible to set the initial value of a counter from the command-line using the --counter option or the “counters” section in a configuration file. The configuration file format for setting counters is very simple. The option name in the configuration file corresponds to the counter name, and the value is the value to set the counter to.

    [counters]
    chapter=4
    part=2

The sample configuration above sets the chapter counter to 4, and the part counter to 2.

The --counter can also set counters. It accepts multiple arguments which must be surrounded by square brackets ([ ]). Each counter set in the --counter option requires two values: the name of the counter and the value to set the counter to. An example of --counter is shown below.

    plastex --counter part 2 --counter chapter 4 file.tex

Just as in the configuration example, this command-line sets the part counter to 2, and the chapter counter to 4.

Note that our notion of “setting” a counter to ‘n‘ is equivalent to the LaTeX command `\setcounter{counter}{n - 1}`. This is so that, for example, in the above configuration, when we first encounter `\section{Foo}`, we get Section 2 instead of Section 3 (since `\section` first increments the counter then uses the counter value).

Set initial counter values

  Command-Line Options: --counter=counter-name initial-value
  specifies the initial counter values.