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
|
%
% Copyright (C) 1998-2019 Javier Bezos http://www.texnia.com
%
% This file may be distributed and/or modified under the conditions of
% the MIT License. A version can be found at the end of this file.
%
% Changes
% ~~~~~~~
%
% 2006-05-12. TeX converts to ord any symbol with a math accent.
% Accents now emulates this behaviour with braces around the
% nucleous; otherwise, the original category is preserved and
% the accents could look misaligned. (Reported by Viet-TrungLuu.)
%
% Release
% ~~~~~~~
\ProvidesPackage{accents}[2006/05/12 v1.4 Math Accent Tools]
\let\cc@palette\mathpalette
\DeclareOption{nonscript}
{\renewcommand\cc@palette[2]{#1\textstyle{#2}}}
\DeclareOption{single}
{\renewcommand\cc@accent[1]{\mathaccent#1}}
\newdimen\cc@skew
\newdimen\cc@wd
\newcount\cc@code
\newcount\cc@group
\newcount\cc@skewchar
\newif\ifcc@more
% Code for real accents
% ~~~~~~~~~~~~~~~~~~~~~
\def\cc@accent#1#2{%
\begingroup
\cc@code=#1\relax
\let\math@bgroup\@empty
\def\math@egroup##1{\cc@setchar##1}%
\cc@palette\cc@@accent{#2}%
{\cc@nuc}%
\endgroup}
\def\cc@iaccent#1#2{%
\cc@fetch{#2}%
\mathaccent#1{%
\ifcc@more#2\else
\cc@phant{#2}%
\gdef\cc@nuc{#2}%
\fi
\kern\cc@skew}%
\kern-\cc@skew}%
\def\cc@@accent#1#2{%
\let\cc@style=#1%
\cc@fetch{#2}%
\mathaccent\cc@code{%
\ifcc@more#2\else
\cc@phant{#2}%
\gdef\cc@nuc{#2}%
\fi
\kern\cc@skew}%
\kern-\cc@skew
\kern\cc@wd}%
% The accents are redefined:
\begingroup
\def\mathaccentV#1{\string"\noexpand\accentclass@}%
\let\protect\@empty
\let\mathaccent\@empty
\def\cc@set#1{%
\xdef#1{\noexpand\protect\noexpand\cc@accent{#1}}}
\cc@set\grave %{\protect\cc@accent{"7012\relax}}
\cc@set\acute %{\protect\cc@accent{"7013\relax}}
\cc@set\check %{\protect\cc@accent{"7014\relax}}
\cc@set\breve %{\protect\cc@accent{"7015\relax}}
\cc@set\bar %{\protect\cc@accent{"7016\relax}}
\cc@set\hat %{\protect\cc@accent{"705E\relax}}
\cc@set\dot %{\protect\cc@accent{"705F\relax}}
\cc@set\tilde %{\protect\cc@accent{"707E\relax}}
\cc@set\ddot %{\protect\cc@accent{"707F\relax}}
\cc@set\vec %{\protect\cc@accent{"017E\relax}}
\gdef\ring{\protect\cc@accent{"7017\relax}}
\@ifundefined{mathring}{}{\cc@set\mathring}
\endgroup
% Faked accents
% ~~~~~~~~~~~~~
\newcommand\accentset[2]{%
\begingroup
\def\cc@a{#1}%
\let\math@bgroup\@empty
\def\math@egroup##1{\cc@setchar##1}%
\cc@palette\cc@accentset{#2}%
{\cc@nuc}%
\endgroup}
\def\cc@accentset#1#2{%
\let\cc@style#1%
\cc@fetch{#2}%
\sbox\z@{$\m@th\cc@style\mathgroup\cc@group
\ifcc@more#2\else\cc@phant{#2}%
\gdef\cc@nuc{#2}\fi$}%
\cc@align{%
\hidewidth\kern\cc@skew
$\m@th\scriptscriptstyle\mathgroup\cc@group\cc@a$%
\hidewidth\cr{\box\z@}}%
\kern\cc@wd}%
\def\cc@iaccentset#1#2{%
\cc@fetch{#2}%
\sbox\z@{$\m@th\cc@style\ifcc@more#2\else\cc@phant{#2}%
\gdef\cc@nuc{#2}\fi$}%
\cc@align{%
\hidewidth\kern\cc@skew
$\m@th\scriptscriptstyle#1$\hidewidth\cr
{\box\z@}}}%
\def\cc@align#1{%
\vbox{%
\baselineskip\z@skip
\lineskip.25ex
\ialign{##\crcr#1\crcr}}}
% Shared by real and faked accents
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\def\cc@phant#1{%
\v@true\h@true
\finph@nt}% with \box0 from \cc@fetch
\def\cc@setchar{%
\cc@skewchar\ifnum\mathgroup=\m@ne
\skewchar\textfont\@ne
\else\ifnum\skewchar\textfont\mathgroup=\m@ne
\skewchar\textfont\@ne
\else\skewchar\textfont\mathgroup\fi\fi
\advance\cc@skewchar"7100 }
\def\cc@fetch#1{%
\cc@group=\the\mathgroup
\let\cc@accent\@gobble
\let\accentset\@gobble
\sbox\z@{$\m@th\mathgroup\cc@group\cc@setchar
\cc@style#1{}\mathchar\cc@skewchar$}%
\sbox\@ne{$\m@th\mathgroup\cc@group\cc@setchar
\cc@style#1\mathchar\cc@skewchar$}%
\cc@morefalse
\def\cc@accent##1{\global\cc@moretrue}%
\def\accentset##1{\global\cc@moretrue}%
\global\cc@skew2\wd\@ne
\global\advance\cc@skew-2\wd\z@
\sbox\z@{$\m@th\mathgroup\cc@group\cc@style#1$}%
\global\cc@wd-\wd\z@
\let\cc@accent\cc@iaccent
\let\accentset\cc@iaccentset}
% Two useful faked accents
% ~~~~~~~~~~~~~~~~~~~~~~~~
\def\dddot{\accentset{{\cc@style.\mkern-1.7mu\textstyle.\mkern-1.7mu.}}}
\def\ddddot{\accentset{{\cc@style.\mkern-2.1mu.\mkern-2.1mu.\mkern-2.1mu.}}}
% Underaccents
% ~~~~~~~~~~~~
\newcommand\underaccent[2]{%
\begingroup
\def\cc@a{#2}% Stores the nucleous...
\cc@palette\cc@underaccent{#1}% ...and the accent is passed
#2%
\endgroup}%
\def\cc@underaccent#1#2{%
\let\cc@style#1%
\expandafter\in@\expandafter\cc@accent\expandafter{#2}%
\ifin@
\expandafter\cc@uaccent#2\@@%
\else
\cc@uaccentset{#2}%
\fi}
\def\cc@uaccent#1#2#3\@@{% #1 and #2 gobbles \protect\cc@accent
\cc@under{%
\vbox to.2ex{%
\hbox{%
$\m@th
\cc@style
\mathgroup\cc@group
\cc@shift
\mathchar#3$}%
\vss}}}
\def\cc@uaccentset#1{%
\cc@under{%
\hbox{%
$\m@th
\cc@style
\mathgroup\cc@group
\cc@shift
\scriptscriptstyle#1$}}}
\def\cc@under#1{%
\cc@group\the\mathgroup
\sbox\z@{$\m@th\cc@style\mathgroup\cc@group\cc@a$}%
\sbox\tw@{$\scriptspace\z@\m@th\cc@style\mathgroup\cc@group\cc@a_{}$}%
\rlap{%
\oalign{%
\vrule \@depth\dp\z@ \@width\z@
\kern\wd\tw@
\crcr
\hidewidth#1\hidewidth}}}
\def\cc@shift{%
\dimen@=-.000008ex
\multiply\dimen@\ifnum\mathgroup=\m@ne
\fontdimen\@ne\textfont\@ne
\else
\fontdimen\@ne\textfont\cc@group\fi
\kern\dimen@}
% And \undertilde
% ~~~~~~~~~~~~~~~
\newcommand\undertilde{\cc@palette\cc@undertilde}
\def\cc@undertilde#1#2{%
\cc@group\the\mathgroup
\sbox\z@{$\m@th\mathgroup\cc@group#1#2$}%
\oalign{%
$\m@th\mathgroup\cc@group#1#2$%
\crcr
\hidewidth
\vbox to.5ex{%
\hbox{%
$\hss
#1%
\mathgroup\cc@group
\widetilde{\hbox to\wd\z@{\hss}}%
\hss$}%
\vss}%
\hidewidth}}
% The following command is used by \DeclareMathAccent
% and it's the only part requiring modification
\def\set@mathaccent#1#2#3#4{%
\xdef#2{\noexpand\protect\noexpand\cc@accent
{"\mathchar@type#3\hexnumber@#1#4\relax}}}
\ProcessOptions
\endinput
MIT License
-----------
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|