Skip to main content

Module cells

Module cells 

Source
Expand description

The cells feature (Cells): tables of cells. A table of cells is a cells environment, a grid of rows and columns that an author fills one cell at a time with \cell, or by rows with \celldata.

\begin{cells}
  \celldata<H>{Name & City}          % a row of two column headers
  \celldata<l, r>{John & Berlin \\ Anna & Zurich}
  \cell<green>[\merge{1-2};3]{Both}  % rows 1 to 2, column 3
\end{cells}

The language guide describes tables of cells for authors.

§Where the environment can be written

The cells environment is declared in the scoped package ENVIRONMENT_PACKAGE (flm.cells.environment). A scoped package (ScopedPackageDef) is a set of element declarations that can be written only inside the bodies and arguments whose declarations refer to it (see scoped packages). The default table float type of the floats feature refers to this package, so by default a table of cells can be written inside a table float and nowhere else. Under the switch CellsConfig::global, the same element is also declared as an ordinary environment, so that a table can be written wherever blocks can. Anywhere else, \begin{cells} is an unknown environment, reported as any unknown environment is. A registry that holds this feature without the floats feature holds, by default, an element no document can write; this is not an error.

§The body

The environment’s body is a sequence of instructions, laid out as blocks, and holds nothing else; whitespace, blank lines and comments between the instructions are ignored.

  • \cell<styles>[placement]{content} adds one cell. Its content is laid out as blocks (e.g., multiple paragraphs). By default the cell goes in the next column of the current row.
  • \celldata<styles>[mapping]{data} adds a cell per entry of its data: rows ended by \\, entries separated by &, each entry inline content. An entry whose only content is a \cell is that cell, whose own styles and placement take precedence over the entry’s; an empty entry adds no cell and leaves its position empty.
  • \\ ends the current row: the next cell starts the next row.
  • \rownames{…} and \colnames{…} give the rows and the columns names: a comma-separated list whose k-th entry is the name of row or column k. A name is an ASCII letter followed by letters, digits or underscores, and can be written wherever a row or column number can, anywhere in the table.

These commands can be written only in the body and, through it, in the data of a \celldata; & only in that data; \merge only in a placement or a mapping. Each set is a scoped package of its own (BODY_PACKAGE, DATA_PACKAGE, MERGE_PACKAGE).

§Placements, mappings and ranges

Rows and columns are numbered from 1.

  • A placement (the optional argument of \cell) is [COL] or [ROW;COL], each a number, a name, . or nothing for the current row or column, or \merge{RANGE} for a cell spanning several.
  • A range is 2-4 (both included), 2+3 (three from 2), or 1,2,3 (a union, which must be contiguous). In \merge, a start left out is the first index, and an end left out is the last index of the table as finally built.
  • A mapping (the optional argument of \celldata) is [COLS] or [ROWS;COLS], each a comma-separated list of indices, ranges and \merge{…}, assigned to the data’s entries in order. An open range (2-) continues one index per entry; with no rows given, the data’s rows go from the current row on.

§Style tokens

The angle brackets hold style tokens separated by whitespace: a name, or a name with a value in braces. Each token refers to a cell style (CellStyle, see the styles module) contributed to the service slot STYLES_SLOT. In a \celldata, a comma separates the token lists of successive entries of a row, the last list repeated. A cell’s own tokens come before its \celldata’s. Of the tokens that give an alignment, the first decides, and likewise for the tokens that make the cell a header; every edge line (a rule: rule{…}, lvert, rvert, a line drawn along an edge of the cell) and every custom style is kept.

§What the feature registers

The feature (Cells, under a CellsConfig) registers:

§How a table is lowered

