Compare commits

...

1 Commits

Author SHA1 Message Date
Marcel Fabian Krüger
caf8f7ee1d Add README 2021-05-03 23:23:36 +02:00
2 changed files with 35 additions and 10 deletions

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# Automated LuaLaTeX math to MathML conversion
**Highly experimental! At this point all interfaces may change without prior warning and many features aren't implemented yet. It is not ready for anything beyond simple experiments.**
This is an attempt to implement automatic conversion of LuaLaTeX inline and display math expressions into MathML code to aid with tagging.
It works best with `unicode-math`, but it can also be used with traditional math fonts if mappings to Unicode are provided.
## Installation
Run `l3build install` to install `luamml` into your local `texmf` tree.
## Demo
Run `lualatex test_tex` to see all equations from [our example file](./text_tex.tex) converted into MathML.
To test it on your own files, add `\usepackage{luamml}` and `\tracingmathml=2` to your preamble.
Also see a [`tagpdf` experiment using this to tag PDF formulas](https://github.com/u-fischer/tagpdf/blob/develop/experiments/exp-mathml-lua.tex).

View File

@ -1,22 +1,34 @@
\documentclass{article} \documentclass{article}
% \usepackage{unicode-math}
\usepackage{amsmath}
\usepackage{luamml} \usepackage{luamml}
\RegisterFamilyMapping\symsymbols{oms} \usepackage{amsmath,array}
\RegisterFamilyMapping\symletters{oml}
\RegisterFamilyMapping\symlargesymbols{omx} \usepackage{unicode-math}
%% Uncomment the following lines when used without unicode-math
% \RegisterFamilyMapping\symsymbols{oms}
% \RegisterFamilyMapping\symletters{oml}
% \RegisterFamilyMapping\symlargesymbols{omx}
\ExplSyntaxOn \ExplSyntaxOn
\tracingmathml2 \tracingmathml=2
\pdfvariable compresslevel0 \pdfvariable compresslevel=0
\cs_new_protected:Npn \ShowMathMLObj { \cs_new_protected:Npn \ShowMathMLObj {
\message { \luamml_get_last_mathml_stream:e{}~0~R } \message { \luamml_get_last_mathml_stream:e{}~0~R }
} }
\ExplSyntaxOff \ExplSyntaxOff
\begin{document} \begin{document}
\[ \[
ax^2+bx+c=0 \begin{pmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{pmatrix}
=
\begin{cases}
1 & $if $a=b\\
2 & $else$
\end{cases}
\] \]
\ShowMathMLObj
\[ \[
x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}. x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}.
\] \]
@ -29,7 +41,6 @@
1+2&=3\\ 1+2&=3\\
5 5
\end{align} \end{align}
\ShowMathMLObj
Es gilt $\sin(x)-\sin(x+2\pi)=0$. Es gilt $\sin(x)-\sin(x+2\pi)=0$.
\end{document} \end{document}