[LyX/2.4.x] Protect \inputencoding in i18npreamble

Juergen Spitzmueller spitz at lyx.org
Mon Oct 7 07:36:18 UTC 2024


commit fd6f8c28c33b6c3c07723adede5eeffed0770236
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sun Oct 6 16:23:05 2024 +0200

    Protect \inputencoding in i18npreamble
    
    as it might end up in a moving argument (\lstlistlistingname in book
    classes).
    
    See https://marc.info/?l=lyx-devel&m=172812937932740
    
    (cherry picked from commit a16e4b206a429ad2ef562446b2e535779e4905e5)
---
 src/LaTeXFeatures.cpp | 4 +++-
 status.24x            | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index 02164ef641..ab7c62c355 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -2032,7 +2032,9 @@ docstring const i18npreamble(docstring const & templ, Language const * lang,
 		else if (ascii_fallback)
 			translated = to_ascii(testenc->latexString(name).first);
 		else
-			translated = "\\inputencoding{" + texenc + "}"
+			// We need to \protect this as it can end up in a moving argument
+			// (\lstlistlistingname in book classes goes to \@mkboth via \contentsname)
+			translated = "\\protect\\inputencoding{" + texenc + "}"
 				+ s1 + langenc + s2 + to_utf8(name)
 				+ s1 + bufenc + s2;
 		preamble = subst(preamble, sub.str(), translated);
diff --git a/status.24x b/status.24x
index 278ef6774b..0b66cc7d48 100644
--- a/status.24x
+++ b/status.24x
@@ -61,6 +61,8 @@ What's new
 
 - Fix instant preview of lilypond snippets (bug 13103).
 
+- Fix LaTeX error with listings, book classes and utf8 encoding.
+
 
 * USER INTERFACE
 


More information about the lyx-cvs mailing list