From 8c01e7e9bb109cc006bac6234088ef1c55a7d072 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 13 Feb 2011 23:32:08 +0000 Subject: unicode-math 0.5d (13feb11) git-svn-id: svn://tug.org/texlive/trunk@21391 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/unicode-math/unicode-math-table.tex | 2 +- .../tex/latex/unicode-math/unicode-math.sty | 827 +++++++++++++++++---- 2 files changed, 692 insertions(+), 137 deletions(-) (limited to 'Master/texmf-dist/tex/latex/unicode-math') diff --git a/Master/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex b/Master/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex index 9f2f6c75cd5..32177250977 100644 --- a/Master/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex +++ b/Master/texmf-dist/tex/latex/unicode-math/unicode-math-table.tex @@ -255,7 +255,7 @@ \UnicodeMathSymbol{"021B6}{\curvearrowleft }{\mathrel}{left curved arrow}% \UnicodeMathSymbol{"021B7}{\curvearrowright }{\mathrel}{right curved arrow}% \UnicodeMathSymbol{"021B8}{\barovernorthwestarrow }{\mathord}{north west arrow to long bar}% -\UnicodeMathSymbol{"021B9}{\barleftarrowrightarrowba}{\mathord}{leftwards arrow to bar over rightwards arrow to bar}% +\UnicodeMathSymbol{"021B9}{\barleftarrowrightarrowbar}{\mathord}{leftwards arrow to bar over rightwards arrow to bar}% \UnicodeMathSymbol{"021BA}{\acwopencirclearrow }{\mathord}{anticlockwise open circle arrow}% \UnicodeMathSymbol{"021BB}{\cwopencirclearrow }{\mathord}{clockwise open circle arrow}% \UnicodeMathSymbol{"021BC}{\leftharpoonup }{\mathrel}{left harpoon-up}% diff --git a/Master/texmf-dist/tex/latex/unicode-math/unicode-math.sty b/Master/texmf-dist/tex/latex/unicode-math/unicode-math.sty index 00941ab020c..f282fb48645 100644 --- a/Master/texmf-dist/tex/latex/unicode-math/unicode-math.sty +++ b/Master/texmf-dist/tex/latex/unicode-math/unicode-math.sty @@ -7,7 +7,8 @@ %% unicode-math.dtx (with options: `preamble') %% unicode-math.dtx (with options: `msg') %% unicode-math.dtx (with options: `package,stix') -%% Copyright 2006-2010 by Will Robertson +%% Copyright 2006-2011 Will Robertson +%% Copyright 2010-2011 Philipp Stephani %% %% This package is free software and may be redistributed and/or modified under %% the conditions of the LaTeX Project Public License, version 1.3c or higher @@ -15,7 +16,7 @@ %% %% This work is "author-maintained" by Will Robertson. \ProvidesPackage{unicode-math} - [2010/09/27 v0.5b Unicode maths in XeLaTeX and LuaLaTeX] + [2011/01/29 v0.5d Unicode maths in XeLaTeX and LuaLaTeX] \usepackage{ifxetex,ifluatex} \ifxetex\else\ifluatex\else \PackageError{unicode-math}{% @@ -26,15 +27,12 @@ \RequirePackage{expl3}[2009/08/12] \RequirePackage{xparse}[2009/08/31] \RequirePackage{l3keys2e} -\RequirePackage{fontspec}[2010/05/18] +\RequirePackage{fontspec}[2010/10/25] \RequirePackage{catchfile} +\RequirePackage{trimspaces} +\RequirePackage{fix-cm} % avoid some warnings +\RequirePackage{filehook}[2011/01/03] \ExplSyntaxOn -\@ifclassloaded{memoir}{ - \cs_set_eq:NN \um_after_pkg:nn \AtEndPackage -}{ - \RequirePackage{scrlfile} - \cs_set_eq:NN \um_after_pkg:nn \AfterPackage -} \cs_generate_variant:Nn \tl_put_right:Nn {cx} \cs_generate_variant:Nn \seq_if_in:NnTF {NV} \cs_generate_variant:Nn \prop_gput:Nnn {Nxn} @@ -45,11 +43,14 @@ \cs:w #3 \exp_after:wN \cs_end: \cs:w #4 \cs_end: } -\bool_new:N \l_um_fontspec_feature_bool +\bool_new:N \c_um_have_fixed_accents_bool +\bool_set:Nn \c_um_have_fixed_accents_bool { + \c_luatex_is_engine_bool && \int_compare_p:n { \luatexversion > 64 } +} \bool_new:N \l_um_ot_math_bool \bool_new:N \l_um_init_bool \bool_new:N \l_um_implicit_alph_bool -\bool_new:N \g_um_mainfont_set_bool +\bool_new:N \g_um_mainfont_already_set_bool \bool_new:N \g_um_literal_bool \bool_new:N \g_um_upLatin_bool \bool_new:N \g_um_uplatin_bool @@ -67,6 +68,7 @@ \bool_new:N \g_um_literal_Nabla_bool \bool_new:N \g_um_literal_partial_bool \bool_new:N \g_um_texgreek_bool +\bool_gset_true:N \g_um_texgreek_bool \bool_new:N \l_um_smallfrac_bool \bool_new:N \g_um_literal_colon_bool \int_new:N \g_um_fam_int @@ -77,7 +79,7 @@ \tl_set:Nn \g_um_math_alphabet_name_num_tl {Numerals} \tl_set:Nn \g_um_math_alphabet_name_misc_tl {Misc.} \prg_new_conditional:Nnn \um_glyph_if_exist:n {p,TF,T,F} { - \etex_iffontchar:D \l_um_font #1 \scan_stop: + \iffontchar \l_um_font #1 \scan_stop: \prg_return_true: \else: \prg_return_false: @@ -102,10 +104,6 @@ \cs_new:Npn \um_warning:n { \msg_warning:nn {unicode-math} } \cs_new:Npn \um_trace:n { \msg_trace:nn {unicode-math} } \cs_new:Npn \um_trace:nx { \msg_trace:nnx {unicode-math} } -\msg_new:nnn {unicode-math} {maths-feature-only} -{ - The~ '#1'~ font~ feature~ can~ only~ be~ used~ for~ maths~ fonts. -} \msg_new:nnn {unicode-math} {disable-beamer} { Disabling~ beamer's~ math~ setup.\\ @@ -136,6 +134,43 @@ { Setup~ alphabet:~ #1. } +\msg_new:nnn {unicode-math} {macro-expected} +{ + I've~ expected~ that~ #1~ is~ a~ macro,~ but~ it~ isn't. +} +\msg_new:nnn {unicode-math} {wrong-meaning} +{ + I've~ expected~ #1~ to~ have~ the~ meaning~ #3,~ but~ it~ has~ the~ meaning~ #2. +} +\msg_new:nnn {unicode-math} {patch-macro} +{ + I'm~ going~ to~ patch~ macro~ #1. +} +\msg_new:nnn { unicode-math } { mathtools } { + I'm~ going~ to~ overwrite~ the~ following~ commands~ from \\ + the~ `mathtools'~ package: \\ + \token_to_str:N \dblcolon,~ + \token_to_str:N \coloneqq,~ + \token_to_str:N \Coloneqq,~ + \token_to_str:N \eqqcolon. \\ + Note~ that~ since~ I~ won't~ overwrite~ the~ other~ colon-like \\ + commands,~ using~ them~ will~ lead~ to~ inconsistencies. +} +\msg_new:nnn { unicode-math } { colonequals } { + I'm~ going~ to~ overwrite~ the~ following~ commands~ from \\ + the~ `colonequals'~ package: \\ + \token_to_str:N \ratio,~ + \token_to_str:N \coloncolon,~ + \token_to_str:N \minuscolon, \\ + \token_to_str:N \colonequals,~ + \token_to_str:N \equalscolon,~ + \token_to_str:N \coloncolonequals. \\ + Note~ that~ since~ I~ won't~ overwrite~ the~ other~ colon-like \\ + commands,~ using~ them~ will~ lead~ to~ inconsistencies. \\ + Furthermore,~ changing~ \token_to_str:N \colonsep \c_space_tl + or~ \token_to_str:N \doublecolonsep \c_space_tl won't~ have \\ + any~ effect~ on~ the~ re-defined~ commands. +} \cs_new:Npn \usv_set:nnn #1#2#3 { \tl_set:cn { \um_to_usv:nn {#1}{#2} } {#3} } @@ -817,6 +852,9 @@ \um_set_mathcode:nnn {#4} {#3} {#1} } } +\edef\mathfence{\string\mathfence} +\edef\mathover{\string\mathover} +\edef\mathunder{\string\mathunder} \cs_new:Npn \um_set_big_operator:nnn #1#2#3 { \group_begin: \char_make_active:n {#3} @@ -850,8 +888,25 @@ \cs_new:Npn \um_delimiter:Nnn #1#2#3 { \Udelimiter \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop: } -\cs_new:Npn \um_accent:Nnn #1#2#3 { +\xetex_or_luatex:nnn { \cs_new:Npn \um_accent:Nnn #1#2#3 } { \Umathaccent \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop: +} { + \Umathaccent \um_accent_keyword: \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop: +} +\luatex_if_engine:T { + \cs_new_nopar:Npn \um_wide_top_accent:Nnn #1 #2 #3 { + \Umathaccent \mathchar@type #1 \use:c { sym #2 } #3 \scan_stop: + } + \bool_if:NTF \c_um_have_fixed_accents_bool { + \cs_new_nopar:Npn \um_wide_bottom_accent:Nnn #1 #2 #3 { + \Umathaccent bottom~ \mathchar@type #1 \use:c { sym #2 } #3 \scan_stop: + } + \cs_new_protected_nopar:Npn \um_accent_keyword: { + \bool_if:NF \l_um_growing_accents_bool { fixed~ } + } + } { + \cs_new_nopar:Npn \um_accent_keyword: { } + } } \cs_generate_variant:Nn \um_set_mathchar:NNnn {c} \cs_set:Npn \um_overbrace:nnn #1#2#3 { @@ -913,47 +968,87 @@ } \DeclareSymbolFont{\um_symfont_tl} {\encodingdefault}{\zf@family}{\mddefault}{\updefault} - \bool_if:nT {\l_um_ot_math_bool && !\g_um_mainfont_set_bool} { - \bool_set_true:N \g_um_mainfont_set_bool + + \bool_if:nT {\l_um_ot_math_bool && !\g_um_mainfont_already_set_bool} { + \bool_set_true:N \g_um_mainfont_already_set_bool + \dim_compare:nF { \fontdimen 10 \l_um_font == 0pt } { + \DeclareMathSizes { \f@size } { \f@size } + { \um_fontdimen_to_percent:nn{10}{\l_um_font}\dimexpr \f@size pt\relax } + { \um_fontdimen_to_percent:nn{11}{\l_um_font}\dimexpr \f@size pt\relax } + } + \fontspec_select:xn {\l_um_font_keyval_tl, + Scale=1.00001, + FontAdjustment={ + \fontdimen8\font= \um_get_fontparam:nn {43} {FractionNumeratorDisplayStyleShiftUp}\relax + \fontdimen9\font= \um_get_fontparam:nn {42} {FractionNumeratorShiftUp}\relax + \fontdimen10\font=\um_get_fontparam:nn {32} {StackTopShiftUp}\relax + \fontdimen11\font=\um_get_fontparam:nn {45} {FractionDenominatorDisplayStyleShiftDown}\relax + \fontdimen12\font=\um_get_fontparam:nn {44} {FractionDenominatorShiftDown}\relax + \fontdimen13\font=\um_get_fontparam:nn {21} {SuperscriptShiftUp}\relax + \fontdimen14\font=\um_get_fontparam:nn {21} {SuperscriptShiftUp}\relax + \fontdimen15\font=\um_get_fontparam:nn {22} {SuperscriptShiftUpCramped}\relax + \fontdimen16\font=\um_get_fontparam:nn {18} {SubscriptShiftDown}\relax + \fontdimen17\font=\um_get_fontparam:nn {18} {SubscriptShiftDownWithSuperscript}\relax + \fontdimen18\font=\um_get_fontparam:nn {24} {SuperscriptBaselineDropMax}\relax + \fontdimen19\font=\um_get_fontparam:nn {20} {SubscriptBaselineDropMin}\relax + \fontdimen20\font=0pt\relax % delim1 = FractionDelimiterDisplaySize + \fontdimen21\font=0pt\relax % delim2 = FractionDelimiterSize + \fontdimen22\font=\um_get_fontparam:nn {15} {AxisHeight}\relax + } + } {#2} \DeclareSymbolFont{symbols} {\encodingdefault}{\zf@family}{\mddefault}{\updefault} + \fontspec_select:xn {\l_um_font_keyval_tl, + Scale=0.99999, + FontAdjustment={ + \fontdimen8\font= \um_get_fontparam:nn {48} {FractionRuleThickness}\relax + \fontdimen9\font= \um_get_fontparam:nn {28} {UpperLimitGapMin}\relax + \fontdimen10\font=\um_get_fontparam:nn {30} {LowerLimitGapMin}\relax + \fontdimen11\font=\um_get_fontparam:nn {29} {UpperLimitBaselineRiseMin}\relax + \fontdimen12\font=\um_get_fontparam:nn {31} {LowerLimitBaselineDropMin}\relax + \fontdimen13\font=0pt\relax + } + } {#2} \DeclareSymbolFont{largesymbols} {\encodingdefault}{\zf@family}{\mddefault}{\updefault} } \um_input_math_symbol_table: \um_remap_symbols: \um_setup_mathactives: + \um_setup_accents: \um_setup_delcodes: \um_setup_alphabets: \ignorespaces } +\xetex_or_luatex:nnn { \cs_new:Nn \um_get_fontparam:nn } { + \the\fontdimen#1\zf@basefont\relax +}{ + \directlua{fontspec.mathfontdimen("zf@basefont","#2")} +} \DeclareDocumentCommand \resetmathfont { O{} m } { - \bool_set_false:N \g_um_mainfont_set_bool + \bool_set_false:N \g_um_mainfont_already_set_bool \setmathfont[#1]{#2} } \cs_new:Npn \um_fontspec_select_font:n #1 { - \bool_set_true:N \l_um_fontspec_feature_bool - \fontspec_select:xn - { - \luatex_if_engine:T { Renderer = Basic, } - BoldFont = {}, ItalicFont = {}, - Script = Math, - SizeFeatures = { - {Size = \tf@size-} , - {Size = \sf@size-\tf@size , - Font = \l_um_script_font_tl , - \l_um_script_features_tl - } , - {Size = -\sf@size , - Font = \l_um_sscript_font_tl , - \l_um_sscript_features_tl - } - }, - \l_um_unknown_keys_clist - } - {#1} + \tl_set:Nx \l_um_font_keyval_tl { + \luatex_if_engine:T { Renderer = Basic, } + BoldFont = {}, ItalicFont = {}, + Script = Math, + SizeFeatures = { + {Size = \tf@size-} , + {Size = \sf@size-\tf@size , + Font = \l_um_script_font_tl , + \l_um_script_features_tl + } , + {Size = -\sf@size , + Font = \l_um_sscript_font_tl , + \l_um_sscript_features_tl + } + }, + \l_um_unknown_keys_clist + } + \fontspec_select:xn {\l_um_font_keyval_tl} {#1} \tl_set_eq:NN \l_um_font \zf@basefont - \bool_set_false:N \l_um_fontspec_feature_bool } \cs_set:Npn \um_process_symbol_noparse:nnn #1#2#3 { \um_set_mathsymbol:nNNn {\um_symfont_tl} #2#3{#1} @@ -1055,23 +1150,140 @@ \tl_remove_all_in:Nn \l_um_nolimits_tl {#1} } \tl_new:Nn \l_um_radicals_tl {\sqrt} -\let\left@primitive\left -\def\left{\mathopen{}\left@primitive} -\newcommand\um@zf@feature[2]{ - \define@key[zf]{options}{#1}[]{ - \bool_if:NTF \l_um_fontspec_feature_bool { - #2 - }{ - \um_warning:n {maths-feature-only} +\cs_new_protected_nopar:Npn \um_new_cramped_style:N #1 { + \xetex_or_luatex:nn { + \quark_new:N #1 + } { + \cs_new_eq:Nc #1 { luatex \cs_to_str:N #1 } + } +} +\um_new_cramped_style:N \crampeddisplaystyle +\um_new_cramped_style:N \crampedtextstyle +\um_new_cramped_style:N \crampedscriptstyle +\um_new_cramped_style:N \crampedscriptscriptstyle +\xetex_if_engine:T { + \cs_new_nopar:Npn \um_font_dimen:Nnnnn #1 #2 #3 #4 #5 { + \fontdimen + \cs_if_eq:NNTF #1 \displaystyle { + #2 \textfont + } { + \cs_if_eq:NNTF #1 \crampeddisplaystyle { + #3 \textfont + } { + \cs_if_eq:NNTF #1 \textstyle { + #4 \textfont + } { + \cs_if_eq:NNTF #1 \crampedtextstyle { + #5 \textfont + } { + \cs_if_eq:NNTF #1 \scriptstyle { + #4 \scriptfont + } { + \cs_if_eq:NNTF #1 \crampedscriptstyle { + #5 \scriptfont + } { + \cs_if_eq:NNTF #1 \scriptscriptstyle { + #4 \scriptscriptfont + } { + #5 \scriptscriptfont + } + } + } + } + } + } } - } -} -\xetex_or_luatex:nnn { \um@zf@feature {ScriptStyle} } - { \fontspec_update_featstr:n {+ssty=0} } - { \fontspec_update_featstr:n {+ssty=1} } -\xetex_or_luatex:nnn { \um@zf@feature {ScriptScriptStyle} } - { \fontspec_update_featstr:n {+ssty=1} } - { \fontspec_update_featstr:n {+ssty=2} } + \c_two + } +} +\xetex_or_luatex:nnn { + \cs_new_protected_nopar:Npn \um_font_param:nnnnn #1 #2 #3 #4 #5 +} { + \um_font_param_aux:ccnnnn { um_ #1 :N } { um_set_ #1 :N } + { #2 } { #3 } { #4 } { #5 } +} { + \tl_set:Nn \l_um_tmpa_tl { #1 } + \tl_remove_all_in:Nn \l_um_tmpa_tl { _ } + \um_font_param_aux:ccc { um_ #1 :N } { um_set_ #1 :N } + { luatexUmath \l_um_tmpa_tl } +} +\cs_new_protected_nopar:Npn \um_font_param:nnn #1 #2 #3 { + \um_font_param:nnnnn { #1 } { #2 } { #2 } { #3 } { #3 } +} +\cs_new_protected_nopar:Npn \um_font_param:nn #1 #2 { + \um_font_param:nnnnn { #1 } { #2 } { #2 } { #2 } { #2 } +} +\xetex_or_luatex:nnn { + \cs_new_protected_nopar:Npn \um_font_param:n #1 +} { } { + \um_font_param:nnnnn { #1 } { 0 } { 0 } { 0 } { 0 } +} +\xetex_or_luatex:nn { + \cs_new_protected_nopar:Npn \um_font_param_aux:NNnnnn #1 #2 #3 #4 #5 #6 { + \cs_new_nopar:Npn #1 ##1 { + \um_font_dimen:Nnnnn ##1 { #3 } { #4 } { #5 } { #6 } + } + \cs_new_protected_nopar:Npn #2 ##1 ##2 { + #1 ##1 \dim_eval:n { ##2 } + } + } + \cs_generate_variant:Nn \um_font_param_aux:NNnnnn { cc } +} { + \cs_new_protected_nopar:Npn \um_font_param_aux:NNN #1 #2 #3 { + \cs_new_nopar:Npn #1 ##1 { + #3 ##1 + } + \cs_new_protected_nopar:Npn #2 ##1 ##2 { + #3 ##1 \dim_eval:n { ##2 } + } + } + \cs_generate_variant:Nn \um_font_param_aux:NNN { ccc } +} +\um_font_param:nn { axis } { 15 } +\um_font_param:nn { operator_size } { 13 } +\um_font_param:n { fraction_del_size } +\um_font_param:nnn { fraction_denom_down } { 45 } { 44 } +\um_font_param:nnn { fraction_denom_vgap } { 50 } { 49 } +\um_font_param:nnn { fraction_num_up } { 43 } { 42 } +\um_font_param:nnn { fraction_num_vgap } { 47 } { 46 } +\um_font_param:nn { fraction_rule } { 48 } +\um_font_param:nn { limit_above_bgap } { 29 } +\um_font_param:n { limit_above_kern } +\um_font_param:nn { limit_above_vgap } { 28 } +\um_font_param:nn { limit_below_bgap } { 31 } +\um_font_param:n { limit_below_kern } +\um_font_param:nn { limit_below_vgap } { 30 } +\um_font_param:nn { over_delimiter_vgap } { 41 } +\um_font_param:nn { over_delimiter_bgap } { 38 } +\um_font_param:nn { under_delimiter_vgap } { 40 } +\um_font_param:nn { under_delimiter_bgap } { 39 } +\um_font_param:nn { overbar_kern } { 55 } +\um_font_param:nn { overbar_rule } { 54 } +\um_font_param:nn { overbar_vgap } { 53 } +\um_font_param:n { quad } +\um_font_param:nn { radical_kern } { 62 } +\um_font_param:nn { radical_rule } { 61 } +\um_font_param:nnn { radical_vgap } { 60 } { 59 } +\um_font_param:nn { radical_degree_before } { 63 } +\um_font_param:nn { radical_degree_after } { 64 } +\um_font_param:nn { radical_degree_raise } { 65 } +\um_font_param:nn { space_after_script } { 27 } +\um_font_param:nnn { stack_denom_down } { 35 } { 34 } +\um_font_param:nnn { stack_num_up } { 33 } { 32 } +\um_font_param:nnn { stack_vgap } { 37 } { 36 } +\um_font_param:nn { sub_shift_down } { 18 } +\um_font_param:nn { sub_shift_drop } { 20 } +\um_font_param:n { subsup_shift_down } +\um_font_param:nn { sub_top_max } { 19 } +\um_font_param:nn { subsup_vgap } { 25 } +\um_font_param:nn { sup_bottom_min } { 23 } +\um_font_param:nn { sup_shift_drop } { 24 } +\um_font_param:nnnnn { sup_shift_up } { 21 } { 22 } { 21 } { 22 } +\um_font_param:nn { supsub_bottom_max } { 26 } +\um_font_param:nn { underbar_kern } { 58 } +\um_font_param:nn { underbar_rule } { 57 } +\um_font_param:nn { underbar_vgap } { 56 } +\um_font_param:n { connector_overlap_min } \keys_define:nn {unicode-math} { script-features .tl_set:N = \l_um_script_features_tl , @@ -1303,12 +1515,13 @@ \exp_after:wN \use_none:nnnnn \token_to_str:N #1 } \clist_map_inline:nn {#2} { - \cs_if_exist:cT {um_config_ \l_um_style_tl _##1:n} { - \str_if_eq:nnTF {##1}{misc} { + \tl_set:Nx \l_um_tmpa_tl { \trim@spaces {##1} } + \cs_if_exist:cT {um_config_ \l_um_style_tl _\l_um_tmpa_tl :n} { + \str_if_eq:xxTF {\l_um_tmpa_tl}{misc} { \um_maybe_init_alphabet:V \l_um_style_tl \clist_map_break: }{ - \um_glyph_if_exist:cT { \um_to_usv:nn {#3}{##1} }{ + \um_glyph_if_exist:cT { \um_to_usv:nn {#3}{\l_um_tmpa_tl} }{ \um_maybe_init_alphabet:V \l_um_style_tl \clist_map_break: } @@ -1316,22 +1529,23 @@ } } \clist_map_inline:nn {#2} { - \cs_if_exist:cT {um_config_ \l_um_style_tl _##1:n} { - \str_if_eq:nnTF {##1}{misc} { - \um_trace:nx {setup-alph} {math \l_um_style_tl~(##1)} - \use:c {um_config_ \l_um_style_tl _##1:n} {#3} + \tl_set:Nx \l_um_tmpa_tl { \trim@spaces {##1} } + \cs_if_exist:cT {um_config_ \l_um_style_tl _ \l_um_tmpa_tl :n} { + \str_if_eq:xxTF {\l_um_tmpa_tl}{misc} { + \um_trace:nx {setup-alph} {math \l_um_style_tl~(\l_um_tmpa_tl)} + \use:c {um_config_ \l_um_style_tl _ \l_um_tmpa_tl :n} {#3} }{ - \um_glyph_if_exist:cTF { \um_to_usv:nn {#3}{##1} } { - \um_trace:nx {setup-alph} {math \l_um_style_tl~(##1)} - \use:c {um_config_ \l_um_style_tl _##1:n} {#3} + \um_glyph_if_exist:cTF { \um_to_usv:nn {#3}{\l_um_tmpa_tl} } { + \um_trace:nx {setup-alph} {math \l_um_style_tl~(\l_um_tmpa_tl)} + \use:c {um_config_ \l_um_style_tl _ \l_um_tmpa_tl :n} {#3} }{ \bool_if:NTF \l_um_implicit_alph_bool { \seq_put_right:Nx \l_um_missing_alph_seq { \@backslashchar math \l_um_style_tl \space - (\tl_use:c{g_um_math_alphabet_name_##1_tl}) + (\tl_use:c{g_um_math_alphabet_name_ \l_um_tmpa_tl _tl}) } }{ - \use:c {um_config_ \l_um_style_tl _##1:n} {up} + \use:c {um_config_ \l_um_style_tl _ \l_um_tmpa_tl :n} {up} } } } @@ -2091,9 +2305,6 @@ } \xetex_or_luatex:nnn { \cs_set:Npn \um_symbol_setup: } { - \def\mathfence{\mathfence} - \def\mathover{\mathover} - \def\mathunder{\mathunder} \cs_set:Npn \UnicodeMathSymbol ##1##2##3##4 { \prg_case_tl:Nnn ##3 { \mathover {} \mathunder {} } { @@ -2135,16 +2346,17 @@ } } \endgroup -\AtBeginDocument{ +\AtBeginDocument{\um_define_math_chars:} +\cs_set:Nn \um_define_math_chars: { \group_begin: \char_make_math_superscript:N \^ - \cs_set:Npn \_um_sym:nnn #1#2#3 { - \bool_if:nF { \cs_if_eq_p:NN #3 \mathaccent || - \cs_if_eq_p:NN #3 \mathopen || - \cs_if_eq_p:NN #3 \mathclose || - \cs_if_eq_p:NN #3 \mathover || - \cs_if_eq_p:NN #3 \mathunder } { - \um_cs_set_eq_active_char:Nw #2 = #1 \q_nil \ignorespaces + \cs_set:Npn \_um_sym:nnn ##1##2##3 { + \bool_if:nF { \cs_if_eq_p:NN ##3 \mathaccent || + \cs_if_eq_p:NN ##3 \mathopen || + \cs_if_eq_p:NN ##3 \mathclose || + \cs_if_eq_p:NN ##3 \mathover || + \cs_if_eq_p:NN ##3 \mathunder } { + \um_cs_set_eq_active_char:Nw ##2 = ##1 \q_nil \ignorespaces } } \char_make_other:N \# @@ -2216,18 +2428,38 @@ } } \cs_new:Npn \um_scan_prime: { + \cs_set_eq:NN \um_superscript:n \use:n \int_zero:N \l_um_primecount_int \um_scanprime_collect:N \um_prime_single_mchar } \cs_new:Npn \um_scan_dprime: { + \cs_set_eq:NN \um_superscript:n \use:n \int_set:Nn \l_um_primecount_int {1} \um_scanprime_collect:N \um_prime_single_mchar } \cs_new:Npn \um_scan_trprime: { + \cs_set_eq:NN \um_superscript:n \use:n \int_set:Nn \l_um_primecount_int {2} \um_scanprime_collect:N \um_prime_single_mchar } \cs_new:Npn \um_scan_qprime: { + \cs_set_eq:NN \um_superscript:n \use:n + \int_set:Nn \l_um_primecount_int {3} + \um_scanprime_collect:N \um_prime_single_mchar +} +\cs_new:Npn \um_scan_sup_prime: { + \int_zero:N \l_um_primecount_int + \um_scanprime_collect:N \um_prime_single_mchar +} +\cs_new:Npn \um_scan_sup_dprime: { + \int_set:Nn \l_um_primecount_int {1} + \um_scanprime_collect:N \um_prime_single_mchar +} +\cs_new:Npn \um_scan_sup_trprime: { + \int_set:Nn \l_um_primecount_int {2} + \um_scanprime_collect:N \um_prime_single_mchar +} +\cs_new:Npn \um_scan_sup_qprime: { \int_set:Nn \l_um_primecount_int {3} \um_scanprime_collect:N \um_prime_single_mchar } @@ -2278,14 +2510,29 @@ } } \cs_new:Npn \um_scan_backprime: { + \cs_set_eq:NN \um_superscript:n \use:n \int_zero:N \l_um_primecount_int \um_scanbackprime_collect:N \um_backprime_single_mchar } \cs_new:Npn \um_scan_backdprime: { + \cs_set_eq:NN \um_superscript:n \use:n \int_set:Nn \l_um_primecount_int {1} \um_scanbackprime_collect:N \um_backprime_single_mchar } \cs_new:Npn \um_scan_backtrprime: { + \cs_set_eq:NN \um_superscript:n \use:n + \int_set:Nn \l_um_primecount_int {2} + \um_scanbackprime_collect:N \um_backprime_single_mchar +} +\cs_new:Npn \um_scan_sup_backprime: { + \int_zero:N \l_um_primecount_int + \um_scanbackprime_collect:N \um_backprime_single_mchar +} +\cs_new:Npn \um_scan_sup_backdprime: { + \int_set:Nn \l_um_primecount_int {1} + \um_scanbackprime_collect:N \um_backprime_single_mchar +} +\cs_new:Npn \um_scan_sup_backtrprime: { \int_set:Nn \l_um_primecount_int {2} \um_scanbackprime_collect:N \um_backprime_single_mchar } @@ -2325,14 +2572,15 @@ } } } -\AtBeginDocument { - \cs_set_eq:NN \prime \um_scan_prime: - \cs_set_eq:NN \drime \um_scan_dprime: - \cs_set_eq:NN \trprime \um_scan_trprime: - \cs_set_eq:NN \qprime \um_scan_qprime: - \cs_set_eq:NN \backprime \um_scan_backprime: - \cs_set_eq:NN \backdprime \um_scan_backdprime: - \cs_set_eq:NN \backtrprime \um_scan_backtrprime: +\AtBeginDocument{\um_define_prime_commands: \um_define_prime_chars:} +\cs_set:Nn \um_define_prime_commands: { + \cs_set_eq:NN \prime \um_prime_single_mchar + \cs_set_eq:NN \drime \um_prime_double_mchar + \cs_set_eq:NN \trprime \um_prime_triple_mchar + \cs_set_eq:NN \qprime \um_prime_quad_mchar + \cs_set_eq:NN \backprime \um_backprime_single_mchar + \cs_set_eq:NN \backdprime \um_backprime_double_mchar + \cs_set_eq:NN \backtrprime \um_backprime_triple_mchar } \group_begin: \char_make_active:N \' @@ -2344,39 +2592,53 @@ \char_make_active:n {"2035} \char_make_active:n {"2036} \char_make_active:n {"2037} - \AtBeginDocument{ - \cs_set_eq:NN ' \um_scan_prime: - \cs_set_eq:NN ^^^^2032 \um_scan_prime: - \cs_set_eq:NN ^^^^2033 \um_scan_dprime: - \cs_set_eq:NN ^^^^2034 \um_scan_trprime: - \cs_set_eq:NN ^^^^2057 \um_scan_qprime: - \cs_set_eq:NN ` \um_scan_backprime: - \cs_set_eq:NN ^^^^2035 \um_scan_backprime: - \cs_set_eq:NN ^^^^2036 \um_scan_backdprime: - \cs_set_eq:NN ^^^^2037 \um_scan_backtrprime: + \cs_gset:Nn \um_define_prime_chars: { + \cs_set_eq:NN ' \um_scan_sup_prime: + \cs_set_eq:NN ^^^^2032 \um_scan_sup_prime: + \cs_set_eq:NN ^^^^2033 \um_scan_sup_dprime: + \cs_set_eq:NN ^^^^2034 \um_scan_sup_trprime: + \cs_set_eq:NN ^^^^2057 \um_scan_sup_qprime: + \cs_set_eq:NN ` \um_scan_sup_backprime: + \cs_set_eq:NN ^^^^2035 \um_scan_sup_backprime: + \cs_set_eq:NN ^^^^2036 \um_scan_sup_backdprime: + \cs_set_eq:NN ^^^^2037 \um_scan_sup_backtrprime: } \group_end: -\luatex_if_engine:T { - \RenewDocumentCommand \sqrt { O{} m } { - \luatexUroot \l_um_radical_sqrt_tl {#1} {#2} +\AtBeginDocument{\um_redefine_radical:} +\xetex_or_luatex:nnn { \cs_set:Nn \um_redefine_radical: } { + \@ifpackageloaded { amsmath } { } { + \cs_set_nopar:Npn \r@@t ##1 ##2 { + \hbox_set:Nn \l_tmpa_box { + \c_math_shift_token + \m@th + ##1 + \sqrtsign { ##2 } + \c_math_shift_token + } + \um_mathstyle_scale:Nnn ##1 { \kern } { + \fontdimen 63 \l_um_font + } + \box_move_up:nn { + (\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box) + * \number \fontdimen 65 \l_um_font / 100 + } { + \box_use:N \rootbox + } + \um_mathstyle_scale:Nnn ##1 { \kern } { + \fontdimen 64 \l_um_font + } + \box_use_clear:N \l_tmpa_box + } } - \cs_set:Npn \root #1 \of #2 { - \luatexUroot \l_um_radical_sqrt_tl {#1} {#2} +} { + \@ifpackageloaded { amsmath } { } { + \cs_set:Npn \root ##1 \of ##2 { + \luatexUroot \l_um_radical_sqrt_tl { ##1 } { ##2 } + } } } -\cs_set_nopar:Npn \r@@t #1#2 { - \setbox\z@\hbox{$\m@th #1\sqrtsign{#2}$} - \um_mathstyle_scale:Nnn{#1}{\kern}{\fontdimen63\l_um_font} - \raise \dimexpr( - \um_fontdimen_to_percent:nn{65}{\l_um_font}\ht\z@- - \um_fontdimen_to_percent:nn{65}{\l_um_font}\dp\z@ - )\relax - \copy \rootbox - \um_mathstyle_scale:Nnn{#1}{\kern}{\fontdimen64\l_um_font} - \box \z@ -} \cs_new:Npn \um_fontdimen_to_percent:nn #1#2 { - 0.\strip@pt\dimexpr\fontdimen#1#2 *65536\relax + \strip@pt\dimexpr\fontdimen#1#2*65536/100\relax } \cs_new:Npn \um_mathstyle_scale:Nnn #1#2#3 { \ifx#1\scriptstyle @@ -2539,7 +2801,6 @@ } \um_setup_active_frac: \def\to{\rightarrow} -\def\overrightarrow{\vec} \def\le{\leq} \def\ge{\geq} \def\neq{\ne} @@ -2552,6 +2813,10 @@ \def\diamond{\smwhtdiamond} \def\emptyset{\varnothing} \def\hbar{\hslash} +\def\land{\wedge} +\def\lor{\vee} +\def\owns{\ni} +\def\gets{\leftarrow} \def\backepsilon{\upbackepsilon} \def\eth{\matheth} \def\smallint{{\textstyle\int}\limits} @@ -2564,20 +2829,58 @@ } \def\mathrm{\mathup} \let\mathfence\mathord -\luatex_if_engine:T { - \cs_set:Npn \overline {\pdfprimitive\overline} -} \def\digamma{\updigamma} \def\Digamma{\upDigamma} \def\operator@font{\um_switchto_mathup:} -\cs_new:Npn \um_patch_pkg:nn #1#2 { - \@ifpackageloaded {#1} { - #2 - }{ - \um_after_pkg:nn {#1} {#2} +\chk_if_free_cs:N \um_tmpa:w +\cs_new_protected_nopar:Npn \um_check_and_fix:NNnnnn #1 #2 #3 #4 #5 #6 { + \cs_if_exist:NT #1 { + \token_if_macro:NTF #1 { + \group_begin: + #2 \um_tmpa:w #3 { #4 } + \cs_if_eq:NNTF #1 \um_tmpa:w { + \msg_info:nnx { unicode-math } { patch-macro } + { \token_to_str:N #1 } + \group_end: + \xetex_or_luatex:nnn { #2 #1 #3 } { #6 } { #5 } + } { + \msg_warning:nnxxx { unicode-math } { wrong-meaning } + { \token_to_str:N #1 } { \token_to_meaning:N #1 } + { \token_to_meaning:N \um_tmpa:w } + \group_end: + } + } { + \msg_warning:nnx { unicode-math } { macro-expected } + { \token_to_str:N #1 } + } } } -\um_patch_pkg:nn {url} { +\cs_new_protected_nopar:Npn \um_check_and_fix:NNnnn #1 #2 #3 #4 #5 { + \um_check_and_fix:NNnnnn #1 #2 { #3 } { #4 } { #5 } { #5 } +} +\cs_new_protected_nopar:Npn \um_check_and_fix_luatex:NNnnn #1 #2 #3 #4 #5 { + \luatex_if_engine:T { + \um_check_and_fix:NNnnn #1 #2 { #3 } { #4 } { #5 } + } +} +\cs_generate_variant:Nn \um_check_and_fix_luatex:NNnnn { c } +\luatex_if_engine:T { + \AtBeginDocument{\um_patch_amsmath:} + \cs_set:Nn \um_patch_amsmath: { + \@ifpackageloaded { amsmath } { } { + \um_check_and_fix:NNnnn \frac \cs_set_nopar:Npn { ##1 ##2 } { + { + \begingroup ##1 \endgroup \over ##2 + } + } { + { + \luatexUstack { \group_begin: ##1 \group_end: \over ##2 } + } + } + } + } +} +\AtEndOfPackageFile * {url} { \tl_put_left:Nn \Url@FormatString { \um_switchto_mathup: } \tl_put_right:Nn \UrlSpecials { \do\`{\mathchar`\`} @@ -2586,7 +2889,7 @@ \do\&{\mathchar`\&} } } -\um_patch_pkg:nn {amsmath} { +\AtEndOfPackageFile * {amsmath} { \tl_remove_in:Nn \@begindocumenthook { \mathchardef\std@minus\mathcode`\-\relax \mathchardef\std@equal\mathcode`\=\relax @@ -2596,11 +2899,171 @@ \cs_set:Npn \@cdots {\mathinner{\cdots}} \cs_set_eq:NN \dotsb@ \cdots \def \resetMathstrut@ {% - \setbox\z@\hbox{$($}% + \setbox\z@\hbox{$($}%) \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@ } + \um_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 { + \um_stack_num_up:N \scriptstyle + + \um_stack_denom_down:N \scriptstyle + } + \lineskip \um_stack_vgap:N \scriptstyle + \lineskiplimit \lineskip + \ialign + \c_group_begin_token + \token_if_eq_meaning:NNT c #1 { \hfil } + \c_math_shift_token + \m@th + \scriptstyle + \c_parameter_token \c_parameter_token + \c_math_shift_token + \hfil + \crcr + } + \um_check_and_fix_luatex:cNnnn { frac~ } \cs_set:Npn { #1 #2 } { + { + \begingroup #1 \endgroup \@@over #2 + } + } { + { + \luatexUstack { \group_begin: #1 \group_end: \@@over #2 } + } + } + \um_check_and_fix_luatex:NNnnn \@genfrac \cs_set_nopar:Npn { + #1 #2 #3 #4 #5 + } { + { + #1 { \begingroup #4 \endgroup #2 #3 \relax #5 } + } + } { + { + #1 { + \luatexUstack { + \group_begin: #4 \group_end: #2 #3 \scan_stop: #5 + } + } + } + } + \um_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 } + } { + \luatexUroot \l_um_radical_sqrt_tl { #1 } { #2 } + } { + \hbox_set:Nn \rootbox { + \c_math_shift_token + \m@th + \scriptscriptstyle { #1 } + \c_math_shift_token + } + \mathchoice + { \r@@t \displaystyle { #2 } } + { \r@@t \textstyle { #2 } } + { \r@@t \scriptstyle { #2 } } + { \r@@t \scriptscriptstyle { #2 } } + } + \c_group_end_token + } + \um_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_shift_token + \m@th + #1 + \mskip \uproot@ mu + \c_math_shift_token + } + \luatexUroot \l_um_radical_sqrt_tl { + \box_move_up:nn { \box_wd:N \l_tmpa_box } { + \hbox:n { + \c_math_shift_token + \m@th + \mkern -\leftroot@ mu + \box_use:N \rootbox + \mkern \leftroot@ mu + \c_math_shift_token + } + } + } { + #2 + } + } { + \hbox_set:Nn \l_tmpa_box { + \c_math_shift_token + \m@th + #1 + \sqrtsign { #2 } + \c_math_shift_token + } + \hbox_set:Nn \l_tmpb_box { + \c_math_shift_token + \m@th + #1 + \mskip \uproot@ mu + \c_math_shift_token + } + \mkern -\leftroot@ mu + \um_mathstyle_scale:Nnn #1 { \kern } { + \fontdimen 63 \l_um_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_um_font / 100 + } { + \box_use:N \rootbox + } + \um_mathstyle_scale:Nnn #1 { \kern } { + \fontdimen 64 \l_um_font + } + \mkern \leftroot@ mu + \box_use_clear:N \l_tmpa_box + } } -\um_patch_pkg:nn {amsopn} { +\AtEndOfPackageFile * {amsopn} { \cs_set:Npn \newmcodes@ { \mathcode`\'39\scan_stop: \mathcode`\*42\scan_stop: @@ -2616,20 +3079,112 @@ \cs_set:Npn \| {\Vert} \cs_set:Npn \mathellipsis {\mathinner{\unicodeellipsis}} \cs_set:Npn \cdots {\mathinner{\unicodecdots}} -\AtBeginDocument{ +\xetex_or_luatex:nnn { \cs_new_protected_nopar:Npn \um_setup_accents: } { \def\widehat{\hat} \def\widetilde{\tilde} + \def\overrightarrow{\vec} +} { + \cs_gset_protected_nopar:Npx \widehat { + \um_wide_top_accent:Nnn \mathaccent { \um_symfont_tl } { "0302 } + } + \cs_gset_protected_nopar:Npx \widetilde { + \um_wide_top_accent:Nnn \mathaccent { \um_symfont_tl } { "0303 } + } + \cs_gset_protected_nopar:Npx \overleftarrow { + \um_wide_top_accent:Nnn \mathaccent { \um_symfont_tl } { "20D6 } + } + \cs_gset_protected_nopar:Npx \overrightarrow { + \um_wide_top_accent:Nnn \mathaccent { \um_symfont_tl } { "20D7 } + } + \cs_gset_protected_nopar:Npx \overleftrightarrow { + \um_wide_top_accent:Nnn \mathaccent { \um_symfont_tl } { "20E1 } + } + \bool_if:NT \c_um_have_fixed_accents_bool { + \cs_gset_protected_nopar:Npx \underrightharpoondown { + \um_wide_bottom_accent:Nnn \mathaccent { \um_symfont_tl } { "20EC } + } + \cs_gset_protected_nopar:Npx \underleftharpoondown { + \um_wide_bottom_accent:Nnn \mathaccent { \um_symfont_tl } { "20ED } + } + \cs_gset_protected_nopar:Npx \underleftarrow { + \um_wide_bottom_accent:Nnn \mathaccent { \um_symfont_tl } { "20EE } + } + \cs_gset_protected_nopar:Npx \underrightarrow { + \um_wide_bottom_accent:Nnn \mathaccent { \um_symfont_tl } { "20EF } + } + } } \cs_set_eq:NN \um_text_slash: \slash \cs_set:Npn \slash { \mode_if_math:TF {\mathslash} {\um_text_slash:} } -\AtEndOfPackage{ - \@ifclassloaded{beamer}{ - \ifbeamer@suppressreplacements\else - \um_warning:n {disable-beamer} - \beamer@suppressreplacementstrue +\AtEndOfPackageFile * { mathtools } { + \um_check_and_fix:NNnnnn \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@ + } { + \use:c { luatexcramped \cs_to_str:N #1 } #2 + } { + \hbox_set:Nn \l_tmpa_box { + \color@setgroup + \c_math_shift_token + \m@th + #1 + \dim_zero:N \nulldelimiterspace + \radical \c_zero { #2 } + \c_math_shift_token + \color@endgroup + } + \box_set_ht:Nn \l_tmpa_box { + \box_ht:N \l_tmpa_box + - \um_radical_vgap:N #1 + } + \box_use_clear:N \l_tmpa_box + } + \msg_warning:nn { unicode-math } { mathtools } + \NewDocumentCommand \dblcolon { } { \Colon } + \NewDocumentCommand \coloneqq { } { \coloneq } + \NewDocumentCommand \Coloneqq { } { \Coloneq } + \NewDocumentCommand \eqqcolon { } { \eqcolon } +} +\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 } +} +\@ifclassloaded{beamer}{ + \ifbeamer@suppressreplacements\else + \um_warning:n {disable-beamer} + \beamer@suppressreplacementstrue + \fi +}{} \ExplSyntaxOff -- cgit v1.2.3