文档:KScript.Document
简介
KScript.Document 用于编写科学和专业文档:论文、报告、信函和发票。一个脚本可以将同一份文档保存为 PDF、Word(.docx)、LaTeX(.tex)、Markdown 和 HTML。它支持 LaTeX 数学公式、编号章节、表格和图表、来自 BibTeX 的引用、脚注以及交叉引用。PDF 由 KScript 自身生成,因此无需安装 TeX、Word 或其他任何软件。
<KScript.Document template="paper" title="How Gliders Move" author="Ada Lovelace" to="'gliders.pdf'">
<Abstract>A glider returns to its own shape every \( p = 4 \) generations, one cell further on.</Abstract>
<Section title="Introduction">
<Paragraph>The Game of Life [@gardner1970] is played on a square grid. Each cell has **eight neighbours**.</Paragraph>
<Math id="eq-speed">v = \frac{\max(|\Delta x|, |\Delta y|)}{p} \, c</Math>
<Paragraph>Equation [#eq-speed] gives a pattern's speed.</Paragraph>
</Section>
<Bibliography>
<Source id="gardner1970" type="article" author="Martin Gardner" title="Mathematical Games" journal="Scientific American" year="1970" />
</Bibliography>
</KScript.Document>import KScript.Document
Document(template: paper, title: 'How Gliders Move', author: 'Ada Lovelace', to: 'gliders.pdf') {
Abstract "A glider returns to its own shape every \( p = 4 \) generations, one cell further on."
Section(title: 'Introduction') {
Paragraph "The Game of Life [@gardner1970] is played on a square grid. Each cell has **eight neighbours**."
Math(id: 'eq-speed') "v = \frac{\max(|\Delta x|, |\Delta y|)}{p} \, c"
Paragraph "Equation [#eq-speed] gives a pattern's speed."
}
Bibliography {
Source(id: 'gardner1970', type: 'article', author: 'Martin Gardner', title: 'Mathematical Games', journal: "Scientific American", year: 1970)
}
}要开始使用,请import KScript.Document,它会引入Document以及放在其中的元素。Document块中的所有内容都是普通的 KScript,因此for、if、变量和函数可以在这些元素之间使用:表格可以由数据生成,区块也可以针对列表中的每一项重复出现。
samples/documents 文件夹中包含一篇完整的论文、一份报告、一封信函和一张发票。kscript make document 用于新建一个文档。
保存文档
to: 会在代码块结束时保存文档。扩展会自动选择格式,传入路径列表则可同时保存多种格式:
<KScript.Document title="Notes" to="notes.pdf, notes.docx, notes.tex">
<Paragraph>Saved three ways.</Paragraph>
</KScript.Document>import KScript.Document
Document(title: 'Notes', to: ['notes.pdf', 'notes.docx', 'notes.tex']) {
Paragraph "Saved three ways."
}| 扩展名 | 产物 |
|---|---|
.pdf |
由 KScript 排版生成的 PDF:包含页码、可点击的目录和书签、链接以及图片。 |
.docx |
一个 Word 文档,包含真正的标题、编号列表、脚注、可在 Word 中编辑的公式,以及 Word 可自动生成的目录。 |
.tex |
用于 pdflatex 的 LaTeX 文件,包含 \section、\label/\ref、amsmath、booktabs 和 \bibitem。图像通过路径引用。 |
.md |
支持 $...$ 数学公式、GitHub 表格和脚注的 Markdown。 |
.html |
这是一个 HTML 页面:样式、MathML 数学公式和图片都包含在其中。 |
into: 会将文档保存在一个变量中(或同时保存),以便你稍后保存它或将其转换为文本:
<import package="KScript.Document" />
<Document title="Report" into="doc">
<Paragraph>Hello.</Paragraph>
</Document>
<do>$doc->save('report.pdf')</do>
<echo>{ $doc->pages() } pages, { $doc->words() } words</echo>import KScript.Document
Document(title: 'Report', into: doc) {
Paragraph "Hello."
}
$doc->save('report.pdf')
echo "{ $doc->pages() } pages, { $doc->words() } words"| 方法 | 作用 |
|---|---|
->save(path, as?) |
以文件扩展名或 as: 所选的格式保存。 |
->pages() |
PDF 文件的页数。 |
->words() |
文本的字数(不计数学公式和代码)。 |
->convert(to: markdown)、->convert(to: latex)和->convert(to: html) |
文档的文本形式,用于打印、发送或自行保存。 |
->bytes(as: pdf|docx|html) |
渲染后的文件,以 base64 值的形式返回,不写入文件。 |
$doc.title 是标题。
路由无需先保存即可发送文档。->bytes(as: pdf) 在内存中渲染文档,@response() 发送字节流:
<import package="KScript.Http" />
<import package="KScript.Document" />
<fn name="invoice" params="id: int">
<Document title="Invoice { $id }" into="doc">
<Paragraph>Thank you for your order.</Paragraph>
</Document>
<return value="@response($doc->bytes(as: pdf), type: 'application/pdf', headers: { 'Content-Disposition': "inline; filename=invoice-{ $id }.pdf" })" />
</fn>import KScript.Http
import KScript.Document
fn invoice(id: int) {
Document(title: "Invoice { $id }", into: doc) {
Paragraph "Thank you for your order."
}
return @response($doc->bytes(as: pdf), type: 'application/pdf', headers: { 'Content-Disposition': "inline; filename=invoice-{ $id }.pdf" })
}从源文件生成文档
无需导入即可使用 Markdown 或 LaTeX 代码块,它们会生成 markdown 或 latex 值:.text 是其源代码,.extension 是其文件扩展名。使用下述方法前请导入 KScript.Document。@document(source) 可将代码块转换为文档;若需 LaTeX 源代码,则使用 as: latex 生成字符串。普通字符串默认为 Markdown。
<import package="KScript.Document" />
<fn name="notes" value="```md
# Notes
Ship *soon*.
```" />
<fn name="paper" value="```latex
\section{Draft}
```" />
<echo value="@notes()->convert(to: html)" />
<do>@notes()->save('notes.pdf')</do>
<do>@paper()->replace('Draft', 'Final')->save('paper')</do>import KScript.Document
fn notes() => ```md
# Notes
Ship *soon*.
```
fn paper() => ```latex
\section{Draft}
```
echo @notes()->convert(to: html)
@notes()->save('notes.pdf')
@paper()->replace('Draft', 'Final')->save('paper')两种围栏都以 ->find(text) 作为第一个源偏移量,以 ->replace(search, replacement) 处理每一个字面匹配项,并以 ->insert(content, at?) 插入文本或同格式围栏。偏移量从零开始计数,省略偏移量则追加到末尾。这些方法在每次编辑后都会返回一个新值。当路径以 .md 或 .tex 结尾,或没有扩展名时,->save(path, as?) 会写入源代码。
一个 Markdown 围栏本身就是一份文档。它具有文档的 ->convert(to: html)、->convert(to: latex)、->words() 和 ->pages(),->save() 会根据路径的扩展名或 as: 将其渲染为 PDF、Word、LaTeX 或 HTML。
LaTeX 围栏块也是一种文档。它包含 ->convert(to: html)、->convert(to: markdown)、->words() 和 ->pages(),由 ->save('paper.pdf') 或 ->save('paper.docx') 进行渲染。KScript 读取 文档部件所能读取的 LaTeX:章节、段落、列表、数学公式、引文、图表以及常用的文本命令。若遇到无法识别的命令,渲染该围栏块时会报错并指出该命令;->save('paper.tex') 则会将 LaTeX 原样保留,供 pdflatex 等 LaTeX 引擎处理。
模板
模板决定文档的整体外观。template: 用于选择整体外观。随后,页面与样式下的每项设置都可以对其进行调整。
| 模板 | 它是什么 |
|---|---|
plain |
默认:衬线字体正文、编号章节、标题位于顶部。 |
paper |
科学论文:居中标题、带单位的作者信息、摘要、首行缩进的段落、编号的公式和参考文献。 |
report |
标题页、目录、彩色无衬线标题、每个顶级章节另起一页,以及包含标题和页码的页脚。 |
letter |
与 Letter 元素配合使用:地址、日期、主题、称呼和落款。 |
invoice |
与 Invoice 元素配合使用:地址、发票信息、包含税费和合计的项目表格。 |
@document_templates() 列出了这些模板。
编写文本
Paragraph、Item、标题和题注中的文本可以使用:
| 写法 | 适用对象 |
|---|---|
**bold**, *italic* |
粗体和斜体(__bold__ 和 _italic_ 同样可用)。 |
`code` |
代码。 |
[text](https://...) |
链接:网址、mailto:,或不带协议的文件或 #place。其他内容(例如 javascript:)保持为普通文本。 |
\( x^2 \) |
行内数学公式。\[ ... \] 同样有效。 |
[@key], [@a; @b] |
在参考文献中引用某一来源。 |
[#id] |
交叉引用:带有该 id 的章节、表格、图形或公式的编号。 |
^[text] |
脚注。 |
--, --- |
短破折号和长破折号。 |
文本中的空行会开始一个新段落。{ } 可像在 KScript 其他地方一样插入一个值,$name 插入变量,因此数学公式使用 \( \) 而非 $。在 \( \) 内,花括号会保留给 LaTeX 使用:\( \frac{1}{2} \) 是分数,而非 KScript 语法。
Paragraph(lines: true) 会保留换行,例如地址或诗歌中的换行。align:(left、center、right、justify)可覆盖文档的对齐方式。
结构
<KScript.Document template="report" title="Annual Report" author="The team" to="'report.pdf'">
<Contents />
<Section title="Summary" id="summary">
<Paragraph>Visits rose every quarter.</Paragraph>
<Section title="Details">
<List style="number">
<Item>First point.</Item>
<Item>Second point.</Item>
<List>
<Item>A point under the second.</Item>
</List>
</List>
</Section>
</Section>
<Section title="Appendix" numbered="false" new_page="true">
<Quote by="John Conway">I'm not a mathematician who's interested in applications.</Quote>
<Code language="python">print('hello')</Code>
</Section>
</KScript.Document>import KScript.Document
Document(template: report, title: 'Annual Report', author: 'The team', to: 'report.pdf') {
Contents
Section(title: 'Summary', id: 'summary') {
Paragraph "Visits rose every quarter."
Section(title: 'Details') {
List(style: number) {
Item "First point."
Item "Second point."
List {
Item "A point under the second."
}
}
}
}
Section(title: 'Appendix', numbered: false, new_page: true) {
Quote(by: 'John Conway') "I'm not a mathematician who's interested in applications."
Code(language: 'python') "print('hello')"
}
}| 元素 | 它是什么 |
|---|---|
Author(affiliation, email) |
作者。其文本即为姓名。也可以在文档上设置 author: "Ada Lovelace; Alan Turing"。 |
Abstract |
标题下方的摘要。 |
Section(title, id, numbered, new_page) |
章节。章节内的章节即为子章节,最多六级;第七级会报错。 |
Paragraph(id, align, lines) |
段落。 |
List(style, start) 和 Item |
列表:bullet、number、letter 或 roman。紧跟在 Item 之后的 List 会嵌套在该项中。 |
Quote(by) |
块引用。 |
Code(language) |
代码,使用等宽字体,保持原样。 |
Contents(title, depth) |
目录;在 PDF 中包含页码。 |
Markdown(path) |
从其文本或文件生成 Markdown:见下文。 |
Latex(path, value) |
从其文本、latex 值或 .tex 文件生成 LaTeX:见下文。 |
PageBreak, VSpace(height), Rule |
分页、VSpace(height: '1cm') 之类的间距,以及跨页的横线。 |
数学
Math 用于单独成行的公式。其文本为 LaTeX,按原样保留,因此花括号和反斜杠无需转义。较长的公式可放入 ```latex 块中分多行书写;较长的 Paragraph 可在行末使用 \(参见长字符串与文本块)。公式会自动编号,id: 可让文本通过 [#id] 引用该编号:
<KScript.Document title="Maths" to="'maths.pdf'">
<Math id="eq-gauss">\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}</Math>
<Math numbered="false">\sum_{k=1}^{n} k = \frac{n(n+1)}{2}</Math>
<Math>A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}, \quad \det A = ad - bc</Math>
</KScript.Document>import KScript.Document
Document(title: 'Maths', to: 'maths.pdf') {
Math(id: 'eq-gauss') "\int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}"
Math(numbered: false) "\sum_{k=1}^{n} k = \frac{n(n+1)}{2}"
Math "A = \begin{pmatrix} a & b \\\\ c & d \end{pmatrix}, \quad \det A = ad - bc"
}在 "..." 字符串中,\\ 用来表示一个反斜杠,因此 LaTeX 的换行符 \\ 需要写成 \\\\。环境中的换行也会结束一行:
<KScript.Document title="Cases" to="'cases.pdf'">
<Math>|x| = \begin{cases}
x & \text{if } x \ge 0
-x & \text{otherwise}
\end{cases}</Math>
</KScript.Document>import KScript.Document
Document(title: 'Cases', to: 'cases.pdf') {
Math "|x| = \begin{cases}
x & \text{if } x \ge 0
-x & \text{otherwise}
\end{cases}"
}数学理解的内容:
- 使用 TeX 间距的字母、数字和运算符;
^和_用于上标和下标;'用于撇号(素数)。 \frac,\dfrac,\tfrac,\binom,\sqrt,\sqrt[n].- 希腊字母(
\alpha到\Omega)、关系符号(\le、\approx、\in、\subseteq、\to……)、运算符(\pm、\times、\cdot、\cup……)、箭头,以及\infty、\partial、\nabla、\forall、\exists等符号。 - 带上下限的大型运算符:
\sum、\prod、\int、\iint、\oint、\bigcup……;以及函数,如\sin、\log、\lim、\max和\operatorname{name}。 \left( ... \right)以及其他会随内容自动伸缩的定界符。matrix、pmatrix、bmatrix、vmatrix、cases、aligned和array环境。\text{...},\mathbf,\mathit,\mathrm,\mathbb,\mathcal,\mathsf,\mathtt;重音符号如\hat、\bar、\vec、\dot、\tilde、\overline、\underline;以及空格\,、\;、\quad、\qquad。
未知命令会报错,并指出是哪个命令,因此拼写错误会在脚本运行时被发现,而不是等到生成 PDF 之后。每种格式都以自己的形式呈现数学公式:PDF 中为绘制图形,LaTeX 中为 amsmath,.docx 中为 Word 公式,HTML 中为 MathML。
表格
表格可以由数据生成,数据通常是一个映射列表:
<let name="people" value="[{ name: 'Ada', born: 1815 }, { name: 'Alan', born: 1912 }]" />
<import package="KScript.Document" />
<Document title="People" to="'people.pdf'">
<Table caption="Two mathematicians." id="tab-people" rows="$people" columns="{ Name: 'name', Born: 'born' }" align="['left', 'right']" />
</Document>$people = [{ name: 'Ada', born: 1815 }, { name: 'Alan', born: 1912 }]
import KScript.Document
Document(title: 'People', to: 'people.pdf') {
Table(caption: 'Two mathematicians.', id: 'tab-people', rows: $people, columns: { Name: 'name', Born: 'born' }, align: ['left', 'right'])
}columns: 是从表头到键的映射(或键的列表,同时也作为表头)。若未提供,则以第一个映射的键作为列。当行的字段已知时(例如脚本中写入的映射列表或模型记录),编辑器会补全键,kscript check 会报告某行缺少的键。除非 align: 另有指定,数字默认右对齐。
或者用 Tr 写入行,单元格之间用 | 分隔:
<KScript.Document title="Scores" to="'scores.pdf'">
<Table caption="Scores." align="['left', 'right', 'right']" widths="[3, 1, 1]" rules="grid">
<Tr header="true">Team | Played | Points</Tr>
<Tr>Red | 3 | 7</Tr>
<Tr>Blue | 3 | **9**</Tr>
</Table>
</KScript.Document>import KScript.Document
Document(title: 'Scores', to: 'scores.pdf') {
Table(caption: 'Scores.', align: ['left', 'right', 'right'], widths: [3, 1, 1], rules: grid) {
Tr(header: true) "Team | Played | Points"
Tr "Red | 3 | 7"
Tr "Blue | 3 | **9**"
}
}widths: 会使表格宽度与文本宽度一致,并按这些比例分配宽度。未提供时,各列宽度与其文本宽度相同。rules: 可取 booktabs(上方、下方及表头下方有线,默认)、grid 或 none;size: 0.9 会使文字变小。标题会为表格编号;当表格跨页时,表头行会重复出现(在 LaTeX 中,超过 30 行的表格会因同样原因成为 longtable)。没有任何行的表格会从 LaTeX 和 Markdown 文件中省略。
数据
<KScript.Document title="Gliders" to="'gliders.pdf'">
<Figure path="glider.png" caption="A glider over four generations." id="fig-glider" width="0.8" />
</KScript.Document>import KScript.Document
Document(title: 'Gliders', to: 'gliders.pdf') {
Figure(path: 'glider.png', caption: 'A glider over four generations.', id: 'fig-glider', width: 0.8)
}path: 是相对于脚本的 PNG 或 JPEG 文件。width: 为占文本宽度的比例(0.5 或 '50%')。带标题的图表按 [#id] 编号。
引用与参考文献
使用 [@key] 进行引用。引用来源可以来自 BibTeX 文件、Source 元素,或两者兼用:
<KScript.Document template="paper" title="Cited" to="'cited.pdf'">
<Paragraph>Life is universal [@berlekamp1982; @rendell2002].</Paragraph>
<Bibliography path="refs.bib">
<Source id="rendell2002" type="inproceedings" author="Paul Rendell" title="Turing Universality of the Game of Life" booktitle="Collision-Based Computing" year="2002" />
</Bibliography>
</KScript.Document>import KScript.Document
Document(template: paper, title: 'Cited', to: 'cited.pdf') {
Paragraph "Life is universal [@berlekamp1982; @rendell2002]."
Bibliography(path: 'refs.bib') {
Source(id: 'rendell2002', type: 'inproceedings', author: 'Paul Rendell', title: 'Turing Universality of the Game of Life', booktitle: "Collision-Based Computing", year: 2002)
}
}仅列出已被引用的来源。使用 citations: numeric(默认)时,按首次被引用的顺序编号,显示为 [1]。使用 citations: author-year 时,显示为 (Berlekamp et al., 1982),列表按作者排序。Source 接受任何 BibTeX 字段作为属性;author 用于分隔多个人名,使用 and。如果你引用了来源但未写 Bibliography,参考文献将放在文末。
引用或交叉引用指向不存在的 id 是错误,同一个 id 被使用两次也是错误。id: 与其他文本一样,因此循环可以为每个条目生成一个:Section(title: $chapter.title, id: "ch-{ $chapter.number }")。
脚注与交叉引用
^[text] 在页面底部放置一个带编号的脚注(在 Word 中是真正的脚注;在 HTML 和 Markdown 中,注释放在末尾)。[#id] 会被替换为具有该 id 的章节、表格、图或公式的编号,因此词语需要由你自己写:Section [#methods] 显示为“Section 2”,Equation [#eq-speed] 显示为“Equation (3)”。在 PDF 和 Word 中,编号是一个链接。
Markdown
Markdown 将 Markdown 添加为文档内容:# 标题会成为章节(按层级嵌套),并包含段落、列表、表格、代码块、引用、--- 分隔线和 {#id} 图片。标题和数学公式可以带有 id:## Results {#results}、\[ E = mc^2 \] {#eq-energy}。
<KScript.Document title="From Markdown" to="'notes.pdf'">
<Markdown path="chapters/introduction.md" />
<Markdown>
## Summary
- Every chapter is a Markdown file.
- The script puts them together.
</Markdown>
</KScript.Document>import KScript.Document
Document(title: 'From Markdown', to: 'notes.pdf') {
Markdown(path: 'chapters/introduction.md')
Markdown "
## Summary
- Every chapter is a Markdown file.
- The script puts them together.
"
}在 Markdown 文件中,$x$ 和 $$ ... $$ 同样是数学表达式。在脚本内的文本中,请使用 \( \) 和 \[ \],因为那里 $ 是变量。
LaTeX
Latex 将 LaTeX 作为文档内容添加,读取方式与文档部件相同。其文本按原样使用,花括号和反斜杠由 LaTeX 解释。它也可接受 latex 值(配合 value:),或 .tex 文件(配合 path:)。
<import package="KScript.Document" />
<fn name="method" value="```latex
\subsection{Method}
We counted \textbf{gliders} by hand.
```" />
<Document title="From LaTeX" to="paper.pdf">
<Latex>\section{Results}
Gliders travel \emph{diagonally}, and $N(t) = N_0 e^{rt}$.</Latex>
<Latex value="@method()" />
<Latex path="chapters/discussion.tex" />
</Document>import KScript.Document
fn method() => ```latex
\subsection{Method}
We counted \textbf{gliders} by hand.
```
Document(title: "From LaTeX", to: "paper.pdf") {
Latex ```latex
\section{Results}
Gliders travel \emph{diagonally}, and $N(t) = N_0 e^{rt}$.
```
Latex(value: @method())
Latex(path: "chapters/discussion.tex")
}无法识别的命令会报错,并指出该命令。
作为组件的部分
在多个文档中重复使用的部件,例如某项发现、某种方法或签名块,可以做成组件。其 render 包含文档元素,或以 md 或 latex 块的形式返回该部件,文档通过名称调用它:Finding(title: 'Gliders', count: 3)。
信件与发票
Letter 会围绕其中的段落排版一封信件。在地址中,\n 用于开始新的一行:
<KScript.Document template="letter" to="'letter.pdf'">
<Letter from="{'Life Lab\n12 Grid Street\nCambridge'}" to="{'Dr Ada Lovelace\nExample University'}" subject="Invitation to speak" opening="Dear Dr Lovelace," closing="Yours sincerely," signature="Alan Turing">
<Paragraph>We would be delighted if you would give the opening talk.</Paragraph>
</Letter>
</KScript.Document>import KScript.Document
Document(template: letter, to: 'letter.pdf') {
Letter(from: 'Life Lab\n12 Grid Street\nCambridge', to: 'Dr Ada Lovelace\nExample University', subject: 'Invitation to speak', opening: 'Dear Dr Lovelace,', closing: 'Yours sincerely,', signature: 'Alan Turing') {
Paragraph "We would be delighted if you would give the opening talk."
}
}Invoice 根据项目列表生成整张发票。每个项目包含 description、quantity(默认为 1)以及 price 或 amount。小计、税额和总额会自动计算:
<let name="items" value="[{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]" />
<import package="KScript.Document" />
<Document template="invoice" to="'invoice.pdf'">
<Invoice number="INV-042" from="{'Life Lab Ltd\n12 Grid Street'}" to="Example University" due="20 December 2026" items="$items" currency="GBP" tax="20" notes="Please pay within 30 days." />
</Document>$items = [{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]
import KScript.Document
Document(template: invoice, to: 'invoice.pdf') {
Invoice(number: 'INV-042', from: 'Life Lab Ltd\n12 Grid Street', to: 'Example University', due: '20 December 2026', items: $items, currency: 'GBP', tax: 20, notes: 'Please pay within 30 days.')
}currency:是一个代码,例如GBP、USD、EUR或JPY,也可以是任意符号。tax:是一个百分比,tax_name:是它的名称(默认增值税),paid:是已支付的金额,会增加一笔应付余额。
页面与样式
这些内容放在 Document 上,用于改变模板的设置:
| 属性 | 作用 |
|---|---|
paper |
a4(默认)、a3、a5、b5、letter或legal,或带引号的尺寸,例如'15cm x 20cm'。landscape: true可将其开启。 |
margin |
一个尺寸('2.5cm'),或'2cm 3cm'(上下、左右),或像 CSS 那样四个尺寸。尺寸可以是mm、cm、in或pt,并需加引号。 |
font, heading_font |
serif(Times)、sans(Helvetica)或mono(Courier)。 |
size, line_height |
文字大小(以磅为单位,11)以及行距(作为其倍数,1.4)。 |
align |
justify、left、center 或 right。 |
accent |
标题和标题页的颜色,加引号:'#1f4e79' 或 'navy' 等名称。 |
numbered |
false 会使各节不带编号。 |
title_page, chapters |
true 将标题放在单独的页面上,并让每个顶级章节都从新页面开始。 |
citations |
numeric 或 author-year。 |
header, footer |
'left | centre | right',与[page]、[pages]、[title]、[author]和[date]。footer: '| Page [page] of [pages] |'使页数居中。footer: ''没有该选项。 |
rules |
默认的表格线:booktabs、grid 或 none。 |
language |
文本的语言,例如 'en-GB',用于 Word 的拼写检查和 HTML。 |
字体和字符
该 PDF 使用所有 PDF 阅读器都具备的字体(Times、Helvetica、Courier 和 Symbol),因此不嵌入任何字体,文件体积较小。这些字体涵盖西欧语言、普通希腊字母和数学符号。超出这些字体范围的字符,例如中文、表情符号或带重音符号的希腊字母(ά),在 PDF 中会显示为 ?;Word、HTML、Markdown 和 LaTeX 文件则会保留这些字符。
命令
| 命令 | 作用 |
|---|---|
@latex_escape(text) |
文本已转义,可安全地放入 LaTeX 文件:\ { } $ & % # _ ~ ^ 已被转义。 |
@document_templates() |
模板及其用途。 |