From 83f797bd52b2793534f22ee366a4b1f6c8580a7e Mon Sep 17 00:00:00 2001 From: szdytom Date: Tue, 8 Jul 2025 17:34:29 +0800 Subject: [PATCH] better visual effects Signed-off-by: szdytom --- color.typ | 25 ++++++++++++++++ cover.typ | 26 ++++++++++++++++ main.typ | 66 +++++++++++++++++++++++++++++++++++----- outline.typ | 3 ++ sections/1A.typ | 2 -- sections/1B.typ | 2 -- sections/1C.typ | 8 +++-- styles.typ | 80 ++++++++++++++++++++----------------------------- toc.typ | 4 +++ 9 files changed, 154 insertions(+), 62 deletions(-) create mode 100644 color.typ create mode 100644 cover.typ create mode 100644 outline.typ create mode 100644 toc.typ diff --git a/color.typ b/color.typ new file mode 100644 index 0000000..4cb9746 --- /dev/null +++ b/color.typ @@ -0,0 +1,25 @@ +// #let theme_color = cmyk(0%, 70%, 100%, 0%) + +#let theme_color_set = ( + "100": cmyk(0%, 70%, 100%, 0%), + "90": rgb("#ee7b1a"), + "80": rgb("#ef8933"), + "70": rgb("#f1984d"), + "60": rgb("#f3a766"), + "50": rgb("#f5b680"), + "40": rgb("#f7c499"), + "30": rgb("#f9d3b3"), + "20": rgb("#fbe1cc"), + "10": rgb("#fdf0e6"), +) + +#let text_color_set = ( + "100": cmyk(100%, 70%, 70%, 30%), + "90": rgb("#1a5356"), +) + +#let aux_color_set = ( + "100": cmyk(70%, 0%, 35%, 0%), + "20": rgb("#d4f0ef"), + "10": rgb("#eaf7f7"), +) \ No newline at end of file diff --git a/cover.typ b/cover.typ new file mode 100644 index 0000000..af79896 --- /dev/null +++ b/cover.typ @@ -0,0 +1,26 @@ +#import "styles.typ": zhfont_sans +#import "color.typ": text_color_set, theme_color_set + +#{ +// Book Cover +set align(right) +set text(font: zhfont_sans) +v(5fr) +{ + set text(fill: text_color_set.at("100"), weight: "semibold") + stack( + dir: ttb, + spacing: 15pt, + text([线性代数应该这样学], 22pt), + text([习题解答], 33pt), + box(width: 10 * 22pt, { + line(end: (100%, 0%), stroke: 3pt + theme_color_set.at("100")) + line(end: (38.2%, 0%), stroke: 3pt + text_color_set.at("100")) + }) + ) +} +v(2fr) + +pagebreak(weak: true) + +} \ No newline at end of file diff --git a/main.typ b/main.typ index 54bd68a..0eaf0db 100644 --- a/main.typ +++ b/main.typ @@ -1,11 +1,59 @@ -#import "styles.typ": project, setup_main_text +#import "styles.typ": project, setup_main_text, margin-wrapper, zhfont_sans +#import "toc.typ": toc +#import "color.typ": text_color_set, theme_color_set #show: project.with("线性代数应该这样学 习题解答") -#let toc = (( - title: [向量空间], - sections: 3, -),) +#include "cover.typ" + +#[ +#show heading.where(level: 1): set text(22pt) += 目录 +#v(1em) +#margin-wrapper( + margin: 2em, + context for i in range(0, toc.len()) { + set text(font: zhfont_sans) + let chapter = toc.at(i) + let nc = numbering("1", i + 1) + let clabel = label("chapter-heading" + nc) + let cloc = query(selector(clabel)).first().location() + link(cloc, { + set text(15pt, fill: text_color_set.at("100")) + numbering("第1章", i + 1) + h(1em) + chapter.title + + h(10pt) + box(width: 1fr, repeat(sym.dot)) + h(10pt) + + str(counter(page).at(cloc).at(0)) + }) + margin-wrapper( + margin: 2em, + for j in range(0, chapter.sections.len()) { + let ns = numbering("1A", i + 1, j + 1) + let slabel = label("section-heading" + ns) + let sloc = query(selector(slabel)).first().location() + link(cloc, { + set text(11pt, fill: text_color_set.at("100")) + ns + h(1em) + chapter.sections.at(j) + + h(10pt) + box(width: 1fr, repeat(sym.dot)) + h(10pt) + + str(counter(page).at(sloc).at(0)) + }) + linebreak() + } + ) + } +) +] #[ #show: setup_main_text @@ -15,12 +63,14 @@ for i in range(0, toc.len()) { pagebreak(weak: true) let chapter = toc.at(i) - heading(chapter.title, level: 1) - for j in range(0, chapter.sections) { + [#heading(chapter.title, level: 1) #label("chapter-heading" + numbering("1", i + 1))] + for j in range(0, chapter.sections.len()) { if j > 0 { pagebreak(weak: true) } - include "sections/" + numbering("1A", i + 1, j + 1) + ".typ" + let n = numbering("1A", i + 1, j + 1) + [#heading(chapter.sections.at(j), level: 2) #label("section-heading" + n)] + include "sections/" + n + ".typ" } } diff --git a/outline.typ b/outline.typ new file mode 100644 index 0000000..f2f36cc --- /dev/null +++ b/outline.typ @@ -0,0 +1,3 @@ +#import "color.typ": text_color_set, theme_color_set +#import "toc.typ": toc + diff --git a/sections/1A.typ b/sections/1A.typ index 3dc4a6d..72d38d8 100644 --- a/sections/1A.typ +++ b/sections/1A.typ @@ -1,7 +1,5 @@ #import "../styles.typ": exercise_sol, ii, note, tab, simple_box, unset-list-indent -== $RR^n$ 和 $CC^n$ - #exercise_sol(type: "proof")[ 证明:$alpha + beta = beta + alpha$ 对所有 $alpha,beta in CC$ 成立。 ][ diff --git a/sections/1B.typ b/sections/1B.typ index 94f95f7..c62517b 100644 --- a/sections/1B.typ +++ b/sections/1B.typ @@ -1,7 +1,5 @@ #import "../styles.typ": exercise_sol, ii, note, tab -== 向量空间的定义 - #exercise_sol(type: "proof")[ 证明:$-(-v)=v$ 对任一 $v in V$ 都成立。 diff --git a/sections/1C.typ b/sections/1C.typ index 736c77d..447ec3b 100644 --- a/sections/1C.typ +++ b/sections/1C.typ @@ -1,7 +1,5 @@ #import "../styles.typ": exercise_sol, ii, note, tab, unset-list-indent -== 子空间 - #exercise_sol(type: "answer")[ 对于 $FF^3$ 的下列各个子集,判断其是否是 $FF^3$ 的子空间: @@ -222,3 +220,9 @@ #tab 这个集合满足对标量数乘封闭,但不满足对加法封闭。比如,取 $u = (1, 0) in U$,$v = (0, 1) in U$,则 $u+v=(1, 1) in.not U$。因此 $U$ 不是 $RR^2$ 的子空间。 ] + +#exercise_sol(type: "answer")[ + 函数 $f: RR -> RR$ 被成为*周期的(periodic)*,是指存在一正数 $p$,使得 $f(x) = f(x + p)$ 对所有 $x in RR$ 成立。$RR -> RR$ 上的周期函数构成的集合是不是 $RR^RR$ 的子空间?请作解释。 +][ + 不是。取 $f(x) = sin x$,$g(x) = sin (sqrt(2) x)$,并令 $h=f+g$。下面说明 $h$ 不是周期函数。 +] diff --git a/styles.typ b/styles.typ index bc4c034..47a5cf4 100644 --- a/styles.typ +++ b/styles.typ @@ -3,20 +3,20 @@ #import "@preview/cetz:0.3.2" #import "@preview/cetz-plot:0.1.1": plot +#import "color.typ": theme_color_set, text_color_set, aux_color_set + #let zhfont_sans = ("Noto Sans CJK SC",) #let zhfont_serif = ("Noto Serif CJK SC",) #let zhfont_fangsong = ("Zhuque Fangsong (technical preview)", "Noto Serif CJK SC") #let monofont = ("Fira Code",) -#let theme_color = color.green - #let tab = h(2em) #let halftab = h(1em) #let ee = "e" #let ii = "i" #let margin-wrapper(margin: 2.5em, body) = { - set align(center) + // set align(center) block(inset: ( left: margin, ), width: 100%, body) @@ -40,14 +40,15 @@ breakable: true, title-style: ( weight: 900, - color: theme_color.darken(40%), + color: text_color_set.at("100"), sep-thickness: 0pt, - font: zhfont_sans + font: zhfont_sans, ), frame: ( - title-color: theme_color.lighten(80%), - border-color: theme_color.darken(40%), - thickness: (left: 1pt), + title-color: theme_color_set.at("20"), + border-color: theme_color_set.at("100"), + body-color: aux_color_set.at("10"), + thickness: (left: 3pt), radius: 0pt ), ) @@ -55,9 +56,9 @@ #let problem_box = showy_wrapper.with( breakable: false, frame: ( - title-color: theme_color.lighten(80%), - border-color: theme_color.darken(40%), - thickness: (left: 1pt), + body-color: aux_color_set.at("10"), + border-color: theme_color_set.at("100"), + thickness: (left: 3pt), radius: 0pt, align: left, ), @@ -83,38 +84,30 @@ spacing: 1.2em, leading: 0.75em, ) - set list(marker: (text(sym.square.filled.small, fill: theme_color), text([--], fill: theme_color)), indent: 2.5em) + set list(marker: (text(sym.square.filled.small, fill: theme_color_set.at("100")), text([--], fill: theme_color_set.at("100"))), indent: 2.5em) set enum(indent: 2.5em) set terms(indent: 2.5em) - show heading: set text(font: zhfont_sans, weight: "semibold") - show strong: set text(fill: theme_color.darken(40%)) + show heading: set text(font: zhfont_sans, weight: "semibold", text_color_set.at("100")) + show strong: set text(fill: theme_color_set.at("100")) set par(justify: true) set text(11pt) - show heading.where(level: 3): set text(14pt) show figure.caption: set text(9pt, font: zhfont_fangsong) show footnote.entry: set text(9pt, font: zhfont_fangsong) - set table(stroke: 1pt + theme_color, inset: 5pt) - set grid(stroke: 1pt + theme_color) + set table(stroke: 1pt + theme_color_set.at("100"), inset: 5pt) + set grid(stroke: 1pt + theme_color_set.at("100")) set highlight(fill: none, stroke: ( - bottom: 4pt + theme_color.lighten(80%) + bottom: 4pt + theme_color_set.at("10") )) set footnote(numbering: "注1") show math.equation: set text(font: ("New Computer Modern Math", ..zhfont_serif)) - - v(10fr) - h(2fr) - [ - #set text(2em, weight: "light", font: zhfont_sans) - #title - ] - v(3fr) + hide[#title ] body } #let note(body, supplement: "注") = { if supplement != none { - text(supplement, 9pt, font: zhfont_sans, weight: "medium", fill: theme_color.darken(40%)) + text(supplement, 9pt, font: zhfont_sans, weight: "medium", fill: theme_color_set.at("100")) h(0.5em) } text(body, 9pt, font: zhfont_fangsong) @@ -124,15 +117,15 @@ // TODO: wrap placed figures: https://github.com/typst/typst/issues/5181 figure(box( inset: 5pt, - stroke: 1pt + theme_color, + stroke: 1pt + theme_color_set.at("100"), body ), ..args) } #let fancy_term_box(title, value) = { box(baseline: 3pt,{ - box(fill: theme_color.lighten(80%), inset: 3pt, text([#title], fill: theme_color.darken(40%), font: zhfont_sans, weight: "medium")) - box(fill: theme_color.lighten(20%), inset: 3pt, text([#value], fill: white, font: zhfont_sans, weight: "medium"))}, + box(fill: theme_color_set.at("20"), inset: 3pt, text([#title], fill: theme_color_set.at("100"), font: zhfont_sans, weight: "medium")) + box(fill: theme_color_set.at("60"), inset: 3pt, text([#value], fill: white, font: zhfont_sans, weight: "medium"))}, ) } @@ -149,7 +142,7 @@ inset: 0.4em, stroke: none, grid.cell( - fill: theme_color.lighten(20%), + fill: theme_color_set.at("80"), { set text(fill: white) "第" @@ -157,7 +150,7 @@ "章" }), grid.cell( - fill: theme_color.lighten(80%), + fill: theme_color_set.at("20"), { it.body }) @@ -170,8 +163,8 @@ counter("section_N").step() counter(figure.where(kind: "exercise-problem")).update(0) block(width: 100%, { - set text(30pt, font: zhfont_sans, weight: "light") - block(stroke: (bottom: 10pt + theme_color.lighten(80%),), inset: -2pt)[ + set text(30pt, font: zhfont_sans, weight: "regular") + block(stroke: (bottom: 10pt + theme_color_set.at("20"),), inset: -2pt)[ #context{ counter("chapter_N").display("1") counter("section_N").display("A") @@ -188,7 +181,7 @@ let isleft = calc.even(this_page) set align(left) if isleft set align(right) if not isleft - set text(9pt, font: zhfont_sans, fill: theme_color.darken(20%)) + set text(9pt, font: zhfont_sans, fill: text_color_set.at("100"), weight: "semibold") let prev_headers = query(selector().before(here())) let book_title = query(selector()).first().text @@ -230,30 +223,21 @@ "explain": "解释", ) tab - text(splt.at(type), font: zhfont_sans, weight: "medium", fill: theme_color.darken(40%)) + text(splt.at(type), font: zhfont_sans, weight: "medium", fill: theme_color_set.at("100")) h(0.5em) s if type == "proof" { h(1fr) - text(sym.square.filled, fill: theme_color) + text(sym.square.filled, fill: theme_color_set.at("60")) } } #let ploting-styles = ( - mark: (fill: theme_color.lighten(80%), stroke: theme_color), + mark: (fill: theme_color_set.at("10"), stroke: theme_color_set.at("80")), nothing: (fill: none, stroke: none), - s_l20: (stroke: theme_color.lighten(20%)), - s: (stroke: theme_color), - s_d20: (stroke: theme_color.darken(20%)), - s_hl: (stroke: theme_color.darken(20%) + 2pt), - s_hl_l20: (stroke: theme_color.lighten(20%) + 2pt), - s_black: (stroke: black), - - f_l80: (stroke: none, fill: theme_color.lighten(80%)), - f_l90: (stroke: none, fill: theme_color.lighten(90%)), - f_l95: (stroke: none, fill: theme_color.lighten(95%)), + s: (stroke: theme_color_set.at("100")), axis: cetz.draw.set-style(axes: (stroke: .5pt, tick: (stroke: .5pt))), ) diff --git a/toc.typ b/toc.typ new file mode 100644 index 0000000..0169534 --- /dev/null +++ b/toc.typ @@ -0,0 +1,4 @@ +#let toc = (( + title: [向量空间], + sections: ([$RR^n$ 和 $CC^n$], [向量空间的定义], [子空间]), +),)