plesty.lib.report.latex

A report as LaTeX, to paste into a paper or a thesis.

Tables are booktabs tables: \multicolumn and \multirow for the spans, with the placeholder & a \multirow needs in the rows it covers, and a \cmidrule under every header group. Figures are pgfplots axes with the data inline. PREAMBLE lists the packages and the PLESTY colours all of it uses.

Attributes

_LEGEND_POS

_SPECIAL

_UNICODE

_TOKENS

PREAMBLE

Functions

_preamble(→ str)

Return the packages and colour definitions a rendered report needs.

to_latex(→ str)

Render a report, or one block of it, as LaTeX.

_block(→ str)

Render one block.

escape(→ str)

Return plain text with every LaTeX special character written as text.

inline(→ str)

Render inline markup as LaTeX; math is passed through as it was written.

_spans(→ str)

Render parsed spans.

_value(→ str)

Render a number, its uncertainty, and a shared power of ten, as math.

_content(→ str)

Render what a cell says, with its note mark.

_column_spec(→ list[str])

Return each column's alignment: centred when every body value there is a number.

_row(→ str)

Render one row: a cell where one starts, a placeholder under a \multirow.

_rules(→ str)

Return a \cmidrule under every header cell spanning several columns.

_notes(→ str)

Render the footnotes and the defined terms below a table.

_table(→ str)

Render a table inside a table environment, title as its caption.

_coordinates(→ str)

Return a trace's finite points as a pgfplots coordinate list.

_figure(→ str)

Render a figure as a pgfplots axis inside a figure environment.

Module Contents

plesty.lib.report.latex._LEGEND_POS
plesty.lib.report.latex._SPECIAL
plesty.lib.report.latex._UNICODE
plesty.lib.report.latex._TOKENS = ('cyan', 'violet', 'mint', 'amber', 'rose', 'blue')
plesty.lib.report.latex._preamble() → str

Return the packages and colour definitions a rendered report needs.

Return type:

str

plesty.lib.report.latex.PREAMBLE = Multiline-String
Show Value
"""\usepackage{booktabs}
\usepackage{multirow}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

"""
plesty.lib.report.latex.to_latex(item: Any) → str

Render a report, or one block of it, as LaTeX.

Parameters:

item (Any) – A Report or a single block.

Returns:

LaTeX for the document body; see PREAMBLE for its preamble.

Return type:

str

plesty.lib.report.latex._block(block: Any) → str

Render one block.

Parameters:

block (Any)

Return type:

str

plesty.lib.report.latex.escape(text: str) → str

Return plain text with every LaTeX special character written as text.

Parameters:

text (str)

Return type:

str

plesty.lib.report.latex.inline(text: str) → str

Render inline markup as LaTeX; math is passed through as it was written.

Parameters:

text (str)

Return type:

str

plesty.lib.report.latex._spans(spans: list[plesty.lib.report.markup.Span]) → str

Render parsed spans.

Parameters:

spans (list[plesty.lib.report.markup.Span])

Return type:

str

plesty.lib.report.latex._value(cell: plesty.lib.report.blocks.Value) → str

Render a number, its uncertainty, and a shared power of ten, as math.

Parameters:

cell (plesty.lib.report.blocks.Value)

Return type:

str

plesty.lib.report.latex._content(cell: plesty.lib.report.blocks._Spanning) → str

Render what a cell says, with its note mark.

Parameters:

cell (plesty.lib.report.blocks._Spanning)

Return type:

str

plesty.lib.report.latex._column_spec(table: plesty.lib.report.blocks.Table) → list[str]

Return each column’s alignment: centred when every body value there is a number.

Parameters:

table (plesty.lib.report.blocks.Table)

Return type:

list[str]

plesty.lib.report.latex._row(row: list[Any], spec: list[str]) → str

Render one row: a cell where one starts, a placeholder under a \multirow.

Parameters:
  • row (list[Any])

  • spec (list[str])

Return type:

str

plesty.lib.report.latex._rules(row: list[Any]) → str

Return a \cmidrule under every header cell spanning several columns.

Parameters:

row (list[Any])

Return type:

str

plesty.lib.report.latex._notes(table: plesty.lib.report.blocks.Table) → str

Render the footnotes and the defined terms below a table.

Parameters:

table (plesty.lib.report.blocks.Table)

Return type:

str

plesty.lib.report.latex._table(table: plesty.lib.report.blocks.Table) → str

Render a table inside a table environment, title as its caption.

Parameters:

table (plesty.lib.report.blocks.Table)

Return type:

str

plesty.lib.report.latex._coordinates(item: plesty.lib.monitor.plots.Line | plesty.lib.monitor.plots.Scatter) → str

Return a trace’s finite points as a pgfplots coordinate list.

Parameters:

item (plesty.lib.monitor.plots.Line | plesty.lib.monitor.plots.Scatter)

Return type:

str

plesty.lib.report.latex._figure(figure: plesty.lib.report.blocks.Figure) → str

Render a figure as a pgfplots axis inside a figure environment.

Lines and points are drawn; an image cannot be inlined as coordinates and is left out with a comment saying so; scalars and text marks go into the caption, which is where a printed figure says such things.

Parameters:

figure (plesty.lib.report.blocks.Figure)

Return type:

str