forked from bai/curriculum-project-hub
c17af60bb0
Single entry `display(info, target, parts)` over an ordered parts array, the frozen contract the generated typst driver calls. Per-kind dispatch for segment/example/lemma/sop; student/teacher matrix derived internally from `target` (student hides example solution + lemma proof; teacher shows all). Content-field values are consumed as already-evaluated content (driver `include`s them ⇒ module body, ADR-0006), never imported/stringified. Optional fields (lemma proof, example source) handled gracefully; unknown kind/target degrade without crashing. Zero @preview deps (CI-robust); CJK + math styled. Smoke compiles to non-empty student/teacher PDFs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
71 lines
2.0 KiB
Typst
71 lines
2.0 KiB
Typst
// Shared hand-written sample lesson exercising all 4 kinds.
|
||
// Content field values are plain content blocks — exactly what the Rust driver
|
||
// would hand us via `include`.
|
||
|
||
#let info = (
|
||
title: "向量与几何 · 示例讲义",
|
||
author: ("张老师", "李老师"),
|
||
)
|
||
|
||
#let parts = (
|
||
// segment
|
||
(
|
||
kind: "segment",
|
||
textbook: [
|
||
本节研究平面向量的基本运算。设 $arrow(a)$、$arrow(b)$ 为平面内两个向量,
|
||
其数量积定义为 $arrow(a) dot arrow(b) = |arrow(a)| |arrow(b)| cos theta$,
|
||
其中 $theta$ 为两向量的夹角。
|
||
],
|
||
),
|
||
// example WITH source
|
||
(
|
||
kind: "example",
|
||
source: "2024 高考甲卷",
|
||
problem: [
|
||
已知 $arrow(a) = (1, 2)$,$arrow(b) = (3, -1)$,求 $arrow(a) dot arrow(b)$。
|
||
],
|
||
solution: [
|
||
由坐标公式,$arrow(a) dot arrow(b) = 1 times 3 + 2 times (-1) = 3 - 2 = 1$。
|
||
],
|
||
),
|
||
// example WITHOUT source
|
||
(
|
||
kind: "example",
|
||
problem: [
|
||
求向量 $arrow(a) = (3, 4)$ 的模长 $|arrow(a)|$。
|
||
],
|
||
solution: [
|
||
$|arrow(a)| = sqrt(3^2 + 4^2) = sqrt(25) = 5$。
|
||
],
|
||
),
|
||
// lemma WITH proof
|
||
(
|
||
kind: "lemma",
|
||
stmt: [
|
||
对任意向量 $arrow(a)$、$arrow(b)$,有 $|arrow(a) dot arrow(b)| <= |arrow(a)| |arrow(b)|$。
|
||
],
|
||
proof: [
|
||
由数量积定义 $arrow(a) dot arrow(b) = |arrow(a)| |arrow(b)| cos theta$,
|
||
又 $|cos theta| <= 1$,故 $|arrow(a) dot arrow(b)| = |arrow(a)| |arrow(b)| |cos theta| <= |arrow(a)| |arrow(b)|$。
|
||
$qed$
|
||
],
|
||
),
|
||
// lemma WITHOUT proof (proof key omitted entirely)
|
||
(
|
||
kind: "lemma",
|
||
stmt: [
|
||
两个非零向量垂直当且仅当其数量积为零,即 $arrow(a) perp arrow(b) <==> arrow(a) dot arrow(b) = 0$。
|
||
],
|
||
),
|
||
// sop
|
||
(
|
||
kind: "sop",
|
||
sop: [
|
||
求两向量夹角的标准步骤:
|
||
+ 计算数量积 $arrow(a) dot arrow(b)$;
|
||
+ 分别计算模长 $|arrow(a)|$、$|arrow(b)|$;
|
||
+ 代入 $cos theta = (arrow(a) dot arrow(b)) / (|arrow(a)| |arrow(b)|)$ 求出 $theta$。
|
||
],
|
||
),
|
||
)
|