commit fb057d73b9c9199fce11355eda8bbe0035a92714
Author: Juergen Spitzmueller <[email protected]>
Date:   Tue Aug 26 08:18:00 2025 +0200

    refstyle: fixup the fallback for "cha" prefix
    
    Simple \let does not work
---
 src/LaTeXFeatures.cpp   | 13 +++++++++++++
 src/insets/InsetRef.cpp |  4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index ee3db69ca3..05f4f48362 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -1814,6 +1814,19 @@ TexString LaTeXFeatures::getMacros() const
        // floats
        getFloatDefinitions(macros);
 
+       if (mustProvide("refstyle:charef")) {
+               // this is not provided by the package, but we use the prefix
+               // copy the definition is a copy of chapref
+               macros << "\\RS@ifundefined{charef}{\n"
+                      << "  \\newref{cha}{%\n"
+                      << "         refcmd    = 
{{\\let\\chpname=\\RS@chpname\\ref{#1}}},\n"
+                      << "         rngtxt    = \\RSrngtxt,\n"
+                      << "         lsttwotxt = \\RSlsttwotxt,\n"
+                      << "         lsttxt    = \\RSlsttxt}\n"
+                      << "}{}\n"
+                      << '\n';
+       }
+
        if (mustProvide("refstyle:subsecref")) {
                // this is not provided by the package, but we use the prefix
                // the definition is a copy of secref
diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index a39dbed7e5..8bb5aad578 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -983,8 +983,8 @@ void InsetRef::validate(LaTeXFeatures & features) const
                        getFormattedCmd(data, label, prefix, 
buffer().masterParams().xref_package, use_caps, useRange());
                if (buffer().masterParams().xref_package == "refstyle") {
                        features.require("refstyle");
-                       if (prefix == "cha")
-                               
features.addPreambleSnippet(from_ascii("\\let\\charef=\\chapref"));
+                       if (prefix == "cha" || prefix == "Cha")
+                               features.require("refstyle:charef");
                        else if (prefix == "subsec" || prefix == "Subsec")
                                features.require("refstyle:subsecref");
                        else if (prefix == "enu" || prefix == "Enu")
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to