diff options
author | Karl Berry <karl@freefriends.org> | 2018-01-07 23:46:58 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-01-07 23:46:58 +0000 |
commit | f15ab98da224024bdcb9d2b70a263c7f6143a91b (patch) | |
tree | 8368ce018ac0869d5d556cc47b29de4770ad3e62 /Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx | |
parent | 6c0d576e1d48613f952b56e99e4dd9d59e41a265 (diff) |
unicode-math (7jan18)
git-svn-id: svn://tug.org/texlive/trunk@46240 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx | 533 |
1 files changed, 128 insertions, 405 deletions
diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx index 84f6f600e62..2aca97a2fa9 100644 --- a/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/um-code-compat.dtx @@ -1,4 +1,5 @@ %%^^A%% um-code-compat.dtx -- part of UNICODE-MATH <wspr.io/unicode-math> +%%^^A%% Compatibility with 3rd party packages. % \section{Compatibility} % @@ -6,52 +7,6 @@ %<*package> % \end{macrocode} % -% \begin{macro}{\@@_check_and_fix:NNnnnn} -% \darg{command} -% \darg{factory command} -% \darg{parameter text} -% \darg{expected replacement text} -% \darg{new replacement text for \LuaTeX} -% \darg{new replacement text for \XeTeX} -% Tries to patch \meta{command}. -% If \meta{command} is undefined, do nothing. -% Otherwise it must be a macro with the given \meta{parameter text} and \meta{expected replacement text}, created by the given \meta{factory command} or equivalent. -% In this case it will be overwritten using the \meta{parameter text} and the \meta{new replacement text for \LuaTeX} or the \meta{new replacement text for \XeTeX}, depending on the engine. -% Otherwise issue a warning and don’t overwrite. -% \begin{macrocode} -\cs_new_protected_nopar:Nn \@@_check_and_fix:NNnnnn - { - \cs_if_exist:NT #1 - { - \token_if_macro:NTF #1 - { - \group_begin: - #2 \@@_tmpa:w #3 { #4 } - \cs_if_eq:NNTF #1 \@@_tmpa:w - { - \msg_info:nnx { unicode-math } { patch-macro } - { \token_to_str:N #1 } - \group_end: - #2 #1 #3 -%<XE> { #6 } -%<LU> { #5 } - } - { - \msg_warning:nnxxx { unicode-math } { wrong-meaning } - { \token_to_str:N #1 } { \token_to_meaning:N #1 } - { \token_to_meaning:N \@@_tmpa:w } - \group_end: - } - } - { - \msg_warning:nnx { unicode-math } { macro-expected } - { \token_to_str:N #1 } - } - } - } -% \end{macrocode} -% \end{macro} -% % \begin{macro}{\@@_check_and_fix:NNnnn} % \darg{command} % \darg{factory command} @@ -61,39 +16,43 @@ % Tries to patch \meta{command}. % If \meta{command} is undefined, do nothing. % Otherwise it must be a macro with the given \meta{parameter text} and \meta{expected replacement text}, created by the given \meta{factory command} or equivalent. -% In this case it will be overwritten using the \meta{parameter text} and the \meta{new replacement text}. +% In this case it will be overwritten using the \meta{parameter text} and the \meta{new replacement text for \LuaTeX} or the \meta{new replacement text for \XeTeX}, depending on the engine. % Otherwise issue a warning and don’t overwrite. % \begin{macrocode} \cs_new_protected_nopar:Nn \@@_check_and_fix:NNnnn - { - \@@_check_and_fix:NNnnnn #1 #2 { #3 } { #4 } { #5 } { #5 } - } + { + \cs_if_exist:NT #1 + { + \token_if_macro:NTF #1 + { + \group_begin: + #2 \@@_tmpa:w #3 { #4 } + \cs_if_eq:NNTF #1 \@@_tmpa:w + { + \msg_info:nnx { unicode-math } { patch-macro } { \token_to_str:N #1 } + \group_end: + #2 #1 #3 { #5 } + } + { + \msg_warning:nnxxx { unicode-math } { wrong-meaning } + { \token_to_str:N #1 } { \token_to_meaning:N #1 } + { \token_to_meaning:N \@@_tmpa:w } + \group_end: + } + } + { + \msg_warning:nnx { unicode-math } { macro-expected } + { \token_to_str:N #1 } + } + } + } % \end{macrocode} % \end{macro} % -% \begin{macro}{\@@_check_and_fix_luatex:NNnnn} -% \begin{macro}{\@@_check_and_fix_luatex:cNnnn} -% \darg{command} -% \darg{factory command} -% \darg{parameter text} -% \darg{expected replacement text} -% \darg{new replacement text} -% Tries to patch \meta{command}. -% If \XeTeX\ is the current engine or \meta{command} is undefined, do nothing. -% Otherwise it must be a macro with the given \meta{parameter text} and \meta{expected replacement text}, created by the given \meta{factory command} or equivalent. -% In this case it will be overwritten using the \meta{parameter text} and the \meta{new replacement text}. -% Otherwise issue a warning and don’t overwrite. -% \begin{macrocode} -\cs_new_protected_nopar:Nn \@@_check_and_fix_luatex:NNnnn - { -%<LU> \@@_check_and_fix:NNnnn #1 #2 { #3 } { #4 } { #5 } - } -\cs_generate_variant:Nn \@@_check_and_fix_luatex:NNnnn { c } -% \end{macrocode} -% \end{macro} -% \end{macro} +% \section{Patching/augmenting 3rd-party packages} +% +% \subsection{\pkg{url}} % -% \paragraph{\pkg{url}} % Simply need to get \pkg{url} in a state such that % when it switches to math mode and enters \ascii\ characters, the maths % setup (i.e., \pkg{unicode-math}) doesn't remap the symbols into Plane 1. @@ -104,310 +63,70 @@ % font still work correctly. % \begin{macrocode} \AtEndOfPackageFile * {url} - { - \tl_put_left:Nn \Url@FormatString { \@@_switchto_up: } - \tl_put_right:Nn \UrlSpecials - { - \do\`{\mathchar`\`} - \do\'{\mathchar`\'} - \do\${\mathchar`\$} - \do\&{\mathchar`\&} - } - } + { + \tl_put_left:Nn \Url@FormatString { \@@_switchto_up: } + \tl_put_right:Nn \UrlSpecials + { + \do \` { \mathchar`\` } + \do \' { \mathchar`\' } + \do \$ { \mathchar`\$ } + \do \& { \mathchar`\& } + } + } % \end{macrocode} % -% \paragraph{\pkg{amsmath}} -% 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: -% \begin{macrocode} -\AtEndOfPackageFile * {amsmath} - { -%<*XE> - \tl_remove_once:Nn \@begindocumenthook - { - \mathchardef\std@minus\mathcode`\-\relax - \mathchardef\std@equal\mathcode`\=\relax - } - \def\std@minus{\Umathcharnum\Umathcodenum`\-\relax} - \def\std@equal{\Umathcharnum\Umathcodenum`\=\relax} -%</XE> -% \end{macrocode} % -% \begin{macrocode} - \cs_set:Npn \@cdots {\mathinner{\cdots}} - \cs_set_eq:NN \dotsb@ \cdots -% \end{macrocode} -% This isn't as clever as the \pkg{amsmath} definition but I think it works: -% \begin{macrocode} -%<*XE> - \def \resetMathstrut@ - {% - \setbox\z@\hbox{$($}%) - \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@ - } -% \end{macrocode} -% The |subarray| environment uses inappropriate font dimensions. -% \begin{macrocode} - \@@_check_and_fix:NNnnn \subarray \cs_set:Npn { #1 } - { - \vcenter - \bgroup - \Let@ - \restore@math@cr - \default@tag - \baselineskip \fontdimen 10~ \scriptfont \tw@ - \advance \baselineskip \fontdimen 12~ \scriptfont \tw@ - \lineskip \thr@@@@ \fontdimen 8~ \scriptfont \thr@@@@ - \lineskiplimit \lineskip - \ialign - \bgroup - \ifx c #1 \hfil \fi - $ \m@th \scriptstyle ## $ - \hfil - \crcr - } - { - \vcenter - \c_group_begin_token - \Let@ - \restore@math@cr - \default@tag - \skip_set:Nn \baselineskip - { -% \end{macrocode} -% Here we use stack top shift + stack bottom shift, which sounds reasonable. -% \begin{macrocode} - \@@_stack_num_up:N \scriptstyle - + \@@_stack_denom_down:N \scriptstyle - } -% \end{macrocode} -% Here we use the minimum stack gap. -% \begin{macrocode} - \lineskip \@@_stack_vgap:N \scriptstyle - \lineskiplimit \lineskip - \ialign - \c_group_begin_token - \token_if_eq_meaning:NNT c #1 { \hfil } - \c_math_toggle_token - \m@th - \scriptstyle - \c_parameter_token \c_parameter_token - \c_math_toggle_token - \hfil - \crcr - } -%</XE> -% \end{macrocode} -% The roots need a complete rework. -% \begin{macrocode} - \@@_check_and_fix_luatex:NNnnn \plainroot@ \cs_set_nopar:Npn { #1 \of #2 } - { - \setbox \rootbox \hbox - { - $ \m@th \scriptscriptstyle { #1 } $ - } - \mathchoice - { \r@@@@t \displaystyle { #2 } } - { \r@@@@t \textstyle { #2 } }~ - { \r@@@@t \scriptstyle { #2 } } - { \r@@@@t \scriptscriptstyle { #2 } } - \egroup - } - { - \bool_if:nTF - { - \int_compare_p:nNn { \uproot@ } = { \c_zero } - && \int_compare_p:nNn { \leftroot@ } = { \c_zero } - } - { - \Uroot \l_@@_radical_sqrt_tl { #1 } { #2 } - } - { - \hbox_set:Nn \rootbox - { - \c_math_toggle_token - \m@th - \scriptscriptstyle { #1 } - \c_math_toggle_token - } - \mathchoice - { \r@@@@t \displaystyle { #2 } } - { \r@@@@t \textstyle { #2 } } - { \r@@@@t \scriptstyle { #2 } } - { \r@@@@t \scriptscriptstyle { #2 } } - } - \c_group_end_token - } - \@@_check_and_fix:NNnnnn \r@@@@t \cs_set_nopar:Npn { #1 #2 } - { - \setboxz@h { $ \m@th #1 \sqrtsign { #2 } $ } - \dimen@ \ht\z@ - \advance \dimen@ -\dp\z@ - \setbox\@ne \hbox { $ \m@th #1 \mskip \uproot@ mu $ } - \advance \dimen@ by 1.667 \wd\@ne - \mkern -\leftroot@ mu - \mkern 5mu - \raise .6\dimen@ \copy\rootbox - \mkern -10mu - \mkern \leftroot@ mu - \boxz@ - } - { - \hbox_set:Nn \l_tmpa_box - { - \c_math_toggle_token - \m@th - #1 - \mskip \uproot@ mu - \c_math_toggle_token - } - \Uroot \l_@@_radical_sqrt_tl - { - \box_move_up:nn { \box_wd:N \l_tmpa_box } - { - \hbox:n - { - \c_math_toggle_token - \m@th - \mkern -\leftroot@ mu - \box_use:N \rootbox - \mkern \leftroot@ mu - \c_math_toggle_token - } - } - } - { #2 } - } - { - \hbox_set:Nn \l_tmpa_box - { - \c_math_toggle_token - \m@th - #1 - \sqrtsign { #2 } - \c_math_toggle_token - } - \hbox_set:Nn \l_tmpb_box - { - \c_math_toggle_token - \m@th - #1 - \mskip \uproot@ mu - \c_math_toggle_token - } - \mkern -\leftroot@ mu - \@@_mathstyle_scale:Nnn #1 { \kern } - { - \fontdimen 63 \l_@@_font - } - \box_move_up:nn - { - \box_wd:N \l_tmpb_box - + (\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box) - * \number \fontdimen 65 \l_@@_font / 100 - } - { - \box_use:N \rootbox - } - \@@_mathstyle_scale:Nnn #1 { \kern } - { - \fontdimen 64 \l_@@_font - } - \mkern \leftroot@ mu - \box_use_clear:N \l_tmpa_box - } - } -% \end{macrocode} +% \subsection{\pkg{mathtools}} % -% \paragraph{\pkg{amsopn}} -% This code is to improve the output of analphabetic symbols in text of operator names (\cs{sin}, \cs{cos}, etc.). Just comment out the offending lines for now: -% \begin{macrocode} -%<*XE> -\AtEndOfPackageFile * {amsopn} - { - \cs_set:Npn \newmcodes@ - { - \mathcode`\'39\scan_stop: - \mathcode`\*42\scan_stop: - \mathcode`\."613A\scan_stop: -%% \ifnum\mathcode`\-=45 \else -%% \mathchardef\std@minus\mathcode`\-\relax -%% \fi - \mathcode`\-45\scan_stop: - \mathcode`\/47\scan_stop: - \mathcode`\:"603A\scan_stop: - } - } -%</XE> -% \end{macrocode} -% -% \paragraph{\pkg{mathtools}} % \pkg{mathtools}’s |\cramped| command and others that make use of its internal version use an incorrect font dimension. % -% \begin{macrocode} -%<*XE> -\AtEndOfPackageFile * { mathtools } - { - \@@_check_and_fix:NNnnn - \MT_cramped_internal:Nn \cs_set_nopar:Npn { #1 #2 } - { - \sbox \z@ - { - $ - \m@th - #1 - \nulldelimiterspace = \z@ - \radical \z@ { #2 } - $ - } - \ifx #1 \displaystyle - \dimen@ = \fontdimen 8 \textfont 3 - \advance \dimen@ .25 \fontdimen 5 \textfont 2 - \else - \dimen@ = 1.25 \fontdimen 8 - \ifx #1 \textstyle - \textfont - \else - \ifx #1 \scriptstyle - \scriptfont - \else - \scriptscriptfont - \fi - \fi - 3 - \fi - \advance \dimen@ -\ht\z@ - \ht\z@ = -\dimen@ - \box\z@ - } -% \end{macrocode} % The \XeTeX\ version is pretty similar to the legacy version, only using the correct font dimensions. % Note we used `\verb|\XeTeXradical|' with the family 255 to be almost sure % that the radical rule width is not set. Former use of `\verb|\newfam|' had an % upsetting effect on legacy math alphabets. % \begin{macrocode} - { - \hbox_set:Nn \l_tmpa_box - { - \color@setgroup - \c_math_toggle_token - \m@th - #1 - \dim_zero:N \nulldelimiterspace - \XeTeXradical \c_two_hundred_fifty_five \c_zero { #2 } - \c_math_toggle_token - \color@endgroup - } - \box_set_ht:Nn \l_tmpa_box - { - \box_ht:N \l_tmpa_box -% \end{macrocode} -% Here we use the radical vertical gap. -% \begin{macrocode} - - \@@_radical_vgap:N #1 - } - \box_use_clear:N \l_tmpa_box +%<*XE> +\AtEndOfPackageFile * { mathtools } + { + \@@_check_and_fix:NNnnn \MT_cramped_internal:Nn \cs_set_nopar:Npn { #1 #2 } + { + \sbox \z@ { $ \m@th #1 \nulldelimiterspace = \z@ \radical \z@ { #2 } $ } + \ifx #1 \displaystyle + \dimen@ = \fontdimen 8 \textfont 3 + \advance \dimen@ .25 \fontdimen 5 \textfont 2 + \else + \dimen@ = 1.25 \fontdimen 8 + \ifx #1 \textstyle + \textfont + \else + \ifx #1 \scriptstyle + \scriptfont + \else + \scriptscriptfont + \fi + \fi + 3 + \fi + \advance \dimen@ -\ht\z@ + \ht\z@ = -\dimen@ + \box\z@ + } + { + \hbox_set:Nn \l_tmpa_box + { + \color@setgroup \c_math_toggle_token \m@th + #1 + \dim_zero:N \nulldelimiterspace + \XeTeXradical \c_two_hundred_fifty_five \c_zero { #2 } + \c_math_toggle_token \color@endgroup + } + \box_set_ht:Nn \l_tmpa_box + { + \box_ht:N \l_tmpa_box - \@@_radical_vgap:N #1 + } + \box_use_clear:N \l_tmpa_box } - } + } %</XE> % \end{macrocode} % @@ -416,40 +135,42 @@ % \pkg{mathtools}’s |\overbracket| and |\underbracket| take optional % arguments and are defined in terms of rules, so we keep them, and rename % ours to |\Uoverbracket| and |\Uunderbracket|. +% +% Original definition used the height of |\braceld| which is not available +% with Unicode fonts, so we are hard coding the $5/18$ex suggested by +% \pkg{mathtools}’s documentation. % \begin{macrocode} \AtEndOfPackageFile * { mathtools } - { + { \cs_set_eq:NN \MToverbracket \overbracket \cs_set_eq:NN \MTunderbracket \underbracket \AtBeginDocument - { - \msg_warning:nn { unicode-math } { mathtools-overbracket } + { + \msg_warning:nn { unicode-math } { mathtools-overbracket } - \def\downbracketfill#1#2 - {% -% \end{macrocode} -% Original definition used the height of |\braceld| which is not available -% with Unicode fonts, so we are hard coding the $5/18$ex suggested by -% \pkg{mathtools}’s documentation. -% \begin{macrocode} - \edef\l_MT_bracketheight_fdim{.27ex}% - \downbracketend{#1}{#2} + \cs_set:Npn \downbracketfill #1 #2 + { + \tl_set:Nn \l_MT_bracketheight_fdim {.27ex} + \downbracketend {#1} {#2} \leaders \vrule \@height #1 \@depth \z@ \hfill - \downbracketend{#1}{#2}% - } - \def\upbracketfill#1#2 - {% - \edef\l_MT_bracketheight_fdim{.27ex}% - \upbracketend{#1}{#2} + \downbracketend {#1} {#2} + } + + \cs_set:Npn \upbracketfill #1 #2 + { + \tl_set:Nn \l_MT_bracketheight_fdim {.27ex} + \upbracketend {#1} {#2} \leaders \vrule \@height \z@ \@depth #1 \hfill - \upbracketend{#1}{#2}% + \upbracketend {#1} {#2} + } + + \cs_set_eq:NN \Uoverbracket \overbracket + \cs_set_eq:NN \Uunderbracket \underbracket + \cs_set_eq:NN \overbracket \MToverbracket + \cs_set_eq:NN \underbracket \MTunderbracket } - \let\Uoverbracket =\overbracket - \let\Uunderbracket=\underbracket - \let\overbracket =\MToverbracket - \let\underbracket =\MTunderbracket - }% end of AtBeginDocument + } % \end{macrocode} % \end{macro} % \end{macro} @@ -464,19 +185,21 @@ % \cmd{\providecommand} \cmd{\AtBeginDocument}, we can just define the % offending commands here. % \begin{macrocode} - \msg_warning:nn { unicode-math } { mathtools-colon } - \NewDocumentCommand \dblcolon { } { \Colon } - \NewDocumentCommand \coloneqq { } { \coloneq } - \NewDocumentCommand \Coloneqq { } { \Coloneq } - \NewDocumentCommand \eqqcolon { } { \eqcolon } - } +\AtEndOfPackageFile * { mathtools } + { + \msg_warning:nn { unicode-math } { mathtools-colon } + \NewDocumentCommand \dblcolon { } { \Colon } + \NewDocumentCommand \coloneqq { } { \coloneq } + \NewDocumentCommand \Coloneqq { } { \Coloneq } + \NewDocumentCommand \eqqcolon { } { \eqcolon } + } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} % \end{macro} % -% \paragraph{\pkg{colonequals}} +% \subsection{\pkg{colonequals}} % % \begin{macro}{\ratio} % \begin{macro}{\coloncolon} @@ -489,15 +212,15 @@ % overwrite their definitions. % \begin{macrocode} \AtEndOfPackageFile * { colonequals } - { - \msg_warning:nn { unicode-math } { colonequals } - \RenewDocumentCommand \ratio { } { \mathratio } - \RenewDocumentCommand \coloncolon { } { \Colon } - \RenewDocumentCommand \minuscolon { } { \dashcolon } - \RenewDocumentCommand \colonequals { } { \coloneq } - \RenewDocumentCommand \equalscolon { } { \eqcolon } - \RenewDocumentCommand \coloncolonequals { } { \Coloneq } - } + { + \msg_warning:nn { unicode-math } { colonequals } + \RenewDocumentCommand \ratio { } { \mathratio } + \RenewDocumentCommand \coloncolon { } { \Colon } + \RenewDocumentCommand \minuscolon { } { \dashcolon } + \RenewDocumentCommand \colonequals { } { \coloneq } + \RenewDocumentCommand \equalscolon { } { \eqcolon } + \RenewDocumentCommand \coloncolonequals { } { \Coloneq } + } % \end{macrocode} % \end{macro} % \end{macro} @@ -521,7 +244,7 @@ % the conditions of the LaTeX Project Public License, version 1.3c or higher % (your choice): <http://www.latex-project.org/lppl/>. % ------------------------------------------------ -% Copyright 2006-2017 Will Robertson, LPPL "maintainer" +% Copyright 2006-2018 Will Robertson, LPPL "maintainer" % Copyright 2010-2017 Philipp Stephani % Copyright 2011-2017 Joseph Wright % Copyright 2012-2015 Khaled Hosny |