подраздел Pylatex
from pylatex import Document, Section, Subsection, Command
from pylatex.utils import italic, NoEscape
#...
with doc.create(Section('A section')):
doc.append('Some regular text and some ')
doc.append(italic('italic text. '))
with doc.create(Subsection('A subsection')):
doc.append('Also some crazy characters: $&#{}')
#...
Powerful Penguin