summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/math-ali.mkiv
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2017-06-16 16:00:40 +0200
committerContext Git Mirror Bot <phg42.2a@gmail.com>2017-06-16 16:00:40 +0200
commit008292817580eba8a0f0cf83d8e2d08df8fc8c3f (patch)
tree7e47d035cc5d1f54d20f556476c439844f1956e0 /tex/context/base/mkiv/math-ali.mkiv
parent5e668aa418d6d082446e9369ae06625b50e49943 (diff)
downloadcontext-008292817580eba8a0f0cf83d8e2d08df8fc8c3f.tar.gz
2017-06-15 22:16:00
Diffstat (limited to 'tex/context/base/mkiv/math-ali.mkiv')
-rw-r--r--tex/context/base/mkiv/math-ali.mkiv166
1 files changed, 113 insertions, 53 deletions
diff --git a/tex/context/base/mkiv/math-ali.mkiv b/tex/context/base/mkiv/math-ali.mkiv
index 1333b4770..1ff72630b 100644
--- a/tex/context/base/mkiv/math-ali.mkiv
+++ b/tex/context/base/mkiv/math-ali.mkiv
@@ -267,7 +267,8 @@
%D Here we implement the user interface part. We start with basic math alignments:
-\newcount\c_math_eqalign_column
+\newcount \c_math_eqalign_column
+\newconditional\c_math_eqalign_first
\newtoks \everymathalignment
\newtoks \everymathalignmentdone
@@ -287,11 +288,20 @@
\dostoptagged % finish cell
\strc_formulas_place_number_nested{#1}{#2}%
\math_number_right_of_eqalign
+ \global\settrue\c_math_eqalign_first
\crcr
\dostoptagged} % finish row
\def\math_alignment_NC
- {\aligntab}
+ {\relax
+ \ifconditional\c_math_eqalign_first
+ \ifx\p_math_alignment_number\v!auto
+ \strc_formulas_place_number_nested{+}{}%
+ \fi
+ \global\setfalse\c_math_eqalign_first
+ \fi
+ \math_number_left_of_eqalign
+ \aligntab}
\def\math_alignment_EQ
{\NC=}
@@ -305,6 +315,7 @@
\let\NN\math_alignment_NN
\let\EQ\math_alignment_EQ
\let\NR\math_alignment_NR
+ \global\settrue\c_math_eqalign_first
\to \everymathalignment
\appendtoks
@@ -321,7 +332,7 @@
\def\math_alignment_snap_start
{\ifgridsnapping
- \snaptogrid[\v!both]\vbox\bgroup
+ \snaptogrid[\v!math]\vbox\bgroup
\fi}
\def\math_alignment_snap_stop
@@ -331,6 +342,8 @@
% end of experimental
+\newconditional\c_math_alignment_auto_number
+
\unexpanded\def\math_alignment_start#1%
{\edef\currentmathalignment{#1}%
\dosingleempty\math_alignment_start_indeed}
@@ -343,6 +356,7 @@
\fi
\the\everymathalignment
\c_math_eqalign_column\zerocount
+ \edef\p_math_alignment_number{\mathalignmentparameter\c!number}%
\processcommacommand
[\mathalignmentparameter\c!align]%
{\advance\c_math_eqalign_column\plusone\math_eqalign_set_column}% takes argument
@@ -1216,6 +1230,8 @@
\newdimen \d_strc_math_display_width
\newbox \b_strc_math_display
\newconstant \c_strc_formulas_frame_mode
+\newdimen \d_strc_math_indent
+\newconditional\c_strc_math_indent
\let\d_strc_math_framed_width\displaywidth
@@ -1230,14 +1246,32 @@
% mode: 0=no frame | 1=number inside frame | 2=number outside frame
\def\strc_math_flush_aligned
- {\ifcase\mathraggedstatus\or\hfill\or\hfill\fi
- \box\b_strc_math_display
- \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi}
+ {\ifcase\c_strc_math_vertical
+ \ifcase\mathraggedstatus\or\hfill\or\hfill\fi
+ \box\b_strc_math_display
+ \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi
+ \else
+ \ifconditional\c_strc_math_indent
+ \ifdim\d_strc_math_indent=\zeropoint\else
+ \hangafter\plusone
+ \hangindent\d_strc_math_indent
+ \fi
+ \fi
+ \edef\p_interlinespace{\formulaparameter\c!interlinespace}%
+ \ifx\p_interlinespace\empty\else\baselineskip\p_interlinespace\fi
+ \global\d_strc_math_indent\zeropoint
+ \ifcase\mathraggedstatus\or\raggedleft\or\raggedcenter\or\raggedright\fi
+ \unhbox\b_strc_math_display
+ \fi}
\def\strc_math_flush_box_normal
- {\hbox to \displaywidth\bgroup
+ {\ifcase\c_strc_math_vertical
+ \hbox to \displaywidth\bgroup
+ \strc_math_flush_aligned
+ \egroup
+ \else
\strc_math_flush_aligned
- \egroup}
+ \fi}
\def\strc_math_flush_box_framed_common
{\setformulaframedparameter\c!align{\formulaparameter\c!align}%
@@ -1466,64 +1500,80 @@
\startforceddisplaymath}
\def\strc_math_flush_number_no
- {\ifconditional\c_strc_math_display_overflow
- \ifcase\c_strc_formulas_frame_mode
- \strc_math_flush_box_normal
- \else
- \strc_math_flush_box_framed_fit_inline
- \fi
- \else
- \ifcase\c_strc_formulas_frame_mode
- %\ifconditional\c_strc_formulas_tight
- % \strc_math_flush_box_normal
- %\else
+ {\ifcase\c_strc_math_vertical
+ \ifconditional\c_strc_math_display_overflow
+ \ifcase\c_strc_formulas_frame_mode
\strc_math_flush_box_normal
- %\fi
- \else
- \ifconditional\c_strc_formulas_tight
+ \else
\strc_math_flush_box_framed_fit_inline
+ \fi
+ \else
+ \ifcase\c_strc_formulas_frame_mode
+ %\ifconditional\c_strc_formulas_tight
+ % \strc_math_flush_box_normal
+ %\else
+ \strc_math_flush_box_normal
+ %\fi
\else
- \strc_math_flush_box_framed_display
+ \ifconditional\c_strc_formulas_tight
+ \strc_math_flush_box_framed_fit_inline
+ \else
+ \strc_math_flush_box_framed_display
+ \fi
\fi
\fi
+ \else
+ \strc_math_flush_box
\fi}
\def\strc_math_flush_number_left
- {\ifconditional\c_strc_math_display_overflow
- \ifcase\c_strc_formulas_frame_mode
- \strc_math_number_left_overflow
- \or
- \strc_math_number_left_overflow_outside
- \or
- \strc_math_number_left_overflow_inside
+ {\ifcase\c_strc_math_vertical
+ \ifconditional\c_strc_math_display_overflow
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_left_overflow
+ \or
+ \strc_math_number_left_overflow_outside
+ \or
+ \strc_math_number_left_overflow_inside
+ \fi
+ \else
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_left_normal
+ \or
+ \strc_math_number_left_normal_outside
+ \or
+ \strc_math_number_left_normal_inside
+ \fi
\fi
\else
- \ifcase\c_strc_formulas_frame_mode
- \strc_math_number_left_normal
- \or
- \strc_math_number_left_normal_outside
- \or
- \strc_math_number_left_normal_inside
- \fi
+ \box\b_strc_formulas_number
+ \hfill
+ \strc_math_flush_aligned
\fi}
\def\strc_math_flush_number_right
- {\ifconditional\c_strc_math_display_overflow
- \ifcase\c_strc_formulas_frame_mode
- \strc_math_number_right_overflow
- \or
- \strc_math_number_right_overflow_outside
- \or
- \strc_math_number_right_overflow_inside
+ {\ifcase\c_strc_math_vertical
+ \ifconditional\c_strc_math_display_overflow
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_right_overflow
+ \or
+ \strc_math_number_right_overflow_outside
+ \or
+ \strc_math_number_right_overflow_inside
+ \fi
+ \else
+ \ifcase\c_strc_formulas_frame_mode
+ \strc_math_number_right_normal
+ \or
+ \strc_math_number_right_normal_outside
+ \or
+ \strc_math_number_right_normal_inside
+ \fi
\fi
\else
- \ifcase\c_strc_formulas_frame_mode
- \strc_math_number_right_normal
- \or
- \strc_math_number_right_normal_outside
- \or
- \strc_math_number_right_normal_inside
- \fi
+ \strc_math_flush_aligned
+ \hfill
+ \box\b_strc_formulas_number
\fi}
\unexpanded\def\strc_math_box_stop
@@ -1560,7 +1610,13 @@
\noindent % \noindentation % not \dontleavehmode
\hskip\d_strc_formulas_display_margin_left % was kern but that doesn't indent
\strc_math_traced_state
- \hbox to \displaywidth \bgroup
+ \ifcase\c_strc_math_vertical
+ \hbox to \displaywidth \bgroup
+ \or
+ \vbox \bgroup \hsize\displaywidth
+ \or
+ \bgroup \hsize\displaywidth
+ \fi
\ifcase\mathnumberstatus
\strc_math_flush_box
\or % status 1
@@ -1586,7 +1642,11 @@
\else
\strc_math_flush_box
\fi
- % \egroup
+ \ifcase\c_strc_math_vertical
+ \or
+ \or
+ \par
+ \fi
\egroup}
\defineinnermathhandler\v!left {\strc_math_box_start\plusone }{\strc_math_box_stop}