feat: initial commit
This commit is contained in:
commit
b802ff49ab
454 files changed
+52429
No files matched your search
@@ -0,0 +1,56 @@
|
||||
# Highlight
|
||||
|
||||
# highlight
|
||||
|
||||
Highlights text with a background color.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
This is #highlight[important].
|
||||
```
|
||||
|
||||
```typst
|
||||
#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
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- fill:
|
||||
- description: The color to highlight the text with. ```typst This is #highlight( fill: blue )[highlighted with blue]. ```
|
||||
- type: none | color | gradient | tiling
|
||||
- default: rgb ("#fffd11a1")
|
||||
- stroke:
|
||||
- description: The highlight\'s border color. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-stroke) for more details. ```typst This is a #highlight( stroke: fuchsia )[stroked highlighting]. ```
|
||||
- type: none | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: (:)
|
||||
- top-edge:
|
||||
- description: The top end of the background rectangle. ```typst #set highlight(top-edge: "ascender") #highlight[a] #highlight[aib] #set highlight(top-edge: "x-height") #highlight[a] #highlight[aib] ```
|
||||
- type: length | str
|
||||
- default: "ascender"
|
||||
- bottom-edge:
|
||||
- description: The bottom end of the background rectangle. ```typst #set highlight(bottom-edge: "descender") #highlight[a] #highlight[ap] #set highlight(bottom-edge: "baseline") #highlight[a] #highlight[ap] ```
|
||||
- type: length | str
|
||||
- default: "descender"
|
||||
- extent:
|
||||
- description: The amount by which to extend the background to the sides beyond (or within if negative) the content. ```typst A long #highlight(extent: 4pt)[background]. ```
|
||||
- type: length
|
||||
- default: 0pt
|
||||
- radius:
|
||||
- description: How much to round the highlight\'s corners. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-radius) for more details. ```typst Listen #highlight( radius: 5pt, extent: 2pt )[carefully], it will be on the test. ```
|
||||
- type: relative | dictionary
|
||||
- default: (:)
|
||||
- body:
|
||||
- description: The content that should be highlighted.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
# Text
|
||||
|
||||
Text styling.
|
||||
|
||||
The [text function](/docs/reference/text/text/) is of particular interest.
|
||||
|
||||
## Definitions
|
||||
|
||||
| Name | Description |
|
||||
| --- | --- |
|
||||
| [`highlight`](/reference/text/highlight/) | Highlights text with a background color. |
|
||||
| [`linebreak`](/reference/text/linebreak/) | Inserts a line break. |
|
||||
| [`lorem`](/reference/text/lorem/) | Creates blind text. |
|
||||
| [`lower`](/reference/text/lower/) | Converts a string or content to lowercase. |
|
||||
| [`overline`](/reference/text/overline/) | Adds a line over text. |
|
||||
| [`raw`](/reference/text/raw/) | Raw text with optional syntax highlighting. |
|
||||
| [`smallcaps`](/reference/text/smallcaps/) | Displays text in small capitals. |
|
||||
| [`smartquote`](/reference/text/smartquote/) | A language-aware quote that reacts to its context. |
|
||||
| [`strike`](/reference/text/strike/) | Strikes through text. |
|
||||
| [`sub`](/reference/text/sub/) | Renders text in subscript. |
|
||||
| [`super`](/reference/text/super/) | Renders text in superscript. |
|
||||
| [`text`](/reference/text/text/) | Customizes the look and layout of text in a variety of ways. |
|
||||
| [`underline`](/reference/text/underline/) | Underlines text. |
|
||||
| [`upper`](/reference/text/upper/) | Converts a string or content to uppercase. |
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Line Break
|
||||
|
||||
# linebreak
|
||||
|
||||
Inserts a line break.
|
||||
|
||||
Advances the paragraph to the next line. A single trailing line break at the end of a paragraph is ignored, but more than one creates additional empty lines.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
*Date:* 26.12.2022 \
|
||||
*Topic:* Infrastructure Test \
|
||||
*Severity:* High \
|
||||
```
|
||||
|
||||
## Syntax
|
||||
|
||||
This function also has dedicated syntax: To insert a line break, simply write a backslash followed by whitespace. This always creates an unjustified break.
|
||||
|
||||
```typst
|
||||
#linebreak(
|
||||
justify: bool
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- justify:
|
||||
- description: Whether to justify the line before the break. This is useful if you found a better line break opportunity in your justified text than Typst did. ```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 ```
|
||||
- type: bool
|
||||
- default: false
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
# Lorem
|
||||
|
||||
# lorem
|
||||
|
||||
Creates blind text.
|
||||
|
||||
This function yields a Latin-like _Lorem Ipsum_ blind text with the given number of words. The sequence of words generated by the function is always the same but randomly chosen. As usual for blind texts, it does not make any sense. Use it as a placeholder to try layouts.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
= Blind Text
|
||||
#lorem(30)
|
||||
|
||||
= More Blind Text
|
||||
#lorem(15)
|
||||
```
|
||||
|
||||
```typst
|
||||
#lorem(
|
||||
words
|
||||
) -> str
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- words:
|
||||
- description: The length of the blind text in words.
|
||||
- type: int
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Lowercase
|
||||
|
||||
# lower
|
||||
|
||||
Converts a string or content to lowercase.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#lower("ABC") \
|
||||
#lower[*My Text*] \
|
||||
#lower[already low]
|
||||
```
|
||||
|
||||
```typst
|
||||
#lower(
|
||||
text
|
||||
) -> str content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- text:
|
||||
- description: The text to convert to lowercase.
|
||||
- type: str | content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# Overline
|
||||
|
||||
# overline
|
||||
|
||||
Adds a line over text.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#overline[A line over text.]
|
||||
```
|
||||
|
||||
```typst
|
||||
#overline(
|
||||
stroke: auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
offset: auto | length,
|
||||
extent: length,
|
||||
evade: bool,
|
||||
background: bool,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- stroke:
|
||||
- description: How to [stroke](/docs/reference/visualize/stroke/) the line. If set to `auto`, takes on the text\'s color and a thickness defined in the current font. ```typst #set text(fill: olive) #overline( stroke: green.darken(20%), offset: -12pt, [The Forest Theme], ) ```
|
||||
- type: auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- offset:
|
||||
- description: The position of the line relative to the baseline. Read from the font tables if `auto`. ```typst #overline(offset: -1.2em)[ The Tale Of A Faraway Line II ] ```
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- extent:
|
||||
- description: The amount by which to extend the line beyond (or within if negative) the content. ```typst #set overline(extent: 4pt) #set underline(extent: 4pt) #overline(underline[Typography Today]) ```
|
||||
- type: length
|
||||
- default: 0pt
|
||||
- evade:
|
||||
- description: Whether the line skips sections in which it would collide with the glyphs. ```typst #overline( evade: false, offset: -7.5pt, stroke: 1pt, extent: 3pt, [Temple], ) ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- background:
|
||||
- description: Whether the line is placed behind the content it overlines. ```typst #set overline(stroke: (thickness: 1em, paint: maroon, cap: "round")) #overline(background: true)[This is stylized.] \\ #overline(background: false)[This is partially hidden.] ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- body:
|
||||
- description: The content to add a line over.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
# Raw Text / Code
|
||||
|
||||
# raw
|
||||
|
||||
Raw text with optional syntax highlighting.
|
||||
|
||||
Displays the text verbatim and in a monospace font. This is typically used to embed computer code into your document.
|
||||
|
||||
Note that text given to this element cannot contain arbitrary formatting, such as `*strong*` or `_emphasis_`, as it is displayed verbatim. If you'd like to display any kind of content with a monospace font, instead of using [`raw`](/docs/reference/text/raw/), you should change its font to a monospace font using the [`text`](/docs/reference/text/text/) function.
|
||||
|
||||
## Example
|
||||
|
||||
```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.
|
||||
```
|
||||
|
||||
You can also construct a [`raw`](/docs/reference/text/raw/) element programmatically from a string (and provide the language tag via the optional [`lang`](/docs/reference/text/raw/#parameters-lang) argument).
|
||||
|
||||
```typst
|
||||
#raw("fn " + "main() {}", lang: "rust")
|
||||
```
|
||||
|
||||
## Syntax
|
||||
|
||||
This function also has dedicated syntax. You can enclose text in 1 or 3+ backticks (```) to make it raw. Two backticks produce empty raw text. This works both in markup and code.
|
||||
|
||||
When you use three or more backticks, you can additionally specify a language tag for syntax highlighting directly after the opening backticks. Within raw blocks, everything (except for the language tag, if applicable) is rendered as is, in particular, there are no escape sequences.
|
||||
|
||||
The language tag is an identifier that directly follows the opening backticks only if there are three or more backticks. If your text starts with something that looks like an identifier, but no syntax highlighting is needed, start the text with a single space (which will be trimmed) or use the single backtick syntax. If your text should start or end with a backtick, put a space before or after it (it will be trimmed).
|
||||
|
||||
If no syntax highlighting is available by default for your specified language tag (or if you want to override the built-in definition), you may provide a custom syntax specification file to the [`syntaxes`](/docs/reference/text/raw/#parameters-syntaxes) field.
|
||||
|
||||
## Styling
|
||||
|
||||
By default, the `raw` element uses the `DejaVu Sans Mono` font (included with Typst), with a smaller font size of `0.8em` (that is, 80% of the global font size). This is because monospace fonts tend to be visually larger than non-monospace fonts.
|
||||
|
||||
You can customize these properties with show-set rules:
|
||||
|
||||
```typst
|
||||
// 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
|
||||
```
|
||||
```
|
||||
|
||||
In addition, you can customize the syntax highlighting colors by setting a custom theme through the [`theme`](/docs/reference/text/raw/#parameters-theme) field.
|
||||
|
||||
For complete customization of the appearance of a raw block, a show rule on [`raw.line`](/docs/reference/text/raw/#definitions-line) could be helpful, such as to add line numbers.
|
||||
|
||||
Note that, in raw text, typesetting features like [hyphenation](/docs/reference/text/text/#parameters-hyphenate), [overhang](/docs/reference/text/text/#parameters-overhang), [CJK-Latin spacing](/docs/reference/text/text/#parameters-cjk-latin-spacing) (and [justification](/docs/reference/model/par/#parameters-justify) for [raw blocks](/docs/reference/text/raw/#parameters-block)) will be disabled by default.
|
||||
|
||||
```typst
|
||||
#raw(
|
||||
text,
|
||||
block: bool,
|
||||
lang: none | str,
|
||||
align: alignment,
|
||||
syntaxes: str | bytes | array,
|
||||
theme: none | auto | str | bytes,
|
||||
tab-size: int
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- text:
|
||||
- description: The raw text. You can also use raw blocks creatively to create custom syntaxes for your automations. ```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 ``` ```
|
||||
- type: str
|
||||
- default: None
|
||||
- block:
|
||||
- description: Whether the raw text is displayed as a separate block. In markup mode, using one-backtick notation makes this `false`. Using three-backtick notation makes it `true` if the enclosed content contains at least one line break. ```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" ``` ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- lang:
|
||||
- description: The language to syntax-highlight in. Apart from typical language tags known from Markdown, this supports the `"typ"`, `"typc"`, and `"typm"` tags for [Typst markup](/docs/reference/syntax/#markup), [Typst code](/docs/reference/syntax/#code), and [Typst math](/docs/reference/syntax/#math), respectively. ```typst ```typ This is *Typst!* ``` This is ```typ also *Typst*```, but inline! ```
|
||||
- type: none | str
|
||||
- default: none
|
||||
- align:
|
||||
- description: The horizontal alignment that each line in a raw block should have. This option is ignored if this is not a raw block (if specified `block: false` or single backticks were used in markup mode). By default, this is set to `start`, meaning that raw text is aligned towards the start of the text direction inside the block by default, regardless of the current context\'s alignment (allowing you to center the raw block itself without centering the text inside it, for example). ```typst #set raw(align: center) ```typc let f(x) = x code = "centered" ``` ```
|
||||
- type: alignment
|
||||
- default: start
|
||||
- syntaxes:
|
||||
- description: Additional syntax definitions to load. The syntax definitions should be in the [`sublime-syntax` file format](https://www.sublimetext.com/docs/syntax.html). You can pass any of the following values: - A path string to load a syntax file from the given path. For more details about paths, see the [Paths section](/docs/reference/syntax/#paths). - Raw bytes from which the syntax should be decoded. - An array where each item is one of the above. ```typst #set raw(syntaxes: "SExpressions.sublime-syntax") ```sexp (defun factorial (x) (if (zerop x) ; with a comment 1 (* x (factorial (- x 1))))) ``` ```
|
||||
- type: str | bytes | array
|
||||
- default: ()
|
||||
- theme:
|
||||
- description: The theme to use for syntax highlighting. Themes should be in the [`tmTheme` file format](https://www.sublimetext.com/docs/color_schemes_tmtheme.html). You can pass any of the following values: - `none`: Disables syntax highlighting. - `auto`: Highlights with Typst\'s default theme. - A path string to load a theme file from the given path. For more details about paths, see the [Paths section](/docs/reference/syntax/#paths). - Raw bytes from which the theme should be decoded. Applying a theme only affects the color of specifically highlighted text. It does not consider the theme\'s foreground and background properties, so that you retain control over the color of raw text. You can apply the foreground color yourself with the [`text`](/docs/reference/text/text/) function and the background with a [filled block](/docs/reference/layout/block/#parameters-fill). You could also use the [`xml`](/docs/reference/data-loading/xml/) function to extract these properties from the theme. ```typst #set raw(theme: "halcyon.tmTheme") #show raw: it => block( fill: rgb("#1d2433"), inset: 8pt, radius: 5pt, text(fill: rgb("#a2aabc"), it) ) ```typ = Chapter 1 #let hi = "Hello World" ``` ```
|
||||
- type: none | auto | str | bytes
|
||||
- default: auto
|
||||
- tab-size:
|
||||
- description: The size for a tab stop in spaces. A tab is replaced with enough spaces to align with the next multiple of the size. ```typst #set raw(tab-size: 8) ```tsv Year Month Day 2000 2 3 2001 2 1 2002 3 10 ``` ```
|
||||
- type: int
|
||||
- default: 2
|
||||
|
||||
|
||||
## Definitions
|
||||
### raw.line
|
||||
|
||||
A highlighted line of raw text.
|
||||
|
||||
This is a helper element that is synthesized by [`raw`](/docs/reference/text/raw/) elements.
|
||||
|
||||
It allows you to access various properties of the line, such as the line number, the raw non-highlighted text, the highlighted text, and whether it is the first or last line of the raw block.
|
||||
|
||||
```typst
|
||||
#raw.line(
|
||||
number,
|
||||
count,
|
||||
text,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- number:
|
||||
- description: The line number of the raw line inside of the raw block, starts at 1.
|
||||
- type: int
|
||||
- default: None
|
||||
- count:
|
||||
- description: The total number of lines in the raw block.
|
||||
- type: int
|
||||
- default: None
|
||||
- text:
|
||||
- description: The line of raw text.
|
||||
- type: str
|
||||
- default: None
|
||||
- body:
|
||||
- description: The highlighted raw text.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
# Small Capitals
|
||||
|
||||
# smallcaps
|
||||
|
||||
Displays text in small capitals.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
Hello \
|
||||
#smallcaps[Hello]
|
||||
```
|
||||
|
||||
## Smallcaps fonts
|
||||
|
||||
By default, this uses the `smcp` and `c2sc` OpenType features on the font. Not all fonts support these features. Sometimes, smallcaps are part of a dedicated font. This is, for example, the case for the _Latin Modern_ family of fonts. In those cases, you can use a show-set rule to customize the appearance of the text in smallcaps:
|
||||
|
||||
```typst
|
||||
#show smallcaps: set text(font: "Latin Modern Roman Caps")
|
||||
```
|
||||
|
||||
In the future, this function will support synthesizing smallcaps from normal letters, but this is not yet implemented.
|
||||
|
||||
## Smallcaps headings
|
||||
|
||||
You can use a [show rule](/docs/reference/styling/#show-rules) to apply smallcaps formatting to all your headings. In the example below, we also center-align our headings and disable the standard bold font.
|
||||
|
||||
```typst
|
||||
#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)
|
||||
```
|
||||
|
||||
```typst
|
||||
#smallcaps(
|
||||
all: bool,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- all:
|
||||
- description: Whether to turn uppercase letters into small capitals as well. Unless overridden by a show rule, this enables the `c2sc` OpenType feature. ```typst #smallcaps(all: true)[UNICEF] is an agency of #smallcaps(all: true)[UN]. ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- body:
|
||||
- description: The content to display in small capitals.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Smartquote
|
||||
|
||||
# smartquote
|
||||
|
||||
A language-aware quote that reacts to its context.
|
||||
|
||||
Automatically turns into an appropriate opening or closing quote based on the active [text language](/docs/reference/text/text/#parameters-lang).
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
"This is in quotes."
|
||||
|
||||
#set text(lang: "de")
|
||||
"Das ist in Anführungszeichen."
|
||||
|
||||
#set text(lang: "fr")
|
||||
"C'est entre guillemets."
|
||||
```
|
||||
|
||||
## Syntax
|
||||
|
||||
This function also has dedicated syntax: The normal quote characters (`'` and `"`). Typst automatically makes your quotes smart.
|
||||
|
||||
```typst
|
||||
#smartquote(
|
||||
double: bool,
|
||||
enabled: bool,
|
||||
alternative: bool,
|
||||
quotes: auto | str | array | dictionary
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- double:
|
||||
- description: Whether this should be a double quote.
|
||||
- type: bool
|
||||
- default: true
|
||||
- enabled:
|
||||
- description: Whether smart quotes are enabled. To disable smartness for a single quote, you can also escape it with a backslash. ```typst #set smartquote(enabled: false) These are "dumb" quotes. ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- alternative:
|
||||
- description: Whether to use alternative quotes. Does nothing for languages that don\'t have alternative quotes, or if explicit quotes were set. ```typst #set text(lang: "de") #set smartquote(alternative: true) "Das ist in anderen Anführungszeichen." ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- quotes:
|
||||
- description: The quotes to use. - When set to `auto`, the appropriate single quotes for the [text language](/docs/reference/text/text/#parameters-lang) will be used. This is the default. - Custom quotes can be passed as a string, array, or dictionary of either - [string](/docs/reference/foundations/str/): a string consisting of two characters containing the opening and closing double quotes (characters here refer to Unicode grapheme clusters) - [array](/docs/reference/foundations/array/): an array containing the opening and closing double quotes - [dictionary](/docs/reference/foundations/dictionary/): a dictionary containing the double and single quotes, each specified as either `auto`, string, or array ```typst #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.\' ```
|
||||
- type: auto | str | array | dictionary
|
||||
- default: auto
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
# Strikethrough
|
||||
|
||||
# strike
|
||||
|
||||
Strikes through text.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
This is #strike[not] relevant.
|
||||
```
|
||||
|
||||
```typst
|
||||
#strike(
|
||||
stroke: auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
offset: auto | length,
|
||||
extent: length,
|
||||
background: bool,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- stroke:
|
||||
- description: How to [stroke](/docs/reference/visualize/stroke/) the line. If set to `auto`, takes on the text\'s color and a thickness defined in the current font. _Note:_ Please don\'t use this for real redaction as you can still copy paste the text. ```typst This is #strike(stroke: 1.5pt + red)[very stricken through]. \\ This is #strike(stroke: 10pt)[redacted]. ```
|
||||
- type: auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- offset:
|
||||
- description: The position of the line relative to the baseline. Read from the font tables if `auto`. This is useful if you are unhappy with the offset your font provides. ```typst #set text(font: "Inria Serif") This is #strike(offset: auto)[low-ish]. \\ This is #strike(offset: -3.5pt)[on-top]. ```
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- extent:
|
||||
- description: The amount by which to extend the line beyond (or within if negative) the content. ```typst This #strike(extent: -2pt)[skips] parts of the word. This #strike(extent: 2pt)[extends] beyond the word. ```
|
||||
- type: length
|
||||
- default: 0pt
|
||||
- background:
|
||||
- description: Whether the line is placed behind the content. ```typst #set strike(stroke: red) #strike(background: true)[This is behind.] \\ #strike(background: false)[This is in front.] ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- body:
|
||||
- description: The content to strike through.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Subscript
|
||||
|
||||
# sub
|
||||
|
||||
Renders text in subscript.
|
||||
|
||||
The text is rendered smaller and its baseline is lowered.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
Revenue#sub[yearly]
|
||||
```
|
||||
|
||||
```typst
|
||||
#sub(
|
||||
typographic: bool,
|
||||
baseline: auto | length,
|
||||
size: auto | length,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- typographic:
|
||||
- description: Whether to use subscript glyphs from the font if available. Ideally, subscripts glyphs are provided by the font (using the `subs` OpenType feature). Otherwise, Typst is able to synthesize subscripts by lowering and scaling down regular glyphs. When this is set to `false`, synthesized glyphs will be used regardless of whether the font provides dedicated subscript glyphs. When `true`, synthesized glyphs may still be used in case the font does not provide the necessary subscript glyphs. ```typst N#sub(typographic: true)[1] N#sub(typographic: false)[1] ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- baseline:
|
||||
- description: The downward baseline shift for synthesized subscripts. This only applies to synthesized subscripts. In other words, this has no effect if `typographic` is `true` and the font provides the necessary subscript glyphs. If set to `auto`, the baseline is shifted according to the metrics provided by the font, with a fallback to `0.2em` in case the font does not define the necessary metrics.
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- size:
|
||||
- description: The font size for synthesized subscripts. This only applies to synthesized subscripts. In other words, this has no effect if `typographic` is `true` and the font provides the necessary subscript glyphs. If set to `auto`, the size is scaled according to the metrics provided by the font, with a fallback to `0.6em` in case the font does not define the necessary metrics.
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- body:
|
||||
- description: The text to display in subscript.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Superscript
|
||||
|
||||
# super
|
||||
|
||||
Renders text in superscript.
|
||||
|
||||
The text is rendered smaller and its baseline is raised.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
1#super[st] try!
|
||||
```
|
||||
|
||||
```typst
|
||||
#super(
|
||||
typographic: bool,
|
||||
baseline: auto | length,
|
||||
size: auto | length,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- typographic:
|
||||
- description: Whether to use superscript glyphs from the font if available. Ideally, superscripts glyphs are provided by the font (using the `sups` OpenType feature). Otherwise, Typst is able to synthesize superscripts by raising and scaling down regular glyphs. When this is set to `false`, synthesized glyphs will be used regardless of whether the font provides dedicated superscript glyphs. When `true`, synthesized glyphs may still be used in case the font does not provide the necessary superscript glyphs. ```typst N#super(typographic: true)[1] N#super(typographic: false)[1] ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- baseline:
|
||||
- description: The downward baseline shift for synthesized superscripts. This only applies to synthesized superscripts. In other words, this has no effect if `typographic` is `true` and the font provides the necessary superscript glyphs. If set to `auto`, the baseline is shifted according to the metrics provided by the font, with a fallback to `-0.5em` in case the font does not define the necessary metrics. Note that, since the baseline shift is applied downward, you will need to provide a negative value for the content to appear as raised above the normal baseline.
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- size:
|
||||
- description: The font size for synthesized superscripts. This only applies to synthesized superscripts. In other words, this has no effect if `typographic` is `true` and the font provides the necessary superscript glyphs. If set to `auto`, the size is scaled according to the metrics provided by the font, with a fallback to `0.6em` in case the font does not define the necessary metrics.
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- body:
|
||||
- description: The text to display in superscript.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
# Text
|
||||
|
||||
# text
|
||||
|
||||
Customizes the look and layout of text in a variety of ways.
|
||||
|
||||
This function is used frequently, both with set rules and directly. While the set rule is often the simpler choice, calling the `text` function directly can be useful when passing text as an argument to another function.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#set text(18pt)
|
||||
With a set rule.
|
||||
|
||||
#emph(text(blue)[
|
||||
With a function call.
|
||||
])
|
||||
```
|
||||
|
||||
```typst
|
||||
#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,
|
||||
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,
|
||||
body: content,
|
||||
text
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- font:
|
||||
- description: A font family descriptor or priority list of font family descriptors. A font family descriptor can be a plain string representing the family name or a dictionary with the following keys: - `name` (required): The font family name. - `covers` (optional): Defines the Unicode codepoints for which the family shall be used. This can be: - A predefined coverage set: - `"latin-in-cjk"` covers all codepoints except for those which exist in Latin fonts, but should preferably be taken from CJK fonts. - A [regular expression](/docs/reference/foundations/regex/) that defines exactly which codepoints shall be covered. Accepts only the subset of regular expressions which consist of exactly one dot, letter, or character class. When processing text, Typst tries all specified font families in order until it finds a font that has the necessary glyphs. In the example below, the font `Inria Serif` is preferred, but since it does not contain Arabic glyphs, the arabic text uses `Noto Sans Arabic` instead. The collection of available fonts differs by platform: - In the web app, you can see the list of available fonts by clicking on the "Ag" button. You can provide additional fonts by uploading `.ttf` or `.otf` files into your project. They will be discovered automatically. The priority is: project fonts \\> server fonts. - Locally, Typst uses your installed system fonts or embedded fonts in the CLI, which are `Libertinus Serif`, `New Computer Modern`, `New Computer Modern Math`, and `DejaVu Sans Mono`. In addition, you can use the `--font-path` argument or `TYPST_FONT_PATHS` environment variable to add directories that should be scanned for fonts. The priority is: `--font-paths` \\> system fonts \\> embedded fonts. Run `typst fonts` to see the fonts that Typst has discovered on your system. Note that you can pass the `--ignore-system-fonts` parameter to the CLI to ensure Typst won\'t search for system fonts. ```typst #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字体 ```
|
||||
- type: str | array | dictionary
|
||||
- default: "libertinus serif"
|
||||
- fallback:
|
||||
- description: Whether to allow last resort font fallback when the primary font list contains no match. This lets Typst search through all available fonts for the most similar one that has the necessary glyphs. _Note:_ Currently, there are no warnings when fallback is disabled and no glyphs are found. Instead, your text shows up in the form of "tofus": Small boxes that indicate the lack of an appropriate glyph. In the future, you will be able to instruct Typst to issue warnings so you know something is up. ```typst #set text(font: "Inria Serif") هذا عربي #set text(fallback: false) هذا عربي ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- style:
|
||||
- description: The desired font style. When an italic style is requested and only an oblique one is available, it is used. Similarly, the other way around, an italic style can stand in for an oblique one. When neither an italic nor an oblique style is available, Typst selects the normal style. Since most fonts are only available either in an italic or oblique style, the difference between italic and oblique style is rarely observable. If you want to emphasize your text, you should do so using the [emph](/docs/reference/model/emph/) function instead. This makes it easy to adapt the style later if you change your mind about how to signify the emphasis. ```typst #text(font: "Libertinus Serif", style: "italic")[Italic] #text(font: "DejaVu Sans", style: "oblique")[Oblique] ```
|
||||
- type: str
|
||||
- default: "normal"
|
||||
- weight:
|
||||
- description: The desired thickness of the font\'s glyphs. Accepts an integer between `100` and `900` or one of the predefined weight names. When the desired weight is not available, Typst selects the font from the family that is closest in weight. If you want to strongly emphasize your text, you should do so using the [strong](/docs/reference/model/strong/) function instead. This makes it easy to adapt the style later if you change your mind about how to signify the strong emphasis. ```typst #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] ```
|
||||
- type: int | str
|
||||
- default: "regular"
|
||||
- stretch:
|
||||
- description: The desired width of the glyphs. Accepts a ratio between `50%` and `200%`. When the desired width is not available, Typst selects the font from the family that is closest in stretch. This will only stretch the text if a condensed or expanded version of the font is available. If you want to adjust the amount of space between characters instead of stretching the glyphs itself, use the [`tracking`](/docs/reference/text/text/#parameters-tracking) property instead. ```typst #text(stretch: 75%)[Condensed] \\ #text(stretch: 100%)[Normal] ```
|
||||
- type: ratio
|
||||
- default: 100 %
|
||||
- size:
|
||||
- description: The size of the glyphs. This value forms the basis of the `em` unit: `1em` is equivalent to the font size. You can also give the font size itself in `em` units. Then, it is relative to the previous font size. ```typst #set text(size: 20pt) very #text(1.5em)[big] text ```
|
||||
- type: length
|
||||
- default: 11pt
|
||||
- fill:
|
||||
- description: The glyph fill paint. ```typst #set text(fill: red) This text is red. ```
|
||||
- type: color | gradient | tiling
|
||||
- default: luma (0 % )
|
||||
- stroke:
|
||||
- description: How to stroke the text. ```typst #text(stroke: 0.5pt + red)[Stroked] ```
|
||||
- type: none | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: none
|
||||
- tracking:
|
||||
- description: The amount of space that should be added between characters. ```typst #set text(tracking: 1.5pt) Distant text. ```
|
||||
- type: length
|
||||
- default: 0pt
|
||||
- spacing:
|
||||
- description: The amount of space between words. Can be given as an absolute length, but also relative to the width of the space character in the font. If you want to adjust the amount of space between characters rather than words, use the [`tracking`](/docs/reference/text/text/#parameters-tracking) property instead. ```typst #set text(spacing: 200%) Text with distant words. ```
|
||||
- type: relative
|
||||
- default: 100 % + 0pt
|
||||
- cjk-latin-spacing:
|
||||
- description: Whether to automatically insert spacing between CJK and Latin characters. ```typst #set text(cjk-latin-spacing: auto) 第4章介绍了基本的API。 #set text(cjk-latin-spacing: none) 第4章介绍了基本的API。 ```
|
||||
- type: none | auto
|
||||
- default: auto
|
||||
- baseline:
|
||||
- description: An amount to shift the text baseline by. ```typst A #text(baseline: 3pt)[lowered] word. ```
|
||||
- type: length
|
||||
- default: 0pt
|
||||
- overhang:
|
||||
- description: Whether certain glyphs can hang over into the margin in justified text. This can make justification visually more pleasing. ```typst #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. ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- top-edge:
|
||||
- description: The top end of the conceptual frame around the text used for layout and positioning. This affects the size of containers that hold text. ```typst #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] ```
|
||||
- type: length | str
|
||||
- default: "cap - height"
|
||||
- bottom-edge:
|
||||
- description: The bottom end of the conceptual frame around the text used for layout and positioning. This affects the size of containers that hold text. ```typst #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] ```
|
||||
- type: length | str
|
||||
- default: "baseline"
|
||||
- lang:
|
||||
- description: An [ISO 639-1/2/3 language code.](https://en.wikipedia.org/wiki/ISO_639) Setting the correct language affects various parts of Typst: - The text processing pipeline can make more informed choices. - Hyphenation will use the correct patterns for the language. - [Smart quotes](/docs/reference/text/smartquote/) turns into the correct quotes for the language. - And all other things which are language-aware. Choosing the correct language is important for accessibility. For example, screen readers will use it to choose a voice that matches the language of the text. If your document is in another language than English (the default), you should set the text language at the start of your document, before any other content. You can, for example, put it right after the `#set document(/* ... */)` rule that [sets your document\'s title](/docs/reference/model/document/#parameters-title). If your document contains passages in a different language than the main language, you should locally change the text language just for those parts, either with a set rule [scoped to a block](/docs/reference/scripting/#blocks) or using a direct text function call such as `#text(lang: "de")[...]`. If multiple codes are available for your language, you should prefer the two-letter code (ISO 639-1) over the three-letter codes (ISO 639-2/3). When you have to use a three-letter code and your language differs between ISO 639-2 and ISO 639-3, use ISO 639-2 for PDF 1.7 (Typst\'s default for PDF export) and below and ISO 639-3 for PDF 2.0 and HTML export. The language code is case-insensitive, and will be lowercased when accessed through [context](/docs/reference/context/). ```typst #set text(lang: "de") #outline() = Einleitung In diesem Dokument, ... ```
|
||||
- type: str
|
||||
- default: "en"
|
||||
- region:
|
||||
- description: An [ISO 3166-1 alpha-2 region code.](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) This lets the text processing pipeline make more informed choices. The region code is case-insensitive, and will be uppercased when accessed through [context](/docs/reference/context/).
|
||||
- type: none | str
|
||||
- default: none
|
||||
- script:
|
||||
- description: The OpenType writing script. The combination of `lang` and `script` determine how font features, such as glyph substitution, are implemented. Frequently the value is a modified (all-lowercase) ISO 15924 script identifier, and the `math` writing script is used for features appropriate for mathematical symbols. When set to `auto`, the default and recommended setting, an appropriate script is chosen for each block of characters sharing a common Unicode script property. ```typst #set text( font: "Libertinus Serif", 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 ```
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- dir:
|
||||
- description: The dominant direction for text and inline objects. Possible values are: - `auto`: Automatically infer the direction from the `lang` property. - `ltr`: Layout text from left to right. - `rtl`: Layout text from right to left. When writing in right-to-left scripts like Arabic or Hebrew, you should set the [text language](/docs/reference/text/text/#parameters-lang) or direction. While individual runs of text are automatically layouted in the correct direction, setting the dominant direction gives the bidirectional reordering algorithm the necessary information to correctly place punctuation and inline objects. Furthermore, setting the direction affects the alignment values `start` and `end`, which are equivalent to `left` and `right` in `ltr` text and the other way around in `rtl` text. If you set this to `rtl` and experience bugs or in some way bad looking output, please get in touch with us through the [Forum](https://forum.typst.app/), [Discord server](https://discord.gg/2uDybryKPe), or our [contact form](https://typst.app/contact). ```typst #set text(dir: rtl) هذا عربي. ```
|
||||
- type: auto | direction
|
||||
- default: auto
|
||||
- hyphenate:
|
||||
- description: Whether to hyphenate text to improve line breaking. When `auto`, text will be hyphenated if and only if justification is enabled. Setting the [text language](/docs/reference/text/text/#parameters-lang) ensures that the correct hyphenation patterns are used. ```typst #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. ```
|
||||
- type: auto | bool
|
||||
- default: auto
|
||||
- costs:
|
||||
- description: The "cost" of various choices when laying out text. A higher cost means the layout engine will make the choice less often. Costs are specified as a ratio of the default cost, so `50%` will make text layout twice as eager to make a given choice, while `200%` will make it half as eager. Currently, the following costs can be customized: - `hyphenation`: splitting a word across multiple lines - `runt`: ending a paragraph with a line with a single word - `widow`: leaving a single line of paragraph on the next page - `orphan`: leaving single line of paragraph on the previous page Hyphenation is generally avoided by placing the whole word on the next line, so a higher hyphenation cost can result in awkward justification spacing. Note: Hyphenation costs will only be applied when the [`linebreaks`](/docs/reference/model/par/#parameters-linebreaks) are set to "optimized". (For example by default implied by [`justify`](/docs/reference/model/par/#parameters-justify).) Runts are avoided by placing more or fewer words on previous lines, so a higher runt cost can result in more awkward in justification spacing. Text layout prevents widows and orphans by default because they are generally discouraged by style guides. However, in some contexts they are allowed because the prevention method, which moves a line to the next page, can result in an uneven number of lines between pages. The `widow` and `orphan` costs allow disabling these modifications. (Currently, `0%` allows widows/orphans; anything else, including the default of `100%`, prevents them. More nuanced cost specification for these modifications is planned for the future.) ```typst #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) ```
|
||||
- type: dictionary
|
||||
- default: (hyphenation : 100 % , runt : 100 % , widow : 100 % , orphan : 100 % ,)
|
||||
- kerning:
|
||||
- description: Whether to apply kerning. When enabled, specific letter pairings move closer together or further apart for a more visually pleasing result. The example below demonstrates how decreasing the gap between the "T" and "o" results in a more natural look. Setting this to `false` disables kerning by turning off the OpenType `kern` font feature. ```typst #set text(size: 25pt) Totally #set text(kerning: false) Totally ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- alternates:
|
||||
- description: Whether to apply stylistic alternates. Sometimes fonts contain alternative glyphs for the same codepoint. Setting this to `true` switches to these by enabling the OpenType `salt` font feature. ```typst #set text( font: "IBM Plex Sans", size: 20pt, ) 0, a, g, ß #set text(alternates: true) 0, a, g, ß ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- stylistic-set:
|
||||
- description: Which stylistic sets to apply. Font designers can categorize alternative glyphs forms into stylistic sets. As this value is highly font-specific, you need to consult your font to know which sets are available. This can be set to an integer or an array of integers, all of which must be between `1` and `20`, enabling the corresponding OpenType feature(s) from `ss01` to `ss20`. Setting this to `none` will disable all stylistic sets. ```typst #set text(font: "IBM Plex Serif") ß vs #text(stylistic-set: 5)[ß] \\ 10 years ago vs #text(stylistic-set: (1, 2, 3))[10 years ago] ```
|
||||
- type: none | int | array
|
||||
- default: ()
|
||||
- ligatures:
|
||||
- description: Whether standard ligatures are active. Certain letter combinations like "fi" are often displayed as a single merged glyph called a _ligature._ Setting this to `false` disables these ligatures by turning off the OpenType `liga` and `clig` font features. ```typst #set text(size: 20pt) A fine ligature. #set text(ligatures: false) A fine ligature. ``` Note that some programming fonts use other OpenType font features to implement "ligatures," including the contextual alternates (`calt`) feature, which is also enabled by default. Use the general [`features`](/docs/reference/text/text/#parameters-features) parameter to control such features.
|
||||
- type: bool
|
||||
- default: true
|
||||
- discretionary-ligatures:
|
||||
- description: Whether ligatures that should be used sparingly are active. Setting this to `true` enables the OpenType `dlig` font feature.
|
||||
- type: bool
|
||||
- default: false
|
||||
- historical-ligatures:
|
||||
- description: Whether historical ligatures are active. Setting this to `true` enables the OpenType `hlig` font feature.
|
||||
- type: bool
|
||||
- default: false
|
||||
- number-type:
|
||||
- description: Which kind of numbers / figures to select. When set to `auto`, the default numbers for the font are used. ```typst #set text(font: "Noto Sans", 20pt) #set text(number-type: "lining") Number 9. #set text(number-type: "old-style") Number 9. ```
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- number-width:
|
||||
- description: The width of numbers / figures. When set to `auto`, the default numbers for the font are used. ```typst #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. ```
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- slashed-zero:
|
||||
- description: Whether to have a slash through the zero glyph. Setting this to `true` enables the OpenType `zero` font feature. ```typst 0, #text(slashed-zero: true)[0] ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- fractions:
|
||||
- description: Whether to turn numbers into fractions. Setting this to `true` enables the OpenType `frac` font feature. It is not advisable to enable this property globally as it will mess with all appearances of numbers after a slash (e.g., in URLs). Instead, enable it locally when you want a fraction. ```typst 1/2 \\ #text(fractions: true)[1/2] ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- features:
|
||||
- description: Raw OpenType features to apply. - If given an array of strings, sets the features identified by the strings to `1`. - If given a dictionary mapping to numbers, sets the features identified by the keys to the values. ```typst // Enable the `frac` feature manually. #set text(features: ("frac",)) 1/2 ``` ```typst #set text(font: "Cascadia Code") => // Disable the contextual alternates (`calt`) feature. #set text(features: (calt: 0)) => ```
|
||||
- type: array | dictionary
|
||||
- default: (:)
|
||||
- body:
|
||||
- description: Content in which all text is styled according to the other arguments.
|
||||
- type: content
|
||||
- default: []
|
||||
- text:
|
||||
- description: The text.
|
||||
- type: str
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
# Underline
|
||||
|
||||
# underline
|
||||
|
||||
Underlines text.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
This is #underline[important].
|
||||
```
|
||||
|
||||
```typst
|
||||
#underline(
|
||||
stroke: auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
offset: auto | length,
|
||||
extent: length,
|
||||
evade: bool,
|
||||
background: bool,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- stroke:
|
||||
- description: How to [stroke](/docs/reference/visualize/stroke/) the line. If set to `auto`, takes on the text\'s color and a thickness defined in the current font. ```typst Take #underline( stroke: 1.5pt + red, offset: 2pt, [care], ) ```
|
||||
- type: auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- offset:
|
||||
- description: The position of the line relative to the baseline, read from the font tables if `auto`. ```typst #underline(offset: 5pt)[ The Tale Of A Faraway Line I ] ```
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- extent:
|
||||
- description: The amount by which to extend the line beyond (or within if negative) the content. ```typst #align(center, underline(extent: 2pt)[Chapter 1] ) ```
|
||||
- type: length
|
||||
- default: 0pt
|
||||
- evade:
|
||||
- description: Whether the line skips sections in which it would collide with the glyphs. ```typst This #underline(evade: true)[is great]. This #underline(evade: false)[is less great]. ```
|
||||
- type: bool
|
||||
- default: true
|
||||
- background:
|
||||
- description: Whether the line is placed behind the content it underlines. ```typst #set underline(stroke: (thickness: 1em, paint: maroon, cap: "round")) #underline(background: true)[This is stylized.] \\ #underline(background: false)[This is partially hidden.] ```
|
||||
- type: bool
|
||||
- default: false
|
||||
- body:
|
||||
- description: The content to underline.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Uppercase
|
||||
|
||||
# upper
|
||||
|
||||
Converts a string or content to uppercase.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#upper("abc") \
|
||||
#upper[*my text*] \
|
||||
#upper[ALREADY HIGH]
|
||||
```
|
||||
|
||||
```typst
|
||||
#upper(
|
||||
text
|
||||
) -> str content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- text:
|
||||
- description: The text to convert to uppercase.
|
||||
- type: str | content
|
||||
- default: None
|
||||
|
||||
|
||||
Reference in new issue
Block a user