plesty.lib.report.latex ======================= .. py:module:: plesty.lib.report.latex .. autoapi-nested-parse:: 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. :data:`PREAMBLE` lists the packages and the PLESTY colours all of it uses. Attributes ---------- .. autoapisummary:: plesty.lib.report.latex._LEGEND_POS plesty.lib.report.latex._SPECIAL plesty.lib.report.latex._UNICODE plesty.lib.report.latex._TOKENS plesty.lib.report.latex.PREAMBLE Functions --------- .. autoapisummary:: plesty.lib.report.latex._preamble plesty.lib.report.latex.to_latex plesty.lib.report.latex._block plesty.lib.report.latex.escape plesty.lib.report.latex.inline plesty.lib.report.latex._spans plesty.lib.report.latex._value plesty.lib.report.latex._content plesty.lib.report.latex._column_spec plesty.lib.report.latex._row plesty.lib.report.latex._rules plesty.lib.report.latex._notes plesty.lib.report.latex._table plesty.lib.report.latex._coordinates plesty.lib.report.latex._figure Module Contents --------------- .. py:data:: _LEGEND_POS .. py:data:: _SPECIAL .. py:data:: _UNICODE .. py:data:: _TOKENS :value: ('cyan', 'violet', 'mint', 'amber', 'rose', 'blue') .. py:function:: _preamble() -> str Return the packages and colour definitions a rendered report needs. .. py:data:: PREAMBLE :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """\usepackage{booktabs} \usepackage{multirow} \usepackage{textcomp} \usepackage{xcolor} \usepackage{pgfplots} \pgfplotsset{compat=1.18} """ .. raw:: html
.. py:function:: to_latex(item: Any) -> str Render a report, or one block of it, as LaTeX. :param item: A :class:`~plesty.lib.report.Report` or a single block. :returns: LaTeX for the document body; see :data:`PREAMBLE` for its preamble. .. py:function:: _block(block: Any) -> str Render one block. .. py:function:: escape(text: str) -> str Return plain text with every LaTeX special character written as text. .. py:function:: inline(text: str) -> str Render inline markup as LaTeX; math is passed through as it was written. .. py:function:: _spans(spans: list[plesty.lib.report.markup.Span]) -> str Render parsed spans. .. py:function:: _value(cell: plesty.lib.report.blocks.Value) -> str Render a number, its uncertainty, and a shared power of ten, as math. .. py:function:: _content(cell: plesty.lib.report.blocks._Spanning) -> str Render what a cell says, with its note mark. .. py:function:: _column_spec(table: plesty.lib.report.blocks.Table) -> list[str] Return each column's alignment: centred when every body value there is a number. .. py:function:: _row(row: list[Any], spec: list[str]) -> str Render one row: a cell where one starts, a placeholder under a ``\multirow``. .. py:function:: _rules(row: list[Any]) -> str Return a ``\cmidrule`` under every header cell spanning several columns. .. py:function:: _notes(table: plesty.lib.report.blocks.Table) -> str Render the footnotes and the defined terms below a table. .. py:function:: _table(table: plesty.lib.report.blocks.Table) -> str Render a table inside a ``table`` environment, title as its caption. .. py:function:: _coordinates(item: plesty.lib.monitor.plots.Line | plesty.lib.monitor.plots.Scatter) -> str Return a trace's finite points as a pgfplots coordinate list. .. py:function:: _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.