I'm working on a large-ish Latex document (my dissertation) in which each chapter has its own .tex file. For various reasons, I have two master files: one that includes all chapters and one that I modify over time to compile whatever chapter I happen to be working on at the time.

For the most part, the chapters are independent and resolving references isn't a big deal. But, there's a handful of important results that need to get referenced across chapters and a few times when I need to refer to another chapter, i.e., In Chap.~\ref{ch:other_chapter}, we discuss X, Y, and Z.. As-is, that of course results in "Chap. ??" in the compiled document. I'd really like to be able to hand off a PDF of a single chapter to someone else to review without a bunch of "??" references (and not have to wait for the whole document to compile).

SO.. Supposing that there's only a handful of such references so that it's manageable to do this manually, and supposing that I don't mind if their values aren't quite right, is there a simple way to manually set the label values in my single-chapter master file so that my compiled document a) doesn't have a bunch of undefined references and b) doesn't include an empty chapter that's just there to populate the reference.

I tried something like

% the chapter I'm currently working on

% so I can reference the next chapter without having to compile it

But then \ref{ch:other_chapter} resolves itself as a Section of the chapter before it.

I don't want to do this:


\chapter{The other chapter}

Because this will actually generate a new chapter in the text, TOC, etc.

  • 1
    Do you use \includeonly? Mar 19, 2012 at 18:08
  • 2
    I think once you have learned about \includeonly, then your question will evaporate.
    – Seamus
    Mar 19, 2012 at 18:08
  • 1
    I am building a catalogue of exercises which reference each other, and this question applies to references between exercise sheets. Using \includeonly is not practical for several reasons; each sheet needs to be its own document.
    – Raphael
    Dec 11, 2012 at 15:03

2 Answers 2


I don't think you should bother with this problem, as it will be solved once you'll have everything in place.

If you really want to set manually references, you can say in your preamble


and then use


so that \ref{ch:other_chapter} will print "2". In the second argument you can put whatever you want.

  • Note to anyone else who stumbles on this: this answers the question directly, but @Seamus' answer is really the right way to go. (Thanks)
    – dantswain
    Mar 19, 2012 at 18:42
  • How do you set the value printed by \nameref?
    – Raphael
    Dec 20, 2012 at 10:08
  • @Raphael That's much more difficult. And, as I said in my answer, quite pointless.
    – egreg
    Dec 20, 2012 at 11:33
  • 1
    Note that the \manuallabel command does not appear to work with hyperref.
    – a3nm
    Feb 20, 2017 at 14:32
  • 2
    @a3nm Probably not, I agree. It would be a new question altogether.
    – egreg
    Feb 20, 2017 at 15:12

The problem you have encountered is a common one, and there is a much better solution than manually fixing the references. With the one master file you can use \includeonly{chap-foo} to compile only the one chapter. This way, references to other chapters will work perfectly.

This requires that the other chapters have been compiled in the past. What \ref{foo} points to is determined by something in the .aux file for the file where the \label{foo} is defined. So as long as you don't go deleting all your .aux files too regularly, this is a good way to crossreference chapters that don't get compiled. Because even if you aren't compiling bar.tex, bar.aux is still read by latex and so it knows what \refs that are \label-ed in bar.tex are supposed to look like.

  • provided the other .aux files exist
    – cmhughes
    Mar 19, 2012 at 18:19
  • Doesn't it have to compile the other chapters to resolve the references, though?
    – dantswain
    Mar 19, 2012 at 18:21
  • (Yes, a recompile of the entire document is required.) I gave @egreg answer credit because it answers the question directly, and upvoted this because it will ultimately be more useful. Thank you.
    – dantswain
    Mar 19, 2012 at 18:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .