Firstly, thank you all for your suggestions.
All your interesting replies led me to this conclusion:
- in most cases, it is enough to make some local adjustments in each line
containing page-numbers or page-number-citations;
- sometimes, when a particularly elegant output is needed, it would really
be desirable to have a two-steps algorithm, with line-breaking performed
again once the actual width of each object is known.
So, I'll start implementing the "general purpose" solution, storing the
needed information inside an object (rather than directly as new
attributes of areas) so as to reduce memory usage.
Regards
Luca