[Tex/LaTex] \ref does not work

cross-referencing

I want to write a paper. There are three Chapters. In the first chapter, I got a Corollary and I labeled it as following:

Corollary 1 \label{cor:1}

In the second chapter, I want to cite the "Corollary 1", I input

Corollary  \ref {cor:1}.

After running pdflatex, it shows the following:

Corollary ??.

without the number "1"

How do I tackle this problem?

Best Answer

This is a MWE on using the \label inside a corollary environment, defined thanks to the amsthm package. Apparently, from the question no environment is used to define the corollary, thus explaining the undesired output of the \ref command.

\documentclass{article}
\usepackage{amsthm}
\newtheorem{corollary}{Corollary}
\begin{document}
\begin{corollary}
    This is a corollary
    \label{the-corollary}
\end{corollary}
Let's make a reference to corollary~\ref{the-corollary}.
\end{document}

enter image description here

Related Question