[Tex/LaTex] pylatex Change Font

pylatexpython

How do I change the font to "helvetica" in pylatex ?

I tried it, but this does not worK:

doc = pylatex.Document(fontenc = 'helvet')

Best Answer

You can add stuff to your preamble using doc.preamble.append(). To add helvet to your preamble use:

doc.preamble.append(Command('usepackage', 'helvet'))

This needs

from pylatex import Command

to work out, if you imported pylatex and not only submodules and functions from it, use pylatex.Command instead.

From what I gathered by a quick look on the documentation of pylatex you might be able to add arbitrary stuff to your document (making a horizontal line possible) by doing:

from pylatex.utils import NoEscape

and then

doc.append(NoEscape(r'\hrule')) # or whichever macro you want to use for your horizontal line

I'm not sure what NoEscape is needed for, perhaps it isn't needed, but I can't try because I don't have pylatex installed.

Related Question