File: t-amsl.tex

package info (click to toggle)
tetex-base 3.0.dfsg.3-5etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 239,592 kB
  • ctags: 10,610
  • sloc: xml: 103,461; perl: 9,398; ruby: 2,850; python: 1,551; php: 1,067; sh: 981; lisp: 494; makefile: 371; awk: 88
file content (225 lines) | stat: -rw-r--r-- 5,762 bytes parent folder | download | duplicates (2)
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
%D \module
%D   [      file=t-amsl,
%D        version=2004.11.18,
%D          title=\CONTEXT\ User Module,
%D       subtitle=AMS-LaTeX compatibility,
%D         author=Giuseppe Bilotta,
%D           date=\currentdate,
%D      copyright={PRAGMA / Giuseppe Bilotta}]

%D This ConTeXt module is intended to provide AMS-LaTeX-like
%D functionality to ConTeXt

% \doifdefined{\amslatexmath}{\message{\amslatexmath}\endinput}
% \def\amslatexmath{AMS-LaTeX compatibility module already loaded}

\usemodule[newmat]

\def\stackrel#1#2{\mathrel{\mathop{#2}\limits^{#1}}}
\def\underset#1#2{\mathrel{\mathop{#2}\limits_{#1}}}

%D Formulas

% \setupformulas[indentnext=no]
% The following requires a patch to work correctly:

\setupformulas[indentnext=auto]

\let\[\startformula
\def\]{\stopformula\ignorespaces}

\def\(#1\){\mathematics{#1}}

\def\startalign{\grabuntil{stopalign}\dostarteqalign}

\def\dostarteqalign#1%
  {\startformula
   \let\\\cr
   \eqalign{#1\crcr}
   \stopformula}
   
\let\stopalign\relax

\def\startgather{\grabuntil{stopgather}\dostartgather}

\def\dostartgather#1%
  {\startformula
   \def\\{\cr&}%
   \eqalign{&#1\crcr}
   \stopformula}

\let\stopgather\relax

%D Blocks used in formulas

%D LaTeX "array"

\unprotect

\newdimen\arraycolsep
\newdimen\prearraycolsep
\newdimen\postarraycolsep

\newcount\amp@count

\arraycolsep1ex % todo: hook into everymath 

\newdimen\arrayrowsep
\arrayrowsep1ex % todo: hook into everymath

% \let\@arraycr\crcr

\def\@arraycr{\crcr\noalign{\hrule height\arrayrowsep width 0pt}}

\newtoks\arraypreamble

\def\startarray#1%
  {\begingroup% needed? erroneous?
   % TODO scan array preamble
   % preamble is assumed to be a sequence of
   % l,r,c which determine whether the specific column should be
   % left-aligned, right-aligned or centered
   \arraypreamble{\tabskip\arraycolsep}%
   \amp@count0
   \let\arrayboxcommand\vcenter
   \scanarraypreamble#1\relax}

\def\scanpreamblenext
  {\afterassignment\doscanarraypreamble\let\next=}
\def\scanarraypreamble
  {\let\array!l=l
   \let\array!r=r
   \let\array!c=c
   \let\array!d=d
   \let\array!t=t
   \scanpreamblenext}

\def\arrayaddleftaligned {\appendtoks&$##$\hss\to\arraypreamble}
\def\arrayaddrightaligned{\appendtoks&\hss$##$\to\arraypreamble}
\def\arrayaddcentered    {\appendtoks&\hss$##$\hss\to\arraypreamble}
\def\arrayaddtextual     {\appendtoks&$\text{##}$\hss\to\arraypreamble}
\def\arrayadddisplayed   {\appendtoks&$\displaystyle##$\hss\to\arraypreamble}

\def\doscanarraypreamble
  {\ifx\next\array!l
     \def\!!next
       {\arrayaddleftaligned
        \advance\amp@count1
        \scanpreamblenext}%
   \else\ifx\next\array!r
     \def\!!next
       {\arrayaddrightaligned
        \advance\amp@count1
        \scanpreamblenext}%
    \else\ifx\next\array!c
      \def\!!next
        {\arrayaddcentered
         \advance\amp@count1
         \scanpreamblenext}%
    \else\ifx\next\array!t
      \def\!!next
        {\arrayaddtextual
         \advance\amp@count1
         \scanpreamblenext}%
    \else\ifx\next\array!d
      \def\!!next
        {\arrayadddisplayed
         \advance\amp@count1
         \scanpreamblenext}%
    \else\if\next\relax
      \def\!!next
        {\appendtoks\tabskip\postarraycolsep\cr\to\arraypreamble
         \dostartarray}%
     \else
       % TODO error
       \message{\meaning\next\space unexpected in preamble; replacing with 'c'}
       \def\!!next  
         {\arrayaddcentered
          \advance\amp@count1
          \scanpreamblenext}%
      \fi \fi \fi \fi \fi \fi
  \!!next}

\def\dostartarray
  {\arrayboxcommand\bgroup % TODO or vcenter or vtop
   \let\\\@arraycr
   % \showthe\arraypreamble
   \tabskip\prearraycolsep
   \expandafter\halign\expandafter\bgroup\the\arraypreamble}

\def\stoparray
  {\crcr\egroup
   \egroup
   \endgroup}

\def\startcases
  {\left\{\startarray{ll}}

\def\stopcases
  {\stoparray\right.}

\def\startbigcases
  {\left\{\startarray{dl}}

\def\stopbigcases
  {\stoparray\right.}

\def\cases#1
  {\left\{\startarray{lt}#1\crcr\stoparray\right.}

%D Font Stuff
%D
%D First of all, we need Fraktur to be loaded correctly, something
%D which ConTeXt doesn't do by default (at least by now)
%D Can't find a better, faster, cleaner way to do it;
%D it should probably be added to ConTeXt default for AMS, anyway

\definebodyfont [12pt,11pt,10pt,9pt] [mm] [mc=eufm10 sa 1]
\definebodyfont [8pt,7pt,6pt]        [mm] [mc=eufm7 sa 1]
\definebodyfont [5pt]                [mm] [mc=eufm5]

%D to make sure they get loaded, we make a font change
%D we restore rm afterwards, not having a way to decide which one
%D was active (anyway, rm is a pretty safe bet when loading
%D a module \dots)

\switchtobodyfont[mm]
\switchtobodyfont[rm]

%D Next we restore LaTeX-like behaviour for \cal, \Bbd, \frak

\definefamilysynonym[default][calligraphic][sy]
\definefamilysynonym[default][blackboard]  [mb]

%D The next one requires eufm to be loaded properly, as above

\definefamilysynonym[default][fraktur][mc]

\def\!mathcal {\fam\purefamily{calligraphic}}
\def\!mathBbd {\fam\purefamily{blackboard}}
\def\!mathfrak{\fam\purefamily{fraktur}}

\def\mathcal #1{{\!mathcal #1}}
\def\mathbb  #1{{\!mathBbd #1}}
\def\mathfrak#1{{\!mathfrak#1}}

\appendtoks
  \let\cal \!mathcal
  \let\Bbd \!mathBbd
  \let\frak\!mathfrak
\to\everymath

\appendtoks
  \let\cal \!mathcal
  \let\Bbd \!mathBbd
  \let\frak\!mathfrak
\to\everydisplay

\enablemathcollection[ams] \usemathcollection[ams]

%D Reference formats

\definereferenceformat[eqref][left=(,right=)]

\protect \endinput