Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions packages/preview/modern-cug-report/0.1.3/Base/base.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// 判断是否为标量类型(不是容器类型)
#let is-scalar(val) = {
type(val) not in (array, dictionary)
}


/**
* 递归合并dict,base是默认的全部参数,config是用户设定的部分参数
*/
#let merge-dict(base, config) = {
// 深度合并字典,递归处理嵌套字典
if type(base) != dictionary or type(config) != dictionary {
panic("Both arguments must be dictionaries.")
}

let result = base
for (key, replacement) in config {
if key in base {
let source = base.at(key)

if type(source) == dictionary and type(replacement) == dictionary {
result.insert(key, merge-dict(source, replacement)) // dict则递归合并
} else if is-scalar(source) and is-scalar(replacement) {
result.insert(key, replacement) // 标量类型则覆盖
} else {
// 类型不兼容,保留原值
}
} else {
// result.insert(key, replacement) // 新键直接添加
}
}
result
}

41 changes: 41 additions & 0 deletions packages/preview/modern-cug-report/0.1.3/Base/list.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#let order-list(i, fill: rgb(0, 0, 255)) = {
let nums = ("①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩")
// type(i)
let it = if type(i) == int { nums.at(i - 1) } else { i }
// it
text(fill: fill)[*#it*]
}

#let order-list-black(i) = {
order-list(i, fill: rgb(0, 0, 0))
}

#let blue-num(it) = {
text(fill: rgb(0, 0, 255))[*#it*]
}

// 用于展示研究基础中的参考文献。
#let ref-list(..it, size:11.5pt) = {

// unable to overwrite
show table.cell: it => {
// set table.cell.where(y: 0): strong
set text(size: size)
set par(spacing: 1.4em, leading: 0.9em)
it
}

// show table.cell.where(y: 0): it => text(it)
// show table.cell: it => text(it, weight: "regular")
v(-0.6em)

table(
columns: (0.68cm, 1fr), // (2.0cm, 1.9cm, 1.55cm),
rows: auto,
align: (top + left, top),
stroke: 0pt,
inset: (x:0pt, y:6.5pt),
..it
)
v(-0.6em)
}
51 changes: 51 additions & 0 deletions packages/preview/modern-cug-report/0.1.3/Base/paragraph.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#let p-compact(it, spacing: 1.24em, leading: 1em) = {
// leading: 行距; spacing: 段距
set par(spacing: spacing, leading: leading)
it
}

#let set-heading(it, fake-par: false, margin: 0.15em) = {
// https://github.com/typst/typst/issues/1896
// https://github.com/shuosc/SHU-Bachelor-Thesis-Typst/issues/12
show heading: it => {
// v(margin)
it
// v(margin)
}

show heading.where(level: 1): it => {
set text(fill: blue) // size: 14pt, , weight: "regular"
set par(leading: 1.0em, spacing: 1.24em)
show "、": [、#h(0.2em)]
show ",": [,#h(0.2em)]
// counter(math.equation).update(0)
// counter(figure.where(kind: image)).update(0)
// counter(figure.where(kind: table)).update(0)
// counter(figure.where(kind: raw)).update(0)
// it.fields()
v(0.5em)
it.body
}

show heading.where(level: 2): it => {
set text(fill: black, weight: "bold") // size: 13pt,
it
v(0.4em)
}

show heading.where(level: 3): it => {
it
v(0.3em)
}

show heading.where(level: 4): it => {
it
v(0.25em)
}

show heading.where(level: 5): it => {
it
v(0.25em)
}
it
}
69 changes: 69 additions & 0 deletions packages/preview/modern-cug-report/0.1.3/Base/size.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#import "base.typ": is-scalar, merge-dict


#let font = (
四号: 14pt,
小四: 12pt,
五号: 10.5pt,
)


// 必须要定义为show function才能生效
#let set-size(it, config) = {
set text(size: config.text)

show math.equation: set text(size: config.math.text)
show math.equation.where(block: true): set text(size: config.math.block)

show figure.caption: set text(size: config.figure) // 图名
show figure.caption.where(kind: table): set text(size: config.table) // 表名

// 不要在全局设置 table.cell 样式,会导致后续无法覆盖
// 使用 table-default 或 table-styled 函数来应用样式
show raw: set text(size: config.raw)

show heading.where(level: 1): set text(size: config.heading.H1)
show heading.where(level: 2): set text(size: config.heading.H2)
show heading.where(level: 3): set text(size: config.heading.H3)
show heading.where(level: 4): set text(size: config.heading.H4)
show heading.where(level: 5): set text(size: config.heading.H5)
show heading.where(level: 6): set text(size: config.heading.H6)
it
}

