[l2h] Figure/Table numbering patch(?)

Bruce Miller bruce.miller@nist.gov
Sun, 25 Nov 2001 23:32:27 -0500

Hi Ross, Hi everybody;
   While processing a batch of documents from other authors,
I was really reluctant to insert all the \protect's throughout
the math in the figure & table captions, so I started looking
for alternatives.  What I worked out seems too simple, so I
must be missing something.... but please consider.

The first problem I was encountering was that the math being
sucked in from the aux file was full of @ (eg \@mathrm, presumably
because of various ams & other packages involved?, but at any rate,
inside aux, @ is a valid letter).  This caused the latex of images.tex
to fail.

Although do_cmd_makeatletter and do_cmd_makeatother are called
around the processing of the aux file, that isn't reflected in
images.tex.  My proposed patch is to add the lines
   $latex_body .= "\\makeatletter";
   $latex_body .= "\\makeatother";
to those two subs.

That patch, of course, leads to the next problem (which I would have had
even if images.tex had suceeded): the captions no longer `match' so that
l2h can't find the appropriate figure or table numbers.  It turns out that
figure & table counters are never used.  A couple of minor changes to
sub extract_captions seems to fix it:

     my $sid = ++$global{'max_id'};

just ahead of the "foreach $key (sort ...." loop.  And inside the
loop, just before the "&write_warnings(qq|\nNo number ..." put:
	  $number= translate_commands("\\the$env"); }

This, of course, falls back to numbering internal to l2h, so at least in the
cases where the number can't be found, it wont automatically inherit the
numbering format from the latex style. OTOH, it does respect any
definitions of \thetable or \thefigure. OTTH (on the third hand :>),
I'm a bit ambivalent about that approach anyway; it's caused me at least as
much grief as benefit.

If you'd prefer a diff, or something, let me know...