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\cellis 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), or1,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:
- the eight elements of the tables of cells (
ENVIRONMENT,CELL,DATA,ROW,COLUMN,MERGE,ROWNAMES,COLNAMES) and its four scoped packages; underCellsConfig::global, the environment also as an ordinary environment; - the content handler
CellsContent, as a peer contribution to thefloatsfeature’s service slot of content handlers (handler); - the service slot
STYLES_SLOTof cell styles (service_slot), with the cell styles it ships (shipped), and a build hook (Finalizer) that collects every cell style once the slot is assembled; - the general lowering rules (
lower) and the recomposition rule of thelatex-recomposedbackend (latex); - the style definition
STYLEfor HTML (html) and the definition pieceLATEX_PIECEfor the recomposed LaTeX (latex); the definition piece of the rendered LaTeX, which deliversSTYLE(latex_rendered); - its settings: the fields of
CellsConfigas data (crate::core::settings).
§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 theflm.pres.cellsnode, with onecellcontent slot per entry: a\cell’s blocks, or a\celldataentry’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-recomposedbackend, the recomposition rule writes one call of the LaTeX hook\flmCellsTable, over thetabularraypackage (latex). - A command of the tables of cells written outside its place is lowered
by
lower::OutsideRuleon every backend.
§Interactions with other features
- The
floatsfeature’stablefloat type refers to the scoped packageENVIRONMENT_PACKAGEand to the content handlercells(handler); without thefloatsfeature, the handler is dropped with one Note, and the environment can be written only underCellsConfig::global. - Any feature may contribute cell styles of its own (
CellStyle); the guide on extending FLM shows how. - The LaTeX family (the
latexhelpers and thelatex-recomposedbackend) owns the constructs the recomposition rule stages; without them, that rule is set aside (excluded from rule selection; seePeerName) 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:
| condition | recovery |
|---|---|
flm.cells.content-outside-cell | the content is left out; a dropped mark is placed before the table |
flm.cells.bad-placement | a placement is ignored, and the cell goes where the current row and column put it; a mapping is ignored whole |
flm.cells.bad-styles | the styles argument is ignored |
flm.cells.unknown-style, flm.cells.bad-style-value | the token is ignored, the others kept |
flm.cells.bad-names | the entry is ignored, the others kept |
flm.cells.overlap | the later cell is left out whole; a dropped mark is placed before the table |
flm.cells.too-large | the cell that would make the table larger than a million positions is left out; a dropped mark is placed before the table |
flm.cells.empty | nothing is written for the table, except the dropped marks of what was left out |
flm.cells.outside-table | a \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
- The feature:
Cells,feature,FEATURE; its configurationCellsConfig. - Names: the elements
ENVIRONMENT,CELL,DATA,ROW,COLUMN,MERGE,ROWNAMES,COLNAMES; the scoped packagesENVIRONMENT_PACKAGE,BODY_PACKAGE,MERGE_PACKAGE,DATA_PACKAGE; the argumentsSTYLES_ARG,PLACEMENT_ARG,CONTENT_ARG,MAPPING_ARG,DATA_ARG,RANGE_ARG,NAMES_ARG; the service slotSTYLES_SLOT; the definitionsSTYLEandLATEX_PIECE. - Reading a table:
read_grid,Grid,CellContent,Problem(reader); the block role by position:stands_in_body,InBody; the styles argument’s parser:CellStylesParser(parser). - Cell styles:
CellStyle,Effect,Parameter,StyleForm,StyleRequirement,Styles,shipped(styles). - Lowering:
lower; HTML:html; the recomposed LaTeX:latex; the rendered LaTeX:latex_rendered; the floats content handler:CellsContent(handler). - Conditions:
diagnostics.
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
cellsfeature, which provides tables of cells. Their identifiers have the formflm.cells.<condition>. Every condition is an error. - handler
- The content handler that the
cellsfeature contributes to thefloatsfeature:CellsContent, namedcells, which admits exactly one table of cells as a float’s content. - html
- The
cellsfeature’s part of an HTML page: its style definitionSTYLE(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-recomposedbackend (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 thetabularraypackage. - latex_
rendered - The definition piece of the
cellsfeature on thelatex-renderedbackend,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_gridreads the body of acellsenvironment 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
cellsfeature (FlmFeature). Under aCellsConfig, it registers thecellsenvironment in its scoped package and, underglobal, as an ordinary environment; the commands of its body and their scoped packages; the content handler for thefloatsfeature; 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. - Cells
Config - The configuration of the
cellsfeature: whether thecellsenvironment is also an ordinary environment of the document. - InBody
- The block role of
\cell,\\,\rownamesand\colnames, decided by position. The command is a block where it is a direct child of the body of acellsenvironment (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,\\,\rownamesand\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
cellsenvironment,flm.cells.cells: a table of cells. - ENVIRONMENT_
PACKAGE - The scoped package that holds the
cellsenvironment,flm.cells.environment: a table of cells can be written in a body whose declaration refers to it. A float type of thefloatsfeature 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
\rownamesand\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 forflm.pres.cellsrefers to it, and the shipped custom styles require it on HTML. - STYLES_
ARG - The name of the styles argument of
\celland\celldata,styles. - STYLES_
SLOT - The name of the service slot of cell styles,
flm.cells.styles: everyCellStylethat 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). Thecellsfeature contributes the cell styles it ships (shipped); any feature may contribute its own, as a peer contribution.
Functions§
- feature
- The
Cellsfeature under the default configuration, ready to be listed in a package entry. - stands_
in_ body - Whether
nodeis a direct child of the body of acellsenvironment: its owner, the command or environment of whose body it is a direct child, is an element namedENVIRONMENT(flm.cells.cells).