Exemplo n.º 1
0
    def __init__(self,
                 options=None,
                 arguments=None,
                 seperate_paragraph=False,
                 begin_paragraph=False,
                 end_paragraph=False,
                 **kwargs):
        from pylatex.parameters import Arguments, Options

        if not hasattr(self, 'container_name'):
            self.container_name = self.__class__.__name__.lower()

        if isinstance(arguments, Arguments):
            self.arguments = arguments
        elif arguments is not None:
            self.arguments = Arguments(arguments)
        else:
            self.arguments = Arguments()

        if isinstance(options, Options):
            self.options = options
        elif options is not None:
            self.options = Options(options)
        else:
            self.options = Options()

        self.seperate_paragraph = seperate_paragraph
        self.begin_paragraph = begin_paragraph
        self.end_paragraph = end_paragraph

        super().__init__(**kwargs)
Exemplo n.º 2
0
    def __init__(self, options=None, arguments=None,
                 seperate_paragraph=False, begin_paragraph=False,
                 end_paragraph=False, **kwargs):
        from pylatex.parameters import Arguments, Options

        if not hasattr(self, 'container_name'):
            self.container_name = self.__class__.__name__.lower()

        if isinstance(arguments, Arguments):
            self.arguments = arguments
        elif arguments is not None:
            self.arguments = Arguments(arguments)
        else:
            self.arguments = Arguments()

        if isinstance(options, Options):
            self.options = options
        elif options is not None:
            self.options = Options(options)
        else:
            self.options = Options()

        self.seperate_paragraph = seperate_paragraph
        self.begin_paragraph = begin_paragraph
        self.end_paragraph = end_paragraph

        super().__init__(**kwargs)
Exemplo n.º 3
0
class Environment(Container):
    r"""A base class for LaTeX environments.

    This class implements the basics of a LaTeX environment. A LaTeX
    environment looks like this:

    .. code-block:: latex

        \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 defalt the
    name of the class in lowercase. However, this default can be overridden by
    setting the environment_name class variable when declaring the class.

    :param name:
    :param options:
    :param arguments:

    :type name: str
    :type options: str or list or \
        :class:`~pylatex.base_classes.command.Options` instance
    :type argument: str or list or \
        :class:`~pylatex.base_classes.command.Arguments` instance
    """
    def __init__(self,
                 options=None,
                 arguments=None,
                 seperate_paragraph=False,
                 begin_paragraph=False,
                 end_paragraph=False,
                 **kwargs):
        from pylatex.parameters import Arguments, Options

        if not hasattr(self, 'container_name'):
            self.container_name = self.__class__.__name__.lower()

        if isinstance(arguments, Arguments):
            self.arguments = arguments
        elif arguments is not None:
            self.arguments = Arguments(arguments)
        else:
            self.arguments = Arguments()

        if isinstance(options, Options):
            self.options = options
        elif options is not None:
            self.options = Options(options)
        else:
            self.options = Options()

        self.seperate_paragraph = seperate_paragraph
        self.begin_paragraph = begin_paragraph
        self.end_paragraph = end_paragraph

        super().__init__(**kwargs)

    def dumps(self):
        """Represent the named container as a string in LaTeX syntax.

        :return:
        :rtype: str
        """

        string = ''

        if self.seperate_paragraph or self.begin_paragraph:
            string += '\n\n'

        string += r'\begin{' + self.container_name + '}'

        string += self.options.dumps()

        string += self.arguments.dumps()

        string += '\n'

        string += super().dumps()

        string += '\n' + r'\end{' + self.container_name + '}'

        if self.seperate_paragraph or self.end_paragraph:
            string += '\n\n'

        return string
Exemplo n.º 4
0
class Environment(Container):

    r"""A base class for LaTeX environments.

    This class implements the basics of a LaTeX environment. A LaTeX
    environment looks like this:

    .. code-block:: latex

        \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 defalt the
    name of the class in lowercase. However, this default can be overridden by
    setting the environment_name class variable when declaring the class.

    :param name:
    :param options:
    :param arguments:

    :type name: str
    :type options: str or list or \
        :class:`~pylatex.base_classes.command.Options` instance
    :type argument: str or list or \
        :class:`~pylatex.base_classes.command.Arguments` instance
    """

    def __init__(self, options=None, arguments=None,
                 seperate_paragraph=False, begin_paragraph=False,
                 end_paragraph=False, **kwargs):
        from pylatex.parameters import Arguments, Options

        if not hasattr(self, 'container_name'):
            self.container_name = self.__class__.__name__.lower()

        if isinstance(arguments, Arguments):
            self.arguments = arguments
        elif arguments is not None:
            self.arguments = Arguments(arguments)
        else:
            self.arguments = Arguments()

        if isinstance(options, Options):
            self.options = options
        elif options is not None:
            self.options = Options(options)
        else:
            self.options = Options()

        self.seperate_paragraph = seperate_paragraph
        self.begin_paragraph = begin_paragraph
        self.end_paragraph = end_paragraph

        super().__init__(**kwargs)

    def dumps(self):
        """Represent the named container as a string in LaTeX syntax.

        :return:
        :rtype: str
        """

        string = ''

        if self.seperate_paragraph or self.begin_paragraph:
            string += '\n\n'

        string += r'\begin{' + self.container_name + '}'

        string += self.options.dumps()

        string += self.arguments.dumps()

        string += '\n'

        string += super().dumps()

        string += '\n' + r'\end{' + self.container_name + '}'

        if self.seperate_paragraph or self.end_paragraph:
            string += '\n\n'

        return string