Files
mytoolkit/templates/md-to-pdf/cv/template.typ
T
Zhengshou Lai 2791a785ff feat: add document conversion templates
Add md-to-pdf and md-to-docx templates for mytoolkit convert command.
Migrated from workspace/templates.
2026-05-06 00:11:37 +08:00

131 lines
2.9 KiB
Typst

// CV 模板 —— 简洁学术风格,参考 default 模板
#let serif-stack = ("Cambria", "PingFang SC", "Helvetica Neue", "Arial")
#let sans-stack = ("Cambria", "PingFang SC", "Helvetica Neue", "Arial")
#let mono-stack = ("Courier New", "Menlo", "Monaco", "SimSun")
#let primary = rgb("#1F4E79")
#let accent = rgb("#3467A8")
#let light = rgb("#96A0AA")
#let rule-blue = accent.lighten(46%)
#let _cv-h1-counter = counter("cv-h1")
#let three-line-table(..args) = {
let kwargs = args.named()
let children = args.pos()
let new_children = ()
let header_seen = false
for child in children {
if child.func() == table.header {
new_children.push(table.hline(stroke: 1.25pt + rule-blue))
new_children.push(child)
header_seen = true
} else if header_seen and child.func() == table.hline {
new_children.push(table.hline(stroke: 0.75pt + rule-blue))
header_seen = false
} else {
new_children.push(child)
}
}
new_children.push(table.hline(stroke: 1.25pt + rule-blue))
kwargs.stroke = none
kwargs.inset = (x: 8pt, y: 5pt)
table(..new_children, ..kwargs)
}
#let cv(body) = {
set page(
paper: "a4",
margin: (top: 2.0cm, bottom: 2.0cm, left: 2.0cm, right: 2.0cm),
header: context {
align(right)[
#text(size: 8pt, fill: light)[
Updated on #datetime.today().display("[year]-[month]-[day]")
]
]
},
footer: context {
align(center)[
#text(size: 8pt, fill: light)[
— #counter(page).display("1") —
]
]
},
)
set text(
font: serif-stack,
size: 10pt,
lang: "zh",
)
show raw: set text(font: mono-stack)
set par(
justify: true,
leading: 0.72em,
spacing: 0.92em,
first-line-indent: 0em,
)
set list(tight: true, indent: 1.2em, body-indent: 0.45em, spacing: 0.85em)
set enum(tight: true, indent: 1.2em, body-indent: 0.45em, spacing: 0.85em)
show heading: it => {
set text(font: sans-stack)
it
}
show heading.where(level: 1): it => {
_cv-h1-counter.step()
context {
let n = _cv-h1-counter.get().first()
if n == 1 {
align(center)[
#text(size: 18pt, weight: "bold")[#it.body]
]
v(0.8em)
} else {
v(1.2em)
text(size: 13pt, weight: "bold", fill: primary, it.body)
v(0.45em)
}
}
}
show heading.where(level: 2): it => {
v(0.8em)
stack(spacing: 0.5em,
text(size: 11pt, weight: "bold", fill: accent, it.body),
line(length: 100%, stroke: 0.7pt + rule-blue),
)
v(0.2em)
}
show heading.where(level: 3): it => {
v(0.5em)
text(size: 10pt, weight: "bold", fill: light, it.body)
v(0.2em)
}
set heading(numbering: none)
show link: it => text(fill: accent, it)
show strong: it => {
text(font: sans-stack, weight: "bold", it.body)
}
set table(
inset: (x: 8pt, y: 5pt),
stroke: 0.5pt + rule-blue,
)
body
}