Attached the patch posted on Bugzilla that makes the caption in table and figure insets slightly better behaved. It covers the most common use cases.
As correctly remarked on Bugzilla, this is something that many starting LyX users stumble on. This bug was classified as major and retargeted for 1.5.0. A proper fix, by switching to caption inset, is not an option now during the freeze. OK to commit? - Martin
Index: text.C =================================================================== --- text.C (revision 13790) +++ text.C (working copy) @@ -1068,6 +1068,13 @@ void LyXText::breakParagraph(LCursor & c // we need to set this before we insert the paragraph. bool const isempty = cpar.allowEmpty() && cpar.empty(); + // Prepare for placing caption based on inset position: + bool const captionbelow = cur.pos() > 0 + && cpar.isInset(0) && !cpar.getInset(0)->isChar(); + bool const captionabove = cur.pos() < cur.lastpos() + && cpar.isInset(cur.pos()) + && !cpar.getInset(cur.pos())->isChar(); + lyx::breakParagraph(cur.buffer().params(), paragraphs(), cpit, cur.pos(), preserve_layout); @@ -1076,13 +1083,22 @@ void LyXText::breakParagraph(LCursor & c cpit = cur.pit(); pit_type next_par = cpit + 1; - // well this is the caption hack since one caption is really enough + // The caption hack. One caption is enough, and we place it under the + // existing inset if breaking to the right of it, and above the inset + // if breaking to the left of it. If no inset exists yet, we open up a + // standard paragraph for inserting an inset, cf. paragraph_funcs.C. + // (MV) if (sensitive) { - if (cur.pos() == 0) - // set to standard-layout + // set the non-caption stuff to standard-layout and + // captions to caption layout + if (captionbelow) { + pars_[next_par].applyLayout(pars_[cpit].layout()); pars_[cpit].applyLayout(tclass.defaultLayout()); - else - // set to standard-layout + } else if (captionabove) { + pars_[cpit].applyLayout(pars_[next_par].layout()); + pars_[next_par].applyLayout(tclass.defaultLayout()); + } else if (cur.pos() != 0) + // Suppress double captions: pars_[next_par].applyLayout(tclass.defaultLayout()); }
signature.asc
Description: This is a digitally signed message part