TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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

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}.

share|improve this answer
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
up vote 0 down vote accepted

This solves the question...

   %Add Content
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.