Skip to content

Commit 36e9557

Browse files
authored
elegant-paper:0.1.0 (typst#2460)
1 parent 1c48f74 commit 36e9557

20 files changed

+1578
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# GNU LESSER GENERAL PUBLIC LICENSE
2+
3+
Version 3, 29 June 2007
4+
5+
Copyright (C) 2007 Free Software Foundation, Inc.
6+
<https://fsf.org/>
7+
8+
Everyone is permitted to copy and distribute verbatim copies of this
9+
license document, but changing it is not allowed.
10+
11+
This version of the GNU Lesser General Public License incorporates the
12+
terms and conditions of version 3 of the GNU General Public License,
13+
supplemented by the additional permissions listed below.
14+
15+
## 0. Additional Definitions.
16+
17+
As used herein, "this License" refers to version 3 of the GNU Lesser
18+
General Public License, and the "GNU GPL" refers to version 3 of the
19+
GNU General Public License.
20+
21+
"The Library" refers to a covered work governed by this License, other
22+
than an Application or a Combined Work as defined below.
23+
24+
An "Application" is any work that makes use of an interface provided
25+
by the Library, but which is not otherwise based on the Library.
26+
Defining a subclass of a class defined by the Library is deemed a mode
27+
of using an interface provided by the Library.
28+
29+
A "Combined Work" is a work produced by combining or linking an
30+
Application with the Library. The particular version of the Library
31+
with which the Combined Work was made is also called the "Linked
32+
Version".
33+
34+
The "Minimal Corresponding Source" for a Combined Work means the
35+
Corresponding Source for the Combined Work, excluding any source code
36+
for portions of the Combined Work that, considered in isolation, are
37+
based on the Application, and not on the Linked Version.
38+
39+
The "Corresponding Application Code" for a Combined Work means the
40+
object code and/or source code for the Application, including any data
41+
and utility programs needed for reproducing the Combined Work from the
42+
Application, but excluding the System Libraries of the Combined Work.
43+
44+
## 1. Exception to Section 3 of the GNU GPL.
45+
46+
You may convey a covered work under sections 3 and 4 of this License
47+
without being bound by section 3 of the GNU GPL.
48+
49+
## 2. Conveying Modified Versions.
50+
51+
If you modify a copy of the Library, and, in your modifications, a
52+
facility refers to a function or data to be supplied by an Application
53+
that uses the facility (other than as an argument passed when the
54+
facility is invoked), then you may convey a copy of the modified
55+
version:
56+
57+
- a) under this License, provided that you make a good faith effort
58+
to ensure that, in the event an Application does not supply the
59+
function or data, the facility still operates, and performs
60+
whatever part of its purpose remains meaningful, or
61+
- b) under the GNU GPL, with none of the additional permissions of
62+
this License applicable to that copy.
63+
64+
## 3. Object Code Incorporating Material from Library Header Files.
65+
66+
The object code form of an Application may incorporate material from a
67+
header file that is part of the Library. You may convey such object
68+
code under terms of your choice, provided that, if the incorporated
69+
material is not limited to numerical parameters, data structure
70+
layouts and accessors, or small macros, inline functions and templates
71+
(ten or fewer lines in length), you do both of the following:
72+
73+
- a) Give prominent notice with each copy of the object code that
74+
the Library is used in it and that the Library and its use are
75+
covered by this License.
76+
- b) Accompany the object code with a copy of the GNU GPL and this
77+
license document.
78+
79+
## 4. Combined Works.
80+
81+
You may convey a Combined Work under terms of your choice that, taken
82+
together, effectively do not restrict modification of the portions of
83+
the Library contained in the Combined Work and reverse engineering for
84+
debugging such modifications, if you also do each of the following:
85+
86+
- a) Give prominent notice with each copy of the Combined Work that
87+
the Library is used in it and that the Library and its use are
88+
covered by this License.
89+
- b) Accompany the Combined Work with a copy of the GNU GPL and this
90+
license document.
91+
- c) For a Combined Work that displays copyright notices during
92+
execution, include the copyright notice for the Library among
93+
these notices, as well as a reference directing the user to the
94+
copies of the GNU GPL and this license document.
95+
- d) Do one of the following:
96+
- 0) Convey the Minimal Corresponding Source under the terms of
97+
this License, and the Corresponding Application Code in a form
98+
suitable for, and under terms that permit, the user to
99+
recombine or relink the Application with a modified version of
100+
the Linked Version to produce a modified Combined Work, in the
101+
manner specified by section 6 of the GNU GPL for conveying
102+
Corresponding Source.
103+
- 1) Use a suitable shared library mechanism for linking with
104+
the Library. A suitable mechanism is one that (a) uses at run
105+
time a copy of the Library already present on the user's
106+
computer system, and (b) will operate properly with a modified
107+
version of the Library that is interface-compatible with the
108+
Linked Version.
109+
- e) Provide Installation Information, but only if you would
110+
otherwise be required to provide such information under section 6
111+
of the GNU GPL, and only to the extent that such information is
112+
necessary to install and execute a modified version of the
113+
Combined Work produced by recombining or relinking the Application
114+
with a modified version of the Linked Version. (If you use option
115+
4d0, the Installation Information must accompany the Minimal
116+
Corresponding Source and Corresponding Application Code. If you
117+
use option 4d1, you must provide the Installation Information in
118+
the manner specified by section 6 of the GNU GPL for conveying
119+
Corresponding Source.)
120+
121+
## 5. Combined Libraries.
122+
123+
You may place library facilities that are a work based on the Library
124+
side by side in a single library together with other library
125+
facilities that are not Applications and are not covered by this
126+
License, and convey such a combined library under terms of your
127+
choice, if you do both of the following:
128+
129+
- a) Accompany the combined library with a copy of the same work
130+
based on the Library, uncombined with any other library
131+
facilities, conveyed under the terms of this License.
132+
- b) Give prominent notice with the combined library that part of it
133+
is a work based on the Library, and explaining where to find the
134+
accompanying uncombined form of the same work.
135+
136+
## 6. Revised Versions of the GNU Lesser General Public License.
137+
138+
The Free Software Foundation may publish revised and/or new versions
139+
of the GNU Lesser General Public License from time to time. Such new
140+
versions will be similar in spirit to the present version, but may
141+
differ in detail to address new problems or concerns.
142+
143+
Each version is given a distinguishing version number. If the Library
144+
as you received it specifies that a certain numbered version of the
145+
GNU Lesser General Public License "or any later version" applies to
146+
it, you have the option of following the terms and conditions either
147+
of that published version or of any later version published by the
148+
Free Software Foundation. If the Library as you received it does not
149+
specify a version number of the GNU Lesser General Public License, you
150+
may choose any version of the GNU Lesser General Public License ever
151+
published by the Free Software Foundation.
152+
153+
If the Library as you received it specifies that a proxy can decide
154+
whether future versions of the GNU Lesser General Public License shall
155+
apply, that proxy's public statement of acceptance of any version is
156+
permanent authorization for you to choose that version for the
157+
Library.
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Elegant Paper Typst Template
2+
3+
一个用于创建优雅学术论文风格文档的 Typst 模板。
4+
5+
灵感来源于一个充满想象力的示例项目:[The Mahiro Papers](https://github.com/xyber-nova/the-mahiro-papers)
6+
7+
## ✨ 特性
8+
9+
* **自动化标题页**: 自动生成包含标题、多作者(含机构、备注、邮箱)、摘要和关键词的专业标题页。
10+
* **可定制目录**: 支持一键生成文档目录 (`enable-outline: true`)。
11+
* **优雅的预设样式**: 预设了适合学术论文的字体大小、段落间距、标题编号和样式。
12+
* **引用与参考文献**: 完美支持 Typst 的引用 (`@label`) 和参考文献 (`#bibliography`) 功能。
13+
* **图表与表格**: 轻松插入和格式化图表 (`#figure`, `#image`) 与表格 (`#table`)。
14+
* **配置灵活**: 可自定义纸张大小 (`paper`) 和基础字体大小 (`font-size`)。
15+
* **中文优化**: 集成了 `zh-kit`,对中文排版提供良好支持。
16+
17+
## 🚀 使用方法
18+
19+
### 1. 导入模板
20+
21+
你可以通过以下两种方式导入此模板:
22+
23+
**方式一:使用 Typst 包管理器 (推荐)**
24+
25+
如果你的项目使用 Typst CLI,可以直接通过包管理器导入 `@preview/elegant-paper`
26+
27+
```typst
28+
// main.typ
29+
#import "@preview/elegant-paper:0.1.0": elegant-paper
30+
// 请将 0.1.0 替换为最新的版本号
31+
```
32+
33+
**方式二:本地导入**
34+
35+
[`lib.typ`](lib.typ:1) 文件复制到你的项目目录下,然后在你的 Typst 文件顶部导入 `elegant-paper` 函数:
36+
37+
```typst
38+
// main.typ
39+
#import "lib.typ": elegant-paper
40+
```
41+
42+
*(请确保路径正确)*
43+
44+
### 2. 调用 `elegant-paper` 函数
45+
46+
使用 `#show` 规则将 `elegant-paper` 函数应用于你的文档,并通过 `.with()` 方法配置参数:
47+
48+
```typst
49+
// main.typ
50+
#import "lib.typ": elegant-paper
51+
52+
#show: elegant-paper.with(
53+
// --- 基础配置 ---
54+
paper: "a4", // 纸张大小 (默认 "a4")
55+
enable-outline: true, // 是否生成目录 (默认 false)
56+
57+
// --- 字体配置 ---
58+
font: (
59+
font-size: 10pt // 基础字体大小 (默认 10pt)
60+
),
61+
62+
// --- 标题页信息 ---
63+
title: (
64+
title: "你的论文标题",
65+
authors: (
66+
(
67+
name: "作者一 (名字)",
68+
institution: "作者一的机构",
69+
email: "[email protected]" // 邮箱可选
70+
),
71+
(
72+
name: "作者二 (名字)",
73+
institution: "作者二的机构",
74+
note: "通讯作者" // 备注可选 (如通讯作者)
75+
),
76+
// 可以添加更多作者...
77+
),
78+
date: "2024年5月28日", // 日期可选 (示例模板中有)
79+
abstract: """
80+
这里是你的论文摘要。它可以是较长的文本块。
81+
摘要内容会自动处理缩进和排版。
82+
""",
83+
keywords: ("关键词一", "关键词二", "Typst模板") // 关键词元组
84+
),
85+
86+
// --- 参考文献 ---
87+
// 注意:参考文献需要在文档末尾显式调用 bibliography 函数
88+
// bibliography-path: "references.bib" // 这是一个示例,实际在下方调用
89+
)
90+
91+
// --- 正文内容 ---
92+
93+
= 引言 <sec:intro>
94+
95+
欢迎使用 Elegant Paper Typst 模板!这里是你的论文正文内容。
96+
97+
你可以使用标准的 Typst 语法编写,例如:
98+
99+
== 研究背景
100+
101+
这里是研究背景部分。你可以添加引用 @example_ref。
102+
103+
* 这是一个列表项。
104+
* 这是另一个列表项。
105+
106+
=== 更深层次的小节
107+
108+
支持多级标题。
109+
110+
#figure(
111+
rect(width: 60%, height: 2cm, fill: blue.lighten(80%)), // 用矩形代替图片
112+
caption: [这是一个图表示例。]
113+
) <fig:example>
114+
115+
如图 @fig:example 所示...
116+
117+
#figure(
118+
table(
119+
columns: (auto, 1fr, 1fr),
120+
align: center,
121+
table.header([ID], [名称], [值]),
122+
[1], [项目A], [100],
123+
[2], [项目B], [200],
124+
),
125+
caption: [这是一个表示例。]
126+
) <tbl:example>
127+
128+
如表 @tbl:example 所示...
129+
130+
= 结论 <sec:conclusion>
131+
132+
这里是结论部分。
133+
134+
// --- 参考文献 ---
135+
// 在文档末尾调用 bibliography 函数
136+
#bibliography("references.bib", title: "参考文献", style: "gb-7714-2015-author-date")
137+
138+
```
139+
140+
### 3. 编写正文
141+
142+
`#show` 规则之后,使用标准的 Typst 标记语言编写你的论文内容,包括各级标题 (`=`, `==`, `===`)、段落、列表、图表、表格和引用等。
143+
144+
### 4. 处理参考文献
145+
146+
1. 创建一个 BibTeX 文件(例如 `references.bib`)。
147+
2. 在你的 Typst 文档中需要引用的地方使用 `@key` 语法,其中 `key` 是 BibTeX 文件中对应的条目键名。
148+
3. 在文档的末尾(通常是正文之后)使用 `#bibliography` 函数来生成参考文献列表,指定 `.bib` 文件的路径和可选的标题及样式。
149+
150+
```typst
151+
// references.bib (示例)
152+
@article{example_ref,
153+
author = {作者姓, 作者名},
154+
title = {示例文献标题},
155+
journal = {虚拟期刊},
156+
year = {2024},
157+
volume = {1},
158+
number = {1},
159+
pages = {1-10}
160+
}
161+
162+
// main.typ (末尾)
163+
#bibliography("references.bib", title: "参考文献", style: "ieee") // 可选不同样式
164+
```
165+
166+
## 📜 许可证
167+
168+
本项目采用 [GNU Lesser General Public License v3.0 (LGPL-3.0)](https://www.gnu.org/licenses/lgpl-3.0.html) 许可证。这意味着:
169+
170+
* **您可以自由地:**
171+
* **使用 (Use):** 在您的任何 Typst 项目(无论是开源还是闭源)中使用本模板。
172+
* **分发 (Distribute):** 分发本模板的原始版本或您修改后的版本。
173+
* **修改 (Modify):** 修改本模板的源代码。
174+
* **在以下条件下:**
175+
* **共享修改 (Share Alike for Modifications to the Library):** 如果您修改了本模板的源代码 (`lib.typ` 或其他核心文件),并且您选择分发这个修改后的版本,那么这个修改后的版本也必须在 LGPL-3.0 或 GPL-3.0 许可下提供。
176+
* **声明和版权 (Notice and Copyright):** 您必须保留原始的版权声明和许可证文本。
177+
* **提供源码 (Source Code Provision):** 如果您分发包含本模板(或其修改版)的二进制或编译形式(例如,作为一个更大的应用程序的一部分),您需要提供一种方式让接收者能够获取模板的源代码。对于 Typst 模板,这通常意味着分发 `.typ` 文件本身即可满足要求。
178+
* **请注意:**
179+
* **链接不“传染” (No "Viral" Effect on Your Project):** 仅仅在您的 Typst 文档或项目中通过 `#import` 使用本模板,并**不会**强制要求您的整个文档或项目也必须采用 LGPL-3.0 许可证。您可以为您的最终文档(例如生成的 PDF)或包含您文档的项目选择任何您希望的许可证。
180+
181+
原始示例 [`template/main.typ`](template/main.typ:1) 及其相关资源可能遵循其原始仓库 [The Mahiro Papers](https://github.com/xyber-nova/the-mahiro-papers) 的许可(CC BY-NC-SA 4.0)。

0 commit comments

Comments
 (0)