summaryrefslogtreecommitdiff
path: root/Master/texmf-doc/doc/english/FAQ-en/html/FAQ-labelctr.html
blob: c629c881aa0abe009ac180ca9a25b9911f89a31d (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&rsquo;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&rsquo;s pretty clunky for an
operation that happens so often ... so there&rsquo;s a command
<code>\</code><code>stepcounter{foo}</code> that does this special case of
increasing-by-one.
<p/>There&rsquo;s an internal LaTeX variable, the &ldquo;current label&rdquo;, that
remembers the last &lsquo;labellable&rsquo; 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) &mdash; but it&rsquo;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>