summaryrefslogtreecommitdiff
path: root/tex/context/base/mkxl/pack-mat.mkxl
blob: c0aa1cc9473cf9408217fcccfc7a237f39c3a941 (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
%D \module
%D   [       file=pack-rul, % was core-rul,
%D        version=2022.02.23,
%D          title=\CONTEXT\ Packaging Macros,
%D       subtitle=Ruled Math,
%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.

\writestatus{loading}{ConTeXt Packaging Macros / Ruled Math}

%D This is a by product of the math improvement activity by Mikael Sundqvist and
%D myself. More might end up here and more control might be added.

\unprotect

\newconditional \c_framed_math_framed

\installtextracker
  {framed.math}
  {\settrue \c_framed_math_framed}
  {\setfalse\c_framed_math_framed}

\tolerant\protected\def\mathframed[#1]#:#2%
  {\begingroup
   \ifconditional\c_framed_math_framed
     \defineboxanchor[temp]%
   \fi
   \setmathatomrule\mathbegincode\mathbincode\allmathstyles\mathbegincode\mathbincode
   \normalexpanded
     {\setbox\scratchbox\hpack
        \ifconditional\c_framed_math_framed
          \s!source \namedboxanchor{temp}
        \fi
        \s!ymove \Umathaxis\Ustyle\mathstyle
        \bgroup
          \framed
            [\c!location=\v!middle,#1]
            {\startimath
             \Ustyle\mathstyle
             #2%
             \stopimath}%
        \egroup}%
   \scratchcounterone\lastleftclass
   \scratchcountertwo\lastrightclass
 % \writestatus{!!}{[\number\lastleftclass,\number\lastrightclass]}%
   \mathatom
     \s!class \mathexplicitcode
     \ifnum\scratchcounterone<\zerocount\else\s!leftclass \scratchcounterone\fi
     \ifnum\scratchcountertwo<\zerocount\else\s!rightclass\scratchcountertwo\fi
     \bgroup
       \ifconditional\c_framed_math_framed
         \setboxanchor[temp][\c!corner={\v!left,\v!bottom},\c!location={\v!right,\v!height}]
           \hpack{\smallinfofont \the\scratchcounterone}%
         \setboxanchor[temp][\c!corner={\v!right,\v!bottom},\c!location={\v!left,\v!height}]
           \hpack{\smallinfofont \the\scratchcountertwo}%
       \fi
       \box\scratchbox
     \egroup
   \endgroup}

%D \starttyping
%D \enabletrackers[framed.math]
%D
%D \startTEXpage[offset=10pt,width=40dk]
%D     \showmakeup[mathglue]
%D     \def\MyTest#1%
%D       {$              x #1                          x $\quad
%D        $              x \mathframed[offset=0pt]{#1} x $\quad
%D        $\displaystyle x #1                          x $\quad
%D        $\displaystyle x \mathframed[offset=0pt]{#1} x $}
%D     \MyTest{>}\blank
%D     \MyTest{+}\blank
%D     \MyTest{!}\blank
%D     \MyTest{+\frac{1}{2}+}\blank
%D     \MyTest{\frac{1}{2}}\blank
%D \stopTEXpage
%D \stoptyping

\protect