Just to add that amsmath also has a mechanism for dealing with the similar problem of ‘multi-pass processing'
that happens when \mathchoice is used.

Of course, the most general solution, for the future, would be to move to:

  Full separation of ‘text input’ (data, pure character strings) from ‘tags’ 
  (non-typesetting process directions, typesetting hints, etc), so that 
      Only the Text gets Typeset — Always      ** The OTTA Principle.

Cheers,  chris 

> From: Heiko Oberdiek <[log in to unmask]>
>To: [log in to unmask] 
>Sent: Sunday, 8 January 2012, 11:46
>Subject: Re: trial typesetting support
>On Sun, Jan 08, 2012 at 11:07:30AM +0000, David Carlisle wrote:
>> On 08/01/2012 10:32, Frank Mittelbach wrote:
>> >I just had a look into the following question on TeX.sx:
>> >
>> >http://tex.stackexchange.com/questions/40330/centered-captions-containing-vref-may-not-always-appear-as-expected
>> >
>> >Anybody some good ideas how to address topic this in a general fashion?
>> >
>> Not really, but tabularx has to play this game a lot
>Another player is amsmath. It needs to know the width of the
>equations in order to know where to put the equation number
>(e.g. below the equation if there is no place in the same line).
>The measuring is done in macro \gmeasure@, it sets the switch
>\ifmeasuring@ to true.
>A more general mechanism would be nice, then a package
>can disable some stuff (e.g. writing to .aux files) in
>trial runs without knowing and supporting all the packages
>that uses trials.
>Elements of that feature could be:
>* A trial switch or something like that.
>  If the trial switch is available and turned on, then the
>  macros can automatically disable some stuff not needed in the
>  trial.
>* A possibility to record undo steps in a hook that is called
>  after the trial. A group resets the state for local assignments.
>  But that does not work for global settings of counters. Or
>  if a acronym macro expands the acronym in the first use und
>  uses the short form in later uses. After the trial the acronym
>  should be reset to the state before the trial.
>Also there might be differnt purposes of the trial that might
>require different steps for suppressing or undoing:
>* Measurement (amsmath, ...)
>* ...?
>Yours sincerely
>  Heiko Oberdiek