How to cross reference theorem lemma etc as for example “Theorem 1” in LyX

I have loaded the theorem by type and theorem by type within Chapter (TIP for learner:add the first in order to add the second).

So I use theorem environment for different types: proposition, corollary, lemma etc.

I cannot find solution how to cross reference them in the format of "Proposition 1.1". The manual does not help either. Please provide a learner-friendly step-by-step guide! (For example, do I need to load anything to the default LyX first? Which LaTeX code has to be pasted etc? )

Urgent help needed as my thesis deadline is one week later!

The following shows why I got stuck:

1: Under corollary environment, I click right after the Corollary 1.1 and insert a label, LyX automatically shows "Under-the-same" in lable context, so I changed it into Corollary 1.3

2: I insert cross reference in the text as "formatted reference".

3: The cross reference result in PDF does not include "Corollary" caption, only 1.3:

Update: I just found that this normal under auto cross-references which is used by Classicthesis template, according to its explanation:

So I just want to know how to input the reference label manually so that it shows "Proposition 1.1" in color in PDF? Or the ultimate solution by changing LaTeX code in the config file it it is not too complex?

UPDATE for learners

I just realized that I can change the style of crossreference in document->setting->pdf properties-> tick "customize hyperref options"->hyperlinks. You can delete the red frame or make them in color or without color!

• Did you try creating a label (insert > label) in the proposition and then where you want to reference, go to insert > cross-reference? – scottkosty Mar 23 '16 at 16:24
• Thx a lot. I got really confused about how to creat a proper label in the Theorem environment, such as where to creat, and how to creat. So step-by-step guide is much appreciated. – Wendy Mar 24 '16 at 0:47
• I see. Why do you mark all of your questions with "Urgent!"? If this really is urgent, you should probably just type in manually "Proposition \ref{yourlabel}". Better solutions will take more time. – scottkosty Mar 24 '16 at 1:29
• My thesis deadline is one week later. Since I want to print it in color (many color figures), this problem is visible to examiners. I am willing to spend several hours to fix it if necessary as long as there exists a solution that I can follow. Thx again. Not sure why I have this simple problem in LyX. – Wendy Mar 24 '16 at 1:44
• Update: I just found that this normal under auto cross-references which is used by Classicthesis template. I have updated my question by including the explanation from the template. So I just want to know how to input the reference label manually so that it shows "Proposition 1.1" in color? Or the ultimate solution by changing LaTeX code in the config file it it is not too complex? – Wendy Mar 24 '16 at 2:29

You need to Insert>Label within your theorem or corollary. Let's say the label is cor:myprecious. It might be that autorefname hasn't been defined for these environments, so you'll have to add

\providecommand{\thmautorefname}{Theorem}
\providecommand{\corautorefname}{Corollary}
\providecommand{\lemautorefname}{Lemma}


either to classicthesis-config.tex (say, around line 230) or your Document>Settings>Preamble You will then insert an autoreference either in a TeX box (ctrl-L) \autoref{cor:myprecious} or by using a custom inset as described in the manual (screenshot above)

• It works! Thx. But what are the commands for Proposition, Figure, Table, Assumption, Example? – Wendy Mar 24 '16 at 4:33
• I knew this was coming :) Check the name of the environment in View>Source. If it's prop, you need to define \propautorefname; if it's example, you'll define \exampleautorefname. Figure and Table should already be defined. – PhilipPirrip Mar 24 '16 at 4:41

Based on the expert's solution (including the latest comments below this answer), I get the perfect outcome:

1: I copy the LaTeX code provided by the expert into Document->Setting->LaTeX preamble

2: Creat a label with a name without space but with the relevant code for auto sorting, e.g."cor:1.1"

3: Insert Ctrl L, get a red square to input the \autoref{cor:1.1}

4: Result

• It's probably better not to have spaces in your labels, and also to make them descriptive rather than having them numbered (what if you insert a corollary between the two that have been named like this?) – PhilipPirrip Mar 24 '16 at 4:49
• Sorry I don't quite get "what if you insert a corollary between the two that have been named like this?". I have many proposition and lemma, eample etc. I can follow your suggestion by using, for example, "Proposition1.1" as a label name, but if I also exclude number, I will easily get lost. How to deal with this issue then? – Wendy Mar 24 '16 at 4:56
• You're creating manually numbered labels, Proposition_1.1 for the first proposition, then Proposition_1.2 for the second etc. Then you decide to add a new proposition between the first two. Now Proposition_1.2 becomes 1.3 and you have to relabel all consecutive propositions. That's why I said it's better to have labels like prop:the-largest-integer, cor:sqrt-two-irrational. – PhilipPirrip Mar 24 '16 at 5:03
• These are just labels, they can be anything. It helps to start them with environmentname: (thm: or cor: or eq:) because they will be sorted in LyX (under Navigate, or Insert>Cross reference) and easier to find. This is actually how LyX starts them by default, when you're using Insert>Label. – PhilipPirrip Mar 24 '16 at 5:17
• I just figured out that they were just label names, not fancy codes, before you posted the latest comment. I will try later and see if there are any new issues. Thx again! – Wendy Mar 24 '16 at 5:19