I am currently doing an article with a lot of Sanskrit and Pali words in the text. Most of these words have diacritics. I went through the accent function in Typst documentation but could not understand how to type one or two accented characters once or twice in every sentence. As you all know, Latex had language pack support. Help much appreciated. thanks.
I think this is the same thing as this thread (Typst) about umlaut, where I think the TL;DR is that this is an input (OS) problem, not a Typst problem. Set up your OS and keyboard so that you can type whatever you need to type in the language that you are typing, and it’s done. Typst support UTF-8 encoding of files, therefore you can insert any character from any language/script, which also in turn will make it easier to read it and review it.
I don’t have to deal with accents, thankfully (at least for the time being), but as a Japanese enjoyer/learner, I wouldn’t expect Typst to provide a way to insert all of the thousands of characters that are used in Japanese only by using the US English OS layout. I can write a wrapper hiragana()
, that will convert "ka"
to か
, but this would be insane to read even a shortened version like:
#hi[hi]#hi[ra]#hi[ga]#hi[na]
instead of just using an IME that can be used in any practical OS, and simply write
ひらがな
And this is only for hiragana. You would also have to have a different wrapper for katakana, but when you need to deal with kanji — good luck. As “しめる” with kanji will have one reading, but you would somehow need to choose through Typst API between something like 占める (occupy), 閉める (close), 締める (fasten).
So accents are basically like that, but you can type most of the things using the “standard” QWERTY keyboard layout for English. So facilitating one and not the other seems like a weird choice. A long time ago, I tried some Neovim plugins to basically have IME for Japanese without using OS’s IME. But that is a plugin, not a built-in solution, because editors also don’t have to facilitate this, they are for editing, not inputting. Just use a better layout or a compose key.
Anyway, you can open an issue requesting a feature, if you really want to. Use arbitrary characters as accents · Issue #422 · typst/typst · GitHub might be related.
There is some discussion about this - a feature request - over in the issue text.accent function counterpart to math.accent · Issue #833 · typst/typst · GitHub
If we use one of the workarounds there it could look like this:
// combining accents
#let grave = "\u{300}"
#let acute = "\u{301}"
e#grave;e#acute; are the same as èé.
// combining accents
#let svarita = "\u{0951}"
अ#svarita;प#svarita;
But then you have to excuse that I just grabbed the first info I could find from Vedic accent - Wikipedia and guessed that this could be an example of an accent you want to use - the example is probably nonsense! The same method/syntax works for any unicode codepoint that’s a combining accent.
If the syntax of the workaround or eventual solution should be e#acute;
or #acute("e")
or #acute[e]
, or anything else, I don’t know, they are all hard to read in the source text…
I am on Linux Mint, US international keyboard. I dont think it is as easy as you suggest. In case I am not getting your point, could you plese elaborate? Thanks.
Considering that those 2 languages are basically not used(?), for them specifically, you will probably have hard time finding an IME. Although there are few options for Indic languages at https://wiki.archlinux.org/title/Input_method#List_of_available_input_method_editors.
According to https://en.wikipedia.org/wiki/Pali#Alphabet_with_diacritics, you can use the Roman script. In that case, you would probably use a compose key, with a standard OS input source. If a compose key is not as fast/comfortable, then you would have to either modify your keyboard layout, or use some key mappings, or projects like GitHub - jtroo/kanata: Improve keyboard comfort and usability with advanced customization, that allows to have different configs/layers for a given keyboard. Which is a host-level software. For programmable keyboards like Glove80, you can use (ZMK) firmware-level keyboard layouts, config, layers, etc.
So there are many options overall.
Bluss, thanks. I am not writing foreign words in English. Sanskrit and Pali words are shown in English spelling with diacritics. example: yathā-bhūta-ñāna. Workarounds using extended syntax can be tiresome. I would like to have simple keyboard inputs/shortcuts based on language pack support as in Latex. Beginning to like Typst, but lack of this feature can be quite a let down.
If you are transliterating words, the US International keyboard should support adding accents by default. If that gets too tiresome, Keyman from SIL should have a keyboard layout available with the accents you need in a couple key-presses. Which romanisation standard are you using? I found this keyboard which uses ISO 15919 except e and o, which use IAST. Since you use Mint, the Ubuntu PPA for Keyman should work.
S_Save, thanks for discovering slp_1 Roman keyboard for me. But I can’t be switching back and forth between keyboards while typing an essay, right? That would be a royal pain in you-know-where if you are composing an essay of several pages. Anyway, it was very kind of you to take time up to look up and trying to help me. Cheers.
Can you quickly describe what those shortcuts in latex are? Maybe they’re simple to duplicate.