-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
2,960 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 OrangeX4 | ||
|
||
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. |
Large diffs are not rendered by default.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
packages/preview/modern-nju-thesis/0.4.0/assets/vi/nju-emblem-purple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions
29
packages/preview/modern-nju-thesis/0.4.0/assets/vi/nju-emblem.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
packages/preview/modern-nju-thesis/0.4.0/assets/vi/nju-name-purple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
packages/preview/modern-nju-thesis/0.4.0/assets/vi/nju-name.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions
24
packages/preview/modern-nju-thesis/0.4.0/layouts/appendix.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#import "@preview/i-figured:0.2.4" | ||
#import "../utils/custom-numbering.typ": custom-numbering | ||
|
||
// 后记,重置 heading 计数器 | ||
#let appendix( | ||
numbering: custom-numbering.with(first-level: "", depth: 4, "1.1 "), | ||
// figure 计数 | ||
show-figure: i-figured.show-figure.with(numbering: "1.1"), | ||
// equation 计数 | ||
show-equation: i-figured.show-equation.with(numbering: "(1.1)"), | ||
// 重置计数 | ||
reset-counter: false, | ||
it, | ||
) = { | ||
set heading(numbering: numbering) | ||
if reset-counter { | ||
counter(heading).update(0) | ||
} | ||
// 设置 figure 的编号 | ||
show figure: show-figure | ||
// 设置 equation 的编号 | ||
show math.equation.where(block: true): show-equation | ||
it | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 文稿设置,可以进行一些像页面边距这类的全局设置 | ||
#let doc( | ||
// documentclass 传入参数 | ||
info: (:), | ||
// 其他参数 | ||
fallback: false, // 字体缺失时使用 fallback,不显示豆腐块 | ||
lang: "zh", | ||
margin: (x: 89pt), | ||
it, | ||
) = { | ||
// 1. 默认参数 | ||
info = ( | ||
title: ("基于 Typst 的", "南京大学学位论文"), | ||
author: "张三", | ||
) + info | ||
|
||
// 2. 对参数进行处理 | ||
// 2.1 如果是字符串,则使用换行符将标题分隔为列表 | ||
if type(info.title) == str { | ||
info.title = info.title.split("\n") | ||
} | ||
|
||
// 3. 基本的样式设置 | ||
set text(fallback: fallback, lang: lang) | ||
set page(margin: margin) | ||
|
||
// 4. PDF 元信息 | ||
set document( | ||
title: (("",)+ info.title).sum(), | ||
author: info.author, | ||
) | ||
|
||
it | ||
} |
174 changes: 174 additions & 0 deletions
174
packages/preview/modern-nju-thesis/0.4.0/layouts/mainmatter.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
#import "@preview/i-figured:0.2.4" | ||
#import "../utils/style.typ": 字号, 字体 | ||
#import "../utils/custom-numbering.typ": custom-numbering | ||
#import "../utils/custom-heading.typ": heading-display, active-heading, current-heading | ||
#import "../utils/unpairs.typ": unpairs | ||
|
||
#let mainmatter( | ||
// documentclass 传入参数 | ||
twoside: false, | ||
fonts: (:), | ||
// 其他参数 | ||
leading: 1.5 * 15.6pt - 0.7em, | ||
spacing: 1.5 * 15.6pt - 0.7em, | ||
justify: true, | ||
first-line-indent: (amount: 2em, all: true), | ||
numbering: custom-numbering.with(first-level: "第一章 ", depth: 4, "1.1 "), | ||
// 正文字体与字号参数 | ||
text-args: auto, | ||
// 标题字体与字号 | ||
heading-font: auto, | ||
heading-size: (字号.四号,), | ||
heading-weight: ("regular",), | ||
heading-above: (2 * 15.6pt - 0.7em, 2 * 15.6pt - 0.7em), | ||
heading-below: (2 * 15.6pt - 0.7em, 1.5 * 15.6pt - 0.7em), | ||
heading-pagebreak: (true, false), | ||
heading-align: (center, auto), | ||
// 页眉 | ||
header-render: auto, | ||
header-vspace: 0em, | ||
display-header: false, | ||
skip-on-first-level: true, | ||
stroke-width: 0.5pt, | ||
reset-footnote: true, | ||
// caption 的 separator | ||
separator: " ", | ||
// caption 样式 | ||
caption-style: strong, | ||
caption-size: 字号.五号, | ||
// figure 计数 | ||
show-figure: i-figured.show-figure, | ||
// equation 计数 | ||
show-equation: i-figured.show-equation, | ||
..args, | ||
it, | ||
) = { | ||
// 0. 标志前言结束 | ||
set page(numbering: "1") | ||
|
||
// 1. 默认参数 | ||
fonts = 字体 + fonts | ||
if text-args == auto { | ||
text-args = (font: fonts.宋体, size: 字号.小四) | ||
} | ||
// 1.1 字体与字号 | ||
if heading-font == auto { | ||
heading-font = (fonts.黑体,) | ||
} | ||
// 1.2 处理 heading- 开头的其他参数 | ||
let heading-text-args-lists = args.named().pairs() | ||
.filter((pair) => pair.at(0).starts-with("heading-")) | ||
.map((pair) => (pair.at(0).slice("heading-".len()), pair.at(1))) | ||
|
||
// 2. 辅助函数 | ||
let array-at(arr, pos) = { | ||
arr.at(calc.min(pos, arr.len()) - 1) | ||
} | ||
|
||
// 3. 设置基本样式 | ||
// 3.1 文本和段落样式 | ||
set text(..text-args) | ||
set par( | ||
leading: leading, | ||
justify: justify, | ||
first-line-indent: first-line-indent, | ||
spacing: spacing, | ||
) | ||
show raw: set text(font: fonts.等宽) | ||
// 3.2 脚注样式 | ||
show footnote.entry: set text(font: fonts.宋体, size: 字号.五号) | ||
// 3.3 设置 figure 的编号 | ||
show heading: i-figured.reset-counters | ||
show figure: show-figure | ||
// 3.4 设置 equation 的编号和假段落首行缩进 | ||
show math.equation.where(block: true): show-equation | ||
// 3.5 表格表头置顶 + 不用冒号用空格分割 + 样式 | ||
show figure.where( | ||
kind: table | ||
): set figure.caption(position: top) | ||
set figure.caption(separator: separator) | ||
show figure.caption: caption-style | ||
show figure.caption: set text(font: fonts.宋体, size: 字号.五号) | ||
// 3.6 优化列表显示 | ||
// 术语列表 terms 不应该缩进 | ||
show terms: set par(first-line-indent: 0pt) | ||
|
||
// 4. 处理标题 | ||
// 4.1 设置标题的 Numbering | ||
set heading(numbering: numbering) | ||
// 4.2 设置字体字号并加入假段落模拟首行缩进 | ||
show heading: it => { | ||
set text( | ||
font: array-at(heading-font, it.level), | ||
size: array-at(heading-size, it.level), | ||
weight: array-at(heading-weight, it.level), | ||
..unpairs(heading-text-args-lists | ||
.map((pair) => (pair.at(0), array-at(pair.at(1), it.level)))) | ||
) | ||
set block( | ||
above: array-at(heading-above, it.level), | ||
below: array-at(heading-below, it.level), | ||
) | ||
it | ||
} | ||
// 4.3 标题居中与自动换页 | ||
show heading: it => { | ||
if array-at(heading-pagebreak, it.level) { | ||
// 如果打上了 no-auto-pagebreak 标签,则不自动换页 | ||
if "label" not in it.fields() or str(it.label) != "no-auto-pagebreak" { | ||
pagebreak(weak: true) | ||
} | ||
} | ||
if array-at(heading-align, it.level) != auto { | ||
set align(array-at(heading-align, it.level)) | ||
it | ||
} else { | ||
it | ||
} | ||
} | ||
|
||
// 5. 处理页眉 | ||
set page(..(if display-header { | ||
( | ||
header: context { | ||
// 重置 footnote 计数器 | ||
if reset-footnote { | ||
counter(footnote).update(0) | ||
} | ||
let loc = here() | ||
// 5.1 获取当前页面的一级标题 | ||
let cur-heading = current-heading(level: 1) | ||
// 5.2 如果当前页面没有一级标题,则渲染页眉 | ||
if not skip-on-first-level or cur-heading == none { | ||
if header-render == auto { | ||
// 一级标题和二级标题 | ||
let first-level-heading = if not twoside or calc.rem(loc.page(), 2) == 0 { heading-display(active-heading(level: 1, loc)) } else { "" } | ||
let second-level-heading = if not twoside or calc.rem(loc.page(), 2) == 2 { heading-display(active-heading(level: 2, prev: false, loc)) } else { "" } | ||
set text(font: fonts.楷体, size: 字号.五号) | ||
stack( | ||
first-level-heading + h(1fr) + second-level-heading, | ||
v(0.25em), | ||
if first-level-heading != "" or second-level-heading != "" { line(length: 100%, stroke: stroke-width + black) }, | ||
) | ||
} else { | ||
header-render(loc) | ||
} | ||
v(header-vspace) | ||
} | ||
} | ||
) | ||
} else { | ||
( | ||
header: { | ||
// 重置 footnote 计数器 | ||
if reset-footnote { | ||
counter(footnote).update(0) | ||
} | ||
} | ||
) | ||
})) | ||
|
||
counter(page).update(1) | ||
|
||
it | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/preview/modern-nju-thesis/0.4.0/layouts/preface.typ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// 前言,重置页面计数器 | ||
#let preface( | ||
// documentclass 传入的参数 | ||
twoside: false, | ||
..args, | ||
it, | ||
) = { | ||
// 分页 | ||
if twoside { | ||
pagebreak() + " " | ||
} | ||
counter(page).update(0) | ||
set page(numbering: "I") | ||
it | ||
} |
Oops, something went wrong.