diff --git a/product_test_template.typ b/product_test_template.typ index 36b1f12..69ad994 100644 --- a/product_test_template.typ +++ b/product_test_template.typ @@ -217,6 +217,57 @@ ) } +// Renders the test conditions as a structured key/value table. +// Each row is a tuple of (label, value). +// Usage: +// #test_conditions_table(( +// ([روش اعمال], [قطره‌ای]), +// ([دمای پخت], [۱۰۳۰، ۱۱۵۰، ۱۱۸۰ °C]), +// )) +#let test_conditions_table(rows) = { + block( + breakable: false, + align(center, table( + columns: (auto, auto), + align: right, + stroke: 0.5pt, + inset: 8pt, + fill: (x, y) => if y == 0 { luma(235) }, + [*شرط آزمون*], + [*مقدار*], + ..rows.flatten(), + )), + ) +} + +// Renders the ink formula as a component / weight-% table and appends an +// automatic total row. Component names are rendered LTR (English). +// Each row is a tuple of (component, weight). +// Usage: +// #ink_formula_table(( +// ("Pigment", 30), +// ("Sol-1", 60), +// ("Super Disp.", 10), +// )) +#let ink_formula_table(rows) = { + let total = rows.fold(0, (acc, row) => acc + row.at(1)) + block( + breakable: false, + align(center, table( + columns: (auto, auto), + align: center, + stroke: 0.5pt, + inset: 8pt, + fill: (x, y) => if y == 0 { luma(235) }, + [*جزء*], + [*درصد وزنی*], + ..rows.map(row => (text(dir: ltr, row.at(0)), [#row.at(1)])).flatten(), + table.cell(fill: luma(245), [*مجموع*]), + table.cell(fill: luma(245), [*#total*]), + )), + ) +} + // Renders the received samples as a structured table. // Each row should contain: // (pigment_name, supplier_code, internal_code, document_no)