Sign, variation and convexity tables in the French tkz-tab style, plus value tables (tableaux de valeurs). Supports auto-computed signs and values from Typst functions.
| Basic sign + variation | Full f’/f’’ analysis | Rational function / pole |
Auto-signs with fn |
Direct signs (no factors) | Value table (fun-table) |
Usage
#import "@preview/functable:0.1.0": sign-table, fun-table
Basic sign + variation table
#sign-table(
factors: (
(expr: $x - 1$, zeros: ((value: $1$, approx: 1),), signs: ("-", "+")),
(expr: $x + 2$, zeros: ((value: $-2$, approx: -2),), signs: ("-", "+")),
),
summary-label: $f'(x)$,
variation: true,
variation-label: $f(x)$,
start-value: $-oo$,
end-value: $+oo$,
variation-values: (
(at: -2, label: $5$),
(at: 1, label: $-4$),
),
)
Auto-computed signs with fn
Provide a Typst function for each factor instead of (or in addition to) signs.
The sign in each interval is inferred by evaluating the function at a test point:
#sign-table(
factors: (
(
expr: $x + 1$,
zeros: ((value: $-1$, approx: -1),),
fn: x => x + 1, // signs inferred automatically
),
(
expr: $x - 1$,
zeros: ((value: $1$, approx: 1),),
fn: x => x - 1,
),
),
summary-label: $f'(x)$,
variation: true,
variation-label: $f(x)$,
)
signs always takes precedence over fn if both are provided. Return none from fn
to mark an interval as HD (hors-domaine), e.g. fn: x => if x <= 0 { none } else { 1 / (2 * calc.sqrt(x)) }.
Direct signs — no factor rows
When the factorisation is not the point, give the signs of the function directly with the
top-level signs/zeros parameters (mutually exclusive with factors). Zeros can be
plain numbers — shorthand for (value: $n$, approx: n) — mixed with dictionaries:
#sign-table(
signs: ("+", "-", "+"),
zeros: (-1, (value: $2$, approx: 2, pole: true)),
summary-label: $f(x)$,
)
The same mechanism gives a variation table alone (no sign row): leave summary-label
at none, set variation: true, and the signs only steer the arrows:
#sign-table(
signs: ("-", "+"),
zeros: (2,),
variation: true,
variation-label: $f(x)$,
start-value: $+oo$,
end-value: $+oo$,
variation-values: ((at: 2, label: $-3$),),
)
second-signs does the same for the f’’ block / convexity row, sharing the top-level zeros.
Full analysis table (f’ + variation + f’’ + convexity)
#sign-table(
factors: (
(expr: $3x^2 - 3$, zeros: (
(value: $-1$, approx: -1),
(value: $1$, approx: 1),
), signs: ("+", "-", "+")),
),
summary-label: $f'(x)$,
variation: true,
variation-label: $f(x)$,
start-value: $+oo$,
end-value: $+oo$,
variation-values: (
(at: -1, label: $2$),
(at: 1, label: $-2$),
),
second-factors: (
(expr: $6x$, zeros: ((value: $0$, approx: 0),), signs: ("-", "+")),
),
second-summary-label: $f''(x)$,
convexity: true,
convexity-label: $f(x)$,
)
Rational function with pole (valeur interdite)
Mark a zero as pole: true to draw a double bar (‖) and break the variation arrows:
#sign-table(
factors: (
(expr: $x + 1$, zeros: ((value: $-1$, approx: -1),), signs: ("-", "+")),
(
expr: $x - 2$,
zeros: ((value: $2$, approx: 2, pole: true),),
signs: ("-", "+"),
),
),
summary-label: $f(x)$,
variation: true,
variation-label: $f(x)$,
)
Value table (explicit)
#fun-table(
x-values: ($0$, $1$, $2$, $3$),
rows: (
(label: $f(x)$, values: ($1$, $3$, $5$, $7$)),
),
)
Value table with auto-computed values
Provide numeric x-values and a fn closure — values are computed automatically:
#fun-table(
x-values: (-3, -2, -1, 0, 1, 2, 3),
rows: (
(label: $f(x) = x^2 - 1$, fn: x => x * x - 1),
),
)
For irrational x values or custom display, use dictionary entries:
#fun-table(
x-values: (
(display: $-pi\/2$, value: -calc.pi / 2),
(display: $0$, value: 0.0),
(display: $pi\/2$, value: calc.pi / 2),
),
rows: (
(label: $sin(x)$, fn: x => calc.sin(x), format: x => $#str(calc.round(x, digits: 4))$),
),
)
sign-table reference
| Parameter | Type | Default | Description |
|---|---|---|---|
factors |
array | () |
Factor rows for f’. Each: (expr, zeros, signs, fn, interdit). |
signs |
array | () |
Direct signs for the summary row, without factor rows. Mutually exclusive with factors. |
zeros |
array | () |
Zeros attached to top-level signs/second-signs. Same format as a factor’s zeros. |
summary-label |
content, none | none |
Label for the f’ summary row. |
variation |
bool | false |
Show variation row with diagonal arrows. |
variation-label |
content, none | none |
Label for the variation row. |
variation-values |
array | () |
Values on the variation row: (at, label, pos). |
bounds |
auto, none, dict | auto |
Domain bounds in x header. auto → $-∞$/$+∞$. |
start-value |
content, none | none |
Function value at left edge of variation row. |
start-pos |
string | "auto" |
"top", "bottom", or "auto". |
end-value |
content, none | none |
Function value at right edge of variation row. |
end-pos |
string | "auto" |
"top", "bottom", or "auto". |
col-width |
length | 1.5cm |
Width of each interval column. |
row-height |
length | 0.9cm |
Height of sign/factor rows. |
var-row-height |
auto, length | auto |
Height of variation/convexity rows. |
second-factors |
array | () |
Factor rows for f’'. Same structure as factors. |
second-signs |
array | () |
Direct signs for the f’’ block, without factor rows. Mutually exclusive with second-factors. |
second-summary-label |
content, none | none |
Label for the f’’ summary row. |
convexity |
bool, string | false |
Convexity row: true/"symbol" → ∪/∩, "text" → “convexe”/“concave”, "both" → symbol + word. |
convexity-label |
content, none | none |
Label for the convexity row. |
hd-fill |
color | rgb("#cfe2f3") |
Fill color for HD bands when hd-style: "fill". |
hd-style |
string | "hatch" |
HD rendering: "hatch", "fill", or "blank". |
show-facteurs |
bool | true |
Show rotated “facteur(s)” strip at left. |
background |
color | white |
Background for label knockout rects. Match your page/container fill. |
Factor dictionary keys
Exactly one of signs or fn is required; every other key is optional.
| Key | Type | Description |
|---|---|---|
expr |
content | Math expression for the row label. |
zeros |
array | Zero declarations (see below). |
signs |
array | "+", "-", "" (blank), or "HD" per interval. Takes precedence over fn. |
fn |
function | x => number for auto-sign inference. Return none for HD intervals. Used when signs is absent. |
interdit |
bool | All zeros of this factor are forbidden values (shorthand for pole: true on each). |
Zero dictionary keys
Each entry in a zeros array is either a plain number — shorthand for
(value: $n$, approx: n) — or a dictionary. value and approx are required;
the rest are optional:
| Key | Type | Description |
|---|---|---|
value |
content | Required. Displayed label (e.g. $sqrt(2)$). |
approx |
float | Required. Numeric approximation used for sorting and interval test points. |
pole |
bool | Valeur interdite — double bar ‖ in summary/variation/convexity. |
mark |
content, "bar", "hd" |
Custom marker in factor and summary rows. |
summary-mark |
content, "bar", "hd" |
Custom marker in summary row only. |
HD intervals
Set signs: (..., "HD", ...) for intervals where the expression does not exist,
or return none from fn. The interval renders as a hatched band (controlled by hd-style).
Use mark: "hd" on a zero to continue the hatch through a boundary point (e.g. a cusp
or vertical tangent where f’ is undefined but f continues), as opposed to mark: "bar" which
draws the asymptote double-bar.
fun-table reference
| Parameter | Type | Default | Description |
|---|---|---|---|
x-values |
array | () |
x column headers. Numbers are displayed in math mode and passed to fn. Dictionaries (display, value) use custom display with numeric value. Content is display-only. |
x-label |
content | $x$ |
Label for the x row. |
rows |
array | () |
Function rows: (label, values?, fn?, format?). |
col-width |
length | 1.5cm |
Column width. |
row-height |
length | 0.9cm |
Row height. |
label-width |
auto, length | auto |
Label column width; auto sizes to fit. |
stroke |
stroke | 0.5pt |
Table border and separator stroke. |
decimals |
auto, int | auto |
Decimal places for computed values. auto trims trailing zeros. |
Row dictionary keys
| Key | Type | Description |
|---|---|---|
label |
content | Row label. |
values |
array | Explicit content cells, one per x column. Use none for blank. Takes precedence over fn for non-numeric x. |
fn |
function | x => number used when x-values entries are numeric. Return none for a blank cell. |
format |
function, none | number => content to customise how computed values render. Default: smart integer/decimal. |
Changelog
[0.1.0] - 2026-07-14
Added
sign-table: sign/variation/convexity tables in the tkz-tab stylefun-table: simple function value tables (tableaux de valeurs)fnparameter on factors for auto-sign inference by numeric evaluationfnparameter onfun-tablerows for auto-computed values from numeric x-values- HD (hors-domaine) hatching with
"hatch","fill", and"blank"styles - Pole / valeur interdite rendering with double bars (‖) and broken arrows
- Dual f’/f’’ block with convexity row (∪/∩)
- Variation arrows with auto-positioned function value labels
- Automatic zero merging across factors
mark: "hd"for domain-boundary points without asymptote implication- Top-level
signs/zeros/second-signsfor direct sign tables and standalone variation tables without factor rows - Number shorthand in
zerosarrays:zeros: (-2, 1)≡(value: $n$, approx: n)per entry - Convexity display modes:
"symbol"(∪/∩),"text"(“convexe”/“concave”),"both"