I have a counter called LCount, which I want to use in some text, and i would like to be able to reference numbers that are relative to that counter. for example, I would like this LaTeX code:

For the regular languages:
&L_\theLCount = L((a|b^*)cc^*a^*(c|b^*)^*)\\\stepcounter{LCount}
&L_\theLCount = L(ac^*c(a^*|b)^*)\stepcounter{LCount}
If $L_\theLCount = L_{\theLCount-2} \cap L_{\theLCount-1}$, then:

to render like this:

enter image description here

if LCount has an initial value of 2. Is there a way of doing this? Should I be using something different other than counters? I know i can use \addtocounter a bunch of times and make the final line:

If $L_\theLCount = \addtocounter{LCount}{-2} L_\theLCount \cap \addtocounter{LCount}{1} L_\theLCount$\stepcounter{LCount}, then:    

but that seems really clumsy and inefficient. Is there a better way?


You can do something like this:

$$L_\theL = L_\nextL + L_\nextL$$
and now:
$$L_\refL{-2} = L_\refL{-1} + L_\theL$$

I.e. use temporal counter.


An option is to use the standard way of \refstepcounter:

For the regular languages:
    L_\theLCount = L((a|b^*)cc^*a^*(c|b^*)^*)
    L_\theLCount = L(ac^*c(a^*|b)^*)
If $L_\theLCount = L_{\ref{first}} \cap L_{\ref{second}}$, then:    

But beware that there will be problems (worth another question, I think) with amsmath and the counters used for equation numbering.

Output in standard article class

(BTW, post a complete MWE next time...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.