]> git.lyx.org Git - features.git/commitdiff
Account for the trailing optional argument of \usepackage.
authorEnrico Forestieri <forenr@lyx.org>
Wed, 3 Jun 2015 17:02:54 +0000 (19:02 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 3 Jun 2015 17:02:54 +0000 (19:02 +0200)
The full syntax is \usepackage[<options>]{<name>}[<min.date>]
even if this is not documented in my old Lamport's LaTeX book...

lib/scripts/lyxpreview2bitmap.py

index 8aaaaaf56b6fced8c0f4bab0744bbea7056bc0e9..3e055429eb60f3edfac025ba688e46d386269eb8 100755 (executable)
@@ -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