GitXplorerGitXplorer
t

latex2unicode

public
36 stars
8 forks
2 issues

Commits

List of commits on branch master.
Unverified
1c8b7c4af7c0f2aee3937c5c24305fd01063bc1b

Bump version to 0.3.2

ttomtung committed 2 years ago
Verified
22820edca5b0a7881d14c32eade773e82b309e58

Fix minus to minus hypen again (#20)

SSiedlerchr committed 2 years ago
Unverified
9500bb2ecb19312f6030c645165fd3b430216870

Add \to \gets and \iff support for ams arrows.

ddweiss committed 2 years ago
Unverified
b6b92b2b1a34ab10536f684e4adf813ad59e5c13

Bump version to 0.3.1

ttomtung committed 2 years ago
Unverified
44008c6ce792ba4f2c6243e7f298d021ce5fdefb

Fix minus as sub- and super-script

ttomtung committed 2 years ago
Unverified
ca4a14e356c036dd228b053d982196031011da04

Bump version to 0.3.0

ttomtung committed 3 years ago

README

The README file for this repository.

LaTeX2Unicode Build Status

LaTeX2Unicode translates LaTeX markup to human readable Unicode when possible. Here's an online demo that can be conveniently used to type in special characters. (demo source)

Basic math notations are supported. For instance:

\because \t{AB} + \t{BC} \neq \t{AC}
\therefore \iint\sqrt[4]{\xi^{\theta+1}} - \frac 38 \le
\Sigma \zeta_i \\
\therefore \exists{x}\forall{y} x \in \^A

is converted to

∵ A͡B + B͡C ≠ A͡C ∴ ∬∜ξ̅ᶿ̅⁺̅¹̅ - ⅜ ≤ Σ ζᵢ

∴ ∃x∀y x ∈ Â

Hundreds of other symbols and special characters are supported, too. For example, \spadesuit, \aleph, \OE, \downdownarrows and \o are translated to , , Œ, , ø, respectively.

Some font styles are supported, too. For instance:

\textbb{Black Board Bold}, \textfrak{Fraktur},
{\bf Bold Face}, {\cal Calligraphic}, {\it Italic},
{\tt Monospace}

is translated to

𝔹𝕝𝕒𝕔𝕜 𝔹𝕠𝕒𝕣𝕕 𝔹𝕠𝕝𝕕, 𝔉𝔯𝔞𝔨𝔱𝔲𝔯, 𝐁𝐨𝐥𝐝 𝐅𝐚𝐜𝐞, 𝓒𝓪𝓵𝓵𝓲𝓰𝓻𝓪𝓹𝓱𝓲𝓬, 𝐼𝑡𝑎𝑙𝑖𝑐, 𝙼𝚘𝚗𝚘𝚜𝚙𝚊𝚌𝚎

Using as Scala / Java Library

LaTeX2Unicode is written in Scala, thus can serve as a 3rd party library in any JVM application that needs to extract information from LaTeX texts (e.g. BibTeX).

Simple Conversion

For simple conversion without configuration, which works fine in most cases, one call to a static method and you're done.

In Scala:

import com.github.tomtung.latex2unicode._

val latex = "\\ss^2 + \\alpha_3 \n \\div \\frac{1}{3} = \\sqrt[3]{123}"
val unicode = LaTeX2Unicode.convert(latex)
println(unicode)

In Java:

import com.github.tomtung.latex2unicode.LaTeX2Unicode;

String latex = "\\ss^2 + \\alpha_3 \n \\div \\frac{1}{3} = \\sqrt[3]{123}"
String unicode = LaTeX2Unicode.convert(latex)
System.out.println(unicode);

Maven / SBT Dependency

To add dependency on LaTeX2Unicode, insert the following to your pom.xml file if you use Apache Maven:

<dependency>
    <groupId>com.github.tomtung</groupId>
    <artifactId>latex2unicode_2.12</artifactId>
    <version>0.3.2</version>
</dependency>

or add the following to your build.sbt file if you use sbt 0.11+:

libraryDependencies += "com.github.tomtung" %% "latex2unicode" % "0.3.2"

Credits

LaTeX2Unicode is inspired by two similar projects, latex-to-unicode by ypsu (written in Python) and latex-to-unicode by vikhyat (written in Ruby).

LaTeX2Unicode is built on fastparse, an fast and elegant PEG parsing framework.

Licence

Apache License Version 2.0