How can I more easily input unicode characters?

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.

1 Like

This is the purpose of Typst’s named symbols: $ sum_(n in NN) alpha dot n $ produces the expected output, as seen below.

You can see a full list of named symbols (a subset of Unicode) here: General Symbols – Typst Documentation. You can even draw to find out the name of your desired symbol using this website: https://detypify.quarticcat.com/

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.

1 Like

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.

1 Like