commit e333a0ac042fb0a42d9d53c75648db230e2d38b5
Author: Juergen Spitzmueller <[email protected]>
Date:   Fri Apr 25 17:51:56 2025 +0200

    Support (known) zref-clever and cleveref theorem refs (#13176)
---
 src/LaTeXFeatures.cpp | 33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 789b03b591..8443490820 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -1944,8 +1944,6 @@ string const LaTeXFeatures::getThmDefinitions() const
                if (thm.counter == "none")
                        tmp << "\\newtheorem*{" << thm.name << "}";
                else {
-                       if (params_.xref_package == "zref" && 
!thm.zrefname.empty() && thm.zrefname != "none")
-                               tmp << "\\zcsetup{countertype={" << thm.name << 
"=" << thm.zrefname << "}}\n";
                        tmp << "\\newtheorem{" << thm.name << "}";
                        if (!thm.counter.empty())
                                tmp << "[" << thm.counter << "]";
@@ -1957,6 +1955,37 @@ string const LaTeXFeatures::getThmDefinitions() const
                                tmp << "[" << thm.parent_counter << "]";
                }
                tmp << "\n";
+
+               // Extra definitions for zref-clever
+               if (thm.counter != "none" && params_.xref_package == "zref" && 
!thm.zrefname.empty() && thm.zrefname != "none") {
+                       if (thm.counter.empty())
+                               tmp << "\\zcsetup{countertype={" << thm.name << 
"=" << thm.zrefname << "}}\n";
+                       else {
+                               if (isAvailableAtLeastFrom("LaTeX", 2020, 10))
+                                       // we have hooks
+                                       tmp << "\\AddToHook{env/" << thm.name 
<< "/begin}"
+                                            << "{\\zcsetup{countertype={" << 
thm.counter << "=" << thm.zrefname << "}}}\n";
+                               else {
+                                       tmp << "\\let\\lyxsave" << thm.name << 
"\\" << thm.name << "\n";
+                                       tmp << "\\def\\" << thm.name
+                                           << "{\\zcsetup{countertype={" << 
thm.counter << "=" << thm.zrefname << "}}"
+                                           << "\\lyxsave" << thm.name << "}\n";
+                               }
+                       }
+               }
+               // or cleveref
+               else if (thm.counter != "none" && params_.xref_package == 
"cleveref" && !thm.counter.empty()) {
+                       if (isAvailableAtLeastFrom("LaTeX", 2020, 10))
+                               // we have hooks
+                               tmp << "\\AddToHook{env/" << thm.name << 
"/begin}"
+                                    << "{\\crefalias{" << thm.counter << "}{" 
<< thm.name << "}}\n";
+                       else {
+                               tmp << "\\let\\lyxsave" << thm.name << "\\" << 
thm.name << "\n";
+                               tmp << "\\def\\" << thm.name
+                                   << "{\\crefalias{" << thm.counter << "}{" 
<< thm.name << "}"
+                                   << "\\lyxsave" << thm.name << "}\n";
+                       }
+               }
        }
 
        return tmp.str();
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to