Fix caption counter in longtables (see #8993).

This commit is contained in:
Juergen Spitzmueller 2014-02-25 08:00:43 +01:00
parent 4066d3818e
commit e359d8f5ca
3 changed files with 17 additions and 3 deletions

View File

@ -172,6 +172,10 @@ public:
bool isSubfloat() const { return subfloat_; }
/// Set the state variable indicating whether we are in a subfloat.
void isSubfloat(bool s) { subfloat_ = s; }
/// Are we in a longtable?
bool isLongtable() const { return longtable_; }
/// Set the state variable indicating whether we are in a longtable.
void isLongtable(bool s) { longtable_ = s; }
/// \name refstepcounter
// @{
@ -225,6 +229,8 @@ private:
std::string current_float_;
/// Are we in a subfloat?
bool subfloat_;
/// Are we in a longtable?
bool longtable_;
/// Used to keep track of active counters.
std::vector<docstring> counter_stack_;
/// Same, but for last layout.

View File

@ -404,6 +404,8 @@ void InsetCaption::updateBuffer(ParIterator const & it, UpdateType utype)
docstring const labelstring = isAscii(lstring) ?
master.B_(to_ascii(lstring)) : lstring;
if (cnts.hasCounter(counter)) {
// for longtables, we step the counter upstream
if (!cnts.isLongtable())
cnts.step(counter, utype);
sec = cnts.theCounter(counter, lang);
}

View File

@ -3897,8 +3897,12 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
// In a longtable, tell captions what the current float is
Counters & cnts = buffer().masterBuffer()->params().documentClass().counters();
string const saveflt = cnts.current_float();
if (tabular.is_long_tabular)
if (tabular.is_long_tabular) {
cnts.current_float("table");
// in longtables, we only step the counter once
cnts.step(from_ascii("table"), utype);
cnts.isLongtable(true);
}
ParIterator it2 = it;
it2.forwardPos();
@ -3907,8 +3911,10 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
buffer().updateBuffer(it2, utype);
//reset afterwards
if (tabular.is_long_tabular)
if (tabular.is_long_tabular) {
cnts.current_float(saveflt);
cnts.isLongtable(false);
}
}