Possible Duplicate:
Can I re-use section labels across chapters?
Is there a way to control the scope of the command \label and \ref?
In document chap1.tex, I declare the label \label{lemma} and access it with \ref{lemma}.
In document chap2.tex, I also declare the label \label{lemma} and access it with \ref{lemma}.
Then, in book.tex, the error multiply defined label is raised.
I understand the error wouldn't be raised if I use \label{1:lemma} and \label{2:lemma}.
Is it possible to redefined the command label and ref so that
\label{lemma} produces the key chap1:lemma, and
\ref{lemma} invokes the key chap1:lemma.
That is label and ref based themselves on the current document name.
Any other solution is also welcome.
lem:def-Rfor the definition of real numbers R. A good editor can show you all til now used labels to choose the right one for referencing ... – Mensch Dec 15 '12 at 01:21lemmas in the same chapter? – Dec 15 '12 at 01:45\newcommand*\labellocal[1]{\label{\thechapter:#1}} \newcommand*\reflocal[1]{\ref{exer:\thechapter:#1}}– Qrrbrbirlbel Dec 15 '12 at 03:08xrpackage helps you out in terms of\label. You'll have to do something similar for\ref. With an automated process and regular\label-\refs, you would most likely not be able to reference across chapters. – Werner Dec 15 '12 at 03:34chap1.tex", maybe every chapter is a separate article? In this case you could combine them using thecombinepackage. It will also take care of labels. – Stephan Lehmke Dec 15 '12 at 07:44