In an old question Converting LaTeX into Unicode for email it is asked how to look up LaTeX symbols as Unicode. So far the most satisfactory answer is given by @Tom. I followed the link in the answer and found a gadget that does the following thing:
- Given
\alpha\partial\infty
it returnsα∂∞
- Given
\mathcal{H}\mathbb{R}
it returnsℋℝ
- Given
\slash{B}\underline{x}\bar{p}
it returnsB̸x̲p̅
(combining character) - Given
e^{1+\phi}_{ρ(χ)}
it returnse¹⁺ᵠᵨ₍ᵪ₎
(subscript and superscript) - Given
\sfrac{1}{2}\sfrac{5}{8}
it returns½⅝
(fraction)
However there are some defects: it cannot handle \overline{AB}
, \sfrac12
, \mathfrak{F}
, \not\exists
and some symbols are missing, such as \longrightarrow
and \bigcap
.
As a comparison, I compile the following code
\documentclass{article}
\usepackage{unicode-math}
\begin{document}
$\alpha\partial\infty$
$\mathcal H\mathbb R\mathfrak F$
$\slash B\underline x\bar p$
$e^{1+\phi}_{ρ(χ)}$
$\frac12\frac58$
$C\longrightarrow D$
\end{document}
and select-and-copy the pdf file. I get
𝛼𝜕∞HR𝔉/𝐵𝑥𝑝̄𝑒1+𝜙 15 𝐶⟶𝐷 𝜌(𝜒) 28
Notice that Latin and Greek characters are in italic, and \mathfrak
works.
I would like to know if there is any method that combines the benefits of the preceding two methods, so that by a^{10}+b^{10}=c^{10}
I can get 𝑎¹⁰ + 𝑏¹⁰ = 𝑐¹⁰
. (Notice the space.)
Update
@Heiko Oberdiek gives a direction: extend the python code. But I will leave this question open as I suspect that this could be done by pure TeX.
In my personal opinion, the converting mechanism should follow some or all of the following rules.
Spaces
Wikipedia says that there are many types of spaces in Unicode. Perhaps we can choose three and associate them to \thinmuskip
, \medmuskip
, \thickmuskip
.
Or we can preserve all spaces and let users control the spacing. (But there is some trouble: for example a\alpha = 1
and \alpha a = 1
)
Sub & superscript
Nested sub and superscript e^{n^2}
should be converted to e^{n²}
. That is, only the innermost sub and superscript is converted.
If a subformula contains characters that has not sub or superscript counterpart, do nothing. For example x^{12q}
.
Fraction
Fraction \frac12
could be converted to ½
or 1/2
. Also \frac{ab}{cd}
can be converted to (ab)/(cd)
or ab/cd
; but \frac{a+b}{c+d}
is always (a+b)/(c+d)
.
Reversibility
I expect that all resulting unicode strings are themselves valid LaTeX code
when unicode-math is included. However, one might prefer x^(p+q)
to x^{(p+q)}
or x^{p+q}
. And x^sin s
looks better than x^{\sin s}
.