]> git.lyx.org Git - lyx.git/commitdiff
Protect \inputencoding in i18npreamble
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 6 Oct 2024 14:23:05 +0000 (16:23 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 6 Oct 2024 14:23:05 +0000 (16:23 +0200)
as it might end up in a moving argument (\lstlistlistingname in book
classes).

See https://marc.info/?l=lyx-devel&m=172812937932740

src/LaTeXFeatures.cpp

index 7ce7966bba235cea23ad232c1a2eb0dbf9b51fbe..dc939f0921b8406a2d13e23c178e88f1ca0e15ad 100644 (file)
@@ -2040,7 +2040,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);