MBEATTIE@VAX.OXFORD.AC.UK (Malcolm Beattie) (03/11/91)
Apparently, there were problems with the mailing of my first query to Info-TeX leaving some people receiving only part of the message. George Greenwade tells me that some old mailers think that a single dot on a line means End-Of-Message and so my using three vertical dots for "and so on" was not such a good idea... Sorry, folks. He suggests that I resend the full text of the question, so here it is, followed by a solution posted by Donald Arseneau which I have tried, tested (it works) and summarised. My thanks to him. > I would like to be able to define things "indirectly" or >"dynamically" in TeX (in fact, AMSTeX, not LaTeX). More precisely, >I would like to be able to do something like: > >\document >\newcount\chap >\newcount\sect >\define\makemark#1{\define\label#1{\the\chap.\the\sect}} >\define\refermark#1{\label#1} >. >. >. >\makemark{fred} % Here, e.g. \chap = 6 and \sect = 7 >. >. >. >From \refermark{fred}, we see that... >\enddocument > >which would produce "...From 6.7, we see that..." >Of course, this doesn't work because the #1 in \define\label#1 >doesn't get replaced by \makemark's first parameter, but instead >gets interpreted as a new local parameter for \label itself. >Similarly, the #1 in the reference to \label#1 is treated as a parameter, >not as text to be expanded. Surely, there must be a well-known, standard >way to get the desired effect (or else it's impossible). >Any advice, please...? The solution, (commentary in Donald Arseneau's posting) is to use \newcount\chap \chap = 1 \newcount\sect \sect = 1 \def\makemark#1 {\expandafter\edef\csname label#1\endcsname{\the\chap.\the\sect}} \def\refermark#1{\csname label#1\endcsname} \document % Now, \chap and \sect are assumed to be incremented appropriately % throughout the document. At some point we use... \makemark{JonesLemma} % Later on we refer to its section or theorem number by... An application of \refermark{JonesLemma} implies that \dots \enddocument ****************************************************************************** Malcolm I.C. Beattie Mathematical Institute E-mail: MBEATTIE@VAX.OXFORD.AC.UK 24-29 St. Giles' JANET: MBEATTIE@UK.AC.OXFORD.VAX Oxford OX1 3LB Phone: (0865) 273565 U.K. Enquiries: (0865) 273525 ****************************************************************************** This really IS the end.