summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-01-07 23:46:58 +0000
committerKarl Berry <karl@freefriends.org>2018-01-07 23:46:58 +0000
commitf15ab98da224024bdcb9d2b70a263c7f6143a91b (patch)
tree8368ce018ac0869d5d556cc47b29de4770ad3e62 /Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx
parent6c0d576e1d48613f952b56e99e4dd9d59e41a265 (diff)
unicode-math (7jan18)
git-svn-id: svn://tug.org/texlive/trunk@46240 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx')
-rw-r--r--Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx375
1 files changed, 215 insertions, 160 deletions
diff --git a/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx b/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx
index 0a7f386eda6..19ea4bcebbf 100644
--- a/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx
+++ b/Master/texmf-dist/source/latex/unicode-math/um-code-epilogue.dtx
@@ -1,4 +1,5 @@
%%^^A%% um-code-epilogue.dtx -- part of UNICODE-MATH <wspr.io/unicode-math>
+%%^^A%% Assorted definitions to close up.
% \section{Epilogue}
%
@@ -16,23 +17,25 @@
% to upright or italic happens with the mathcode definitions, whereas these macros
% just stand for the literal Unicode characters.
% \begin{macrocode}
-\AtBeginDocument{\@@_resolve_greek:}
+\AtBeginDocument { \@@_resolve_greek: }
+% \end{macrocode}
+% \begin{macrocode}
\cs_new:Npn \@@_resolve_greek:
- {
- \clist_map_inline:nn
- {
- Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,
- alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,
- Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,
- mu,nu,xi,omicron,pi,rho,sigma,tau,upsilon,phi,chi,psi,omega,
- varTheta,varsigma,vartheta,varkappa,varrho,varpi,varepsilon,varphi
- }
- {
- \tl_set:cx {##1} { \exp_not:c { mit ##1 } }
- \tl_set:cx {up ##1} { \exp_not:N \symup \exp_not:c { ##1 } }
- \tl_set:cx {it ##1} { \exp_not:N \symit \exp_not:c { ##1 } }
- }
- }
+ {
+ \clist_map_inline:nn
+ {
+ Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,
+ alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,
+ Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,
+ mu,nu,xi,omicron,pi,rho,sigma,tau,upsilon,phi,chi,psi,omega,
+ varTheta,varsigma,vartheta,varkappa,varrho,varpi,varepsilon,varphi
+ }
+ {
+ \tl_set:cx {##1} { \exp_not:c { mit ##1 } }
+ \tl_set:cx {up ##1} { \exp_not:N \symup \exp_not:c { ##1 } }
+ \tl_set:cx {it ##1} { \exp_not:N \symit \exp_not:c { ##1 } }
+ }
+ }
% \end{macrocode}
% \end{macro}
%
@@ -42,128 +45,102 @@
%
% 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 }
-%</LU>
-% \end{macrocode}
%
+% \begin{macro}{\@@_redefine_radical:}
% \begin{macrocode}
-\AtBeginDocument{\@@_redefine_radical:}
-\cs_new:Nn \@@_redefine_radical:
-%<*XE>
- {
- \@ifpackageloaded { amsmath } { }
- {
+\AtBeginDocument{ \@ifpackageloaded { amsmath } { } { \@@_redefine_radical: } }
% \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}
+%<*XE>
+\cs_new:Nn \@@_redefine_radical:
+ {
\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}
- }
- }
+ {
+ \hbox_set:Nn \l_tmpa_box
+ {
+ \c_math_toggle_token \m@th
+ ##1 \sqrtsign { ##2 }
+ \c_math_toggle_token
+ }
+ \@@_mathstyle_scale:NnnN ##1 { \kern } { \fontdimen 63 \g_@@_sqrt_font_cmd_tl } \g_@@_sqrt_font_cmd_tl
+ \box_move_up:nn
+ {
+ (\box_ht:N \l_tmpa_box - \box_dp:N \l_tmpa_box) * \number \fontdimen 65 \g_@@_sqrt_font_cmd_tl / 100
+ }
+ { \box_use:N \rootbox }
+ \@@_mathstyle_scale:NnnN ##1 { \kern } { \fontdimen 64 \g_@@_sqrt_font_cmd_tl } \g_@@_sqrt_font_cmd_tl
+ \box_use_clear:N \l_tmpa_box
+ }
+ }
%</XE>
-%<*LU>
- {
- \@ifpackageloaded { amsmath } { }
- {
% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\root}
% Redefine this macro for \LuaTeX, which provides us a nice primitive to use.
% \begin{macrocode}
+%<*LU>
+\cs_new:Nn \@@_redefine_radical:
+ {
\cs_set:Npn \root ##1 \of ##2
- {
- \Uroot \l_@@_radical_sqrt_tl { ##1 } { ##2 }
- }
-% \end{macrocode}
-% \end{macro}
-% \begin{macrocode}
- }
- }
+ {
+ \Uroot \l_@@_radical_sqrt_tl { ##1 } { ##2 }
+ }
+ }
%</LU>
% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
%
% \subsubsection{Active fractions}
-% Active fractions can be setup independently of any maths font definition;
+%
+% Active fractions can be set up 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}
- }
- }
- }
+\cs_new:Nn \@@_which_frac:nn
+ {
+ \bool_if:NTF \l_@@_smallfrac_bool {\tfrac} {\frac} {#1} {#2}
+ }
% \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:
+ {
+ \@@_mathactive_remap:nn {"2189} { \@@_which_frac:nn {0} {3} }
+ \@@_mathactive_remap:nn {"2152} { \@@_which_frac:nn {1} {10} }
+ \@@_mathactive_remap:nn {"2151} { \@@_which_frac:nn {1} {9} }
+ \@@_mathactive_remap:nn {"215B} { \@@_which_frac:nn {1} {8} }
+ \@@_mathactive_remap:nn {"2150} { \@@_which_frac:nn {1} {7} }
+ \@@_mathactive_remap:nn {"2159} { \@@_which_frac:nn {1} {6} }
+ \@@_mathactive_remap:nn {"2155} { \@@_which_frac:nn {1} {5} }
+ \@@_mathactive_remap:nn {"00BC} { \@@_which_frac:nn {1} {4} }
+ \@@_mathactive_remap:nn {"2153} { \@@_which_frac:nn {1} {3} }
+ \@@_mathactive_remap:nn {"215C} { \@@_which_frac:nn {3} {8} }
+ \@@_mathactive_remap:nn {"2156} { \@@_which_frac:nn {2} {5} }
+ \@@_mathactive_remap:nn {"00BD} { \@@_which_frac:nn {1} {2} }
+ \@@_mathactive_remap:nn {"2157} { \@@_which_frac:nn {3} {5} }
+ \@@_mathactive_remap:nn {"215D} { \@@_which_frac:nn {5} {8} }
+ \@@_mathactive_remap:nn {"2154} { \@@_which_frac:nn {2} {3} }
+ \@@_mathactive_remap:nn {"00BE} { \@@_which_frac:nn {3} {4} }
+ \@@_mathactive_remap:nn {"2158} { \@@_which_frac:nn {4} {5} }
+ \@@_mathactive_remap:nn {"215A} { \@@_which_frac:nn {5} {6} }
+ \@@_mathactive_remap:nn {"215E} { \@@_which_frac:nn {7} {8} }
+ }
% \end{macrocode}
%
+% \begin{macrocode}
+\AtBeginDocument { \@@_setup_active_frac: }
+% \end{macrocode}
+%
+%
% \subsection{Synonyms and all the rest}
%
% These are symbols with multiple names. Eventually to be taken care of
@@ -214,9 +191,9 @@
% \begin{macrocode}
\cs_set_eq:NN \latexe_underbar:n \underbar
\renewcommand\underbar
- {
- \mode_if_math:TF \mathunderbar \latexe_underbar:n
- }
+ {
+ \mode_if_math:TF \mathunderbar \latexe_underbar:n
+ }
% \end{macrocode}
% \end{macro}
%
@@ -226,15 +203,15 @@
% 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{:} }
- }
- }
+ {
+ % 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}
%
@@ -249,9 +226,11 @@
% \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}}
@@ -261,18 +240,20 @@
% \begin{macrocode}
\cs_set_eq:NN \@@_text_slash: \slash
\cs_set_protected:Npn \slash
- {
- \mode_if_math:TF {\mathslash} {\@@_text_slash:}
- }
+ {
+ \mode_if_math:TF {\mathslash} {\@@_text_slash:}
+ }
% \end{macrocode}
%
+%
% \subsubsection{\cs{not}}
% \label{sec:negations}
%
% 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
+% however \XeTeX\ does not 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.
%
@@ -283,50 +264,124 @@
% 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{macro}{\not}
% \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 }
+\DeclareDocumentCommand \not {m}
+ {
+ \tl_set:Nx \l_@@_not_token_name_tl { \cs_to_str:N #1 }
+ \tl_if_empty:NT \l_@@_not_token_name_tl
+ {
+ \tl_set:Nx \l_@@_not_token_name_tl { \token_to_str:N #1 }
+ }
+ \cs_if_exist:cTF { not \l_@@_not_token_name_tl }
{
- \use:c { not \l_not_token_name_tl }
+ \use:c { not \l_@@_not_token_name_tl }
}
{
- \@@_oldnot: #1
+ \cs_if_exist:cTF { n \l_@@_not_token_name_tl }
+ {
+ \use:c { n \l_@@_not_token_name_tl }
+ }
+ {
+ \tl_if_eq:nnTF {#1} {$} { \notaccent{} } { \notaccent } #1
+ }
}
- }
- }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\NewNegationCommand}
+% \begin{macro}{\RenewNegationCommand}
+% \begin{macrocode}
+\DeclareDocumentCommand \NewNegationCommand {mm}
+ {
+ \@@_set_negation_command:Nnn \cs_new_protected:cpn {#1} {#2}
+ }
% \end{macrocode}
+%
% \begin{macrocode}
-\cs_set_eq:NN \@@_oldnot: \not
-\AtBeginDocument{\cs_set_eq:NN \not \@@_newnot:N}
+\DeclareDocumentCommand \RenewNegationCommand {mm}
+ {
+ \@@_set_negation_command:Nnn \cs_set_protected:cpn {#1} {#2}
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_set:Nn \@@_set_negation_command:Nnn
+ {
+ \tl_set:Nx \l_@@_not_token_name_tl { \cs_to_str:N #2 }
+ \tl_if_empty:NT \l_@@_not_token_name_tl
+ {
+ \tl_set:Nx \l_@@_not_token_name_tl { \token_to_str:N #2 }
+ }
+ #1 { not \l_@@_not_token_name_tl } { #3 }
+ }
% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
% \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 }
- }
+\NewNegationCommand { = } { \neq }
+\NewNegationCommand { < } { \nless }
+\NewNegationCommand { > } { \ngtr }
+\NewNegationCommand { \gets } { \nleftarrow }
+\NewNegationCommand { \simeq } { \nsime }
+\NewNegationCommand { \equal } { \ne }
+\NewNegationCommand { \le } { \nleq }
+\NewNegationCommand { \ge } { \ngeq }
+\NewNegationCommand { \greater } { \ngtr }
+\NewNegationCommand { \forksnot } { \forks }
% \end{macrocode}
%
%
+% \subsubsection{Full-width remapping}
+%
+% While this could be done with the full mathcode remapping machinery used
+% for the other purposes, it would be fairly redundant with plain ASCII.
+% Worse, this would slow down what is already an inefficient part of \pkg{unicode-math}.
+%
+% Instead we use mathactive to do a plain old mapping from full-width to ASCII directly.
+%
+% Until I get requests for it, I've not included symbols or punctuation here.
+%
+% \paragraph{Numbers}
+%
+% \begin{macrocode}
+\int_step_inline:nnnn {0} {1} {9}
+ {
+ \@@_mathactive_remap:nn {"FF10+#1} {\char\int_eval:n{`\0+#1}}
+ }
+% \end{macrocode}
+%
+% \paragraph{Letters}
+%
+% \begin{macrocode}
+\int_step_inline:nnnn {0} {1} {26}
+ {
+ \@@_mathactive_remap:nn {"FF21+#1} {\char\int_eval:n{`\A+#1}}
+ \@@_mathactive_remap:nn {"FF41+#1} {\char\int_eval:n{`\a+#1}}
+ }
+% \end{macrocode}
+%
+%
+% \subsection{Legacy characters}
+%
+% \begin{macro}{\@@_undeclare_symbol:N}
+% \begin{macrocode}
+\cs_new:Nn \@@_undeclare_symbol:N
+ {
+ \cs_set_protected:Npn #1
+ { \@@_error:nx {legacy-char-not-supported} { \token_to_str:N #1 } }
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% If you have better ideas about what to do here, please mention.
+% \begin{macrocode}
+\@@_undeclare_symbol:N \arrowvert
+\@@_undeclare_symbol:N \Arrowvert
+\@@_undeclare_symbol:N \bracevert
+% \end{macrocode}
%
% \begin{macrocode}
%</package>
@@ -343,7 +398,7 @@
% the conditions of the LaTeX Project Public License, version 1.3c or higher
% (your choice): <http://www.latex-project.org/lppl/>.
% ------------------------------------------------
-% Copyright 2006-2017 Will Robertson, LPPL "maintainer"
+% Copyright 2006-2018 Will Robertson, LPPL "maintainer"
% Copyright 2010-2017 Philipp Stephani
% Copyright 2011-2017 Joseph Wright
% Copyright 2012-2015 Khaled Hosny