#let default-size(text: 13pt) = {
(
text: text,
math: (
text: text - 0.5pt, // 插入正文的公式
block: text - 0.5pt, // 单独一行的公式
),
figure: text - 1pt, // 图件标题
table: text - 1pt, // 表格标题
raw: text - 2pt, // 代码
heading: (
default: text, //
H1: text + 1.5pt, // default + 1
H2: text + 1.0pt, // default
H3: text + 0.5pt, // default
H4: text + 0.5pt, // default
H5: text + 0.5pt, // default
H6: text + 0.5pt, // default
),
)
}

#let define-size(text, config) = {
let base_size = default-size(text: text)
merge-dict(base_size, config)
}

// 为表格应用自定义样式(统一函数,可用于默认或特殊表格)
#let table-styled(tbl, config: (text: 11pt, math: 10pt)) = {
show table.cell: it => {
set text(size: config.text)
show math.equation: set text(size: config.math)
it
}
tbl
}
41 changes: 41 additions & 0 deletions packages/preview/modern-cug-report/0.1.3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# typst自然科学报告写作规范

> Typst Template for Natural Science Reports


<!-- ![](./thumbnail.png) -->

## Installation

- Local mode
```powershell
# powershell
mkdir -path $env:APPDATA/typst/packages/local
cd $env:APPDATA/typst/packages/local
git clone https://github.com/CUG-hydro/modern-cug-report.typ modern-cug-report
```

- Official released

```typst
#import "@local/modern-cug-report:0.1.3": *
#show: (doc) => template(doc,
footer: "CUG水文气象学2025",
header: "蒸散发的基本原理"
)
#let delta(x) = $Delta #x$
```

## Example

A complete example can be found at: [example/ch03_Evapotranspiration.typ](example/ch03_Evapotranspiration.typ)

The following is the output of the above example:

![](./example/p1.png)

![](./example/p2.png)

![](./example/p3.png)

![](./example/p4.png)
40 changes: 40 additions & 0 deletions packages/preview/modern-cug-report/0.1.3/boxes.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#import "@preview/showybox:2.0.4": showybox


#let nonum(eq) = math.equation(block: true, numbering: none, eq)

#let mybox(it, color, width: auto) = {
context {
showybox(
it,
frame: (
// title-color: red.darken(30%),
inset: (x: 0.4em, y: 0.55em),
border-color: color.darken(30%),
body-color: color.lighten(95%),
),
width: width,
// width: 90%,
// title: [*比热容*]
)
v(-0.2em)
}
}

#let box-blue(it) = mybox(it, blue)

#let box-green(it) = mybox(it, green)

#let box-red(it) = mybox(it, red)

#let beamer-block(value, color: black.lighten(10%)) = {
let margin = -0.4em
v(margin)

let mar = 0.25em
pad(left: mar)[
#block(fill: luma(240), inset: (x: 0.4em, y: 0.6em), outset: 0em, stroke: (left: mar + color))[#value]
]

