# Splitting(!) one latex document into two pdf outputs including references

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?

• Maybe you want to use `xref`? I'm not entirely sure quite what you want the results to be, though. Why not just print the pages you want (if it is one document) or split the file (if it is two)? – cfr Feb 2 '14 at 0:03
• This answer might help you: tex.stackexchange.com/questions/155867/… . Use the `subfiles` package to seperately include the main thesis and your appendix. Compile the main thesis only or compile the entire file. – Snicksie Feb 2 '14 at 8:55

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.

• That did it. Not completely, though (One main document and another separate document with separate titlepage but "cross"-references to each other), but at least now I can create two documents with correct links and references. – Kris Feb 2 '14 at 12:26
• sure, if you want different title pages in different situations then it gets slightly more elaborate, but the principle still applies - good luck with your thesis – Frank Mittelbach Feb 2 '14 at 13:04

To get a thesis-PDF without the appendix - but including all references to it - compile your thesis including the appendix. Then use Acrobat Pro or pdftk (free software) to remove unwanted pages.

If you want only the appendix: remove the other pages.

nameref will solve your third problem. See here: \nameref -- How to display section name AND its number

• This option kills all inner links within each document, and cross references between separate documents. – Herpes Free Engineer Sep 21 '16 at 9:45