MHB Multiple Labels to a Single Definition or Theorem.

AI Thread Summary
Defining multiple labels within a single definition environment, such as for open and closed sets, appears to function correctly without warnings, but there are potential pitfalls to consider. While some users report success with this approach, especially when using the amsthm package for definitions, concerns arise about the need to change labels if definitions are split later. The discussion highlights that while multiple labels can simplify referencing, particularly for complex concepts, it may lead to confusion in other environments like equations, where the first label is often discarded. Users suggest utilizing tools like Emacs with RefTeX for easier label management and recommend the cleveref package to streamline referencing without needing to specify the type of label. Overall, while using multiple labels can be convenient, careful consideration of the document structure and potential future changes is advised.
caffeinemachine
Gold Member
MHB
Messages
799
Reaction score
15
Suppose I define closed sets and open sets in a single definition environment. Now I want to put two labels in the environment. \label{Open Set} and \label{Closed Set}.

I have tried this and this doesn't cause any trouble and doesn't give any warning.

But are there any hidden pitfalls in doing this? Is there a better method?
 
Physics news on Phys.org
I think you might have problems. You can't do this with the equation environment, for example. It throws away the first label. I would label like this:

\label{Open and Closed Sets}

How are you defining your definition environment?
 
Ackbach said:
I think you might have problems. You can't do this with the equation environment, for example. It throws away the first label. I would label like this:

\label{Open and Closed Sets}

How are you defining your definition environment?
I have used the amsthm package for the definition environment.

In the preamble I have written \newtheorem{definition}{Definition}[section]

Then wherever I need to define something I just write

\begin{definition}
stuff
\end{definition}
____

I think labeling it as \label{Open and closed sets} is not a viable option.
I have a definition environment where I have deifned injective, surjective, bijective functions. In the same environment I have defied image, preimage etc.

It is always a good idea to define closely related concepts in a single environment.

Multiple labels would make like so much better.
 
Hmm. Well, it seems to work. I tried a simple \newtheorem{theorem}{Theorem}, and slapped two labels on it. Then I used both labels later, and they both referenced correctly.
 
Another possibility is to create nested definition environments. You could create a subdefinition environment that takes its numbering within the standard definition environment. They would work similarly to sections and subsections. You'd have to experiment with the environment definition (I don't know the exact syntax to make it work off the top of my head).
 
Ackbach said:
Hmm. Well, it seems to work. I tried a simple \newtheorem{theorem}{Theorem}, and slapped two labels on it. Then I used both labels later, and they both referenced correctly.
Works on my system too. Hope it is not dangerous.
 
I don't see any harm from multiple labels. The \label command writes to the .aux file a line of the following form.

\newlabel{eq:pythagoras}{{4}{1}}

Here the first number is the value of the counter that was incremented last using \refstepounter (in the case of the equation environment, the counter called "equation"), and the second number is the current page number. I don't see any difference between the lines in the .aux file from the two \label commands inside the equation environment. When the .aux file is read before processing the .tex file, the information about the labels is read and later used when a \ref command is encountered.

Ackbach said:
I would label like this:

\label{Open and Closed Sets}
The main drawback from this that I see is the need to change the labels if the author decides to split the definition into two.

I am not sure if the situation changes by packages that deal with references (such as hyperref).
 
Evgeny.Makarov said:
I don't see any harm from multiple labels. The \label command writes to the .aux file a line of the following form.

\newlabel{eq:pythagoras}{{4}{1}}

Here the first number is the value of the counter that was incremented last using \refstepounter (in the case of the equation environment, the counter called "equation"), and the second number is the current page number. I don't see any difference between the lines in the .aux file from the two \label commands inside the equation environment. When the .aux file is read before processing the .tex file, the information about the labels is read and later used when a \ref command is encountered.

Danks. I feel much safer now. :)
 
Evgeny.Makarov said:
The main drawback from this that I see is the need to change the labels if the author decides to split the definition into two.

True, although that's nothing a good text editor can't chew through fairly quickly.
 
  • #10
caffeinemachine said:
Suppose I define closed sets and open sets in a single definition environment. Now I want to put two labels in the environment. \label{Open Set} and \label{Closed Set}.

I have tried this and this doesn't cause any trouble and doesn't give any warning.

But are there any hidden pitfalls in doing this? Is there a better method?
I don't understand what you want to achieve. Can you post some example code and describe the output you would like?
 
  • #11
dwsmith said:
I don't understand what you want to achieve. Can you post some example code and describe the output you would like?
Okay.

Suppose on the first page of a document I write:

\begin{definition}
\label{Open And Closed Set}
An open set is blah blah. A closed set is the complement of an open set.
\end{definition}

Now suppose I am, say, on the 56th page and I need to invoke the concept of a closed set and want to tell the reader too see Definition ref{wait.. what was the label?}.
I know that I have defined it somewhere. May be in a same environment with some other concept also defined there. May be not. What could be the label I had used there? Going back and checking the label would be such a waste of time. So what I'd prefer doing is:

\begin{definition}
\label{Open Set}
\label{Closed Set}
An open set is blah blah. A closed set is the complement of an open set.
\end{definition}

Now I don't need to burden my head with what is the label I have used in the environment I have defined a closed set.
I know my habit is to label a definition environment once for each concept defined in it. So when I invoke the concept of a closed set, and want to make the reader's life easier, I simply write ref{Closed Set}.

Obviously the concept of a closed set is known to everybody and thus wouldn't need this kind of treatment. But some more involved and lesser known concepts demand this.
 
  • #12
caffeinemachine said:
What could be the label I had used there? Going back and checking the label would be such a waste of time.
Your approach may work for definitions, but it's hard to avoid giving hard-to-remember labels to other things, such as equations, theorems and items. A good text editor should facilitate recalling labels. I am using Ref mode in Emacs, which gives you a menu with recent labels, so you don't have to actually go to another part of the document.
 
  • #13
Use AUCTeX with RefTeX and your problem will be solve. When you are using those two with whatever compiler you like, you simply hit control+c and then ). This bings up
http://img543.imageshack.us/img543/7210/4qez.png

Then I have the option of carriage return for ref, p for page ref, a autoref, and u autopageref. Now suppose I hit return then I get a list of all my references by section or chapter. This is a practice quiz that has only one reference so it isn't going to look too special.
http://img600.imageshack.us/img600/4972/vuha.png

n and p let me jump to the next or previous sections list of references. I can navigate through 1000s of references across many pages in seconds. Then I simply highlight the one I want and hit enter. I can even select multiple ones and hit enter to add them all.

To make life even easier, use cleveref when references. Then you don't have to do label{eq:name} or label{fig:name}, you just do label{name}, and when you reference, you will do \cref{name}. Cleveref can determine if it is a figure, equation, definition, theorem, lemma, or anything else.
 
Back
Top