Am Samstag, dem 22.11.2025 um 12:45 +0300 schrieb [email protected]:
> The behavior is different with color amstext, as they do not go away
> by saving and re-opening.

amstext is not a color, and it is loaded since your math uses \text.
This is principally correct, since the command is provided by this
package.

On the other hand, if amsmath is loaded, this will also load amstext
internally, so we do not need to load the package in that case
ourselves.

Looking closer, this is also what we attempt.
However, the new method
LaTeXFeatures::getUnknownPackages()
loads it then since it never gets added to features_loaded_.

The attached patch would fix this, but there are probably more cases
like this (maybe the geometry case has the same cause), so I wonder if
the problem should rather be fixed in getUnknownPackages() which should
really only load _unknown_ packages, not all required packages not
loaded so far.

As to geometry: LaTeXFeatures::isProvided() does not add a package to
features_loaded_ if it is provided. This might be the reason for it to
be loaded when it shouldn't.

Enrico?

-- 
Jürgen
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index b854a4f4c7..718a295bd6 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -2085,15 +2085,15 @@ string const LaTeXFeatures::loadAMSPackages() const
 	ostringstream tmp;
 
 	if (mustProvide("amsmath")
-	    && params_.use_package("amsmath") != BufferParams::package_off) {
+	    && params_.use_package("amsmath") != BufferParams::package_off)
 		tmp << "\\usepackage{amsmath}\n";
-	} else {
-		// amsbsy and amstext are already provided by amsmath
-		if (mustProvide("amsbsy"))
-			tmp << "\\usepackage{amsbsy}\n";
-		if (mustProvide("amstext"))
-			tmp << "\\usepackage{amstext}\n";
-	}
+
+	// amsbsy and amstext are already provided by amsmath
+	if (mustProvide("amsbsy") && !mustProvide("amsmath"))
+		tmp << "\\usepackage{amsbsy}\n";
+	if (mustProvide("amstext") && !mustProvide("amsmath"))
+		tmp << "\\usepackage{amstext}\n";
+
 
 	if (mustProvide("amsthm"))
 		tmp << "\\usepackage{amsthm}\n";
-- 
lyx-devel mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to