Discussion:
Ling-TeX: multiply-defined labels
Simona Herdan
2007-07-29 19:17:29 UTC
Permalink
Hi everyone,

I have a question that is not technically related to linguistics, but I
am hoping that some of you encountered the same problem and found an
easy solution. I'd rather not spend time reinventing the wheel.

So - when I work on a project that includes several different latex
files, I often find that I reuse the same labels, which leads to
complaints of "multiply-defined labels" when all files are packed
together in the final product. Of course, I can always do it the boring
way and fix the labels manually, but the problem comes up more and more
as the project gets longer. Any suggestions?

Thanks in advance,
Simona Herdan
--
_____________________

Simona Herdan
Department of Linguistics
University of Connecticut
Joost Kremers
2007-07-29 19:29:10 UTC
Permalink
Post by Simona Herdan
Hi everyone,
I have a question that is not technically related to linguistics, but I am
hoping that some of you encountered the same problem and found an easy
solution. I'd rather not spend time reinventing the wheel.
So - when I work on a project that includes several different latex files,
I often find that I reuse the same labels, which leads to complaints of
"multiply-defined labels" when all files are packed together in the final
product. Of course, I can always do it the boring way and fix the labels
manually, but the problem comes up more and more as the project gets
longer. Any suggestions?
use reftex to come up with label names. it tries its best to make sure
names are unique.

i see no way to automatically fix documents that already have mulitply
defined labels, because there is no way a computer could ever figure out if
a reference to a multiply defined label should go to the first or the
second (third, etc.) definition.
--
Joost Kremers
Life has its moments
Simona Herdan
2007-07-29 20:32:14 UTC
Permalink
Hi Joost,
Post by Joost Kremers
use reftex to come up with label names. it tries its best to make sure
names are unique.
I'm not sure that's what I want - it probably assigns unique numerical
labels, which are very hard to remember later if I need to use it a few
pages later.
Post by Joost Kremers
i see no way to automatically fix documents that already have mulitply
defined labels, because there is no way a computer could ever figure out if
a reference to a multiply defined label should go to the first or the
second (third, etc.) definition.
Ideally, I would like to come up with my own labels, but to have a
system that can check within the files that I identify as belonging to
my project if there already is a label with that name.

Maybe I'm just asking for too much. I'll look at reftex in more detail.

Thanks anyway. I wasn't aware of reftex.

Simona
--
_____________________

Simona Herdan
Department of Linguistics
University of Connecticut
Joost Kremers
2007-07-29 20:54:12 UTC
Permalink
Post by Simona Herdan
Hi Joost,
Post by Joost Kremers
use reftex to come up with label names. it tries its best to make sure
names are unique.
I'm not sure that's what I want - it probably assigns unique numerical
labels,
actually, it is a bit smarter than that. e.g. for sections, it usually
takes (parts of) the words of the section title and composes a label with
those.
Post by Simona Herdan
which are very hard to remember later if I need to use it a few
pages later.
come to think of it, you never mentioned you use emacs... reftex is an
emacs add-on, so my suggestion only works if you use emacs to write your
latex source files...

if you do, though, reftex is certainly something to check out: your problem
of remembering which labels you've given is also handled in a very
beautiful way. if you insert a reference, reftex shows you all labels in
the file, with a bit of context so that you can tell what they refer to. it
is also smart about the labels it shows you. so if e.g. you're typing "see
section " and then use reftex to insert a reference, it only shows you
labels of sections.

