@@ -17,310 +17,8 @@ Typst 是可用于出版的可编程标记语言,拥有变量、函数与包
1717- ** 现代编程语言** :Typst 是可用于出版的可编程标记语言,拥有变量、函数、包管理与错误检查等现代编程语言的特性,同时也提供了闭包等特性,便于进行函数式编程。以及包括了 [ 标记模式] 、{脚本模式} 与 $数学模式$ 等多种模式的作用域,并且它们可以不限深度地、交互地嵌套。并且通过 [ 包管理] ( https://typst-doc-cn.github.io/docs/packages/ ) ,你不再需要像 TexLive 一样在本地安装一大堆并不必要的宏包,而是按需自动从云端下载。
1818
1919
20- ## 目前仍存在的 CJK 问题 { #question }
21-
22- 参考 [ Discord] ( https://discord.com/channels/1054443721975922748/1176062736514429008 ) 的记录,可知目前仍存在:
23-
24- - 行内代码或行内数学公式与中文之间的自动空格 [ #2702 ] ( https://github.com/typst/typst/issues/2702 ) [ #2703 ] ( https://github.com/typst/typst/issues/2703 ) 。
25- - 不能简单地实现首段缩进 [ #311 ] ( https://github.com/typst/typst/issues/311 ) 。
26- - 暂时无法忽略 CJK 字符之间的单个换行符自动转换成的空格 [ #792 ] ( https://github.com/typst/typst/issues/792 ) 。
27- - 有时候段落开始的 CJK 标点符号没有被调整 [ #2348 ] ( https://github.com/typst/typst/issues/2348 ) 。
28-
29-
30- ## 常见 Q&A { #question-and-answer }
31-
32- ### 如何进一步进阶?
33-
34- 除了参考,还可以考虑阅读 [ typst-examples-book] ( https://sitandr.github.io/typst-examples-book/book/ ) ,里面包含了一些 Typst 的高级知识、简单示例,以及一些最佳实践。
35-
36- ---
37-
3820** 请阅读 [ 小蓝书] ( https://typst-doc-cn.github.io/tutorial/ ) 和 [ Typst 中文社区导航 FAQ] ( https://typst-doc-cn.github.io/guide/ ) 。**
3921
4022** 请阅读 [ 小蓝书] ( https://typst-doc-cn.github.io/tutorial/ ) 和 [ Typst 中文社区导航 FAQ] ( https://typst-doc-cn.github.io/guide/ ) 。**
4123
4224** 请阅读 [ 小蓝书] ( https://typst-doc-cn.github.io/tutorial/ ) 和 [ Typst 中文社区导航 FAQ] ( https://typst-doc-cn.github.io/guide/ ) 。**
43-
44- ---
45-
46- ### 如何使用 VS Code 进行本地编辑?
47-
48- 1 . 在 [ VS Code] ( https://code.visualstudio.com/ ) 中打开任意工作目录。
49- 2 . 在 VS Code 中安装 [ Tinymist Typst] ( https://marketplace.visualstudio.com/items?itemName=myriad-dreamin.tinymist ) 插件,其提供了语法高亮、错误检查和预览等功能。** 不要安装 Typst LSP 插件,该插件已过时。**
50- - 也推荐下载 [ Typst Companion] ( https://marketplace.visualstudio.com/items?itemName=CalebFiggers.typst-companion ) 插件,其提供了例如 ` Ctrl + B ` 进行加粗等便捷的快捷键。
51- - 你还可以下载我开发的 [ Typst Sync] ( https://marketplace.visualstudio.com/items?itemName=OrangeX4.vscode-typst-sync ) 和 [ Typst Sympy Calculator] ( https://marketplace.visualstudio.com/items?itemName=OrangeX4.vscode-typst-sympy-calculator ) 插件,前者提供了本地包的云同步功能,后者提供了基于 Typst 语法的科学计算器功能。
52- 3 . 新建一个 ` test.typ ` 文件,写入内容 ` = Hello World ` 。
53- 4 . 按下 ` Ctrl + K V ` ,即可同步增量渲染与预览。
54-
55-
56- ### 如何为中英文设置不同的字体?
57-
58- 可以使用 text 里面的 fallback 特性。
59- Typst 中的 font 参数可以接收一个数组,会根据字体里有无当前字符来依次选择字体。
60- 因此我们只需要传入一个英文字体后接中文字体的数组,就可以达到为中英文设置不同的字体的效果。
61-
62- ``` example
63- Hello World 你好世界
64-
65- #[
66- #set text(font: ("IBM Plex Serif", "Noto Sans CJK SC"), lang: "zh", region: "cn")
67-
68- Hello World 你好世界
69- ]
70- ```
71-
72- 如果你还需要对中文字体进行特殊处理,例如只缩小中文字体的大小,可以考虑用正则表达式进行 hack:
73-
74- ``` example
75- #show regex("\p{sc=Hani}+"): set text(size: 0.8em)
76-
77- Hello World 你好世界
78- ```
79-
80-
81- ### 为什么我设置的字体没有生效?
82-
83- 如果中文字体不符合 typst 要求,那么它不会选择你声明的字体,例如字体的变体数量不够,参考更详细的 [ issue] ( https://github.com/typst/typst/issues/725 ) 。
84-
85- 1 . ` typst fonts ` 查看系统字体,确保字体名字没有错误。
86- 2 . ` typst fonts --font-path path/to/your-fonts ` 指定字体目录。
87- 3 . ` typst fonts --variants ` 查看字体变体。
88- 4 . 检查中文字体是否已经完全安装。
89-
90-
91- ### 为什么连续标点会挤压在一起?
92-
93- 如果字体与 ` text(lang: .., region: ..) ` 不匹配,可能会导致连续标点的挤压。例如字体不是中国大陆的,标点压缩会出错;反之亦然。
94-
95-
96- ### 如何添加中文粗体和斜体?
97-
98- 可以使用 [ cuti] ( https://github.com/csimide/cuti ) 包。
99-
100-
101- ### 如何为设置各行段落的缩进?
102-
103- 使用 ` #set par(first-line-indent: 2em) ` :
104-
105- ``` example
106- #set par(first-line-indent: 2em)
107-
108- = 一级标题
109-
110- 豫章故郡,洪都新府。星分翼轸,地接衡庐。襟三江而带五湖,控蛮荆而引瓯越。物华天宝,龙光射牛斗之墟;人杰地灵,徐孺下陈蕃之榻。雄州雾列,俊采星驰。
111-
112- 台隍枕夷夏之交,宾主尽东南之美。都督阎公之雅望,棨戟遥临;宇文新州之懿范,襜帷暂驻。
113-
114- 十旬休假,胜友如云;千里逢迎,高朋满座。腾蛟起凤,孟学士之词宗;紫电青霜,王将军之武库。家君作宰,路出名区;童子何知,躬逢胜饯。
115-
116- == 二级标题
117-
118- 时维九月,序属三秋。潦水尽而寒潭清,烟光凝而暮山紫。俨骖騑于上路,访风景于崇阿。临帝子之长洲,得天人之旧馆。
119-
120- 层峦耸翠,上出重霄;飞阁流丹,下临无地。鹤汀凫渚,穷岛屿之萦回;桂殿兰宫,即冈峦之体势。
121- ```
122-
123- 缺点是标题下的第一行没有缩进。为了解决这个问题,我们有两种办法:
124-
125- ** 第一种办法:手动加入缩进。**
126-
127- ``` example
128- #set par(first-line-indent: 2em)
129-
130- #let indent = h(2em)
131-
132- = 一级标题
133-
134- #indent 豫章故郡,洪都新府。星分翼轸,地接衡庐。襟三江而带五湖,控蛮荆而引瓯越。物华天宝,龙光射牛斗之墟;人杰地灵,徐孺下陈蕃之榻。雄州雾列,俊采星驰。
135-
136- 台隍枕夷夏之交,宾主尽东南之美。都督阎公之雅望,棨戟遥临;宇文新州之懿范,襜帷暂驻。
137-
138- 十旬休假,胜友如云;千里逢迎,高朋满座。腾蛟起凤,孟学士之词宗;紫电青霜,王将军之武库。家君作宰,路出名区;童子何知,躬逢胜饯。
139-
140- == 二级标题
141-
142- #indent 时维九月,序属三秋。潦水尽而寒潭清,烟光凝而暮山紫。俨骖騑于上路,访风景于崇阿。临帝子之长洲,得天人之旧馆。
143-
144- 层峦耸翠,上出重霄;飞阁流丹,下临无地。鹤汀凫渚,穷岛屿之萦回;桂殿兰宫,即冈峦之体势。
145- ```
146-
147- 这样做的优点是可以手动控制缩进,缺点是手动缩进不太方便。
148-
149- ** 第二种办法:使用假段落自动加入缩进。**
150-
151- ``` example
152- #set par(first-line-indent: 2em)
153-
154- #let fakepar = style(styles => {
155- let b = par[#box()]
156- let t = measure(b + b, styles);
157-
158- b
159- v(-t.height)
160- })
161-
162- #show heading: it => {
163- it
164- fakepar
165- }
166-
167- = 一级标题
168-
169- 豫章故郡,洪都新府。星分翼轸,地接衡庐。襟三江而带五湖,控蛮荆而引瓯越。物华天宝,龙光射牛斗之墟;人杰地灵,徐孺下陈蕃之榻。雄州雾列,俊采星驰。
170-
171- 台隍枕夷夏之交,宾主尽东南之美。都督阎公之雅望,棨戟遥临;宇文新州之懿范,襜帷暂驻。
172-
173- 十旬休假,胜友如云;千里逢迎,高朋满座。腾蛟起凤,孟学士之词宗;紫电青霜,王将军之武库。家君作宰,路出名区;童子何知,躬逢胜饯。
174-
175- == 二级标题
176-
177- 时维九月,序属三秋。潦水尽而寒潭清,烟光凝而暮山紫。俨骖騑于上路,访风景于崇阿。临帝子之长洲,得天人之旧馆。
178-
179- 层峦耸翠,上出重霄;飞阁流丹,下临无地。鹤汀凫渚,穷岛屿之萦回;桂殿兰宫,即冈峦之体势。
180- ```
181-
182- PS: 例子来源于 [ Myriad-Dreamin] ( https://github.com/Myriad-Dreamin )
183-
184-
185- ### 如何嵌入 PDF 文件?
186-
187- 你暂时没有办法在 Typst 里嵌入 PDF 文件,但是你可以先使用 [ 在线工具] ( https://cloudconvert.com/pdf-to-svg ) 将 PDF 文件转换为 SVG 文件,然后嵌入 svg 文件。
188-
189-
190- ### 如何根据章节对图表和公式进行编码?
191-
192- 可以使用 [ i-figured] ( https://github.com/RubixDev/typst-i-figured ) 包。
193-
194-
195- ### 如何编写复杂表格或编写简洁的表格?
196-
197- 复杂表格:可以查看 [ Table Guide] ( https://typst.app/docs/guides/table-guide/ ) 。
198-
199- 类 Markdown 表格:可以使用 [ tablem] ( https://github.com/OrangeX4/typst-tablem ) 包。
200-
201- ### 如何更换不同的参考文献格式?
202-
203- Typst (>=0.10.0) 可以使用 csl 文件指定参考文献格式,见 [ ` bibliography ` 的文档] ( https://typst.app/docs/reference/model/bibliography/#parameters-style ) 。
204-
205- Typst 内置了中文常用的 GB/T-7714-2015 格式,其他 GB/T-7714-2015 变体可以查看 [ GB/T 7714—2015 相关的 CSL 样式] ( https://github.com/redleafnew/Chinese-STD-GB-T-7714-related-csl ) 。
206-
207- ### 为什么指定参考文献 csl 后,报错 ` failed to load CSL style ` ?
208-
209- ** 报错1:** `` (duplicate field `layout`) ``
210-
211- Typst 暂不支持 CSL-M 标准,可以注释掉多余的 ` <layout> ` ** 临时** 解决。
212-
213- 在 csl 文件里搜索 ` bibliography ` ,这里通常有多个 ` <layout> ` ,一般建议注释掉 ` <layout locale="en"> ` 这一段 ` <layout> ` 。例子如下
214-
215- ``` xml
216- <bibliography entry-spacing =" 0" et-al-min =" 4" et-al-use-first =" 3" second-field-align =" flush" >
217- <!--
218- <layout locale="en">
219- <text variable="citation-number" prefix="[" suffix="]"/>
220- <text macro="entry-layout"/>
221- </layout>
222- -->
223- <layout >
224- <text variable =" citation-number" prefix =" [" suffix =" ]" />
225- <text macro =" entry-layout" />
226- </layout >
227- </bibliography >
228- ```
229-
230- (示例来自 http://www.zotero.org/styles/china-national-standard-gb-t-7714-2015-numeric ,原作者见此文件,依 CC-BY-SA 3.0 协议使用)
231-
232- 这样修改之后,csl 根据文献语言自动使用“等”或“et al.”的功能会失效,请见下一条 Q&A 的问题1。
233-
234- ** 报错2:** `` (unknown variant `institution`, expected one of `name`, `et-al`, `label`, `substitute`) ``
235-
236- 在 csl 文件里注释掉不支持的部分。
237-
238- ### 为什么参考文献格式与预期不符?
239-
240- ** 问题1:** 希望在中文文献使用 ` 等 ` 、在西文文献使用 ` et al. ` ,但 Typst 均显示为 ` 等 ` (或均显示为 ` et al. ` )。
241-
242- Typst 暂不支持 CSL-M 标准,因此暂时无法通过修改 csl 文件实现中文西文自动使用不同的文字([ typst/typst #2793 ] ( https://github.com/typst/typst/issues/2793 ) , [ typst/citationberg #5 ] ( https://github.com/typst/citationberg/issues/5 ) , [ typst/hayagriva #126 ] ( https://github.com/typst/hayagriva/pull/126 ) )。
243-
244- 如果参考文献均为同一种语言,可以为参考文献部分设定语言,如:
245-
246- ``` example
247- #set text(lang: "zh")
248- 一些内容 @tbs1 。
249-
250- #heading(level: 1, numbering: none)[参考文献]
251- #{
252- set text(lang: "en")
253- bibliography(
254- "many-authors.bib",
255- style: "gb-7714-2015-numeric",
256- title: none
257- )
258- }
259- ```
260-
261- 如果需要实现中文西文自动使用不同的文字,可以使用正则替换魔法,请见 [ nju-lug/modern-nju-thesis #3 ] ( https://github.com/nju-lug/modern-nju-thesis/issues/3 ) 。
262-
263- ** 问题2:** (numeric 格式) 连续引用多条文献时,应当折叠为 ` [1-4] ` ,但是 Typst 折叠为 ` [1,4] ` 。
264-
265- hayagriva 已知 bug [ typst/hayagriva #154 ] ( https://github.com/typst/hayagriva/issues/154 ) 。
266-
267- 可以通过将 csl 文件里的 ` after-collapse-delimiter="," ` 改成 ` after-collapse-delimiter="-" ` 临时解决。请注意,这样做并不符合 CSL 规范,修改后的文件不应当用于 Zotero 等文献管理软件。** 待 hayagriva 修复此 bug 后,需要改回** 。
268-
269- ** 问题3:** 引文条目中 ` . ` 部分丢失。
270-
271- 在 csl 中修改生成引文条目的 ` macro ` ,向缺少 ` . ` 的部分添加 ` <group delimiter=". "> ` 。
272-
273- ** 问题4:** 参考文献不显示 bib 中的 ` note ` 。
274-
275- 目前暂不支持([ typst/hayagriva #91 ] ( https://github.com/typst/hayagriva/issues/91 ) )。
276-
277- ** 问题5:** 学位论文 ` [D] ` 后不显示 ` 地点: 学校名称, 年份. ` 。
278-
279- Typst 暂不支持 ` school ` ` institution ` 作为 ` publisher ` 的别名,亦不支持解析 csl 中的 ` institution ` ([ typst/hayagriva #112 ] ( https://github.com/typst/hayagriva/issues/112 ) )。如需修复,请手动修改 bib 文件内对应条目,在 ` school = {学校名称}, ` 下加一行 ` publisher = {学校名称}, ` ,如:
280-
281- ```
282- @phdthesis{alterego,
283- type = {{超高校级学位论文}},
284- title = {{基于图书室的笔记本电脑的 Alter Ego 系统}},
285- author = {不二咲, 千尋},
286- year = {2010},
287- address = {某地},
288- school = {私立希望ヶ峰学園},
289- publisher = {私立希望ヶ峰学園},
290- }
291- ```
292-
293- ## 一些 Typst 中文资源列表 { #resources }
294-
295- 可以查看 [ Awesome Typst 中文版] ( https://github.com/typst-doc-cn/awesome-typst-cn ) 中文版,以及浏览 [ 第三方包] ( https://typst-doc-cn.github.io/docs/packages/ ) 。
296-
297- ** 中国大学论文** :
298-
299- - [ pkuthss-typst] ( https://github.com/lucifer1004/pkuthss-typst ) : 北京大学学位论文模板
300- - [ BUAA-typst] ( https://github.com/cherichy/BUAA-typst ) : 北京航空航天大学学位论文模板
301- - [ bupt-typst] ( https://github.com/QQKdeGit/bupt-typst ) : 北京邮电大学本科学士学位论文模板
302- - [ HUST-typst-template] ( https://github.com/werifu/HUST-typst-template ) : 用于华科毕业设计(本科)的 typst 模板。
303- - [ SHU-Bachelor-Thesis-Typst] ( https://github.com/shuosc/SHU-Bachelor-Thesis-Typst ) : 上海大学本科毕业论文 typst 模板 (开发ing)
304- - [ sysu-thesis-typst] ( https://github.com/howardlau1999/sysu-thesis-typst ) : 中山大学学位论文 Typst 模板
305- - [ ZJGSU-typst-template] ( https://github.com/jujimeizuo/ZJGSU-typst-template ) : 浙江工商大学毕业设计(本科)的 typst 模板。
306- - [ CQUPTypst] ( https://github.com/jerrita/CQUPTypst ) : 一个 Typest 模板,但是大专
307- - [ zjut-report-typst] ( https://github.com/zjutjh/zjut-report-typst ) : 浙江工业大学一些实验报告的 Typst 模板
308- - [ HIT-Thesis-Typst] ( https://github.com/chosertech/HIT-Thesis-Typst ) : 适用于哈尔滨工业大学学位论文的 Typst 模板
309- - [ nju-thesis-typst] ( https://github.com/nju-lug/nju-thesis-typst ) : 南京大学学位论文 Typst 模板,使用 Typst 包管理、闭包等现代编程语言特性开发,一个更方便编辑和拓展的模板
310- - [ nuist-thesis-typst] ( https://github.com/Dustella/nuist-thesis-typst ) : 南京信息工程大学本科生毕业论文/设计 Typst 模板,分叉自 nju-thesis-typst
311- - [ SEU-Typst-Template] ( https://github.com/csimide/SEU-Typst-Template ) : 东南大学本科毕业设计与学位论文模板
312- - [ HZAU_Typst] ( https://github.com/wagaaa/HZAU_Typst?tab=readme-ov-file ) : 华中农业大学本科生/研究生学位论文模板(非官方)
313- - [ cug-thesis-typst] ( https://github.com/Rsweater/cug-thesis-typst ) :中国地质大学(武汉)学位论文 Typst 模板
314-
315- ** 中文简历** :
316-
317- - [ uniquecv-typst] ( https://github.com/gaoachao/uniquecv-typst ) : 一个使用 Typst 编写的简历模板,基于 uniquecv
318- - [ typst-cv-miku] ( https://github.com/ice-kylin/typst-cv-miku ) : 简历模板,有多种版本,包括中文
319- - [ awesomeCV-Typst] ( https://github.com/mintyfrankie/awesomeCV-Typst ) : 一份参考 ` Awesome-CV ` 的简历模版,支持多语言简历管理
320- - [ Chinese-Resume-in-Typst] ( https://github.com/OrangeX4/Chinese-Resume-in-Typst ) : 使用 Typst 编写的中文简历, 语法简洁, 样式美观, 开箱即用, 可选是否显示照片
321- - [ neet-cv] ( https://github.com/kznr02/neet-cv ) : 作者自用后开源的一份使用 typst 自制的中文简历模板,具有简单的使用方法,其中有部分参考 ` wondercv ` ,开箱即用,简洁美观
322-
323- ** 幻灯片** :
324-
325- - [ touying] ( https://github.com/touying-typ/touying ) - 拥有强大功能和丰富模板的幻灯片包,包括详细的[ 中文文档] ( https://touying-typ.github.io/touying/zh/docs/intro/ )
326- - [ pinit] ( https://github.com/OrangeX4/typst-pinit ) - 并非幻灯片包,而是一个好用的相对定位工具包
0 commit comments