Account for the trailing optional argument of \usepackage.

The full syntax is \usepackage[<options>]{<name>}[<min.date>]
even if this is not documented in my old Lamport's LaTeX book...
This commit is contained in:
Enrico Forestieri 2015-06-03 19:02:54 +02:00
parent 3c3cb777d6
commit 5998555743

View File

@ -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