summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-library/src/math/matrix.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/crates/typst-library/src/math/matrix.rs b/crates/typst-library/src/math/matrix.rs
index 1dee5434..91310ed3 100644
--- a/crates/typst-library/src/math/matrix.rs
+++ b/crates/typst-library/src/math/matrix.rs
@@ -270,6 +270,15 @@ pub struct CasesElem {
#[default(Delimiter::Brace)]
pub delim: Delimiter,
+ /// Whether the direction of cases should be reversed.
+ ///
+ /// ```example
+ /// #set math.cases(reverse: true)
+ /// $ cases(1, 2) = x $
+ /// ```
+ #[default(false)]
+ pub reverse: bool,
+
/// The gap between branches.
///
/// ```example
@@ -295,7 +304,14 @@ impl LayoutMath for CasesElem {
FixedAlign::Start,
self.gap(ctx.styles()),
)?;
- layout_delimiters(ctx, frame, Some(delim.open()), None, self.span())
+
+ let (open, close) = if self.reverse(ctx.styles()) {
+ (None, Some(delim.close()))
+ } else {
+ (Some(delim.open()), None)
+ };
+
+ layout_delimiters(ctx, frame, open, close, self.span())
}
}