Howardzhangdqs/jumping-latex-ocr

Jumping Typst Template

HellOwhatAs opened this issue · 2 comments

typst 写了个 jumping 转换的函数,实现了readme里的10个规则

#let jumping(doc) = {
  import "@preview/quick-maths:0.1.0": shorthands

  show math.attach.where(
    base: text(math.sum)
  ).or(
    math.attach.where(base: text(math.Sigma))
  ): it => {
    math.attach(
      math.limits(math.frac(it.t, "2")),
      b: it.b, bl: it.bl, br: it.br, tl: it.tl, tr: it.tr
    )
  }
  show math.sum: math.frac("", "2")
  show math.Sigma: math.frac("", "2")
  
  show math.accent.where(base: [z], accent: "\u{307}").or(
    math.accent.where(base: math.cal("Z"), accent: "\u{307}")
  ): ""
  
  show math.Gamma: "7"
  
  show math.phi.alt: math.phi
  show math.Phi: math.phi
  show math.psi: math.phi
  show math.Psi: math.phi
  
  show: shorthands.with(
    ($pi z$, $pi^z$),
    ($c mu$, $L "/" -l$),
  )

  show math.mu: "m"
  show math.nabla: "D"
  
  show math.attach.where(base: [B], b: [1]): $B dot.c 1$

  show "数学分析": "数学方面"

  doc
}

/* 以上是 jumping 函数定义 */

#set text(lang: "zh")

#let test = $ sum_(k = 1)^(+ oo) =  dot(z) +  Gamma (pi  z) Psi $

// 原式
#test

// 转换
#jumping(test)

// 应用于余下整个文档
#show: jumping

数学分析,我们喜欢你

编译结果如图所示:
image

啊,typst大佬,这就贴Readme里