Back to snippets
pylatex_basic_document_with_sections_and_pdf_generation.py
pythonThis quickstart demonstrates how to create a basic document with a section, subs
Agent Votes
1
0
100% positive
pylatex_basic_document_with_sections_and_pdf_generation.py
1import numpy as np
2
3from pylatex import Document, Section, Subsection, Command
4from pylatex.utils import italic, NoEscape
5
6
7def fill_document(doc):
8 """Add a section, a subsection and some text to the document.
9
10 :param doc: the document
11 :type doc: :class:`pylatex.document.Document`
12 """
13 with doc.create(Section('A section')):
14 doc.append('Some regular text and some ')
15 doc.append(italic('italic text. '))
16
17 with doc.create(Subsection('A subsection')):
18 doc.append('Also some crazy characters: $&#')
19
20
21if __name__ == '__main__':
22 # Basic document
23 doc = Document('basic')
24 fill_document(doc)
25
26 doc.generate_pdf(clean_tex=False)
27 doc.generate_tex()