[texhax] Help on cross-references

Philip G. Ratcliffe philip.ratcliffe at fastwebnet.it
Sat Mar 14 21:54:21 CET 2009

> What Christian wants (I believe) is for Equations to be 
> labeled as (1), (2), ..., and within the same section in 
> which they are first displayed, they would be referred to as 
> Equation (1), etc. When referring to Equations in a different 
> section, but in the same chapter, it would display Equation 
> (1.2) for the second equation in the first section. When 
> referring to equations in a different chapter, it would 
> display Equation (1.2.3) for the third equation in the second 
> section of the first chapter.

That's what I understood too.

> Although I'm out of my league here, I envision a solution 
> wherein you redefine the \theequation command, and use the 
> ifthen package to exame the \section and \chapter of the 
> current location, compare with the location of the equation, 
> and display different results accordingly. Something like:

Unfortunately, \theequation is what is printed inside the relevant display
math environment and what is used to store the number, but the \ref command
know nothing about it.

> \def\theequation {%
> \ifthenelse{ \equal{\chapter}{\Eq_chapter} }% If same chapter
>    {\ifthenelse{ \equal{\section}{\Eq_section} }% and same section
>       {\equation}% print just the number.
>       {\Eq_section.\equation}% If different section, print 
> section number as well
>    }% If different chapter, print the chapter and section numbers
>    {\Eq_chapter.\Eq_section.\equation} }

The logic is about right but applied to the wrong object.

> Hopefully I closed all my brackets. The only thing that 
> you're missing now is how to figure out in what 
> chapter/section an equation begins (I made up the commands 
> \Eq_chapter and \Eq_section). Hopefully someone else can post 
> that information.

Well, it would be nice, if it worked like that ... but ...

Here is an example of how the \label command puts the info away in the aux


That is, 5.1.10 is the equation number labelled "eq:mellin" and 55 is the
page on which it appeared.

So, what is really needed is a macro that parses the number retreived and
chops the unnecessary bits off.

Good luck!


More information about the texhax mailing list