I'm working on a book in which page numbers (\count0) repeat. I have 24 pages of front matter numbered in roman numerals, about 800 pages of main text, and then another 400 pages of "Supplement" which are numbered S1 to S400. I want to extract pages 345 to 380 (a chapter) for review, but I can't seem to figure out how to do it using TeXlive on Debian Linux:

  • If I use dvips, I get not only pages 345 to 380, but also pages S345 to S380.

  • If I use dvidvi with option -i (@1)345..(@1)380, the resulting .dvi file is not convertible to PDF (conversion fails with an undefined identifier in the PostScript, might be H.S)

How can I extract the pages I want? Is there a trick using \count1 that might help? I'd really like to avoid crawling .aux files and calculating absolute page numbers.

ETA: Doing it by hand by, say, using xdvi or Evince to get the page numbers, is not an option I really wish to pursue. The point is to be able to get a previewed page range quickly---I'm mostly pulling these ranges from the chapter's table of contents. Doing the arithmetic in my head every time would make me crazy! (It's actually easier just to get the superfluous pages and then remove them using pdftk. But I hope to do better.)

  • Is it an option to open the dvi file in Evince to find the absolute page numbers? Or just 345+24=369 to 380+24=404? So that would be dvips -p =369 -l =404. Or print to file from Evince with a page range. Or make a pdf and then extract the pages with pdftk. Or temporarily modify your supplement numbering in your LaTeX source. – Marijn Jun 14 '19 at 21:48
  • I'd also use pdftk or similar as it uses the sheet count, not the page numbers – daleif Jun 14 '19 at 21:54
  • If you know how to do this "by hand" using xdvi etc then it should be scriptable. I have a similar issue, but without the repeating page numbers, where I need to extract various sections of the document. To do this I have automated \label{...} commands at appropriate places in the TeX file that, in effect, write custom markers to the aux file. I then have a python script read the aux file to find the page numbers and extract the pages that I need. – Andrew Jun 15 '19 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.