In my LaTeX document I've defined several environments for various types of entities: theorem, lemma, corollary, definition, notation, and example.
And in the text when I reference one of them I have to add a descriptive word such as the following.
As we see in Lemma~\ref{lemma.100} and Theorem~\ref{theorem.105}, any such set is finite.
The problem is that from time to time, I change my mind about whether a certain entity should be a lemma or a theorem or a corollary etc. I can easily change the definition site from \begin{lemma}...\end{lemma} to \begin{theorem}...\end{theorem}, but then I need to change all the use-sites as well.
Is there a better way? Can I somehow define my lemma, theorem etc environments so that I can use a reference such as \envref{ent.100} and that will expand to Lemma~\ref{ent.100} if ent.100 is a lemma, but expand to Theorem~\ref{ent.100} if ent.100 is a theorem?
The same problem exists for tables and figures, but somewhat less often.
I'm not sure if it is important, but here is how I'm defining my environments currently.
\documentclass[a4paper]{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{framed}
\theoremstyle{plain}% default
\newtheorem{prototheorem}{Theorem}[section]
\colorlet{shadecolor}{orange!15}
\newenvironment{theorem}
{\begin{shaded}\begin{prototheorem}}
{\end{prototheorem}\end{shaded}}
\newtheorem{protolemma}[prototheorem]{Lemma}
\newenvironment{lemma}
{\begin{shaded}\begin{protolemma}}
{\end{protolemma}\end{shaded}}
\newtheorem{protocorollary}[prototheorem]{Corollary}
\newenvironment{corollary}
{\begin{shaded}\begin{protocorollary}}
{\end{protocorollary}\end{shaded}}
\theoremstyle{definition}
\newtheorem{protonotation}{Notation}[section]
\newenvironment{notation}
{\begin{shaded}\begin{protonotation}}
{\end{protonotation}\end{shaded}}
\newtheorem{protoexample}{Example}[section]
\newenvironment{example}
{\begin{shaded}\begin{protoexample}}
{\end{protoexample}\end{shaded}}
\newtheorem{protodefinition}{Definition}[section]
\newenvironment{definition}
{\begin{shaded}\begin{protodefinition}}
{\end{protodefinition}\end{shaded}}
\begin{document}
\section{Introduction}
\begin{lemma}
\label{ent.201}
If $V$ is a set of subsets of $U$, and $\exists X_0 \in V$ such that
$X \in V$ implies $X_0 \subseteq X$, then $X_0 = \bigcap V$.
\end{lemma}
Intuitively, Lemma~\ref{ent.201} says that given a set of subsets,
if one of those subsets happens to be a subset of all the given
subsets, then it is in fact the intersection of
all the subsets.
\begin{theorem}
\label{ent.188} %% used
If $V \subseteq U$, and if $F$ is a set of binary functions defined on
$U$, then there exists a unique $clos_F(V)$, and it is closed under $F$.
\end{theorem}
We can see from Lemma~\ref{ent.201} and also from
Theorem~\ref{ent.188} such sets are always finite.
2
\end{document}
cleverefpackage is done for that. It defines a\crefand a\Crefcommands and manages ranges of references. Note it must be loaded afterhyperref. – Bernard May 07 '18 at 08:51\autoreffrom\hyperref. See, for example, https://tex.stackexchange.com/questions/46258/how-to-get-correct-autoref-for-theorems/113540#113540. The advantage of\autorefis that the arxiv accepts it. – May 07 '18 at 09:41