# \label and \ref are different [closed]

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}
-

## closed as off-topic by Mico, Gonzalo Medina, Svend Tveskæg, Adam Liter, Paul GaboritJun 30 at 5:55

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

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
I'm voting to close this question as off-topic because it's an about an error that (a) is not related to the material in the posting and (b) was resolved using methods not explained in the comments. –  Mico Jun 30 at 4:43

\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