Skip to content

Commit

Permalink
Revert block equation hack
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Oct 15, 2024
1 parent e59ce5d commit b1d76c1
Show file tree
Hide file tree
Showing 29 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions src/plot/formats.typ
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Temporary fix Typst measure bug
#let _block-eq(body) = math.equation(block: true, numbering: none, body)

// Compare two floats
#let _compare(a, b, eps: 1e-6) = {
return calc.abs(a - b) <= eps
Expand Down Expand Up @@ -59,7 +56,7 @@
/// - eps (number): Epsilon used for comparison
/// -> Content if a matching fraction could be found or none
#let fraction(value, denom: auto, eps: 1e-6) = {
return _block-eq(_find-fraction(value, denom: denom, eps: eps))
return _find-fraction(value, denom: denom, eps: eps)
}

/// Multiple of tick formatter
Expand Down Expand Up @@ -88,24 +85,24 @@
/// -> Content if a matching fraction could be found or none
#let multiple-of(value, factor: calc.pi, symbol: $pi$, fraction: true, digits: 2, eps: 1e-6, prefix: [], suffix: []) = {
if _compare(value, 0, eps: eps) {
return _block-eq($0$)
return $0$
}

let a = value / factor
if _compare(a, 1, eps: eps) {
return _block-eq(prefix + symbol + suffix)
return prefix + symbol + suffix
} else if _compare(a, -1, eps: eps) {
return _block-eq(prefix + $-$ + symbol + suffix)
return prefix + $-$ + symbol + suffix
}

if fraction != none {
let frac = _find-fraction(a, denom: if fraction == true { auto } else { fraction })
if frac != none {
return _block-eq(prefix + frac + symbol + suffix)
return prefix + frac + symbol + suffix
}
}

return _block-eq(prefix + $#calc.round(a, digits: digits)$ + symbol + suffix)
return prefix + $#calc.round(a, digits: digits)$ + symbol + suffix
}

/// Scientific notation tick formatter
Expand Down Expand Up @@ -140,10 +137,10 @@

value = calc.round(value, digits: digits)
if exponent <= -1 or exponent >= 1 {
return _block-eq(prefix + $#value times 10^#exponent$ + suffix)
return prefix + $#value times 10^#exponent$ + suffix
}

return _block-eq(prefix + $#value$ + suffix)
return prefix + $#value$ + suffix
}

/// Rounded decimal number formatter
Expand All @@ -163,5 +160,5 @@
/// - suffix (content): Content to append
/// -> Content
#let decimal(value, digits: 2, prefix: [], suffix: []) = {
_block-eq(prefix + $#calc.round(value, digits: digits)$ + suffix)
prefix + $#calc.round(value, digits: digits)$ + suffix
}
2 changes: 1 addition & 1 deletion src/plot/util.typ
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@

for (name, axis) in axis-dict {
if not "ticks" in axis { axis.ticks = () }
axis.label = get-axis-option(name, "label", math.equation(block: true, numbering: none, $#name$))
axis.label = get-axis-option(name, "label", $#name$)

// Configure axis bounds
axis.min = get-axis-option(name, "min", axis.min)
Expand Down
Binary file modified tests/axes/log-mode/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/axes/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/chart/boxwhisker/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/chart/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/annotation/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/bar/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/boxwhisker/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/broken-axes/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/contour/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/equal-axis/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/format/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/grid/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/hvline/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/legend/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/line/between/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/line/fill/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/line/line-type/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/line/linearization/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/line/mark/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/line/spline/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/marks/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/mirror-axes/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/parametric/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/reverse-axis/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/vertical/ref/1.png
Binary file modified tests/plot/violin/ref/1.png

0 comments on commit b1d76c1

Please sign in to comment.