In this post Custom theorem numbering there is an explanation by egreg that shows how to implement this. Now I would like to be able to reference so that I would not have to type lemma/proposition etc. right before \ref{}
when referring to a particular \label{}
because by using \ref{}
it only gives the numbering. However, using the cref{}
from the cleveref package only gives question marks on the page after compilation (which I'm not surprised about since it's a package independent of the code given by egreg). How does one solve this problem?
\documentclass[11pt]{article}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
%\usepackage{xparse}
\usepackage{mathtools}
\usepackage{ulem}
\usepackage{enumerate}
\usepackage{xcolor}
\usepackage[shortlabels]{enumitem}
\usepackage{cleveref}
%===========================================================%
%The code below customises theorem numbering
%===========================================================%
\newtheorem{innercustomgeneric}{\customgenericname}
\providecommand{\customgenericname}{}
\newcommand{\newcustomtheorem}[2]{%
\newenvironment{#1}[1]
{%
\renewcommand\customgenericname{#2}%
\renewcommand\theinnercustomgeneric{##1}%
\innercustomgeneric
}
{\endinnercustomgeneric}
}
\newcustomtheorem{customdefinition}{Definition}
\newcustomtheorem{customlemma}{Lemma}
\newcustomtheorem{customproposition}{Proposition}
%===========================================================%
\begin{document}
\begin{customproposition}{5.2} \label{hello}
blah blah
\end{customproposition}
I want to Proposition \ref{hello} without
having to type proposition
at the beginning of \ref{hello}.
\end{document}
Is there an efficient and clean way to do this? Either via cleveref or other alternatives by writing a particular code to reference \label{}
without having to write "Proposition" in front of the reference?
Best Answer
Add the
cleveref
type and alias the counter.