pylatex.base_classes.containers¶
This module implements LaTeX base classes that can be subclassed.
-
class
Container
(*, data=None)[source]¶ Bases:
pylatex.base_classes.latex_object.LatexObject
,collections.UserList
A base class that groups multiple LaTeX classes.
This class should be subclassed when a LaTeX class has content that is of variable length. It subclasses UserList, so it holds a list of elements that can simply be accessed by using normal list functionality, like indexing or appending.
Parameters: data (list, LatexObject
or something that can be converted to a ) – string The content with which the container is initialized-
dumps_content
(**kwargs)[source]¶ Represent the container as a string in LaTeX syntax.
Parameters: **kwargs – Arguments that can be passed to dumps_list
Returns: A LaTeX string representing the container Return type: string
-
create
(child)[source]¶ Add a LaTeX object to current container, context-manager style.
Parameters: child ( Container
) – An object to be added to the current container
-
begin_paragraph
= False¶
-
-
class
Environment
(*, options=None, arguments=None, start_arguments=None, **kwargs)[source]¶ Bases:
pylatex.base_classes.containers.Container
A base class for LaTeX environments.
This class implements the basics of a LaTeX environment. A LaTeX environment looks like this:
\begin{environment_name} Some content that is in the environment \end{environment_name}
The text that is used in the place of environment_name is by default the name of the class in lowercase. However, this default can be overridden in 2 ways: 1. setting the _latex_name class variable when declaring the class 2. setting the _latex_name attribute when initialising object
Parameters: -
omit_if_empty
= False[source]¶ Set to true if this full container should be equivalent to an empty string if it has no content.
-
dumps
()[source]¶ Represent the environment as a string in LaTeX syntax.
Returns: A LaTeX string representing the environment. Return type: str
-
begin_paragraph
= False¶
-
create
(child)[source]¶ Add a LaTeX object to current container, context-manager style.
Parameters: child ( Container
) – An object to be added to the current container
-
dumps_content
(**kwargs)[source]¶ Represent the container as a string in LaTeX syntax.
Parameters: **kwargs – Arguments that can be passed to dumps_list
Returns: A LaTeX string representing the container Return type: string
-
-
class
ContainerCommand
(arguments=None, options=None, *, data=None, **kwargs)[source]¶ Bases:
pylatex.base_classes.containers.Container
A base class for a container command (A command which contains data).
Container command example:
\CommandName[options]{arguments}{ data }
Parameters: - arguments (str or
list
) – The arguments for the container command - options (str, list or
Options
) – The options for the preamble command - data (str or
LatexObject
) – The data to place inside the preamble command
- arguments (str or