I stumbled onto the same problem, and Ulrike’s answer didn’t fully work for me because something in the document reset the page numbers (according to Okular they were numbered 1(cover), 2, 1(title), 2, i(index), ii, 1, 2, 3, 4, …) and \the\c@page doesn’t give the absolute PDF page number.
I asked around for absolute page numbers, \theps@count not working for me because the inclusion of the package providing it broke the build with undefined references. I was told on Chat that recent enough LᴬTᴇΧ maintains an absolute page count; ltshipout documents them, and \ReadonlyShipoutCounter is the one to use here.
It’s a bit tricky to use, but good for our scenario: immediately after a \clearpage¹ it’s the absolute page number of the previous page, so we just add \@ne (one) to it but reuse the same algorithm.
① Use \clearpage, not \newpage, as the latter only terminates a column in multi-column typesetting and doesn’t flush out floats.
I’ve changed the algorithm in one more way: it outputs an extra blank page to ensure that the inside of the cover is always completely blank, so the code given now inserts 1‥4 blank pages.
% clear 1‥4 pages for the back cover
\clearpage% to flush out the previous page, if it isn’t yet
\pagestyle{empty}%
\null\clearpage% force one to be empty for inner back cover
% align outer back cover to multiple of 4
\makeatletter%
% \clearpage\ReadonlyShipoutCounter = abs page number of previous page
\count@=\ReadonlyShipoutCounter%
\advance\count@\@ne% number of the current page
% modulo 4
\@tempcnta=\count@%
\divide\@tempcnta by 4%
\multiply\@tempcnta by 4%
\count@=\numexpr\count@-\@tempcnta\relax%
% if modulo is not 0, align to multiple of 4…
\ifnum\count@>0%
% by inserting (4-modulo) empty pages
\loop\ifnum\count@<4%
\null\clearpage%
\advance\count@\@ne%
\repeat%
\fi%
\makeatother%
% render outer back cover, for example:
\pagecolor{blue}\afterpage{\nopagecolor}%
\AddToShipoutPictureFG*{\AtPageUpperLeft{%
% other half of the coloured background
\put(0mm,-100mm){%
\color{green}%
\rule{\paperwidth}{100mm}%
}%
}}%
\null\clearpage% force out back cover
~\newpageif necessary. – Ulrike Fischer Aug 26 '13 at 08:26\if{\getpagerefnumber{\thispage}\modulo4\equals3}{\clearpage}thrice and be done with it, no? – towi Aug 26 '13 at 09:08