| 1 |
%%^^A%% um-code-compat.dtx -- part of UNICODE-MATH <wspr.io/unicode-math> |
| 2 |
%%^^A%% Compatibility with 3rd party packages. |
| 3 |
|
| 4 |
% \section{Compatibility} |
| 5 |
% |
| 6 |
% \begin{macrocode} |
| 7 |
%<*package> |
| 8 |
% \end{macrocode} |
| 9 |
% |
| 10 |
% |
| 11 |
% \section{Patching/augmenting 3rd-party packages} |
| 12 |
% |
| 13 |
% \subsection{\pkg{url}} |
| 14 |
% Here we need to get \pkg{url} in a state such that |
| 15 |
% when it switches to math mode and enters \ascii\ characters, the maths |
| 16 |
% setup (i.e., \pkg{unicode-math}) doesn't remap the symbols into Plane 1. |
| 17 |
% Which is what \cs{symliteral} is intended to do. |
| 18 |
% This is the same as writing, e.g., |\def\UrlFont{\ttfamily\@@_switch_to:n{literal}}| |
| 19 |
% but activates automatically so documents that might change the \cs{url} |
| 20 |
% font through the standard interface still work correctly. |
| 21 |
% \begin{macrocode} |
| 22 |
\@@_after_package:nNn {url} \@@_patch_url: |
| 23 |
{ |
| 24 |
\tl_put_left:Nn \Url@FormatString { \@@_switch_to:n {literal} } |
| 25 |
\tl_put_right:Nn \UrlSpecials |
| 26 |
{ |
| 27 |
\do \` { \mathchar`\` } |
| 28 |
\do \' { \mathchar`\' } |
| 29 |
\do \$ { \mathchar`\$ } |
| 30 |
\do \& { \mathchar`\& } |
| 31 |
} |
| 32 |
} |
| 33 |
% \end{macrocode} |
| 34 |
% |
| 35 |
% |
| 36 |
% \subsection{\pkg{mathtools}} |
| 37 |
% |
| 38 |
% \pkg{mathtools}’s |\cramped| command and others that make use of its internal version use an incorrect font dimension. |
| 39 |
% |
| 40 |
% The \XeTeX\ version is pretty similar to the legacy version, only using the correct font dimensions. |
| 41 |
% Note we used `\verb|\XeTeXradical|' with the family 255 to be almost sure |
| 42 |
% that the radical rule width is not set. Former use of `\verb|\newfam|' had an |
| 43 |
% upsetting effect on legacy math alphabets. |
| 44 |
% \begin{macrocode} |
| 45 |
%<*XE> |
| 46 |
\@@_after_package:nNn { mathtools } \@@_patch_mathtools_A: |
| 47 |
{ |
| 48 |
\cs_set_nopar:Npn \MT_cramped_internal:Nn ##1 ##2 |
| 49 |
{ |
| 50 |
\hbox_set:Nn \l_tmpa_box |
| 51 |
{ |
| 52 |
\color@setgroup \c_math_toggle_token \m@th |
| 53 |
##1 |
| 54 |
\dim_zero:N \nulldelimiterspace |
| 55 |
\XeTeXradical 255 ~ 0 ~ { ##2 } |
| 56 |
\c_math_toggle_token \color@endgroup |
| 57 |
} |
| 58 |
\box_set_ht:Nn \l_tmpa_box |
| 59 |
{ |
| 60 |
\box_ht:N \l_tmpa_box - \@@_radical_vgap:N ##1 |
| 61 |
} |
| 62 |
\box_use_drop:N \l_tmpa_box |
| 63 |
} |
| 64 |
} |
| 65 |
%</XE> |
| 66 |
% \end{macrocode} |
| 67 |
% |
| 68 |
% \begin{macro}{\overbracket} |
| 69 |
% \begin{macro}{\underbracket} |
| 70 |
% \pkg{mathtools}’s |\overbracket| and |\underbracket| take optional |
| 71 |
% arguments and are defined in terms of rules, so we keep them, and rename |
| 72 |
% ours to |\Uoverbracket| and |\Uunderbracket|. |
| 73 |
% |
| 74 |
% Original definition used the height of |\braceld| which is not available |
| 75 |
% with Unicode fonts, so we are hard coding the $5/18$ex suggested by |
| 76 |
% \pkg{mathtools}’s documentation. |
| 77 |
% \begin{macrocode} |
| 78 |
\@@_after_package:nNn { mathtools } \@@_patch_mathtools_B: |
| 79 |
{ |
| 80 |
\cs_set_eq:NN \MToverbracket \overbracket |
| 81 |
\cs_set_eq:NN \MTunderbracket \underbracket |
| 82 |
|
| 83 |
\AtBeginDocument |
| 84 |
{ |
| 85 |
\msg_warning:nn { unicode-math } { mathtools-overbracket } |
| 86 |
|
| 87 |
\cs_set:Npn \downbracketfill ##1 ##2 |
| 88 |
{ |
| 89 |
\tl_set:Nn \l_MT_bracketheight_fdim {.27ex} |
| 90 |
\downbracketend {##1} {##2} |
| 91 |
\leaders \vrule \@height ##1 \@depth \z@ \hfill |
| 92 |
\downbracketend {##1} {##2} |
| 93 |
} |
| 94 |
|
| 95 |
\cs_set:Npn \upbracketfill ##1 ##2 |
| 96 |
{ |
| 97 |
\tl_set:Nn \l_MT_bracketheight_fdim {.27ex} |
| 98 |
\upbracketend {##1} {##2} |
| 99 |
\leaders \vrule \@height \z@ \@depth ##1 \hfill |
| 100 |
\upbracketend {##1} {##2} |
| 101 |
} |
| 102 |
|
| 103 |
\cs_set_eq:NN \Uoverbracket \overbracket |
| 104 |
\cs_set_eq:NN \Uunderbracket \underbracket |
| 105 |
\cs_set_eq:NN \overbracket \MToverbracket |
| 106 |
\cs_set_eq:NN \underbracket \MTunderbracket |
| 107 |
} |
| 108 |
} |
| 109 |
% \end{macrocode} |
| 110 |
% \end{macro} |
| 111 |
% \end{macro} |
| 112 |
% |
| 113 |
% \begin{macro}{\dblcolon} |
| 114 |
% \begin{macro}{\coloneqq} |
| 115 |
% \begin{macro}{\Coloneqq} |
| 116 |
% \begin{macro}{\eqqcolon} |
| 117 |
% \pkg{mathtools} defines several commands as combinations of colons and |
| 118 |
% other characters, but with meanings incompatible to \pkg{unicode-math}. |
| 119 |
% Thus we issue a warning. Note \pkg{mathtools} uses |
| 120 |
% \cmd{\providecommand} \cmd{\AtBeginDocument}. |
| 121 |
% \begin{macrocode} |
| 122 |
\@@_after_package:nNn { mathtools } \@@_patch_mathtools_C: |
| 123 |
{ |
| 124 |
\msg_warning:nn { unicode-math } { mathtools-colon } |
| 125 |
\DeclareDocumentCommand \dblcolon { } { \Colon } |
| 126 |
\DeclareDocumentCommand \coloneqq { } { \coloneq } |
| 127 |
\DeclareDocumentCommand \Coloneqq { } { \Coloneq } |
| 128 |
\DeclareDocumentCommand \eqqcolon { } { \eqcolon } |
| 129 |
} |
| 130 |
% \end{macrocode} |
| 131 |
% \end{macro} |
| 132 |
% \end{macro} |
| 133 |
% \end{macro} |
| 134 |
% \end{macro} |
| 135 |
% |
| 136 |
% \begin{macrocode} |
| 137 |
%</package> |
| 138 |
% \end{macrocode} |
| 139 |
|
| 140 |
\endinput |
| 141 |
|
| 142 |
% /© |
| 143 |
% |
| 144 |
% ------------------------------------------------ |
| 145 |
% The UNICODE-MATH package <wspr.io/unicode-math> |
| 146 |
% ------------------------------------------------ |
| 147 |
% This package is free software and may be redistributed and/or modified under |
| 148 |
% the conditions of the LaTeX Project Public License, version 1.3c or higher |
| 149 |
% (your choice): <http://www.latex-project.org/lppl/>. |
| 150 |
% ------------------------------------------------ |
| 151 |
% Copyright 2006-2019 Will Robertson, LPPL "maintainer" |
| 152 |
% Copyright 2010-2017 Philipp Stephani |
| 153 |
% Copyright 2011-2017 Joseph Wright |
| 154 |
% Copyright 2012-2015 Khaled Hosny |
| 155 |
% ------------------------------------------------ |
| 156 |
% |
| 157 |
% ©/ |