15

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?

  • 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. – Peter 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
  • 1
    @xport From the TOC of the first full run! – Yiannis Lazarides Jun 5 '11 at 17:27
20
\documentclass[a4paper]{article}
\usepackage[1-10]{pagesel}

\begin{document}
% text
\end{document}

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.

  • The problem with pdfpages is that the included PDF loses the links that it has. :( – Peter Krumins Jun 5 '11 at 15:23
  • @xport be aware of this problem that I had when using pdfpages – Peter Krumins Jun 5 '11 at 15:34
  • 1
    @Peteris: The solution given above does not use pdfpages. @egreg just added another method by using pdfpages. :-) – xport Jun 5 '11 at 15:38
  • 1
    @Peteris: there are free pdf manipulation tools that do what you want. – egreg Jun 5 '11 at 15:42
  • 2
    @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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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