pylatex.base_classes.latex_object

This module implements the base LaTeX object.

class LatexObject[source]

Bases: object

The class that every other LaTeX class is a subclass of.

This class implements the main methods that every LaTeX object needs. For conversion to LaTeX formatted strings it implements the dumps, dump and generate_tex methods. It also provides the methods that can be used to represent the packages required by the LatexObject.

escape[source]

Determine whether or not to escape content of this class.

This defaults to True for most classes.

begin_paragraph = False[source]

Start a new paragraph before this environment.

end_paragraph = False[source]

Start a new paragraph after this environment.

separate_paragraph = False[source]

Same as enabling begin_paragraph and end_paragraph, so effectively placing this element in its own paragraph.

packages = OrderedSet()
latex_name[source]

Return the name of the class used in LaTeX.

It can be None when the class doesn’t have a name.

dumps()[source]

Represent the class as a string in LaTeX syntax.

This method should be implemented by any class that subclasses this class.

dump(file_w)[source]

Write the LaTeX representation of the class to a file.

Parameters:file_w (io.TextIOBase) – The file object in which to save the data
generate_tex(filepath)[source]

Generate a .tex file.

Parameters:filepath (str) – The name of the file (without .tex)
dumps_packages()[source]

Represent the packages needed as a string in LaTeX syntax.

Returns:
Return type:list
dump_packages(file_w)[source]

Write the LaTeX representation of the packages to a file.

Parameters:file_w (io.TextIOBase) – The file object in which to save the data
dumps_as_content()[source]

Create a string representation of the object as content.

This is currently only used to add new lines before and after the output of the dumps function. These can be added or removed by changing the begin_paragraph, end_paragraph and separate_paragraph attributes of the class.