Am Montag, dem 05.01.2026 um 15:02 +0100 schrieb Jean-Marc Lasgouttes:
> Does this ring a bell for someone?
Enumerate counters are not reset top what has been previously active
after the end of the enumeration.
The attached patch provides a (rather simple) fix. Probably we should
go for something more generalizable on layout level.
--
Jürgen
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index c7d765018f..80d5965b19 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5331,6 +5331,10 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
par.params().labelWidthString(docstring());
}
+ // restore previous counter after enumeration
+ if (layout.labeltype != LABEL_ENUMERATE && prefixIs(counters.currentCounter(), from_ascii("enum")))
+ counters.restoreLastCounter();
+
switch(layout.labeltype) {
case LABEL_ITEMIZE: {
par.params().labelString(
@@ -5342,6 +5346,12 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
}
case LABEL_ENUMERATE: {
+ // If we have a non-enumerate active counter, save it, since it needs
+ // to be restored after the enumeration
+ if (!counters.currentCounter().empty()
+ && !prefixIs(counters.currentCounter(), from_ascii("enum")))
+ counters.saveLastCounter();
+
docstring enumcounter = layout.counter.empty() ? from_ascii("enum") : layout.counter;
switch (par.itemdepth) {
diff --git a/src/Counters.cpp b/src/Counters.cpp
index a93274558a..f6ce5eeac7 100644
--- a/src/Counters.cpp
+++ b/src/Counters.cpp
@@ -490,6 +490,14 @@ bool Counters::remove(docstring const & cnt)
}
+void Counters::restoreLastCounter()
+{
+ counter_stack_.pop_back();
+ if (counter_stack_.empty())
+ counter_stack_.push_back(from_ascii(""));
+}
+
+
docstring Counters::labelItem(docstring const & ctr,
docstring const & numbertype) const
{
diff --git a/src/Counters.h b/src/Counters.h
index d522a7b757..d69cce60ce 100644
--- a/src/Counters.h
+++ b/src/Counters.h
@@ -244,7 +244,7 @@ public:
void saveLastCounter()
{ counter_stack_.push_back(counter_stack_.back()); }
///
- void restoreLastCounter() { counter_stack_.pop_back(); }
+ void restoreLastCounter();
// @}
///
std::vector<docstring> listOfCounters() const;
--
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel