typst_reference / chp04.typ
孟祥瑞
上传语料:typst_reference
fdbb2bf verified
Raw History Blame Contribute Delete
76.7 kB
#let rtext(content)={ text(fill: red,content) } #let btext(content)={ text(fill: blue,content) } = 文本库(Text)<text_type> 文本样式。 文本功能尤为值得关注。 == 高亮文本(highlight)<highlight> 用背景色高亮文本。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst This is #highlight[important]. ``` ],[ #set align(horizon) #image("images/4001.png",width: auto) ] ) === 参数(Parameters) ```typc highlight( fill: none color gradient tiling, stroke: none length color gradient stroke tiling dictionary, top-edge: length str, bottom-edge: length str, extent: length, radius: relative dictionary, body:content, ) → content ``` - *fill*: none or color or gradient or tiling 用于高亮文本的颜色。默认值:```typc rgb("#fffd11a1")``` #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst This is #highlight( fill: blue )[highlighted with blue]. ``` ],[ #set align(horizon) #image("images/4002.png",width: auto) ] ) - *stroke*:none length color gradient stroke tiling dictionary 高亮部分的边框颜色。更多详情请参阅#link(<rect_stroke>)[矩形组件]的文档。默认值:( : )。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst This is a #highlight( stroke: fuchsia )[stroked highlighting]. ``` ],[ #set align(horizon) #image("images/4003.png",width: auto) ] ) - *top-edge*: length str 背景矩形的顶端。默认值:```typc "ascender"```。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #set highlight(top-edge: "ascender") #highlight[a] #highlight[aib] #set highlight(top-edge: "x-height") #highlight[a] #highlight[aib] ``` ],[ #set align(horizon) #image("images/4004.png",width: auto) ] ) #table( columns: (0.5fr,1.5fr), stroke: none, align: left, table.header([Variant],[Details]), table.hline(), [\"ascender\"],[字体的升部,通常会超出所有字形的高度。], [\"cap-height\"],[大写字母的近似高度。], [\"x-height\"],[非升部小写字母的近似高度。], [\"baseline\"],[字母赖以放置的基线。], [\"bounds\"],[字形边界框的上边缘。] ) - *bottom-edge*: length str 背景矩形的底端。默认值:```typc "descender"```。 #table( columns: 1fr, align: left, stroke: none, [ ```typst #set highlight(bottom-edge: "descender") #highlight[a] #highlight[ap] #set highlight(bottom-edge: "baseline") #highlight[a] #highlight[ap] ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4005.png",width: 80%) ] ) ] ) #table( columns: (0.5fr,1.5fr), stroke: none, align: left, table.header([Variant],[Details]), table.hline(), [\"baseline\"],[字母所在的基线。], [\"descender\"],[该字体的下行延伸部分,通常超过所有字形的下沉深度。], [\"bounds\"],[字形边界框的底边。] ) - *extent*: length 向两侧延伸背景的距离;若数值为负,则代表向内容内部收缩。默认值:#text(fill: red,"0pt")。 #table( columns: 1fr, align: left, stroke: none, [ ```typst A long #highlight(extent: 4pt)[background]. ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4006.png",width: 80%) ] ) ] ) - *radius*: relative dictionary 高亮区域圆角的弧度大小。更多详情请参阅矩形相关文档。默认值:( : )。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst Listen #highlight( radius: 5pt, extent: 2pt )[carefully], it will be on the test. ``` ],[ #set align(horizon) #image("images/4007.png",width: auto) ] ) - *body*: content 需要突出显示的内容。 == 换行(linebreak)<linebreak> 插入换行符。 将段落切换至下一行。段落末尾单个尾随换行符会被忽略,但多个换行符会生成额外空行。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst *Date:* 26.12.2022 \ *Topic:* Infrastructure Test \ *Severity:* High \ ``` ],[ #set align(horizon) #image("images/4008.png",width: auto) ] ) === 语法(Syntax) 该函数还有专用语法:如需插入换行,只需输入反斜杠后接空白字符。该方式生成的换行始终为非对齐换行。 === 参数(Parameters) ```typc linebreak(justify:bool) → content ``` - *justify*: bool 是否对断行前的文本进行两端对齐。默认值:#text(fill: red,"false")。 如果你在两端对齐文本中找到了比Typst自动判定更合适的断行位置,该选项会很有用。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #set par(justify: true) #let jb = linebreak(justify: true) I have manually tuned the #jb line breaks in this paragraph #jb for an _interesting_ result. #jb ``` ],[ #set align(horizon) #image("images/4009.png",width: auto) ] ) == Lorem(lorem)<lorem> 生成占位文本。 该函数可生成类拉丁文的乱数占位文本,单词数量由用户指定。函数生成的单词序列固定,但单词是随机选取的。和常规占位文本一样,文本本身没有实际含义。可将其作为占位内容,用于测试页面布局。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst = Blind Text #lorem(30) = More Blind Text #lorem(15) ``` ],[ #set align(horizon) #image("images/4010.png",width: auto) ] ) === 参数(Parameters) ```typc lorem(words:int) → str ``` - *words*: int 盲文本的单词数量。 == Lower(lower)<lower> 将字符串或内容转换为小写。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #lower("ABC") \ #lower[*My Text*] \ #lower[already low] ``` ],[ #set align(horizon) #image("images/4011.png",width: auto) ] ) === 参数(Parameters) ```typc lower(text:str content) → strcontent ``` - *text*: str or content 要转换为小写的文本。 == Overline(overline)<overline> 为文本添加上划线。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #overline[A line over text.] ``` ],[ #set align(horizon) #image("images/4012.png",width: auto) ] ) === 参数(Parameters) ```typc overline( stroke: auto length color gradient stroke tiling dictionary, offset: auto length, extent: length, evade: bool, background: bool, body:content, ) → content ``` - *stroke*: auto length color gradient stroke tiling dictionary 如何描边。默认值:#rtext()[auto]。 如果设置为自动,则采用文本的颜色以及当前字体所定义的粗细。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #set text(fill: olive) #overline( stroke: green.darken(20%), offset: -12pt, [The Forest Theme], ) ``` ],[ #set align(horizon) #image("images/4013.png",width: auto) ] ) - *offset*: auto length 该线条相对于基线的位置。若为自动,则从字体表读取。默认值:#rtext()[auto]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #overline(offset: -1.2em)[ The Tale Of A Faraway Line II ] ``` ],[ #set align(horizon) #image("images/4014.png",width: auto) ] ) - *extent*: length 需要将线条延伸超出内容的距离(若为负值,则向内容内部延伸)。默认值:#rtext()[0pt]。 #table( columns: 1fr, align: left, stroke: none, [ ```typst #set overline(extent: 4pt) #set underline(extent: 4pt) #overline(underline[Typography Today]) ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4015.png",width: 80%) ] ) ] ) - *evade*: bool 该行是否会跳过会与字形发生碰撞的区域。默认值:#rtext()[true]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #overline( evade: false, offset: -7.5pt, stroke: 1pt, extent: 3pt, [Temple], ) ``` ],[ #set align(horizon) #image("images/4016.png",width: auto) ] ) - *background*: bool 该线条是否放置在其上划线内容的后方。默认值:#rtext()[false]。 #table( columns: 1fr, align: left, stroke: none, [ ```typst #set overline(stroke: aqua + 5pt) #overline(background: true)[Fully visible.] \ #overline(background: false)[Partially hidden.] ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4017.png",width: 80%) ] ) ] ) - *body*: content 需要在上方添加线条的内容。 == 原始文本/代码(Raw Text / Code)<raw> 带有可选语法高亮的原始文本。 以等宽字体原样展示文本。这通常用于在文档中嵌入计算机代码。 传递给该元素的文本会忽略标记语法,例如*加粗*或_斜体_,并原样显示。如果你希望使用等宽字体展示内容,同时保留标记语法,不要使用原始文本模式,你可以通过 #link(<text_font>)[text.font] 参数将文本字体显式设置为等宽字体。 原始元素主要通过#link(<raw_Syntax>)[专用语法]生成:在文本两侧使用单个反引号(\`)或三个及以上反引号包裹文本。当使用三个或更多反引号时,紧跟起始反引号后的文本会被视为用于语法高亮的#link(<raw_lang>)[语言标记],原始文本则从第一个空白字符之后开始。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst Adding `rbx` to `rcx` gives the desired result. What is ```rust fn main()``` in Rust would be ```c int main()``` in C. ```rust fn main() { println!("Hello World!"); } ``` This has ``` `backticks` ``` in it (but the spaces are trimmed). And ``` here``` the leading space is also trimmed. ``` ],[ #set align(horizon) #image("images/4018.png",width: auto) ] ) 你也可以通过代码从字符串构建原生元素(并可通过可选的 #link(<raw_lang>)[lang] 参数提供语言标签)。 #table( columns: 1fr, align: left, stroke: none, [ ```typst #raw("fn " + "main() {}", lang: "rust") ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4019.png",width: 80%) ] ) ] ) 如果你的指定语言标签默认没有可用的语法高亮(或者你想要覆盖内置定义),你可以向语法参数提供自定义语法规范文件。 === 风格(Styling)<raw_Styling> 风默认情况下,原始元素使用 DejaVu Sans Mono 字体(Typst自带),字号设为更小的 0.8em(即全局字号的80%)。这是因为等宽字体在视觉上通常比非等宽字体更大。 你可以通过show-set规则来自定义这些属性: ```typc // Switch to Cascadia Code for both // inline and block raw. #show raw: set text(font: "Cascadia Code") // Reset raw blocks to the same size as normal text, // but keep inline raw at the reduced size. #show raw.where(block: true): set text(1em / 0.8) Now using the `Cascadia Code` font for raw text. Here's some Python code. It looks larger now: ``` ```py def python(): return 5 + 5 ``` #figure( table( columns: 1, align: center, stroke: none, fill: luma(240), [ #image("images/4020.png",width: 80%) ] ) ) 此外,你可以通过 #link(<raw_theme>)[theme] 参数设置自定义主题,来定制语法高亮颜色。 如果要对原始代码块的外观进行完整自定义,可以使用 raw.line 的显示规则,例如添加行号。 请注意,在原始文本中,#link(<text_hyphenate>)[断字]、#link(<text_overhang>)[悬挂缩进]、#link(<text_cjk-latin-spacing>)[中日韩文字与拉丁文字间距]等排版特性,(对于原始代码块而言)#link(<Paragraph_justify>)[两端对齐功能]默认将被禁用。 === 语法(Syntax)<raw_Syntax> 该函数提供专用语法,可在标记模式与代码模式下生成原始文本元素。你可以在文本两侧使用一个或三个及以上反引号(\`)将其包裹,从而转为原始文本。两侧反引号数量必须保持一致,且被包裹的文本内部不能连续出现同等数量的反引号。仅输入两个反引号(\`\`)会生成空原始文本。 与Markdown的显著区别包括:单个反引号包裹的文本可以跨多行,并且不会移除缩进;而三个及以上反引号语法在行内使用时,仍然会解析语言标签。 用单个反引号包裹的原始文本无法指定语言标签,始终作为行内元素放在段落内,也就是#link(<raw_block>)[块参数]为#rtext()[false]。 #set par(hanging-indent: 1.3cm) 使用三个或更多反引号的原始语法具备以下特性: -- *在起始反引号之后,原始块仅会被数量相同的一串反引号终止。*\ 若要在内容中包含一串反引号,首尾使用的反引号数量必须比该串反引号至少多一个。 -- *如果原始文本包含换行,则为块级元素;否则为行内元素。*\ 这会相应地将#link(<raw_block>)[块参数]设置为#rtext()[true]或#rtext()[false]。 -- *起始反引号之后、首个空白字符之前的文本,会被当作用于语法高亮的语言标签。*\ 判定哪些文本可作为语言标签的具体规则计划进行调整,#link(<raw_Language-tag-changes>)[详细说明见下文]。 -- *首行与末行拥有特殊的裁剪规则*\ 对于首行:如果起始反引号或语言标签之后全部都是空白字符,则整行都会被裁剪。但如果该行存在非空白字符,那么仅会裁剪起始反引号或语言标签之后紧邻的单个空格(若存在)。 如果末行到结束反引号为止全部为空白字符,则该行会被裁剪。反之,若末行最后一个非空白字符是反引号,那么会从该行末尾裁剪掉一个空格(若存在)。 -- *各行开头共有的缩进会被裁剪*\ Typst 会移除原始文本所有行开头共有的空白字符,也就是公共缩进。起始反引号所在行除外。\ Typst首先找到包含非空白字符且开头空白字符数量最少的行(包含结束反引号所在行)。然后 Typst 对每一行都裁剪对应数量的开头空白字符。纯空白行也会移除同等数量字符直至该行清空,但会保留末尾多余的空白字符。\ 请注意,为简化处理,该检查将制表符和空格视为等价字符,并且它基于#link("https://www.unicode.org/glossary/#code_point")[Unicode码点]数量(即字符数量)进行处理,而非字节长度。 #set par(hanging-indent: 0cm) 三反引号语法的这些特性支持一些不太直观的使用场景: #set par(hanging-indent: 1.3cm) -- 若要书写包含连续反引号的文本,使用比该序列数量更多的反引号将其包裹:\`\`\`\` enclosed\`\`\`backticks\`\`\`\` -- 若要书写以反引号开头或结尾的文本,在首尾反引号内侧添加空格:\`\`\` \`backticks\` \`\`\` -- 若要书写带语言标签的行内高亮文本,在语言标签与文本之间添加空格:\`\`\`rust #rtext()[fn] main() {}\`\`\` -- 若要书写不带任何语言标签的行内文本,在起始反引号后添加空格:\`\`\` text\`\`\`,也可以使用单反引号语法:\`text\` #set par(hanging-indent: 0cm) *使用原始语法嵌入字符串*(*Embedding strings with raw syntax*) 原始语法的一个常见用例是:通过访问原始内容的.textfield来获取底层字符串,从而将带格式的数据嵌入为字符串。这也可以配合字节构造函数,把字符串转换为字节。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst An inline YAML dictionary via `.text` #yaml(bytes( ```yaml Magic: limited-by: Mana Pokémon: limited-by: Energy Yu-Gi-Oh: limited-by: false ```text // ^^^^ used as a string )) ``` ],[ #set align(horizon) #image("images/4021.png",width: auto) ] ) *语言标签变更(Language tag changes)*<raw_Language-tag-changes> 在使用三个或更多反引号的原始代码语法时,起始反引号之后紧跟的文本(直到第一个空白字符为止)会被视作#link(<raw_lang>)[语言标签]。但在当前版本的 Typst 中,只有符合 Typst 标识符规范的文本才会被识别为语言标签。第一个不属于合法标识符的字符,会被当作原始文本的起始。 例如,在当前版本的 Typst 中,如果一个原始代码块以 C++ 开头,标识符 C 会作为语言标签,而原始文本从 ++ 开始。如果原始代码块以 ++C 开头,则不会设置语言标签,原始文本直接从 ++C 开始。 若要在当前版本 Typst 中使用不符合标识符规范的语言标签,必须使用 #link(<raw_lang>)[lang] 参数:既可以通过构造函数传入字符串调用:```typst #raw("text", lang: "...")```,也可以使用 set 规则:```typ #set raw(lang: "...")```。 在下一个版本的 Typst 中,到第一个空白字符或反引号之前的全部文本都会被当作语言标签,语言标签支持的字符集更广。包含空格或反引号的标签,仍然需要通过 #link(<raw_lang>)[lang] 参数手动设置。 如果你的原始代码块在下一版 Typst 中的解析逻辑会发生变化,Typst 会发出警告提示你。 === 参数(Parameters) ```typc raw( text:str, block: bool, lang: none str, align: alignment, syntaxes: str path bytes array, theme: none auto str path bytes, tab-size: int, ) → content ``` - *text*: str<raw_text> 原始文本。 你也可以创造性地使用原始代码块,为自动化操作创建自定义语法。 #table( columns: 1fr, align: left, stroke: none, [ ```typst // Parse numbers in raw blocks with the // `mydsl` tag and sum them up. #show raw.where(lang: "mydsl"): it => { let sum = 0 for part in it.text.split("+") { sum += int(part.trim()) } sum } ``` ```mydsl 1 + 2 + 3 + 4 + 5 ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4022.png",width: 80%) ] ) ] ) - *block*: bool<raw_block> 原始文本是否作为独立块展示。默认值:#rtext()[false]。 在标记模式下,使用单反引号写法时该选项为否。若使用三反引号写法,当包裹内容至少包含一处换行时,该选项为是。 #table( columns: 1fr, align: left, stroke: none, [ ```typst // Display inline code in a small box // that retains the correct baseline. #show raw.where(block: false): box.with( fill: luma(240), inset: (x: 3pt, y: 0pt), outset: (y: 3pt), radius: 2pt, ) // Display block code in a larger block // with more padding. #show raw.where(block: true): block.with( fill: luma(240), inset: 10pt, radius: 4pt, ) With `rg`, you can search through your files quickly. This example searches the current directory recursively for the text `Hello World`: ``` \`\`\`bash rg "Hello World" \`\`\` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4023.png",width: 80%) ] ) ] ) - *lang*: none str<raw_lang> 用于语法高亮解析原始文本的语言。默认值:#rtext()[none]。 在HTML导出时,该选项会设置生成的html.code元素的data-lang属性。 除了Markdown中常见的语言标签外,还支持用于#link(<Syntax_Markup>)[Typst标记]、#link(<Syntax_Code_mode>)[Typst代码]和#link(<Syntax_Math_mode>)[Typst数学公式]的标签,分别为\"typ\"、\"typc\"以及\"typm\"。 #table( columns: 1fr, align: left, stroke: none, [ ```typ This is *Typst!* ``` This is ```typ also *Typst*```, but inline! ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4024.png",width: 80%) ] ) ] ) - *align: alignment*<raw_align> 原始块中每一行应采用的水平对齐方式。如果当前不是原始块(设置了 block: false,或在标记模式中使用了单个反引号),该选项会被忽略。默认值:start。 默认值为 start,即默认情况下原始文本沿块内文本方向的起始端对齐,不受当前上下文对齐方式影响(例如,这允许你将原始块整体居中,而不把块内的文本也居中)。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typst #set raw(align: center) ```typc let f(x) = x code = "centered" ``` ``` ],[ #set align(horizon) #image("images/4025.png",width: auto) ] ) - *syntaxes*: str path bytes array<raw_syntaxes> 要加载的附加语法定义。语法定义需采用 sublime-syntax 文件格式。 你可以传入以下任意类型的值:\ #set par(hanging-indent: 1cm) -- 用于加载语法文件的路径字符串或#link(<Path>)[路径]。\ -- 可从中解码出语法的原始字节。\ -- 一个数组,数组内每一项为上述类型之一。 #set par(hanging-indent: 0cm) #table( columns: 1fr, align: left, stroke: none, [ ```typ #set raw(syntaxes: "SExpressions.sublime-syntax") ``` ```sexp (defun factorial (x) (if (zerop x) ; with a comment 1 (\* x (factorial (- x 1))))) ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4026.png",width: 80%) ] ) ] ) - *theme: none auto str path bytes*<raw_theme> 用于语法高亮的主题。主题需采用 tmTheme 文件格式。默认值:#rtext()[auto]。 你可以传入以下任意值:\ #set par(hanging-indent: 1cm) -- #rtext()[none]:禁用语法高亮。\ -- #rtext()[auto]:使用 Typst 默认主题进行高亮。\ -- 路径字符串,即加载主题文件的#link(<Path>)[路径]。\ -- 用于解码主题的原始字节数据。 #set par(hanging-indent: 0cm) 应用主题仅会影响被专门高亮文本的颜色。它不会读取主题的前景色与背景色属性,因此你可以自主控制普通文本的颜色。你可以通过 #rtext()[text] 函数自行设置前景色,通过#link(<block_fill>)[填充块]设置背景色,也可以使用 xml 函数从主题文件中提取这些属性。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set raw(theme: "halcyon.tmTheme") #show raw: it => block( fill: rgb("#1d2433"), inset: 8pt, radius: 5pt, text(fill: rgb("#a2aabc"), it) ) = Chapter 1 #let hi = "Hello World" ``` ],[ #set align(horizon) #image("images/4027.png",width: auto) ] ) - *tab-size*: int 制表位的空格宽度。一个制表符会替换为足量空格,以对齐到该宽度的下一个整数倍位置。默认值:#rtext()[2]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set raw(tab-size: 8) #set par(first-line-indent: 0cm) ``` #set par(first-line-indent: 0cm) \`\`\`tsv\ Year Month Day\ 2000 2 3\ 2001 2 1\ 2002 3 10\ \`\`\` ],[ #set align(horizon) #image("images/4028.png",width: auto) ] ) === 定义(Definitions) - line<raw_line> 一行高亮的原始文本。 这是由原始元素合成的辅助元素。 它允许你获取该行的各类属性,例如行号、未高亮的原始文本、高亮文本,以及它是否为原始代码块的首行或末行。 ```typc raw.line( number:int, count:int, text:str, body:content, ) → content ``` #set par(hanging-indent: 1cm) -- *number*: int 原始代码块内原始行的行号,从1开始。 -- *count*: int 原始代码块中的总行数。 -- *body*: content 高亮的原始文本。 #set par(hanging-indent: 0cm) == 小型大写字母(smallcaps)<smallcaps> 以小型大写字母显示文本。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ Hello \ #smallcaps[Hello] ``` #set par(first-line-indent: 0cm) ],[ #set align(horizon) #image("images/4029.png",width: auto) ] ) === 小写大写字体(Smallcaps fonts)<smallcaps_fonts> 默认情况下,该功能会使用字体上的smcp与c2sc OpenType特性。并非所有字体都支持这些特性。有时小型大写字母会作为独立字体的一部分存在,例如拉丁现代字体家族就是如此。在这类场景下,你可以使用show-set规则自定义小型大写字母文本的显示效果: ```typ #show smallcaps: set text(font: "Latin Modern Roman Caps") ``` 未来,该功能将支持从普通字母合成小型大写字母,但此功能尚未实现。 === 小型大写字母标题(Smallcaps headings)<smallcaps_headings> 你可以使用显示规则为所有标题应用小型大写字母格式。在下面的示例中,我们还将标题设置为居中对齐,并取消默认的粗体字体。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set par(justify: true) #set heading(numbering: "I.") #show heading: smallcaps #show heading: set align(center) #show heading: set text( weight: "regular" ) = Introduction #lorem(40) ``` ],[ #set align(horizon) #image("images/4030.png",width: auto) ] ) === 参数(Parameters)<smallcaps_Parameters> ```typc smallcaps( all: bool, body:content, ) → content ``` - *all*: bool 是否同时将大写字母转为小型大写字母。默认值:#rtext()[false]。 除非显示规则覆盖该设置,否则会启用OpenType字体的c2sc特性。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #smallcaps(all: true)[UNICEF] is an agency of #smallcaps(all: true)[UN]. ``` ],[ #set align(horizon) #image("images/4031.png",width: auto) ] ) - *body*: content 要以小型大写字母显示的内容。 == 智能引号(smartquote)<smartquote> 可感知语言的引号,能够根据上下文做出适配。 会根据当前使用的#link(<text_lang>)[文本语言],自动切换为合适的前引号或后引号。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ "This is in quotes." #set text(lang: "de") "Das ist in Anführungszeichen." #set text(lang: "fr") "C'est entre guillemets." ``` ],[ #set align(horizon) #image("images/4032.png",width: auto) ] ) === 语法(Syntax) 该函数还有专用语法:普通引号字符(\'和\")。Typst 会自动将你的引号转换为智能引号。 === 参数(Parameters)<smallcaps_Parameters> ```typc smartquote( double: bool, enabled: bool, alternative: bool, quotes: auto str array dictionary, ) → content ``` - *double*: bool 这是否应该使用双引号。默认值:#rtext()[true]。 - *enabled*: bool 是否启用智能引号。默认值:#rtext()[true]。 如需让单个引号不启用智能特性,你也可以使用反斜杠对其转义。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set smartquote(enabled: false) These are "dumb" quotes. ``` ],[ #set align(horizon) #image("images/4033.png",width: auto) ] ) - *alternative*: bool 是否使用备用引号。默认值:#rtext()[false]。 对于没有备用引号的语言,或已设置显式引号的情况,该选项不生效。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(lang: "de") #set smartquote(alternative: true) "Das ist in anderen Anführungszeichen." ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4034.png",width: 80%) ] ) ] ) - *quotes*: auto str array dictionary\ 要使用的引号。默认值:#rtext()[auto]。 - 设置为自动时,将使用适配文本语言的相应单引号。这是默认设置。 - 自定义引号可以通过字符串、数组或字典形式传入,可为以下任意一种 - #link(<String>)[string]:由两个字符组成的字符串,包含起始双引号与结束双引号(此处字符指Unicode字形簇) - #link(<array>)[array]:包含起始双引号与结束双引号的数组 - #link(<dictionary>)[dictionary]:包含双引号和单引号的字典,每种引号可指定为#rtext()[auto]、string或array类型 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(lang: "de") 'Das sind normale Anführungszeichen.' #set smartquote(quotes: "()") "Das sind eigene Anführungszeichen." #set smartquote(quotes: (single: ("[[", "]]"), double: auto)) 'Das sind eigene Anführungszeichen.' ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4035.png",width: 80%) ] ) ] ) == 添加删除线(strike)<strike> 给文本添加删除线。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ This is #strike[not] relevant. ``` ],[ #set align(horizon) #image("images/4036.png",width: auto) ] ) === 参数(Parameters) ```typc strike( stroke: auto length color gradient stroke tiling dictionary, offset: auto length, extent: length, background: bool, body:content, ) → content ``` - *stroke*: auto length color gradient stroke tiling dictionary 如何绘制描边线条。默认值:#rtext()[auto]。 若设置为自动,将采用文本颜色以及当前字体所定义的粗细。 注意:请勿将此用于正式内容涂黑遮挡,因为文本仍可被复制粘贴。 #table( columns: 1fr, align: left, stroke: none, [ ```typ This is #strike(stroke: 1.5pt + red)[very stricken through]. \ This is #strike(stroke: 10pt)[redacted]. ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4037.png",width: 80%) ] ) ] ) - *offset*: auto length 线条相对于基线的位置。若设置为自动,则从字体表读取该值。默认值:#rtext()[auto]。 如果你对字体自带的偏移量不满意,这个参数会很有用。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(font: "Inria Serif") This is #strike(offset: auto)[low-ish]. \ This is #strike(offset: -3.5pt)[on-top]. ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4038.png",width: 80%) ] ) ] ) - *extent*: length 将线条向内容外侧延伸的距离(若数值为负,则向内容内侧缩进)。默认值:#rtext()[0pt]。 #table( columns: 1fr, align: left, stroke: none, [ ```typ This #strike(extent: -2pt)[skips] parts of the word. This #strike(extent: 2pt)[extends] beyond the word. ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4039.png",width: 80%) ] ) ] ) - *background*: bool 该行是否放置在内容后方。默认值:#rtext()[false]。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set strike(stroke: red + 2pt) #strike(background: true)[This is behind.] \ #strike(background: false)[This is in front.] ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4040.png",width: 80%) ] ) ] ) - *body*:content 需要加删除线的文本。 == 下标(sub)<sub> 将文本渲染为下标。 文本会以更小的字号显示,且基线位置下移。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ Revenue#sub[yearly] ``` ],[ #set align(horizon) #image("images/4041.png",width: auto) ] ) === 参数(Parameters) ```typc sub( typographic: bool, baseline: auto length, size: auto length, body:content, ) → content ``` - *typographic*: bool<sub_typographic> 是否使用字体自带的下标字形(如有)。默认值:#rtext()[true]。 理想情况下,下标字形由字体提供(通过OpenType的subs特性)。如果字体未提供,Typst可以通过下移并缩小普通字形来合成下标。 当该项设为false时,无论字体是否提供专用下标字形,都将使用合成字形。当该项设为true时,若字体缺少所需下标字形,仍可能使用合成字形。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ N#sub(typographic: true)[1] N#sub(typographic: false)[1] ``` ],[ #set align(horizon) #image("images/4042.png",width: auto) ] ) - *baseline*: auto length<sub_baseline> 合成下标用的基线向下偏移量。默认值:#rtext()[auto]。 该设置仅对合成下标生效。也就是说,如果启用排版字体(typographic为#rtext()[true])且字体自带所需的下标字形,则此设置无效。 若设为#rtext()[auto],基线将根据字体提供的度量信息进行偏移;当字体未定义相关度量信息时,回退使用#rtext()[0.2em]。 使用多字体时,可能需要手动指定基线和#link(<sub_size>)[字号]。可参考上标(#link(<super_baseline>)[super])的示例。 - *size*: auto length<sub_size> 合成下标所用的字体大小。默认值:#rtext()[auto]。 该设置仅对合成下标生效。也就是说,如果开启排版模式且字体自带所需的下标字形,则此设置无效。 若设为#rtext()[auto],大小会根据字体提供的度量信息进行缩放;当字体未定义相关度量信息时,将回退使用#rtext()[0.6em]。 - *body*:content<sub_body> 要作为下标显示的文本。 == 上标(super)<super> 将文本以上标形式呈现。 文本会缩小显示,且基线向上偏移。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ 1#super[st] try! ``` ],[ #set align(horizon) #image("images/4043.png",width: auto) ] ) === 参数(Parameters) ```typc super( typographic: bool, baseline: auto length, size: auto length, body:content, ) → content ``` - *typographic*: bool<super_typographic> 是否在字体支持的情况下使用字体自带的上标字形。默认值:#rtext()[true]。 理想情况下,上标字形由字体提供(通过 sups OpenType 特性)。如果字体不支持,Typst 可以将普通字形上移并缩小来合成上标。 当该项设为 false 时,无论字体是否提供专用上标字形,都将使用合成字形。当该项设为 true 时,若字体没有所需的上标字形,仍可能使用合成字形。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ N#super(typographic: true)[1] N#super(typographic: false)[1] ``` ],[ #set align(horizon) #image("images/4044.png",width: auto) ] ) - *baseline*: auto length<super_baseline> 合成上标的基线向下偏移量。默认值:#rtext()[auto]。 该设置仅对合成上标生效。也就是说,如果开启了印刷字体模式且字体自带所需的上标字形,此设置不会产生任何效果。 若设置为#rtext()[auto],基线将根据字体提供的度量信息进行偏移;当字体未定义相关度量信息时,会回退使用 #rtext()[-0.5em]。 注意:由于基线偏移方向为向下,想要让内容显示在普通基线的上方,你需要设置一个负值。 有时需要显式指定基线和#link(<super_size>)[字号]。在下面的示例中,上标文本使用了多款度量标准不兼容的字体。为避免对齐错乱,我们对所有字体的度量参数进行强制覆盖。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #let tz(timezone) = text( font: "Roboto", smallcaps(timezone, all: true), ) / Per-font metrics: 14:00#super[#tz[UTC], not #tz[CET]] #set super( baseline: -0.4em, size: 0.6em, typographic: false, ) / Unified metrics: 14:00#super[#tz[UTC], not #tz[CET]] ``` ],[ #set align(horizon) #image("images/4045.png",width: auto) ] ) - *size*: auto length<super_size> 合成上标的字体大小。默认值:#rtext()[auto]。 该设置仅适用于合成上标。也就是说,如果启用印刷排版模式且字体自带所需的上标字形,则该设置无效。 若设为自动,大小将根据字体提供的度量信息进行缩放;当字体未定义相关度量信息时,会回退至0.6em。 - *body*: content<super_body> 要作为上标显示的文本。 == 文本(text)<text> 以多种方式自定义文本的外观与布局。 该函数经常使用,既可配合预设规则使用,也可直接调用。虽然使用预设规则通常是更简便的选择,但在将文本作为参数传递给其他函数时,直接调用文本函数会很有用。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(18pt) With a set rule. #emph(text(blue)[ With a function call. ]) ``` ],[ #set align(horizon) #image("images/4046.png",width: auto) ] ) === 参数(Parameters) ```typc text( font: str array dictionary, fallback: bool, style: str, weight: int str, stretch: ratio, size: length, fill: color gradient tiling, stroke: none length color gradient stroke tiling dictionary, tracking: length, spacing: relative, cjk-latin-spacing: none auto, baseline: length, overhang: bool, top-edge: length str, bottom-edge: length str, lang: str, region: none str, script: auto str, dir: auto direction, hyphenate: auto bool, costs: dictionary, kerning: bool, alternates: bool int, stylistic-set: none int array, ligatures: bool, discretionary-ligatures: bool, historical-ligatures: bool, number-type: auto str, number-width: auto str, slashed-zero: bool, fractions: bool, features: array dictionary, variations: dictionary, body: content, text: str, ) → content ``` - *font*: str array dictionary<text_font> 字体族描述符,或是字体族描述符的优先级列表。默认值:```typc "libertinus serif"```。 字体族描述符可以是代表字体族名称的纯文本字符串,也可以是包含以下键的字典: #set par(hanging-indent: 1.3cm) -- name(必填):字体族名称。 -- covers(可选):定义该字体族适用的Unicode码点。可以为: #set par(first-line-indent: 2cm,hanging-indent: 2cm) $circle$ 预定义覆盖集: $quad square$ “latin-in-cjk”涵盖所有码位,但不包含那些在拉丁字体中存在、却最好从中日韩字体获取的码位。 $circle$ 用于精确规定需要覆盖哪些码点的#link(<regex>)[正则表达式]。仅接受由单个点、字母或字符类构成的那部分正则表达式子集。 #set par(first-line-indent: 1cm,hanging-indent: 0cm) 处理文本时,Typst会按顺序尝试所有指定的字体系列,直到找到包含所需字形的字体。在下方示例中,优先使用 Inria Serif 字体,但由于该字体不含阿拉伯文字形,阿拉伯语文本会改用 Noto Sans Arabic。 Typst 旨在将同一系列下的不同字体统一为同一个系列名称。为此,它会自动去除字体系列名称中常见的样式后缀,例如“Bold”(粗体)或“Condensed”(压缩体)。不要通过字体名称选择这类变体,而应使用 Typst 的内置机制(如字重和拉伸参数)进行设置。同理,在 Typst 中使用可变字体时,应当省略“Variable”、“Var”以及“VF”这类后缀,因为 Typst 会自动剔除它们,从而把静态字体和可变字体归为同一个系列。 在同一系列的多款字体之间,Typst 会挑选与配置的#link(<text_style>)[文本样式]、#link(<text_weight>)[字重]以及#link(<text_stretch>)[拉伸度]匹配度最高的字体。如果静态字体和可变字体都支持某一配置,会优先选用可变字体。 可用字体集合因平台而异: #set par(hanging-indent: 1.3cm) -- 在网页应用中,点击“Ag”按钮即可查看可用字体列表。你可以将.ttf或.otf文件上传到项目中以添加额外字体,程序会自动识别这些字体。字体优先级:项目字体 > 服务器字体。 -- 在本地环境下,Typst会使用你已安装的系统字体,或是命令行工具内置字体,内置字体包括Libertinus Serif、New Computer Modern、New Computer Modern Math以及DejaVu Sans Mono。此外,你可以使用--font-path参数或TYPST_FONT_PATHS环境变量,添加用于扫描字体的目录。字体优先级:--font-path > 系统字体 > 内置字体。执行typst fonts命令,可以查看Typst在你的系统中识别到的字体。注意,你可以向命令行传入--ignore-system-fonts参数,让Typst不检索系统字体。 #set par(hanging-indent: 0cm) #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(font: "PT Sans") This is sans-serif. #set text(font: ( "Inria Serif", "Noto Sans Arabic", )) This is Latin. \ هذا عربي. // Change font only for numbers. #set text(font: ( (name: "PT Sans", covers: regex("[0-9]")), "Libertinus Serif" )) The number 123. // Mix Latin and CJK fonts. #set text(font: ( (name: "Inria Serif", covers: "latin-in-cjk"), "Noto Serif CJK SC" )) 分别设置“中文”和English字体 ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4047.png",width: 80%) ] ) ] ) - *fallback*: bool<text_fallback> 当主字体列表没有匹配项时,是否启用最后的字体回退机制。开启后,Typst会在所有可用字体中查找拥有所需字形、相似度最高的字体。默认值:#rtext()[true]。 注意:目前,若关闭回退机制且找不到对应字形时不会弹出警告。文本会以“豆腐块”形式显示:也就是用来表示缺少合适字形的小方框。未来版本中,你可以设置让Typst发出警告,以便及时发现这类问题。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(font: "Inria Serif") هذا عربي #set text(fallback: false) هذا عربي ``` ],[ #set align(horizon) #image("images/4048.png",width: auto) ] ) - *style*: str<text_style> 所需字体样式。默认值:```typc "normal"```。 当请求斜体(italic)样式,但仅有倾斜体(oblique)可用时,会使用倾斜体。同理反过来,斜体样式也可以替代倾斜体。如果斜体和倾斜体都不可用,Typst 将选用常规样式。由于大多数字体仅提供斜体或倾斜体其中一种,二者的差别通常很难察觉。 搭配合适的可变字体使用时,Typst 会根据该属性自动配置 ital(用于斜体样式)或 slnt(用于倾斜体样式)#link(<text_variations>)[字体变体]。 注意:如果你想强调文本,应当使用 emph 函数实现。这样后续如果想要更换强调的表现形式,调整样式会更加方便。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #text(font: "Libertinus Serif", style: "italic")[Italic] #text(font: "DejaVu Sans", style: "oblique")[Oblique] ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4049.png",width: 80%) ] ) ] ) #table( columns: (0.5fr,1.5fr), align: left, stroke: none, table.header([Variant],[Details]), table.hline(), [\"normal\"],[默认的、通常为正体的样式。], [\"italic\"],[一种带有自定义字形的草书字体。], [\"oblique\"],[只是常规样式的倾斜版本。] ) - *weight*: int str<text_weight> 字体字形的目标字重。可接受100至900之间的整数,或是预定义的字重名称。当所需字重不可用时,Typst会从该字族中选择字重最接近的字体。默认值:```typc "regular"```。 搭配合适的可变字体使用时,Typst会基于该属性自动配置wght#link(<text_variations>)[字体变体]。 注:如果你想对文本进行着重强调,应当改用strong函数。这样一来,若后续你想调整着重强调的样式,修改起来会更加方便。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(font: "IBM Plex Sans") #text(weight: "light")[Light] \ #text(weight: "regular")[Regular] \ #text(weight: "medium")[Medium] \ #text(weight: 500)[Medium] \ #text(weight: "bold")[Bold] ``` ],[ #set align(horizon) #image("images/4050.png",width: auto) ] ) #table( columns: (0.5fr,1.5fr), align: left, stroke: none, table.header([Variant],[Details]), table.hline(), [\"thin\"],[细字重(100)。], [\"extralight\"],[特细字重(200)。], [\"light\"],[细字重(300)。], [\"regular\"],[常规字重(400)。], [\"medium\"],[中等字重(500)。], [\"semibold\"],[半粗字重(600)。], [\"bold\"],[粗体字重(700)。], [\"extrabold\"],[特粗字重(800)。], [\"black\"],[黑粗字重(900)。], ) - *stretch*: ratio<text_stretch> 字形的目标宽度。可接受介于50%到200%之间的比例值。当无法设置该目标宽度时,Typst会从字族中选取拉伸程度最接近的字体。仅当该字体存在压缩或扩展版本时,文本才会被拉伸。默认值:#rtext()[100%]。 搭配合适的可变字体使用时,Typst会基于该属性自动配置wdth#link(<text_variations>)[字体变化轴]。 如果你想要调整字符之间的间距,而不是拉伸字形本身,请改用字距(#link(<text_tracking>)[tracking])属性。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(font: "IBM Plex Sans") #text(stretch: 75%)[Condensed] \ #text(stretch: 100%)[Normal] ``` ],[ #set align(horizon) #image("images/4051.png",width: auto) ] ) - *size*: length<text_size> 字形的大小。该值是em单位的基准:1em等于字体大小。默认值:#rtext()[11pt]。 你也可以使用em单位来设置字体大小,此时字体大小会相对于上一级字体大小进行计算。 当搭配合适的可变字体使用时,Typst会根据该属性自动配置opsz(光学尺寸)#link(<text_variations>)[字体变体],针对当前字号优化文字可读性。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(size: 20pt) very #text(1.5em)[big] text ``` ],[ #set align(horizon) #image("images/4052.png",width: auto) ] ) - *fill*: color gradient tiling<text_fill> 字形填充颜料。默认值:luma(#rtext()[0%])。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(fill: red) This text is red. ``` ],[ #set align(horizon) #image("images/4053.png",width: auto) ] ) - *stroke*: none length color gradient stroke tiling dictionary<text_stroke> 如何给文字添加描边。默认值:#rtext()[none]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #text(stroke: 0.5pt + red)[Stroked] ``` ],[ #set align(horizon) #image("images/4054.png",width: auto) ] ) - *tracking*: length<text_tracking> 字符之间需要添加的间距值。默认值:#rtext()[0pt]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(tracking: 1.5pt) Distant text. ``` ],[ #set align(horizon) #image("images/4055.png",width: auto) ] ) - *spacing*: relative<text_spacing> 单词之间的间距。默认值:#rtext()[100%+0pt]。 可以设置为固定长度,也可相对于字体中空格字符的宽度进行设置。 如果你想调整字符之间而非单词之间的间距,请改用字间距属性。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(spacing: 200%) Text with distant words. ``` ],[ #set align(horizon) #image("images/4056.png",width: auto) ] ) - *cjk-latin-spacing*: none auto<text_cjk-latin-spacing> 是否在中日韩文字与拉丁字符之间自动插入空格。默认值:#rtext()[auto]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(cjk-latin-spacing: auto) 第4章介绍了基本的API。 #set text(cjk-latin-spacing: none) 第4章介绍了基本的API。 ``` ],[ #set align(horizon) #image("images/4057.png",width: auto) ] ) - *baseline*: length<text_baseline> 用于偏移文本基线的数值。默认值:#rtext()[0pt]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ A #text(baseline: 3pt)[lowered] word. ``` ],[ #set align(horizon) #image("images/4058.png",width: auto) ] ) - *overhang*: bool<text_overhang> 两端对齐文本中,某些字形是否可以延伸到页边距区域。这样能让两端对齐的排版视觉效果更佳。默认值:#rtext()[true]。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set page(width: 220pt) #set par(justify: true) This justified text has a hyphen in the paragraph's second line. Hanging the hyphen slightly into the margin results in a clearer paragraph edge. #set text(overhang: false) This justified text has a hyphen in the paragraph's second line. Hanging the hyphen slightly into the margin results in a clearer paragraph edge. ``` ],[ #set align(horizon) #image("images/4059.png",width: auto) ] ) - *top-edge*: length str<text_top-edge> 用于布局和定位的文本外围概念框的顶端。该属性会影响承载文本的容器大小。默认值:```typc "cap-height"```。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set rect(inset: 0pt) #set text(size: 20pt) #set text(top-edge: "ascender") #rect(fill: aqua)[Typst] #set text(top-edge: "cap-height") #rect(fill: aqua)[Typst] ``` ],[ #set align(horizon) #image("images/4060.png",width: auto) ] ) #table( columns: (0.5fr,1.5fr), align: left, stroke: none, table.header([Variant],[Details]), table.hline(), [\"ascender\"],[该字体的升部,通常超过所有字形的高度。], [\"cap-height\"],[大写字母的近似高度。], [\"x-height\"],[不含升部小写字母的近似高度。], [\"baseline\"],[字母所依托的基线。], [\"bounds\"],[字形边界框的顶边。], ) - *bottom-edge*: length str<text_bottom-edge> 文本周围用于布局和定位的概念框架的底端。该属性会影响容纳文本的容器大小。默认值:```typc "baseline"```。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set rect(inset: 0pt) #set text(size: 20pt) #set text(bottom-edge: "baseline") #rect(fill: aqua)[Typst] #set text(bottom-edge: "descender") #rect(fill: aqua)[Typst] ``` ],[ #set align(horizon) #image("images/4061.png",width: auto) ] ) #table( columns: (0.5fr,1.5fr), align: left, stroke: none, table.header([Variant],[Details]), table.hline(), [\"baseline\"],[字母所处的基线。], [\"descender\"],[字体的下伸部,其深度通常超过所有字形的下沿。], [\"bounds\"],[字形边界框的底边。], ) - *lang*: str<text_lang> #link("https://en.wikipedia.org/wiki/ISO_639")[ISO 639-1/2/3语言代码]。默认值:```typc "en"```。 设置正确的语言会影响 Typst 的多个方面: -- 文本处理流程可以做出更合理的判断。 -- 断词会使用对应语言的规则。 -- 智能引号会转换为该语言适用的引号样式。 -- 以及其他所有与语言相关的功能。 选择正确的语言对于无障碍访问十分重要。例如,屏幕阅读器会依据语言设置,选用与文本语言匹配的语音。如果文档使用英语(默认语言)之外的其他语言,你需要在文档开头、所有其他内容之前设置文本语言。举例来说,你可以将该设置紧跟在用于#link(<document_title>)[设定文档标题]的 ```typ #set document(/* ... */)``` 规则之后。 如果文档内包含与主体语言不同的段落,你应当仅针对这些部分局部修改文本语言,可使用作用域限定在#link(<Scripting_Blocks>)[文本块]的set规则,或是直接调用文本函数,例如 ```typ #text(lang: "de")[...]```。 若你的语言存在多种可用代码,应优先选用双字母代码(ISO 639-1),而非三字母代码(ISO 639-2/3)。当必须使用三字母代码,且该语言在 ISO 639-2 和 ISO 639-3 中的代码不一致时,PDF 1.7(Typst 默认PDF导出版本)及更低版本请使用 ISO 639-2;PDF 2.0 和 HTML 导出则使用 ISO 639-3。 语言代码不区分大小写,通过#link(<Context>)[上下文]读取时会转为小写。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(lang: "de") #outline() = Einleitung In diesem Dokument, ... ``` ],[ #set align(horizon) #image("images/4062.png",width: auto) ] ) - *region*: none str<text_region> #link("https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2")[ISO 3166-1 alpha-2 区域代码]。默认值:```typc none```。 这可让文本处理流水线做出更合理的判断。 该区域代码不区分大小写,通过#link(<Context>)[上下文]读取时会转为大写。 - *script*: auto str<text_script> OpenType书写文字体系。默认值:```typc auto```。 语言与文字体系的组合决定字体特性(例如字形替换)的实现方式。该值通常采用经过修改的(全小写)ISO 15924文字体系标识符,数学书写文字体系用于适配数学符号相关特性。 当设置为#rtext()[auto](默认且推荐设置)时,系统会为每一组拥有相同Unicode文字体系属性的字符块选取合适的文字体系。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text( font: "IBM Plex Sans", size: 20pt, ) #let scedilla = [Ş] #scedilla // S with a cedilla #set text(lang: "ro", script: "latn") #scedilla // S with a subscript comma #set text(lang: "ro", script: "grek") #scedilla // S with a cedilla ``` ],[ #set align(horizon) #image("images/4063.png",width: auto) ] ) - *dir*: auto direction<text_dir> 文本和行内对象的主导方向。默认值:```typc auto```。 可选值如下: -- #rtext()[auto]:根据 lang 属性自动推断方向。 -- ltr:文本从左向右排布。 -- rtl:文本从右向左排布。 在书写阿拉伯语、希伯来语这类从右向左书写的文字时,你需要设置#link(<text_lang>)[文本语言]或文字方向。虽然独立文本片段会自动按正确方向排版,但设置主导方向可以为双向重排算法提供必要信息,从而正确放置标点符号和行内对象。此外,文字方向设置会影响起始端与结束端的对齐属性:在从左向右文本中,这两个属性分别等同于左对齐和右对齐;而在从右向左文本中则正好相反。 如果你将此项设置为从右向左(rtl)后遇到程序缺陷,或是出现显示效果异常的情况,请通过#link("https://forum.typst.app/")[论坛]、#link("https://discord.gg/2uDybryKPe")[Discord服务器]或者我们的#link("https://typst.app/contact")[联系表单]与我们取得联系。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(dir: rtl) هذا عربي. ``` ],[ #set align(horizon) #image("images/4064.png",width: auto) ] ) - *hyphenate*: auto bool<text_hyphenate> 是否对文本使用连字符以优化换行。设为#text(fill:red,"auto")时,仅当启用两端对齐时,文本才会使用连字符。默认值:```typc auto```。 设置#link(<text_lang>)[文本语言]可确保使用正确的断词规则。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set page(width: 200pt) #set par(justify: true) This text illustrates how enabling hyphenation can improve justification. #set text(hyphenate: false) This text illustrates how enabling hyphenation can improve justification. ``` ],[ #set align(horizon) #image("images/4065.png",width: auto) ] ) - *costs*: dictionary<text_costs> 默认值: ```typc ( hyphenation: 100%, runt: 100%, widow: 100%, orphan: 100%, ) ```。 排版文本时各类选择的“代价”。代价越高,排版引擎就越少采用该选择。代价以默认代价的比值设定,因此50%的代价会让文本排版做出该选择的意愿提升一倍,而200%的代价则会让其做出该选择的意愿减半。 目前可自定义的开销项如下: #set par(hanging-indent: 1cm) -- hyphenation: 将一个单词拆分到多行\ -- runt: 段落末尾仅由一个单词单独占一行\ -- widow: 段落单独一行留在下一页\ -- orphan: 段落单独一行留在上一页 #set par(hanging-indent: 0cm) 断字一般会通过把整个单词放到下一行来避免,因此更高的断字代价会造成不自然的两端对齐间距。注:断字代价仅在换行设置为“优化”时生效(例如#link(<Paragraph>)[两端对齐模式]默认启用该设置)。 短行可以通过在上一行多放或少放单词来规避,因此更高的短行代价同样会导致两端对齐的间距效果变差。 文本排版默认会防止孤行与寡行,因为各类排版规范通常不建议出现这类情况。但在部分场景下允许保留孤行、寡行,原因是防止孤行寡行的处理方式会把一行移到下一页,这可能导致各页面的行数不均衡。孤行与寡行代价参数可关闭这类自动调整。(当前规则:设为0%时允许孤行/寡行;其他数值,包括默认值100%,都会阻止孤行寡行。后续计划为这类调整提供更精细的代价配置。) #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(hyphenate: true, size: 11.4pt) #set par(justify: true) #lorem(10) // Set hyphenation to ten times the normal cost. #set text(costs: (hyphenation: 1000%)) #lorem(10) ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4065.png",width: 80%) ] ) ] ) - *kerning*: bool<text_kerning> 是否应用字距调整。默认值:```typc true```。 启用后,特定字母对的间距会拉近或拉远,以获得更好的视觉效果。下方示例展示了缩小字母“T”和“o”之间的间隙后,观感会更加自然。将此项设为#text(fill: red,"false")会关闭OpenType字体的字距特性,从而禁用字距调整。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(size: 25pt) Totally #set text(kerning: false) Totally ``` ],[ #set align(horizon) #image("images/4067.png",width: auto) ] ) - *alternates*: bool int<text_alternates> 是否启用样式替换字符。默认值:```typc 0```。 部分字体针对同一编码点提供备选字形。将该项设为true时,会开启OpenType的salt字体特性以切换至这类备选字形。可使用整数在多种备选字形之间进行选择。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text( font: "IBM Plex Sans", size: 20pt, ) 0, a, g, ß #set text(alternates: true) 0, a, g, ß ``` ],[ #set align(horizon) #image("images/4068.png",width: auto) ] ) - *stylistic-set*: none int array<text_stylistic-set> 要应用哪些样式集。字体设计师可以将替代字形归类到各个样式集中。由于该值高度依赖具体字体,你需要查阅所用字体的说明,了解可用的样式集。 该属性可以设置为一个整数或者整数数组,所有数值必须在1到20之间,以此开启从ss01到ss20对应的OpenType特性。若设置为none,则会禁用所有样式集。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(font: "IBM Plex Serif") ß vs #text(stylistic-set: 5)[ß] \ 10 years ago vs #text(stylistic-set: (1, 2, 3))[10 years ago] ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4069.png",width: 80%) ] ) ] ) - *ligatures*: bool<text_ligatures> 是否启用标准连字。默认值:```typc true```。 某些字母组合(例如“fi”)通常会显示为一个合并字形,称为连字。将此项设为false会关闭OpenType字体的liga与clig特性,从而禁用这类连字。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(size: 20pt) A fine ligature. #set text(ligatures: false) A fine ligature. ``` ],[ #set align(horizon) #image("images/4070.png",width: auto) ] ) 请注意,部分编程字体使用其他OpenType字体特性来实现“连字”,其中包括上下文替换(calt)特性,该特性默认同样处于启用状态。可使用通用#link(<text_features>)[特性]参数来控制这类特性。 - *discretionary-ligatures*: bool<text_discretionary-ligatures> 是否启用应谨慎使用的连字。将其设置为 true 可启用 OpenType dlig 字体功能。默认值:```typc false```。 - *historical-ligatures*: bool<text_historical-ligatures> 是否启用历史连字。将此项设为true会开启OpenType的hlig字体特性。默认值:```typc false```。 - *number-type*: auto str<text_number-type> 选择何种数字/字形。设置为自动时,将使用该字体的默认数字样式。默认值:```typc auto```。 - *number-width*: auto str<text_number-width> 数字/图形的宽度。设置为自动时,将使用该字体的默认数字样式。默认值:```typc auto```。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(font: "Noto Sans", 20pt) #set text(number-width: "proportional") A 12 B 34. \ A 56 B 78. #set text(number-width: "tabular") A 12 B 34. \ A 56 B 78. ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4071.png",width: 80%) ] ) ] ) #table( columns: (0.5fr,1.5fr), align: left, stroke: none, table.header([Variant],[Details]), table.hline(), [\"proportional\"],[具有字形专属宽度的数字(OpenType pnum字体特性)。], [\"tabular\"],[等宽数字(OpenType tnum字体特性)。], ) - *slashed-zero*: bool<text_slashed-zero> 是否在数字0字形上加斜杠。将此项设为true会启用OpenType字体的零数字特性。默认值:```typc false```。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ 0, #text(slashed-zero: true)[0] ``` ],[ #set align(horizon) #image("images/4072.png",width: auto) ] ) - *fractions*: bool<text_fractions> 是否将数字转换为分数。将此项设为#text(fill: red,"true")可启用OpenType分数字体特性。默认值:```typc false```。 不建议全局启用该属性,因为它会影响所有斜杠后的数字显示(例如网址中的数字)。如需使用分数效果,请在局部启用。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ 1/2 \ #text(fractions: true)[1/2] ``` ],[ #set align(horizon) #image("images/4073.png",width: auto) ] ) - *features*: array dictionary<text_features> 要应用的原始 OpenType 特性。默认值:```typc (:)```。 #set par(hanging-indent: 1cm) -- 如果提供字符串数组,将这些字符串标识的特性设置为 1。\ -- 如果提供映射到数字的字典,将这些键标识的特性设置为对应的值。这允许与非布尔特性(如 swsh)进行交互。 #set par(hanging-indent: 0cm) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ // Enable the `frac` feature manually. #set text(features: ("frac",)) 1/2 ``` ],[ #set align(horizon) #image("images/4074.png",width: auto) ] ) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text(font: "Cascadia Code") => // Disable the contextual alternates (`calt`) feature. #set text(features: (calt: 0)) => ``` ],[ #set align(horizon) #image("images/4075.png",width: auto) ] ) - *variations*: dictionary<text_variations> 要应用的原始OpenType字体变体。默认值:```typc (:)```。 传统静态字体的每一种样式组合都需要单独的字体文件,而可变字体带有变体轴,可通过变体轴生成多种不同样式。变体轴由区分大小写的四字符字符串标识。 有几个知名的可变字体轴,Typst 会根据文字#link(<text_weight>)[字重]、#link(<text_stretch>)[拉伸度]、#link(<text_style>)[样式]和#link(<text_size>)[字号]自动设置合适的数值,包括: #set par(hanging-indent: 1cm) -- wght:字重(例如 400 代表常规字重,700 代表粗体)\ --wdth:字宽(百分比,例如 100 代表正常宽度)\ -- slnt:倾斜角度(单位为度,负值代表向右倾斜)\ -- ital:斜体开关(0 为正体,1 为斜体)\ -- opsz:光学字号(单位为磅) #set par(hanging-indent: 0cm) 字体也可以定义自定义变化轴,以实现任意视觉效果。例如,某个变化轴的数值设置得越高,字体样式就可以变得越富有奇趣感。 借助 variations 参数,你可以直接为当前字体所支持的变化轴设置数值。该参数仅在搭配支持指定变化轴的可变字体时生效。你既可以使用该参数覆盖通用变化轴的自动赋值,也可以为自定义变化轴设置数值。 参数值应为字典类型,将轴标签(四个字符的#link(<String>)[字符串])映射到对应的数值(#link(<float>)[浮点数])。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set text(font: "Fraunces", size: 60pt) #text(variations: (SOFT: 0))[Soft? No.] \ #text(variations: (SOFT: 100))[Soft? Yes.] ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4076.png",width: 80%) ] ) ] ) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #set text( font: "Roboto Flex", weight: 900, stretch: 150%, ) Wide and Heavy #text(variations: (wght: 400))[ Forced back to normal, but still wide. ] ``` ],[ #set align(horizon) #image("images/4077.png",width: auto) ] ) - *body*: content<text_body> 所有文本均按照其他参数设置样式的内容。默认值:```typc []```。 - *text*: str<text_text> 文本。 == 下划线(underline)<underline> 给文字添加下划线。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ This is #underline[important]. ``` ],[ #set align(horizon) #image("images/4078.png",width: auto) ] ) === 参数(Parameters) ```typc underline( stroke: auto length color gradient stroke tiling dictionary, offset: auto length, extent: length, evade: bool, background: bool, body:content, ) → content ``` - *stroke*: auto length color gradient stroke tiling dictionary<underline_stoke> 如何#link(<stroke>)[描]边。默认值:```typc auto```。 如果设置为自动,则采用文本的颜色以及当前字体所定义的粗细。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ Take #underline( stroke: 1.5pt + red, offset: 2pt, [care], ) ``` ],[ #set align(horizon) #image("images/4079.png",width: auto) ] ) - *offset*: auto length<underline_offset> 如果设为自动,则从字体表读取线条相对于基线的位置。默认值:```typc auto```。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #underline(offset: 5pt)[ The Tale Of A Faraway Line I ] ``` ],[ #set align(horizon) #image("images/4080.png",width: auto) ] ) - *extent*: length<underline_extent> 将线条延伸至内容之外(若为负值,则向内容内部延伸)的长度。默认值:```typc 0pt```。 #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #align(center, underline(extent: 2pt)[Chapter 1] ) ] ``` ],[ #set align(horizon) #image("images/4081.png",width: auto) ] ) - *evade*: bool<underline_evade> 该行是否跳过会与字形发生碰撞的区域。默认值:```typc true```。 #table( columns: 1fr, align: left, stroke: none, [ ```typ This #underline(evade: true)[is great]. This #underline(evade: false)[is less great]. ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4082.png",width: 80%) ] ) ] ) - *background*: bool 该线条是否置于其所下划线内容的后方。默认值:```typc false```。 #table( columns: 1fr, align: left, stroke: none, [ ```typ #set underline(stroke: aqua + 5pt, evade: false) #underline(background: true)[Fully visible.] \ #underline(background: false)[Partially hidden.] ``` ], [ #set quote(block: true) #show quote: set align(center) #rect( fill: luma(240), width: 100%, height: auto, quote[ #image("images/4083.png",width: 80%) ] ) ] ) - *body*:content 需要添加下划线的内容。 == 大写字母(upper)<upper> 将字符串或内容转换为大写。 === 示例(Example) #table( columns: (1fr,1fr), align: (left,left), stroke: none, fill: (rgb(250, 250, 250),luma(86.27%)), [ ```typ #upper("abc") \ #upper[*my text*] \ #upper[ALREADY HIGH] ``` ],[ #set align(horizon) #image("images/4084.png",width: auto) ] ) === 参数(Parameters) ```typc upper(text: str content) → strcontent ``` - *text*: str content 要转为大写的文本。
#let rtext(content)={
text(fill: red,content)
}
#let btext(content)={
text(fill: blue,content)
}
= 文本库(Text)<text_type>
文本样式。
文本功能尤为值得关注。
== 高亮文本(highlight)<highlight>
用背景色高亮文本。
=== 示例(Example)
#table(
columns: (1fr,1fr),
align: (left,left),
stroke: none,
fill: (rgb(250, 250, 250),luma(86.27%)),
[
```typst
This is #highlight[important].
```
],[
#set align(horizon)
#image("images/4001.png",width: auto)
]
)
=== 参数(Parameters)
```typc
highlight(
fill: none color gradient tiling,
stroke: none length color gradient stroke tiling dictionary,
top-edge: length str,
bottom-edge: length str,
extent: length,
radius: relative dictionary,
body:content,
) → content
```
- *fill*: none or color or gradient or tiling
用于高亮文本的颜色。默认值:```typc rgb("#fffd11a1")```
#table(
columns: (1fr,1fr),
align: (left,left),
stroke: none,
fill: (rgb(250, 250, 250),luma(86.27%)),
[
```typst
This is #highlight(
fill: blue
)[highlighted with blue].
```
],[
#set align(horizon)
#image("images/4002.png",width: auto)
]
)
- *stroke*:none length color gradient stroke tiling dictionary
高亮部分的边框颜色。更多详情请参阅#link(<rect_stroke>)[矩形组件]的文档。默认值:( : )。
#table(
columns: (1fr,1fr),
align: (left,left),
stroke: none,
fill: (rgb(250, 250, 250),luma(86.27%)),
[
```typst
This is a #highlight(
stroke: fuchsia
)[stroked highlighting].
```
],[
#set align(horizon)
#image("images/4003.png",width: auto)
]
)
- *top-edge*: length str
背景矩形的顶端。默认值:```typc "ascender"```。
#table(
columns: (1fr,1fr),
align: (left,left),
stroke: none,
fill: (rgb(250, 250, 250),luma(86.27%)),
[
```typst
#set highlight(top-edge: "ascender")
#highlight[a] #highlight[aib]
#set highlight(top-edge: "x-height")
#highlight[a] #highlight[aib]
```
],[
#set align(horizon)
#image("images/4004.png",width: auto)
]
)
#table(
columns: (0.5fr,1.5fr),
stroke: none,