# Reference in theorem environment without label

I have

\documentclass[10pt,a4paper,onecolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage{fancyhdr}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\newcommand*{\qeda}{\hfill\ensuremath{\square}}
\newtheorem{theorem}{Teorema}[section]
\newtheorem{cor}{Corolario}[theorem]
\newtheorem{lem}[theorem]{Lema}
\newtheorem{defin}[theorem]{Definición}
\newtheorem{ejem}[theorem]{Ejemplo}
\newtheorem{obs}[theorem]{Observación}
\newtheorem{pro}[theorem]{Proposición}

\begin{document}
\section{HELLO}

\begin{defin}
HHHH
\end{defin}

\begin{defin}
IIII
\end{defin}

\begin{defin}
JJJJ
\end{defin}
\end{document}


and I wish to make a reference to "Definición 1.3" without writing or using the\label command. Something like: "About the word in Definición 1.3 the world is more beautiful."

I use \ref{defin1.3} but it doesn't work. Thanks

• I added an answer but I have to tell that the way you want to use it is not really suggested since all of your your references in the will be broken by just adding a new section before the current section you used the references. Also, references and labels supposed to be unique and named after names (not their numbers) because this way you can include your chapter in another document on another place etc without the need to change them. You are losing all these and also, (without hyperref)... Isn't it easier to write "In Definition~1.3" than "In Definition~\ref{defin1.3}? – koleygr Mar 8 at 2:15
• thanks i new in latex, i doesn´t know ~ follow of number make this more fast – user89940 Mar 8 at 2:20
• Welcome! What I am writing above is that you will gain nothing from writing "In Definition~\ref{defin1.3}" instead of "In Definition~1.3"... So, I would suggest to addapt the : "In Definition~1.3" that is faster and not worse than the "In Definition~\ref{defin1.3}" – koleygr Mar 8 at 2:24
• What's wrong in using \label and \ref? – egreg Mar 8 at 8:08

The way you want to use the \ref command is not really suggested since all of your references in the document will be broken by just adding a new section before the current section where you used the references. Also, references and labels are supposed to be unique and named after section or element names (not their numbers) because this way you can include your chapter in another document or another place, etc., without the need to change them. You are losing all these benefits and also, (without hyperref)... It is easier to write

In Definition~1.3


than

In Definition~\ref{defin1.3}


and the second way is finally worse than the first for the reasons described above.

The actually good usage would be:

In Definition~\ref{Def:1DMotion}, we can see that 1-Dimensional motion is always defining a straight line.


This last code (or the whole chapter) can be copy-pasted or included even in different documents and will give the correct number of the Definition anywhere...

Even after the above comments, Here is a way:

\documentclass[10pt,a4paper,onecolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{hyperref}
\newtheorem{theorem}{Teorema}[section]
\newtheorem{cor}{Corolario}[theorem]
\newtheorem{lem}[theorem]{Lema}
\newtheorem{defin}[theorem]{Definición}
\newtheorem{ejem}[theorem]{Ejemplo}
\newtheorem{obs}[theorem]{Observación}
\newtheorem{pro}[theorem]{Proposición}

\let\olddefin\defin
\let\oldenddefin\enddefin
\renewenvironment{defin}{\olddefin}{\label{Defin\thetheorem}\oldenddefin}

\newcommand{\defref}[1]{Definición~\ref{#1}}

\begin{document}
\section{HELLO}

\begin{defin}
HHHH
\end{defin}

\clearpage

\begin{defin}
IIII
\end{defin}

\clearpage

\begin{defin}
JJJJ
\end{defin}

Definición~\ref{Defin1.2} is in page \pageref{Defin1.2} and Definición~\ref{Defin1.3} is in page \pageref{Defin1.3}

or

\defref{Defin1.2} is in page \pageref{Defin1.2} and \defref{Defin1.3} is in page \pageref{Defin1.3}

\end{document}


PS: I added the hyperref package and \pageref command with some \clearpages in order to be able to check the correctness of the references.

Also added a command \defref that will automatically print the "named" reference.

• Your comment to the question saying why not using \label and \ref was a bad idea is good information that might be lost since it's in a comment. It would be helpful to add it to this answer. – barbara beeton Mar 9 at 1:19
• @barbarabeeton Thanks... Done – koleygr Mar 9 at 1:46
• @barbarabeeton sure... Take the freedom to make it as you wish... (My English are not good enough... even if improved somehow here) – koleygr Mar 9 at 2:02