From b33531bef5c97b2091a85f6e275adefcdd5dd7e9 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Sat, 9 Nov 2024 14:42:11 +0100 Subject: [PATCH] added max-width param to _col --- src/diagram.typ | 5 +++-- src/renderer.typ | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/diagram.typ b/src/diagram.typ index 2f3feec..b286ffc 100644 --- a/src/diagram.typ +++ b/src/diagram.typ @@ -19,14 +19,15 @@ ),) } -#let _col(p1, p2, width: auto, margin: 0, min-width: 0) = { +#let _col(p1, p2, width: auto, margin: 0, min-width: 0, max-width: none) = { return (( type: "col", p1: p1, p2: p2, width: width, margin: margin, - min-width: min-width + min-width: min-width, + max-width: max-width ),) } diff --git a/src/renderer.typ b/src/renderer.typ index 6843e47..9938e64 100644 --- a/src/renderer.typ +++ b/src/renderer.typ @@ -218,10 +218,13 @@ if elmt.width != auto { widths.at(i) = normalize-units(elmt.width) } - widths.at(i) = calc.max( - widths.at(i), - normalize-units(elmt.min-width) - ) + normalize-units(elmt.margin) + + let width = widths.at(i) + width = calc.max(width, normalize-units(elmt.min-width)) + if elmt.max-width != none { + width = calc.min(width, normalize-units(elmt.max-width)) + } + widths.at(i) = width + normalize-units(elmt.margin) } }