Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
    
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 '13 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 '13 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 '13 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 '13 at 19:27
    
Please see update –  Boris Feb 1 '13 at 19:39
add comment

Your Answer

 
discard

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.