v(margin)
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions packages/preview/modern-cug-report/0.1.3/example/References.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
@article{miguezmacho_role_2012,
title = {The role of groundwater in the {Amazon} water cycle: 1. {Influence} on seasonal streamflow, flooding and wetlands},
volume = {117},
copyright = {http://onlinelibrary.wiley.com/termsAndConditions\#vor},
issn = {0148-0227},
shorttitle = {The role of groundwater in the {Amazon} water cycle},
url = {https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2012JD017539},
doi = {10.1029/2012JD017539},
language = {en},
number = {D15},
urldate = {2024-11-14},
journal = {Journal of Geophysical Research: Atmospheres},
author = {Miguez‐Macho, Gonzalo and Fan, Ying},
month = aug,
year = {2012},
keywords = {⭐⭐, /unread},
pages = {2012JD017539},
file = {Miguez‐Macho_Fan - 2012 - Journal of Geophysical Research Atmospheres - The role of groundwater in the Amazon water cycle.pdf:D\:\\Documents\\OneDrive\\Research\\Zotero\\生态水文模型\\KongSPAC\\地下水\\Miguez‐Macho_Fan - 2012 - Journal of Geophysical Research Atmospheres - The role of groundwater in the Amazon water cycle.pdf:application/pdf},
}

@article{miguez-macho_spatiotemporal_2021,
title = {Spatiotemporal origin of soil water taken up by vegetation},
volume = {598},
issn = {0028-0836, 1476-4687},
url = {https://www.nature.com/articles/s41586-021-03958-6},
doi = {10.1038/s41586-021-03958-6},
language = {en},
number = {7882},
urldate = {2024-11-14},
journal = {Nature},
author = {Miguez-Macho, Gonzalo and Fan, Ying},
month = oct,
year = {2021},
keywords = {⭐},
pages = {624--628},
file = {Miguez-Macho_Fan - 2021 - Nature - Spatiotemporal origin of soil water taken up by vegetation.pdf:D\:\\Documents\\OneDrive\\Research\\Zotero\\生态水文模型\\KongSPAC\\地下水\\Miguez-Macho_Fan - 2021 - Nature - Spatiotemporal origin of soil water taken up by vegetation.pdf:application/pdf},
}

@article{miguezmacho_incorporating_2007,
title = {Incorporating water table dynamics in climate modeling: 2. {Formulation}, validation, and soil moisture simulation},
volume = {112},
copyright = {http://onlinelibrary.wiley.com/termsAndConditions\#vor},
issn = {0148-0227},
shorttitle = {Incorporating water table dynamics in climate modeling},
url = {https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2006JD008112},
doi = {10.1029/2006JD008112},
language = {en},
number = {D13},
urldate = {2024-11-14},
journal = {Journal of Geophysical Research: Atmospheres},
author = {Miguez‐Macho, Gonzalo and Fan, Ying and Weaver, Christopher P. and Walko, Robert and Robock, Alan},
month = jul,
year = {2007},
keywords = {⭐⭐},
pages = {2006JD008112},
file = {Miguez‐Macho et al - 2007 - Journal of Geophysical Research Atmospheres - Incorporating water table dynamics in climate modeling.pdf:D\:\\Documents\\OneDrive\\Research\\Zotero\\生态水文模型\\KongSPAC\\地下水\\Miguez‐Macho et al - 2007 - Journal of Geophysical Research Atmospheres - Incorporating water table dynamics in climate modeling.pdf:application/pdf},
}

@article{fan_incorporating_2007,
title = {Incorporating water table dynamics in climate modeling: 1. {Water} table observations and equilibrium water table simulations},
volume = {112},
copyright = {http://onlinelibrary.wiley.com/termsAndConditions\#vor},
issn = {0148-0227},
shorttitle = {Incorporating water table dynamics in climate modeling},
url = {https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2006JD008111},
doi = {10.1029/2006JD008111},
language = {en},
number = {D10},
urldate = {2024-11-16},
journal = {Journal of Geophysical Research: Atmospheres},
author = {Fan, Ying and Miguez‐Macho, Gonzalo and Weaver, Christopher P. and Walko, Robert and Robock, Alan},
month = may,
year = {2007},
pages = {2006JD008111},
file = {Fan et al - 2007 - Journal of Geophysical Research Atmospheres - Incorporating water table dynamics in climate modeling.pdf:D\:\\Documents\\OneDrive\\Research\\Zotero\\生态水文模型\\KongSPAC\\地下水\\Fan et al - 2007 - Journal of Geophysical Research Atmospheres - Incorporating water table dynamics in climate modeling.pdf:application/pdf},
}

@article{miguezmacho_role_2012-1,
title = {The role of groundwater in the {Amazon} water cycle: 2. {Influence} on seasonal soil moisture and evapotranspiration},
volume = {117},
copyright = {http://onlinelibrary.wiley.com/termsAndConditions\#vor},
issn = {0148-0227},
shorttitle = {The role of groundwater in the {Amazon} water cycle},
url = {https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2012JD017540},
doi = {10.1029/2012JD017540},
language = {en},
number = {D15},
urldate = {2024-11-18},
journal = {Journal of Geophysical Research: Atmospheres},
author = {Miguez‐Macho, Gonzalo and Fan, Ying},
month = aug,
year = {2012},
pages = {2012JD017540},
file = {Miguez‐Macho_Fan - 2012 - Journal of Geophysical Research Atmospheres - The role of groundwater in the Amazon water cycle.pdf:D\:\\Documents\\OneDrive\\Research\\Zotero\\生态水文模型\\KongSPAC\\地下水\\Miguez‐Macho_Fan - 2012 - Journal of Geophysical Research Atmospheres - The role of groundwater in the Amazon water cycle2.pdf:application/pdf},
}

@book{monteith2013,
title={Principles of environmental physics: plants, animals, and the atmosphere},
author={Monteith, John and Unsworth, Mike},
year={2013},
publisher={Academic press}
}
Loading