From 5998555743811cf51e406061723d53a05cf685c3 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Wed, 3 Jun 2015 19:02:54 +0200 Subject: [PATCH] Account for the trailing optional argument of \usepackage. The full syntax is \usepackage[]{}[] even if this is not documented in my old Lamport's LaTeX book... --- lib/scripts/lyxpreview2bitmap.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/scripts/lyxpreview2bitmap.py b/lib/scripts/lyxpreview2bitmap.py index 8aaaaaf56b..3e055429eb 100755 --- a/lib/scripts/lyxpreview2bitmap.py +++ b/lib/scripts/lyxpreview2bitmap.py @@ -193,8 +193,10 @@ def fix_latex_file(latex_file, pdf_output): tmp.write("\\def\\t@a{microtype}\n") tmp.write("\\let\\oldusepkg\\usepackage\n") tmp.write("\\def\\usepackage{\\@ifnextchar[\\@usepkg{\\@usepkg[]}}\n") - tmp.write("\\def\@usepkg[#1]#2{\\def\\t@b{#2}") - tmp.write("\\ifx\\t@a\\t@b\\else\\oldusepkg[#1]{#2}\\fi}\n") + tmp.write("\\def\\@usepkg[#1]#2{\\@ifnextchar[") + tmp.write("{\\@@usepkg[#1]{#2}}{\\@@usepkg[#1]{#2}[]}}\n") + tmp.write("\\def\@@usepkg[#1]#2[#3]{\\def\\t@b{#2}") + tmp.write("\\ifx\\t@a\\t@b\\else\\oldusepkg[#1]{#2}[#3]\\fi}\n") tmp.write(line) continue -- 2.39.5