summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/math-pln.mkxl
blob: fa44fda2cec660f83df54c70a2710eba65d657c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
%D \module
%D   [       file=math-pln,
%D        version=2001.11.16,
%D          title=\CONTEXT\ Math Macros,
%D       subtitle=Plain Helpers,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D Here we collect some Plain \TEX\ leftovers.

\writestatus{loading}{ConTeXt Math Macros / Plain Helpers}

\unprotect

% We need proper unicode:

\def\relbar{\mathrel{\smash-}} % - has the same height as + .. no clue what this refers to

%D This might change:

\permanent\protected\def\hrulefill{\leaders\hrule\hfill}
%permanent\protected\def\dotfill  {\cleaders\hbox{\normalstartimath\mathsurround\zeropoint\mkern1.5mu.\mkern1.5mu\normalstopimath}\hfill}

%D These need an update:

\permanent\protected\def\bmod
  {\nonscript
   \mskip-\medmuskip
   \mkern5mu
   \mfunction{mod}%
   \penalty900
   \mkern5mu
   \nonscript
   \mskip-\medmuskip}

\permanent\protected\def\pmod#1%
  {\allowbreak
   \mkern18mu
   (\mfunction{mod}\mskip\medmuskip#1)}

%D This comes from plain but I gave it a \CONTEXT\ touch. When Mikael and I are in
%D the mood we will redo them in a more modern way.

\permanent\def\math_border_NC_indeed
  {\enforced\global\def\math_border_NC{\aligntab}}

\aliased\let\math_border_NC\math_border_NC_indeed

\permanent\def\math_border_NR
  {\enforced\global\let\math_border_NC\math_border_NC_indeed
   \cr}

\protected\def\math_border_matrix#1#2#3% adapted plain
  {\begingroup
   %
   \setbox\scratchbox\hbox\bgroup
     \mr B%
   \egroup
   \scratchdimenone\wd\scratchbox
   %
   \scratchdimentwo.2\bodyfontsize
   %
   \mathsurround\zeropoint
   %
   \enforced\def\NC{\math_border_NC}%
   \enforced\def\NR{\math_border_NR}%
   %
   \gdef\m_math_border_matrix
     {\kern\scratchdimentwo
      \glet\m_math_border_matrix\relax}%
   %
   \setbox\scratchboxone\vbox\bgroup
     \everycr{\noalign\bgroup\m_math_border_matrix\egroup}%
     \tabskip \zeroskip
     \halign{% \ialign resets everycr
       \startimath\alignmark\alignmark\stopimath
       \hfil
       \kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
       \aligntab
       \thinspace
       \hfil
       \startimath\alignmark\alignmark\stopimath
       \hfil
       \aligntab
       \aligntab
       \quad
       \hfil
       \startimath\alignmark\alignmark\stopimath
       \hfil
       \crcr
       \omit
       \strut
       \hfil
       \crcr
       \noalign{\kern-\baselineskip}%
       #3\crcr
       \omit
       \strut
       \cr}%
   \egroup
   \setbox\scratchboxtwo\vbox\bgroup
     \unvcopy\scratchboxone
     \global\setbox\globalscratchbox\lastbox
   \egroup
   \setbox\scratchboxtwo\hbox\bgroup
     \unhbox\globalscratchbox
     \unskip
     \global\setbox\globalscratchbox\lastbox
   \egroup
   \setbox\scratchboxtwo\hbox\bgroup
     \startimath
     \kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
     \left#1\relax
     \kern-\wd\globalscratchbox
     \global\setbox\globalscratchbox\vbox\bgroup
       \box\globalscratchbox
       \kern\scratchdimentwo
     \egroup
     \vcenter\bgroup
       \kern-\ht\globalscratchbox
       \unvbox\scratchboxone
       \kern-\baselineskip
     \egroup
     \thinspace
     \right#2\relax
     \stopimath
   \egroup
   \null
   \thickspace
   \vbox\bgroup
     \kern\ht\globalscratchbox
     \box\scratchboxtwo
   \egroup
   %
   \endgroup}

\permanent\protected\def\bordermatrix {\math_border_matrix()}
\permanent\protected\def\bbordermatrix{\math_border_matrix[]}

\permanent\protected\def\startbordermatrix #1\stopbordermatrix {\math_border_matrix(){#1}}
\permanent\protected\def\startbbordermatrix#1\stopbbordermatrix{\math_border_matrix[]{#1}}

\permanent\let\stopbordermatrix \relax
\permanent\let\stopbbordermatrix\relax

\protect \endinput