[texhax] setting counters to output of a \ref command

Uwe Lück uwe.lueck at web.de
Mon Feb 12 01:49:19 CET 2007


At 17:52 08.02.07, David Romano wrote:
>I'd like to have a particular theorem appear twice in a paper,
>and I'd like its appearance to be identical in both,
>the numbering in particular, without having to set the
>section and theorem counters by hand.
>
>Is there a way of getting a hold of the numbers generated by the \ref
>command so I can use them to set the relevant counters and duplicate the
>appearance of the theorem?  I've tried several sources of LaTeX
>documentation and just can't seem to find a way to do this; the only
>related piece of information I found was that one can "transport" the
>current value of a counter with \value{counter}, but here I'm interested
>in transporting a value that is not current.

For a "general" part of your question, I guess that Heiko Oberdiek's
refcount package from

     CTAN:/macros/latex/contrib/oberdiek/

is what you are looking for.

Considering merely the single problem that you (David Romano)
posted, however, I guess that my previous advice would be
"shooting cannon balls at sparrows", "as (about) we Germans say"
(i.e., the effort is very much more than what actually is needed).
My suggestion:

  1. Put some \label{thm:glorious} into the first environment
     that generates your "glorious" theorem.

  2. For repeating your "glorious" theorem, just type
     (and change what doesn't fit your design):

       \begin{trivlist}
         \item[\bfseries Theorem \ref{thm:glorious}]
         \slshape %% ... or \itshape ...
         <Repeat text body of your "glorious" theorem>
       \end{trivlist}

[-- This finishes the kernel of my suggestion;
the following remarks rather address "TeX philosophers".]

I find the present query interesting because I myself
like a style used in (philosophical/...) theory of
measurement where the most interesting results
are stated in a first part of a section;
while proofs follow in a kind of appendix (of the section).
With this idea however, I hadn't just /repeated/
such theorems. Rather, I introduced some technical terms
and used them for restating the main results in a hopefully
more transparent wording.

HTH -- Uwe.

At 23:19 08.02.07, Philip G. Ratcliffe wrote:
>The following is adapted from a suggestion in the FAQ for lists, it should
>be possible to do something similar for theorems.
>
>\documentclass{article}
>\begin{document}
>\noindent Here's a list:
>\begin{enumerate}
>   \item A
>   \item B
>   \newcounter{it:last-scalar-rule}%
>   \setcounter{it:last-scalar-rule}{\value{enumi}}%
>   \item C
>\end{enumerate}
>And here's a repetition:
>\begin{enumerate}
>   \setcounter{enumi}{\value{it:last-scalar-rule}}
>   \addtocounter{enumi}{-1}
>   \item B
>\end{enumerate}
>\end{document}

... sorry, LaTeX counters are used too carelessly anyway.
(I am thinking of similar discussions concerning LaTeX3
or that package allocating registers locally.)




More information about the texhax mailing list