Varioref and previous page

You understand varioref correctly, but cleveref overwrites some of its functions and does so incorrectly. It is a typical case of adding % characters to the end of every line and in some cases that is simply wrong.

The cleveref packages makes a modified copy of the command \@@vpageref that contained the lines

    \advance\@tempcnta-2
    \ifnum \thevpagerefnum =\@tempcnta

The redefinition turns this into

    \advance\@tempcnta-2%                 <--- wrong %
    \ifnum \thevpagerefnum =\@tempcnta%

As a result TeX expands the \ifnum while still looking for the finish of the number -2... instead of substracting 2 from \@tempcnta and then doing the test.

In other words: blindly adding % the the end of every line in a definition can be harmful (the one on the next line is also useless but does no harm).

So the best fix is to get cleveref corrected. Short term solution: you can repatch it like this:

\usepackage{etoolbox}
\makeatletter
\patchcmd\cref@old@@vpageref
{\advance\@tempcnta-2}
{\advance\@tempcnta-2 }{\typeout{patch ok}}{\ERRORpatchFaild}
\makeatother

Ugh. I think some time ago I got fed up with tracking down spurious spacing errors in cleveref, and ran the source through sed to add % at the ends of all lines. That was dumb. But then, so is TeX's whitespace handling.

@Frank Mittelbach: Thanks for taking the time to track this down. This should be fixed in version 0.19.3 now on my web site. The MWE from this question works, at least. I'll upload to CTAN after a bit more testing. (I added a \relax instead of removing the %, as it makes it slightly easier to track down spurious spaces if any more crop up in future.)

I fear there may be other similar bugs still lurking in cleveref, though.