# \label and \ref are different

When I used in theorem environment, I found that \ref{} didn't point to what I labeled. For example, I used \label{1.1.1} and \ref{1.1.1}, but it turned out to be Theorem 1.1. I don't know why? Anybody hep me? Thanks.

\documentclass{book}

\usepackage{amsmath}

\usepackage{amsthm}

\newtheoremstyle{plain}

{\topsep}   % ABOVESPACE

{\topsep}   % BELOWSPACE

{\itshape}  % BODYFONT

{0pt}       % INDENT

{5pt plus 1pt minus 1pt}

{\thmname{#1}~\thmnumber{#2}\thmnote{(#3)}}

\newtheorem{theorem}{Theorem}

\begin{document}

\chapter{}

\section{Word}

\begin{theorem}\label{1.1.1}This is good.

\end{theorem}

By theorem (\ref{1.1.1}), this word is also good.

\end{document}

-
It's best to give some contextual reference to the \label, as in \label{good-thm}, rather than \label{1.2.3}. –  Werner Sep 3 '14 at 5:56

\label and \ref have nothing to do with how theorem numbers are created and displayed. To get 1.1.1, you need to number theorems within sections. This is done by the optional argument in

\newtheorem{theorem}{Theorem}[section]  %<--- here


Code:

\documentclass{book}

\usepackage{amsmath}

\usepackage{amsthm}

\newtheoremstyle{plain}
{\topsep}   % ABOVESPACE
{\topsep}   % BELOWSPACE
{\itshape}  % BODYFONT
{0pt}       % INDENT
{5pt plus 1pt minus 1pt}
{\thmname{#1}~\thmnumber{#2}\thmnote{(#3)}}

\newtheorem{theorem}{Theorem}[section]

\begin{document}

\chapter{}

\section{Word}

\begin{theorem}\label{1.1.1}This is good.

\end{theorem}

By theorem (\ref{1.1.1}), this word is also good.

\end{document}


As an aside, it is not a good idea to use specific numbers in \label. Use some key which you can remember and the key show connection to the theorem as in this example

\begin{theorem}\label{thm:fermat}

$x^n + y^n = z^n, \qquad xyz \neq 0$............

\end{theorem}

By theorem (\ref{thm:fermat}), this word is also good.

-
Sorry. That's not where I made a mistake. I just put \ref{1.1.1}\label{1.1.1} somewhere later. I finally found it. Anyway, thank you very much. –  ksj03 Sep 3 '14 at 15:04
@ksj03 Sorry my crystal ball fell down and broke ;-) –  Harish Kumar Sep 3 '14 at 22:32