The reader read_grid reads a table at lowering. Every rule that lowers a table calls it, and nothing stores its result. Its result is the payload of the presentation element flm.pres.cells (CellsPayload), the grid’s size and one entry per cell with the facts its tokens state, together with each cell’s content and the problems it found.

  • On every backend except latex-recomposed, the general rule (lower::CellsRule) stages one dropped mark (flm.pres.dropped) per thing left out, then the flm.pres.cells node, with one cell content slot per entry: a \cell’s blocks, or a \celldata entry’s content as one paragraph with the whitespace at its edges trimmed. It requires, on the backend it runs on, the style definitions or definition pieces that the table’s cell styles declare for that backend (CellStyle::requires). The text backend lays the table out in aligned columns; the HTML backend writes a <table> as the HTML contract states (html; see also the rendering guide).
  • On the latex-recomposed backend, the recomposition rule writes one call of the LaTeX hook \flmCellsTable, over the tabularray package (latex).
  • A command of the tables of cells written outside its place is lowered by lower::OutsideRule on every backend.

§Interactions with other features

  • The floats feature’s table float type refers to the scoped package ENVIRONMENT_PACKAGE and to the content handler cells (handler); without the floats feature, the handler is dropped with one Note, and the environment can be written only under CellsConfig::global.
  • Any feature may contribute cell styles of its own (CellStyle); the guide on extending FLM shows how.
  • The LaTeX family (the latex helpers and the latex-recomposed backend) owns the constructs the recomposition rule stages; without them, that rule is set aside (excluded from rule selection; see PeerName) and the registry still builds.

§Diagnostics

Every mistake is an Error with a recovery (diagnostics), reported each time a rule lowers the table, and never under the check workflow (CHECK_WORKFLOW), which lowers nothing. A dropped mark (flm.pres.dropped; see recovery) shows where something was left out:

conditionrecovery
flm.cells.content-outside-cellthe content is left out; a dropped mark is placed before the table
flm.cells.bad-placementa placement is ignored, and the cell goes where the current row and column put it; a mapping is ignored whole
flm.cells.bad-stylesthe styles argument is ignored
flm.cells.unknown-style, flm.cells.bad-style-valuethe token is ignored, the others kept
flm.cells.bad-namesthe entry is ignored, the others kept
flm.cells.overlapthe later cell is left out whole; a dropped mark is placed before the table
flm.cells.too-largethe cell that would make the table larger than a million positions is left out; a dropped mark is placed before the table
flm.cells.emptynothing is written for the table, except the dropped marks of what was left out
flm.cells.outside-tablea \cell’s or a \celldata’s content is shown where the command is written; a command without content is left out, and a dropped mark is placed where it was

§Items of this module

Re-exports§

pub use handler::CellsContent;
pub use parser::CellStylesParser;
pub use reader::CellContent;
pub use reader::Grid;
pub use reader::Problem;
pub use reader::read_grid;
pub use styles::CellStyle;
pub use styles::Effect;
pub use styles::Parameter;
pub use styles::StyleForm;
pub use styles::StyleRequirement;
pub use styles::Styles;
pub use styles::shipped;

Modules§

diagnostics
This module defines the diagnostic conditions of the cells feature, which provides tables of cells. Their identifiers have the form flm.cells.<condition>. Every condition is an error.
handler
The content handler that the cells feature contributes to the floats feature: CellsContent, named cells, which admits exactly one table of cells as a float’s content.
html
The cells feature’s part of an HTML page: its style definition STYLE (flm.cells.style, stylesheet), the stylesheet that the HTML backend includes wherever a page holds a table of cells.
latex
The recomposition rule of a table of cells on the latex-recomposed backend (LATEX_RULE, CellsLatexRule): the table is written as one call of the LaTeX hook \flmCellsTable (LaTeX hooks), which the feature’s definition piece (definition_piece) defines over the tabularray package.
latex_rendered
The definition piece of the cells feature on the latex-rendered backend, flm.latex.def.flmx.cells.styles (piece).
lower
The general lowering rules of the tables of cells.
parser
The parser of a cell’s styles argument (CellStylesParser): an optional group delimited by < and >, holding document content.
reader
The reader of a table of cells: read_grid reads the body of a cells environment into the table’s grid, at lowering.
styles
The cell styles of the tables of cells: what a style token written in the angle brackets of \cell<…> or \celldata<…> states about a cell.

