def make_preamble(dolidoc, issue, date): assert isinstance(dolidoc, Document) assert isinstance(issue, int) assert isinstance(date, datetime.datetime) # packages dolidoc.packages.pop() # to remove stupid package lastpage added by pylatex # preamble itself dolidoc.preamble.append(Command("currentissue", issue)) # substitute correct values dolidoc.preamble.append(Command("currentyear", date.year)) dolidoc.preamble.append(Command("currentmonth", date.month)) dolidoc.preamble.append(Command("currentday", date.day)) dolidoc.preamble.append(Command("titleformat", options='block', arguments=Command("section"), extra_arguments=Arguments(NoEscape(r"\large\bfseries\filcenter"), Command("thesection"), Command("1em"), Command("MakeUppercase")))) dolidoc.preamble.append(Command('title', 'Diário Oficial (preview)')) return dolidoc