From 3d580a7cc76095b4d8586e784ec045c6c53479f0 Mon Sep 17 00:00:00 2001 From: Ulrike Fischer Date: Wed, 19 Feb 2025 23:23:43 +0100 Subject: [PATCH] corrections from review, trim spaces --- required/latex-lab/latex-lab-amsmath.dtx | 158 +++++++++++------------ required/latex-lab/latex-lab-math.dtx | 40 +++--- 2 files changed, 101 insertions(+), 97 deletions(-) diff --git a/required/latex-lab/latex-lab-amsmath.dtx b/required/latex-lab/latex-lab-amsmath.dtx index 880c0a271..3c9b8585a 100644 --- a/required/latex-lab/latex-lab-amsmath.dtx +++ b/required/latex-lab/latex-lab-amsmath.dtx @@ -94,7 +94,7 @@ % % \subsubsection{Tag} % The tag/label must be saved, so that it can be reinserted later. -% +% % TODO: \cs{maketag@@@} is perhaps used in places where tagging/luamml handling % is not wanted. This must be checked and handled. % \begin{macro}{\maketag@@@} @@ -114,8 +114,8 @@ % \end{macrocode} % \end{macro} % \cs{eqref} uses \cs{tagform@} and so \cs{maketag@@@} but we do not want this tagging -% there. -% +% there. +% % \begin{macro}{\eqref} % \begin{macro}{\maketag@@@notog} % \begin{macrocode} @@ -127,9 +127,9 @@ % \end{macro} % % \subsubsection{align \& friends} -% +% % Most display environment uses a common command for the end which contains -% the luamml socket to finalize the mtable. +% the luamml socket to finalize the mtable. % \begin{macro}{\common@align@ending} % \begin{macrocode} \def\common@align@ending { @@ -197,7 +197,7 @@ } % \end{macrocode} % -% And register these environments for the math grabbing. +% And register these environments for the math grabbing. % \begin{macrocode} \math_register_halign_env:nn {align}{} \math_register_halign_env:nn {align*}{} @@ -210,7 +210,7 @@ \math_register_halign_env:nn {xxalignat}{} % \end{macrocode} % -% The align preamble (used in \cs{align@}) needs code for luamml +% The align preamble (used in \cs{align@}) needs code for luamml % to save the cells. % \begin{macro}{\align@preamble} % \begin{macrocode} @@ -221,12 +221,12 @@ { \@lign $ - \m@th\displaystyle{##} + \m@th\displaystyle{##} \ifmeasuring@ \luamml_ignore: \else \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd} } - \fi + \fi $ }% \ifmeasuring@ @@ -240,7 +240,7 @@ { \@lign $ - \m@th\displaystyle{{}##} + \m@th\displaystyle{{}##} \ifmeasuring@ \luamml_ignore: \else @@ -280,7 +280,7 @@ } % \end{macrocode} % \end{macro} -% +% % \subsubsection{\texttt{gather} and \texttt{gather*}} % % \begin{macro}{\gather@} @@ -316,7 +316,7 @@ } % \end{macrocode} % \end{macro} -% +% % \begin{macro}{\endgather} % \begin{macrocode} \def\endgather{ @@ -326,13 +326,13 @@ \egroup $$ \ignorespacesafterend -} +} % \end{macrocode} % \end{macro} % -% The original definition of \texttt{gather*} uses \cs{endgather} +% The original definition of \texttt{gather*} uses \cs{endgather} % but this redirection doesn't work if we alter \texttt{gather} so we use -% the real meaning and add the socket. ! +% the real meaning and add the socket. % \begin{environment}{gather*} % \begin{macrocode} \renewenvironment{gather*} @@ -340,8 +340,8 @@ \start@gather\st@rredtrue } { - \math@cr - \black@\totwidth@ + \math@cr + \black@\totwidth@ \UseExpandableTaggingSocket{math/luamml/mtable/finalize} {gather} \egroup $$\ignorespacesafterend @@ -411,7 +411,7 @@ } % \end{macrocode} % \end{macro} -% +% % \begin{environment}{gathered} % \begin{macrocode} \renewenvironment{gathered}[1][c]{% @@ -457,10 +457,10 @@ % \end{macro} % % \subsubsection{multline and multline*} -% -% \texttt{multline*} needs a redefinition before it is registered as it uses -% \cs{endmultline}, this must be replaced by the true code. -% +% +% \texttt{multline*} needs a redefinition before it is registered as it uses +% \cs{endmultline}, this must be replaced by the true code. +% % \begin{environment}{multline*} % \begin{macrocode} \renewenvironment{multline*}{\start@multline\st@rredtrue} @@ -470,11 +470,11 @@ } % \end{macrocode} % \end{environment} -% +% % And now we register both % \begin{macrocode} \math_register_halign_env:nn {multline}{} -\math_register_halign_env:nn {multline*}{} +\math_register_halign_env:nn {multline*}{} % \end{macrocode} % % In the internal commands we have to add sockets for alignment attributes @@ -544,22 +544,22 @@ \fi \ifmeasuring@ \else \UseTaggingSocket{math/luamml/mtable/aligncol} {left} - \fi + \fi #1% \ifmeasuring@ \else \UseTaggingSocket{math/luamml/mtable/aligncol} {right} - \fi + \fi } % \end{macrocode} % \end{macro} -% +% % Luckily, \texttt{multline} uses \cs{endmultline@math} in exactly % the spot where we have to set the flag. % Less luckily, \cs{endmultline@math} sometimes get overwritten for the last line. % But that isn't much of a problem since we want special behavior there anyway. % \begin{macro}{\endmultline@math} % \begin{macrocode} -\def\endmultline@math +\def\endmultline@math { \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd} } $ @@ -625,7 +625,7 @@ % \end{macro} % % \subsection{Cases} -% +% % \begin{macro}{env@cases} % \begin{macrocode} \def\env@cases{% @@ -684,17 +684,17 @@ } % \end{macrocode} % \end{environment} -% +% % \subsection{The split environment} -% -% The split environment is not trivial to handle as it has a rather convoluted +% +% The split environment is not trivial to handle as it has a rather convoluted % implementation in amsmath: depending on in which display environment it is embedded % it takes different branches, which makes it difficult to finalize the mtable. -% -% The following patches work with leqno and reqno if the (default) \texttt{centertags} -% are used. +% +% The following patches work with leqno and reqno if the (default) \texttt{centertags} +% are used. % The currently fail (the structure is wrong) if the option \texttt{tbtags} is used. -% The alignment of the cells is currently not handled. +% The alignment of the cells is currently not handled. % A simple debug command until everything is sorted. % \begin{macro}{\__math_split_debug_typeout:n} % \begin{macrocode} @@ -714,12 +714,12 @@ \renewenvironment{split}{% \__math_split_debug_typeout:n {begin~split} \if@display - \ifinner + \ifinner \@xp\@xp\@xp\split@aligned - \else + \else \ifst@rred \else \global\@eqnswtrue \fi \fi - \else + \else \let\endsplit\@empty \@xp\collect@body\@xp\split@err \fi \collect@body\gather@split @@ -727,14 +727,14 @@ \crcr \UseExpandableTaggingSocket{math/luamml/mtable/innertable/save}% \egroup - \egroup + \egroup \iftagsleft@ \@xp\lendsplit@ \else \@xp\rendsplit@ \fi } % \end{macrocode} % \end{environment} % % In \cs{gather@split} we have to add the finalization socket. -% We also set the boolean to true so that we can detect if +% We also set the boolean to true so that we can detect if % the finalization has already happened. Perhaps this % could be done in the luamml code instead? % \begin{macro}{\gather@split} @@ -758,11 +758,11 @@ \def\endmathdisplay@a{% \__math_split_debug_typeout:n{endmathdisplay@a} \__math_split_debug_typeout:n{finalize~innertable~endmathdisplay@a} - \math@cr - \black@ \totwidth@ + \math@cr + \black@ \totwidth@ \egroup \egroup - \UseExpandableTaggingSocket{math/luamml/mtable/innertable/finalize}% + \UseExpandableTaggingSocket{math/luamml/mtable/innertable/finalize}% }% } % \end{macrocode} @@ -771,19 +771,19 @@ % \begin{macro}{\insplit@} % In \cs{insplit@} we have to add the sockets which store the cell content. % \begin{macrocode} -\def\insplit@{\__math_split_debug_typeout:n{insplit@}% +\def\insplit@{\__math_split_debug_typeout:n{insplit@}% \global\setbox\z@\vbox\bgroup \Let@ \chardef\dspbrk@context\@ne \restore@math@cr \default@tag % disallow use of \tag here \ialign\bgroup \hfil \strut@ - $\m@th\displaystyle {##}% - \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd} }% - $% + $\m@th\displaystyle {##}% + \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd} }% + $% \UseTaggingSocket{math/luamml/mtable/finalizecol}{last}% &$\m@th\displaystyle {{}##}% - \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd} }% + \UseTaggingSocket{math/luamml/save/nNn}{ {} \displaystyle {mtd} }% $% \UseTaggingSocket{math/luamml/mtable/finalizecol}{last}% \hfill % Why not \hfil?---dmj, 1994/12/28 @@ -793,7 +793,7 @@ % \end{macro} % And now the difficult part. Depending on the options leqno/reqno \cs{lendsplit@} % or \cs{rendsplit@} are used for the typesetting and the inner table must -% be finalized here in case this hasn't happen yet. This must be tested with the +% be finalized here in case this hasn't happen yet. This must be tested with the % boolean from \cs{gather@split} % \begin{macrocode} \def\lendsplit@{% @@ -811,22 +811,22 @@ \global\setbox\thr@@\lastbox }% \__math_split_debug_typeout:n{lendsplit@/aligncase} - \ifctagsplit@ - \__math_split_debug_typeout:n{lendsplit@/aligncase/centertags} + \ifctagsplit@ + \__math_split_debug_typeout:n{lendsplit@/aligncase/centertags} \gdef\split@{% \hbox to\wd\thr@@{}% - &\vcenter{\vbox{\moveleft\wd\thr@@\box9}}% + &\vcenter{\vbox{\moveleft\wd\thr@@\box9}}% \__math_split_debug_typeout:n{finalize~innertable~aligncase} - \UseTaggingSocket{math/luamml/mtable/innertable/finalize}% + \UseTaggingSocket{math/luamml/mtable/innertable/finalize}% }% \else %TODO, not correct yet. - \__math_split_debug_typeout:n{lendsplit@/aligncase/tbtags} + \__math_split_debug_typeout:n{lendsplit@/aligncase/tbtags} \gdef\split@{% \hbox to\wd\thr@@{}% - &\vbox{\moveleft\wd\thr@@\box9}% + &\vbox{\moveleft\wd\thr@@\box9}% \__math_split_debug_typeout:n{finalize~innertable~aligncase} - \UseTaggingSocket{math/luamml/mtable/innertable/finalize}% + \UseTaggingSocket{math/luamml/mtable/innertable/finalize}% }% \fi \else @@ -838,7 +838,7 @@ { \__math_split_debug_typeout:n{lendsplit/equationcase/centertags} \gdef\split@% - {\UseTaggingSocket{math/luamml/annotate/false}{}{\vcenter{\box9}}} + {\UseTaggingSocket{math/luamml/annotate/false}{}{\vcenter{\box9}}} } { \__math_split_debug_typeout:n {lendsplit/gathercase/centertags} @@ -852,26 +852,26 @@ { \__math_split_debug_typeout:n {lendsplit/equationcase/tbtags} \gdef\split@% - {\UseTaggingSocket{math/luamml/annotate/false}{}{\box9}} - } + {\UseTaggingSocket{math/luamml/annotate/false}{}{\box9}} + } { \__math_split_debug_typeout:n {lendsplit/gathercase/tbtags} \gdef\split@{ - \box9% + \box9% \__math_split_debug_typeout:n {finalize~innertable~gathercase} \UseTaggingSocket{math/luamml/mtable/innertable/finalize}} } - \fi + \fi \fi \aftergroup\split@ } % \end{macrocode} -% +% % \begin{macro}{\rendsplit@} % And more or less the same for the \cs{rendsplit@} environment. % \begin{macrocode} \def\rendsplit@{% - \ifinalign@ + \ifinalign@ \global\setbox9 \vtop{% \unvcopy\z@ \global\setbox8 \lastbox @@ -884,15 +884,15 @@ \unskip \global\setbox\thr@@\lastbox }% - \ifctagsplit@ + \ifctagsplit@ \gdef\split@{% \hbox to\wd\thr@@{} &\vcenter{\vbox{\moveleft\wd\thr@@\boxz@}}% - \__math_split_debug_typeout:n {rendsplit/aligncase/centertags} - \__math_split_debug_typeout:n {finalize~innertable~aligncase} - \UseTaggingSocket{math/luamml/mtable/innertable/finalize} + \__math_split_debug_typeout:n {rendsplit/aligncase/centertags} + \__math_split_debug_typeout:n {finalize~innertable~aligncase} + \UseTaggingSocket{math/luamml/mtable/innertable/finalize} }% - \else + \else \__math_split_debug_typeout:n{rendsplit@/aligncase/tbtags} %TODO tbtags is not correct yet \global\setbox7 \hbox{\unhbox\tw@\unskip}% @@ -905,29 +905,29 @@ \crcr \noalign{\global\lineht@\z@}% \add@amps\@tempcnta - \UseTaggingSocket{math/luamml/annotate/false}{}{\box\thr@@} + \UseTaggingSocket{math/luamml/annotate/false}{}{\box\thr@@} &\box7 \__math_split_debug_typeout:n {finalize~innertable~aligncase} - \UseTaggingSocket{math/luamml/mtable/innertable/finalize}% + \UseTaggingSocket{math/luamml/mtable/innertable/finalize}% }% \fi % \end{macrocode} % and again the if we are not in align we need to test for \cs{gathersplit} % \begin{macrocode} - \else - \ifctagsplit@ + \else + \ifctagsplit@ \bool_if:NTF \l__math_gathersplit_bool { \__math_split_debug_typeout:n {rendsplit/equationcase/centertags} \gdef\split@% - {\UseTaggingSocket{math/luamml/annotate/false}{}{\vcenter{\boxz@}}} + {\UseTaggingSocket{math/luamml/annotate/false}{}{\vcenter{\boxz@}}} } { \__math_split_debug_typeout:n {rendsplit/gathercase/centertags} - \gdef\split@{\vcenter{\boxz@}% + \gdef\split@{\vcenter{\boxz@}% \__math_split_debug_typeout:n {finalize~innertable~gathercase} \UseTaggingSocket{math/luamml/mtable/innertable/finalize}} - } + } \else \bool_if:NTF \l__math_gathersplit_bool { @@ -950,7 +950,7 @@ % \subsection{\cs{intertext}} % The \cs{intertext} command errors with active tagging as it is processed twice % which leads to duplicated structures. -% +% % \begin{macro}{\intertext@} % TODO: review and add sockets! % \begin{macrocode} @@ -991,7 +991,7 @@ \tag_mc_begin_pop:n{}}% \penalty\predisplaypenalty\vskip\abovedisplayskip% }% -}} +}} % \end{macrocode} % \end{macro} % @@ -1000,7 +1000,7 @@ % The \cs{text} command uses \cs{mathchoice} which \enquote{typesets} the argument % four times. This makes it quite problematic for tagging. Without precautions % structure objects would be created four times and would get MC-chunks as kids -% that doesn't really exist. amsmath contains a switch that allows to execute code +% that don't really exist. amsmath contains a switch that allows to execute code % only in the first (displaymath) branch, but that isn't usable here. At first because % we don't know if the first branch creates the same structure as the one that is % actually used. At second because the engines executes some commands like \cs{label} diff --git a/required/latex-lab/latex-lab-math.dtx b/required/latex-lab/latex-lab-math.dtx index 9d4fbdd30..8b2f619b4 100644 --- a/required/latex-lab/latex-lab-math.dtx +++ b/required/latex-lab/latex-lab-math.dtx @@ -81,8 +81,8 @@ % \car*{Todo: update all the documentation! Both here and % (what little there is!) in the implementation section.} % -% Tagging math involves a variety of tasks that require that -% math is captured before the typesetting +% Tagging math involves a variety of tasks that require that +% math is captured before the typesetting: % \begin{itemize} % \item When typesetting the math MC-tags and structure commands must % be inserted at the begin and the end, and perhaps also around lines @@ -151,7 +151,7 @@ % but it requires that the font supports the chars, which is not the case % for various OpenType fonts.) % Additional tagging inside the math should be not needed. -% If the symbols needs an actualtext then a Span can be added around the whole thing. +% If the symbols need an actualtext then a Span can be added around the whole material. % % \end{itemize} % @@ -166,7 +166,11 @@ % The first two are new commands. |\m@th| is a standard \LaTeX\ command % used in a number of places to set |\mathsurround| to zero; % with active tagging it is also used to identify math -% that should not be tagged. Details are described below. +% that should not be tagged, because it has traditionally be used in exactly +% the places where math mode is used for its layout charactistics and not for +% representing a formula.\footnote{This way even code that is not adjusted up +% for tagging is handled correctly if it uses \cs{m@th}.}. +% Details are described below. % (|\SuspendTagging| is documented in source2e.pdf.) % % To set |\mathsurround| without disabling math tagging, use |\mathsurround\z@| directly. @@ -250,7 +254,7 @@ % |\vcenter| (and is used in array.sty for the tabular code). % % \section{Math capture interfaces} -% +% % \subsection{Code level interfaces} % % \begin{function}{\math_register_env:n, \math_register_env:nn} @@ -462,9 +466,9 @@ % % \subsection{Automatic mathml creation with luamml}\label{sec:luamml} % -% If lualatex and the package \pkg{unicode-math} is used -% the package \texttt{luamml} is loaded and -% will automatically generate the file |\jobname-luamml-mathml.html| +% If lualatex and the package \pkg{unicode-math} is used, +% the package \texttt{luamml} is loaded and this package +% will then automatically generate the file |\jobname-luamml-mathml.html| % with mathml representations of all math formulas. % This file is then used in subsequent compilations and works also with % pdflatex. @@ -581,7 +585,7 @@ % \item[reading and embedding] % By default the code will read and embed % mathml from |\jobname-mathml.html| and |\jobname-luamml-mathml.html| in this order and -% the first fragment with a new hash value will be inserted.% +% the first fragment with a new hash value will be inserted. % The list of sources and their order can be changed with the key % |math/mathml/sources|, setting that to an empty value suppresses % the loading mathml associated files completely. For efficiency reasons @@ -597,7 +601,7 @@ % equations with the same source and so the same hash % can have different mathml representation, e.g., % if there are references or commands or counters in the equation. This -% will change in a feature version. +% will change in a future version. % The attachment can be suppressed locally with |math/mathml/AF=false|. % The mathml fragment will still be embedded in the PDF! % @@ -656,13 +660,13 @@ % % \item Begin and end of the math or math environment can not be hidden in commands. % For example \verb+>{$}l<{$}+ in a tabular would lead to errors. Therefore -% in a tabular a slower token-by-token grabbing is used. +% in a tabular a slower token-by-token grabbing is used. % \end{enumerate} % % \subsection{Fake math} -% For the current state see \ref{sec:nocapture} above. The text here is mainly -% kept for history. -% +% For the current state see \ref{sec:nocapture} above. The text here is mainly +% kept for history. +% % In a number of places in \LaTeX{} math commands (mainly |$|) is used % only for technical reason, e.g., to access a math font, to setup a symbol % or to use \cs{vcenter}. @@ -1168,7 +1172,7 @@ { % \end{macrocode} % We check here if the current group level is equal to the one stored for the -% outer math. If not we add currently only add text to change the hash. +% outer math. If not, we add currently a suffix to change the hash. % \changes{0.6k}{2024-12-04}{Test for current group level} % \begin{macrocode} \int_compare:nNnF @@ -1647,7 +1651,7 @@ % \end{macrocode} % \end{plugdecl} % -% \subsubsection{Sockets for tags (labels)} +% \subsubsection{Sockets plugs for tags (labels)} % \begin{socketdecl} % { % tagsupport/math/display/tag/begin, @@ -2697,14 +2701,14 @@ % % Tabulars currently contain a \$ that shouldn't trigger math % tagging. Also we do need to change the grabbing method to the slow -% loop-method. +% loop-method. % \begin{macrocode} \RequirePackage{array} \tl_if_exist:NT\@kernel@tabular@init { \tl_put_right:Nn\@kernel@tabular@init {\cs_set_protected:Npn \@@_grab_dollar:w { \@@_grab_dollar_loop: }} - } + } % \end{macrocode} % % \begin{macro}{\@@_m@th:, \m@th}