Structs§

Cells
The cells feature (FlmFeature). Under a CellsConfig, it registers the cells environment in its scoped package and, under global, as an ordinary environment; the commands of its body and their scoped packages; the content handler for the floats feature; the service slot of cell styles with the shipped ones; the lowering rules; the HTML style definition and the LaTeX definition piece. See the module documentation.
CellsConfig
The configuration of the cells feature: whether the cells environment is also an ordinary environment of the document.
InBody
The block role of \cell, \\, \rownames and \colnames, decided by position. The command is a block where it is a direct child of the body of a cells environment (stands_in_body), as one of the table’s instructions. It is inline content everywhere else: inside the data of a \celldata, where it is an entry’s cell or ends a row, and inside a cell’s content, where it is out of place and reported when lowered (OutsideTable).

Constants§

BODY_PACKAGE
The scoped package of the environment’s body, flm.cells.body: \cell, \celldata, \\, \rownames and \colnames, which can be written only there and, through it, in the data of a \celldata.
CELL
The element of \cell, flm.cells.cell: one cell.
COLNAMES
The element of \colnames, flm.cells.colnames.
COLUMN
The element of & in the data of \celldata, flm.cells.column: the end of an entry.
CONTENT_ARG
The name of the content argument of \cell, content.
DATA
The element of \celldata, flm.cells.data: a cell per entry of its data.
DATA_ARG
The name of the data argument of \celldata, data.
DATA_PACKAGE
The scoped package of the data of \celldata, flm.cells.data: &.
ENVIRONMENT
The element of the cells environment, flm.cells.cells: a table of cells.
ENVIRONMENT_PACKAGE
The scoped package that holds the cells environment, flm.cells.environment: a table of cells can be written in a body whose declaration refers to it. A float type of the floats feature refers to it in its configuration; the feature declares the package under every configuration.
FEATURE
The feature’s registered name, cells.
LATEX_PIECE
The identifier of the feature’s definition piece for the recomposed LaTeX, flm.latex.def.cells (latex::definition_piece), which the recomposition rule of a table requires, and which the shipped custom styles require on that backend.
MAPPING_ARG
The name of the mapping argument of \celldata, mapping.
MERGE
The element of \merge, flm.cells.merge: a span of rows or of columns.
MERGE_PACKAGE
The scoped package of a placement and a mapping, flm.cells.merge: \merge.
NAMES_ARG
The name of the argument of \rownames and \colnames, names.
PLACEMENT_ARG
The name of the placement argument of \cell, placement.
RANGE_ARG
The name of the range argument of \merge, range.
ROW
The element of \\ in a table of cells, flm.cells.row: the end of a row.
ROWNAMES
The element of \rownames, flm.cells.rownames.
STYLE
The identifier of the feature’s style definition for HTML, flm.cells.style (html::stylesheet). The HTML contract’s row for flm.pres.cells refers to it, and the shipped custom styles require it on HTML.
STYLES_ARG
The name of the styles argument of \cell and \celldata, styles.
STYLES_SLOT
The name of the service slot of cell styles, flm.cells.styles: every CellStyle that a table’s tokens may refer to, in the order of contribution (Arity::OrderedMany). A service slot is the declaration, by the feature that owns an interaction, of a dotted name, the type of the values the slot takes and its arity; any feature may contribute values to it (see services). The cells feature contributes the cell styles it ships (shipped); any feature may contribute its own, as a peer contribution.

Functions§

feature
The Cells feature under the default configuration, ready to be listed in a package entry.
stands_in_body
Whether node is a direct child of the body of a cells environment: its owner, the command or environment of whose body it is a direct child, is an element named ENVIRONMENT (flm.cells.cells).