diff --git a/base/lttagging.dtx b/base/lttagging.dtx index 284a1fe0c..58f38b37c 100644 --- a/base/lttagging.dtx +++ b/base/lttagging.dtx @@ -566,6 +566,8 @@ % \NewSocket{tagsupport/math/display/end}{0} % \NewSocket{tagsupport/math/display/formula/begin}{2} % % \NewSocket{tagsupport/math/display/formula/end}{0} +% \NewSocket{tagsupport/math/display/tag/begin}{0} % +% \NewSocket{tagsupport/math/display/tag/end}{0} % \end{macrocode} % % \subsubsection{Sockets specific for luamml} diff --git a/required/latex-lab/latex-lab-amsmath.dtx b/required/latex-lab/latex-lab-amsmath.dtx index cece84325..ed22453c1 100644 --- a/required/latex-lab/latex-lab-amsmath.dtx +++ b/required/latex-lab/latex-lab-amsmath.dtx @@ -88,22 +88,31 @@ % The tag/label must be saved, so that it can be reinserted later. % TODO: xml export looks ok, but tagging with structure elements % is wrong and must be corrected. +% TODO: \cs{maketag@@@} is used in places where tagging/luamml handling +% is not wanted. This must be checked and handled. % \begin{macrocode} -\@namedef{maketag@@@} #1 +\def\maketag@@@#1 {% \ifmeasuring@ \hbox{\m@th\normalfont#1}% \else - \tagmcend \tagstructbegin{tag=Lbl}% - \tagmcbegin{tag=Lbl}% + \UseTaggingSocket{math/display/tag/begin} \hbox{\m@th\normalfont#1 \UseTaggingSocket{math/luamml/mtable/tag/save} }% - \tagmcend \tagstructend \tagmcbegin{}% + \UseTaggingSocket{math/display/tag/end} \fi } % \end{macrocode} -% +% \cs{eqref} uses \cs{tagform@} and so \cs{maketag@@@} but we do not want this tagging +% there. +% +% \begin{macrocode} +\def\maketag@@@notag#1{\hbox{\m@th\normalfont#1}} +\DeclareRobustCommand{\eqref}[1] + {\textup{\let\maketag@@@\maketag@@@notag\tagform@{\ref{#1}}}} +% \end{macrocode} +% % \subsubsection{align \& friends} % The align preamble (used in \cs{align@}) needs code for luamml % to save the cells. diff --git a/required/latex-lab/latex-lab-math.dtx b/required/latex-lab/latex-lab-math.dtx index 022ea8ee7..2d7ede7d4 100644 --- a/required/latex-lab/latex-lab-math.dtx +++ b/required/latex-lab/latex-lab-math.dtx @@ -1505,6 +1505,46 @@ % \end{macrocode} % \end{plugdecl} % +% \subsubsection{Sockets for tags (labels)} +% \begin{socketdecl} +% { +% tagsupport/math/display/tag/begin, +% tagsupport/math/display/tag/end, +% } +% These sockets are used in \cs{maketag@@@} to tag +% labels as Lbl. luamml changes the plug to move +% the Lbl into the math structure with an intent. +% \changes{v0.6l}{2025-02-06}{added sockets for tags/labels} +% \begin{macrocode} +\socket_new:nn {tagsupport/math/display/tag/begin}{0} +\socket_new:nn {tagsupport/math/display/tag/end}{0} +% \end{macrocode} +%\end{socketdecl} +% +% \begin{plugdecl}{default} +% \changes{v0.6j}{2024-11-19}{moved \cs{tagpdfparaOff} into the socket, tagging/765} +% \begin{macrocode} +\socket_new_plug:nnn + {tagsupport/math/display/tag/begin} + {default} + { + \tag_mc_end: + \tag_struct_begin:n {tag=Lbl} + \tag_mc_begin:n {} + } +\socket_new_plug:nnn + {tagsupport/math/display/tag/end} + {default} + { + \tag_mc_end: + \tag_struct_end: + \tag_mc_begin:n{} + } +\socket_assign_plug:nn {tagsupport/math/display/tag/begin}{default} +\socket_assign_plug:nn {tagsupport/math/display/tag/end}{default} +% \end{macrocode} +% \end{plugdecl} +% % \subsubsection{Internal sockets} % % \begin{variable}{\l_@@_content_template_tl} diff --git a/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua b/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua index 35454af4e..372f548d7 100644 --- a/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua +++ b/texmf/tex/lualatex/luamml/luamml-structelemwriter.lua @@ -8,6 +8,9 @@ local mc_end = token.create'tag_mc_end:' local catlatex = luatexbase.registernumber("catcodetable@latex") +ltx.__tag.struct.luamml = ltx.__tag.struct.luamml or {} +ltx.__tag.struct.luamml.labels = ltx.__tag.struct.luamml.labels or {} + local function escape_name(name) return name end @@ -117,10 +120,13 @@ local function write_elem(tree, stash) end for _, elem in ipairs(tree) do if type(elem) ~= 'string' and not elem['tex:ignore'] then - if elem['intent']==':equationlabel' and lastlblstructnum then - elem[1][#elem+1]={[':structnum']= lastlblstructnum} - lastlblstructnum=nil - end + if elem['intent']==':equationlabel' and ltx.__tag.struct.luamml.labels then + if #ltx.__tag.struct.luamml.labels > 0 then + -- print("CHECK LABEL STRUCTURE: ",table.serialize(elem), table.serialize(ltx.__tag.struct.luamml.labels)) + local num= table.remove(ltx.__tag.struct.luamml.labels,1) + elem[1][#elem+1]={[':structnum']= num} + end + end write_elem(elem) end end diff --git a/texmf/tex/lualatex/luamml/luamml.sty b/texmf/tex/lualatex/luamml/luamml.sty index 736e3bf66..db68b1800 100644 --- a/texmf/tex/lualatex/luamml/luamml.sty +++ b/texmf/tex/lualatex/luamml/luamml.sty @@ -231,6 +231,35 @@ } \AssignSocketPlug{tagsupport/math/luamml/mtable/tag/set}{luamml} +\clist_map_inline:nn + { + align, + alignat, + xalignat, + xxalignat, + flalign, + gather, + %multline, % NO + %equation, % NO + } + {\tl_const:cn { c__luamml_label_#1_tl}{}} +\NewSocketPlug{tagsupport/math/display/tag/begin}{luamml} + { + \tag_mc_end: + \bool_lazy_and:nnTF + { \tl_if_exist_p:c { c__luamml_label_ \@currenvir _tl } } + { \int_if_odd_p:n { \int_div_truncate:nn { \l__luamml_flag_int } { 8 } } } + { + \typeout{Stash~and~move~\@currenvir~Lbl} + \tag_struct_begin:n {tag=Lbl,stash} + \directlua{table.insert(ltx.__tag.struct.luamml.labels,\tag_get:n{struct_num})} + } + { + \tag_struct_begin:n {tag=Lbl} + } + \tag_mc_begin:n {} + } +\AssignSocketPlug{tagsupport/math/display/tag/begin}{luamml} \str_if_exist:cF { l__socket_tagsupport/math/luamml/hbox_plug_str } { \NewSocket{tagsupport/math/luamml/hbox}{2}