How to get just a number of a theorem instead of "Theorem 1.2"

Hi, I am looking for a possibility to refer to math environments like #theorem, #lemma etc. just by their numbers.
In packages like “great-theorems” one can write

#theorem[This is my first theorem.] <th1>
#theorem[This is my second theorem.] <th2>
#theorem[This is the last theorem.] <th3>

Then @th1 will print something like Theorem 1.2.
However, if I want to mention several them at once:

From @th1, @th2 and @th3 we get that ...

then I get

From Theorem 1.2, Theorem 1.3 and Theorem 1.4 we get that ...

I am looking for the possibilty to escape repeating the word “Theorem”, and to get the output like

From Theorems 1.2, 1.3 and 1.4 we get that ...

Thus I need to be able to get only the number of the theorem via the code like:

From Theorems #thnum(<th1>), #thnum(<th2>) and #thnum(<th3>) we get that ...

I will be very grateful for any ideas in this direction.

Hi! The easiest solution, I feel like, would be a text show rule:

#import "@preview/great-theorems:0.1.2": *
#import "@preview/rich-counters:0.2.1": *

#let mathcounter = rich-counter(identifier: "mathblocks", inherited_levels: 1)
#let theorem = mathblock(blocktitle: "Theorem", counter: mathcounter)

#theorem[This is my first theorem.] <th1>
#theorem[This is my second theorem.] <th2>
#theorem[This is the last theorem.] <th3>

#let thnum(label) = {
  show "Theorem" + sym.space.nobreak: none
  ref(label)
}

From @th1, @th2 and @th3 we get that ...

From Theorems #thnum(<th1>), #thnum(<th2>) and #thnum(<th3>) we get that ...

1 Like

Thank you very much for the help and the example! It works perfectly!

1 Like

Thanks Andrew for making a minimal example for the question.

Here’s an alternative that is kind of quick and neat - and it was actually mentioned by PgSuper on the discord today (I wouldn’t have come up with it it).

It uses customization of the supplement to remove the supplement:

From @th1[Theorems], @th2[] and @th3[] we get that ...

image

Which is a useful little trick that’s worth knowing anyway.

4 Likes

To add on this: It is possible to do quite some tricks using the supplement if you write your own show ref: it => {...} rule, as you can branch on what supplement gets passed.

For an example, my package theoretic (shameless plug) uses this to provide many different reference formats easily:
image

3 Likes