diff options
Diffstat (limited to 'tex/context/base/mkxl/strc-mat.mkxl')
-rw-r--r-- | tex/context/base/mkxl/strc-mat.mkxl | 366 |
1 files changed, 141 insertions, 225 deletions
diff --git a/tex/context/base/mkxl/strc-mat.mkxl b/tex/context/base/mkxl/strc-mat.mkxl index 3c6772dc0..b8d05fb33 100644 --- a/tex/context/base/mkxl/strc-mat.mkxl +++ b/tex/context/base/mkxl/strc-mat.mkxl @@ -29,7 +29,6 @@ %\c!numberstyle=, %\c!numbercolor=, %\c!numbercommand=, - %\c!margin=, %\c!align=, %\c!separator=, % \c!splitmethod=\v!both, % first|last|both|<empty> @@ -44,12 +43,16 @@ \c!spaceafter=\formulaparameter\c!spacebefore, \c!spaceinbetween=\v!quarterline, \c!width=\hsize, - \c!leftmargin=\zeropoint, - \c!rightmargin=\zeropoint, + \c!margin=\zeropoint, + \c!leftmargin=\formulaparameter\c!margin, + \c!rightmargin=\formulaparameter\c!margin, \c!indentnext=\v!no, \c!alternative=\s!default, \c!strut=\v!yes, % per 2022-04, was \v!no \c!numberstrut=\v!yes, % \v!no \v!yes \v!always + \c!margindistance=\zeropoint, + \c!leftmargindistance=\formulaparameter\c!margindistance, + \c!rightmargindistance=\formulaparameter\c!margindistance, \c!numberthreshold=\emwidth, \c!numberdistance=2\emwidth] @@ -341,6 +344,15 @@ {\begingroup \rm % determines the distance and main font \edef\p_location{\formulaparameter\c!location}% + \ifx\p_location\v!atrightmargin + \ifzeropt\s_strc_formulas_margin_right + \let\p_location\v!right + \fi + \orelse\ifx\p_location\v!atleftmargin + \ifzeropt\s_strc_formulas_margin_left + \let\p_location\v!left + \fi + \fi \strc_formulas_show_references \ifx\p_location\v!right \strc_formulas_add_distance\plusone\v!left\formulaparameter @@ -485,26 +497,6 @@ \theformuladestinationattribute\currentnestedformulaattribute \fi} -% \def\strc_formulas_handle_numbering_indeed -% {\ifempty\namedformulaentry -% \doifelsetext\currentnestedformulasuffix -% {\strc_counters_increment\v!formula -% \ifcstok{+}\currentnestedformulasuffix -% \strc_counters_increment_sub\v!formula\plustwo -% \else -% \strc_counters_setown_sub\v!formula\plustwo\currentnestedformulasuffix -% \fi}% -% {\ifempty\currentplaceformulasuffix\else -% \let\currentnestedformulasuffix \currentplaceformulasuffix -% \let\currentnestedformulareference\currentplaceformulareference -% \strc_formulas_place_number_nested_check -% \fi -% \strc_counters_increment\v!formula}% -% \fi -% \glettonothing\currentplaceformulasuffix -% \glettonothing\currentnestedformulasuffix -% \placecurrentformulanumber} - \def\strc_formulas_handle_numbering_indeed {\ifempty\namedformulaentry \doifelsetext\currentnestedformulasuffix @@ -701,6 +693,7 @@ \newconditional\c_strc_formulas_packed \newconditional\c_strc_formulas_depth \newbox \b_strc_formulas_number +\newdimen \d_strc_formulas_number \def\strc_formulas_display_space_before_normal {% not ok, try \stopformula\par\startformula vs \stopformula\startformula @@ -857,7 +850,7 @@ \scratchdimentwo \ifconditional\c_strc_formulas_tight\formulaparameter\c!numberthreshold\else\zeropoint\fi\relax \scratchdimenthree.5\exheight \ifcase\scratchdimentwo\else\ifx#2\v!left - \middlered + \darkred \kern-\scratchdimentwo \vrule \s!height\scratchdimenthree @@ -865,14 +858,14 @@ \s!width \scratchdimentwo \fi\fi \ifcase\scratchdimenone\else - \ifcase#1\or\middlegreen\else\middleblue\fi + \ifcase#1\or\darkgreen\else\darkblue\fi \vrule \s!height\scratchdimenthree \s!depth \scratchdimenthree \s!width \scratchdimenone \fi \ifcase\scratchdimentwo\else\ifx#2\v!right - \middlered + \darkred \vrule \s!height\scratchdimenthree \s!depth \scratchdimenthree @@ -960,11 +953,6 @@ \global\c_strc_math_split_mode\c_strc_math_flow_mode \fi \mathpenaltiesmode\plusone - \ifnum\c_strc_math_split_mode=\c_strc_math_line_mode - \global\setfalse\c_strc_math_indent - \else - \global\settrue\c_strc_math_indent % otherwise no breaks - \fi \global\d_strc_math_indent\zeropoint} \def\strc_math_set_number_location @@ -1035,26 +1023,6 @@ \boundary\c_bndr_mathalign \fi} -% \tolerant\protected\def\strc_math_skip_here[#1]% -% {% no strut as it will influence fences -% \ifconditional\c_strc_math_trace_hang -% \strc_math_trace_okay{darkblue}{S #1}% -% \fi -% \scratchdimen\dimexpr\formulaparameter\c!textmargin\relax -% \ifchkdim#1\or -% \d_strc_math_hang_state#1% -% \orelse\ifchknum#1\or -% \d_strc_math_hang_state#1\scratchdimen -% \orelse\iftok{#1}{+}% -% \advanceby\d_strc_math_hang_state\scratchdimen -% \orelse\iftok{#1}{-}% -% \advanceby\d_strc_math_hang_state-\scratchdimen -% \else -% \d_strc_math_hang_state\scratchdimen -% \fi -% \kern\d_strc_math_hang_state -% \strc_math_pickup_again} - \newboundary\c_bndr_skiphere \tolerant\protected\def\strc_math_skip_here[#1]% @@ -1091,49 +1059,6 @@ % % \blank[line] \ruledhbox{zzzz} \blank[line] -% \tolerant\protected\def\strc_math_text_here[#1]#:#*#=% -% {\ifparameter#2\or -% \ifnum\lastboundary=\c_math_begin_boundary\else -% \ifcstok{#1}\v!right\else -% \strc_math_break_here -% \fi -% \fi -% \vadjust -% \ifcstok{#1}\v!before -% pre -% \orelse\ifcstok{#1}\v!left -% pre -% baseline -% depth before -\thousandpoint -% \orelse\ifcstok{#1}\v!right -% post -% baseline -% \fi -% \bgroup -% \hbox to \displaywidth \bgroup -% \strut -% \ifcstok{#1}\v!right -% \hfill#2% -% \else -% #2\hss -% \fi -% \strut -% \egroup -% \egroup -% \ifcstok{#1}\v!right -% \strc_math_break_here -% \else -% % \mathatom class \mathexplicitcode{}% -% \strc_math_pickup_again -% \fi -% \orelse\ifcstok{#1}\v!page -% \strc_math_page_here -% \orelse\ifcstok{#1}\v!samepage -% \strc_math_same_here -% \else -% \strc_math_break_here -% \fi} - \definelocalboxes [\v!lefttext] [\c!command=\localmarginlefttext\zeropoint, @@ -1152,10 +1077,10 @@ \installcorenamespace{mathbreakhere} \def\strc_math_text_here_right#1% - {\localbox[\v!righttext]{\llap{#1\kern\leftskip}}} + {\localbox[\v!righttext]{\llap{#1\kern\rightskip}}} \def\strc_math_text_here_left#1% - {\localbox[\v!lefttext]{\rlap{\kern\rightskip#1}}} + {\localbox[\v!lefttext]{\rlap{\kern\leftskip#1}}} \def\strc_math_text_here_before#1% {\vadjust pre \bgroup @@ -1285,7 +1210,7 @@ \newconstant\c_strc_math_split_status \prependtoks - \c_strc_math_ragged_status\plustwo + \c_strc_math_ragged_status\plustwo % middle \c_strc_math_split_status \zerocount \to \everymathematics @@ -1298,29 +1223,31 @@ {\raggedright \mathgluemode\plustwo \c_strc_math_ragged_status\plusone + \setfalse\c_strc_math_number_swapped \updateparagraphproperties} % not needed \defcsname\??mathtextalign\v!middle\endcsname {\raggedcenter \mathgluemode\plustwo \c_strc_math_ragged_status\plustwo + \setfalse\c_strc_math_number_swapped \updateparagraphproperties} % not needed \defcsname\??mathtextalign\v!flushright\endcsname {\raggedleft \mathgluemode\plustwo \c_strc_math_ragged_status\plusthree + \setfalse\c_strc_math_number_swapped \updateparagraphproperties} % not needed -\defcsname\??mathtextalign\v!slanted\endcsname +\defcsname\??mathtextalign\v!slanted\endcsname % maybe move bottom to number location {\raggedslanted %\mathgluemode\plustwo \c_strc_math_ragged_status\plustwo - \ifcase\c_strc_math_number_location\or - \parinitleftskip\wd\b_strc_formulas_number % should normally fit - \else - \parfillrightskip\wd\b_strc_formulas_number % should normally fit - \fi + \edef\p_distance{\formulaparameter\c!leftmargindistance}% + \parinitleftskip \ifx\p_distance\v!number \wd\b_strc_formulas_number \else \p_distance \fi + \edef\p_distance{\formulaparameter\c!rightmargindistance}% + \parfillrightskip\ifx\p_distance\v!number \wd\b_strc_formulas_number \else \p_distance \fi \updateparagraphproperties} % not needed \def\strc_math_setup_align @@ -1328,6 +1255,8 @@ \lastnamedcs\else\begincsname\??mathtextalign\v!middle\endcsname \fi} +% split : wrap (box) and flow (yes) + \defcsname\??mathtextalign\v!flushleft:\v!auto\endcsname {\raggedright \mathgluemode\plustwo @@ -1335,14 +1264,14 @@ \strc_math_analyze_box} \defcsname\??mathtextalign\v!middle:\v!auto\endcsname - {\raggedright - \mathgluemode\plustwo - \c_strc_math_ragged_status\plustwo - \strc_math_analyze_box} + {\raggedright % needed for the lua magick (stage 1) + \mathgluemode\plustwo % only shrink (otherwise inconsistent) + \c_strc_math_ragged_status\plustwo % needed for the lua magick (stage 2) + \strc_math_analyze_box} % lua magick \defcsname\??mathtextalign\v!flushright:\v!auto\endcsname {\raggedright - \mathgluemode\plustwo + \mathgluemode\plustwo % only shrink \c_strc_math_ragged_status\plusthree \strc_math_analyze_box} @@ -1391,25 +1320,30 @@ \appendtoks \global\d_strc_math_indent \zeropoint \global\c_strc_math_n_of_lines \zerocount - \global\d_strc_math_max_width \zeropoint - \global\d_strc_math_first_width \zeropoint \global\d_strc_math_first_height\zeropoint - \global\d_strc_math_last_width \zeropoint + \global\d_strc_math_first_left \zeropoint + \global\d_strc_math_first_right \zeropoint + \global\d_strc_math_last_left \zeropoint + \global\d_strc_math_last_right \zeropoint \global\d_strc_math_last_depth \zeropoint + \global\d_strc_math_max_right \zeropoint + \global\d_strc_math_max_left \zeropoint + \global\d_math_strc_hangindent \zeropoint + \global\c_math_strc_hangafter \zeropoint \to \everyresetformulas \newbox\b_strc_math_display % most code is in math-ali (for historical reasons) -\newgluespec\s_strc_formulas_margin_left -\newgluespec\s_strc_formulas_margin_right +\newgluespec\s_strc_formulas_margin_left % maybe just dimen +\newgluespec\s_strc_formulas_margin_right % idem \def\strc_formulas_set_paragraph {%\setlocalhsize %\hsize\localhsize % \d_strc_formulas_display_width\formulaparameter\c!width\relax - \s_strc_formulas_margin_left \leftskip - \s_strc_formulas_margin_right\rightskip +% \s_strc_formulas_margin_left \leftskip +% \s_strc_formulas_margin_right\rightskip \edef\p_margin{\formulaparameter\c!leftmargin}% \ifempty\p_margin \else \doadaptleftskip\p_margin @@ -1418,85 +1352,39 @@ \ifempty\p_margin \else \doadaptrightskip\p_margin \fi - \edef\p_margin{\formulaparameter\c!margin}% - \ifempty\p_margin \else - \doadaptleftskip\p_margin - \doadaptrightskip\p_margin - \fi - % this was lost +% \edef\p_margin{\formulaparameter\c!margin}% +% \ifempty\p_margin \else +% \doadaptleftskip\p_margin +% \doadaptrightskip\p_margin +% \fi + \s_strc_formulas_margin_left \leftskip + \s_strc_formulas_margin_right\rightskip \edef\p_interlinespace{\formulaparameter\c!interlinespace}% \ifempty\p_interlinespace\else\baselineskip\p_interlinespace\fi - % and is now back \global\setfalse\c_strc_math_aligned_here \hsize\d_strc_formulas_display_width \displaywidth\hsize \displayindent\zeropoint} -% \def\strc_math_analyze_box -% {\clf_handlemathhang -% stage \plusone -% alignstate \c_strc_math_ragged_status -% box \b_strc_math_display -% distance \formulaparameter\c!textdistance -% \relax -% %\holdingmigrations\zerocount -% \setbox\b_strc_math_display\vbox\bgroup % \vtop -% \ifnum\c_strc_math_split_mode=\c_strc_math_line_mode -% % we can't end up here -% \orelse\ifconditional\c_strc_math_aligned_here -% \ifzeropt\d_strc_math_indent\else -% \hangafter\plusone -% \hangindent\d_strc_math_indent -% \fi -% % \strc_math_setup_align % _inner -% \else -% \strc_math_setup_align -% \fi -% % \strc_math_setup_spacing\formulaparameter -% \strc_math_setup_penalties -% \unhbox\b_strc_math_display -% \egroup -% \clf_handlemathhang -% stage \ifconditional\c_strc_math_aligned_here \plustwo \else \plusthree \fi -% % alignstate \c_strc_math_ragged_status -% % box \b_strc_math_display -% % distance \formulaparameter\c!textdistance -% \relax -% % -% \begingroup -% \edef\v_spac_whitespace_current{\formulaparameter\c!spaceinbetween}% -% \spac_whitespace_setup -% \clf_handlemathhang -% stage \plusfour -% inbetween 1\parskip -% height \strutht -% depth \strutdp -% \relax -% \endgroup} - \def\strc_math_analyze_box {\clf_handlemathhang stage \plusone alignstate \c_strc_math_ragged_status box \b_strc_math_display distance \formulaparameter\c!textdistance + leftmargin \the\dimexpr\s_strc_formulas_margin_left\relax + rightmargin \the\dimexpr\s_strc_formulas_margin_right\relax \relax %\holdingmigrations\zerocount \setbox\b_strc_math_display\vbox\bgroup % \vtop - \ifnum\c_strc_math_split_mode=\c_strc_math_line_mode - % we can't end up here - \orelse\ifconditional\c_strc_math_aligned_here + % beware: everypar is doing sidefloats here so we then have hang values set + % but we have no local leftskip and rightskip as they are reflected in hsize + \strc_formulas_trigger_side_box + \ifconditional\c_strc_math_aligned_here \ifzeropt\d_strc_math_indent\else -% \ifnum\c_page_sides_hangafter=\zerocount -% \hangafter\plusone -% \hangindent\d_strc_math_indent -% \else - % this might become the default anyway: - \advanceby\leftskip\d_strc_math_indent - \hskip-\d_strc_math_indent -% \fi + \advanceby\leftskip\d_strc_math_indent % which is why we see a leftskip reported ! + \hskip-\d_strc_math_indent \fi - % \strc_math_setup_align % _inner \else \strc_math_setup_align \fi @@ -1523,49 +1411,34 @@ \relax \endgroup} -\def\strc_math_show_margins_there - {\vadjust pre \bgroup - \c_attr_visual\attributeunsetvalue - \hbox to \hsize \bgroup - \setbox\scratchbox\hbox to \hsize\bgroup - \bgroup\darkred \vrule \s!width\leftskip \egroup\hss - \bgroup\darkgray\leaders\vrule\hfill \egroup\hss - \bgroup\white \vrule \s!width\emwidth \egroup\hss - \bgroup\darkgray\leaders\vrule\hfill \egroup\hss - \bgroup\darkblue\vrule \s!width\rightskip\egroup - \egroup - \ht\scratchbox1.2\exheight - \dp\scratchbox0.4\exheight - \strut - \box\scratchbox - \hskip-\hsize - \hbox to \hsize \bgroup - \white - \infofont - \hskip1\leftskip - \quad - \formulaparameter\c!split - \quad - \formulaparameter\c!align - \egroup - \egroup - \egroup} - \let\strc_math_inject_show_margins_here\relax -\def\strc_math_show_margins_indeed - {\gdef\strc_math_inject_show_margins_here - {\strc_math_show_margins_there - \glet\strc_math_inject_show_margins_here\relax}% - \appendtoks\strc_math_inject_show_margins_here\to\everypar} +\integerdef\c_strc_math_positioning\zerocount + +%D For practical reasons this one is kept extern: + +\newconditional\c_strc_math_ignore_number % for testing space compatibility + +\fetchmodulecommand \showmathmargins \f!math_run \installtextracker {math.showmargins} - {\let\strc_math_show_margins\strc_math_show_margins_indeed} - {\let\strc_math_show_margins\relax} + {\def\strc_math_show_margins{\showmathmargins[\v!all]}% + \let\strc_math_flush_number_box\strc_math_flush_number_box_visual} + {\let\strc_math_show_margins\relax + \let\strc_math_flush_number_box\strc_math_flush_number_box_normal} + +\installtextracker + {math.showmargins.less} + {\def\strc_math_show_margins{\showmathmargins}% + \let\strc_math_flush_number_box\strc_math_flush_number_box_visual} + {\let\strc_math_show_margins\relax + \let\strc_math_flush_number_box\strc_math_flush_number_box_normal} \let\strc_math_show_margins\relax +%D Till here. + \def\strc_math_set_options#1% {\setfalse\c_strc_formulas_tight \setfalse\c_strc_formulas_packed @@ -1583,8 +1456,46 @@ \rawprocesscommacommand[\p_option]\strc_formulas_option \fi} +% This is an experiment! + +% \lettonothing\strc_formulas_start_side_box +% \lettonothing\strc_formulas_stop_side_box +% \lettonothing\strc_formulas_check_side_box +% \lettonothing\strc_formulas_trigger_side_box + +\newdimen\d_strc_math_side_width + +\def\strc_formulas_check_side_box + {\doifelsesidefloat + {\d_strc_math_side_width\d_page_sides_width}% + {\d_strc_math_side_width\zeropoint}} + +\def\strc_formulas_start_side_box + {\ifzeropt\d_strc_math_side_width\else + \advance\displaywidth-\d_strc_math_side_width + \ifnum\c_page_sides_checks_done<\plustwo + % see \strc_formulas_display_space_before_normal + \vkern-\strutht % quite a hack + \fi + \dontleavehmode\dbox + \fi + \bgroup} + +\def\strc_formulas_stop_side_box + {\egroup} + +\def\strc_formulas_trigger_side_box + {\ifzeropt\d_strc_math_side_width\else + \advance\hsize-\d_strc_math_side_width + \forgeteverypar + \dontleavehmode + \fi} + +% End of experiment. + \tolerant\protected\def\strc_formulas_start_formula#1#:#*[#2]% setting leftskip adaption is slow ! - {\ifhmode + {\strc_formulas_check_side_box + \ifhmode \par \fi \bgroup % HERE @@ -1853,15 +1764,20 @@ {\xdef\currentplaceformulasuffix{#1}% \strc_formulas_place_nop} -\protected\def\strc_formulas_place_nop - {\doifelsenextchar$\strc_formulas_place_pickup\strc_formulas_place_indeed} % [ref]$$ [ref]\start +%D We no longer picku p $$ as this is now equivalent to inline: -\protected\def\strc_formulas_place_indeed - {\strc_formulas_place_numbering} +% \protected\def\strc_formulas_place_nop +% {\doifelsenextchar$\strc_formulas_place_pickup\strc_formulas_place_indeed} % [ref]$$ [ref]\start +% +% \protected\def\strc_formulas_place_indeed +% {\strc_formulas_place_numbering} +% +% \protected\def\strc_formulas_place_pickup$$#1$$% +% {\strc_formulas_place_numbering +% \strc_formulas_start_formula{}#1\strc_formulas_stop_formula} -\protected\def\strc_formulas_place_pickup$$#1$$% - {\strc_formulas_place_numbering - \strc_formulas_start_formula{}#1\strc_formulas_stop_formula} +\protected\def\strc_formulas_place_nop + {\strc_formulas_place_numbering} % \let\startplaceformula\placeformula % \let\stopplaceformula \relax @@ -1984,15 +1900,15 @@ % \stopplaceformula % \stoptext +% Relaxing in the macro is really needed because otherwise we get spurious +% numbers probably due to some % interference with other local variables + \def\strc_formulas_place_number_in_box {\dostarttagged\t!formulacaption\empty - % this is really needed, otherwise we get spurious numbers probably due to some - % interference with other local variables .. also keep an eye on eqtest in the - % MS tests - \glet\strc_formulas_place_number \relax - %\glet\strc_formulas_place_number_nested\gobbletwoarguments - % + \glet\strc_formulas_place_number \relax + %\glet\strc_formulas_place_number_nested\gobbletwoarguments \global\setbox\b_strc_formulas_number\naturalhbox{\strc_formulas_number_indeed}% + \global\d_strc_formulas_number\wd\b_strc_formulas_number \dostoptagged} \let\strc_formulas_flush_number\relax |