Including several tex files in one: multiple defined labels

  • #1
1,983
106
Hi PF!

I have a divided a main.tex into chapters, chapter_1.tex, chapter_2.tex.... Each chapter is included in the main.tex via \include{chapter_1}. Each chapter also references equations. Is there a way to have each of the chapter_1.tex only reference that file's equations, sections, figures? As is, I have multiple defined labels.

Thanks so much!
 

Answers and Replies

  • #2
Wrichik Basu
Insights Author
Gold Member
2020 Award
1,710
1,556
Why don't you generate the pdf for each chapter separately, and then combine them into one file? This would be better than including all those chapters into the main .tex file. Adobe online, for instance, allows you to combine files for free.
 
  • #3
DrClaude
Mentor
7,587
3,951
Why not simply change the labels? Each file/chapter could have its own label prefix to make sure there can be no multiply defined labels (it is easy to perform a search and replace in each file to include those prefixes).
 
  • Like
Likes joshmccraney, Orodruin, pasmith and 2 others
  • #4
pasmith
Homework Helper
2,004
638
Why don't you generate the pdf for each chapter separately, and then combine them into one file? This would be better than including all those chapters into the main .tex file. Adobe online, for instance, allows you to combine files for free.

That breaks things if one chapter makes references to the content of another, or you have page references, or you want to generate a single bibliography for the entire work.
 
  • Like
Likes Wrichik Basu, joshmccraney and FactChecker
  • #5
Orodruin
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Gold Member
16,980
6,778
The sad and somewhat dry truth is to not use the same label several times in different files if you want to compile them together. Making references between the files is a feature and this requires unique lables. I suggest going with #3.
 
  • Like
Likes joshmccraney
  • #6
1,983
106
Thanks everyone. I'll just rename the equations. Wasn't sure if there was a package available that made this simple, but this is still very easy.
 

Related Threads on Including several tex files in one: multiple defined labels

Replies
1
Views
2K
Replies
1
Views
7K
Replies
5
Views
887
  • Last Post
Replies
1
Views
644
Replies
1
Views
3K
  • Last Post
Replies
7
Views
764
Replies
1
Views
5K
Top