summaryrefslogtreecommitdiff
path: root/tex/context/base/core-mat.tex
blob: ca6497481f7bc39c74148474098f5b82fe895361 (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
%D \module
%D   [       file=core-mat,
%D        version=1998.12.07,
%D          title=\CONTEXT\ Core Macros,
%D       subtitle=Math Fundsmentals,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. Non||commercial use is
%C granted.

\writestatus{loading}{Context Core Macros / Math Fundamentals}

\unprotect

%D \macros 
%D   {big..}
%D
%D Because they are related to the bodyfontsize, we redefine 
%D some \PLAIN\ macros. 

\def\@@dobig#1#2%
  {{\hbox{$\left#2\vbox\!!to#1\bodyfontsize{}\right.\n@space$}}}

\def\big {\@@dobig{0.85}}
\def\Big {\@@dobig{1.15}}
\def\bigg{\@@dobig{1.45}}
\def\Bigg{\@@dobig{1.75}}

%D \macros 
%D   {bordermatrix}
%D
%D We already redefined \type {\bordermatrix} in \type 
%D {font-ini}.

%D \macros
%D   {super, sub}
%D
%D \TEX\ uses \type{^} and \type{_} for entering super- and 
%D subscript mode. We want however a bit more control than 
%D normally provided, and therefore provide \type {\super} 
%D and \type{sub}. 

\global\let\normalsuper=^ 
\global\let\normalsub  =_ 

\newcount\supersubmode

\newevery\everysupersub \EverySuperSub

\appendtoks \advance\supersubmode by 1 \to \everysupersub

% \def\dodosuper#1{\normalsuper{\the\everysupersub#1}}
% \def\dodosub  #1{\normalsub  {\the\everysupersub#1}}
% 
% \def\dosuper{\ifx\next\bgroup\expandafter\dodosuper\else\normalsuper\fi}
% \def\dosub  {\ifx\next\bgroup\expandafter\dodosub  \else\normalsub  \fi}
% 
% \def\super  {\futurelet\next\dosuper}
% \def\sub    {\futurelet\next\dosub  }

\def\super#1{\normalsuper{\the\everysupersub#1}}
\def\sub  #1{\normalsub  {\the\everysupersub#1}}

%D \macros
%D   {enablesupersub}
%D 
%D We can let \type {^} and \type {_} act like \type {\super} 
%D and \type {\sub} by saying \type {\enablesupersub}. 

\bgroup
\catcode`\^=\@@active
\catcode`\_=\@@active
\gdef\enablesupersub%
  {\catcode`\^=\@@active
   \def^{\ifmmode\expandafter\super\else\expandafter\normalsuper\fi}%
   \catcode`\_=\@@active
   \def_{\ifmmode\expandafter\sub  \else\expandafter\normalsub  \fi}}
\egroup

%D \macro
%D   {restoremathstyle}
%D
%D We can pick up the current math style by calling \type 
%D {\restoremathstyle}.

\def\restoremathstyle%
  {\ifmmode
     \ifcase\supersubmode
       \textstyle
     \or
       \scriptstyle
     \else
       \scriptscriptstyle
     \fi
   \fi}

%D \macros
%D   {mathstyle}
%D
%D If one want to be sure that something is typeset in the 
%D appropriate style, \type {\mathstyle} can be used:
%D
%D \starttypen
%D \mathstyle{something}
%D \stoptypen

\def\mathstyle#1%
  {\mathchoice
     {\displaystyle     #1}%
     {\textstyle        #1}%
     {\scriptstyle      #1}%
     {\scriptscriptstyle#1}}

%D \macros
%D   {frac}
%D
%D This is another one Tobias asked for. It replaces the 
%D primitive \type {\over}. We also take the opportunity to 
%D handle math style restorin, which makes sure units and 
%D chemicals come out ok. 

\def\frac#1#2%
  {{{\mathstyle{#1}}\over{\mathstyle{#2}}}}

%D The next macro, \type {\ch}, is \PPCHTEX\ aware. In
%D formulas one can therefore best use \type {\ch} instead of
%D \type {\chemical}, especially in fractions. 

\ifx\mathstyle\undefined 
  \let\mathstyle\relax
\fi

\def\ch#1%
  {\ifx\@@chemicalletter\undefined
     \mathstyle{\rm#1}%
   \else
     \dosetsubscripts
     \mathstyle{\@@chemicalletter{#1}}%
     \doresetsubscripts
   \fi}

\protect

\endinput