but as i said, you need to be using emacs for it...
--
Joost Kremers
Life has its moments
augerot
2007-07-29 21:21:41 UTC
Permalink
Hi,
I just tack on to my preamble for any given document or project an alphabetical list with definitions of any labels or special commands I use in that project. I put it after the end{document} so it never gets in my way as I process files with that preamble. Then if I am in doubt, I can simply search that preamble file for a given label name, etc.
--
jim augerot
Post by Simona Herdan
Hi Joost,
Post by Joost Kremers
use reftex to come up with label names. it tries its best to make sure
names are unique.
I'm not sure that's what I want - it probably assigns unique numerical labels,
which are very hard to remember later if I need to use it a few pages later.
Post by Joost Kremers
i see no way to automatically fix documents that already have mulitply
defined labels, because there is no way a computer could ever figure out if
a reference to a multiply defined label should go to the first or the
second (third, etc.) definition.
Ideally, I would like to come up with my own labels, but to have a system that
can check within the files that I identify as belonging to my project if there
already is a label with that name.
Maybe I'm just asking for too much. I'll look at reftex in more detail.
Thanks anyway. I wasn't aware of reftex.
Simona
Christina Thiele
2007-07-30 01:12:24 UTC
Permalink
Post by Simona Herdan
Hi everyone,
I have a question that is not technically related to linguistics, but I
am hoping that some of you encountered the same problem and found an
easy solution. I'd rather not spend time reinventing the wheel.
So - when I work on a project that includes several different latex
files, I often find that I reuse the same labels, which leads to
complaints of "multiply-defined labels" when all files are packed
together in the final product. Of course, I can always do it the boring
way and fix the labels manually, but the problem comes up more and more
as the project gets longer. Any suggestions?
Thanks in advance,
Simona Herdan
I've run into a similar problem -- multiple use of the same label --
in a book which has biblios at the end of each chapter. I'm using the
\includeonly + \include type of run-file, so a single TeX processing
run encounters the same author in several chapters:

\bibitem{Karman45} in chaps 1, 5, 7

I just did a global replacement in each chapter:

\bibitem{1-Karman45}
\bibitem{5-Karman45}
\bibitem{7-Karman45}

That way, I know which chapter a reference is in, and each is
unique. And I completely avoided ;-) any labour-intensive renaming of
the \bibitem entries.

What if you did something similar to your \labels:

\label{1-xxx}
and
\label{4-xxx}

would then be unique. The xxx is still the same, but the prefix keeps
them separate. And it's a quick fix.

Ch.
Simona Herdan
2007-07-30 02:23:33 UTC
Permalink
Thanks Christina -

I had in mind something like that, and it looks to me like the easiest
thing to do at this point. But I have to say that I also sort of like
reftex, which Joost suggested. It seems useful for avoiding duplicates
within the same file. Thank you both for the pointers.

Cheers,
Simona
Post by Christina Thiele
\label{1-xxx}
and
\label{4-xxx}
would then be unique. The xxx is still the same, but the prefix keeps
them separate. And it's a quick fix.
Ch.
--
_____________________

Simona Herdan
Department of Linguistics
University of Connecticut
Alexis Dimitriadis
2007-08-07 21:55:30 UTC
Permalink
Well you could avoid the problem by using a prefix for all labels in each
part of your project (e.g. c1 for chapter 1, etc.). But that's ugly--
besides, a solution that does not require extra work would be nicer, right?

So I'd look for a package that lets you define labels with file-local scope;
unfortunately my short search did not reveal one, but maybe one exists--
there seems to be a package for everything these days :-) The closest I know
of is the package xr, which however is for referring to labels across
separate documents (it does provide a way of dealing with multiply-used
labels).

The package you need would be sort of the opposite of xr: It might arrange
for the calls to \label to be remembered only within the same file (or
perhaps chapter, etc), instead of having effect over the entire document.
There would also be some way of defining global labels, or of referencing
labels defined in other files. If your writing style rarely uses references
across files, this should be just what you need.

Anyway you could ask the question on the comp.text.tex newsgroup, where the
real experts hang out. Good luck,

Alexis

----- Original Message -----
From: "Simona Herdan" <simona.herdan-ylq8G2Nda/***@public.gmane.org>
To: "LingTex" <ling-tex-6miFZF/***@public.gmane.org>
Sent: Sunday, July 29, 2007 9:17 PM
Subject: Ling-TeX: multiply-defined labels
Post by Simona Herdan
Hi everyone,
I have a question that is not technically related to linguistics, but I am
hoping that some of you encountered the same problem and found an easy
solution. I'd rather not spend time reinventing the wheel.
So - when I work on a project that includes several different latex files,
I often find that I reuse the same labels, which leads to complaints of
"multiply-defined labels" when all files are packed together in the final
product. Of course, I can always do it the boring way and fix the labels
manually, but the problem comes up more and more as the project gets
longer. Any suggestions?
Thanks in advance,
Simona Herdan
--
_____________________
Simona Herdan
Department of Linguistics
University of Connecticut
Loading...