summaryrefslogtreecommitdiff
path: root/docs/src/reference/details.yml
blob: 789e539021e78a8fce60c195910666174ba2c596 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
types: |
  To style your document, you need to work with values of different kinds: Lengths
  specifying the size of your elements, colors for your text and shapes, and more.
  Typst categorizes these into clearly defined _types_ and tells you where it
  expects which type of value.

  Apart from very basic types for numeric values and typical types known from
  programming languages, Typst provides a special type for _content._ A value of
  this type can hold anything that you can enter into your document: Text,
  elements like headings and shapes, and style information.

  In some places of Typst more specialized data types are used. Instead of listing
  all of them here, they are explained where they are relevant.

text: |
  Text styling.

  The [text function]($func/text) is of particular interest.

math: |
  Typst has special [syntax]($syntax/#math) and library functions
  to typeset mathematical formulas. Math formulas can be displayed inline with
  text or as separate blocks. They will be typeset into their own block if they
  start and end with at least one space (e.g. `[$ x^2 $]`).

  In math, single letters are always displayed as is. Multiple letters, however,
  are interpreted as variables and functions. To display multiple letters
  verbatim, you can place them into quotes and to access single letter
  variables, you can use the
  [hashtag syntax]($scripting/#expressions).

  ```example
  $ A = pi r^2 $
  $ "area" = pi dot.op "radius"^2 $
  $ cal(A) :=
      { x in RR | x "is natural" } $
  ```

  Math mode makes a wide selection of [symbols]($category/symbols/sym) like
  `pi`, `dot.op`, or `RR` available. Many mathematical symbols are available in
  different variants. You can select between different variants by applying
  [modifiers]($type/symbol) to the symbol. Typst further recognizes a number of
  shorthand sequences like `=>` that approximate a symbol. When such a shorthand
  exists, the symbol's documentation lists it.

  ```example
  $ x < y => x gt.eq.not y $
  ```

  Formulas can also contain line breaks. Each line can contain one or multiple
  _alignment points_ (`&`) which are then aligned.
  ```example
  $ sum_(k=0)^n k
      &= 1 + ... + n \
      &= (n(n+1)) / 2 $
  ```

  Math mode supports special function calls without the hashtag prefix. In these
  "math calls", the argument list works a little differently than in code:

  - Within them, Typst is still in "math mode". Thus, you can write math directly
    into them, but need to use hashtag syntax to pass code expressions (except
    for strings, which are available in the math syntax).
  - They support positional and named arguments, but don't support
    trailing content blocks and argument spreading.
  - They provide additional syntax for 2-dimensional argument lists. The
    semicolon (`;`) merges preceding arguments separated by commas into an array
    argument.

  ```example
  $ frac(a^2, 2) $
  $ vec(1, 2, delim: "[") $
  $ mat(1, 2; 3, 4) $
  $ lim_x =
      op("lim", limits: #true)_x $
  ```

  To write a verbatim comma or semicolon in a math call, escape it with a
  backslash. The colon on the other hand is only recognized in a special way if
  directly preceded by an identifier, so to display it verbatim in those cases,
  you can just insert a space before it.

  Functions calls preceded by a hashtag are normal code function calls and not
  affected by these rules.

layout: |
  Arranging elements on the page in different ways.

  By combining layout functions, you can create complex and automatic layouts.

visualize: |
  Drawing and data visualization.

  _Note:_ Functions for plotting and diagrams are not yet available. They will
  be in the future.

meta: |
  Document structuring and metadata setup.

  Here, you can find functions to structure your document and configure its
  metadata.

symbols: |
  These two modules give names to symbols and emoji to make them easy to insert
  with a normal keyboard. Alternatively, you can also always directly enter
  Unicode symbols into your text and formulas. In addition to the symbols listed
  below, math mode defines `dif` and `Dif`. These are not normal symbol values
  because they also affect spacing and font style.

sym: |
  Named general symbols.

  For example, `#sym.arrow` produces the → symbol. Within
  [formulas]($category/math), these symbols can be used without the `#sym.`
  prefix.

emoji: |
  Named emoji.

  For example, `#emoji.face` produces the 😀 emoji. If you frequently use
  certain emojis, you can also import them from the `emoji` module (`[#import
  emoji: face]`) to use them without the `#emoji.` prefix.

foundations: |
  Foundational functions for computation.

calculate: |
  Calculations and processing of numeric values.

  These functions are part of the `calc` module and not imported by default. In
  addition to the functions listed below, the `calc` module also defines the
  constants `pi`, `e`, `inf`, and `nan`.

construct: |
  Construction of and conversions between values of different types.

data-loading: |
  Data loading from external files.

  These functions help you with embedding data from experiments and APIs in your
  documents.

utility: |
  Useful utility functions.