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)
# Create a new document doc = Document() with doc.create(Section('Custom commands')): doc.append( """ The following is a demonstration of a custom \\LaTeX command with a couple of parameters. """) # Define the new command new_comm = Command('newcommand{\\exampleCommand}', options=3, arguments='\\color{#1} #2 #3 \\color{black}') doc.append(new_comm) # Use our newly created command with different arguments doc.append(ExampleCommand(arguments=Arguments('blue', 'Hello', 'World!'))) doc.append(ExampleCommand(arguments=Arguments('green', 'Hello', 'World!'))) doc.append(ExampleCommand(arguments=Arguments('red', 'Hello', 'World!'))) with doc.create(Section('Custom environments')): doc.append( """ The following is a demonstration of a custom \\LaTeX environment using the mdframed package. """) # Define a style for our box mdf_style_definition = Command('mdfdefinestyle', arguments=['my_style', 'linecolor=#1,\ linewidth=#2,\