1

My dissertation is several chapters, each written in a different .tex file. How can I reference the chapter number from one chapter in the text of another? For example, how would I produce

'... will be discussed more thoroughly in chapter 3.'

where '3' is dynamically generated based on its order in the list of chapters included (using \include) in the master file?

  • 1
    this is basic functionality- use \chapter{your title here}\label{anynameyouwantnospaces} and then \ref{anynameyouwantnospaces}. also check out the cleveref and varioref packages – cmhughes Feb 14 '14 at 22:33
  • I've done what cmhughes suggested, but it leaves me with ?? in place of the \ref command. I'm compiling with XeLaTeX, if that makes a difference. – ToddAO Feb 16 '14 at 5:33
  • compile it again :) – cmhughes Feb 16 '14 at 13:04
  • I have. Several times. It's a poorly-written template, required by the University. Could that be affecting things? I compile using a batch file: XeLaTeX, XeLaTeX, BibTeX, XeLaTeX, XeLaTeX. But it won't let me dynamically reference labels in other chapters (specifically, the chapter label). – ToddAO Feb 17 '14 at 13:59
  • 1
    BTW, if you want to cross-reference your title, that is the actual words of the title and not only its numeral reference, you can use nameref (which is a part of hyperref). – Júda Ronén Feb 17 '14 at 14:30
2

Just do it! This is how my thesis is organised. In each separate chapter file, start with something like

\chapter{Introduction}
\label{chap:intro}

Then in your next chapter you just do \ref{chap:intro}

By the way, you might want to check out the import package: I have each chapter in a subdirectory and the figures for each chapter in their own subdirectories. import and in particular the command subimport makes it all much neater.

0

I just use \input not \include then you can compile one document with all cross references and a correct list of references. If you need to compile only that chapter you can use make a chapter specific file like the main thesis file but eliminate the other chapters (comment out). You can also reset the chapter counter if you want for providing to your advisor and such. See Input vs Include Discussion for more information

  • 1
    If you use \include you have \includeonly, so no need to comment out. – Gonzalo Medina Feb 15 '14 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.