Welcome to Python Extends LaTeX documentation!

To get started, look here.

An overview

pyexlatex lets you create PDF and HTML documents and presentations with a high-level API. Getting started is as simple as:

pl.Document("some content")

It has two APIs, object-oriented and template-driven, to suit different workflows. pyexlatex makes it easy to insert data into your document.

Object-oriented:

my_value = 5

contents = [
    pl.Section(
        [
            f'Some text. My value is {my_value}.',
            pl.UnorderedList([
                'A bullet',
                'List'
            ])
        ],
        title='First Section'
    )
]

pl.Document(contents)

Template-driven:

template = """
{% filter Section(title='First Section') %}

Some text. My value is {{ my_value }}.
{{ [
    'A bullet',
    'List'
] | UnorderedList }}

{% endfilter %}
"""

class MyModel(pl.Model):
    my_value = 5

content = [MyModel(template_str=template)]
pl.Document(content)

Presentations are supported too.

pres_content = [
    pl.Frame(
        [
            'Some text',
            pl.Block(
                [
                    'more text'
                ],
                title='My Block'
            ),
            pl.OrderedList(["one", "two"])
        ]
    )
]
pl.Presentation(pres_content)

Document Types

Document(content)

Main class used for creating latex documents.

Standalone(content)

The main high-level class for creating one-off graphics, equations, etc.

Presentation(content)

The main high-level class for creating presentations, can render presentations as PDF in either a presenter style or a handouts style.

Equations

Equation([eq, ...])

Pass sympy or string equations to have them rendered in LaTeX.

Sections

Paragraph(...)

A paragraph, the second smallest section block.

SubParagraph(...)

Part of a paragraph, the smallest section block.

Section(...)

A section of the document, the second largest section type.

SubSection(...)

A part of a section, the third largest section type.

SubSubSection(...)

A part of a subsection, the fourth largest section type.

Appendix(...)

Content to be placed at the end, separate from the main document.

Header(contents)

Adds a header to a document, aligned to right, center, or left.

Text

Bold(...)

Makes text bold.

Underline(...)

Adds an underline to text.

Italics(...)

Italicizes text.

TextSize(...)

Resize text in this group by a relative size.

TextColor(...)

Changes the color of text.

Monospace(...)

Pass text to render it in a monospace font.

SmallCaps(...)

Makes text all caps, but with originally capital letters slightly larger than other letters.

Raw(contents)

Don't replace latex characters in this blocks such as or %, useful for adding latex commands or comments manually.

Footnote(contents)

Creates a footnote at the bottom of the page, with a mark next to where the object itself is placed to reference the footnote.

Python(...)

Renders passed contents as Python code, with syntax highlighting.

ThisPageNumber()

Gets a reference to the current page number, can be included in headers and more.

ParagraphIndent(...)

Used for setting paragraph indents, from the left or right.

LaTeX(**kwargs)

Displays the string "LaTeX" with special formatting

Lists

UnorderedList(items)

Bullet point items.

Figures

Figure(subfigures)

Used for creating latex figures from images.

Subfigure(...)

Used for more control over building figures

Graphic(filepath)

Basic class for including graphics, just the image with no structure.

Tables

Panel(panel_grid)

Represents one section of a table.

DataTable(...)

Represents a subsection in a panel, but tracks row and column labels, which may be consolidated when assembled into Panels then a Table

LabelCollection(values)

Represents one row of labels.

LabelTable(...)

A set of label rows to apply to a DataTable.

Label(value)

Only necessary to use if need to set span or alignment manually.

Table(panels)

An object for creating latex tables.

Tabular(content)

The main part of a LaTeX table which contains the rows and columns.

ValuesTable(rows)

Python interface for a part of a table containing rows and columns with values

ColumnAlignment(...)

Alignment of a single column in a table

ColumnsAlignment([...])

A set of column alignments, usually for the whole table

TopRule()

A line which can be added on the top of a table

MidRule()

A line which can be added in the middle of a table

BottomRule()

A line which can be added at the bottom of a table

TableLineSegment(...)

A table line which does not need to stretch to the full length of the table

MultiColumnLabel(...)

A label which spans multiple columns in a table

TableLineBreak([...])

A line break character to be used in LaTeX tables

TabularStar(content)

tabular* environment, allows for controlling width.

Layouts and Spacing

Center(...)

Align the passed contents to the center of the container

PageBreak()

Adds a break point where a new page should be started.

VFill()

Vertical fill, put between items to put vertical spacing between them.

HFill()

Horizontal fill, put between items to put horizontal spacing between them.

VSpace([...])

Manually insert vertical spacing, of a given height.

HSpace([...])

Manually insert horizontal spacing, of a given length.

HLine([thickness])

Draws a horizontal line across the text width.

