# Combining different LaTeX articles / documents: How to avoid mixing of equation labels between different chapters of thesis?

I am going to write my PhD thesis. I have 7 to 8 papers written in latex. Now I want to compile all the papers in to chapters of thesis. Since all the paper have almost common equation labels so when I compile my latex file then wrong equations get referred from same label in other chapters. Is possible to avoid mixing of equation within different chapters of thesis, so that I can refer an equation independent within same chapter without bothering the similar equation labels in other chapters? Or I need to compile chapter differently into single file by using command \include{chapterX} ?

Here is example code:

\documentclass[fleqn,preprint,10pt]{report}
\usepackage{amsmath}
\usepackage{natbib}
\begin{document}
\begin{titlepage}
\begin{center}
{\Large This is my thesis}
\end{center}
\vskip 5pt
\end{titlepage}
\tableofcontents
\listoffigures
\listoftables
\chapter{}
\section{This is my Introduction}
Here is my equation
\begin{align}
\label{1}x^2+y^2=1
\end{align}
\begin{align}
\label{2}x^2+y^2=1
\end{align}
I can refer this equation as \eqref{1}. But since chapter 1 and 2 have common labels so the wrong equation get referred.
\chapter{}
\section{This is second Chapter}
Here is my another equation in second chapter
\begin{align}
\label{1}\tan(x)=x
\end{align}
\begin{align}
\label{2}\cot(x)=x
\end{align}
I can also refer this equation as \eqref{1}. How I can refer equation in a chapter without mixing labels from other chapters ?
\section*{References}
\bibliography{My.Bibtex.Library}
\bibliographystyle{plain}
\end{document}

• I'm not so experienced, but I think the problem you have is due to same equations labels in different chapters. IMO the only option you have is to give labels some unique value, e.g. "ch1:eq1" for 1st equation in chapter 1 and "ch2:eq1" for 1st equation in chapter 2. Mar 1 '17 at 10:24
• Labelling with \label{1} and \label{2} is apparently not the best way of using labels. Repeating the label with the same label identifier is an error and you should have noticed the warning messages about multiply defined labels
– user31729
Mar 1 '17 at 10:51
• @ChristianHupfer: I have found solution my problem, see answer to my own question. Now next problem is, how I can refer equation from chapter 2 in chapter 3 when I have similar labels in both chapters. The both chapters are saved in different Tex files by different names. Mar 1 '17 at 11:53
• @IgotiT: No, that's not the solution actually. Again: Don't repeat label names!
– user31729
Mar 1 '17 at 12:01
• @ChristianHupfer: What should I do now!!! I completely messed my latex source code with similar label. Is there any solution or I have to change labels or should take output for each chapter as pdf and then combine pdf? Mar 2 '17 at 0:53

• Just open every article (LaTeX document) separately and search and replace \label{ with \label{Paper01_ and so on.
• Do the same for \eqref{ and \ref{.
• Do it for every article, Paper01 to Paper_07.