tags:

views:

40

answers:

2

I have several lemmas in which I specify constants $C_1$, $C_2$, and so forth for later reference. Naturally, this is annoying when I later insert a new constant definition in the middle. What I'd like is a macro that lets me assign labels to constants and handles the numbering for me. I'm thinking something along the lines of

%% Pseudocode
\begin{lemma}
    \newconstant{important-bound}
    We will show that $f(x) \le \ref{important-bound} g(x)$ for all $x$.
\end{lemma}

Is this possible?

A: 

What you're looking for is to create your own counter.

rcollyer
+2  A: 

Expanding on rcollyer's suggestions of using a counter:

%counter of current constant number:    
  \newcounter{constant} 
%defines a new constant, but does not typeset anything:
  \newcommand{\newconstant}[1]{\refstepcounter{constant}\label{#1}} 
%typesets named constant:
  \newcommand{\useconstant}[1]{C_\ref{#1}}

And here is a code snippet that seems to work:

I want to define two constants:\newconstant{A}\newconstant{B}$\useconstant{A}$ and
$\useconstant{B}$. Then I want to use $\useconstant{A}$ again.
Aniko
Very nice. I thought about something like this, but wasn't sure if labels would work as intended. Definitely +1.
finrod
Thanks Aniko, this is what I was looking for.
Joshua