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

I use pdflatex to generate my documents. I want to create a preview of my document and generate only the first 10 pages, but I still want the full table of contents. How do I do that?

share|improve this question
My comment may not answer your question. Do you know \includeonly which is invoked in the preamble to activate only one inclusion but the whole indexing and cross referencing still work? – xport Jun 5 '11 at 15:10
Yes, I know about \includeonly but the first 10 pages end in the middle of chapter two, which is where I want to stop. – Peteris Krumins Jun 5 '11 at 15:20
A simple quick and efficient technique. Insert `\end{document}' where you want to break off. Keep life simple. – Yiannis Lazarides Jun 5 '11 at 15:38
@Yiannis: But how can you know the number of pages exactly? :-) – xport Jun 5 '11 at 15:45
@xport From the TOC of the first full run! – Yiannis Lazarides Jun 5 '11 at 17:27
up vote 20 down vote accepted

% text

Thanks to Heiko Oberdiek. Remember, though, that references and table of contents will be incomplete. An alternative way is to compile the whole document and load its first ten pages in another one via pdfpages.

share|improve this answer
The problem with pdfpages is that the included PDF loses the links that it has. :( – Peteris Krumins Jun 5 '11 at 15:23
+1 I just have known this good package. – xport Jun 5 '11 at 15:28
@Peteris: The solution given above does not use pdfpages. @egreg just added another method by using pdfpages. :-) – xport Jun 5 '11 at 15:38
@Peteris: there are free pdf manipulation tools that do what you want. – egreg Jun 5 '11 at 15:42
@Peteris, @egreg -- if a complete run has previously created a full table of contents, it should suffice for the partial run to insert the command \nofiles in the preamble. then the old toc (and aux files) won't be overwritten. of course, this doesn't work if it's necessary to have intermediate working files for the first ten pages. – barbara beeton Jun 6 '11 at 12:39

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.