Debian Codegraph @

texmf-dist/source/latex/unicode-math/um-code-amsmath.dtx

raw
1 %%^^A%% um-code-amsmath.dtx -- part of UNICODE-MATH <wspr.io/unicode-math>
2 %%^^A%% Compatibility with amsmath.
3
4 % \section{Compatibility with \pkg{amsmath}}
5 %
6 % \begin{macrocode}
7 %<*package>
8 % \end{macrocode}
9 %
10 % Since the mathcode of |`\-| is greater than eight bits, this piece of |\AtBeginDocument| code from \pkg{amsmath} dies if we try and set the maths font in the preamble:
11 % \begin{macrocode}
12 \tl_remove_once:Nn \@begindocumenthook
13 {
14 \mathchardef\std@minus\mathcode`\-\relax
15 \mathchardef\std@equal\mathcode`\=\relax
16 }
17 \AtBeginDocument
18 {
19 \Umathcharnumdef\std@minus\Umathcodenum`-
20 \Umathcharnumdef\std@equal\Umathcodenum`=
21 }
22 % \end{macrocode}
23 %
24 % \begin{macrocode}
25 \cs_set:Npn \@cdots {\mathinner{\unicodecdots}}
26 \cs_set_eq:NN \dotsb@ \cdots
27 % \end{macrocode}
28 % This isn't as clever as the \pkg{amsmath} definition but I think it works:
29 % \begin{macrocode}
30 %<*XE>
31 \def \resetMathstrut@
32 {%
33 \setbox\z@\hbox{$($}%)
34 \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@
35 }
36 % \end{macrocode}
37 % The |subarray| environment uses inappropriate font dimensions.
38 % \begin{macrocode}
39 \cs_set:Npn \subarray #1
40 {
41 \vcenter
42 \c_group_begin_token
43 \Let@
44 \restore@math@cr
45 \default@tag
46 \skip_set:Nn \baselineskip
47 {
48 \@@_stack_num_up:N \scriptstyle
49 + \@@_stack_denom_down:N \scriptstyle
50 }
51 \lineskip \@@_stack_vgap:N \scriptstyle
52 \lineskiplimit \lineskip
53 \ialign
54 \c_group_begin_token
55 \token_if_eq_meaning:NNT c #1 { \hfil }
56 \c_math_toggle_token
57 \m@th
58 \scriptstyle
59 \c_parameter_token \c_parameter_token
60 \c_math_toggle_token
61 \hfil
62 \crcr
63 }
64 %</XE>
65 % \end{macrocode}
66 % The roots need a complete rework.
67 % \begin{macrocode}
68 %<*LU>
69 \cs_set_nopar:Npn \plainroot@ #1 \of #2
70 {
71 \bool_if:nTF
72 {
73 \@@_int_if_zero_p:n \uproot@ && \@@_int_if_zero_p:n \leftroot@
74 }
75 {
76 \Uroot \c_@@_radical_sqrt_tl { #1 } { #2 }
77 }
78 {
79 \hbox_set:Nn \rootbox
80 {
81 \c_math_toggle_token \m@th
82 \scriptscriptstyle { #1 }
83 \c_math_toggle_token
84 }
85 \mathchoice
86 { \r@@@@t \displaystyle { #2 } }
87 { \r@@@@t \textstyle { #2 } }
88 { \r@@@@t \scriptstyle { #2 } }
89 { \r@@@@t \scriptscriptstyle { #2 } }
90 }
91 \c_group_end_token
92 }
93 %</LU>
94 % \end{macrocode}
95 %
96 % \begin{macrocode}
97 \cs_set_nopar:Npn \r@@@@t #1 #2
98 %<*LU>
99 {
100 \hbox_set:Nn \l_tmpa_box
101 {
102 \c_math_toggle_token \m@th
103 #1 \mskip \uproot@ mu
104 \c_math_toggle_token
105 }
106 \Uroot \c_@@_radical_sqrt_tl
107 {
108 \box_move_up:nn { \box_wd:N \l_tmpa_box }
109 {
110 \hbox:n
111 {
112 \c_math_toggle_token \m@th
113 \mkern -\leftroot@ mu
114 \box_use:N \rootbox
115 \mkern \leftroot@ mu
116 \c_math_toggle_token
117 }
118 }
119 }
120 { #2 }
121 }
122 %</LU>
123 %<*XE>
124 {
125 \hbox_set:Nn \l_tmpa_box
126 {
127 \c_math_toggle_token \m@th
128 #1 \sqrtsign { #2 }
129 \c_math_toggle_token
130 }
131 \hbox_set:Nn \l_tmpb_box
132 {
133 \c_math_toggle_token \m@th
134 #1 \mskip \uproot@ mu
135 \c_math_toggle_token
136 }
137 \mkern -\leftroot@ mu
138 \@@_mathstyle_scale:NnnN #1 { \kern } { \fontdimen 63 \g_@@_sqrt_font_cmd_tl } \g_@@_sqrt_font_cmd_tl
139 \box_move_up:nn
140 {
141 \box_wd:N \l_tmpb_box + (\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box)
142 * \number \fontdimen 65 \g_@@_sqrt_font_cmd_tl / 100
143 }
144 { \box_use:N \rootbox }
145 \@@_mathstyle_scale:NnnN #1 { \kern } { \fontdimen 64 \g_@@_sqrt_font_cmd_tl } \g_@@_sqrt_font_cmd_tl
146 \mkern \leftroot@ mu
147 \box_use_drop:N \l_tmpa_box
148 }
149 %</XE>
150 % \end{macrocode}
151 %
152 % \begin{macrocode}
153 %</package>
154 % \end{macrocode}
155
156 \endinput
157
158 % /©
159 %
160 % ------------------------------------------------
161 % The UNICODE-MATH package <wspr.io/unicode-math>
162 % ------------------------------------------------
163 % This package is free software and may be redistributed and/or modified under
164 % the conditions of the LaTeX Project Public License, version 1.3c or higher
165 % (your choice): <http://www.latex-project.org/lppl/>.
166 % ------------------------------------------------
167 % Copyright 2006-2019 Will Robertson, LPPL "maintainer"
168 % Copyright 2010-2017 Philipp Stephani
169 % Copyright 2011-2017 Joseph Wright
170 % Copyright 2012-2015 Khaled Hosny
171 % ------------------------------------------------
172 %
173 % ©/