/UniTeX

A transpiler that converts TeX into Unicode (as possible).

Primary LanguageTypeScriptMIT LicenseMIT

UniTeX

A transpiler that converts TeX into Unicode (as possible).

Usage

UniTeX.parse(source: string)

Example

  • text formula

    source target source target
    \TeX TᴇX \LaTeX LᴬTᴇX
    \KaTeX KᴬTᴇX \UniTeX UⁿᵢTᴇX
    source target
    a^2 + b^2 = c^2 a² + b² = c²
    source \ell(D) - \ell(K-D) = \deg D - g + 1
    target ℓ(D) - ℓ(K-D) = deg D - g + 1
    source E[m] \simeq \Z/m\Z \times \Z/m\Z, \text{Gal}(\bar a/a) \rarr \text{Aut}(E[m])
    target E[m] ≃ ℤ/mℤ × ℤ/mℤ, Gal(ā/a) → Aut(E[m])
  • environment

    % source & target
    \begin{pmatrix} 
       \cos\theta & -\sin\theta \\
       \sin\theta & \cos\theta 
    \end{pmatrix}
    
    ((cosθ -sinθ)(sinθ cosθ))
    

    % source & target
    \theorem (Wedderburn). All finite fields are commutative. 
    \proof. Omitted.
    
    \lemma. If K is a commutative field, every finite subgroup of K^\times is cyclic.
    
    𝐓𝐡𝐞𝐨𝐫𝐞𝐦 (Wedderburn). All finite fields are commutative. 
    𝑝𝑟𝑜𝑜𝑓. Omitted.
    
    𝐋𝐞𝐦𝐦𝐚. If K is a commutative field, every finite subgroup of Kˣ is cyclic.
    
  • inline formula

    source $J = [\frac{\partial f_1}{\partial x_1} \cdots \frac{\partial f_n}{\partial x_n}]$
    target 𝐽 = [(∂ 𝑓₁)/(∂ 𝑥₁) ⋯ (∂ 𝑓ₙ)/(∂ 𝑥ₙ)]
  • block formula

    % source & target
    $$\dfrac{4}{\pi}\;=\;1+\dfrac{1^2}{2+\dfrac{3^2}{2+\dfrac{5^2}{2+\ddots}}}$$
    
     4                  1²         
    ---  =  1 + -------------------
     π                    3²       
                 2 + ------------- 
                            5²     
                      2 + -------  
                           2 + ⋱   
    

TODO

  • Some basic or commonly used macro commands. ideally including but not limited to the functions in MathJax and KaTeX, They have some differences in the supported macros. This project will prefer the latter design (i.e. Supported Functions).

    • Fixed
      • Greek Letters
      • Unicode Block 79 : Mathematical Operators
        • 220x ~ 226x
        • 227x ~ 22Fx
      • Delimiters
      • Arrows
      • Operators
        • Big Operators
        • Operator Names
        • Combined Operator Names
      • Theorem Environment
      • Vertical Layout
      • Spacing
    • Unary
      • Accents (hard)
      • Font Family
      • Extensible Arrows
      • Optionals (sqrt)
    • Binary
      • Relations Operators
      • Fractions (inline)
      • (cmdline only) Fractions (block)
      • Binomials
    • Environments
      • Matrix (inline)
      • (cmdline only) Matrix (block)
      • Typeface (math env)
      • Typesetting (block)
      • Array
      • Align Family
      • (cmdline only) AMScd
      • (cmdline only) Tikzcd (hard)
    • Macros
      • Def
      • Command
  • A website convenient for input and output. Source code repository.

  • Additional unicode characters and corresponding macro commands (BabelMap). This is mainly for the macro commands that exist in the common packages of TeX, which are not implemented by KaTeX or MathJax but are supported by Unicode.

  • Multiline Structure.

Future

  • The output is syntactically compatible with AsciiMath, which may be used as the default style or an optional setting.

  • Terminal versions (in other languages). It is suitable for some environments with high performance requirements, so the JVM family (Java, Kotlin, etc.) or Rust will be given priority in language selection.


Development

  • node.js

Build (for Browser)

  • node.js
  • esbuild
npm run build

License

UniTeX is licensed under the MIT License.