Options in documentclass in pylatex
4,010
Constructor Document
does not support options for the document class. However, the documentclass
is available as Command
and can be overwritten:
doc = Document('basic')
doc.documentclass = Command(
'documentclass',
options=['12pt', 'landscape'],
arguments=['article'],
)
Also a package like geometry
can be added, see the following example, which was derived from the basic and full example of the documentation of pylatex
:
#!/usr/bin/env python
from pylatex import Document, Section, Subsection, Package, Command
from pylatex.utils import italic, NoEscape
def fill_document(doc):
"""Add a section, a subsection and some text to the document.
:param doc: the document
:type doc: :class:`pylatex.document.Document` instance
"""
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: $&#{}')
if __name__ == '__main__':
# Basic document
doc = Document('basic')
doc.documentclass = Command(
'documentclass',
options=['12pt', 'landscape'],
arguments=['article'],
)
fill_document(doc)
doc.packages.append(Package('geometry',
options=['a6paper', 'showframe']))
doc.generate_pdf(clean_tex=False)
doc.generate_tex()
Related videos on Youtube
Author by
966996
Updated on January 03, 2020Comments
-
966996 almost 4 years
I do not understand the documentation of
pylatex
. I'm usingpylatex
.How do I change the page orientation and font size?