Ejemplo n.º 1
0
with doc.create(Section('Custom environments')):
    doc.append(NoEscape(
        r"""
        The following is a demonstration of a custom \LaTeX{}
        environment using the mdframed package.
        """))

    # Define a style for our box
    mdf_style_definition = UnsafeCommand('mdfdefinestyle',
                                         arguments=['my_style',
                                                    ('linecolor=#1,'
                                                     'linewidth=#2,'
                                                     'leftmargin=1cm,'
                                                     'leftmargin=1cm')])

    # Define the new environment using the style definition above
    new_env = UnsafeCommand('newenvironment', 'exampleEnvironment', options=2,
                            extra_arguments=[
                                mdf_style_definition.dumps() +
                                r'\begin{mdframed}[style=my_style]',
                                r'\end{mdframed}'])
    doc.append(new_env)

    # Usage of the newly created environment
    with doc.create(
            ExampleEnvironment(arguments=Arguments('red', 3))) as environment:
        environment.append('This is the actual content')

# Generate pdf
doc.generate_pdf('own_commands_ex')
Ejemplo n.º 2
0
        """))

    # Define a style for our box
    mdf_style_definition = UnsafeCommand('mdfdefinestyle',
                                         arguments=[
                                             'my_style',
                                             ('linecolor=#1,'
                                              'linewidth=#2,'
                                              'leftmargin=1cm,'
                                              'leftmargin=1cm')
                                         ])

    # Define the new environment using the style definition above
    new_env = UnsafeCommand(
        'newenvironment',
        'exampleEnvironment',
        options=2,
        extra_arguments=[
            mdf_style_definition.dumps() + r'\begin{mdframed}[style=my_style]',
            r'\end{mdframed}'
        ])
    doc.append(new_env)

    # Usage of the newly created environment
    with doc.create(
            ExampleEnvironment(arguments=Arguments('red', 3))) as environment:
        environment.append('This is the actual content')

# Generate pdf
doc.generate_pdf('own_commands_ex')
Ejemplo n.º 3
0
with doc.create(Section('Custom environments')):
    doc.append(NoEscape(
        r"""
        The following is a demonstration of a custom \LaTeX{}
        environment using the mdframed package.
        """))

    # Define a style for our box
    mdf_style_definition = UnsafeCommand('mdfdefinestyle',
                                         arguments=['my_style',
                                                    ('linecolor=#1,'
                                                     'linewidth=#2,'
                                                     'leftmargin=1cm,'
                                                     'leftmargin=1cm')])

    # Define the new environment using the style definition above
    new_env = UnsafeCommand('newenvironment', 'exampleEnvironment', options=2,
                            extra_arguments=[
                                mdf_style_definition.dumps() +
                                r'\begin{mdframed}[style=my_style]',
                                r'\end{mdframed}'])
    doc.append(new_env)

    # Usage of the newly created environment
    with doc.create(
            ExampleEnvironment(arguments=Arguments('red', 3))) as environment:
        environment.append('This is the actual content')

# Generate pdf
doc.generate_pdf('own_commands_ex', clean_tex=False)