[LyX/2.5.x] Prevent duplicate theorem definitions (#13302)
Juergen Spitzmueller <[email protected]> Thu, 23 Apr 2026 16:46:16 +0000
| Newsgroups | gmane.editors.lyx.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit 2d2d226820b0bcdc918fef22e45d54adf21dbe8a Author: Juergen Spitzmueller <[email protected]> Date: Thu Apr 23 10:27:34 2026 +0200 Prevent duplicate theorem definitions (#13302) If theorems are multiply defined, use the last definition. (cherry picked from commit e2baf31523f55b163bf79bdaeaa82ba090c47118) --- lib/layouts/theorems-starred-equivalents.inc | 24 ------------------------ src/LaTeXFeatures.cpp | 8 ++++---- src/LaTeXFeatures.h | 2 +- status.25x | 2 ++ 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/lib/layouts/theorems-starred-equivalents.inc b/lib/layouts/theorems-starred-equivalents.inc index 36d40206ac..20d5bbbe46 100644 --- a/lib/layouts/theorems-starred-equivalents.inc +++ b/lib/layouts/theorems-starred-equivalents.inc @@ -6,83 +6,59 @@ Format 111 Style Theorem CopyStyle Theorem* DependsOn Theorem* - Preamble - EndPreamble End Style Corollary CopyStyle Corollary* DependsOn Corollary* - Preamble - EndPreamble End Style Lemma CopyStyle Lemma* DependsOn Lemma* - Preamble - EndPreamble End Style Proposition CopyStyle Proposition* DependsOn Proposition* - Preamble - EndPreamble End Style Conjecture CopyStyle Conjecture* DependsOn Conjecture* - Preamble - EndPreamble End Style Definition CopyStyle Definition* DependsOn Definition* - Preamble - EndPreamble End Style Example CopyStyle Example* DependsOn Example* - Preamble - EndPreamble End Style Solution CopyStyle Solution* DependsOn Solution* - Preamble - EndPreamble End Style Problem CopyStyle Problem* DependsOn Problem* - Preamble - EndPreamble End Style Exercise CopyStyle Exercise* DependsOn Exercise* - Preamble - EndPreamble End Style Remark CopyStyle Remark* DependsOn Remark* - Preamble - EndPreamble End Style Claim CopyStyle Claim* DependsOn Claim* - Preamble - EndPreamble End diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp index 8b26943070..72b3e79dc7 100644 --- a/src/LaTeXFeatures.cpp +++ b/src/LaTeXFeatures.cpp @@ -702,7 +702,7 @@ void LaTeXFeatures::useLayout(docstring const & layoutname, int level) thm.style = layout.thmStyle(); thm.zrefname = layout.thmZRefName(); thm.refprefix = to_ascii(layout.refprefix); - usedTheorems_.push_back(thm); + usedTheorems_[thm.name] = thm; require("amsthm"); } usedLayouts_.push_back(layoutname); @@ -2010,8 +2010,8 @@ string const LaTeXFeatures::getThmDefinitions() const ostringstream tmp; string laststyle; - for (auto const & thm : usedTheorems_) { - if (isProvided("newtheorem:" + thm.name)) + for (auto const & [name, thm] : usedTheorems_) { + if (isProvided("newtheorem:" + name)) continue; if (thm.style != laststyle) { tmp << "\\theoremstyle{" << thm.style << "}\n"; @@ -2042,7 +2042,7 @@ string const LaTeXFeatures::getThmExtraDefinitions() const { ostringstream tmp; - for (auto const & thm : usedTheorems_) { + for (auto const & [name, thm] : usedTheorems_) { if (thm.counter == "none") continue; diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index f420c3286a..5ccc014f3b 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -249,7 +249,7 @@ private: /// UsedFloats usedFloats_; /// - std::list<ThmInfo> usedTheorems_; + std::map<std::string, ThmInfo> usedTheorems_; /// typedef std::map<docstring, std::string> FileMap; /// diff --git a/status.25x b/status.25x index a339e241e4..153b77c929 100644 --- a/status.25x +++ b/status.25x @@ -47,6 +47,8 @@ What's new - Fix problem with nesting of languages. +- Prevent duplicate theorem definitions (bug 13302). + * USER INTERFACE -- lyx-cvs mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-cvs