typst icon indicating copy to clipboard operation
typst copied to clipboard

Cyrillic numbering (Russian)

Open Andrew15-5 opened this issue 1 year ago • 7 comments

Description

I thought, that adding #set enum(numbering: "а)" | "А)" | "а." |"А.") numbering patterns would be perfect. But it's only for Cyrillic (which is my main issue). Maybe adding custom numbering — string (where each char is indexed enum label) or list of strings — would be a more flexible and universal solution.

Note: in Cyrillic enum list, next letters are de facto excluded: ё, й, ъ, ы, ь (source).

Use Case

Everyone would be able to easily create new numbering styles (emoji, Cyrillic, Japanese etc.).

Andrew15-5 avatar Jun 27 '23 16:06 Andrew15-5

You can already provide an arbitrary function to that argument

Enivex avatar Jun 27 '23 17:06 Enivex

Nice. Thank you!

Here is my MWE:

#let ru_alph(pattern: "а)") = {
  let alphabet = "абвгдежзиклмнопрстуфхцчшщэюя".split("")
  let f(i) = {
    let letter = alphabet.at(i)
    let str = ""
    for char in pattern {
      if char == "а" {
        str += letter
      }
      else if char == "А" {
        str += upper(letter)
      }
      else {
        str += char
      }
    }
    str
  }
  f
}
#set enum(numbering: ru_alph()) // or
#set enum(numbering: ru_alph(pattern: "А."))

Andrew15-5 avatar Jun 27 '23 17:06 Andrew15-5

I think the original issue is still relevant, though. There should be a cyrillic numbering kind.

MDLC01 avatar Jun 27 '23 21:06 MDLC01

I mean, for convenience — yes. But is it the only one which should be added — probably not. Although I don't know if every language uses its own alphabet/syllabary in enumerated lists.

Andrew15-5 avatar Jun 27 '23 21:06 Andrew15-5

The search for a solution to the same problem brought me here. If numbering patterns should support several alphabets (except English, Japanese, etc.), then it would be great for me to see support for Cyrillic alphabet out of the box as well. Otherwise, we are back to the fundamental problems of LaTeX.

Anyway, Typst is great!

syroezhkin avatar Dec 23 '23 14:12 syroezhkin

@syroezhkin, I think I haven't opened an issue asking for all numbering styles (not only Russian ones) because I have found this package: https://github.com/typst/packages/tree/main/packages/preview/numberingx/0.0.1 https://github.com/edhebi/numberingx

Which implements all the "predefined counter styles" listed here: https://www.w3.org/TR/predefined-counter-styles/. So I tried it and it works. Here is a MWE that covers all use cases (in a form of 2 examples) for Russian (case, excluded letters, [.)] suffix):

#import "@preview/numberingx:0.0.1"
#columns(2, {
  set enum(numbering: numberingx.formatter("{lower-russian})"))
  enum(..range(28).map(it => enum.item[]))
  colbreak()
  set enum(numbering: numberingx.formatter("{upper-russian-full})"))
  enum(..range(33).map(it => enum.item[]))
})
output

image

Although I never really had to use it in my documents. Nevertheless, it would be nice if not only Russian, but all the standard counter styles were to be added directly into Typst. You can open an issue about it, if it doesn't exist yet.

Andrew15-5 avatar Dec 23 '23 15:12 Andrew15-5

I'll re-open this issue, because the provided solutions are more of a workaround, than what I described/wanted.

There is already support for English, Japanese and Chinese, IIUC (https://typst.app/docs/reference/model/numbering/#parameters-numbering):

Counting symbols are 1, a, A, i, I, 一, 壹, あ, い, ア, イ, א, 가, ㄱ, and *. They are replaced by the number in the sequence, in the given case.

Since the most common set is the non-full one, I think it's better to include it, instead of the full one.

Andrew15-5 avatar Apr 10 '24 12:04 Andrew15-5