# Defining a new example environment and giving reference it

How to give cross-reference to all words, Example 1, as follows?

I defined a new environment as follows:

\newtheorem{exmp}{Example}

When I give a \label{Example} to the example and write \ref{Example}, I get:

\documentclass[final,5p,times,twocolumn]{elsarticle}
\usepackage{hyperref}

\hypersetup{
urlcolor=blue,
citecolor=blue}
\usepackage[all]{xy,xypic}
\usepackage{amsfonts,amssymb,amsmath,amsgen,amsopn,amsbsy,theorem,graphicx,epsfig}
\usepackage{multicol}
\usepackage{eufrak,amscd,bezier,latexsym,mathrsfs,enumerate,multirow}
\usepackage[utf8]{inputenc}\usepackage[english]{babel}
\usepackage[dvipsnames]{xcolor}
\usepackage[pagewise]{lineno}
\usepackage{cleveref}
\graphicspath{{figures/}}
\usepackage{subfig}
\usepackage{longtable}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}% http://ctan.org/pkg/algorithm2e
\DontPrintSemicolon
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%

\usepackage{amsthm}
\theoremstyle{definition}
\theoremstyle{remark}
\newtheorem{exmp}{Example}
\newtheorem{rem}{Remark}
\let\proof\relax
\let\endproof\relax
\let\example\relax
\let\endexample\relax
%%%%%%%%%%%

\begin{document}
\begin{exmp} \label{Ex1}
Let's consider:
$$2x+y=3$$
\end{exmp}

\begin{table*}[h!]
\caption{Results in \cref{EX1}

.....
\end{document}


• You should take a look at the cleveref package (to be loaded after hyperref).. Mar 9, 2021 at 20:48
• In fact, I usually cleveref and \cref. But it doesn't work in here. Mar 9, 2021 at 21:25
• Could you post a minimal, yet complete, code that we can text to see what happens? Mar 9, 2021 at 21:27
• Thank you. I edited the OP. Mar 9, 2021 at 21:35
• I'm sorry, but I can't compile your code. I don't have some packages installed (unrelated to the problem such as subfig, which is obsolete), vut more important there seems to be conflicts between packages. Could you post a code with only the relevant packages? Mar 9, 2021 at 22:23