From fd5f690d11016435384d6ae952eb94789cf60746 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 2 Oct 2017 21:58:46 +0000 Subject: unicode-math (2oct17) git-svn-id: svn://tug.org/texlive/trunk@45453 c570f23f-e606-0410-a88d-b1316a301751 --- .../latex/unicode-math/unicode-math-epilogue.dtx | 883 +++++++++++ .../latex/unicode-math/unicode-math-preamble.dtx | 618 ++++++++ .../source/latex/unicode-math/unicode-math.dtx | 1641 ++------------------ 3 files changed, 1588 insertions(+), 1554 deletions(-) create mode 100644 Master/texmf-dist/source/latex/unicode-math/unicode-math-epilogue.dtx create mode 100644 Master/texmf-dist/source/latex/unicode-math/unicode-math-preamble.dtx (limited to 'Master/texmf-dist/source/latex/unicode-math') diff --git a/Master/texmf-dist/source/latex/unicode-math/unicode-math-epilogue.dtx b/Master/texmf-dist/source/latex/unicode-math/unicode-math-epilogue.dtx new file mode 100644 index 00000000000..a4505c0a526 --- /dev/null +++ b/Master/texmf-dist/source/latex/unicode-math/unicode-math-epilogue.dtx @@ -0,0 +1,883 @@ + +% \section{Epilogue} +% +% \begin{macrocode} +%<*package&(XE|LU)> +% \end{macrocode} +% +% Lots of little things to tidy up. +% +% \subsection{Primes} +% +% We need a new `prime' algorithm. Unicode math has four pre-drawn prime glyphs. +% \begin{quote}\obeylines +% \unichar{2032} {prime} (\cs{prime}): $x\prime$ +% \unichar{2033} {double prime} (\cs{dprime}): $x\dprime$ +% \unichar{2034} {triple prime} (\cs{trprime}): $x\trprime$ +% \unichar{2057} {quadruple prime} (\cs{qprime}): $x\qprime$ +% \end{quote} +% As you can see, they're all drawn at the correct height without being superscripted. +% However, in a correctly behaving OpenType font, +% we also see different behaviour after the \texttt{ssty} feature is applied: +% \begin{quote} +% \font\1="Cambria Math:script=math,+ssty=0"\1 +% \char"1D465\char"2032\quad +% \char"1D465\char"2033\quad +% \char"1D465\char"2034\quad +% \char"1D465\char"2057 +% \end{quote} +% The glyphs are now `full size' so that when placed inside a superscript, +% their shape will match the originally sized ones. Many thanks to Ross Mills +% of Tiro Typeworks for originally pointing out this behaviour. +% +% In regular \LaTeX, primes can be entered with the straight quote character +% |'|, and multiple straight quotes chain together to produce multiple +% primes. Better results can be achieved in \pkg{unicode-math} by chaining +% multiple single primes into a pre-drawn multi-prime glyph; consider +% $x\prime{}\prime{}\prime$ vs.\ $x\trprime$. +% +% For Unicode maths, we wish to conserve this behaviour and augment it with +% the possibility of adding any combination of Unicode prime or any of the +% $n$-prime characters. E.g., the user might copy-paste a double prime from +% another source and then later type another single prime after it; the output +% should be the triple prime. +% +% Our algorithm is: +% \begin{itemize}[nolistsep] +% \item Prime encountered; pcount=1. +% \item Scan ahead; if prime: pcount:=pcount+1; repeat. +% \item If not prime, stop scanning. +% \item If pcount=1, \cs{prime}, end. +% \item If pcount=2, check \cs{dprime}; if it exists, use it, end; if not, goto last step. +% \item Ditto pcount=3 \& \cs{trprime}. +% \item Ditto pcount=4 \& \cs{qprime}. +% \item If pcount>4 or the glyph doesn't exist, insert pcount \cs{prime}s with \cs{primekern} between each. +% \end{itemize} +% +% This is a wrapper to insert a superscript; if there is a subsequent +% trailing superscript, then it is included within the insertion. +% \begin{macrocode} +\cs_new:Nn \@@_arg_i_before_egroup:n {#1\egroup} +\cs_new:Nn \@@_superscript:n + { + ^\bgroup #1 + \peek_meaning_remove:NTF ^ \@@_arg_i_before_egroup:n \egroup + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new:Nn \@@_nprimes:Nn + { + \@@_superscript:n + { + #1 + \prg_replicate:nn {#2-1} { \mskip \g_@@_primekern_muskip #1 } + } + } + +\cs_new:Nn \@@_nprimes_select:nn + { + \int_case:nnF {#2} + { + {1} { \@@_superscript:n {#1} } + {2} { + \@@_glyph_if_exist:nTF {"2033} + { \@@_superscript:n {\@@_prime_double_mchar} } + { \@@_nprimes:Nn #1 {#2} } + } + {3} { + \@@_glyph_if_exist:nTF {"2034} + { \@@_superscript:n {\@@_prime_triple_mchar} } + { \@@_nprimes:Nn #1 {#2} } + } + {4} { + \@@_glyph_if_exist:nTF {"2057} + { \@@_superscript:n {\@@_prime_quad_mchar} } + { \@@_nprimes:Nn #1 {#2} } + } + } + { + \@@_nprimes:Nn #1 {#2} + } + } +\cs_new:Nn \@@_nbackprimes_select:nn + { + \int_case:nnF {#2} + { + {1} { \@@_superscript:n {#1} } + {2} { + \@@_glyph_if_exist:nTF {"2036} + { \@@_superscript:n {\@@_backprime_double_mchar} } + { \@@_nprimes:Nn #1 {#2} } + } + {3} { + \@@_glyph_if_exist:nTF {"2037} + { \@@_superscript:n {\@@_backprime_triple_mchar} } + { \@@_nprimes:Nn #1 {#2} } + } + } + { + \@@_nprimes:Nn #1 {#2} + } + } +% \end{macrocode} +% +% Scanning is annoying because I'm too lazy to do it for the general case. +% +% \begin{macrocode} +\cs_new:Npn \@@_scan_prime: + { + \cs_set_eq:NN \@@_superscript:n \use:n + \int_zero:N \l_@@_primecount_int + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Npn \@@_scan_dprime: + { + \cs_set_eq:NN \@@_superscript:n \use:n + \int_set:Nn \l_@@_primecount_int {1} + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Npn \@@_scan_trprime: + { + \cs_set_eq:NN \@@_superscript:n \use:n + \int_set:Nn \l_@@_primecount_int {2} + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Npn \@@_scan_qprime: + { + \cs_set_eq:NN \@@_superscript:n \use:n + \int_set:Nn \l_@@_primecount_int {3} + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Npn \@@_scan_sup_prime: + { + \int_zero:N \l_@@_primecount_int + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Npn \@@_scan_sup_dprime: + { + \int_set:Nn \l_@@_primecount_int {1} + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Npn \@@_scan_sup_trprime: + { + \int_set:Nn \l_@@_primecount_int {2} + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Npn \@@_scan_sup_qprime: + { + \int_set:Nn \l_@@_primecount_int {3} + \@@_scanprime_collect:N \@@_prime_single_mchar + } +\cs_new:Nn \@@_scanprime_collect:N + { + \int_incr:N \l_@@_primecount_int + \peek_meaning_remove:NTF ' + { \@@_scanprime_collect:N #1 } + { + \peek_meaning_remove:NTF \@@_scan_prime: + { \@@_scanprime_collect:N #1 } + { + \peek_meaning_remove:NTF ^^^^2032 + { \@@_scanprime_collect:N #1 } + { + \peek_meaning_remove:NTF \@@_scan_dprime: + { + \int_incr:N \l_@@_primecount_int + \@@_scanprime_collect:N #1 + } + { + \peek_meaning_remove:NTF ^^^^2033 + { + \int_incr:N \l_@@_primecount_int + \@@_scanprime_collect:N #1 + } + { + \peek_meaning_remove:NTF \@@_scan_trprime: + { + \int_add:Nn \l_@@_primecount_int {2} + \@@_scanprime_collect:N #1 + } + { + \peek_meaning_remove:NTF ^^^^2034 + { + \int_add:Nn \l_@@_primecount_int {2} + \@@_scanprime_collect:N #1 + } + { + \peek_meaning_remove:NTF \@@_scan_qprime: + { + \int_add:Nn \l_@@_primecount_int {3} + \@@_scanprime_collect:N #1 + } + { + \peek_meaning_remove:NTF ^^^^2057 + { + \int_add:Nn \l_@@_primecount_int {3} + \@@_scanprime_collect:N #1 + } + { + \@@_nprimes_select:nn {#1} {\l_@@_primecount_int} + } + } + } + } + } + } + } + } + } + } +\cs_new:Npn \@@_scan_backprime: + { + \cs_set_eq:NN \@@_superscript:n \use:n + \int_zero:N \l_@@_primecount_int + \@@_scanbackprime_collect:N \@@_backprime_single_mchar + } +\cs_new:Npn \@@_scan_backdprime: + { + \cs_set_eq:NN \@@_superscript:n \use:n + \int_set:Nn \l_@@_primecount_int {1} + \@@_scanbackprime_collect:N \@@_backprime_single_mchar + } +\cs_new:Npn \@@_scan_backtrprime: + { + \cs_set_eq:NN \@@_superscript:n \use:n + \int_set:Nn \l_@@_primecount_int {2} + \@@_scanbackprime_collect:N \@@_backprime_single_mchar + } +\cs_new:Npn \@@_scan_sup_backprime: + { + \int_zero:N \l_@@_primecount_int + \@@_scanbackprime_collect:N \@@_backprime_single_mchar + } +\cs_new:Npn \@@_scan_sup_backdprime: + { + \int_set:Nn \l_@@_primecount_int {1} + \@@_scanbackprime_collect:N \@@_backprime_single_mchar + } +\cs_new:Npn \@@_scan_sup_backtrprime: + { + \int_set:Nn \l_@@_primecount_int {2} + \@@_scanbackprime_collect:N \@@_backprime_single_mchar + } +\cs_new:Nn \@@_scanbackprime_collect:N + { + \int_incr:N \l_@@_primecount_int + \peek_meaning_remove:NTF ` + { + \@@_scanbackprime_collect:N #1 + } + { + \peek_meaning_remove:NTF \@@_scan_backprime: + { + \@@_scanbackprime_collect:N #1 + } + { + \peek_meaning_remove:NTF ^^^^2035 + { + \@@_scanbackprime_collect:N #1 + } + { + \peek_meaning_remove:NTF \@@_scan_backdprime: + { + \int_incr:N \l_@@_primecount_int + \@@_scanbackprime_collect:N #1 + } + { + \peek_meaning_remove:NTF ^^^^2036 + { + \int_incr:N \l_@@_primecount_int + \@@_scanbackprime_collect:N #1 + } + { + \peek_meaning_remove:NTF \@@_scan_backtrprime: + { + \int_add:Nn \l_@@_primecount_int {2} + \@@_scanbackprime_collect:N #1 + } + { + \peek_meaning_remove:NTF ^^^^2037 + { + \int_add:Nn \l_@@_primecount_int {2} + \@@_scanbackprime_collect:N #1 + } + { + \@@_nbackprimes_select:nn {#1} {\l_@@_primecount_int} + } + } + } + } + } + } + } + } +% \end{macrocode} +% +% \begin{macrocode} +\AtBeginDocument{\@@_define_prime_commands: \@@_define_prime_chars:} +\cs_new:Nn \@@_define_prime_commands: + { + \cs_set_eq:NN \prime \@@_prime_single_mchar + \cs_set_eq:NN \dprime \@@_prime_double_mchar + \cs_set_eq:NN \trprime \@@_prime_triple_mchar + \cs_set_eq:NN \qprime \@@_prime_quad_mchar + \cs_set_eq:NN \backprime \@@_backprime_single_mchar + \cs_set_eq:NN \backdprime \@@_backprime_double_mchar + \cs_set_eq:NN \backtrprime \@@_backprime_triple_mchar + } +\group_begin: + \char_set_catcode_active:N \' + \char_set_catcode_active:N \` + \char_set_catcode_active:n {"2032} + \char_set_catcode_active:n {"2033} + \char_set_catcode_active:n {"2034} + \char_set_catcode_active:n {"2057} + \char_set_catcode_active:n {"2035} + \char_set_catcode_active:n {"2036} + \char_set_catcode_active:n {"2037} + \cs_gset:Nn \@@_define_prime_chars: + { + \cs_set_eq:NN ' \@@_scan_sup_prime: + \cs_set_eq:NN ^^^^2032 \@@_scan_sup_prime: + \cs_set_eq:NN ^^^^2033 \@@_scan_sup_dprime: + \cs_set_eq:NN ^^^^2034 \@@_scan_sup_trprime: + \cs_set_eq:NN ^^^^2057 \@@_scan_sup_qprime: + \cs_set_eq:NN ` \@@_scan_sup_backprime: + \cs_set_eq:NN ^^^^2035 \@@_scan_sup_backprime: + \cs_set_eq:NN ^^^^2036 \@@_scan_sup_backdprime: + \cs_set_eq:NN ^^^^2037 \@@_scan_sup_backtrprime: + } +\group_end: +% \end{macrocode} +% +% \subsection{Unicode radicals} +% +% Make sure \cs{Uroot} is defined in the case where the \LaTeX{} +% kernel doesn't make it available with its native name. +% \begin{macrocode} +%<*LU> +\cs_if_exist:NF \Uroot + { \cs_new_eq:NN \Uroot \luatexUroot } +% +% \end{macrocode} +% +% \begin{macrocode} +\AtBeginDocument{\@@_redefine_radical:} +\cs_new:Nn \@@_redefine_radical: +%<*XE> + { + \@ifpackageloaded { amsmath } { } + { +% \end{macrocode} +% \begin{macro}{\r@@t} +% \darg{A mathstyle (for \cmd\mathpalette)} +% \darg{Leading superscript for the sqrt sign} +% A re-implementation of \LaTeX's hard-coded n-root sign using the appropriate \cmd\fontdimen s. +% \begin{macrocode} + \cs_set_nopar:Npn \r@@@@t ##1 ##2 + { + \hbox_set:Nn \l_tmpa_box + { + \c_math_toggle_token + \m@th + ##1 + \sqrtsign { ##2 } + \c_math_toggle_token + } + \@@_mathstyle_scale:Nnn ##1 { \kern } + { \fontdimen 63 \l_@@_font } + \box_move_up:nn + { + (\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 } + \box_use_clear:N \l_tmpa_box + } +% \end{macrocode} +% \end{macro} +% \begin{macrocode} + } + } +% +%<*LU> + { + \@ifpackageloaded { amsmath } { } + { +% \end{macrocode} +% \begin{macro}{\root} +% Redefine this macro for \LuaTeX, which provides us a nice primitive to use. +% \begin{macrocode} + \cs_set:Npn \root ##1 \of ##2 + { + \Uroot \l_@@_radical_sqrt_tl { ##1 } { ##2 } + } +% \end{macrocode} +% \end{macro} +% \begin{macrocode} + } + } +% +% \end{macrocode} +% +% +% \begin{macro}{\@@_fontdimen_to_percent:nn} +% \begin{macro}{\@@_fontdimen_to_scale:nn} +% \darg{Font dimen number} +% \darg{Font `variable'} +% \cmd\fontdimen s |10|, |11|, and |65| aren't actually dimensions, they're percentage values given in units of |sp|. +% \cs{@@_fontdimen_to_percent:nn} takes a font dimension number and outputs the decimal value of the associated parameter. +% \cs{@@_fontdimen_to_scale:nn} returns a dimension correspond to the current +% font size relative proportion based on that percentage. +% \begin{macrocode} +\cs_new:Nn \@@_fontdimen_to_percent:nn + { + \fp_eval:n { \dim_to_decimal:n { \fontdimen #1 #2 } * 65536 / 100 } + } +\cs_new:Nn \@@_fontdimen_to_scale:nn + { + \fp_eval:n {\@@_fontdimen_to_percent:nn {#1} {#2} * \f@size } pt + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\@@_mathstyle_scale:Nnn} +% \darg{A math style (\cs{scriptstyle}, say)} +% \darg{Macro that takes a non-delimited length argument (like \cmd\kern)} +% \darg{Length control sequence to be scaled according to the math style} +% This macro is used to scale the lengths reported by \cmd\fontdimen\ according to the scale factor for script- and scriptscript-size objects. +% \begin{macrocode} +\cs_new:Nn \@@_mathstyle_scale:Nnn + { + \ifx#1\scriptstyle + #2 \@@_fontdimen_to_percent:nn {10} \l_@@_font #3 + \else + \ifx#1\scriptscriptstyle + #2 \@@_fontdimen_to_percent:nn {11} \l_@@_font #3 + \else + #2 #3 + \fi + \fi + } +% \end{macrocode} +% \end{macro} +% +% \subsection{Unicode sub- and super-scripts} +% +% The idea here is to enter a scanning state after a superscript or subscript +% is encountered. +% If subsequent superscripts or subscripts (resp.) are found, +% they are lumped together. +% Each sub/super has a corresponding regular size +% glyph which is used by \XeTeX\ to typeset the results; this means that the +% actual subscript/superscript glyphs are never seen in the output +% document~--- they are only used as input characters. +% +% Open question: should the superscript-like `modifiers' (\unichar{1D2C} +% {modifier capital letter a} and on) be included here? +% \begin{macrocode} +\group_begin: +% \end{macrocode} +% \paragraph{Superscripts} +% Populate a property list with superscript characters; themselves as their +% key, and their replacement as each key's value. +% Then make the superscript active and bind it to the scanning function. +% +% \cs{scantokens} makes this process much simpler since we can activate the +% char and assign its meaning in one step. +% \begin{macrocode} +\cs_new:Nn \@@_setup_active_superscript:nn + { + \prop_gput:Nnn \g_@@_supers_prop {#1} {#2} + \char_set_catcode_active:N #1 + \@@_char_gmake_mathactive:N #1 + \scantokens + { + \cs_gset:Npn #1 + { + \tl_set:Nn \l_@@_ss_chain_tl {#2} + \cs_set_eq:NN \@@_sub_or_super:n \sp + \tl_set:Nn \l_@@_tmpa_tl {supers} + \@@_scan_sscript: + } + } + } +% \end{macrocode} +% Bam: +% \begin{macrocode} +\@@_setup_active_superscript:nn {^^^^2070} {0} +\@@_setup_active_superscript:nn {^^^^00b9} {1} +\@@_setup_active_superscript:nn {^^^^00b2} {2} +\@@_setup_active_superscript:nn {^^^^00b3} {3} +\@@_setup_active_superscript:nn {^^^^2074} {4} +\@@_setup_active_superscript:nn {^^^^2075} {5} +\@@_setup_active_superscript:nn {^^^^2076} {6} +\@@_setup_active_superscript:nn {^^^^2077} {7} +\@@_setup_active_superscript:nn {^^^^2078} {8} +\@@_setup_active_superscript:nn {^^^^2079} {9} +\@@_setup_active_superscript:nn {^^^^207a} {+} +\@@_setup_active_superscript:nn {^^^^207b} {-} +\@@_setup_active_superscript:nn {^^^^207c} {=} +\@@_setup_active_superscript:nn {^^^^207d} {(} +\@@_setup_active_superscript:nn {^^^^207e} {)} +\@@_setup_active_superscript:nn {^^^^2071} {i} +\@@_setup_active_superscript:nn {^^^^207f} {n} +\@@_setup_active_superscript:nn {^^^^02b0} {h} +\@@_setup_active_superscript:nn {^^^^02b2} {j} +\@@_setup_active_superscript:nn {^^^^02b3} {r} +\@@_setup_active_superscript:nn {^^^^02b7} {w} +\@@_setup_active_superscript:nn {^^^^02b8} {y} +% \end{macrocode} +% \paragraph{Subscripts} Ditto above. +% \begin{macrocode} +\cs_new:Nn \@@_setup_active_subscript:nn + { + \prop_gput:Nnn \g_@@_subs_prop {#1} {#2} + \char_set_catcode_active:N #1 + \@@_char_gmake_mathactive:N #1 + \scantokens + { + \cs_gset:Npn #1 + { + \tl_set:Nn \l_@@_ss_chain_tl {#2} + \cs_set_eq:NN \@@_sub_or_super:n \sb + \tl_set:Nn \l_@@_tmpa_tl {subs} + \@@_scan_sscript: + } + } + } +% \end{macrocode} +% A few more subscripts than superscripts: +% \begin{macrocode} +\@@_setup_active_subscript:nn {^^^^2080} {0} +\@@_setup_active_subscript:nn {^^^^2081} {1} +\@@_setup_active_subscript:nn {^^^^2082} {2} +\@@_setup_active_subscript:nn {^^^^2083} {3} +\@@_setup_active_subscript:nn {^^^^2084} {4} +\@@_setup_active_subscript:nn {^^^^2085} {5} +\@@_setup_active_subscript:nn {^^^^2086} {6} +\@@_setup_active_subscript:nn {^^^^2087} {7} +\@@_setup_active_subscript:nn {^^^^2088} {8} +\@@_setup_active_subscript:nn {^^^^2089} {9} +\@@_setup_active_subscript:nn {^^^^208a} {+} +\@@_setup_active_subscript:nn {^^^^208b} {-} +\@@_setup_active_subscript:nn {^^^^208c} {=} +\@@_setup_active_subscript:nn {^^^^208d} {(} +\@@_setup_active_subscript:nn {^^^^208e} {)} +\@@_setup_active_subscript:nn {^^^^2090} {a} +\@@_setup_active_subscript:nn {^^^^2091} {e} +\@@_setup_active_subscript:nn {^^^^2095} {h} +\@@_setup_active_subscript:nn {^^^^1d62} {i} +\@@_setup_active_subscript:nn {^^^^2c7c} {j} +\@@_setup_active_subscript:nn {^^^^2096} {k} +\@@_setup_active_subscript:nn {^^^^2097} {l} +\@@_setup_active_subscript:nn {^^^^2098} {m} +\@@_setup_active_subscript:nn {^^^^2099} {n} +\@@_setup_active_subscript:nn {^^^^2092} {o} +\@@_setup_active_subscript:nn {^^^^209a} {p} +\@@_setup_active_subscript:nn {^^^^1d63} {r} +\@@_setup_active_subscript:nn {^^^^209b} {s} +\@@_setup_active_subscript:nn {^^^^209c} {t} +\@@_setup_active_subscript:nn {^^^^1d64} {u} +\@@_setup_active_subscript:nn {^^^^1d65} {v} +\@@_setup_active_subscript:nn {^^^^2093} {x} +\@@_setup_active_subscript:nn {^^^^1d66} {\beta} +\@@_setup_active_subscript:nn {^^^^1d67} {\gamma} +\@@_setup_active_subscript:nn {^^^^1d68} {\rho} +\@@_setup_active_subscript:nn {^^^^1d69} {\phi} +\@@_setup_active_subscript:nn {^^^^1d6a} {\chi} +% \end{macrocode} +% +% \begin{macrocode} +\group_end: +% \end{macrocode} +% The scanning command, which collects a chain of subscripts or a chain +% of superscripts and then typesets what it has collected. +% \begin{macrocode} +\cs_new:Npn \@@_scan_sscript: + { + \@@_scan_sscript:TF + { + \@@_scan_sscript: + } + { + \@@_sub_or_super:n {\l_@@_ss_chain_tl} + } + } +% \end{macrocode} +% We do not skip spaces when scanning ahead, and we explicitly wish to +% bail out on encountering a space or a brace. These cases are filtered +% using \cs{peek_N_type:TF}. Otherwise the token can be taken as an +% \texttt{N}-type argument. Then we search for it in the appropriate +% property list (\cs{l_@@_tmpa_tl} is |subs| or |supers|). +% If found, add the value to the current chain of sub/superscripts. +% Remember to put the character back in the input otherwise. +% The \cs{group_align_safe_begin:} and \cs{group_align_safe_end:} are +% needed in case |#3| is |&|. +% \begin{macrocode} +\cs_new:Npn \@@_scan_sscript:TF #1#2 + { + \peek_N_type:TF + { + \group_align_safe_begin: + \@@_scan_sscript_aux:nnN {#1} {#2} + } + {#2} + } +\cs_new:Npn \@@_scan_sscript_aux:nnN #1#2#3 + { + \prop_get:cnNTF {g_@@_\l_@@_tmpa_tl _prop} {#3} \l_@@_tmpb_tl + { + \tl_put_right:NV \l_@@_ss_chain_tl \l_@@_tmpb_tl + \group_align_safe_end: + #1 + } + { \group_align_safe_end: #2 #3 } + } +% \end{macrocode} +% +% \subsubsection{Active fractions} +% Active fractions can be setup independently of any maths font definition; +% all it requires is a mapping from the Unicode input chars to the relevant +% \LaTeX\ fraction declaration. +% +% \begin{macrocode} +\cs_new:Npn \@@_define_active_frac:Nw #1 #2/#3 + { + \char_set_catcode_active:N #1 + \@@_char_gmake_mathactive:N #1 + \tl_rescan:nn + { + \catcode`\_=11\relax + \catcode`\:=11\relax + } + { + \cs_gset:Npx #1 + { + \bool_if:NTF \l_@@_smallfrac_bool {\exp_not:N\tfrac} {\exp_not:N\frac} + {#2} {#3} + } + } + } +% \end{macrocode} +% These are redefined for each math font selection in case the |active-frac| +% feature changes. +% \begin{macrocode} +\cs_new:Npn \@@_setup_active_frac: + { + \group_begin: + \@@_define_active_frac:Nw ^^^^2189 0/3 + \@@_define_active_frac:Nw ^^^^2152 1/{10} + \@@_define_active_frac:Nw ^^^^2151 1/9 + \@@_define_active_frac:Nw ^^^^215b 1/8 + \@@_define_active_frac:Nw ^^^^2150 1/7 + \@@_define_active_frac:Nw ^^^^2159 1/6 + \@@_define_active_frac:Nw ^^^^2155 1/5 + \@@_define_active_frac:Nw ^^^^00bc 1/4 + \@@_define_active_frac:Nw ^^^^2153 1/3 + \@@_define_active_frac:Nw ^^^^215c 3/8 + \@@_define_active_frac:Nw ^^^^2156 2/5 + \@@_define_active_frac:Nw ^^^^00bd 1/2 + \@@_define_active_frac:Nw ^^^^2157 3/5 + \@@_define_active_frac:Nw ^^^^215d 5/8 + \@@_define_active_frac:Nw ^^^^2154 2/3 + \@@_define_active_frac:Nw ^^^^00be 3/4 + \@@_define_active_frac:Nw ^^^^2158 4/5 + \@@_define_active_frac:Nw ^^^^215a 5/6 + \@@_define_active_frac:Nw ^^^^215e 7/8 + \group_end: + } +\@@_setup_active_frac: +% \end{macrocode} +% +% \subsection{Synonyms and all the rest} +% +% These are symbols with multiple names. Eventually to be taken care of +% automatically by the maths characters database. +% \begin{macrocode} +\protected\def\to{\rightarrow} +\protected\def\le{\leq} +\protected\def\ge{\geq} +\protected\def\neq{\ne} +\protected\def\triangle{\mathord{\bigtriangleup}} +\protected\def\bigcirc{\mdlgwhtcircle} +\protected\def\circ{\vysmwhtcircle} +\protected\def\bullet{\smblkcircle} +\protected\def\mathyen{\yen} +\protected\def\mathsterling{\sterling} +\protected\def\diamond{\smwhtdiamond} +\protected\def\emptyset{\varnothing} +\protected\def\hbar{\hslash} +\protected\def\land{\wedge} +\protected\def\lor{\vee} +\protected\def\owns{\ni} +\protected\def\gets{\leftarrow} +\protected\def\mathring{\ocirc} +\protected\def\lnot{\neg} +\protected\def\longdivision{\longdivisionsign} +% \end{macrocode} +% These are somewhat odd: (and their usual Unicode uprightness does not match their amssymb glyphs) +% \begin{macrocode} +\protected\def\backepsilon{\upbackepsilon} +\protected\def\eth{\matheth} +% \end{macrocode} +% These are names that are `frozen' in HTML but have dumb names: +% \begin{macrocode} +\protected\def\dbkarow {\dbkarrow} +\protected\def\drbkarow{\drbkarrow} +\protected\def\hksearow{\hksearrow} +\protected\def\hkswarow{\hkswarrow} +% \end{macrocode} +% +% Due to the magic of OpenType math, big operators are automatically +% enlarged when necessary. Since there isn't a separate unicode glyph for +% `small integral', I'm not sure if there is a better way to do this: +% \begin{macrocode} +\protected\def\smallint{\mathop{\textstyle\int}\limits} +% \end{macrocode} +% +% \begin{macro}{\underbar} +% \begin{macrocode} +\cs_set_eq:NN \latexe_underbar:n \underbar +\renewcommand\underbar + { + \mode_if_math:TF \mathunderbar \latexe_underbar:n + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\colon} +% Define \cs{colon} as a mathpunct `|:|'. +% This is wrong: it should be \unichar{003A} {colon} instead! +% We hope no-one will notice. +% \begin{macrocode} +\@ifpackageloaded{amsmath} + { + % define their own colon, perhaps I should just steal it. (It does look much better.) + } + { + \cs_set_protected:Npn \colon + { + \bool_if:NTF \g_@@_literal_colon_bool {:} { \mathpunct{:} } + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\digamma} +% \begin{macro}{\Digamma} +% I might end up just changing these in the table. +% \begin{macrocode} +\protected\def\digamma{\updigamma} +\protected\def\Digamma{\upDigamma} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \paragraph{Symbols} +% \begin{macrocode} +\cs_set_protected:Npn \| {\Vert} +% \end{macrocode} +% \cs{mathinner} items: +% \begin{macrocode} +\cs_set_protected:Npn \mathellipsis {\mathinner{\unicodeellipsis}} +\cs_set_protected:Npn \cdots {\mathinner{\unicodecdots}} +% \end{macrocode} +% +% \begin{macrocode} +\cs_set_eq:NN \@@_text_slash: \slash +\cs_set_protected:Npn \slash + { + \mode_if_math:TF {\mathslash} {\@@_text_slash:} + } +% \end{macrocode} +% +% \paragraph{\cs{not}} +% The situation of \cs{not} symbol is currently messy, in Unicode it is defined +% as a combining mark so naturally it should be treated as a math accent, +% however neither Lua\TeX\ nor \XeTeX\ correctly place it as it needs special +% treatment compared to other accents, furthermore a math accent changes the +% spacing of its nucleus, so \cs{not=} will be spaced as an ordinary not +% relational symbol, which is undesired. +% +% Here modify \cs{not} to a macro that tries to use predefined negated symbols, +% which would give better results in most cases, until there is more robust +% solution in the engines. +% +% This code is based on an answer to a TeX -- Stack Exchange question by Enrico +% Gregorio\footnote{\url{http://tex.stackexchange.com/a/47260/729}}. +% +% \begin{macrocode} +\cs_new:Npn \@@_newnot:N #1 + { + \tl_set:Nx \l_not_token_name_tl { \token_to_str:N #1 } + \exp_args:Nx \tl_if_empty:nF { \tl_tail:V \l_not_token_name_tl } + { + \tl_set:Nx \l_not_token_name_tl { \tl_tail:V \l_not_token_name_tl } + } + \cs_if_exist:cTF { n \l_not_token_name_tl } + { + \use:c { n \l_not_token_name_tl } + } + { + \cs_if_exist:cTF { not \l_not_token_name_tl } + { + \use:c { not \l_not_token_name_tl } + } + { + \@@_oldnot: #1 + } + } + } +% \end{macrocode} +% \begin{macrocode} +\cs_set_eq:NN \@@_oldnot: \not +\AtBeginDocument{\cs_set_eq:NN \not \@@_newnot:N} +% \end{macrocode} +% \begin{macrocode} +\cs_new_protected_nopar:Nn \@@_setup_negations: + { + \cs_gset:cpn { not= } { \neq } + \cs_gset:cpn { not< } { \nless } + \cs_gset:cpn { not> } { \ngtr } + \cs_gset:Npn \ngets { \nleftarrow } + \cs_gset:Npn \nsimeq { \nsime } + \cs_gset:Npn \nequal { \ne } + \cs_gset:Npn \nle { \nleq } + \cs_gset:Npn \nge { \ngeq } + \cs_gset:Npn \ngreater { \ngtr } + \cs_gset:Npn \nforksnot { \forks } + } +% \end{macrocode} +% +% +% +% \section{Fall-back font} +% +% Want to load Latin Modern Math if nothing else. +% Reset the `font already loaded' boolean so that a new font being set will do the right thing. +% TODO: need a better way to do this for the general case. +% \begin{macrocode} +\AtBeginDocument { \@@_load_lm_if_necessary: } +\cs_new:Nn \@@_load_lm_if_necessary: + { + \cs_if_exist:NF \l_@@_fontname_tl + { + % TODO: update this when lmmath-bold.otf is released + \setmathfont{latinmodern-math.otf}[BoldFont={latinmodern-math.otf}] + \bool_set_false:N \g_@@_mainfont_already_set_bool + } + } +% \end{macrocode} +% +% \begin{macrocode} +% +% \end{macrocode} +% +\endinput + + diff --git a/Master/texmf-dist/source/latex/unicode-math/unicode-math-preamble.dtx b/Master/texmf-dist/source/latex/unicode-math/unicode-math-preamble.dtx new file mode 100644 index 00000000000..37f8194711b --- /dev/null +++ b/Master/texmf-dist/source/latex/unicode-math/unicode-math-preamble.dtx @@ -0,0 +1,618 @@ + +% \section{Preamble} +% +% The prefix for \pkg{unicode-math} is \texttt{um}: +% \begin{macrocode} +%<@@=um> +% \end{macrocode} +% +% The shared part of the code starts here before the split above. +% \begin{macrocode} +%<*preamble&!XE&!LU> +% \end{macrocode} +% +% Bail early if using pdf\TeX. +% \begin{macrocode} +\ifdefined\XeTeXversion + \ifdim\number\XeTeXversion\XeTeXrevision in<0.9998in% + \PackageError{unicode-math}{% + Cannot run with this version of XeTeX!\MessageBreak + You need XeTeX 0.9998 or newer.% + }\@ehd + \fi +\else\ifdefined\luatexversion + \ifnum\luatexversion<64% + \PackageError{unicode-math}{% + Cannot run with this version of LuaTeX!\MessageBreak + You need LuaTeX 0.64 or newer.% + }\@ehd + \fi +\else + \PackageError{unicode-math}{% + Cannot be run with pdfLaTeX!\MessageBreak + Use XeLaTeX or LuaLaTeX instead.% + }\@ehd +\fi\fi +% \end{macrocode} +% +% \paragraph{Packages} +% \begin{macrocode} +\RequirePackage{expl3}[2015/03/01] +\RequirePackage{ucharcat} +\RequirePackage{xparse} +\RequirePackage{l3keys2e} +\RequirePackage{fontspec}[2015/03/14] +\RequirePackage{fix-cm} % avoid some warnings +\RequirePackage{filehook} +% \end{macrocode} +% +% \begin{macrocode} +\ExplSyntaxOn +% \end{macrocode} +% +% Variants needed from \pkg{expl3}: +% \begin{macrocode} +\cs_set_protected_nopar:Npn \exp_last_unbraced:NNx { \::N \::x_unbraced \::: } +% \end{macrocode} +% +% For \pkg{fontspec}: +% \begin{macrocode} +\cs_generate_variant:Nn \fontspec_set_family:Nnn {Nx} +\cs_generate_variant:Nn \fontspec_set_fontface:NNnn {NNx} +% \end{macrocode} +% +% \paragraph{Conditionals} +% +% \begin{macrocode} +\bool_new:N \l_@@_ot_math_bool +\bool_new:N \l_@@_init_bool +\bool_new:N \l_@@_implicit_alph_bool +\bool_new:N \g_@@_mainfont_already_set_bool +% \end{macrocode} +% For \opt{math-style}: +% \begin{macrocode} +\bool_new:N \g_@@_literal_bool +\bool_new:N \g_@@_upLatin_bool +\bool_new:N \g_@@_uplatin_bool +\bool_new:N \g_@@_upGreek_bool +\bool_new:N \g_@@_upgreek_bool +% \end{macrocode} +% For \opt{bold-style}: +% \begin{macrocode} +\bool_new:N \g_@@_bfliteral_bool +\bool_new:N \g_@@_bfupLatin_bool +\bool_new:N \g_@@_bfuplatin_bool +\bool_new:N \g_@@_bfupGreek_bool +\bool_new:N \g_@@_bfupgreek_bool +% \end{macrocode} +% For \opt{sans-style}: +% \begin{macrocode} +\bool_new:N \g_@@_upsans_bool +\bool_new:N \g_@@_sfliteral_bool +% \end{macrocode} +% For assorted package options: +% \begin{macrocode} +\bool_new:N \g_@@_upNabla_bool +\bool_new:N \g_@@_uppartial_bool +\bool_new:N \g_@@_literal_Nabla_bool +\bool_new:N \g_@@_literal_partial_bool +\bool_new:N \l_@@_smallfrac_bool +\bool_new:N \g_@@_literal_colon_bool +\bool_new:N \g_@@_mathrm_text_bool +\bool_new:N \g_@@_mathit_text_bool +\bool_new:N \g_@@_mathbf_text_bool +\bool_new:N \g_@@_mathsf_text_bool +\bool_new:N \g_@@_mathtt_text_bool +% \end{macrocode} +% +% \paragraph{Variables} +% \begin{macrocode} +\int_new:N \g_@@_fam_int +% \end{macrocode} +% +% For displaying in warning messages, etc.: +% \begin{macrocode} +\tl_const:Nn \c_@@_math_alphabet_name_latin_tl {Latin,~lowercase} +\tl_const:Nn \c_@@_math_alphabet_name_Latin_tl {Latin,~uppercase} +\tl_const:Nn \c_@@_math_alphabet_name_greek_tl {Greek,~lowercase} +\tl_const:Nn \c_@@_math_alphabet_name_Greek_tl {Greek,~uppercase} +\tl_const:Nn \c_@@_math_alphabet_name_num_tl {Numerals} +\tl_const:Nn \c_@@_math_alphabet_name_misc_tl {Misc.} +% \end{macrocode} +% +% \begin{macrocode} +\tl_new:N \l_@@_mathstyle_tl +% \end{macrocode} +% +% Used to store the font switch for the \cs{operator@font}. +% \begin{macrocode} +\tl_new:N \g_@@_operator_mathfont_tl +% \end{macrocode} +% +% Variables: +% \begin{macrocode} +\seq_new:N \l_@@_missing_alph_seq +\seq_new:N \l_@@_mathalph_seq +\seq_new:N \l_@@_char_range_seq +\seq_new:N \l_@@_mclass_range_seq +\seq_new:N \l_@@_cmd_range_seq +% \end{macrocode} +% +% \begin{macro}{\g_@@_mathclasses_seq} +% Every math class. +% \begin{macrocode} +\seq_new:N \g_@@_mathclasses_seq +\seq_set_from_clist:Nn \g_@@_mathclasses_seq + { + \mathord,\mathalpha,\mathbin,\mathrel,\mathpunct, + \mathop, + \mathopen,\mathclose, + \mathfence,\mathover,\mathunder, + \mathaccent,\mathbotaccent,\mathaccentwide,\mathbotaccentwide + } +% \end{macrocode} +% \end{macro} +% + +% \begin{macro}{\g_@@_default_mathalph_seq} +% This sequence stores the alphabets in each math style. +% \begin{macrocode} +\seq_new:N \g_@@_default_mathalph_seq +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\g_@@_mathstyles_seq} +% This is every `named range' and every `math style' known to \pkg{unicode-math}. +% A named range is such as "bfit" and "sfit", which are also math styles (with \cs{symbfit} and \cs{symsfit}). +% `Mathstyles' are a superset of named ranges and also include commands such as \cs{symbf} and \cs{symsf}. +% +% N.B. for parsing purposes `named ranges' are defined as strings! +% \begin{macrocode} +\seq_new:N \g_@@_named_ranges_seq +\seq_new:N \g_@@_mathstyles_seq +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\muskip_new:N \g_@@_primekern_muskip +\muskip_gset:Nn \g_@@_primekern_muskip { -\thinmuskip/2 }% arbitrary +\int_new:N \l_@@_primecount_int +\prop_new:N \g_@@_supers_prop +\prop_new:N \g_@@_subs_prop +\tl_new:N \l_not_token_name_tl +% \end{macrocode} +% +% \subsection{Extras} +% +% What might end up being provided by the kernel. +% +% \begin{macro}{\@@_glyph_if_exist:nTF} +%: TODO: Generalise for arbitrary fonts! \cs{l_@@_font} is not always the one used for a specific glyph!! +% \begin{macrocode} +\prg_new_conditional:Nnn \@@_glyph_if_exist:n {p,TF,T,F} + { + \etex_iffontchar:D \l_@@_font #1 \scan_stop: + \prg_return_true: + \else: + \prg_return_false: + \fi: + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_set_mathcode:nnnn} +% \begin{macro}{\@@_set_mathcode:nnn} +% \begin{macro}{\@@_set_mathchar:NNnn} +% \begin{macro}{\@@_set_mathchar:cNnn} +% \begin{macro}{\@@_set_delcode:nnn} +% \begin{macro}{\@@_radical:nn} +% \begin{macro}{\@@_delimiter:Nnn} +% \begin{macro}{\@@_accent:nnn} +% \begin{macro}{\@@_accent_keyword:} +% These are all wrappers for the primitive commands that take numerical +% input only. +% \begin{macrocode} +\cs_set:Npn \@@_set_mathcode:nnnn #1#2#3#4 { + \Umathcode \int_eval:n {#1} = + \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop: +} +\cs_set:Npn \@@_set_mathcode:nnn #1#2#3 { + \Umathcode \int_eval:n {#1} = + \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#1} \scan_stop: +} +\cs_set:Npn \@@_set_mathchar:NNnn #1#2#3#4 { + \Umathchardef #1 = + \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop: +} +\cs_new:Nn \@@_set_delcode:nnn { + \Udelcode#2 = \csname sym#1\endcsname #3 \scan_stop: +} +\cs_new:Nn \@@_radical:nn { + \Uradical \csname sym#1\endcsname #2 \scan_stop: +} +\cs_new:Nn \@@_delimiter:Nnn { + \Udelimiter \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop: +} +\cs_new:Nn \@@_accent:nnn { + \Umathaccent #1~ \mathchar@type\mathaccent \use:c { sym #2 } #3 \scan_stop: +} +% \end{macrocode} +% +% \begin{macrocode} +\cs_generate_variant:Nn \@@_set_mathchar:NNnn {c} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\@@_char_gmake_mathactive:N} +% \begin{macro}{\@@_char_gmake_mathactive:n} +% \begin{macrocode} +\cs_new:Nn \@@_char_gmake_mathactive:N + { + \global\mathcode `#1 = "8000 \scan_stop: + } +\cs_new:Nn \@@_char_gmake_mathactive:n + { + \global\mathcode #1 = "8000 \scan_stop: + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Alphabet Unicode positions} +% +% Before we begin, let's define the positions of the various Unicode +% alphabets so that our code is a little more readable.\footnote{`\textsc{u.s.v.}' stands +% for `Unicode scalar value'.} +% +% Rather than `readable', in the end, this makes the code more extensible. +% \begin{macrocode} +\cs_new:Nn \usv_set:nnn + { \tl_set:cn { g_@@_#1_#2_usv } {#3} } +\cs_new:Nn \@@_to_usv:nn + { \use:c { g_@@_#1_#2_usv } } +\prg_new_conditional:Nnn \@@_usv_if_exist:nn {T,F,TF} + { + \cs_if_exist:cTF { g_@@_#1_#2_usv } + \prg_return_true: \prg_return_false: + } +% \end{macrocode} +% +% \subsection{Package options} +% +% \begin{macro}{\unimathsetup} +% This macro can be used in lieu of or later to override +% options declared when the package is loaded. +% \begin{macrocode} +\DeclareDocumentCommand \unimathsetup {m} + { \keys_set:nn {unicode-math} {#1} } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@@_keys_choices:nn} +% To simplify the creation of option keys, let's iterate in pairs rather than worry about equals signs and commas. +% \begin{macrocode} +\cs_new:Nn \@@_keys_choices:nn + { + \cs_set:Npn \@@_keys_choices_fn:nn { \@@_keys_choices_aux:nnn {#1} } + \use:x + { + \exp_not:N \keys_define:nn {unicode-math} + { + #1 .choice: , + \@@_tl_map_dbl:nN {#2} \@@_keys_choices_fn:nn + } + } + } +\cs_new:Nn \@@_keys_choices_aux:nnn { #1 / #2 .code:n = { \exp_not:n {#3} } , } + +\cs_new:Nn \@@_tl_map_dbl:nN + { + \__@@_tl_map_dbl:Nnn #2 #1 \q_recursion_tail {}{} \q_recursion_stop + } +\cs_new:Nn \__@@_tl_map_dbl:Nnn + { + \quark_if_recursion_tail_stop:n {#2} + \quark_if_recursion_tail_stop:n {#3} + #1 {#2} {#3} + \__@@_tl_map_dbl:Nnn #1 + } +% \end{macrocode} +% \end{macro} +% +% \paragraph{Compatibility} +% \begin{macrocode} +\@@_keys_choices:nn {mathup} + { + {sym} { \bool_set_false:N \g_@@_mathrm_text_bool } + {text} { \bool_set_true:N \g_@@_mathrm_text_bool } + } +\@@_keys_choices:nn {mathrm} + { + {sym} { \bool_set_false:N \g_@@_mathrm_text_bool } + {text} { \bool_set_true:N \g_@@_mathrm_text_bool } + } +\@@_keys_choices:nn {mathit} + { + {sym} { \bool_set_false:N \g_@@_mathit_text_bool } + {text} { \bool_set_true:N \g_@@_mathit_text_bool } + } +\@@_keys_choices:nn {mathbf} + { + {sym} { \bool_set_false:N \g_@@_mathbf_text_bool } + {text} { \bool_set_true:N \g_@@_mathbf_text_bool } + } +\@@_keys_choices:nn {mathsf} + { + {sym} { \bool_set_false:N \g_@@_mathsf_text_bool } + {text} { \bool_set_true:N \g_@@_mathsf_text_bool } + } +\@@_keys_choices:nn {mathtt} + { + {sym} { \bool_set_false:N \g_@@_mathtt_text_bool } + {text} { \bool_set_true:N \g_@@_mathtt_text_bool } + } +% \end{macrocode} +% +% \paragraph{math-style} +% \begin{macrocode} +\@@_keys_choices:nn {normal-style} + { + {ISO} { + \bool_set_false:N \g_@@_literal_bool + \bool_set_false:N \g_@@_upGreek_bool + \bool_set_false:N \g_@@_upgreek_bool + \bool_set_false:N \g_@@_upLatin_bool + \bool_set_false:N \g_@@_uplatin_bool + } + {TeX} { + \bool_set_false:N \g_@@_literal_bool + \bool_set_true:N \g_@@_upGreek_bool + \bool_set_false:N \g_@@_upgreek_bool + \bool_set_false:N \g_@@_upLatin_bool + \bool_set_false:N \g_@@_uplatin_bool + } + {french} { + \bool_set_false:N \g_@@_literal_bool + \bool_set_true:N \g_@@_upGreek_bool + \bool_set_true:N \g_@@_upgreek_bool + \bool_set_true:N \g_@@_upLatin_bool + \bool_set_false:N \g_@@_uplatin_bool + } + {upright} { + \bool_set_false:N \g_@@_literal_bool + \bool_set_true:N \g_@@_upGreek_bool + \bool_set_true:N \g_@@_upgreek_bool + \bool_set_true:N \g_@@_upLatin_bool + \bool_set_true:N \g_@@_uplatin_bool + } + {literal} { + \bool_set_true:N \g_@@_literal_bool + } + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_keys_choices:nn {math-style} + { + {ISO} { + \unimathsetup { nabla=upright, partial=italic, + normal-style=ISO, bold-style=ISO, sans-style=italic } + } + {TeX} { + \unimathsetup { nabla=upright, partial=italic, + normal-style=TeX, bold-style=TeX, sans-style=upright } + } + {french} { + \unimathsetup { nabla=upright, partial=upright, + normal-style=french, bold-style=upright, sans-style=upright } + } + {upright} { + \unimathsetup { nabla=upright, partial=upright, + normal-style=upright, bold-style=upright, sans-style=upright } + } + {literal} { + \unimathsetup { colon=literal, nabla=literal, partial=literal, + normal-style=literal, bold-style=literal, sans-style=literal } + } + } +% \end{macrocode} +% +% \paragraph{bold-style} +% \begin{macrocode} +\@@_keys_choices:nn {bold-style} + { + {ISO} { + \bool_set_false:N \g_@@_bfliteral_bool + \bool_set_false:N \g_@@_bfupGreek_bool + \bool_set_false:N \g_@@_bfupgreek_bool + \bool_set_false:N \g_@@_bfupLatin_bool + \bool_set_false:N \g_@@_bfuplatin_bool + } + {TeX} { + \bool_set_false:N \g_@@_bfliteral_bool + \bool_set_true:N \g_@@_bfupGreek_bool + \bool_set_false:N \g_@@_bfupgreek_bool + \bool_set_true:N \g_@@_bfupLatin_bool + \bool_set_true:N \g_@@_bfuplatin_bool + } + {upright} { + \bool_set_false:N \g_@@_bfliteral_bool + \bool_set_true:N \g_@@_bfupGreek_bool + \bool_set_true:N \g_@@_bfupgreek_bool + \bool_set_true:N \g_@@_bfupLatin_bool + \bool_set_true:N \g_@@_bfuplatin_bool + } + {literal} { + \bool_set_true:N \g_@@_bfliteral_bool + } + } +% \end{macrocode} +% +% \paragraph{sans-style} +% \begin{macrocode} +\@@_keys_choices:nn {sans-style} + { + {italic} { \bool_set_false:N \g_@@_upsans_bool } + {upright} { \bool_set_true:N \g_@@_upsans_bool } + {literal} { \bool_set_true:N \g_@@_sfliteral_bool } + } +% \end{macrocode} +% +% +% \paragraph{Nabla and partial} +% \begin{macrocode} +\@@_keys_choices:nn {nabla} + { + {upright} { + \bool_set_false:N \g_@@_literal_Nabla_bool + \bool_set_true:N \g_@@_upNabla_bool + } + {italic} { + \bool_set_false:N \g_@@_literal_Nabla_bool + \bool_set_false:N \g_@@_upNabla_bool + } + {literal} { \bool_set_true:N \g_@@_literal_Nabla_bool } + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_keys_choices:nn {partial} + { + {upright} { + \bool_set_false:N \g_@@_literal_partial_bool + \bool_set_true:N \g_@@_uppartial_bool + } + {italic} { + \bool_set_false:N \g_@@_literal_partial_bool + \bool_set_false:N \g_@@_uppartial_bool + } + {literal} { \bool_set_true:N \g_@@_literal_partial_bool } + } +% \end{macrocode} +% +% \paragraph{Colon style} +% \begin{macrocode} +\@@_keys_choices:nn {colon} + { + {literal} { \bool_set_true:N \g_@@_literal_colon_bool } + {TeX} { \bool_set_false:N \g_@@_literal_colon_bool } + } +% \end{macrocode} +% +% \paragraph{Slash delimiter style} +% \begin{macrocode} +\@@_keys_choices:nn {slash-delimiter} + { + {ascii} { \tl_set:Nn \g_@@_slash_delimiter_usv {"002F} } + {frac} { \tl_set:Nn \g_@@_slash_delimiter_usv {"2044} } + {div} { \tl_set:Nn \g_@@_slash_delimiter_usv {"2215} } + } +% \end{macrocode} +% +% +% \paragraph{Active fraction style} +% \begin{macrocode} +\@@_keys_choices:nn {active-frac} + { + {small} + { + \cs_if_exist:NTF \tfrac + { \bool_set_true:N \l_@@_smallfrac_bool } + { + \@@_warning:n {no-tfrac} + \bool_set_false:N \l_@@_smallfrac_bool + } + \use:c {@@_setup_active_frac:} + } + + {normalsize} + { + \bool_set_false:N \l_@@_smallfrac_bool + \use:c {@@_setup_active_frac:} + } + } +% \end{macrocode} +% +% \paragraph{Debug/tracing} +% +% +% \begin{macrocode} +\keys_define:nn {unicode-math} + { + warnings-off .code:n = + { + \clist_map_inline:nn {#1} + { \msg_redirect_name:nnn { unicode-math } { ##1 } { none } } + } + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_keys_choices:nn {trace} + { + {on} {} % default + {debug} { \msg_redirect_module:nnn { unicode-math } { log } { warning } } + {off} { \msg_redirect_module:nnn { unicode-math } { log } { none } } + } +% \end{macrocode} +% +% \begin{macrocode} +\unimathsetup {math-style=TeX} +\unimathsetup {slash-delimiter=ascii} +\unimathsetup {trace=off} +\unimathsetup {mathrm=text,mathit=text,mathbf=text,mathsf=text,mathtt=text} +\cs_if_exist:NT \tfrac { \unimathsetup {active-frac=small} } +\ProcessKeysOptions {unicode-math} +% \end{macrocode} +% +% \subsection{Programmers' interface} +% +% \begin{macro}{\unimath_get_mathstyle:} +% This command expands to the currently math style. +% \begin{macrocode} +\cs_new:Nn \unimath_get_mathstyle: + { + \tl_use:N \l_@@_mathstyle_tl + } +% \end{macrocode} +% \end{macro} +% +% \subsection{Overcoming \texorpdfstring{\cmd\@onlypreamble}{\textbackslash @onlypreamble}} +% +% The requirement of only setting up the maths fonts in the preamble is now removed. +% The following list might be overly ambitious. +% \begin{macrocode} +\tl_map_inline:nn + { + \new@mathgroup\cdp@list\cdp@elt\DeclareMathSizes + \@DeclareMathSizes\newmathalphabet\newmathalphabet@@\newmathalphabet@@@ + \DeclareMathVersion\define@mathalphabet\define@mathgroup\addtoversion + \version@list\version@elt\alpha@list\alpha@elt + \restore@mathversion\init@restore@version\dorestore@version\process@table + \new@mathversion\DeclareSymbolFont\group@list\group@elt + \new@symbolfont\SetSymbolFont\SetSymbolFont@\get@cdp + \DeclareMathAlphabet\new@mathalphabet\SetMathAlphabet\SetMathAlphabet@ + \DeclareMathAccent\set@mathaccent\DeclareMathSymbol\set@mathchar + \set@mathsymbol\DeclareMathDelimiter\@xxDeclareMathDelimiter + \@DeclareMathDelimiter\@xDeclareMathDelimiter\set@mathdelimiter + \set@@mathdelimiter\DeclareMathRadical\mathchar@type + \DeclareSymbolFontAlphabet\DeclareSymbolFontAlphabet@ + } + { + \tl_remove_once:Nn \@preamblecmds {\do#1} + } +% \end{macrocode} +% +% End of preamble code. +% \begin{macrocode} +% +% \end{macrocode} diff --git a/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx b/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx index 1b18fe91517..6ed3ad8bb1b 100644 --- a/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx +++ b/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx @@ -29,7 +29,7 @@ This work is "maintained" by Will Robertson. \def\UMDEBUG{,debug}% \fi \generate{\file{unicode-math.sty}{ - \from{unicode-math.dtx}{preamble\UMDEBUG} + \from{unicode-math-preamble.dtx}{preamble\UMDEBUG} \from{unicode-math-msg.dtx}{msg\UMDEBUG} \from{unicode-math-usv.dtx}{usv\UMDEBUG} \from{unicode-math.dtx}{load\UMDEBUG} @@ -37,10 +37,12 @@ This work is "maintained" by Will Robertson. }} \generate{\file{unicode-math-xetex.sty}{ \from{unicode-math.dtx}{package,XE\UMDEBUG} + \from{unicode-math-epilogue.dtx}{package,XE\UMDEBUG} \from{unicode-math-compat.dtx}{compat,XE\UMDEBUG} }} \generate{\file{unicode-math-luatex.sty}{ \from{unicode-math.dtx}{package,LU\UMDEBUG} + \from{unicode-math-epilogue.dtx}{package,XE\UMDEBUG} \from{unicode-math-compat.dtx}{compat,LU\UMDEBUG} }} \def\tempa{plain} @@ -53,12 +55,13 @@ This work is "maintained" by Will Robertson. %\ProvidesPackage{unicode-math-xetex} %\ProvidesPackage{unicode-math-luatex} %<*preamble> - [2017/08/02 v0.8f Unicode maths in XeLaTeX and LuaLaTeX] + [2017/10/02 v0.8g Unicode maths in XeLaTeX and LuaLaTeX] % %<*internal> \def\DOCUMENTEND{F} \input{unicode-math-doc} \DocInput{unicode-math.dtx} +\DocInput{unicode-math-preamble.dtx} \DocInput{unicode-math-msg.dtx} \DocInput{unicode-math-usv.dtx} \DocInput{unicode-math-alphabets.dtx} @@ -76,7 +79,6 @@ This work is "maintained" by Will Robertson. %<@@=um> % \end{macrocode} % -% \section{Header code} % % We (later on) bifurcate the package based on the engine being used. % These separate package files are indicated with the Docstrip flags \textsf{LU} and \textsf{XE}, respectively. @@ -87,594 +89,6 @@ This work is "maintained" by Will Robertson. \sys_if_engine_xetex:T { \RequirePackage{unicode-math-xetex} } % % \end{macrocode} -% The shared part of the code starts here before the split above. -% \begin{macrocode} -%<*preamble&!XE&!LU> -% \end{macrocode} -% -% Bail early if using pdf\TeX. -% \begin{macrocode} -\usepackage{ifxetex,ifluatex} -\ifxetex - \ifdim\number\XeTeXversion\XeTeXrevision in<0.9998in% - \PackageError{unicode-math}{% - Cannot run with this version of XeTeX!\MessageBreak - You need XeTeX 0.9998 or newer.% - }\@ehd - \fi -\else\ifluatex - \ifnum\luatexversion<64% - \PackageError{unicode-math}{% - Cannot run with this version of LuaTeX!\MessageBreak - You need LuaTeX 0.64 or newer.% - }\@ehd - \fi -\else - \PackageError{unicode-math}{% - Cannot be run with pdfLaTeX!\MessageBreak - Use XeLaTeX or LuaLaTeX instead.% - }\@ehd -\fi\fi -% \end{macrocode} -% -% \paragraph{Packages} -% \begin{macrocode} -\RequirePackage{expl3}[2015/03/01] -\RequirePackage{ucharcat} -\RequirePackage{xparse} -\RequirePackage{l3keys2e} -\RequirePackage{fontspec}[2015/03/14] -\RequirePackage{fix-cm} % avoid some warnings -\RequirePackage{filehook} -% \end{macrocode} -% -% \begin{macrocode} -\ExplSyntaxOn -% \end{macrocode} -% -% Variants needed from \pkg{expl3}: -% \begin{macrocode} -\cs_set_protected_nopar:Npn \exp_last_unbraced:NNx { \::N \::x_unbraced \::: } -% \end{macrocode} -% -% For \pkg{fontspec}: -% \begin{macrocode} -\cs_generate_variant:Nn \fontspec_set_family:Nnn {Nx} -\cs_generate_variant:Nn \fontspec_set_fontface:NNnn {NNx} -% \end{macrocode} -% -% \paragraph{Conditionals} -% -% \begin{macrocode} -\bool_new:N \l_@@_ot_math_bool -\bool_new:N \l_@@_init_bool -\bool_new:N \l_@@_implicit_alph_bool -\bool_new:N \g_@@_mainfont_already_set_bool -% \end{macrocode} -% For \opt{math-style}: -% \begin{macrocode} -\bool_new:N \g_@@_literal_bool -\bool_new:N \g_@@_upLatin_bool -\bool_new:N \g_@@_uplatin_bool -\bool_new:N \g_@@_upGreek_bool -\bool_new:N \g_@@_upgreek_bool -% \end{macrocode} -% For \opt{bold-style}: -% \begin{macrocode} -\bool_new:N \g_@@_bfliteral_bool -\bool_new:N \g_@@_bfupLatin_bool -\bool_new:N \g_@@_bfuplatin_bool -\bool_new:N \g_@@_bfupGreek_bool -\bool_new:N \g_@@_bfupgreek_bool -% \end{macrocode} -% For \opt{sans-style}: -% \begin{macrocode} -\bool_new:N \g_@@_upsans_bool -\bool_new:N \g_@@_sfliteral_bool -% \end{macrocode} -% For assorted package options: -% \begin{macrocode} -\bool_new:N \g_@@_upNabla_bool -\bool_new:N \g_@@_uppartial_bool -\bool_new:N \g_@@_literal_Nabla_bool -\bool_new:N \g_@@_literal_partial_bool -\bool_new:N \l_@@_smallfrac_bool -\bool_new:N \g_@@_literal_colon_bool -\bool_new:N \g_@@_mathrm_text_bool -\bool_new:N \g_@@_mathit_text_bool -\bool_new:N \g_@@_mathbf_text_bool -\bool_new:N \g_@@_mathsf_text_bool -\bool_new:N \g_@@_mathtt_text_bool -% \end{macrocode} -% -% \paragraph{Variables} -% \begin{macrocode} -\int_new:N \g_@@_fam_int -% \end{macrocode} -% -% For displaying in warning messages, etc.: -% \begin{macrocode} -\tl_const:Nn \c_@@_math_alphabet_name_latin_tl {Latin,~lowercase} -\tl_const:Nn \c_@@_math_alphabet_name_Latin_tl {Latin,~uppercase} -\tl_const:Nn \c_@@_math_alphabet_name_greek_tl {Greek,~lowercase} -\tl_const:Nn \c_@@_math_alphabet_name_Greek_tl {Greek,~uppercase} -\tl_const:Nn \c_@@_math_alphabet_name_num_tl {Numerals} -\tl_const:Nn \c_@@_math_alphabet_name_misc_tl {Misc.} -% \end{macrocode} -% -% \begin{macrocode} -\tl_new:N \l_@@_mathstyle_tl -% \end{macrocode} -% -% Used to store the font switch for the \cs{operator@font}. -% \begin{macrocode} -\tl_new:N \g_@@_operator_mathfont_tl -% \end{macrocode} -% -% Variables: -% \begin{macrocode} -\seq_new:N \l_@@_missing_alph_seq -\seq_new:N \l_@@_mathalph_seq -\seq_new:N \l_@@_char_range_seq -\seq_new:N \l_@@_mclass_range_seq -\seq_new:N \l_@@_cmd_range_seq -% \end{macrocode} -% -% \begin{macro}{\g_@@_mathclasses_seq} -% Every math class. -% \begin{macrocode} -\seq_new:N \g_@@_mathclasses_seq -\seq_set_from_clist:Nn \g_@@_mathclasses_seq - { - \mathord,\mathalpha,\mathbin,\mathrel,\mathpunct, - \mathop, - \mathopen,\mathclose, - \mathfence,\mathover,\mathunder, - \mathaccent,\mathbotaccent,\mathaccentwide,\mathbotaccentwide - } -% \end{macrocode} -% \end{macro} -% - -% \begin{macro}{\g_@@_default_mathalph_seq} -% This sequence stores the alphabets in each math style. -% \begin{macrocode} -\seq_new:N \g_@@_default_mathalph_seq -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\g_@@_mathstyles_seq} -% This is every `named range' and every `math style' known to \pkg{unicode-math}. -% A named range is such as "bfit" and "sfit", which are also math styles (with \cs{symbfit} and \cs{symsfit}). -% `Mathstyles' are a superset of named ranges and also include commands such as \cs{symbf} and \cs{symsf}. -% -% N.B. for parsing purposes `named ranges' are defined as strings! -% \begin{macrocode} -\seq_new:N \g_@@_named_ranges_seq -\seq_new:N \g_@@_mathstyles_seq -% \end{macrocode} -% \end{macro} -% -% \begin{macrocode} -\muskip_new:N \g_@@_primekern_muskip -\muskip_gset:Nn \g_@@_primekern_muskip { -\thinmuskip/2 }% arbitrary -\int_new:N \l_@@_primecount_int -\prop_new:N \g_@@_supers_prop -\prop_new:N \g_@@_subs_prop -\tl_new:N \l_not_token_name_tl -% \end{macrocode} -% -% \subsection{Extras} -% -% What might end up being provided by the kernel. -% -% \begin{macro}{\@@_glyph_if_exist:nTF} -%: TODO: Generalise for arbitrary fonts! \cs{l_@@_font} is not always the one used for a specific glyph!! -% \begin{macrocode} -\prg_new_conditional:Nnn \@@_glyph_if_exist:n {p,TF,T,F} - { - \etex_iffontchar:D \l_@@_font #1 \scan_stop: - \prg_return_true: - \else: - \prg_return_false: - \fi: - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_set_mathcode:nnnn} -% \begin{macro}{\@@_set_mathcode:nnn} -% \begin{macro}{\@@_set_mathchar:NNnn} -% \begin{macro}{\@@_set_mathchar:cNnn} -% \begin{macro}{\@@_set_delcode:nnn} -% \begin{macro}{\@@_radical:nn} -% \begin{macro}{\@@_delimiter:Nnn} -% \begin{macro}{\@@_accent:nnn} -% \begin{macro}{\@@_accent_keyword:} -% These are all wrappers for the primitive commands that take numerical -% input only. -% \begin{macrocode} -\cs_set:Npn \@@_set_mathcode:nnnn #1#2#3#4 { - \Umathcode \int_eval:n {#1} = - \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop: -} -\cs_set:Npn \@@_set_mathcode:nnn #1#2#3 { - \Umathcode \int_eval:n {#1} = - \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#1} \scan_stop: -} -\cs_set:Npn \@@_set_mathchar:NNnn #1#2#3#4 { - \Umathchardef #1 = - \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop: -} -\cs_new:Nn \@@_set_delcode:nnn { - \Udelcode#2 = \csname sym#1\endcsname #3 \scan_stop: -} -\cs_new:Nn \@@_radical:nn { - \Uradical \csname sym#1\endcsname #2 \scan_stop: -} -\cs_new:Nn \@@_delimiter:Nnn { - \Udelimiter \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop: -} -\cs_new:Nn \@@_accent:nnn { - \Umathaccent #1~ \mathchar@type\mathaccent \use:c { sym #2 } #3 \scan_stop: -} -% \end{macrocode} -% -% \begin{macrocode} -\cs_generate_variant:Nn \@@_set_mathchar:NNnn {c} -% \end{macrocode} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% \end{macro} -% -% -% \begin{macro}{\@@_char_gmake_mathactive:N} -% \begin{macro}{\@@_char_gmake_mathactive:n} -% \begin{macrocode} -\cs_new:Nn \@@_char_gmake_mathactive:N - { - \global\mathcode `#1 = "8000 \scan_stop: - } -\cs_new:Nn \@@_char_gmake_mathactive:n - { - \global\mathcode #1 = "8000 \scan_stop: - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \subsection{Alphabet Unicode positions} -% -% Before we begin, let's define the positions of the various Unicode -% alphabets so that our code is a little more readable.\footnote{`\textsc{u.s.v.}' stands -% for `Unicode scalar value'.} -% -% Rather than `readable', in the end, this makes the code more extensible. -% \begin{macrocode} -\cs_new:Nn \usv_set:nnn - { \tl_set:cn { g_@@_#1_#2_usv } {#3} } -\cs_new:Nn \@@_to_usv:nn - { \use:c { g_@@_#1_#2_usv } } -\prg_new_conditional:Nnn \@@_usv_if_exist:nn {T,F,TF} - { - \cs_if_exist:cTF { g_@@_#1_#2_usv } - \prg_return_true: \prg_return_false: - } -% \end{macrocode} -% -% \subsection{Package options} -% -% \begin{macro}{\unimathsetup} -% This macro can be used in lieu of or later to override -% options declared when the package is loaded. -% \begin{macrocode} -\DeclareDocumentCommand \unimathsetup {m} - { \keys_set:nn {unicode-math} {#1} } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\@@_keys_choices:nn} -% To simplify the creation of option keys, let's iterate in pairs rather than worry about equals signs and commas. -% \begin{macrocode} -\cs_new:Nn \@@_keys_choices:nn - { - \cs_set:Npn \@@_keys_choices_fn:nn { \@@_keys_choices_aux:nnn {#1} } - \use:x - { - \exp_not:N \keys_define:nn {unicode-math} - { - #1 .choice: , - \@@_tl_map_dbl:nN {#2} \@@_keys_choices_fn:nn - } - } - } -\cs_new:Nn \@@_keys_choices_aux:nnn { #1 / #2 .code:n = { \exp_not:n {#3} } , } - -\cs_new:Nn \@@_tl_map_dbl:nN - { - \__@@_tl_map_dbl:Nnn #2 #1 \q_recursion_tail {}{} \q_recursion_stop - } -\cs_new:Nn \__@@_tl_map_dbl:Nnn - { - \quark_if_recursion_tail_stop:n {#2} - \quark_if_recursion_tail_stop:n {#3} - #1 {#2} {#3} - \__@@_tl_map_dbl:Nnn #1 - } -% \end{macrocode} -% \end{macro} -% -% \paragraph{Compatibility} -% \begin{macrocode} -\@@_keys_choices:nn {mathup} - { - {sym} { \bool_set_false:N \g_@@_mathrm_text_bool } - {text} { \bool_set_true:N \g_@@_mathrm_text_bool } - } -\@@_keys_choices:nn {mathrm} - { - {sym} { \bool_set_false:N \g_@@_mathrm_text_bool } - {text} { \bool_set_true:N \g_@@_mathrm_text_bool } - } -\@@_keys_choices:nn {mathit} - { - {sym} { \bool_set_false:N \g_@@_mathit_text_bool } - {text} { \bool_set_true:N \g_@@_mathit_text_bool } - } -\@@_keys_choices:nn {mathbf} - { - {sym} { \bool_set_false:N \g_@@_mathbf_text_bool } - {text} { \bool_set_true:N \g_@@_mathbf_text_bool } - } -\@@_keys_choices:nn {mathsf} - { - {sym} { \bool_set_false:N \g_@@_mathsf_text_bool } - {text} { \bool_set_true:N \g_@@_mathsf_text_bool } - } -\@@_keys_choices:nn {mathtt} - { - {sym} { \bool_set_false:N \g_@@_mathtt_text_bool } - {text} { \bool_set_true:N \g_@@_mathtt_text_bool } - } -% \end{macrocode} -% -% \paragraph{math-style} -% \begin{macrocode} -\@@_keys_choices:nn {normal-style} - { - {ISO} { - \bool_set_false:N \g_@@_literal_bool - \bool_set_false:N \g_@@_upGreek_bool - \bool_set_false:N \g_@@_upgreek_bool - \bool_set_false:N \g_@@_upLatin_bool - \bool_set_false:N \g_@@_uplatin_bool - } - {TeX} { - \bool_set_false:N \g_@@_literal_bool - \bool_set_true:N \g_@@_upGreek_bool - \bool_set_false:N \g_@@_upgreek_bool - \bool_set_false:N \g_@@_upLatin_bool - \bool_set_false:N \g_@@_uplatin_bool - } - {french} { - \bool_set_false:N \g_@@_literal_bool - \bool_set_true:N \g_@@_upGreek_bool - \bool_set_true:N \g_@@_upgreek_bool - \bool_set_true:N \g_@@_upLatin_bool - \bool_set_false:N \g_@@_uplatin_bool - } - {upright} { - \bool_set_false:N \g_@@_literal_bool - \bool_set_true:N \g_@@_upGreek_bool - \bool_set_true:N \g_@@_upgreek_bool - \bool_set_true:N \g_@@_upLatin_bool - \bool_set_true:N \g_@@_uplatin_bool - } - {literal} { - \bool_set_true:N \g_@@_literal_bool - } - } -% \end{macrocode} -% -% \begin{macrocode} -\@@_keys_choices:nn {math-style} - { - {ISO} { - \unimathsetup { nabla=upright, partial=italic, - normal-style=ISO, bold-style=ISO, sans-style=italic } - } - {TeX} { - \unimathsetup { nabla=upright, partial=italic, - normal-style=TeX, bold-style=TeX, sans-style=upright } - } - {french} { - \unimathsetup { nabla=upright, partial=upright, - normal-style=french, bold-style=upright, sans-style=upright } - } - {upright} { - \unimathsetup { nabla=upright, partial=upright, - normal-style=upright, bold-style=upright, sans-style=upright } - } - {literal} { - \unimathsetup { colon=literal, nabla=literal, partial=literal, - normal-style=literal, bold-style=literal, sans-style=literal } - } - } -% \end{macrocode} -% -% \paragraph{bold-style} -% \begin{macrocode} -\@@_keys_choices:nn {bold-style} - { - {ISO} { - \bool_set_false:N \g_@@_bfliteral_bool - \bool_set_false:N \g_@@_bfupGreek_bool - \bool_set_false:N \g_@@_bfupgreek_bool - \bool_set_false:N \g_@@_bfupLatin_bool - \bool_set_false:N \g_@@_bfuplatin_bool - } - {TeX} { - \bool_set_false:N \g_@@_bfliteral_bool - \bool_set_true:N \g_@@_bfupGreek_bool - \bool_set_false:N \g_@@_bfupgreek_bool - \bool_set_true:N \g_@@_bfupLatin_bool - \bool_set_true:N \g_@@_bfuplatin_bool - } - {upright} { - \bool_set_false:N \g_@@_bfliteral_bool - \bool_set_true:N \g_@@_bfupGreek_bool - \bool_set_true:N \g_@@_bfupgreek_bool - \bool_set_true:N \g_@@_bfupLatin_bool - \bool_set_true:N \g_@@_bfuplatin_bool - } - {literal} { - \bool_set_true:N \g_@@_bfliteral_bool - } - } -% \end{macrocode} -% -% \paragraph{sans-style} -% \begin{macrocode} -\@@_keys_choices:nn {sans-style} - { - {italic} { \bool_set_false:N \g_@@_upsans_bool } - {upright} { \bool_set_true:N \g_@@_upsans_bool } - {literal} { \bool_set_true:N \g_@@_sfliteral_bool } - } -% \end{macrocode} -% -% -% \paragraph{Nabla and partial} -% \begin{macrocode} -\@@_keys_choices:nn {nabla} - { - {upright} { - \bool_set_false:N \g_@@_literal_Nabla_bool - \bool_set_true:N \g_@@_upNabla_bool - } - {italic} { - \bool_set_false:N \g_@@_literal_Nabla_bool - \bool_set_false:N \g_@@_upNabla_bool - } - {literal} { \bool_set_true:N \g_@@_literal_Nabla_bool } - } -% \end{macrocode} -% -% \begin{macrocode} -\@@_keys_choices:nn {partial} - { - {upright} { - \bool_set_false:N \g_@@_literal_partial_bool - \bool_set_true:N \g_@@_uppartial_bool - } - {italic} { - \bool_set_false:N \g_@@_literal_partial_bool - \bool_set_false:N \g_@@_uppartial_bool - } - {literal} { \bool_set_true:N \g_@@_literal_partial_bool } - } -% \end{macrocode} -% -% \paragraph{Colon style} -% \begin{macrocode} -\@@_keys_choices:nn {colon} - { - {literal} { \bool_set_true:N \g_@@_literal_colon_bool } - {TeX} { \bool_set_false:N \g_@@_literal_colon_bool } - } -% \end{macrocode} -% -% \paragraph{Slash delimiter style} -% \begin{macrocode} -\@@_keys_choices:nn {slash-delimiter} - { - {ascii} { \tl_set:Nn \g_@@_slash_delimiter_usv {"002F} } - {frac} { \tl_set:Nn \g_@@_slash_delimiter_usv {"2044} } - {div} { \tl_set:Nn \g_@@_slash_delimiter_usv {"2215} } - } -% \end{macrocode} -% -% -% \paragraph{Active fraction style} -% \begin{macrocode} -\@@_keys_choices:nn {active-frac} - { - {small} - { - \cs_if_exist:NTF \tfrac - { \bool_set_true:N \l_@@_smallfrac_bool } - { - \@@_warning:n {no-tfrac} - \bool_set_false:N \l_@@_smallfrac_bool - } - \use:c {@@_setup_active_frac:} - } - - {normalsize} - { - \bool_set_false:N \l_@@_smallfrac_bool - \use:c {@@_setup_active_frac:} - } - } -% \end{macrocode} -% -% \paragraph{Debug/tracing} -% -% -% \begin{macrocode} -\keys_define:nn {unicode-math} - { - warnings-off .code:n = - { - \clist_map_inline:nn {#1} - { \msg_redirect_name:nnn { unicode-math } { ##1 } { none } } - } - } -% \end{macrocode} -% -% \begin{macrocode} -\@@_keys_choices:nn {trace} - { - {on} {} % default - {debug} { \msg_redirect_module:nnn { unicode-math } { log } { warning } } - {off} { \msg_redirect_module:nnn { unicode-math } { log } { none } } - } -% \end{macrocode} -% -% \begin{macrocode} -\unimathsetup {math-style=TeX} -\unimathsetup {slash-delimiter=ascii} -\unimathsetup {trace=off} -\unimathsetup {mathrm=text,mathit=text,mathbf=text,mathsf=text,mathtt=text} -\cs_if_exist:NT \tfrac { \unimathsetup {active-frac=small} } -\ProcessKeysOptions {unicode-math} -% \end{macrocode} -% -% \subsection{Programmers' interface} -% -% \begin{macro}{\unimath_get_mathstyle:} -% This command expands to the currently math style. -% \begin{macrocode} -\cs_new:Nn \unimath_get_mathstyle: - { - \tl_use:N \l_@@_mathstyle_tl - } -% \end{macrocode} -% \end{macro} -% -% End of preamble code. -% \begin{macrocode} -% -% \end{macrocode} -% -% (Error messages and warning definitions go here from the |msg| chunk -% defined in \secref[vref]{codemsg}.) % % \section{Bifurcation} % @@ -701,30 +115,6 @@ This work is "maintained" by Will Robertson. % \end{macrocode} % % -% \subsection{Overcoming \texorpdfstring{\cmd\@onlypreamble}{\textbackslash @onlypreamble}} -% -% The requirement of only setting up the maths fonts in the preamble is now removed. The following list might be overly ambitious. -% \begin{macrocode} -\tl_map_inline:nn - { - \new@mathgroup\cdp@list\cdp@elt\DeclareMathSizes - \@DeclareMathSizes\newmathalphabet\newmathalphabet@@\newmathalphabet@@@ - \DeclareMathVersion\define@mathalphabet\define@mathgroup\addtoversion - \version@list\version@elt\alpha@list\alpha@elt - \restore@mathversion\init@restore@version\dorestore@version\process@table - \new@mathversion\DeclareSymbolFont\group@list\group@elt - \new@symbolfont\SetSymbolFont\SetSymbolFont@\get@cdp - \DeclareMathAlphabet\new@mathalphabet\SetMathAlphabet\SetMathAlphabet@ - \DeclareMathAccent\set@mathaccent\DeclareMathSymbol\set@mathchar - \set@mathsymbol\DeclareMathDelimiter\@xxDeclareMathDelimiter - \@DeclareMathDelimiter\@xDeclareMathDelimiter\set@mathdelimiter - \set@@mathdelimiter\DeclareMathRadical\mathchar@type - \DeclareSymbolFontAlphabet\DeclareSymbolFontAlphabet@ - } - { - \tl_remove_once:Nn \@preamblecmds {\do#1} - } -% \end{macrocode} % % \section{Fundamentals} % @@ -980,83 +370,66 @@ This work is "maintained" by Will Robertson. % \subsubsection{Text font} % \begin{macrocode} \cs_generate_variant:Nn \tl_if_eq:nnT {o} -\cs_set:Nn \__fontspec_setmainfont:nn - { - \fontspec_set_family:Nnn \rmdefault {#1}{#2} - \tl_if_eq:onT {\g__fontspec_mathrm_tl} {\rmdefault} - { -% \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {#1} {#2} -% \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {Renderer=Basic,#1} {#2} - \SetMathAlphabet\mathrm{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\updefault - \SetMathAlphabet\mathit{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\itdefault - \SetMathAlphabet\mathbf{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\bfdefault\updefault - } - \normalfont - \ignorespaces - } +\cs_set:Nn \__fontspec_setmainfont_hook:nn + { + \tl_if_eq:onT {\g__fontspec_mathrm_tl} {\rmdefault} + { +% \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {#1} {#2} +% \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {Renderer=Basic,#1} {#2} + \SetMathAlphabet\mathrm{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\updefault + \SetMathAlphabet\mathit{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\itdefault + \SetMathAlphabet\mathbf{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\bfdefault\updefault + } + } -\cs_set:Nn \__fontspec_setsansfont:nn - { - \fontspec_set_family:Nnn \sfdefault {#1}{#2} - \tl_if_eq:onT {\g__fontspec_mathsf_tl} {\sfdefault} - { -% \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {#1} {#2} -% \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {Renderer=Basic,#1} {#2} - \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g__fontspec_mathsf_tl\mddefault\updefault - \SetMathAlphabet\mathsf{bold} \g_fontspec_encoding_tl\g__fontspec_mathsf_tl\bfdefault\updefault - } - \normalfont - \ignorespaces - } +\cs_set:Nn \__fontspec_setsansfont_hook:nn + { + \tl_if_eq:onT {\g__fontspec_mathsf_tl} {\sfdefault} + { +% \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {#1} {#2} +% \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {Renderer=Basic,#1} {#2} + \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g__fontspec_mathsf_tl\mddefault\updefault + \SetMathAlphabet\mathsf{bold} \g_fontspec_encoding_tl\g__fontspec_mathsf_tl\bfdefault\updefault + } + } -\cs_set:Nn \__fontspec_setmonofont:nn - { - \fontspec_set_family:Nnn \ttdefault {#1}{#2} - \tl_if_eq:onT {\g__fontspec_mathtt_tl} {\ttdefault} - { -% \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {#1} {#2} -% \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {Renderer=Basic,#1} {#2} - \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g__fontspec_mathtt_tl\mddefault\updefault - \SetMathAlphabet\mathtt{bold} \g_fontspec_encoding_tl\g__fontspec_mathtt_tl\bfdefault\updefault - } - \normalfont - \ignorespaces - } +\cs_set:Nn \__fontspec_setmonofont_hook:nn + { + \tl_if_eq:onT {\g__fontspec_mathtt_tl} {\ttdefault} + { +% \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {#1} {#2} +% \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {Renderer=Basic,#1} {#2} + \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g__fontspec_mathtt_tl\mddefault\updefault + \SetMathAlphabet\mathtt{bold} \g_fontspec_encoding_tl\g__fontspec_mathtt_tl\bfdefault\updefault + } + } % \end{macrocode} % % \subsubsection{Maths font} % If the maths fonts are set explicitly, then the text commands above will not execute their branches to set the maths font alphabets. % \begin{macrocode} -\cs_set:Nn \__fontspec_setmathrm:nn - { -% \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {#1} {#2} -% \fontspec_set_family:Nnn \g__fontspec_mathrm_tl {Renderer=Basic,#1} {#2} - \SetMathAlphabet\mathrm{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\updefault - \SetMathAlphabet\mathit{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\itdefault - \SetMathAlphabet\mathbf{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\bfdefault\updefault - } -\cs_set:Nn \__fontspec_setboldmathrm:nn - { -% \fontspec_set_family:Nnn \g__fontspec_bfmathrm_tl {#1} {#2} -% \fontspec_set_family:Nnn \g__fontspec_bfmathrm_tl {Renderer=Basic,#1} {#2} - \SetMathAlphabet\mathrm{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\mddefault\updefault - \SetMathAlphabet\mathbf{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\bfdefault\updefault - \SetMathAlphabet\mathit{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\mddefault\itdefault - } -\cs_set:Nn \__fontspec_setmathsf:nn - { -% \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {#1} {#2} -% \fontspec_set_family:Nnn \g__fontspec_mathsf_tl {Renderer=Basic,#1} {#2} - \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g__fontspec_mathsf_tl\mddefault\updefault - \SetMathAlphabet\mathsf{bold} \g_fontspec_encoding_tl\g__fontspec_mathsf_tl\bfdefault\updefault - } -\cs_set:Nn \__fontspec_setmathtt:nn - { -% \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {#1} {#2} -% \fontspec_set_family:Nnn \g__fontspec_mathtt_tl {Renderer=Basic,#1} {#2} - \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g__fontspec_mathtt_tl\mddefault\updefault - \SetMathAlphabet\mathtt{bold} \g_fontspec_encoding_tl\g__fontspec_mathtt_tl\bfdefault\updefault - } +\cs_set:Nn \__fontspec_setmathrm_hook:nn + { + \SetMathAlphabet\mathrm{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\updefault + \SetMathAlphabet\mathit{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\mddefault\itdefault + \SetMathAlphabet\mathbf{normal}\g_fontspec_encoding_tl\g__fontspec_mathrm_tl\bfdefault\updefault + } +\cs_set:Nn \__fontspec_setboldmathrm_hook:nn + { + \SetMathAlphabet\mathrm{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\mddefault\updefault + \SetMathAlphabet\mathbf{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\bfdefault\updefault + \SetMathAlphabet\mathit{bold}\g_fontspec_encoding_tl\g__fontspec_bfmathrm_tl\mddefault\itdefault + } +\cs_set:Nn \__fontspec_setmathsf_hook:nn + { + \SetMathAlphabet\mathsf{normal}\g_fontspec_encoding_tl\g__fontspec_mathsf_tl\mddefault\updefault + \SetMathAlphabet\mathsf{bold} \g_fontspec_encoding_tl\g__fontspec_mathsf_tl\bfdefault\updefault + } +\cs_set:Nn \__fontspec_setmathtt_hook:nn + { + \SetMathAlphabet\mathtt{normal}\g_fontspec_encoding_tl\g__fontspec_mathtt_tl\mddefault\updefault + \SetMathAlphabet\mathtt{bold} \g_fontspec_encoding_tl\g__fontspec_mathtt_tl\bfdefault\updefault + } % \end{macrocode} % % @@ -1072,6 +445,13 @@ This work is "maintained" by Will Robertson. % \doarg{font features} % \begin{macrocode} \DeclareDocumentCommand \setmathfont { O{} m O{} } + { + \@@_setmathfont:nn {#1,#3} {#2} + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_set:Nn \@@_setmathfont:nn { \tl_set:Nn \l_@@_fontname_tl {#2} \@@_init: @@ -1087,7 +467,7 @@ This work is "maintained" by Will Robertson. % \end{macrocode} % Parse options and tell people what's going on: % \begin{macrocode} - \keys_set_known:nnN {unicode-math} {#1,#3} \l_@@_unknown_keys_clist + \keys_set_known:nnN {unicode-math} {#1} \l_@@_unknown_keys_clist \bool_if:NT \l_@@_init_bool { \@@_log:n {default-math-font} } % \end{macrocode} % Use \pkg{fontspec} to select a font to use. @@ -1225,16 +605,37 @@ This work is "maintained" by Will Robertson. % \begin{macrocode} \cs_new:Nn \@@_declare_math_sizes: { +%<*LU> + \fp_compare:nF { \@@_script_style_size:n {ScriptPercentScaleDown} == 0 } + { + \DeclareMathSizes { \f@size } { \f@size } + { \@@_script_style_size:n {ScriptPercentScaleDown} } + { \@@_script_style_size:n {ScriptScriptPercentScaleDown} } + } +% +%<*XE> \dim_compare:nF { \fontdimen 10 \l_@@_font == 0pt } { \DeclareMathSizes { \f@size } { \f@size } { \@@_fontdimen_to_scale:nn {10} {\l_@@_font} } { \@@_fontdimen_to_scale:nn {11} {\l_@@_font} } } +% } % \end{macrocode} % \end{macro} % +%<*LU> +% \begin{macro}{\@@_script_style_size:n} +% Determine script- and scriptscriptstyle sizes using luaotfload: +% \begin{macrocode} +\cs_new:Nn \@@_script_style_size:n + { + \fp_eval:n {\directlua{tex.sprint(luaotfload.aux.get_math_dimension("l_@@_font","#1"))} * \f@size / 100 } + } +% \end{macrocode} +% \end{macro} +% % % % \begin{macro}{\@@_setup_legacy_fam_two:} @@ -2977,874 +2378,6 @@ This work is "maintained" by Will Robertson. } % \end{macrocode} % -% \section{Fall-back font} -% -% Want to load Latin Modern Math if nothing else. -% Reset the `font already loaded' boolean so that a new font being set will do the right thing. -% TODO: need a better way to do this for the general case. -% \begin{macrocode} -\AtBeginDocument { \@@_load_lm_if_necessary: } -\cs_new:Nn \@@_load_lm_if_necessary: - { - \cs_if_exist:NF \l_@@_fontname_tl - { - % TODO: update this when lmmath-bold.otf is released - \setmathfont{latinmodern-math.otf}[BoldFont={latinmodern-math.otf}] - \bool_set_false:N \g_@@_mainfont_already_set_bool - } - } -% \end{macrocode} -% -% \section{Epilogue} -% -% Lots of little things to tidy up. -% -% \subsection{Primes} -% -% We need a new `prime' algorithm. Unicode math has four pre-drawn prime glyphs. -% \begin{quote}\obeylines -% \unichar{2032} {prime} (\cs{prime}): $x\prime$ -% \unichar{2033} {double prime} (\cs{dprime}): $x\dprime$ -% \unichar{2034} {triple prime} (\cs{trprime}): $x\trprime$ -% \unichar{2057} {quadruple prime} (\cs{qprime}): $x\qprime$ -% \end{quote} -% As you can see, they're all drawn at the correct height without being superscripted. -% However, in a correctly behaving OpenType font, -% we also see different behaviour after the \texttt{ssty} feature is applied: -% \begin{quote} -% \font\1="Cambria Math:script=math,+ssty=0"\1 -% \char"1D465\char"2032\quad -% \char"1D465\char"2033\quad -% \char"1D465\char"2034\quad -% \char"1D465\char"2057 -% \end{quote} -% The glyphs are now `full size' so that when placed inside a superscript, -% their shape will match the originally sized ones. Many thanks to Ross Mills -% of Tiro Typeworks for originally pointing out this behaviour. -% -% In regular \LaTeX, primes can be entered with the straight quote character -% |'|, and multiple straight quotes chain together to produce multiple -% primes. Better results can be achieved in \pkg{unicode-math} by chaining -% multiple single primes into a pre-drawn multi-prime glyph; consider -% $x\prime{}\prime{}\prime$ vs.\ $x\trprime$. -% -% For Unicode maths, we wish to conserve this behaviour and augment it with -% the possibility of adding any combination of Unicode prime or any of the -% $n$-prime characters. E.g., the user might copy-paste a double prime from -% another source and then later type another single prime after it; the output -% should be the triple prime. -% -% Our algorithm is: -% \begin{itemize}[nolistsep] -% \item Prime encountered; pcount=1. -% \item Scan ahead; if prime: pcount:=pcount+1; repeat. -% \item If not prime, stop scanning. -% \item If pcount=1, \cs{prime}, end. -% \item If pcount=2, check \cs{dprime}; if it exists, use it, end; if not, goto last step. -% \item Ditto pcount=3 \& \cs{trprime}. -% \item Ditto pcount=4 \& \cs{qprime}. -% \item If pcount>4 or the glyph doesn't exist, insert pcount \cs{prime}s with \cs{primekern} between each. -% \end{itemize} -% -% This is a wrapper to insert a superscript; if there is a subsequent -% trailing superscript, then it is included within the insertion. -% \begin{macrocode} -\cs_new:Nn \@@_arg_i_before_egroup:n {#1\egroup} -\cs_new:Nn \@@_superscript:n - { - ^\bgroup #1 - \peek_meaning_remove:NTF ^ \@@_arg_i_before_egroup:n \egroup - } -% \end{macrocode} -% -% \begin{macrocode} -\cs_new:Nn \@@_nprimes:Nn - { - \@@_superscript:n - { - #1 - \prg_replicate:nn {#2-1} { \mskip \g_@@_primekern_muskip #1 } - } - } - -\cs_new:Nn \@@_nprimes_select:nn - { - \int_case:nnF {#2} - { - {1} { \@@_superscript:n {#1} } - {2} { - \@@_glyph_if_exist:nTF {"2033} - { \@@_superscript:n {\@@_prime_double_mchar} } - { \@@_nprimes:Nn #1 {#2} } - } - {3} { - \@@_glyph_if_exist:nTF {"2034} - { \@@_superscript:n {\@@_prime_triple_mchar} } - { \@@_nprimes:Nn #1 {#2} } - } - {4} { - \@@_glyph_if_exist:nTF {"2057} - { \@@_superscript:n {\@@_prime_quad_mchar} } - { \@@_nprimes:Nn #1 {#2} } - } - } - { - \@@_nprimes:Nn #1 {#2} - } - } -\cs_new:Nn \@@_nbackprimes_select:nn - { - \int_case:nnF {#2} - { - {1} { \@@_superscript:n {#1} } - {2} { - \@@_glyph_if_exist:nTF {"2036} - { \@@_superscript:n {\@@_backprime_double_mchar} } - { \@@_nprimes:Nn #1 {#2} } - } - {3} { - \@@_glyph_if_exist:nTF {"2037} - { \@@_superscript:n {\@@_backprime_triple_mchar} } - { \@@_nprimes:Nn #1 {#2} } - } - } - { - \@@_nprimes:Nn #1 {#2} - } - } -% \end{macrocode} -% -% Scanning is annoying because I'm too lazy to do it for the general case. -% -% \begin{macrocode} -\cs_new:Npn \@@_scan_prime: - { - \cs_set_eq:NN \@@_superscript:n \use:n - \int_zero:N \l_@@_primecount_int - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Npn \@@_scan_dprime: - { - \cs_set_eq:NN \@@_superscript:n \use:n - \int_set:Nn \l_@@_primecount_int {1} - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Npn \@@_scan_trprime: - { - \cs_set_eq:NN \@@_superscript:n \use:n - \int_set:Nn \l_@@_primecount_int {2} - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Npn \@@_scan_qprime: - { - \cs_set_eq:NN \@@_superscript:n \use:n - \int_set:Nn \l_@@_primecount_int {3} - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Npn \@@_scan_sup_prime: - { - \int_zero:N \l_@@_primecount_int - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Npn \@@_scan_sup_dprime: - { - \int_set:Nn \l_@@_primecount_int {1} - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Npn \@@_scan_sup_trprime: - { - \int_set:Nn \l_@@_primecount_int {2} - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Npn \@@_scan_sup_qprime: - { - \int_set:Nn \l_@@_primecount_int {3} - \@@_scanprime_collect:N \@@_prime_single_mchar - } -\cs_new:Nn \@@_scanprime_collect:N - { - \int_incr:N \l_@@_primecount_int - \peek_meaning_remove:NTF ' - { \@@_scanprime_collect:N #1 } - { - \peek_meaning_remove:NTF \@@_scan_prime: - { \@@_scanprime_collect:N #1 } - { - \peek_meaning_remove:NTF ^^^^2032 - { \@@_scanprime_collect:N #1 } - { - \peek_meaning_remove:NTF \@@_scan_dprime: - { - \int_incr:N \l_@@_primecount_int - \@@_scanprime_collect:N #1 - } - { - \peek_meaning_remove:NTF ^^^^2033 - { - \int_incr:N \l_@@_primecount_int - \@@_scanprime_collect:N #1 - } - { - \peek_meaning_remove:NTF \@@_scan_trprime: - { - \int_add:Nn \l_@@_primecount_int {2} - \@@_scanprime_collect:N #1 - } - { - \peek_meaning_remove:NTF ^^^^2034 - { - \int_add:Nn \l_@@_primecount_int {2} - \@@_scanprime_collect:N #1 - } - { - \peek_meaning_remove:NTF \@@_scan_qprime: - { - \int_add:Nn \l_@@_primecount_int {3} - \@@_scanprime_collect:N #1 - } - { - \peek_meaning_remove:NTF ^^^^2057 - { - \int_add:Nn \l_@@_primecount_int {3} - \@@_scanprime_collect:N #1 - } - { - \@@_nprimes_select:nn {#1} {\l_@@_primecount_int} - } - } - } - } - } - } - } - } - } - } -\cs_new:Npn \@@_scan_backprime: - { - \cs_set_eq:NN \@@_superscript:n \use:n - \int_zero:N \l_@@_primecount_int - \@@_scanbackprime_collect:N \@@_backprime_single_mchar - } -\cs_new:Npn \@@_scan_backdprime: - { - \cs_set_eq:NN \@@_superscript:n \use:n - \int_set:Nn \l_@@_primecount_int {1} - \@@_scanbackprime_collect:N \@@_backprime_single_mchar - } -\cs_new:Npn \@@_scan_backtrprime: - { - \cs_set_eq:NN \@@_superscript:n \use:n - \int_set:Nn \l_@@_primecount_int {2} - \@@_scanbackprime_collect:N \@@_backprime_single_mchar - } -\cs_new:Npn \@@_scan_sup_backprime: - { - \int_zero:N \l_@@_primecount_int - \@@_scanbackprime_collect:N \@@_backprime_single_mchar - } -\cs_new:Npn \@@_scan_sup_backdprime: - { - \int_set:Nn \l_@@_primecount_int {1} - \@@_scanbackprime_collect:N \@@_backprime_single_mchar - } -\cs_new:Npn \@@_scan_sup_backtrprime: - { - \int_set:Nn \l_@@_primecount_int {2} - \@@_scanbackprime_collect:N \@@_backprime_single_mchar - } -\cs_new:Nn \@@_scanbackprime_collect:N - { - \int_incr:N \l_@@_primecount_int - \peek_meaning_remove:NTF ` - { - \@@_scanbackprime_collect:N #1 - } - { - \peek_meaning_remove:NTF \@@_scan_backprime: - { - \@@_scanbackprime_collect:N #1 - } - { - \peek_meaning_remove:NTF ^^^^2035 - { - \@@_scanbackprime_collect:N #1 - } - { - \peek_meaning_remove:NTF \@@_scan_backdprime: - { - \int_incr:N \l_@@_primecount_int - \@@_scanbackprime_collect:N #1 - } - { - \peek_meaning_remove:NTF ^^^^2036 - { - \int_incr:N \l_@@_primecount_int - \@@_scanbackprime_collect:N #1 - } - { - \peek_meaning_remove:NTF \@@_scan_backtrprime: - { - \int_add:Nn \l_@@_primecount_int {2} - \@@_scanbackprime_collect:N #1 - } - { - \peek_meaning_remove:NTF ^^^^2037 - { - \int_add:Nn \l_@@_primecount_int {2} - \@@_scanbackprime_collect:N #1 - } - { - \@@_nbackprimes_select:nn {#1} {\l_@@_primecount_int} - } - } - } - } - } - } - } - } -% \end{macrocode} -% -% \begin{macrocode} -\AtBeginDocument{\@@_define_prime_commands: \@@_define_prime_chars:} -\cs_new:Nn \@@_define_prime_commands: - { - \cs_set_eq:NN \prime \@@_prime_single_mchar - \cs_set_eq:NN \dprime \@@_prime_double_mchar - \cs_set_eq:NN \trprime \@@_prime_triple_mchar - \cs_set_eq:NN \qprime \@@_prime_quad_mchar - \cs_set_eq:NN \backprime \@@_backprime_single_mchar - \cs_set_eq:NN \backdprime \@@_backprime_double_mchar - \cs_set_eq:NN \backtrprime \@@_backprime_triple_mchar - } -\group_begin: - \char_set_catcode_active:N \' - \char_set_catcode_active:N \` - \char_set_catcode_active:n {"2032} - \char_set_catcode_active:n {"2033} - \char_set_catcode_active:n {"2034} - \char_set_catcode_active:n {"2057} - \char_set_catcode_active:n {"2035} - \char_set_catcode_active:n {"2036} - \char_set_catcode_active:n {"2037} - \cs_gset:Nn \@@_define_prime_chars: - { - \cs_set_eq:NN ' \@@_scan_sup_prime: - \cs_set_eq:NN ^^^^2032 \@@_scan_sup_prime: - \cs_set_eq:NN ^^^^2033 \@@_scan_sup_dprime: - \cs_set_eq:NN ^^^^2034 \@@_scan_sup_trprime: - \cs_set_eq:NN ^^^^2057 \@@_scan_sup_qprime: - \cs_set_eq:NN ` \@@_scan_sup_backprime: - \cs_set_eq:NN ^^^^2035 \@@_scan_sup_backprime: - \cs_set_eq:NN ^^^^2036 \@@_scan_sup_backdprime: - \cs_set_eq:NN ^^^^2037 \@@_scan_sup_backtrprime: - } -\group_end: -% \end{macrocode} -% -% \subsection{Unicode radicals} -% -% Make sure \cs{Uroot} is defined in the case where the \LaTeX{} -% kernel doesn't make it available with its native name. -% \begin{macrocode} -%<*LU> -\cs_if_exist:NF \Uroot - { \cs_new_eq:NN \Uroot \luatexUroot } -% -% \end{macrocode} -% -% \begin{macrocode} -\AtBeginDocument{\@@_redefine_radical:} -\cs_new:Nn \@@_redefine_radical: -%<*XE> - { - \@ifpackageloaded { amsmath } { } - { -% \end{macrocode} -% \begin{macro}{\r@@t} -% \darg{A mathstyle (for \cmd\mathpalette)} -% \darg{Leading superscript for the sqrt sign} -% A re-implementation of \LaTeX's hard-coded n-root sign using the appropriate \cmd\fontdimen s. -% \begin{macrocode} - \cs_set_nopar:Npn \r@@@@t ##1 ##2 - { - \hbox_set:Nn \l_tmpa_box - { - \c_math_toggle_token - \m@th - ##1 - \sqrtsign { ##2 } - \c_math_toggle_token - } - \@@_mathstyle_scale:Nnn ##1 { \kern } - { \fontdimen 63 \l_@@_font } - \box_move_up:nn - { - (\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 } - \box_use_clear:N \l_tmpa_box - } -% \end{macrocode} -% \end{macro} -% \begin{macrocode} - } - } -% -%<*LU> - { - \@ifpackageloaded { amsmath } { } - { -% \end{macrocode} -% \begin{macro}{\root} -% Redefine this macro for \LuaTeX, which provides us a nice primitive to use. -% \begin{macrocode} - \cs_set:Npn \root ##1 \of ##2 - { - \Uroot \l_@@_radical_sqrt_tl { ##1 } { ##2 } - } -% \end{macrocode} -% \end{macro} -% \begin{macrocode} - } - } -% -% \end{macrocode} -% -% -% \begin{macro}{\@@_fontdimen_to_percent:nn} -% \begin{macro}{\@@_fontdimen_to_scale:nn} -% \darg{Font dimen number} -% \darg{Font `variable'} -% \cmd\fontdimen s |10|, |11|, and |65| aren't actually dimensions, they're percentage values given in units of |sp|. -% \cs{@@_fontdimen_to_percent:nn} takes a font dimension number and outputs the decimal value of the associated parameter. -% \cs{@@_fontdimen_to_scale:nn} returns a dimension correspond to the current -% font size relative proportion based on that percentage. -% \begin{macrocode} -\cs_new:Nn \@@_fontdimen_to_percent:nn - { - \fp_eval:n { \dim_to_decimal:n { \fontdimen #1 #2 } * 65536 / 100 } - } -\cs_new:Nn \@@_fontdimen_to_scale:nn - { - \fp_eval:n {\@@_fontdimen_to_percent:nn {#1} {#2} * \f@size } pt - } -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \begin{macro}{\@@_mathstyle_scale:Nnn} -% \darg{A math style (\cs{scriptstyle}, say)} -% \darg{Macro that takes a non-delimited length argument (like \cmd\kern)} -% \darg{Length control sequence to be scaled according to the math style} -% This macro is used to scale the lengths reported by \cmd\fontdimen\ according to the scale factor for script- and scriptscript-size objects. -% \begin{macrocode} -\cs_new:Nn \@@_mathstyle_scale:Nnn - { - \ifx#1\scriptstyle - #2 \@@_fontdimen_to_percent:nn {10} \l_@@_font #3 - \else - \ifx#1\scriptscriptstyle - #2 \@@_fontdimen_to_percent:nn {11} \l_@@_font #3 - \else - #2 #3 - \fi - \fi - } -% \end{macrocode} -% \end{macro} -% -% \subsection{Unicode sub- and super-scripts} -% -% The idea here is to enter a scanning state after a superscript or subscript -% is encountered. -% If subsequent superscripts or subscripts (resp.) are found, -% they are lumped together. -% Each sub/super has a corresponding regular size -% glyph which is used by \XeTeX\ to typeset the results; this means that the -% actual subscript/superscript glyphs are never seen in the output -% document~--- they are only used as input characters. -% -% Open question: should the superscript-like `modifiers' (\unichar{1D2C} -% {modifier capital letter a} and on) be included here? -% \begin{macrocode} -\group_begin: -% \end{macrocode} -% \paragraph{Superscripts} -% Populate a property list with superscript characters; themselves as their -% key, and their replacement as each key's value. -% Then make the superscript active and bind it to the scanning function. -% -% \cs{scantokens} makes this process much simpler since we can activate the -% char and assign its meaning in one step. -% \begin{macrocode} -\cs_new:Nn \@@_setup_active_superscript:nn - { - \prop_gput:Nnn \g_@@_supers_prop {#1} {#2} - \char_set_catcode_active:N #1 - \@@_char_gmake_mathactive:N #1 - \scantokens - { - \cs_gset:Npn #1 - { - \tl_set:Nn \l_@@_ss_chain_tl {#2} - \cs_set_eq:NN \@@_sub_or_super:n \sp - \tl_set:Nn \l_@@_tmpa_tl {supers} - \@@_scan_sscript: - } - } - } -% \end{macrocode} -% Bam: -% \begin{macrocode} -\@@_setup_active_superscript:nn {^^^^2070} {0} -\@@_setup_active_superscript:nn {^^^^00b9} {1} -\@@_setup_active_superscript:nn {^^^^00b2} {2} -\@@_setup_active_superscript:nn {^^^^00b3} {3} -\@@_setup_active_superscript:nn {^^^^2074} {4} -\@@_setup_active_superscript:nn {^^^^2075} {5} -\@@_setup_active_superscript:nn {^^^^2076} {6} -\@@_setup_active_superscript:nn {^^^^2077} {7} -\@@_setup_active_superscript:nn {^^^^2078} {8} -\@@_setup_active_superscript:nn {^^^^2079} {9} -\@@_setup_active_superscript:nn {^^^^207a} {+} -\@@_setup_active_superscript:nn {^^^^207b} {-} -\@@_setup_active_superscript:nn {^^^^207c} {=} -\@@_setup_active_superscript:nn {^^^^207d} {(} -\@@_setup_active_superscript:nn {^^^^207e} {)} -\@@_setup_active_superscript:nn {^^^^2071} {i} -\@@_setup_active_superscript:nn {^^^^207f} {n} -\@@_setup_active_superscript:nn {^^^^02b0} {h} -\@@_setup_active_superscript:nn {^^^^02b2} {j} -\@@_setup_active_superscript:nn {^^^^02b3} {r} -\@@_setup_active_superscript:nn {^^^^02b7} {w} -\@@_setup_active_superscript:nn {^^^^02b8} {y} -% \end{macrocode} -% \paragraph{Subscripts} Ditto above. -% \begin{macrocode} -\cs_new:Nn \@@_setup_active_subscript:nn - { - \prop_gput:Nnn \g_@@_subs_prop {#1} {#2} - \char_set_catcode_active:N #1 - \@@_char_gmake_mathactive:N #1 - \scantokens - { - \cs_gset:Npn #1 - { - \tl_set:Nn \l_@@_ss_chain_tl {#2} - \cs_set_eq:NN \@@_sub_or_super:n \sb - \tl_set:Nn \l_@@_tmpa_tl {subs} - \@@_scan_sscript: - } - } - } -% \end{macrocode} -% A few more subscripts than superscripts: -% \begin{macrocode} -\@@_setup_active_subscript:nn {^^^^2080} {0} -\@@_setup_active_subscript:nn {^^^^2081} {1} -\@@_setup_active_subscript:nn {^^^^2082} {2} -\@@_setup_active_subscript:nn {^^^^2083} {3} -\@@_setup_active_subscript:nn {^^^^2084} {4} -\@@_setup_active_subscript:nn {^^^^2085} {5} -\@@_setup_active_subscript:nn {^^^^2086} {6} -\@@_setup_active_subscript:nn {^^^^2087} {7} -\@@_setup_active_subscript:nn {^^^^2088} {8} -\@@_setup_active_subscript:nn {^^^^2089} {9} -\@@_setup_active_subscript:nn {^^^^208a} {+} -\@@_setup_active_subscript:nn {^^^^208b} {-} -\@@_setup_active_subscript:nn {^^^^208c} {=} -\@@_setup_active_subscript:nn {^^^^208d} {(} -\@@_setup_active_subscript:nn {^^^^208e} {)} -\@@_setup_active_subscript:nn {^^^^2090} {a} -\@@_setup_active_subscript:nn {^^^^2091} {e} -\@@_setup_active_subscript:nn {^^^^2095} {h} -\@@_setup_active_subscript:nn {^^^^1d62} {i} -\@@_setup_active_subscript:nn {^^^^2c7c} {j} -\@@_setup_active_subscript:nn {^^^^2096} {k} -\@@_setup_active_subscript:nn {^^^^2097} {l} -\@@_setup_active_subscript:nn {^^^^2098} {m} -\@@_setup_active_subscript:nn {^^^^2099} {n} -\@@_setup_active_subscript:nn {^^^^2092} {o} -\@@_setup_active_subscript:nn {^^^^209a} {p} -\@@_setup_active_subscript:nn {^^^^1d63} {r} -\@@_setup_active_subscript:nn {^^^^209b} {s} -\@@_setup_active_subscript:nn {^^^^209c} {t} -\@@_setup_active_subscript:nn {^^^^1d64} {u} -\@@_setup_active_subscript:nn {^^^^1d65} {v} -\@@_setup_active_subscript:nn {^^^^2093} {x} -\@@_setup_active_subscript:nn {^^^^1d66} {\beta} -\@@_setup_active_subscript:nn {^^^^1d67} {\gamma} -\@@_setup_active_subscript:nn {^^^^1d68} {\rho} -\@@_setup_active_subscript:nn {^^^^1d69} {\phi} -\@@_setup_active_subscript:nn {^^^^1d6a} {\chi} -% \end{macrocode} -% -% \begin{macrocode} -\group_end: -% \end{macrocode} -% The scanning command, which collects a chain of subscripts or a chain -% of superscripts and then typesets what it has collected. -% \begin{macrocode} -\cs_new:Npn \@@_scan_sscript: - { - \@@_scan_sscript:TF - { - \@@_scan_sscript: - } - { - \@@_sub_or_super:n {\l_@@_ss_chain_tl} - } - } -% \end{macrocode} -% We do not skip spaces when scanning ahead, and we explicitly wish to -% bail out on encountering a space or a brace. These cases are filtered -% using \cs{peek_N_type:TF}. Otherwise the token can be taken as an -% \texttt{N}-type argument. Then we search for it in the appropriate -% property list (\cs{l_@@_tmpa_tl} is |subs| or |supers|). -% If found, add the value to the current chain of sub/superscripts. -% Remember to put the character back in the input otherwise. -% The \cs{group_align_safe_begin:} and \cs{group_align_safe_end:} are -% needed in case |#3| is |&|. -% \begin{macrocode} -\cs_new:Npn \@@_scan_sscript:TF #1#2 - { - \peek_N_type:TF - { - \group_align_safe_begin: - \@@_scan_sscript_aux:nnN {#1} {#2} - } - {#2} - } -\cs_new:Npn \@@_scan_sscript_aux:nnN #1#2#3 - { - \prop_get:cnNTF {g_@@_\l_@@_tmpa_tl _prop} {#3} \l_@@_tmpb_tl - { - \tl_put_right:NV \l_@@_ss_chain_tl \l_@@_tmpb_tl - \group_align_safe_end: - #1 - } - { \group_align_safe_end: #2 #3 } - } -% \end{macrocode} -% -% \subsubsection{Active fractions} -% Active fractions can be setup independently of any maths font definition; -% all it requires is a mapping from the Unicode input chars to the relevant -% \LaTeX\ fraction declaration. -% -% \begin{macrocode} -\cs_new:Npn \@@_define_active_frac:Nw #1 #2/#3 - { - \char_set_catcode_active:N #1 - \@@_char_gmake_mathactive:N #1 - \tl_rescan:nn - { - \catcode`\_=11\relax - \catcode`\:=11\relax - } - { - \cs_gset:Npx #1 - { - \bool_if:NTF \l_@@_smallfrac_bool {\exp_not:N\tfrac} {\exp_not:N\frac} - {#2} {#3} - } - } - } -% \end{macrocode} -% These are redefined for each math font selection in case the |active-frac| -% feature changes. -% \begin{macrocode} -\cs_new:Npn \@@_setup_active_frac: - { - \group_begin: - \@@_define_active_frac:Nw ^^^^2189 0/3 - \@@_define_active_frac:Nw ^^^^2152 1/{10} - \@@_define_active_frac:Nw ^^^^2151 1/9 - \@@_define_active_frac:Nw ^^^^215b 1/8 - \@@_define_active_frac:Nw ^^^^2150 1/7 - \@@_define_active_frac:Nw ^^^^2159 1/6 - \@@_define_active_frac:Nw ^^^^2155 1/5 - \@@_define_active_frac:Nw ^^^^00bc 1/4 - \@@_define_active_frac:Nw ^^^^2153 1/3 - \@@_define_active_frac:Nw ^^^^215c 3/8 - \@@_define_active_frac:Nw ^^^^2156 2/5 - \@@_define_active_frac:Nw ^^^^00bd 1/2 - \@@_define_active_frac:Nw ^^^^2157 3/5 - \@@_define_active_frac:Nw ^^^^215d 5/8 - \@@_define_active_frac:Nw ^^^^2154 2/3 - \@@_define_active_frac:Nw ^^^^00be 3/4 - \@@_define_active_frac:Nw ^^^^2158 4/5 - \@@_define_active_frac:Nw ^^^^215a 5/6 - \@@_define_active_frac:Nw ^^^^215e 7/8 - \group_end: - } -\@@_setup_active_frac: -% \end{macrocode} -% -% \subsection{Synonyms and all the rest} -% -% These are symbols with multiple names. Eventually to be taken care of -% automatically by the maths characters database. -% \begin{macrocode} -\protected\def\to{\rightarrow} -\protected\def\le{\leq} -\protected\def\ge{\geq} -\protected\def\neq{\ne} -\protected\def\triangle{\mathord{\bigtriangleup}} -\protected\def\bigcirc{\mdlgwhtcircle} -\protected\def\circ{\vysmwhtcircle} -\protected\def\bullet{\smblkcircle} -\protected\def\mathyen{\yen} -\protected\def\mathsterling{\sterling} -\protected\def\diamond{\smwhtdiamond} -\protected\def\emptyset{\varnothing} -\protected\def\hbar{\hslash} -\protected\def\land{\wedge} -\protected\def\lor{\vee} -\protected\def\owns{\ni} -\protected\def\gets{\leftarrow} -\protected\def\mathring{\ocirc} -\protected\def\lnot{\neg} -\protected\def\longdivision{\longdivisionsign} -% \end{macrocode} -% These are somewhat odd: (and their usual Unicode uprightness does not match their amssymb glyphs) -% \begin{macrocode} -\protected\def\backepsilon{\upbackepsilon} -\protected\def\eth{\matheth} -% \end{macrocode} -% These are names that are `frozen' in HTML but have dumb names: -% \begin{macrocode} -\protected\def\dbkarow {\dbkarrow} -\protected\def\drbkarow{\drbkarrow} -\protected\def\hksearow{\hksearrow} -\protected\def\hkswarow{\hkswarrow} -% \end{macrocode} -% -% Due to the magic of OpenType math, big operators are automatically -% enlarged when necessary. Since there isn't a separate unicode glyph for -% `small integral', I'm not sure if there is a better way to do this: -% \begin{macrocode} -\protected\def\smallint{\mathop{\textstyle\int}\limits} -% \end{macrocode} -% -% \begin{macro}{\underbar} -% \begin{macrocode} -\cs_set_eq:NN \latexe_underbar:n \underbar -\renewcommand\underbar - { - \mode_if_math:TF \mathunderbar \latexe_underbar:n - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\colon} -% Define \cs{colon} as a mathpunct `|:|'. -% This is wrong: it should be \unichar{003A} {colon} instead! -% We hope no-one will notice. -% \begin{macrocode} -\@ifpackageloaded{amsmath} - { - % define their own colon, perhaps I should just steal it. (It does look much better.) - } - { - \cs_set_protected:Npn \colon - { - \bool_if:NTF \g_@@_literal_colon_bool {:} { \mathpunct{:} } - } - } -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\digamma} -% \begin{macro}{\Digamma} -% I might end up just changing these in the table. -% \begin{macrocode} -\protected\def\digamma{\updigamma} -\protected\def\Digamma{\upDigamma} -% \end{macrocode} -% \end{macro} -% \end{macro} -% -% \paragraph{Symbols} -% \begin{macrocode} -\cs_set_protected:Npn \| {\Vert} -% \end{macrocode} -% \cs{mathinner} items: -% \begin{macrocode} -\cs_set_protected:Npn \mathellipsis {\mathinner{\unicodeellipsis}} -\cs_set_protected:Npn \cdots {\mathinner{\unicodecdots}} -% \end{macrocode} -% -% \begin{macrocode} -\cs_set_eq:NN \@@_text_slash: \slash -\cs_set_protected:Npn \slash - { - \mode_if_math:TF {\mathslash} {\@@_text_slash:} - } -% \end{macrocode} -% -% \paragraph{\cs{not}} -% The situation of \cs{not} symbol is currently messy, in Unicode it is defined -% as a combining mark so naturally it should be treated as a math accent, -% however neither Lua\TeX\ nor \XeTeX\ correctly place it as it needs special -% treatment compared to other accents, furthermore a math accent changes the -% spacing of its nucleus, so \cs{not=} will be spaced as an ordinary not -% relational symbol, which is undesired. -% -% Here modify \cs{not} to a macro that tries to use predefined negated symbols, -% which would give better results in most cases, until there is more robust -% solution in the engines. -% -% This code is based on an answer to a TeX -- Stack Exchange question by Enrico -% Gregorio\footnote{\url{http://tex.stackexchange.com/a/47260/729}}. -% -% \begin{macrocode} -\cs_new:Npn \@@_newnot:N #1 - { - \tl_set:Nx \l_not_token_name_tl { \token_to_str:N #1 } - \exp_args:Nx \tl_if_empty:nF { \tl_tail:V \l_not_token_name_tl } - { - \tl_set:Nx \l_not_token_name_tl { \tl_tail:V \l_not_token_name_tl } - } - \cs_if_exist:cTF { n \l_not_token_name_tl } - { - \use:c { n \l_not_token_name_tl } - } - { - \cs_if_exist:cTF { not \l_not_token_name_tl } - { - \use:c { not \l_not_token_name_tl } - } - { - \@@_oldnot: #1 - } - } - } -% \end{macrocode} -% \begin{macrocode} -\cs_set_eq:NN \@@_oldnot: \not -\AtBeginDocument{\cs_set_eq:NN \not \@@_newnot:N} -% \end{macrocode} -% \begin{macrocode} -\cs_new_protected_nopar:Nn \@@_setup_negations: - { - \cs_gset:cpn { not= } { \neq } - \cs_gset:cpn { not< } { \nless } - \cs_gset:cpn { not> } { \ngtr } - \cs_gset:Npn \ngets { \nleftarrow } - \cs_gset:Npn \nsimeq { \nsime } - \cs_gset:Npn \nequal { \ne } - \cs_gset:Npn \nle { \nleq } - \cs_gset:Npn \nge { \ngeq } - \cs_gset:Npn \ngreater { \ngtr } - \cs_gset:Npn \nforksnot { \forks } - } -% \end{macrocode} % % \begin{macrocode} % -- cgit v1.2.3