Example #1
0
    def dumps(self):
        """Represent the function as a string in LaTeX syntax.

        Returns
        -------
        str
            A LaTeX string representing the function.
        """

        content = self.dumps_content()
        if not content.strip() and self.omit_if_empty:
            return ''

        string = ''

        if self.args is not None:
            begin = Command(self.command, arguments=(self.name, self.args))
        else:
            begin = Command(self.command, arguments=self.name)

        string += begin.dumps() + self.content_separator
        string += content + self.content_separator
        string += Command('End' + self.command).dumps()

        return string
    def dumps(self):
        # note: most of the following was copied from the pyLaTeX library so
        #       in order to fix a logic error at the end of the function.

        content = self.dumps_content()

        if not content.strip() and self.omit_if_empty:
            return ""

        string = ""

        start = Command(self.latex_name,
                        arguments=self.arguments,
                        options=self.options)

        string += start.dumps()

        if content != "":
            string += "{{ \n {} \n}}".format(content)

        return string