# Include aux file in tex source?

I have a large book broken into several chapters, each of which reference each other heavily. I would like to be able to distribute individual chapters as self-contained .tex files. I can do this except for the fact that references will not work unless I have the .aux file for the entire book (and I use the xr package for external references). I would thus like to be able to include the large .aux file in the individual chapter files when distributing the individual files. Is there a way I can do this?

-
But what behavior do you want? If one chapter references another with \ref, what do you want it to display when that chapter is distributed separately? –  Ben Jan 5 '11 at 19:12
The same that it would display as if it were in the total document. (Each individual chapter file starts the numbering according to its place in the book, so there should not be a conflict.) As in, I would like to store the cross-referencing data within each .tex file so that the others are not necessary. –  Akhil Mathew Jan 5 '11 at 19:13
you should use \include and \includeonly, then you can run individuell chapters. See also tex.ac.uk/cgi-bin/texfaq2html?label=include –  Herbert Jan 5 '11 at 19:59
have you already considered the filecontents environment and package? –  equaeghe Mar 15 '11 at 12:49

You can use either of the environments filecontents or filecontents*. Each of those takes one required argument, the name of the file to be created, and then then it creates that file with the contents of the environment.

The unstarred version adds a few lines of comments at the beginning of the file describing how the file was created, the starred version doesn't add anything to the contents of the environment.

You use these environments before the \documentclass command. That is, you'd beging your latex file with, e.g.,

\begin{filecontents*}{myotherstuff.aux}
\newlabel{\whatever}...
...
\end{filecontents*}


and your \documentclass command comes after that.

-