[LyX/2.5.x] Amend 59509e2afa3f
Juergen Spitzmueller
spitz at lyx.org
Thu May 7 08:41:56 UTC 2026
commit 165b156924156759a5acf98e2fa5c479d8ea82f3
Author: Juergen Spitzmueller <spitz at lyx.org>
Date: Wed May 6 12:19:22 2026 +0200
Amend 59509e2afa3f
Consider custom color as well
(cherry picked from commit 0db69518726354f0448dc5654ba841d54aa0769f)
---
src/tex2lyx/Preamble.cpp | 23 +++++++++++++++++------
status.25x | 2 ++
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 70db5a5380..1543ce9ac2 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -3623,22 +3623,33 @@ void Preamble::parse(Parser & p, string const & forceclass,
if (t.cs() == "colorlet") {
string const color1 = p.getArg('{', '}');
string const color2 = p.getArg('{', '}');
- if (color1 == "document_fontcolor")
+ bool is_known_source_col = false;
+ if (color1 == "document_fontcolor") {
h_fontcolor = getLyXColor(color2, true);
- else if (color1 == "note_fontcolor")
+ is_known_source_col = true;
+ } else if (color1 == "note_fontcolor") {
h_notefontcolor = getLyXColor(color2, true);
- else if (color1 == "page_backgroundcolor")
+ is_known_source_col = true;
+ } else if (color1 == "page_backgroundcolor") {
h_backgroundcolor = getLyXColor(color2, true);
- else if (color1 == "shadecolor")
+ is_known_source_col = true;
+ } else if (color1 == "shadecolor") {
h_boxbgcolor = getLyXColor(color2, true);
- else if (theLaTeXColors().isLaTeXColor(color2)) {
+ is_known_source_col = true;
+ } else if (h_custom_colors.find(color2) != h_custom_colors.end()) {
+ // a known custom color
+ h_custom_colors[color1] = h_custom_colors[color2];
+ } else if (theLaTeXColors().isLaTeXColor(color2)) {
+ // check if the source is a known defined color
for (auto const & cc : theLaTeXColors().getLaTeXColors()) {
if (cc.first == color2) {
h_custom_colors[color1] = ltrim(cc.second.hexname(), "#");
+ is_known_source_col = true;
break;
}
}
- } else {
+ }
+ if (!is_known_source_col) {
h_preamble << "\\colorlet{" << color1
<< "}{" << color2 << '}';
}
diff --git a/status.25x b/status.25x
index 696d91883f..a5fb4c3716 100644
--- a/status.25x
+++ b/status.25x
@@ -24,6 +24,8 @@ What's new
* TEX2LYX IMPROVEMENTS
+- Add support for \colorlet if the second arg is a known LaTeX or custom
+ color (bug 13310).
* USER INTERFACE
More information about the lyx-cvs
mailing list