Much like the author of this question, I would like to automatically number some constants in my document. A relatively easy way to do this is by creating a new counter, assigning a label to each constant on its first use, and then referencing to it later in the document (see these answers).
However, I would like to be able to use my constants with the same command throughout the document, and number them based on first usage, so that the following examples would work:
Here are some constants $\C{first}, \C{second}$.
Later, we reference $\C{first}$.
Actually, we forgot that $\C{important}$ should come first!
Here are some constants $\C{first}, \C{second}$.
Later, we reference $\C{first}$.
Respectively resulting in:
Here are some constants $c_1, c_2$.
Later, we reference $c_1$.
Actually, we forgot that $c_1$ should come first! Here are some constants $c_2, c_3$.
Later, we reference $c_2$.
If it helps, you can assume I will be using the memoir
class.
\C
is not really a good choice for your command name, because\usepackage[unicode]{hyperref}
would break the document. – egreg Sep 24 '20 at 8:02\C
in the question for conciseness, but in my document I used\const
, which so far didn't result in any clashes. – A.P. Sep 24 '20 at 8:18