[texhax] in-section references

tom sgouros tomfool at as220.org
Sat Jan 27 22:46:11 CET 2007

Hi Martin:

I'm afraid you will be in for some editing of references.  I make my
references look like \sectionref{subsub2} in order to deal with
situations comparable to this.  For example, I have a section that
appears in book A and booklet B.  In book A, the \sectionref{subsub2}
resolves to "Section 2.1.2" and when the same string appears in booklet
B, you get "Book A".  This way the text can read "see
\sectionref{subsub2}" and the english works with both situations.  But
you need to get the variable parts of the language inside the
\sectionref macro, which is why I think you'll need to edit.  Otherwise
you're going to have to write a macro that can erase a few words behind
it which sounds pretty hairy.

What I think you need to do is the same thing, but using a comparison
between \thesection and \ref{#1} instead of \@ifundefined.  (You'll
probably want a logical OR of three or four comparisons, between
\ref{#1}, \thechapter, \thesection and \thesubsection or
\thesubsubsection, really.)  Something like the following almost does
what you want, and perhaps you can make the conditional more elaborate
to get it exact:

                         \ifx\testa\testb #2\else #3\fi}
\newcommand{\sectionref}[1]{\testref{#1}{This section}%

Hope this helps.


p.s. Judy says hi.

 tomfool at as220 dot org

More information about the texhax mailing list