Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modern-cornell-notebooks:0.2.0 #1570

Closed
wants to merge 4 commits into from
Closed
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
21 changes: 21 additions & 0 deletions packages/preview/modern-cornell-notebooks/0.2.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 aFeiCQUT

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions packages/preview/modern-cornell-notebooks/0.2.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Typst note template

[简体中文](README_zh.md) English

| Cover | Contents | Main Body |
|:--:|:--:|:--:|
| ![Cover](https://raw.githubusercontent.com/aFei-CQUT/cornell-notebooks/main/images/cover.png) | ![Contents](https://raw.githubusercontent.com/aFei-CQUT/cornell-notebooks/main/images/contents.png) | ![Body](https://raw.githubusercontent.com/aFei-CQUT/cornell-notebooks/main/images/body1.png) |


Simple and Functional Typst Note Template

This template is designed for efficient and organized note-taking with Typst. It provides a clean and straightforward structure, making it easy to capture and organize your thoughts without unnecessary complexity.

## Acknowledgments

The following projects have been instrumental in providing substantial inspiration and code for this project.

https://github.com/gRox167/typst-assignment-template

https://github.com/DVDTSB/dvdtyp

https://github.com/a-kkiri/SimpleNote

https://github.com/spidersouris/touying-unistra-pristine

https://github.com/wardenxyz/xyznote
23 changes: 23 additions & 0 deletions packages/preview/modern-cornell-notebooks/0.2.0/README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Typst note template

简体中文 [English](README.md)

| 封面 | 目录 | 正文 |
|:--:|:--:|:--:|
| ![Cover](https://raw.githubusercontent.com/aFei-CQUT/cornell-notebooks/main/images/cover-zh.png) | ![Contents](https://raw.githubusercontent.com/aFei-CQUT/cornell-notebooks/main/images/contents-zh.png) | ![Body](https://raw.githubusercontent.com/aFei-CQUT/cornell-notebooks/main/images/body1-zh.png) |

简单且实用的 Typst 笔记模板

cornell-note是一个专为 Typst 设计的模板,旨在帮助用户记录高效且有组织的笔记。它提供了一个干净且直接的结构,使得记录和整理想法变得更加简单。

## 鸣谢

以下项目为本项目的开发提供了关键的灵感和重要的代码贡献。

https://github.com/gRox167/typst-assignment-template

https://github.com/DVDTSB/dvdtyp

https://github.com/a-kkiri/SimpleNote

https://github.com/spidersouris/touying-unistra-pristine
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// cornell-layouts.typ
// 康纳尔笔记布局

#import "../layouts/cornell-lines.typ": cornell-lines

#let cornell-layouts(body) = {
show: it => {
set page(
paper: "a4",
margin: (left: 1.5cm + 5cm, bottom: 1.5cm + 5.5cm, right: 1.5cm, top: 1.5cm),
background: cornell-lines()
)
it
}
body
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// cornell-lines.typ
// 康奈尔笔记风格的线条

#let cornell-lines() = {
// 左侧垂直线
place(
left,
dx: 6cm,
line(
start: (0pt, 0pt),
end: (0pt, 85%),
stroke: 0.5pt
)
)
// 底部水平线
place(
bottom,
dy:-4.45cm,
line(
start: (0pt, 0pt),
end: (100%, 0pt),
stroke: 0.5pt
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// heading-styles.typ
// 标题样式

#let heading-styles = (
main: (it) => [
#set text(font: ("libertinus serif", "kaiti"))
#if it.numbering != none {
text(rgb("#2196F3"), weight: 500)[#sym.section]
h(0.5em)
text(rgb("#2196F3"))[#counter(heading).display()]
}
#it.body
#v(0.1em)
#if it.level == 1 and it.numbering != none {
counter("chapter").step()
counter(math.equation).update(0)
}
],

level1: (it) => box(width: 100%)[
#set align(left)
#set text(size: 18pt)
#set heading(numbering: "1.1.1.1.")
#it
],

other: (it) => box(width: 100%)[
#set align(left)
#set text(size: 15pt)
#set heading(numbering: "1.1.1.1.")
#it
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// ordinary-layouts.typ
// 普通文档布局

#let ordinary-layouts = (
page-settings: (
paper: "a4",
margin: (left: 1.5cm + 6.5cm, bottom: 1.5cm + 5.5cm, right: 1.5cm, top: 1.5cm),
),

header: context {
set text(font: ("Times New Roman", "kaiti"))
if counter(page).at(here()).first() == 0 { return }

let elems = query(heading.where(level: 1).after(here()))
let before-elems = query(heading.where(level: 1).before(here()))

let chapter-title = ""

if elems != () and elems.first().location().page() == here().page() {
chapter-title = elems.first().body
} else if before-elems != () {
chapter-title = before-elems.last().body
}

if chapter-title == "" { return }

align(center)[#emph(chapter-title)] // 居中显示章节标题

v(-8pt)
align(center)[#line(length: 105%, stroke: (thickness: 1pt, dash: "solid"))]
},

footer: context {
if counter(page).at(here()).first() == 0 { return }
let page-width = 21cm // A4纸宽度
place(
bottom + left,
dx: page-width / 5.5,
dy: -0.25cm,
text(size: 10pt)[#align(center, counter(page).display("1 / 1", both: true))]
)
}
)
189 changes: 189 additions & 0 deletions packages/preview/modern-cornell-notebooks/0.2.0/lib/lib.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
// lib.typ
// 库

// 页面
//
// 页面函数
#import "../pages/cover.typ": cover
#import "../pages/preface.typ": preface-content

// 布局
//
// 布局.变量
#import "../layouts/heading-styles.typ": heading-styles
#import "../layouts/ordinary-layouts.typ": ordinary-layouts
//
// 布局.函数
#import "../layouts/cornell-lines.typ": cornell-lines
#import "../layouts/cornell-layouts.typ": cornell-layouts

// 工具
//
// 工具.变量
#import "../utils/sectionline.typ": sectionline
//
// 工具.函数
#import "../utils/colors.typ": *
#import "../utils/color-box.typ": *
#import "../utils/left-note.typ": left-note
#import "../utils/bottom-note.typ": bottom-note
#import "../utils/bibliography.typ": bibliography-content
//
// 工具.外部库
#import "../utils/codly.typ":*
#import "../utils/codly-languages.typ":*

// cornell-note 模板函数
// 此函数用于创建康奈尔笔记风格的文档
#let cornell-note(
title: "",
author: "",
abstract: "",
createtime: "",
bibliography-style: "ieee",
lang: "zh",
preface: none,
body,
bibliography-file: none,
) = {
set text(lang: lang)
set document(author: author, date: auto, title: title)

// 标题计数器
let chaptercounter = counter("chapter")
set heading(numbering: "1.1.1.1.1.")

// 将页面设置和其他依赖于 context 的操作包装在 context 块中
context {

// 标题样式
show heading: heading-styles.main
show heading.where(level: 1): heading-styles.level1
show heading: heading-styles.other

// 设置目录样式
set outline(fill: repeat[~.], indent: 1em)
show outline: set heading(numbering: none)
show outline: set par(first-line-indent: 0em)
show outline.entry.where(level: 1): it => {
text(font: "libertinus serif", rgb("#2196F3"))[#strong[#it]]
}
show outline.entry: it => {
h(1em)
text(font: "libertinus serif", rgb("#2196F3"))[#it]
}

// 设置首行缩进
set par(first-line-indent: 2em)
let fakepar = context {
let b = par(box())
b
v(-measure(b + b).height)
}
show math.equation.where(block: true): it => it + fakepar // 公式后缩进
show heading: it => it + fakepar // 标题后缩进
show figure: it => it + fakepar // 图表后缩进
show enum.item: it => it + fakepar
show list.item: it => it + fakepar // 列表后缩进

// 调用封面
cover(
title: title,
author: author,
abstract: abstract,
createtime: createtime,
lang: lang
)

// 调用序(如果提供)
if preface != none {
preface-content(content: preface, lang: lang)
}

// 设置表格样式
set table(
fill: (_, row) => {
if row == 0 {
rgb("#2c3338").lighten(10%) // 表头深色背景
} else if calc.odd(row) {
rgb("#ffffff") // 奇数行为白色
} else {
rgb("#000000").lighten(85%) // 偶数行为浅灰色
}
},
stroke: 0.1pt + rgb("#000000"),
)

// 设置表头字体为浅色且加粗
show table.cell.where(y: 0): it => {
set text(fill: white)
strong(it)
}

// 设置引用块样式
set quote(block: true)

// 设置内联代码样式
show raw.where(block: false): it => box(fill: rgb("#d7d7d7"), inset: (x: 2pt), outset: (y: 3pt), radius: 1pt)[#it]

// 设置链接下划线样式
show link: {
underline.with(stroke: rgb("#0074d9"), offset: 2pt)
}

// codly 支持代码显示
show: codly-init //初始化 codly
codly(languages: codly-languages) //设置语言图标

// 设置公式编号样式
set math.equation(
numbering: (..nums) => (
context {
set text(size: 9pt)
numbering("(1.1)", chaptercounter.at(here()).first(), ..nums)
}
),
)

// 设置图表编号样式
set figure(
numbering: (..nums) => (
context {
set text(font: ("Libertinus Serif", "KaiTi"), size: 9pt)
numbering("1.1", chaptercounter.at(here()).first(), ..nums)
}
),
)

// 设置图片表格 caption 字体字号
show figure.caption: set text(font: ("Libertinus Serif", "KaiTi"), size: 9pt)

// 设置正文字体字号
set text(
font: ("Libertinus Serif", "KaiTi"),
)

pagebreak()

counter(page).update(0)

outline()

pagebreak()

// 普通文档页面布局
set page(
..ordinary-layouts.page-settings,
header: ordinary-layouts.header,
footer: ordinary-layouts.footer
)

// 康纳尔笔记页面布局
cornell-layouts(body)
}

// 添加参考文献(如果提供)
if bibliography-file != none {
bibliography-content(bibliography-style, bibliography-file)
}
}
Loading
Loading