From 372e43e16571dc80d55e20f3fcfebf635eb01fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Fabian=20Kr=C3=BCger?= Date: Tue, 27 Apr 2021 01:47:42 +0200 Subject: [PATCH] Fix align spacing --- luamml-amsmath.lua | 2 +- luamml-convert.lua | 7 ++++++- test_tex.tex | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/luamml-amsmath.lua b/luamml-amsmath.lua index 1e961c4..e383d12 100644 --- a/luamml-amsmath.lua +++ b/luamml-amsmath.lua @@ -70,7 +70,7 @@ lua.get_functions_table()[funcid] = function() if not mml_table then return end local columns = node.count(node.id'align_record', tex.lists.align_head)//2 mml_table.columnalign = string.rep('right left', columns, ' ') - mml_table.columnalign = string.rep('0.3em', columns, '0.8em ') -- FIXME: 0.3em is a hack needed since MathML doesn't add spacing for our empty mrow + mml_table.columnspacing = string.rep('0', columns, ' 0.8em ') -- FIXME: 0.3em is a hack needed since MathML doesn't add spacing for our empty mrow save_result(mml_table, 0) end diff --git a/luamml-convert.lua b/luamml-convert.lua index ab83c94..5500f9e 100644 --- a/luamml-convert.lua +++ b/luamml-convert.lua @@ -376,10 +376,15 @@ function nodes_to_table(head, cur_style) end nonscript = nil if core and new_core ~= space_like then - core = new_core + core = core == space_like and new_core or nil end mn = new_mn end + -- In TeX, groups are never space like + if core == space_like then + core = {[0] = 'mi', intent = '@ignore'} + result[#result+1] = core + end if t[0] == 'mrow' and #t == 1 then assert(t == result) result = t[1] diff --git a/test_tex.tex b/test_tex.tex index 90f3d7e..8a00fc5 100644 --- a/test_tex.tex +++ b/test_tex.tex @@ -25,7 +25,7 @@ \] \begin{align} - abc&=def\\ + abc&=def & e^{\mathrm{i}\pi}&=-1\\ 1+2&=3\\ 5 \end{align}