| 1 |
%%^^A%% um-code-epilogue.dtx -- part of UNICODE-MATH <wspr.io/unicode-math> |
| 2 |
%%^^A%% Assorted definitions to close up. |
| 3 |
|
| 4 |
% \section{Epilogue} |
| 5 |
% |
| 6 |
% \begin{macrocode} |
| 7 |
%<*package> |
| 8 |
% \end{macrocode} |
| 9 |
% |
| 10 |
% Lots of little things to tidy up. |
| 11 |
% |
| 12 |
% \subsection{Resolving Greek symbol name control sequences} |
| 13 |
% |
| 14 |
% \begin{macro}{\@@_resolve_greek:} |
| 15 |
% This macro defines \cmd\Alpha\dots\cmd\omega\ as their corresponding |
| 16 |
% Unicode (mathematical italic) character. Remember that the mapping |
| 17 |
% to upright or italic happens with the mathcode definitions, whereas these macros |
| 18 |
% just stand for the literal Unicode characters. |
| 19 |
% \begin{macrocode} |
| 20 |
\AtBeginDocument { \debug_suspend: \@@_resolve_greek: \debug_resume: } |
| 21 |
% \end{macrocode} |
| 22 |
% \begin{macrocode} |
| 23 |
\cs_new:Npn \@@_resolve_greek: |
| 24 |
{ |
| 25 |
\clist_map_inline:nn |
| 26 |
{ |
| 27 |
Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda, |
| 28 |
alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda, |
| 29 |
Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega, |
| 30 |
mu,nu,xi,omicron,pi,rho,sigma,tau,upsilon,phi,chi,psi,omega, |
| 31 |
varTheta,varsigma,vartheta,varkappa,varrho,varpi,varepsilon,varphi |
| 32 |
} |
| 33 |
{ |
| 34 |
\tl_set:cx {##1} { \exp_not:c { mit ##1 } } |
| 35 |
\tl_set:cx {up ##1} { \exp_not:N \symup \exp_not:c { ##1 } } |
| 36 |
\tl_set:cx {it ##1} { \exp_not:N \symit \exp_not:c { ##1 } } |
| 37 |
} |
| 38 |
} |
| 39 |
% \end{macrocode} |
| 40 |
% \end{macro} |
| 41 |
% |
| 42 |
% |
| 43 |
% |
| 44 |
% |
| 45 |
% |
| 46 |
% \subsubsection{Active fractions} |
| 47 |
% |
| 48 |
% Active fractions can be set up independently of any maths font definition; |
| 49 |
% all it requires is a mapping from the Unicode input chars to the relevant |
| 50 |
% \LaTeX\ fraction declaration. |
| 51 |
% |
| 52 |
% \begin{macrocode} |
| 53 |
\cs_new:Nn \@@_which_frac:nn |
| 54 |
{ |
| 55 |
\bool_if:NTF \l_@@_smallfrac_bool {\tfrac} {\frac} {#1} {#2} |
| 56 |
} |
| 57 |
% \end{macrocode} |
| 58 |
% |
| 59 |
% \begin{macrocode} |
| 60 |
\cs_new:Npn \@@_setup_active_frac: |
| 61 |
{ |
| 62 |
\@@_mathactive_remap:nn {"2189} { \@@_which_frac:nn {0} {3} } |
| 63 |
\@@_mathactive_remap:nn {"2152} { \@@_which_frac:nn {1} {10} } |
| 64 |
\@@_mathactive_remap:nn {"2151} { \@@_which_frac:nn {1} {9} } |
| 65 |
\@@_mathactive_remap:nn {"215B} { \@@_which_frac:nn {1} {8} } |
| 66 |
\@@_mathactive_remap:nn {"2150} { \@@_which_frac:nn {1} {7} } |
| 67 |
\@@_mathactive_remap:nn {"2159} { \@@_which_frac:nn {1} {6} } |
| 68 |
\@@_mathactive_remap:nn {"2155} { \@@_which_frac:nn {1} {5} } |
| 69 |
\@@_mathactive_remap:nn {"00BC} { \@@_which_frac:nn {1} {4} } |
| 70 |
\@@_mathactive_remap:nn {"2153} { \@@_which_frac:nn {1} {3} } |
| 71 |
\@@_mathactive_remap:nn {"215C} { \@@_which_frac:nn {3} {8} } |
| 72 |
\@@_mathactive_remap:nn {"2156} { \@@_which_frac:nn {2} {5} } |
| 73 |
\@@_mathactive_remap:nn {"00BD} { \@@_which_frac:nn {1} {2} } |
| 74 |
\@@_mathactive_remap:nn {"2157} { \@@_which_frac:nn {3} {5} } |
| 75 |
\@@_mathactive_remap:nn {"215D} { \@@_which_frac:nn {5} {8} } |
| 76 |
\@@_mathactive_remap:nn {"2154} { \@@_which_frac:nn {2} {3} } |
| 77 |
\@@_mathactive_remap:nn {"00BE} { \@@_which_frac:nn {3} {4} } |
| 78 |
\@@_mathactive_remap:nn {"2158} { \@@_which_frac:nn {4} {5} } |
| 79 |
\@@_mathactive_remap:nn {"215A} { \@@_which_frac:nn {5} {6} } |
| 80 |
\@@_mathactive_remap:nn {"215E} { \@@_which_frac:nn {7} {8} } |
| 81 |
} |
| 82 |
% \end{macrocode} |
| 83 |
% |
| 84 |
% \begin{macrocode} |
| 85 |
\AtBeginDocument { \@@_setup_active_frac: } |
| 86 |
% \end{macrocode} |
| 87 |
% |
| 88 |
% |
| 89 |
% \subsection{Synonyms and all the rest} |
| 90 |
% |
| 91 |
% These are symbols with multiple names. Eventually to be taken care of |
| 92 |
% automatically by the maths characters database. |
| 93 |
% \begin{macrocode} |
| 94 |
\protected\def\to{\rightarrow} |
| 95 |
\protected\def\le{\leq} |
| 96 |
\protected\def\ge{\geq} |
| 97 |
\protected\def\neq{\ne} |
| 98 |
\protected\def\triangle{\mathord{\bigtriangleup}} |
| 99 |
\protected\def\bigcirc{\mdlgwhtcircle} |
| 100 |
\protected\def\circ{\vysmwhtcircle} |
| 101 |
\protected\def\bullet{\smblkcircle} |
| 102 |
\protected\def\mathyen{\yen} |
| 103 |
\protected\def\mathsterling{\sterling} |
| 104 |
\protected\def\diamond{\smwhtdiamond} |
| 105 |
\protected\def\emptyset{\varnothing} |
| 106 |
\protected\def\hbar{\hslash} |
| 107 |
\protected\def\land{\wedge} |
| 108 |
\protected\def\lor{\vee} |
| 109 |
\protected\def\owns{\ni} |
| 110 |
\protected\def\gets{\leftarrow} |
| 111 |
\protected\def\mathring{\ocirc} |
| 112 |
\protected\def\lnot{\neg} |
| 113 |
\protected\def\longdivision{\longdivisionsign} |
| 114 |
% \end{macrocode} |
| 115 |
% These are somewhat odd: (and their usual Unicode uprightness does not match their amssymb glyphs) |
| 116 |
% \begin{macrocode} |
| 117 |
\protected\def\backepsilon{\upbackepsilon} |
| 118 |
\protected\def\eth{\matheth} |
| 119 |
% \end{macrocode} |
| 120 |
% These are names that are `frozen' in HTML but have dumb names: |
| 121 |
% \begin{macrocode} |
| 122 |
\protected\def\dbkarow {\dbkarrow} |
| 123 |
\protected\def\drbkarow{\drbkarrow} |
| 124 |
\protected\def\hksearow{\hksearrow} |
| 125 |
\protected\def\hkswarow{\hkswarrow} |
| 126 |
% \end{macrocode} |
| 127 |
% |
| 128 |
% Due to the magic of OpenType math, big operators are automatically |
| 129 |
% enlarged when necessary. Since there isn't a separate unicode glyph for |
| 130 |
% `small integral', I'm not sure if there is a better way to do this: |
| 131 |
% \begin{macrocode} |
| 132 |
\protected\def\smallint{\mathop{\textstyle\int}\limits} |
| 133 |
% \end{macrocode} |
| 134 |
% |
| 135 |
% \begin{macro}{\underbar} |
| 136 |
% \begin{macrocode} |
| 137 |
\cs_set_eq:NN \latexe_underbar:n \underbar |
| 138 |
\renewcommand\underbar |
| 139 |
{ |
| 140 |
\mode_if_math:TF \mathunderbar \latexe_underbar:n |
| 141 |
} |
| 142 |
% \end{macrocode} |
| 143 |
% \end{macro} |
| 144 |
% |
| 145 |
% \begin{macro}{\smallsetminus} |
| 146 |
% \begin{macrocode} |
| 147 |
\cs_set_protected:Npn \smallsetminus { \mathbin{ \mathpalette \@@_smallsetminus: \relax} } |
| 148 |
\cs_set:Npn \__um_smallsetminus: #1 { \rotatebox{135}{ \smash{ \raisebox{-\height}{$#1\minus$} } }} |
| 149 |
% \end{macrocode} |
| 150 |
% \end{macro} |
| 151 |
% |
| 152 |
% \begin{macro}{\digamma} |
| 153 |
% \begin{macro}{\Digamma} |
| 154 |
% I might end up just changing these in the table. |
| 155 |
% \begin{macrocode} |
| 156 |
\cs_set_protected:Npn \digamma {\updigamma} |
| 157 |
\cs_set_protected:Npn \Digamma {\upDigamma} |
| 158 |
% \end{macrocode} |
| 159 |
% \end{macro} |
| 160 |
% \end{macro} |
| 161 |
% |
| 162 |
% \paragraph{Symbols} |
| 163 |
% |
| 164 |
% \begin{macrocode} |
| 165 |
\cs_set_protected:Npn \| {\Vert} |
| 166 |
% \end{macrocode} |
| 167 |
% |
| 168 |
% \cs{mathinner} items: |
| 169 |
% \begin{macrocode} |
| 170 |
\cs_set_protected:Npn \mathellipsis {\mathinner{\unicodeellipsis}} |
| 171 |
\cs_set_protected:Npn \cdots {\mathinner{\unicodecdots}} |
| 172 |
% \end{macrocode} |
| 173 |
% |
| 174 |
% \begin{macrocode} |
| 175 |
\cs_set_eq:NN \@@_text_slash: \slash |
| 176 |
\cs_set_protected:Npn \slash |
| 177 |
{ |
| 178 |
\mode_if_math:TF {\mathslash} {\@@_text_slash:} |
| 179 |
} |
| 180 |
% \end{macrocode} |
| 181 |
% |
| 182 |
% |
| 183 |
% \subsubsection{\cs{not}} |
| 184 |
% \label{sec:negations} |
| 185 |
% |
| 186 |
% The situation of \cs{not} symbol is currently messy, in Unicode it is defined |
| 187 |
% as a combining mark so naturally it should be treated as a math accent, |
| 188 |
% however \XeTeX\ does not correctly place it as it needs special |
| 189 |
% treatment compared to other accents. |
| 190 |
% Furthermore a math accent changes the |
| 191 |
% spacing of its nucleus, so \cs{not=} will be spaced as an ordinary not |
| 192 |
% relational symbol, which is undesired. |
| 193 |
% |
| 194 |
% Here modify \cs{not} to a macro that tries to use predefined negated symbols, |
| 195 |
% which would give better results in most cases, until there is more robust |
| 196 |
% solution in the engines. |
| 197 |
% |
| 198 |
% This code is based on an answer to a TeX -- Stack Exchange question by Enrico |
| 199 |
% Gregorio\footnote{\url{http://tex.stackexchange.com/a/47260/729}}. |
| 200 |
% |
| 201 |
% \begin{macro}{\not} |
| 202 |
% \begin{macrocode} |
| 203 |
\DeclareDocumentCommand \not {m} |
| 204 |
{ |
| 205 |
\tl_set:Nx \l_@@_not_token_name_tl { \cs_to_str:N #1 } |
| 206 |
\tl_if_empty:NT \l_@@_not_token_name_tl |
| 207 |
{ |
| 208 |
\tl_set:Nx \l_@@_not_token_name_tl { \token_to_str:N #1 } |
| 209 |
} |
| 210 |
\cs_if_exist:cTF { not \l_@@_not_token_name_tl } |
| 211 |
{ |
| 212 |
\use:c { not \l_@@_not_token_name_tl } |
| 213 |
} |
| 214 |
{ |
| 215 |
\cs_if_exist:cTF { n \l_@@_not_token_name_tl } |
| 216 |
{ |
| 217 |
\use:c { n \l_@@_not_token_name_tl } |
| 218 |
} |
| 219 |
{ |
| 220 |
\tl_if_eq:nnTF {#1} {$} { \notaccent{} } { \notaccent } #1 |
| 221 |
} |
| 222 |
} |
| 223 |
} |
| 224 |
% \end{macrocode} |
| 225 |
% \end{macro} |
| 226 |
% |
| 227 |
% \begin{macro}{\NewNegationCommand} |
| 228 |
% \begin{macro}{\RenewNegationCommand} |
| 229 |
% \begin{macrocode} |
| 230 |
\DeclareDocumentCommand \NewNegationCommand {mm} |
| 231 |
{ |
| 232 |
\@@_set_negation_command:Nnn \cs_new_protected:cpn {#1} {#2} |
| 233 |
} |
| 234 |
% \end{macrocode} |
| 235 |
% |
| 236 |
% \begin{macrocode} |
| 237 |
\DeclareDocumentCommand \RenewNegationCommand {mm} |
| 238 |
{ |
| 239 |
\@@_set_negation_command:Nnn \cs_set_protected:cpn {#1} {#2} |
| 240 |
} |
| 241 |
% \end{macrocode} |
| 242 |
% |
| 243 |
% \begin{macrocode} |
| 244 |
\cs_set:Nn \@@_set_negation_command:Nnn |
| 245 |
{ |
| 246 |
\tl_set:Nx \l_@@_not_token_name_tl { \cs_to_str:N #2 } |
| 247 |
\tl_if_empty:NT \l_@@_not_token_name_tl |
| 248 |
{ |
| 249 |
\tl_set:Nx \l_@@_not_token_name_tl { \token_to_str:N #2 } |
| 250 |
} |
| 251 |
#1 { not \l_@@_not_token_name_tl } { #3 } |
| 252 |
} |
| 253 |
% \end{macrocode} |
| 254 |
% \end{macro} |
| 255 |
% \end{macro} |
| 256 |
% |
| 257 |
% \begin{macrocode} |
| 258 |
\NewNegationCommand { = } { \neq } |
| 259 |
\NewNegationCommand { < } { \nless } |
| 260 |
\NewNegationCommand { > } { \ngtr } |
| 261 |
\NewNegationCommand { \gets } { \nleftarrow } |
| 262 |
\NewNegationCommand { \simeq } { \nsime } |
| 263 |
\NewNegationCommand { \equal } { \ne } |
| 264 |
\NewNegationCommand { \le } { \nleq } |
| 265 |
\NewNegationCommand { \ge } { \ngeq } |
| 266 |
\NewNegationCommand { \greater } { \ngtr } |
| 267 |
\NewNegationCommand { \forksnot } { \forks } |
| 268 |
% \end{macrocode} |
| 269 |
% |
| 270 |
% |
| 271 |
% \subsubsection{Full-width remapping} |
| 272 |
% |
| 273 |
% While this could be done with the full mathcode remapping machinery used |
| 274 |
% for the other purposes, it would be fairly redundant with plain ASCII. |
| 275 |
% Worse, this would slow down what is already an inefficient part of \pkg{unicode-math}. |
| 276 |
% |
| 277 |
% Instead we use mathactive to do a plain old mapping from full-width to ASCII directly. |
| 278 |
% |
| 279 |
% Until I get requests for it, I've not included symbols or punctuation here. |
| 280 |
% |
| 281 |
% \paragraph{Numbers} |
| 282 |
% |
| 283 |
% \begin{macrocode} |
| 284 |
\int_step_inline:nnnn {0} {1} {9} |
| 285 |
{ |
| 286 |
\@@_mathactive_remap:nn {"FF10+#1} {\char\int_eval:n{`\0+#1}} |
| 287 |
} |
| 288 |
% \end{macrocode} |
| 289 |
% |
| 290 |
% \paragraph{Letters} |
| 291 |
% |
| 292 |
% \begin{macrocode} |
| 293 |
\int_step_inline:nnnn {0} {1} {26} |
| 294 |
{ |
| 295 |
\@@_mathactive_remap:nn {"FF21+#1} {\char\int_eval:n{`\A+#1}} |
| 296 |
\@@_mathactive_remap:nn {"FF41+#1} {\char\int_eval:n{`\a+#1}} |
| 297 |
} |
| 298 |
% \end{macrocode} |
| 299 |
% |
| 300 |
% |
| 301 |
% \subsection{Legacy characters} |
| 302 |
% |
| 303 |
% \begin{macro}{\@@_undeclare_symbol:N} |
| 304 |
% \begin{macrocode} |
| 305 |
\cs_new:Nn \@@_undeclare_symbol:N |
| 306 |
{ |
| 307 |
\cs_set_protected:Npn #1 |
| 308 |
{ \@@_error:nx {legacy-char-not-supported} { \token_to_str:N #1 } } |
| 309 |
} |
| 310 |
% \end{macrocode} |
| 311 |
% \end{macro} |
| 312 |
% |
| 313 |
% If you have better ideas about what to do here, please mention. |
| 314 |
% \begin{macrocode} |
| 315 |
\@@_undeclare_symbol:N \arrowvert |
| 316 |
\@@_undeclare_symbol:N \Arrowvert |
| 317 |
\@@_undeclare_symbol:N \bracevert |
| 318 |
% \end{macrocode} |
| 319 |
% |
| 320 |
% \begin{macrocode} |
| 321 |
%</package> |
| 322 |
% \end{macrocode} |
| 323 |
% |
| 324 |
% \section*{Fin} |
| 325 |
% |
| 326 |
% The official end of the package: |
| 327 |
% \begin{macrocode} |
| 328 |
%<package>\endinput |
| 329 |
% \end{macrocode} |
| 330 |
|
| 331 |
\endinput |
| 332 |
|
| 333 |
% /© |
| 334 |
% |
| 335 |
% ------------------------------------------------ |
| 336 |
% The UNICODE-MATH package <wspr.io/unicode-math> |
| 337 |
% ------------------------------------------------ |
| 338 |
% This package is free software and may be redistributed and/or modified under |
| 339 |
% the conditions of the LaTeX Project Public License, version 1.3c or higher |
| 340 |
% (your choice): <http://www.latex-project.org/lppl/>. |
| 341 |
% ------------------------------------------------ |
| 342 |
% Copyright 2006-2019 Will Robertson, LPPL "maintainer" |
| 343 |
% Copyright 2010-2017 Philipp Stephani |
| 344 |
% Copyright 2011-2017 Joseph Wright |
| 345 |
% Copyright 2012-2015 Khaled Hosny |
| 346 |
% ------------------------------------------------ |
| 347 |
% |
| 348 |
% ©/ |