[Tex/LaTex] How to find out the counter of theorems etc. in LyX

cross-referencinglinkslyxtheorems

I have a document that has a lot of theorems – all introduced in LyX via the "Theorems"-Module (for those who don't know LyX, that means, that I didn't define my own theorem environment via \newtheorem…, LyX did!).

Now I want do to reference to some of my theorems.

As far as I know, this is done by giving the theorem I want to reference a label and then using \hyperref[LABEL]{TEXT}, where "TEXT" is then the colored link to the theorem (somehow \ref isn't working in LyX, if anyone is wondering why hyperref).

And now my question comes in: I need a command that somehow returns the number of the theorem (all my theorem are numbered continuously with one number through the whole text) that has the label "LABEL" – like \findnumber{LABEL} – so that I can use \hyperref[LABEL]{\findnumber{LABEL}}.

Thus, if I add another theorem the number that is the link to that theorem also changes. I don't know if this solution is the "correct" one. If it isn't, please let me know.

Best Answer

To add cross references to a theorem, first add a label right after the theorem "title" (e.g. Theorem 1) with Insert --> Label or the image of label button on LyX toolbar button on the toolbar. This places, well, a label at that point which you can refer to at other places in the document. The label refers to the last "active" counter, so when you place it right at the beginning of the theorem, you know you get the right one.

A cross reference is added via Insert --> Cross reference or the image of cross reference button on LyX toolbar button on the toolbar (right next to the insert label-button). You will get a list of all the labels in the document, and a choice of what kind of reference you would like. For example, <reference> prints just the number.

To change the type of reference just right click the reference and choose from the menu that pops up.

\hyperref

One use of this command is to have a clickable link that consists of more that just the number. hyperref provides a starred \ref command that prints the relevant number without turning it into a clickable link. For example:

\hyperref[thm:ATheorem]{Theorem \ref*{thm:ATheorem}}

Summary of sorts

In the screenshot below I've tried to "sum up" some of this (click it to see larger). To point out the obvious, LyX on the left, PDF output on the right.

enter image description here