plasma_posters
Type part of a name or a dotted path
Scientific posters from Python: a layout of text, figures and equations written to a print-ready PDF.
Attributes
| Name | Description |
|---|---|
__version__ | No description. |
Classes
Functions
| Name | Description |
|---|---|
compile_latex | Compile a LaTeX file to a PDF next to it. |
preview | Render a page of a PDF as a PNG, to check its layout. |
preview_pages | Render every page of a PDF as a PNG, e.g. the slides of a talk. |
Modules
Blockclassdataclass#
plasma_posters.posterView sourceclass Block(title: str, body: str, column: int = 0)A titled block of a poster column.
Attributes
Posterclassdataclass#
plasma_posters.posterView sourceclass Poster(title: str, authors: str = '', institute: str = '', size: str = 'a0', orientation: str = 'portrait', columns: int = 2, blocks: list[Block] = list())A scientific poster: a title, authors, and blocks of text and figures in columns.
Attributes
| Name | Type | Description |
|---|---|---|
title | str | The poster’s title (LaTeX). |
authors | str | The authors, as one line (LaTeX). |
institute | str | The authors’ institute, below the authors (LaTeX); empty for none. |
size | str | The paper size, one of :data:SIZES. |
orientation | str | "portrait" or "landscape". |
columns | int | The number of columns, of equal width. |
blocks | list[Block] | The blocks, in the order they were added. |
authorsattributeclass attributeinstance attribute#
authors: str = ''blocksattributeclass attributeinstance attribute#
blocks: list[Block] = field(default_factory=list)columnsattributeclass attributeinstance attribute#
columns: int = 2instituteattributeclass attributeinstance attribute#
institute: str = ''orientationattributeclass attributeinstance attribute#
orientation: str = 'portrait'sizeattributeclass attributeinstance attribute#
size: str = 'a0'titleattributeinstance attribute#
title: strblockmethod#
def block(title: str, body: str, column: int = 0) -> NoneAdd a block of text.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
title | str | required | The block’s heading (LaTeX). |
body | str | required | The text (LaTeX); paragraphs are separated by blank lines. Its common indentation is removed, so it can be an indented triple-quoted string. |
column | int | 0 | The column to put the block in, from 0; blocks of a column are stacked in the order they are added. |
Raises
ValueError- If the column does not exist.
buildmethod#
def build(path: str | Path, engine: str = 'lualatex') -> PathWrite the poster’s LaTeX next to path and compile it to a PDF.
Parameters
Returns
Path- The PDF’s path.
figuremethod#
def figure(title: str, path: str | Path, caption: str = '', width: float = 0.95, column: int = 0) -> NoneAdd a block with a figure.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
title | str | required | The block’s heading (LaTeX). |
path | str | Path | required | The figure file (PDF, PNG or JPEG), relative to the poster’s .tex file
or absolute. |
caption | str | '' | The caption below the figure (LaTeX); empty for none. |
width | float | 0.95 | The figure’s width as a fraction of the column’s width. |
column | int | 0 | The column to put the block in, from 0. |
Raises
ValueError- If the width is not in (0, 1] or the column does not exist.
savemethod#
def save(path: str | Path) -> PathWrite the poster’s LaTeX to a file.
Parameters
| Name | Type | Description |
|---|---|---|
path | str | Path | The .tex file to write. |
Returns
Path- The path written.
to_latexmethod#
def to_latex() -> strThe poster as a LaTeX document.
Returns
str- The complete document, for
lualatexorpdflatex.
compile_latexfunction#
plasma_posters.posterView sourcedef compile_latex(tex: str | Path, engine: str = 'lualatex') -> PathCompile a LaTeX file to a PDF next to it.
Parameters
Returns
Path- The PDF’s path.
Raises
FileNotFoundError- If the LaTeX program is not installed.
RuntimeError- If LaTeX fails; the message ends with the end of its log.
previewfunction#
plasma_posters.posterView sourcedef preview(pdf: str | Path, png: str | Path | None = None, dpi: int = 30, page: int = 1) -> PathRender a page of a PDF as a PNG, to check its layout.
Uses pdftoppm from poppler (poppler-utils on Debian and Ubuntu, poppler in
Homebrew).
Parameters
Returns
Path- The PNG’s path.
Raises
ValueError- If the page is less than 1.
FileNotFoundError- If pdftoppm is not installed.
RuntimeError- If pdftoppm fails, e.g. on a page the PDF does not have.
preview_pagesfunction#
plasma_posters.posterView sourcedef preview_pages(pdf: str | Path, folder: str | Path | None = None, dpi: int = 30) -> list[Path]Render every page of a PDF as a PNG, e.g. the slides of a talk.
The PNGs are <name>-<page>.png (with pdftoppm’s zero padding, talk-01.png for a
PDF of 10 to 99 pages); earlier PNGs of that name in the folder are removed first, so the
list holds only this PDF’s pages.
Parameters
Returns
list[Path]- The PNGs, in page order.
Raises
FileNotFoundError- If pdftoppm is not installed.
RuntimeError- If pdftoppm fails.