[LyX/2.5.x] tex2lyx: add support for \colorlet if the second arg is a known LaTeX color (#13310)

Juergen Spitzmueller <[email protected]> Thu, 07 May 2026 08:41:55 +0000
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit f659096c8ddc9f11da8281874425e56dac2fd729
Author: Juergen Spitzmueller <[email protected]>
Date:   Wed May 6 09:11:32 2026 +0200

    tex2lyx: add support for \colorlet if the second arg is a known LaTeX color (#13310)
    
    (cherry picked from commit 59509e2afa3f3fb3b12b6d89bf9c3096267b9ba4)
---
 src/tex2lyx/Preamble.cpp | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 1f95ec55d8..70db5a5380 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -17,6 +17,7 @@
 #include "tex2lyx.h"
 
 #include "Encoding.h"
+#include "LaTeXColors.h"
 #include "LaTeXPackages.h"
 #include "LayoutFile.h"
 #include "TextClass.h"
@@ -3630,7 +3631,14 @@ void Preamble::parse(Parser & p, string const & forceclass,
 				h_backgroundcolor = getLyXColor(color2, true);
 			else if (color1 == "shadecolor")
 				h_boxbgcolor = getLyXColor(color2, true);
-			else {
+			else if (theLaTeXColors().isLaTeXColor(color2)) {
+				for (auto const & cc : theLaTeXColors().getLaTeXColors()) {
+					if (cc.first == color2) {
+						h_custom_colors[color1] = ltrim(cc.second.hexname(), "#");
+						break;
+					}
+				}
+			} else {
 				h_preamble << "\\colorlet{" << color1
 				           << "}{" << color2 << '}';
 			}
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs