pylatex.document¶
This module implements the class that deals with the full document.
-
class
Document
(default_filepath='default_filepath', *, documentclass='article', document_options=None, fontenc='T1', inputenc='utf8', font_size='normalsize', lmodern=True, textcomp=True, microtype=None, page_numbers=True, indent=None, geometry_options=None, data=None)[source]¶ Bases:
pylatex.base_classes.containers.Environment
A class that contains a full LaTeX document.
If needed, you can append stuff to the preamble or the packages. For instance, if you need to use
\maketitle
you can add the title, author and date commands to the preamble to make it work.Parameters: - default_filepath (str) – The default path to save files.
- documentclass (str or
Command
) – The LaTeX class of the document. - document_options (str or
list
) – The options to supply to the documentclass - fontenc (str) – The option for the fontenc package. If it is
None
, the fontenc package will not be loaded at all. - inputenc (str) – The option for the inputenc package. If it is
None
, the inputenc package will not be loaded at all. - font_size (str) – The font size to declare as normalsize
- lmodern (bool) – Use the Latin Modern font. This is a font that contains more glyphs than the standard LaTeX font.
- textcomp (bool) – Adds even more glyphs, for instance the Euro (€) sign.
- page_numbers (bool) – Adds the ability to add the last page to the document.
- indent (bool) – Determines whether or not the document requires indentation. If it
is
None
it will use the value from the active config. Which isTrue
by default. - geometry_options (dict) – The options to supply to the geometry package
- data (list) – Initial content of the document.
-
generate_tex
(filepath=None)[source]¶ Generate a .tex file for the document.
Parameters: filepath (str) – The name of the file (without .tex), if this is not supplied the default filepath attribute is used as the path.
-
generate_pdf
(filepath=None, *, clean=True, clean_tex=True, compiler=None, compiler_args=None, silent=True)[source]¶ Generate a pdf file from the document.
Parameters: - filepath (str) – The name of the file (without .pdf), if it is
None
thedefault_filepath
attribute will be used. - clean (bool) – Whether non-pdf files created that are created during compilation should be removed.
- clean_tex (bool) – Also remove the generated tex file.
- compiler (
str
orNone
) – The name of the LaTeX compiler to use. If it is None, PyLaTeX will choose a fitting one on its own. Starting withlatexmk
and thenpdflatex
. - compiler_args (
list
orNone
) – Extra arguments that should be passed to the LaTeX compiler. If this is None it defaults to an empty list. - silent (bool) – Whether to hide compiler output
- filepath (str) – The name of the file (without .pdf), if it is
-
change_page_style
(style)[source]¶ Alternate page styles of the current page.
Parameters: style (str) – value to set for the page style of the current page
-
change_document_style
(style)[source]¶ Alternate page style for the entire document.
Parameters: style (str) – value to set for the document style
-
add_color
(name, model, description)[source]¶ Add a color that can be used throughout the document.
Parameters:
-
change_length
(parameter, value)[source]¶ Change the length of a certain parameter to a certain value.
Parameters:
-
omit_if_empty
= False¶