[Tex/LaTex] Manually set reference values

cross-referencingnumbering

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
\include{the_chapter}

% so I can reference the next chapter without having to compile it
\setcounter{chapter}{2}
\label{ch:other_chapter}

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

I don't want to do this:

\include{the_chapter}

\chapter{The other chapter}
\label{ch:other_chapter}

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

Best Answer

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

\makeatletter
\newcommand{\manuallabel}[2]{\def\@currentlabel{#2}\label{#1}}
\makeatother

and then use

\manuallabel{ch:other_chapter}{2}

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

Related Question