Typst supports unicode symbols out-of-the box, but I found no obvious way to type them in my code. I am using VS Code with the Tinymist plugin.
In other contexts I use the Unicode Latex plugin: Unicode Latex - Visual Studio Marketplace which allows me to just type LaTeX syntax which tab-completes to unicode. So if I type \beta<TAB> a nice β is inserted in my source. This works in all sorts of file types in VS code, but I am unable to make it work with typ-files.
Does anyone have a smooth solution for entering unicode? I would prefer not to have to remember hex codes.
Note that accessing named symbols outside of math mode requires prefixing them with #sym. (e.g. #sym.alpha). For convenience, you can write as follows to import some symbols from that namespace, avoiding the sym prefix even outside of math mode:
// Without imports:
#sym.alpha
// With imports:
#import sym: alpha
// Output: alpha symbol
#alpha
If a symbol is not in the default list of symbols, you can create your own if you know the codepoint number (or if you just paste the character), by binding either a string or a symbol type (Symbol Type – Typst Documentation) to a variable:
// Simple symbol (no variants)
#let coolarrow = "\u{226B}"
// Just pasting "≫" above would also work
$ coolarrow $
// Complex symbol (multiple variants)
#let letterA = symbol(
"a",
("uppercase", "A"),
("turned", "Ɐ")
)
#letterA
#letterA.uppercase
#letterA.turned
If you don’t have the Unicode character you need but remember what it looks like, there is also a website where you can draw to get any Unicode character: https://shapecatcher.com/
Thanks, but there is a slight misunderstanding here. I am looking for how to use α directly in my source code, instead of alpha. I want my source code to look like this:
sum_(n in NN) α dot n
and, specifically, I am looking for an easier way to type unicode characters, such as the way the Unicode LaTeX plugin allows.
I don’t think this exists yet, but I think that wouldn’t be too hard to add to Tinymist. It already has a symbol lookup feature, and Typst symbols are already Unicode characters (I assume all of them? at least most). I would open an issue about it on their Github repo, and maybe also on webapp-issues for the official app.
Hi @DNF ! Glad to see another Julia user on the Typst forum !
This feature is not currently available in VSCode. However, you can try the Typst Math VSCode extension (see here) that allows to preview math symbols directly in the editor.
I just noticed that I had both typ and typst in the Unicode Latex extension list. The typ entry seems to not do anything, but I confirm that the typst one does allow me to use the extension as expected.
Note also that you have to restart the VSCode process for the extension changes to go into effect.