Inline Syntax [inline-syntax-en-US]
Inline Syntax [inline-syntax-en-US]
Inline Typst might be the true strength of Kodama, as the designers have made great efforts to make it behave just like or at least very close to $\KaTeX$ inline formulas, so that the inline formulas written in Typst do not appear inferior when mixed with $\KaTeX$.
Inline Typst also uses link-like syntax, but in this case, no file is actually linked. The url
part is used to specify the inline mode and the margin
parameter. In most cases, users do not need to manually set the margin
parameter to achieve a good presentation. The inline mode is a parameter designed for the convenience of the Markdown editor’s own preview feature. When the user enters math
, the content of the text
part is automatically enclosed with ${}$
before being compiled by Typst. Here are some examples:
[$x^2$](inline)
,x^2
is a valid formula for both $\KaTeX$ and Typst. In this case, the Markdown editor’s own preview feature can correctly display it as $x^2$. However, this example is so simple that there is no real reason to use Typst.#
is a frequently used character in Typst. If you still write${}$
manually, it would lead to a poor preview experience in the editor. This is where the inline mode parametermath
comes into play. Now you can write the first example as[x^2](inline-math)
.Values of parameters are separated by
-
. The positions ofmath
andmargin
are fixed, which means that if both parameters are present, you can only writemargin
aftermath
. Themargin
is composed of text in the form of{x}-{y}
, wherex
andy
are any valid Typst length values, such as0pt-2pt
. Wheny
is missing,y
will adopt the value ofx
.