commit 35aa4bda311f0bde3293192e353a2401c4bf970a
Author: Enrico Forestieri <[email protected]>
Date: Fri Aug 1 21:13:10 2025 +0200
Account for unknown required packages
---
src/LaTeXFeatures.cpp | 19 ++++++++++++-------
src/LaTeXFeatures.h | 2 ++
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 3670dc26d7..bccc79ef64 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -775,7 +775,11 @@ bool LaTeXFeatures::isProvided(string const & name) const
bool LaTeXFeatures::mustProvide(string const & name) const
{
- return isRequired(name) && !isProvided(name);
+ if (isRequired(name) && !isProvided(name)) {
+ features_loaded_.insert(name);
+ return true;
+ }
+ return false;
}
@@ -1305,12 +1309,6 @@ string const LaTeXFeatures::getPackages() const
{
ostringstream packages;
- // FIXME: currently, we can only load packages and macros known
- // to LyX.
- // However, with the Require tag of layouts/custom insets,
- // also unknown packages can be requested. They are silently
- // swallowed now. We should change this eventually.
-
// Simple hooks to add things before or after a given "simple"
// feature. Useful if loading order matters.
map<string, string> before_simplefeature_;
@@ -1612,6 +1610,13 @@ string const LaTeXFeatures::getPackages() const
packages << "\\usepackage{microtype}\n";
}
+ // Account for unknown packages mentioned in the Require tag
+ // of layouts/custom insets
+ for (string const & name : features_) {
+ if (features_loaded_.find(name) == features_loaded_.end())
+ packages << "\\usepackage{" << name << "}\n";
+ }
+
return packages.str();
}
diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h
index 2d6fce25ca..2909a89e94 100644
--- a/src/LaTeXFeatures.h
+++ b/src/LaTeXFeatures.h
@@ -224,6 +224,8 @@ private:
Features features_;
/// Features that are provided
Features provides_;
+ /// Already accounted for features
+ mutable Features features_loaded_;
/// Static preamble bits, from external templates, or anywhere else
typedef std::list<TexString> SnippetList;
///
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs