summaryrefslogtreecommitdiff
path: root/tex/context/base/math-int.mkiv
blob: 6b65738ff2ea25d61e3f535dc59547f8be941056 (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
%D \module
%D   [       file=math-int,
%D        version=2007.07.19,
%D          title=\CONTEXT\ Math Macros,
%D       subtitle=Scripts,
%D         author={Hans Hagen \& Taco Hoekwater \& Aditya Mahajan},
%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 Math Macros / Integrals}

% todo: int and sum etc can be stackers

\unprotect

%D \startbuffer
%D   $\int    _a^b f(x)   dx  $ and also
%D   $\iint   _a^b f(x,y) dxdy$,
%D   $\iiint  _a^b f(x,y) dxdy$,
%D   \startformula
%D     \int    _a^b f(x) dx \quad
%D     \iint   _a^b f(x) dx \quad
%D     \iiint  _a^b f(x) dx \quad
%D   \stopformula
%D \stopbuffer
%D
%D Default: \getbuffer
%D
%D Displaylimits: \setupmathematics[integral=displaylimits] \getbuffer
%D
%D Limits: \setupmathematics[integral=limits] \getbuffer

%D Adapted to mkiv by HH from code by AM.

\installcorenamespace{mathintegral}

\newconstant\mathintlimitmode

\def\intlimits % also used elsewhere
  {\ifcase\mathintlimitmode
     \nolimits
   \or
     \displaylimits
   \or
     \limits
   \or
     % auto
     \ifcase\normalmathstyle\displaylimits\or\displaylimits\else\limits\fi
   % \ifnum\attribute\mathmodeattribute=\plusone % we need a proper flag
   %    \displaylimits
   % \else
   %    \limits
   % \fi
   \else
     % none
   \fi}

\letvalue{\??mathintegral      nolimits}\zerocount
\letvalue{\??mathintegral displaylimits}\plusone
\letvalue{\??mathintegral        limits}\plustwo
\letvalue{\??mathintegral    autolimits}\plusthree
\letvalue{\??mathintegral          none}\plusfour

\appendtoks
    \mathintlimitmode\executeifdefined{\??mathintegral\mathematicsparameter\s!integral}\zerocount
\to \everyswitchmathematics

\setupmathematics
% [\v!integral=nolimits]
  [\v!integral=autolimits]

%D The following code is used for fallbacks and might become obsolete once
%D we have enough \OPENTYPE\ math fonts.

% \def\math_repeated_integal_i
%   {\int}

% \def\math_repeated_integal_ii
%   {\math_repeated_integal_i
%    \math_repeated_integral_kern
%    \math_repeated_integal_i
%    \math_repeat_integral_finish
%    \intlimits}

% \def\math_repeated_integal_iii
%   {\math_repeated_integal_i
%    \math_repeated_integral_kern
%    \math_repeated_integal_ii}
%
% \def\math_repeated_integal_iiii
%   {\math_repeated_integal_i
%    \math_repeated_integral_kern
%    \math_repeated_integal_iii}
%
% \unexpanded\def\math_repeat_integral#1%
%   {\let\math_repeat_integral_finish\donothing
%    \iffontchar\textfont\zerocount#1\relax
%      \expandafter\math_repeat_integral_real
%    \else
%      \expandafter\math_repeat_integral_fake
%    \fi}
%
% \def\math_repeat_integral_fake#1#2%
%   {\let\math_repeat_integral_fake_symbol#2%
%    \futurelet\next\math_repeat_integral_fake_indeed}
%
% \def\math_repeat_integral_real#1#2%
%   {#1}
%
% \definemathcommand [iint]   {\math_repeat_integral{"0222C}\normalint  \math_repeated_integal_ii  } % double
% \definemathcommand [iiint]  {\math_repeat_integral{"0222D}\normaliint \math_repeated_integal_iii } % tripple
% \definemathcommand [iiiint] {\math_repeat_integral{"FFFFF}\normaliiint\math_repeated_integal_iiii} % quadruple
%
% \def\math_repeated_integral_kern
%   {\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}}
%
% \def\math_repeat_integral_fake_indeed
%    {\ifx\next\limits
%       \math_repeated_integral_correction
%     \else\ifx\next\displaylimits
%       \math_repeated_integral_correction
%     \else\ifx\next\nolimits
%       % nothing
%     \else\ifcase\mathintlimitmode
%       % nothing
%     \else
%       \math_repeated_integral_correction
%     \fi\fi\fi\fi
%     \math_repeat_integral_fake_symbol}
%
% \def\math_repeated_integral_correction
%   {\mkern-7mu\mathchoice{\mkern-2mu}{}{}{}%
%    \mathop\bgroup\mkern7mu\mathchoice{\mkern2mu}{}{}{}\let\math_repeat_integral_finish\egroup}
%
% %D If the \type{\limits} option is used after \type {\iint}, use \type
% %D {\mathop} and fudge the left hand space a bit to make the subscript
% %D visually centered.

\protect \endinput