From b9751385d126c1dee3d21504e311bb1dc2fdacf8 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 23 Jan 2025 13:08:50 -0800 Subject: [PATCH] Added `if_solutions` methods Reviewed-on: https://git.betalupi.com/Mark/handouts/pulls/5 Co-authored-by: Mark Co-committed-by: Mark --- lib/typst/local/handout/0.1.0/handout.typ | 6 +++++- src/Advanced/Tropical Polynomials/parts/00 arithmetic.typ | 2 +- .../Tropical Polynomials/parts/01 polynomials.typ | 8 ++++---- src/Advanced/Tropical Polynomials/parts/02 cubic.typ | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/typst/local/handout/0.1.0/handout.typ b/lib/typst/local/handout/0.1.0/handout.typ index 63dd031..f35cebd 100755 --- a/lib/typst/local/handout/0.1.0/handout.typ +++ b/lib/typst/local/handout/0.1.0/handout.typ @@ -137,7 +137,11 @@ } } -#let notsolution(content) = { +#let if_solutions(content) = { + if show_solutions { content } +} + +#let if_no_solutions(content) = { if not show_solutions { content } } diff --git a/src/Advanced/Tropical Polynomials/parts/00 arithmetic.typ b/src/Advanced/Tropical Polynomials/parts/00 arithmetic.typ index 3c89898..819e524 100644 --- a/src/Advanced/Tropical Polynomials/parts/00 arithmetic.typ +++ b/src/Advanced/Tropical Polynomials/parts/00 arithmetic.typ @@ -126,7 +126,7 @@ Fill the following tropical addition and multiplication tables #let col = 10mm -#notsolution( +#if_no_solutions( table( columns: (1fr, 1fr), align: center, diff --git a/src/Advanced/Tropical Polynomials/parts/01 polynomials.typ b/src/Advanced/Tropical Polynomials/parts/01 polynomials.typ index 1a809f8..7a88c3b 100644 --- a/src/Advanced/Tropical Polynomials/parts/01 polynomials.typ +++ b/src/Advanced/Tropical Polynomials/parts/01 polynomials.typ @@ -63,7 +63,7 @@ where all exponents represent repeated tropical multiplication. Draw a graph of the tropical polynomial $f(x) = x^2 #tp 1x #tp 4$. \ #hint([$1x$ is not equal to $x$.]) -#notsolution(graphgrid(none)) +#if_no_solutions(graphgrid(none)) #solution([ $f(x) = min(2x , 1+x, 4)$, which looks like: @@ -132,7 +132,7 @@ How can we use the graph to determine these roots? Graph $f(x) = -2x^2 #tp x #tp 8$. \ #hint([Use half scale. 1 box = 2 units.]) -#notsolution(graphgrid(none)) +#if_no_solutions(graphgrid(none)) #solution([ #graphgrid({ @@ -210,7 +210,7 @@ and always produces $7$ for sufficiently large inputs. #problem() Graph $f(x) = 1x^2 #tp 3x #tp 5$. -#notsolution(graphgrid(none)) +#if_no_solutions(graphgrid(none)) #solution([ The graphs of all three terms intersect at the same point: @@ -261,7 +261,7 @@ How are the roots of $f$ related to its coefficients? #problem() Graph $f(x) = 2x^2 #tp 4x #tp 4$. -#notsolution(graphgrid(none)) +#if_no_solutions(graphgrid(none)) #solution( graphgrid({ diff --git a/src/Advanced/Tropical Polynomials/parts/02 cubic.typ b/src/Advanced/Tropical Polynomials/parts/02 cubic.typ index a63bec0..5b586f2 100644 --- a/src/Advanced/Tropical Polynomials/parts/02 cubic.typ +++ b/src/Advanced/Tropical Polynomials/parts/02 cubic.typ @@ -10,7 +10,7 @@ Consider the polynomial $f(x) = x^3 #tp x^2 #tp 3x #tp 6$. \ - use this graph to find the roots of $f$ - write (and expand) a product of linear factors with the same graph as $f$. -#notsolution(graphgrid(none)) +#if_no_solutions(graphgrid(none)) #solution([ - Roots are 1, 2, and 3. @@ -48,7 +48,7 @@ Consider the polynomial $f(x) = x^3 #tp x^2 #tp 6x #tp 6$. \ - use this graph to find the roots of $f$ - write (and expand) a product of linear factors with the same graph as $f$. -#notsolution(graphgrid(none)) +#if_no_solutions(graphgrid(none)) #solution([ - Roots are 1, 2.5, and 2.5. @@ -82,7 +82,7 @@ Consider the polynomial $f(x) = x^3 #tp 6x^2 #tp 6x #tp 6$. \ - use this graph to find the roots of $f$ - write (and expand) a product of linear factors with the same graph as $f$. -#notsolution(graphgrid(none)) +#if_no_solutions(graphgrid(none)) #solution([ - Roots are 2, 2, and 2.