Martin Vermeer wrote:

On Sat, Jan 21, 2006 at 02:09:29AM +0100, Helge Hafting wrote:
Create a memoir document.
Insert a figure float, with picture and caption.
Mark everything inside the float, insert a minipage.
Observe that the lyx GUI now call the caption "meaningless"
instead of the usual "Figure #".  It is as if a caption somehow
was entered outside a float (where they are meanlingless.)

This is wrong, for latex have no problem with this. There are two common reasons for doing this:
1. want to tweak caption placement a bit
2. want to have several captions in a float, e.g. in order to
  seemingly have two floating figures side by side. This is a
  common trick which used to work well.

Something screwed up in the detection of whether or not the caption
ultimately is inside a float?

Weird... this ought to work right. The code is in buffer_funcs.C:

   471         } else if (layout->labeltype == LABEL_SENSITIVE) {
   472                 // Search for the first float or wrap inset in the 
iterator
   473                 string type;
   474                 size_t i = it.depth();
   475                 while (i > 0) {
   476                         --i;
   477                         InsetBase * const in = &it[i].inset();
   478                         if (in->lyxCode() == InsetBase::FLOAT_CODE
   479                             || in->lyxCode() == InsetBase::WRAP_CODE)
   480                                 type = in->getInsetName();
   481                                 break;
   482                 }
   483
   484                 string s;
   485                 if (!type.empty()) {
   486                         Floating const & fl = 
textclass.floats().getType(type);
   487
   488                         counters.step(fl.type());
   489
   490                         // Doesn't work... yet.
   491                         s = bformat(_("%1$s #:"), buf.B_(fl.name()));
   492                 } else {

As you see, it searches the cursor stack in the "outward" direction for a
Float or Wrap inset, happily using the first it finds... could you add
debug instrumentation (lyxerr) to this code to see what really happens?
No need for instrumentation, I see something very suspicious here.

Your "while" loop will always break on the first iteration, because
your if-statement does _not_ use {} and is followed by a break.
I added the missing {}, a tested patch is attached.

I hope this can go in as a trivial/obvious fix.

Test results:
1. label inside a float is still ok
2. label inside minipage inside float is now ok too
3. label inside 2 & 3 levels of minipages inside a float is now ok too
4. label inside one or more minipages not in a float is still meaningless, as it should.

Helge Hafting

? buffer_funcs.diff
? frontends/gnome/.deps
? frontends/gnome/Makefile
? frontends/gnome/Makefile.in
? mathed/math_nestinset.C.testing
Index: ChangeLog
===================================================================
RCS file: /var/cvs/lyx/lyx-devel/src/ChangeLog,v
retrieving revision 1.2359
diff -u -p -u -r1.2359 ChangeLog
--- ChangeLog   19 Jan 2006 21:18:23 -0000      1.2359
+++ ChangeLog   23 Jan 2006 09:59:46 -0000
@@ -1,3 +1,8 @@
+2006-01-23  Helge Hafting <[EMAIL PROTECTED]>
+       * buffer_funcs.C: Trivial fix - added {} around
+         the statements to be affected by a if-test. Now
+         label in a minipage in a float looks ok on screen again.
+
 2006-01-11  Georg Baum  <[EMAIL PROTECTED]>
 
        * converter.C (convert): handle unknown formats
Index: buffer_funcs.C
===================================================================
RCS file: /var/cvs/lyx/lyx-devel/src/buffer_funcs.C,v
retrieving revision 1.35
diff -u -p -u -r1.35 buffer_funcs.C
--- buffer_funcs.C      29 Nov 2005 13:39:03 -0000      1.35
+++ buffer_funcs.C      23 Jan 2006 09:59:46 -0000
@@ -476,9 +476,10 @@ void setCounter(Buffer const & buf, ParI
                        --i;
                        InsetBase * const in = &it[i].inset();
                        if (in->lyxCode() == InsetBase::FLOAT_CODE
-                           || in->lyxCode() == InsetBase::WRAP_CODE)
+                           || in->lyxCode() == InsetBase::WRAP_CODE) {
                                type = in->getInsetName();
                                break;
+      }
                }
 
                string s;

Reply via email to