Re: How to do Conditional Formatting?
Valeriy E. Ushakov <uwe <at> stderr.spb.ru>
2012-06-08 03:41:29 GMT
On Thu, Jun 07, 2012 at 15:44:53 -0700, Michael Koehmstedt, RenPet wrote:
> I'm at a loss at how I can write a <at> Case statement that will print the
> table on the first-run, gather the page numbers, and on the 2nd run test
> whether it fit on the current page. I have grown up using programming
> languages where everything is done in one pass, so that is where the
> conceptual problem is coming from.
Don't think in terms of if-then-else. Print *both* objects, but make
the "See next page" one empty if the main object fits.
print(table on next page ? "See next page" : "");
On the first run "if (table on next page)" is false since lout doesn't
know page number of the table yet, so the first object is empty.
The second object is printed and either does or doesn't fit the page.
On the second run "table on next page" is checked.
If on the first run the table did fit, the code doesn't print anything
(again) and the real table is again printed (and fits). The process
If on the first run the table didn't fit, you know now, so the code
prints "See...". It then prints the table that still doesn't fit and
goes to the next page. The process converged.
In theory you can get a process like that, that flip-flops between two
states and never converges, or converges to a wrong state. In your
case you should be careful to only print "See..." when you know the
table is on the next page. Potential race would be like this:
1) a table that would just barely fit
2) you print "See..." on the first run
3) with that "See..." in place the table no longer fits
In that case the process will converge to a wrong state: "See..." is
printed and the table is on the next page, even though without
"See..." it would fit.
This can be triggered if you are not careful in step #2 above. On the
first run lout doesn't know (some) page numbers, so you may end up
comparing "??" with "??" (where "??" is substituted for unresolvable
cross-references) unless you are careful in spelling out that "table
on next page" condition.
> On Wed, Jun 6, 2012 at 7:35 PM, Pierre <pierre.lesimple <at> mcgill.ca> wrote:
> > **
> > I must be missing something again, but "running Lout twice on the same
> > document." in that context sounds conceptually easy enough, if not
> > automated.
> > There must be some misunderstanding.
> > On 2012-06-06 19:12, Michael Koehmstedt, RenPet wrote:
> > Well, I think I must admit defeat at this point. My conceptual
> > understanding of Lout is just too limited to figure out how to do this even
> > after hours of trying. I'm not even sure what kind of questions to ask
> > really...Jeff, you thought it would be a fun exercise to come up with this,
> > so I think this might be a good opportunity :) Otherwise, I am going to
> > need some more explicit guidance on how this might be done.
> > What I'm looking for is to be able to invoke something like:
> > object.tag <at> CanFitOnCurrentPage optional.object.tag
> > where if object.tag can fit on the current page it prints that, and if it
> > can't fit on the current page it prints the optional.object.tag (with an
> > empty object being the default).
> > Much appreciated,
> > Michael
> > On Fri, Jun 1, 2012 at 10:10 PM, Jeff Kingston <jeff <at> it.usyd.edu.au>wrote:
> >> > *The big question is, if I have to print Table1 to figure out what page
> >> it
> >> > ends up on, how can I "unprint" it and print the alternate Table
> >> instead?*
> >> By running Lout twice on the same document.
> >> Jeff