summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/commath/commath.sty
blob: 76a60c9e9e72825bd281f08a1074cddf9ba56b77 (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
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
%%% ====================================================================
%%% @LaTeX-file{
%%%   filename  = "commath.sty",
%%%   version   = "0.3",
%%%   date      = "2006",
%%%   author    = "Wolfgang Putschögl",
%%%   address   = "Johann Radon Institute for Computational and Applied Mathematics (RICAM)
%%%                Austrian Academy of Sciences
%%%                Altenbergerstraße 69
%%%                A-4040 Linz, Austria",
%%%   email     = "Wolfgang.Putschoegl@oeaw.ac.at",
%%%   codetable = "Western European, iso 8859-15",
%%%   keywords  = "LaTeX",
%%% }
%%% ====================================================================
\NeedsTeXFormat{LaTeX2e} % LaTeX 2.09 can't be used (nor non-LaTeX)
[1994/12/01]             % LaTeX date must December 1994 or later

\RequirePackage{ifthen}
\RequirePackage{amsmath}

% Differential (upface d)
\DeclareMathOperator{\dif}{d \!}
% Derivative (upface D)
\DeclareMathOperator{\Dif}{D \!}

% Command for partial derivatives. The first argument denotes the function and the second argument denotes the variable with respect to which the derivative is taken. The optional argument denotes the order of differentiation. The style (text style/display style) is determined automatically
\providecommand{\pd}[3][]{\ensuremath{
\ifinner
\tfrac{\partial{^{#1}}#2}{\partial{#3^{#1}}}
\else
\dfrac{\partial{^{#1}}#2}{\partial{#3^{#1}}}
\fi
}}

% \tpd[2]{f}{k} denotes the second partial derivative of f with respect to k
% The first letter t means "text style"
\providecommand{\tpd}[3][]{\ensuremath{\mathinner{
\tfrac{\partial{^{#1}}#2}{\partial{#3^{#1}}}
}}}
% \dpd[2]{f}{k} denotes the second partial derivative of f with respect to k
% The first letter d means "display style"
\providecommand{\dpd}[3][]{\ensuremath{\mathinner{
\dfrac{\partial{^{#1}}#2}{\partial{#3^{#1}}}
}}}

% mixed derivative - analogous to the partial derivative command
% \md{f}{5}{x}{2}{y}{3}
\providecommand{\md}[6]{\ensuremath{
\ifinner
\tfrac{\partial{^{#2}}#1}{\partial{#3^{#4}}\partial{#5^{#6}}}
\else
\dfrac{\partial{^{#2}}#1}{\partial{#3^{#4}}\partial{#5^{#6}}}
\fi
}}

% \tpd[2]{f}{k} denotes the second partial derivative of f with respect to k
% The first letter t means "text style"
\providecommand{\tmd}[6]{\ensuremath{\mathinner{
\tfrac{\partial{^{#2}}#1}{\partial{#3^{#4}}\partial{#5^{#6}}}
}}}
% \dpd[2]{f}{k} denotes the second partial derivative of f with respect to k
% The first letter d means "display style"
\providecommand{\dmd}[6]{\ensuremath{\mathinner{
\dfrac{\partial{^{#2}}#1}{\partial{#3^{#4}}\partial{#5^{#6}}}
}}}


% ordinary derivative - analogous to the partial derivative command
\providecommand{\od}[3][]{\ensuremath{
\ifinner
\tfrac{\dif{^{#1}}#2}{\dif{#3^{#1}}}
\else
\dfrac{\dif{^{#1}}#2}{\dif{#3^{#1}}}
\fi
}}

\providecommand{\tod}[3][]{\ensuremath{\mathinner{
\tfrac{\dif{^{#1}}#2}{\dif{#3^{#1}}}
}}}
\providecommand{\dod}[3][]{\ensuremath{\mathinner{
\dfrac{\dif{^{#1}}#2}{\dif{#3^{#1}}}
}}}



\providecommand{\thmref}[1]{Theorem~\ref{#1}}
\providecommand{\exref}[1]{Example~\ref{#1}}
\providecommand{\defnref}[1]{Definition~\ref{#1}}
\providecommand{\secref}[1]{\S\ref{#1}}
\providecommand{\lemref}[1]{Lemma~\ref{#1}}
\providecommand{\propref}[1]{Proposition~\ref{#1}}
\providecommand{\remref}[1]{Remark~\ref{#1}}
\providecommand{\figref}[1]{Figure~\ref{#1}}
\providecommand{\colref}[1]{Corollary~\ref{#1}}
\providecommand{\appref}[1]{Appendix~\ref{#1}}
\providecommand{\assref}[1]{Assumption~\ref{#1}}

% Make nested braces grow.
\delimitershortfall-1sp

% the value for the optional argument ranges from -1 to 4 with higher values resulting in larger delimiters
% default value for #1 is -1 which results in automatic size for the parenthesis (del -> DELimiters)
\providecommand{\del}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
\left(#2\right)}{}
\ifthenelse{\equal{#1}{0}}{ % if
(#2)}{}
\ifthenelse{\equal{#1}{1}}{ % if
\bigl(#2\bigr)}{}
\ifthenelse{\equal{#1}{2}}{ % if
\Bigl(#2\Bigr)}{}
\ifthenelse{\equal{#1}{3}}{ % if
\biggl(#2\biggr)}{}
\ifthenelse{\equal{#1}{4}}{ % if
\Biggl(#2\Biggr)}{}
}} % \ensuremath{\mathinner{
}  % DELimiters - normal parenthesis, the optional argument describes the size of the parenthesis, no argument results in automatic size

% the value for the optional argument ranges from -1 to 4 with higher values resulting in larger delimiters
% default value for #1 is -1 which results in automatic size for the brackets
\providecommand{\set}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
\left\{#2\right\}}{}
\ifthenelse{\equal{#1}{0}}{ % if
\{#2\}}{}
\ifthenelse{\equal{#1}{1}}{ % if
\bigl\{#2\bigr\}}{}
\ifthenelse{\equal{#1}{2}}{ % if
\Bigl\{#2\Bigr\}}{}
\ifthenelse{\equal{#1}{3}}{ % if
\biggl\{#2\biggr\}}{}
\ifthenelse{\equal{#1}{4}}{ % if
\Biggl\{#2\Biggr\}}{}
}} % \ensuremath{\mathinner{
}  % Curly BRaces, the optional argument describes the size of the braces, no argument results in automatic size
\let\cbr=\set % Curly BRaces

% the value for the optional argument ranges from -1 to 4 with higher values resulting in larger delimiters
% default value for #1 is -1 which results in automatic size for the brackets
\providecommand{\sbr}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
\left[#2\right]}{}
\ifthenelse{\equal{#1}{0}}{ % if
[#2]}{}
\ifthenelse{\equal{#1}{1}}{ % if
\bigl[#2\bigr]}{}
\ifthenelse{\equal{#1}{2}}{ % if
\Bigl[#2\Bigr]}{}
\ifthenelse{\equal{#1}{3}}{ % if
\biggl[#2\biggr]}{}
\ifthenelse{\equal{#1}{4}}{ % if
\Biggl[#2\Biggr]}{}
}} % \ensuremath{\mathinner{
} % Square BRackets, the optional argument describes the size of the brackets, no argument results in automatic size

% All kinds of intervals -------------------------------------------------

% the value for the optional argument ranges from -1 to 4 with higher values resulting in larger delimiters
% (#1,#2) open   open
\providecommand{\intoo}[2][-1]{\del[#1]{#2}}
% [#1,#2] closed closed
\providecommand{\intcc}[2][-1]{\sbr[#1]{#2}}

% (#1,#2] open   closed
\providecommand{\intoc}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
\left(#2\right]}{}
\ifthenelse{\equal{#1}{0}}{ % if
(#2]}{}
\ifthenelse{\equal{#1}{1}}{ % if
\bigl(#2\bigr]}{}
\ifthenelse{\equal{#1}{2}}{ % if
\Bigl(#2\Bigr]}{}
\ifthenelse{\equal{#1}{3}}{ % if
\biggl(#2\biggr]}{}
\ifthenelse{\equal{#1}{4}}{ % if
\Biggl(#2\Biggr]}{}
}} % \ensuremath{\mathinner{
}

% [#1,#2) closed open
\providecommand{\intco}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
\left[#2\right)}{}
\ifthenelse{\equal{#1}{0}}{ % if
[#2)}{}
\ifthenelse{\equal{#1}{1}}{ % if
\bigl[#2\bigr)}{}
\ifthenelse{\equal{#1}{2}}{ % if
\Bigl[#2\Bigr)}{}
\ifthenelse{\equal{#1}{3}}{ % if
\biggl[#2\biggr)}{}
\ifthenelse{\equal{#1}{4}}{ % if
\Biggl[#2\Biggr)}{}
}} % \ensuremath{\mathinner{
}
% ------------------------------------------------------------------------

% Notation for an expression evaluated at a particular condition:
% the value for the optional argument ranges from -1 to 4 with higher values resulting in larger delimiters
\providecommand{\eval}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
#2\Biggr\rvert}{}
\ifthenelse{\equal{#1}{0}}{ % if
#2\rvert}{}
\ifthenelse{\equal{#1}{1}}{ % if
#2\bigr\rvert}{}
\ifthenelse{\equal{#1}{2}}{ % if
#2\Bigr\rvert}{}
\ifthenelse{\equal{#1}{3}}{ % if
#2\biggr\rvert}{}
\ifthenelse{\equal{#1}{4}}{ % if
#2\Biggr\rvert}{}
}} % \ensuremath{\mathinner{
}

\providecommand{\sVert}[1][0]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{0}}{ % if
\rvert}{}
\ifthenelse{\equal{#1}{1}}{ % if
\bigr\rvert}{}
\ifthenelse{\equal{#1}{2}}{ % if
\Bigr\rvert}{}
\ifthenelse{\equal{#1}{3}}{ % if
\biggr\rvert}{}
\ifthenelse{\equal{#1}{4}}{ % if
\Biggr\rvert}{}
}} % \ensuremath{\mathinner{
}


% Enclose the argument in vert-bar delimiters:
% the value for the optional argument ranges from -1 to 4 with higher values resulting in larger delimiters
\providecommand{\envert}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
\!\left\lvert#2\right\rvert}{}
\ifthenelse{\equal{#1}{0}}{ % if
\lvert#2\rvert}{}
\ifthenelse{\equal{#1}{1}}{ % if
\!\bigl\lvert#2\bigr\rvert}{}
\ifthenelse{\equal{#1}{2}}{ % if
\!\Bigl\lvert#2\Bigr\rvert}{}
\ifthenelse{\equal{#1}{3}}{ % if
\!\biggl\lvert#2\biggr\rvert}{}
\ifthenelse{\equal{#1}{4}}{ % if
\!\Biggl\lvert#2\Biggr\rvert}{}
}} % \ensuremath{\mathinner{
}
\let\abs=\envert

% Enclose the argument in double-vert-bar delimiters:
% the value for the optional argument ranges from -1 to 4 with higher values resulting in larger delimiters
\providecommand{\enVert}[2][-1]{
\ensuremath{\mathinner{
\ifthenelse{\equal{#1}{-1}}{ % if
\!\left\lVert#2\right\rVert}{}
\ifthenelse{\equal{#1}{0}}{ % if
\lVert#2\rVert}{}
\ifthenelse{\equal{#1}{1}}{ % if
\!\bigl\lVert#2\bigr\rVert}{}
\ifthenelse{\equal{#1}{2}}{ % if
\!\Bigl\lVert#2\Bigr\rVert}{}
\ifthenelse{\equal{#1}{3}}{ % if
\!\biggl\lVert#2\biggr\rVert}{}
\ifthenelse{\equal{#1}{4}}{ % if
\!\Biggl\lVert#2\Biggr\rVert}{}
}} % \ensuremath{\mathinner{
}
\let\norm=\enVert

% Fix alignment of := in mathmode
\mathchardef\ordinarycolon\mathcode`\:
\mathcode`\:=\string"8000
\begingroup \catcode`\:=\active
   \gdef:{\mathrel{\mathop\ordinarycolon}}
\endgroup

% Full function
\providecommand{\fullfunction}[5]{\ensuremath{
   \begin {array}{ccrcl}
       {#1}    & \colon  & {#2} & \longrightarrow & {#3} \\
       \mbox{} & \mbox{} & {#4} & \longmapsto     & {#5}
   \end{array}
}}

% ------------------------------------------------------------------------