OutputLineBreak([...])

Create an intentional line break in text

NoPageBreak(...)

Contents within this environment will not have a page break come in the middle.

NoLineBreak(...)

Prevents a line break within text, where a hyphen would normally be placed.

Justifying(...)

Returns paragraph to the default of justifying text on both left and right.

Group(contents)

Groups together latex items so that "global" commands will only affect the items in a group

CellLayout(content, ...)

Lay content out in a grid where each cell is arbitrarily sized

GridLayout(content, ...)

Evenly spaced grid layout.

MultiCol(content, ...)

Multi-column layout that does not make any constraints on vertical sizing.

VerticallySpaced(content)

Inserts vertical spacing between items until they fill the content area

HorizontallySpaced(content)

Inserts horiztonal spacing between items until they fill the content area

MultiColumn(content)

Layout multiple columns in a text area

References

Ref(contents)

Pass a label to create an in text reference to that label.

NameRef(contents)

Pass a label to create an in text reference to that label.

Label(contents)

A label which can later be referred to by Ref

Hyperlink(href)

Create links to urls, with or without displaying text instead of the link.

Citations

BibTexArticle(...)

Biblography document which is an article.

BibTexMisc(...)

Biblography document which is of miscellaneous type.

BibTexManual(...)

Biblography document which is a manual.

Bibliography([...])

High-level class for working with bibliographies in LaTeX.

Cite(...)

Basic citation command, creates a reference to a document included in the bibliography.

CiteP(...)

Paragraph citation command, creates a paragraph (with parentheses) reference to a document included in the bibliography.

CiteT(...)

In text citation command, creates an in text (without parentheses) reference to a document included in the bibliography.

Presentations

Presentation(content)

The main high-level class for creating presentations, can render presentations as PDF in either a presenter style or a handouts style.

Frame(content)

Basic unit for creating a slide in a presentation.

Block(content)

Block with an optional header

AlertBlock(content)

Block with an optional header which is red

ExamplesBlock(content)

Block which always has the header title "Examples"

adjust_to_full_size_and_center(content)

Takes content and adjusts it to 90% text width, 80% text height, but keeping the aspect ratio.

GridFrame(...)

Creates a CellFrame, automatically setting widths and heights as an even split based on the shape of the content passed

DimAndRevealListItem(...)

Single list item which reveals on each slide one-by-one and as the next one reveals, the last one dims.

DimAndRevealListItems(...)

List items which reveal on each slide one-by-one and as the next one reveals, the last one dims.

TwoColumnGraphicDimRevealFrame(...)

A TwoColumnGraphicFrame where the non-graphic column is bulleted or numbered dim and reveal items

TwoColumnGraphicFrame(...)

A GridFrame with graphics on one side and text on the other.

BasicTwoColumnGraphicFrame(...)

Similar to TwoColumnGraphicFrame, but does not put any constraints on vertical sizing

BasicTwoColumnFrame(...)

Similar to TwoColumnFrame but does not put any constraints on vertical sizing

TwoColumnFrame(...)

Creates a GridFrame, automatically setting widths and heights as an even split based on the shape of the content passed

DimRevealListFrame(content)

A Frame where the content is bulleted or numbered dim and reveal items

GraphicFrame(...)

Resizes passed graphic to take up entire frame.

MultiGraphicFrame(content)

Resizes each graphic to full width and puts vertical space in between graphics.

Overlay(...)

Creates an effect on a frame such as appearing on a later frame.

Range(...)

Option to be passed to Overlay which says object should exist on the frame on a certain range of slides e.g.

NextWithIncrement([...])

Option to be passed to Overlay which makes object appear on the next slide of the frame, and creates an additional slide

NextWithoutIncrement([...])

Option to be passed to Overlay which makes object appear on the next slide of the frame, and does not creates an additional slide

UntilEnd(content)

Option to be passed to Overlay that makes object exist until the end of the frame

PresentationAppendix(content)

Appendix to be used in a beamer presentation

Colors

RGB([...])

Define a color using an RGB code, such as RGB(33, 173, 42)

Hex(...)

Define a color using a hex code, such as #21ad2a

Template-Driven

Template()

Base class for creating custom Pyexlatex templates.

EnvironmentTemplate(...)

Base class which makes it easy to create new environment types.

JinjaEnvironment(...)

A jinja Environment but with pyexlatex models as built in filters and handling extracting pyexlatex data

JinjaTemplate(source, ...)

A jinja Template but with pyexlatex models as built-in filters and handling extracting pyexlatex data

Model([template_str, ...])

A data model combined with a Jinja template.

LaTeX Package Management

Package(name[, ...])

Represents LaTeX usepackage{}, pass to Document if any custom LaTeX packages are needed.

API Documentation

A full list of modules

Indices and tables