diff --git a/README.md b/README.md new file mode 100644 index 0000000..254df05 --- /dev/null +++ b/README.md @@ -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](./test_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). diff --git a/test_tex.tex b/test_tex.tex index 8a00fc5..55c341a 100644 --- a/test_tex.tex +++ b/test_tex.tex @@ -1,22 +1,34 @@ \documentclass{article} -% \usepackage{unicode-math} -\usepackage{amsmath} \usepackage{luamml} -\RegisterFamilyMapping\symsymbols{oms} -\RegisterFamilyMapping\symletters{oml} -\RegisterFamilyMapping\symlargesymbols{omx} +\usepackage{amsmath,array} + +\usepackage{unicode-math} +%% Uncomment the following lines when used without unicode-math +% \RegisterFamilyMapping\symsymbols{oms} +% \RegisterFamilyMapping\symletters{oml} +% \RegisterFamilyMapping\symlargesymbols{omx} + \ExplSyntaxOn -\tracingmathml2 -\pdfvariable compresslevel0 +\tracingmathml=2 +\pdfvariable compresslevel=0 \cs_new_protected:Npn \ShowMathMLObj { \message { \luamml_get_last_mathml_stream:e{}~0~R } } \ExplSyntaxOff + \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}. \] @@ -29,7 +41,6 @@ 1+2&=3\\ 5 \end{align} -\ShowMathMLObj Es gilt $\sin(x)-\sin(x+2\pi)=0$. \end{document}