commit c78ade8a387535eb28bd07fb9adfdaff19bc41d4
Author: Juergen Spitzmueller <[email protected]>
Date:   Sat Aug 9 18:37:36 2025 +0200

    tex2lyx: Minimize package option clashes with babel in user preamble
---
 src/tex2lyx/Preamble.cpp                | 3 ++-
 src/tex2lyx/test/tabular-x-test.lyx.lyx | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index fbcb0bfb91..7f446bd75f 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -2075,7 +2075,8 @@ void Preamble::handle_package(Parser &p, string const & 
name,
                                // perhaps in future others.
                                // Therefore keep the babel call as it is as 
the user might have
                                // reasons for it.
-                               string const babelcall = "\\usepackage[" + opts 
+ "]{babel}\n";
+                               // But use \PassOptionsToPackage to avoid 
clashes.
+                               string const babelcall = 
"\\PassOptionsToPackage{"+ opts + "}{babel}\n\\usepackage{babel}\n";
                                if (!contains(h_preamble.str(), babelcall))
                                        h_preamble << babelcall;
                        }
diff --git a/src/tex2lyx/test/tabular-x-test.lyx.lyx 
b/src/tex2lyx/test/tabular-x-test.lyx.lyx
index 430e238674..81f63f8682 100644
--- a/src/tex2lyx/test/tabular-x-test.lyx.lyx
+++ b/src/tex2lyx/test/tabular-x-test.lyx.lyx
@@ -13,7 +13,8 @@
 
 
 
-\usepackage[english]{babel}
+\PassOptionsToPackage{english}{babel}
+\usepackage{babel}
 
 \end_preamble
 \use_default_options false
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to