# Change Page Ordering

In one of my documents, the first few (lets say 2) pages include code output and settings and configurations, in terms of communicating with R for example (for plotting etc...), I would like these pages to appear at the rear of the document, or split off into a second document.

They need to be 'typeset' in the original order, since much of the appearance of the document thereafter, is dependent on what is defined in this pre-section. The actual contents of the output to the pre-section, however, is trivial to the reader of the actual document, however, of interest to me.

How can I re-arrange or split the document post typesetting, to either remove the first 2 pages into a new document, or, move them to the end of the current document.

-
have you looked at the pdfpages package? – cmhughes Dec 20 '12 at 3:08
Can you be more precise as to what in those "pre-sections" is relevant for the following material? – egreg Dec 20 '12 at 7:35

This solves the question...

\AtEndDocument{
}

-

Not sure if I understood your problem but if the first couple pages are just settings, you could create an .sty file, say mysettings.sty, with all your customizations and in the original document replace the first couple pages with \usepackage{mysettings}.

-
I'm not sure that will work here. The settings are actually 'R' settings, not latex settings, they are defined at runtime from inside \begin{document} \end{document} to define the 'R' environment, certain output is returned, and that output is what is being inserted into the document. I want the output, so I can refer back to it later in version control. It needs to be done at the start, but I want the output to be put at the end (or in a separate file) – Nicholas Hamilton Dec 20 '12 at 0:57
@ADP Have you thought about using the commands \AtBeginDocument and \AtEndDocument? – mkota Dec 20 '12 at 3:13
@Jay, that solved my problem. If you want to post as a complete answer, I'll mark it as a solution... – Nicholas Hamilton Dec 20 '12 at 3:30