[Tex/LaTex] Changing font size mid document with pylatex

fontsfontsizepython

I'm trying to change a font size at some arbitrary point in my document, and I'm using pylatex to create the file. I've gotten it to change manually by putting after the header:

\begin{document}%
\fontsize{15}{12}\selectfont

However when pylatex creates the file it puts in:

\begin{document}%
\normalsize%
\fontsize{15}{12}%

I've manually tested it by taking our \normalsize% and the font changes. How do I get rid of `normalsize? Also, is there a better way to do this?

Here's my code:

    doc = pylatex.Document('basic',inputenc = 'utf8x', lmodern = False, fontenc = None, textcomp = None)
    packages = [Package('babel', options = ['english', 'hebrew']), Package('inputenc', options = 'utf8enc')]
    doc.packages.append(Package('babel', options = ['english', 'hebrew']))
    doc.preamble.append(pylatex.Command('selectlanguage', 'hebrew'))
    doc.append(pylatex.Command('fontsize', arguments = ['15', '12']))
    doc.append(text[0].decode('utf-8'))
    doc.append(pylatex.Command('selectlanguage', 'english')) 
    doc.append(text[1].decode('utf-8'))
    doc.generate_pdf(clean_tex=False, compiler = "pdflatex ")
    doc.generate_tex()

Best Answer

You need to change the pylatex.Document arguments to:

doc = pylatex.Document('basic',font_size = '', inputenc = 'utf8x', lmodern = False, fontenc = None, textcomp = None)

in order to remove the normalsize line.

To put the fontselect in place a command for it after the command for fontsize like this:

doc.append(pylatex.Command('fontsize', arguments = ['15', '12']))
doc.append(pylatex.Command('selectfont'))

The font size will then be 15.