I've recently started on trying to create letters to send using LaTeX, and I would also like to generate envelopes for those letters at the same time. I discovered the envlab package which looks like it does an excellent job at that.

The only issue that I'm having is that this puts the envelope content at the end of the document. For my use it would work out better if the envelope were created as the first page of the resulting document. That would allow me to put an envelope into the manual slot of my printer to have that printed and then the printer would pull the paper from the automatic feeder. With the envelope last, my printer just prints the envelope content onto a plain sheet of paper pulled from the tray.

Is there some option that I'm missing which would allow me to reorder the output so that the envelope content would come first?

I'm using pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian).

2 Answers 2


The suggestion from Boris about pstops caused be to discover the psselect command. This allows me to reorder the pages in the resulting .ps file using:

psselect _1,1-_2 in.ps out.ps

Since the _ character refers to a page counted from the end of the document.


This is difficult to achieve on TeX level, but you can rearrange pages before sending them to the printer.

  1. If you use dvips mode (recommended for better interaction with PostScript printers), just put -r option to dvips call, which means printing the pages in the reverse order.

  2. If you use pdf mode, you may filter the file through pdftk

    pdftk in.pdf cat end-1 output out.pdf

Update: OP asked for a solution useful for a Makefile. Here it is:

export N=`pdfinfo ${PDF} | grep '^Pages' | awk '{print $$2-1}'`;\
    pdftk ${PDF} cat end 1 - $$N output out${PDF}

Note that we use $$ instead of $ since this is a Makefile fragment

  • That would work fine if the actual letter is just one page, but in the rare case where it's multiple pages I'd prefer that the (non-envelope) pages are kept in the original order.
    – qqx
    Feb 1, 2013 at 19:09
  • With pdftk you can do this too: pdftk in.pdf cat 5 1-4 out.pdf. With dvips you probably need pstops.
    – Boris
    Feb 1, 2013 at 19:17
  • I'm aware of that option with pdftk, but I was really hoping for some method that I could put into a Makefile. Needing to know the number of pages in the document makes that difficult.
    – qqx
    Feb 1, 2013 at 19:23
  • Well, it is easy with Makefiles :) pdfinfo FILE.PDF | grep '^Pages:' | awk '{print $2}' gives you the number of pages...
    – Boris
    Feb 1, 2013 at 19:27
  • Please see update
    – Boris
    Feb 1, 2013 at 19:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .