From 9f7497c928e8bce2a732ca3df8b35d7dd9da84f3 Mon Sep 17 00:00:00 2001 From: Mc-Zen <52877387+Mc-Zen@users.noreply.github.com> Date: Fri, 28 Aug 2026 12:58:35 +0200 Subject: [PATCH 1/2] [fix] exponent sign with math: false --- src/formatting.typ | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/formatting.typ b/src/formatting.typ index 71c46a8..96c7a0f 100644 --- a/src/formatting.typ +++ b/src/formatting.typ @@ -23,12 +23,16 @@ /// if `positive-sign` is set to true. In all other cases, the result is /// `none`. /// -> content | none -#let format-sign(sign, positive-sign: false) = { - if sign == "-" { - math.class("unary", sym.minus) +#let format-sign(sign, positive-sign: false, math: true) = { + sign = if sign == "-" { + sym.minus } else if sign == "+" and positive-sign { - return math.class("unary", sym.plus) + sym.plus } + if math { + sign = std.math.class("unary", sign) + } + sign } @@ -167,7 +171,7 @@ )) return sequence(( - format-sign(it.sign, positive-sign: it.positive-sign), + format-sign(it.sign, positive-sign: it.positive-sign, math: it.math), format-integer((int: it.int, group: it.group)), frac, )) @@ -215,6 +219,7 @@ group: false, positive-sign: false, decimal-separator: it.decimal-separator, + math: it.math, ))) if is-symmetric { if it.concise { @@ -275,6 +280,7 @@ group: false, positive-sign: it.positive-sign-exponent, decimal-separator: it.decimal-separator, + math: it.math )) if it.math { @@ -368,7 +374,7 @@ ) let integer-part = ( - format-sign(it.sign, positive-sign: it.positive-sign), + format-sign(it.sign, positive-sign: it.positive-sign, math: it.math), format-integer(integer), ) From 1f32718f920d6683a5196e028061f6e2fdb52232 Mon Sep 17 00:00:00 2001 From: Mc-Zen <52877387+Mc-Zen@users.noreply.github.com> Date: Fri, 28 Aug 2026 13:07:11 +0200 Subject: [PATCH 2/2] [add] tests --- tests/num/positive-sign-exponent/ref.typ | 9 +++++++++ tests/num/positive-sign-exponent/test.typ | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/num/positive-sign-exponent/ref.typ b/tests/num/positive-sign-exponent/ref.typ index c324aab..856e721 100644 --- a/tests/num/positive-sign-exponent/ref.typ +++ b/tests/num/positive-sign-exponent/ref.typ @@ -6,3 +6,12 @@ $1×10^(-1)$ \ $1×10^(-1)$ \ $1×10^(+9)$ \ $1×10^(9)$ \ + +#pagebreak() +#set super(typographic: false) +1#sym.space.thin×#sym.space.thin;10#super[3] \ +1#sym.space.thin×#sym.space.thin;10#super[+3] \ +1#sym.space.thin×#sym.space.thin;10#super[−1] \ +1#sym.space.thin×#sym.space.thin;10#super[−1] \ +1#sym.space.thin×#sym.space.thin;10#super[+9] \ +1#sym.space.thin×#sym.space.thin;10#super[9] \ diff --git a/tests/num/positive-sign-exponent/test.typ b/tests/num/positive-sign-exponent/test.typ index ae95e09..ff929df 100644 --- a/tests/num/positive-sign-exponent/test.typ +++ b/tests/num/positive-sign-exponent/test.typ @@ -2,6 +2,19 @@ #set page(width: auto, height: auto, margin: 2pt) +#num("1e3", positive-sign-exponent: false) \ +#num("1e3", positive-sign-exponent: true) \ +#num("1e-1", positive-sign-exponent: false) \ +#num("1e-1", positive-sign-exponent: true) \ +#set-num(positive-sign-exponent: true) +#num("1e9") \ +#set-num(positive-sign-exponent: false) +#num("1e9") + +#pagebreak() + +#set-num(math: false) + #num("1e3", positive-sign-exponent: false) \ #num("1e3", positive-sign-exponent: true) \ #num("1e-1", positive-sign-exponent: false) \