[Tex/LaTex] \autoref from hyperref not showing correct theorem label


I am writing some lecture notes for a course on overleaf.





%some text


Let $K\ss L$ be fields and let $\a \in L$ be algebraic over $K$. Then:
[K(\a):K]=\deg P_{min}(\a,K) \, .

%some more text

Hence, by \autoref{p:deg}, we have:

%even more text


I just recently found out about the \autoref command provided by the hyperref package. Quite pleased with it, it worked fine showing the correct label for my custom theorem environments (lemmas, prepositions, etc.).
However, I realised that at some point all the labels appeared as "Theorem" instead. I don't recall making any changes to the preamble in that short amount of time. Also, I have read this question:
How to get correct autoref for theorems
However, I didn't have \<name>autorefname in the preamble before and it worked…
I have tried to compile it on my MiKTeX and I get the same output, so this doesn't seem to be related to Overleaf.

Best Answer

The problem arises because the theorem, corollary, definition, lemma, and proposition environments all share the same counter.

The quickest solution I can think of is to (a) add the instruction


after loading the hyperref package and (b) replace all instances of \autoref with \cref.

Aside: I can't help but remark that your document suffers from a gross overuse of \left and \right to autosize the "fence symbols" (parentheses, brackets, etc.). In many cases I've looked at, omitting the \left and \right instructions would definitely be the (typographically) correct thing to do.

Related Question