[Tex/LaTex] Splitting(!) one latex document into two pdf outputs including references

cleverefcross-referencinghyperrefpdfvarioref

I have a quite huge thesis-latex-document with lots of references to the appendix. The whole document I would like to split into two pdf-files. That means: I would like to have the thesis and the appendix as separate .pdf-outputs with own titlepages but the references in the main document leading to the appendix, so I can print out two independent documents.

The reason is: The main file is my thesis, the appendix is – obviously – the appendix that is not actually independent from the thesis but should be treated as independent if you know what I mean. I would like to be able to give out the thesis without the appendix but the references that I have to the appendix should indicate that it actually is another document.

I am using the scrreprt-KOMA-Script document class and I would like to keep using it. Also I am using the varioref, hyperref and the cleveref-packages in combination. I also would like to keep that.

I assume I'll have to create two separate "main files". One for the main document "thesis.tex" and one for the appendix "appendix.tex". The question then is: How can I

  1. let the included "appendix.tex"-file get compiled while actually
    compiling the "thesis.tex" including all necessary references? In
    this case the hyperlinks are not that important.
  2. get as output thesis.pdf and appendix.pdf?
  3. get the reference in the main document point to sth. like "Appendix, p. XY" or – preferabily since I am writing in German – "Anhang, S. XY"?

I am using Sublime Text with the latexing-extension but I guess this is not very important in this case. In terms of typesetting engine I use pdflatex, so nothing really experimental.

After all I need to know:
What package do I might need for this? What changes do I need to undertake in my document (for example labels) to accomplish the above mentioned results?

Best Answer

A fairly simple way to achieve this is to use the \include command to load your thesis main text and from a separate file your appendix. You then have one main file, say full.tex that compiles the whole document until all references are correct.

In addition you can set up two short files that are identical to the full.tex but containing an \includeonly statement loading only the thesis or only the appendix. After resolving the x-references running full.tex often enough the .aux files of the included files contain all relevant information to produce the two pdf files you need by running each file with the \includeonly statement once.

Compared to the suggestion to strip out the appendix from the full pdf this approach has the advantage that it can be automated, i.e., it doesn't involve any manual steps. On the downside it means additional LaTeX runs to produce the partial documents.

Related Question