I have looked up many solutions to the problem of referencing a theorem, corollary, lemma, etc. in terms of their name. What I mean is that if the label of a theorem 1 is \label{T:theoremOne}, then when using the command \ref{T:theoremOne}, we get the name and the number of the theorem, that is Theorem 1.
I get the idea of how to get this result when the environments do not depend on a single counter, however I am stuck with a problem in the name when I use a single counter for all my theorems, corollaries, lemmas, propositions, definitions and all (I know, this seems to be silly, but it is a requirement for the final draft of my PhD thesis!). Here is a workable example to illustrate my problem.
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\newtheorem{theorem}{Theorem}
\labelformat{theorem}{Theorem~#1}
\newtheorem{corollary}[theorem]{Corollary}
\labelformat{corollary}{Corollary~#1}
\usepackage{graphicx}
\usepackage{lmodern}
\author{Pierre-Olivier Parisé}
\begin{document}
A working example.
\begin{theorem}\label{T:theoremOne}
Here's a first theorem.
\end{theorem}
So, when we refer to \ref{T:theoremOne}, we get the following corollary.
\begin{corollary}\label{C:corollaryOne}
Here's a corollary of the first Theorem.
\end{corollary}
So now, we see that \ref{C:corollaryOne} is not named correctly...
\end{document}
If you try it, you will get the following output. As you can see, the corollary is printed as Theorem 2 instead of Corollary 2. I think that I know where's the problem. The corollary environment use the same counter as the theorem environment. So, when it prints the name of the counter, it takes the theorem counter's name instead of the corollary counter's name (there are the same in fact, as I understand). I also try to use an external counter for all the environments, but it didn't work as expected (it only prints the number since the counter has no name... and also I would have to select the good name of the environment to print it correctly, which is not obvious for me how to implement this).
Does anybody would have a solution to this problem? Please, if I missed any post on this issue, please refer me to it. I would really appreciate help for this issue. Thank you!
amssymb
loadsamsfonts
, so it's not necessary to load both. No harm done, but nothing gained.