blob: 903ad03de7cc6e641364856e92ecf7abf5349246 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<head>
<title>UK TeX FAQ -- question label labelctr</title>
</head><body>
<h3>Making labels from a counter</h3>
<p>Suppose we have a LaTeX counter, which we've defined with
<code>\</code><code>newcounter{foo}</code>. We can increment the value of the counter
by <code>\</code><code>addtocounter{foo}{1}</code>, but that's pretty clunky for an
operation that happens so often ... so there's a command
<code>\</code><code>stepcounter{foo}</code> that does this special case of
increasing-by-one.
<p>There's an internal LaTeX variable, the "current label", that
remembers the last 'labellable' thing that LaTeX has processed.
You could (if you were to insist) set that value by the relevant
TeX command (having taken the necessary precautions to ensure that
the internal command worked) - but it's not necessary. If, instead
of either of the stepping methods above, you say
<code>\</code><code>refstepcounter{foo}</code>, the internal variable is set to the
new value, and (until something else comes along), <code>\</code><code>label</code> will
refer to the counter.
<p><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=labelctr">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=labelctr</a>
</body>
|