Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!jarthur!cbrown.claremont.edu!dhosek From: dhosek@cbrown.claremont.edu (Don Hosek) Newsgroups: comp.text.tex Subject: Re: Labels that store the kind of object being labeled Message-ID: <1991Mar20.133639.1@cbrown.claremont.edu> Date: 20 Mar 91 21:36:39 GMT References: <63335@bbn.BBN.COM> Sender: news@jarthur.Claremont.EDU Followup-To: comp.text.tex Organization: Quixote Lines: 76 In article <63335@bbn.BBN.COM>, hersh@bbn.com (Hershel Safer) writes: > Rather than write > Theorem~\ref{foo} > all the time, I use > \newcommand{\thmref}[1]{Theorem~\ref{#1}} . > Actually, it's fancier; since I may want the same label for a theorem, > an associated figure, and the section in which they are found, I have > \newcommand{\thmref}[1]{Theorem~\ref{th:#1}} , > \newcommand{\secref}[1]{Section~\ref{s:#1}} , > and a variety of other referencing commands with different prefixes. I > also have corresponding labeling commands, such as > \newcommand{\thmlabel}[1]{\label{th:#1}} and > \newcommand{\seclabel}[1]{\label{s:#1}} . > Here's the problem. Suppose that I change a theorem to a proposition. > Changing \thmlabel to \proplabel is easy enough, but then I also have to > change all references to the claim from \thmref to \propref. > What I would like is a single labeling command and a single referencing > command. The labeling command would take two arguments; the first would > be the _kind_ of item and the second would be the label. It would store > the kind of item. > The referencing command would take a single argument, the label. It > would use the stored item information to prepend the correct word to the > reference number. > Any references to existing solutions or suggestions for how to do this? > Either TeX or LaTeX would be fine. Thank you. LaTeX has a command \p@ITEM which is normally null to refer to each counter. Defining, e.g., \p@section to be Section~ will cause those words to be prepended to any reference to a section reference. This works for nearly everything (the one exception I have envountered is eqalign does not prepend \p@equation to the equation number in labels generated there). This use of \p@WHICHEVER, however, is not recommended since it does limit the portability of your documents across styles. Its intended purpose is to allow things like sections numbered as: I A 1 a and referred to as I.A I.A I.A.1 I.A.1(a) (this is, in fact, what happens in the enumerate environment). More sophisticated things are possible as well (for example, I've written a p@section which would give "A" if the section is in the current chapter and "A in Chapter 2" if the section is in a different chapter. In general, sophisticated uses of \p@WHATEVER, however, will become rather complicated. Macro expansion timings can get really unpleasant. -dh --- Don Hosek To retrieve files from ymir via the | dhosek@ymir.claremont.edu mailserver, send a message to | Quixote TeX Consulting mailserv@ymir.claremont.edu with a | 714-625-0147 line saying send [DIRECTORY]FILENAME where DIRECTORY is the FTP directory (sans "anonymous") and FILENAME is the filename, e.g. "send [tex]00readme.txt". There is a list of files in each directory under the name 00files.txt Binary files are not available by this technique.