Grids¶
The grid{} keyword draws a ruled rectangle with part of its cells
coloured — the figure a fraction, an area or a multiplication is read on.
The first value is the grid, rows×cols; the second — optional — the
area to colour, in the same form. As for the other keywords, values are
separated by ;, and options follow a | separator; multiple options are
separated by ;. x is accepted in place of ×, for an expression typed
on a keyboard that has none.
| Expression | Renders as |
|---|---|
grid{3×4} |
|
grid{3×4; 2×3 | start=topleft} |
What the fill descriptor says¶
The second value is read as a number of cells — 2×3 is six — and the
shape it names is a wish, not a promise: what is drawn is whatever six cells
can be made into inside that grid. Five situations follow from the two
descriptors, and the figure picks the first that applies:
- the area is the grid, or more than it (
grid{5×7; 9×9}): every cell is coloured; - the rectangle fits as asked (
grid{6×4; 3×2}): it is drawn from the start corner; - it fits once turned or reshaped (
grid{3×8; 4×2}lies down as 2×4;grid{3×8; 9×2}, eighteen cells, is drawn 3×6): the same area, in the dimensions that fit; - it does not fit, but the cells left white do (
grid{3×8; 4×5}— of twenty-four cells, twenty coloured leave four): the grid is coloured whole, and that rectangle painted back over it, in the corner opposite the start one; - neither fits (
grid{8×8; 5×9}): the area is split in two — a full-width band from the start corner, and the remainder in a one-cell-thick strip beside it.
The last two are what make an awkward number of cells drawable at all, and they are why the count, not the shape, is what the descriptor really names.
| Expression | Renders as |
|---|---|
grid{3×8; 4×5 | start=bottomright} |
|
grid{8×8; 5×9 | start=bottomleft} |
Options¶
start— the corner the colouring starts from:topleft,topright,bottomleft,bottomright, orrandom(the default) to draw one.seed— seeds that draw. Left out, the seed is derived from the expression itself, so the same expression always draws the same figure — the question page, the answer page and a snapshot rendered again months later all agree — while two different expressions get two different corners. Passseed=to vary the drawing of two otherwise identical expressions.fill— colour of the coloured cells (default:rendering.grids.fill_color).background— colour the complement strategy paints back over the filled grid. It stands for the empty cells, so it must match what the figure sits on; white by default.cell_size— side of a cell in pixels. Defaults tocell_size_ratio× the base font size.color— colour of the ruling. Left out, it follows the surrounding text.thickness— stroke width of the ruling, in pixels.baseline— vertical alignment of the grid with the surrounding text:middle(default),toporbottom.font_size— scales the whole figure by that factor.
| Expression | Renders as |
|---|---|
grid{5×5; 2×3 | start=topright ; fill=#eba215} |
The defaults of the last few live under rendering.grids in the
configuration.