summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx')
-rw-r--r--Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx550
1 files changed, 293 insertions, 257 deletions
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 fdaa2e6d29a..b6121b84d02 100644
--- a/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx
+++ b/Master/texmf-dist/source/latex/unicode-math/unicode-math.dtx
@@ -6,7 +6,19 @@
\begingroup
\input docstrip.tex
\keepsilent
-\preamble
+\let\MetaPrefix\DoubleperCent
+\declarepreamble\texpreamble
+Copyright 2006-2011 Will Robertson <will.robertson@latex-project.org>
+Copyright 2010-2011 Philipp Stephani <st_philipp@yahoo.de>
+
+This package is free software and may be redistributed and/or modified under
+the conditions of the LaTeX Project Public License, version 1.3c or higher
+(your choice): <http://www.latex-project.org/lppl/>.
+
+This work is "author-maintained" by Will Robertson.
+\endpreamble
+\def\MetaPrefix{--}
+\declarepreamble\luapreamble
Copyright 2006-2011 Will Robertson <will.robertson@latex-project.org>
Copyright 2010-2011 Philipp Stephani <st_philipp@yahoo.de>
@@ -18,11 +30,17 @@ This work is "author-maintained" by Will Robertson.
\endpreamble
\nopostamble
\askforoverwritefalse
+\let\MetaPrefix\DoubleperCent
+\usepreamble\texpreamble
\generate{\file{unicode-math.sty}{
\from{unicode-math.dtx}{preamble}
\from{unicode-math.dtx}{msg}
\from{unicode-math.dtx}{package,stix}
}}
+\def\MetaPrefix{--}
+\usepreamble\luapreamble
+\generate{\file{unicode-math.lua}{\from{unicode-math.dtx}{lua}}}
+\let\MetaPrefix\DoubleperCent
\nopreamble
\def\tempa{plain}
\ifx\tempa\fmtname\endgroup\expandafter\bye\fi
@@ -32,7 +50,7 @@ This work is "author-maintained" by Will Robertson.
%</internal>
%<preamble>\ProvidesPackage{unicode-math}
%<*preamble>
- [2011/01/29 v0.5d Unicode maths in XeLaTeX and LuaLaTeX]
+ [2011/07/31 v0.5e Unicode maths in XeLaTeX and LuaLaTeX]
%</preamble>
%<*internal>
\documentclass[a4paper]{ltxdoc}
@@ -138,11 +156,13 @@ This work is "author-maintained" by Will Robertson.
% \end{verbatim}
% \end{quote}
%
-% Two OpenType maths fonts are included by default in \TeX\ Live 2010:
-% Asana Math and XITS Math. These can be loaded directly with their filename
+% Three OpenType maths fonts are included by default in \TeX\ Live 2011:
+% Latin Modern Math, Asana Math, and XITS Math.
+% These can be loaded directly with their filename
% with both \XeLaTeX\ and \LuaLaTeX; resp.,
% \begin{quote}
% \begin{verbatim}
+% \setmathfont{lmmath-regular.otf}
% \setmathfont{Asana-Math.otf}
% \setmathfont{xits-math.otf}
% \end{verbatim}
@@ -150,6 +170,9 @@ This work is "author-maintained" by Will Robertson.
% Other OpenType maths fonts may be loaded in the usual way; please see the
% \pkg{fontspec} documentation for more information.
%
+% Once the package is loaded, traditional TFM-based fonts are not supported any more;
+% you can only switch to a different OpenType math font using the \cs{setmathfont} command.
+%
%
% \subsection{Package options}
% Package options may be set when the package as loaded or at any later
@@ -259,7 +282,7 @@ This work is "author-maintained" by Will Robertson.
% \seclabel{range}
%
% There will probably be few cases where a single Unicode maths font suffices
-% (simply due to glyph coverage). The upcoming \STIX\ font comes to mind as a
+% (simply due to glyph coverage). The \STIX\ font comes to mind as a
% possible exception. It will therefore be necessary to delegate specific
% Unicode ranges of glyphs to separate fonts:
% \codeline{\cmd\setmathfont|[range=|\meta{unicode range}|,|\meta{font features}|]|\marg{font name}}
@@ -631,10 +654,10 @@ This work is "author-maintained" by Will Robertson.
% \subsubsection{Epsilon and phi: $\epsilon$ vs.\ $\varepsilon$ and $\phi$ vs.\ $\varphi$}
% \seclabel{vargreek-shape}
%
-% \TeX\ defines \cs{epsilon} to look like $\varepsilon$ and \cs{varepsilon} to
-% look like $\epsilon$. The Unicode glyph directly after delta and before zeta
-% is `epsilon' and looks like $\epsilon$; there is a subsequent variant of
-% epsilon that looks like $\varepsilon$. This creates a problem. People who
+% \TeX\ defines \cs{epsilon} to look like $\epsilon$ and \cs{varepsilon} to
+% look like $\varepsilon$. By constrast, the Unicode glyph directly after delta and before zeta
+% is `epsilon' and looks like $\varepsilon$; there is a subsequent variant of
+% epsilon that looks like $\epsilon$. This creates a problem. People who
% use Unicode input won't want their glyphs transforming; \TeX\ users will be
% confused that what they think as `normal epsilon' is actual the `variant
% epsilon'. And the same problem exists for `phi'.
@@ -702,22 +725,8 @@ This work is "author-maintained" by Will Robertson.
% \begin{figure}\centering
% \fbox{\fontspec{Charis SIL}\Large
% A
-% ^^^^2070
-% ^^^^00b9
-% ^^^^00b2
-% ^^^^00b3
-% ^^^^2074
-% ^^^^2075
-% ^^^^2076
-% ^^^^2077
-% ^^^^2078
-% ^^^^2079
-% ^^^^207a
-% ^^^^207b
-% ^^^^207c
-% ^^^^207d
-% ^^^^207e
-% ^^^^2071
+% ^^^^2070 ^^^^00b9 ^^^^00b2 ^^^^00b3 ^^^^2074 ^^^^2075 ^^^^2076 ^^^^2077
+% ^^^^2078 ^^^^2079 ^^^^207a ^^^^207b ^^^^207c ^^^^207d ^^^^207e ^^^^2071
% ^^^^207f
% Z}
% \caption{
@@ -733,34 +742,10 @@ This work is "author-maintained" by Will Robertson.
% \begin{figure}\centering
% \fbox{\fontspec{Charis SIL}\Large
% A
-% ^^^^2080
-% ^^^^2081
-% ^^^^2082
-% ^^^^2083
-% ^^^^2084
-% ^^^^2085
-% ^^^^2086
-% ^^^^2087
-% ^^^^2088
-% ^^^^2089
-% ^^^^208a
-% ^^^^208b
-% ^^^^208c
-% ^^^^208d
-% ^^^^208e
-% ^^^^2090
-% ^^^^2091
-% ^^^^1d62
-% ^^^^2092
-% ^^^^1d63
-% ^^^^1d64
-% ^^^^1d65
-% ^^^^2093
-% ^^^^1d66
-% ^^^^1d67
-% ^^^^1d68
-% ^^^^1d69
-% ^^^^1d6a
+% ^^^^2080 ^^^^2081 ^^^^2082 ^^^^2083 ^^^^2084 ^^^^2085 ^^^^2086 ^^^^2087
+% ^^^^2088 ^^^^2089 ^^^^208a ^^^^208b ^^^^208c ^^^^208d ^^^^208e ^^^^2090
+% ^^^^2091 ^^^^1d62 ^^^^2092 ^^^^1d63 ^^^^1d64 ^^^^1d65 ^^^^2093 ^^^^1d66
+% ^^^^1d67 ^^^^1d68 ^^^^1d69 ^^^^1d6a
% Z}
% \caption{
% The Unicode subscripts supported as input characters.
@@ -1048,7 +1033,7 @@ This work is "author-maintained" by Will Robertson.
\RequirePackage{l3keys2e}
\RequirePackage{fontspec}[2010/10/25]
\RequirePackage{catchfile}
-\RequirePackage{trimspaces}
+\RequirePackage{trimspaces}% I'd like to incorporate this into expl3...
\RequirePackage{fix-cm} % avoid some warnings
\RequirePackage{filehook}[2011/01/03]
% \end{macrocode}
@@ -1058,6 +1043,20 @@ This work is "author-maintained" by Will Robertson.
\ExplSyntaxOn
% \end{macrocode}
%
+% \paragraph{Forwards compatibility}
+% \begin{macrocode}
+\cs_if_exist:NF \char_set_catcode_other:N
+ {
+ \cs_set_eq:NN \c_math_toggle_token \c_math_shift_token
+ \cs_set_eq:NN \char_set_catcode_other:N \char_make_other:N
+ \cs_set_eq:NN \char_set_catcode_active:N \char_make_active:N
+ \cs_set_eq:NN \char_set_catcode_active:n \char_make_active:n
+ \cs_set_eq:NN \char_set_catcode_escape:N \char_make_escape:N
+ \cs_set_eq:NN \char_set_catcode_math_superscript:N
+ \char_make_math_superscript:N
+ }
+% \end{macrocode}
+%
% \paragraph{Extra \pkg{expl3} variants}
% \begin{macrocode}
\cs_generate_variant:Nn \tl_put_right:Nn {cx}
@@ -1073,14 +1072,17 @@ This work is "author-maintained" by Will Robertson.
\cs:w #3 \exp_after:wN \cs_end:
\cs:w #4 \cs_end:
}
+\cs_new_protected_nopar:Npn \bool_const:Nn #1 #2 {
+ \bool_new:N #1
+ \bool_set:Nn #1 { #2 }
+}
% \end{macrocode}
%
%
% \paragraph{Conditionals}
% Engine capabilities:
% \begin{macrocode}
-\bool_new:N \c_um_have_fixed_accents_bool
-\bool_set:Nn \c_um_have_fixed_accents_bool {
+\bool_const:Nn \c_um_have_fixed_accents_bool {
\c_luatex_is_engine_bool && \int_compare_p:n { \luatexversion > 64 }
}
% \end{macrocode}
@@ -1170,6 +1172,9 @@ This work is "author-maintained" by Will Robertson.
\um_cs_compat:n {radical}
\um_cs_compat:n {mathaccent}
\um_cs_compat:n {delimiter}
+\luatex_if_engine:T {
+ \RequirePackage { lualatex-math } [ 2011/05/05 ]
+}
% \end{macrocode}
%
% \subsubsection{Function variants}
@@ -1178,8 +1183,40 @@ This work is "author-maintained" by Will Robertson.
\cs_generate_variant:Nn \fontspec_select:nn {x}
% \end{macrocode}
%
+% \subsubsection{\Hologo{LuaLaTeX} module}
+%
+% We create a \pkg{luatexbase} module that contains Lua functions for use with \hologo{LuaLaTeX}.
% \begin{macrocode}
+\luatex_if_engine:T {
+ \RequirePackage { luatexbase }
+ \RequirePackage { luaotfload } [ 2010/11/26 ]
+ \RequireLuaModule { unicode-math } [ 2011/04/23 ]
+}
%</preamble>
+%<*lua>
+local err, warn, info, log = luatexbase.provides_module({
+ name = "unicode-math",
+ date = "2011/04/23",
+ version = 0.1,
+ description = "Unicode math typesetting for LuaLaTeX",
+ author = "Khaled Hosny, Will Robertson, Philipp Stephani",
+ licence = "LPPL v1.3+"
+})
+% \end{macrocode}
+% \LuaTeX\ does not provide interface to accessing
+% \texttt{(Script)ScriptPercentScaleDown} math constants, so we
+% emulate \XeTeX\ behaviour by setting \cs{fontdimen10} and
+% \cs{fontdimen11}.
+% \begin{macrocode}
+local function set_sscale_dimens(fontdata)
+ local mc = fontdata.MathConstants
+ if mc then
+ fontdata.parameters[10] = mc.ScriptPercentScaleDown or 70
+ fontdata.parameters[11] = mc.ScriptScriptPercentScaleDown or 50
+ end
+end
+luatexbase.add_to_callback("luaotfload.patch_font", set_sscale_dimens, "unicode_math.set_sscale_dimens")
+%</lua>
% \end{macrocode}
%
% (Error messages and warning definitions go here from the |msg| chunk
@@ -2072,33 +2109,33 @@ This work is "author-maintained" by Will Robertson.
}
\mathopen {
\tl_if_in:NnTF \l_um_radicals_tl {#2} {
- \cs_gset:cpx {\cs_to_str:N #2 sign} { \um_radical:nn {#1} {#4} }
+ \cs_gset_protected_nopar:cpx {\cs_to_str:N #2 sign} { \um_radical:nn {#1} {#4} }
\tl_set:cn {l_um_radical_\cs_to_str:N #2_tl} {\use:c{sym #1}~ #4}
}{
\um_set_delcode:nnn {#1} {#4} {#4}
\um_set_mathcode:nnn {#4} \mathopen {#1}
- \cs_gset:Npx #2 { \um_delimiter:Nnn \mathopen {#1} {#4} }
+ \cs_gset_protected_nopar:Npx #2 { \um_delimiter:Nnn \mathopen {#1} {#4} }
}
}
\mathclose {
\um_set_delcode:nnn {#1} {#4} {#4}
\um_set_mathcode:nnn {#4} \mathclose {#1}
- \cs_gset:Npx #2 { \um_delimiter:Nnn \mathclose {#1} {#4} }
+ \cs_gset_protected_nopar:Npx #2 { \um_delimiter:Nnn \mathclose {#1} {#4} }
}
\mathaccent {
- \cs_gset:Npx #2 { \um_accent:Nnn #3 {#1} {#4} }
+ \cs_gset_protected_nopar:Npx #2 { \um_accent:Nnn #3 {#1} {#4} }
}
\mathfence {
\um_set_mathcode:nnn {#4} {#3} {#1}
\um_set_delcode:nnn {#1} {#4} {#4}
- \cs_gset:cpx {l \cs_to_str:N #2} { \um_delimiter:Nnn \mathopen {#1} {#4} }
- \cs_gset:cpx {r \cs_to_str:N #2} { \um_delimiter:Nnn \mathclose {#1} {#4} }
+ \cs_gset_protected_nopar:cpx {l \cs_to_str:N #2} { \um_delimiter:Nnn \mathopen {#1} {#4} }
+ \cs_gset_protected_nopar:cpx {r \cs_to_str:N #2} { \um_delimiter:Nnn \mathclose {#1} {#4} }
}
\mathover { % LuaTeX only
- \cs_set:Npn #2 ##1 { \mathop { \um_overbrace:nnn {#1} {#4} {##1} } \limits }
+ \cs_set_protected_nopar:Npn #2 ##1 { \mathop { \um_overbrace:nnn {#1} {#4} {##1} } \limits }
}
\mathunder { % LuaTeX only
- \cs_set:Npn #2 ##1 { \mathop { \um_underbrace:nnn {#1} {#4} {##1} } \limits }
+ \cs_set_protected_nopar:Npn #2 ##1 { \mathop { \um_underbrace:nnn {#1} {#4} {##1} } \limits }
}
}{
\um_set_mathcode:nnn {#4} {#3} {#1}
@@ -2144,7 +2181,7 @@ This work is "author-maintained" by Will Robertson.
% \begin{macrocode}
\cs_new:Npn \um_set_big_operator:nnn #1#2#3 {
\group_begin:
- \char_make_active:n {#3}
+ \char_set_catcode_active:n {#3}
\char_gmake_mathactive:n {#3}
\um_active_char_set:wc #3 \q_nil { \cs_to_str:N #2 _sym }
\group_end:
@@ -2173,16 +2210,16 @@ This work is "author-maintained" by Will Robertson.
% input only.
% \begin{macrocode}
\cs_set:Npn \um_set_mathcode:nnnn #1#2#3#4 {
- \Umathcode \intexpr_eval:n {#1} =
- \mathchar@type#2 \csname sym#3\endcsname \intexpr_eval:n {#4} \scan_stop:
+ \Umathcode \int_eval:n {#1} =
+ \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop:
}
\cs_set:Npn \um_set_mathcode:nnn #1#2#3 {
- \Umathcode \intexpr_eval:n {#1} =
- \mathchar@type#2 \csname sym#3\endcsname \intexpr_eval:n {#1} \scan_stop:
+ \Umathcode \int_eval:n {#1} =
+ \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#1} \scan_stop:
}
\cs_set:Npn \um_set_mathchar:NNnn #1#2#3#4 {
\Umathchardef #1 =
- \mathchar@type#2 \csname sym#3\endcsname \intexpr_eval:n {#4} \scan_stop:
+ \mathchar@type#2 \csname sym#3\endcsname \int_eval:n {#4} \scan_stop:
}
\cs_new:Npn \um_set_delcode:nnn #1#2#3 {
\Udelcode#2 = \csname sym#1\endcsname #3
@@ -2196,7 +2233,7 @@ This work is "author-maintained" by Will Robertson.
\xetex_or_luatex:nnn { \cs_new:Npn \um_accent:Nnn #1#2#3 } {
\Umathaccent \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop:
} {
- \Umathaccent \um_accent_keyword: \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop:
+ \Umathaccent \c_um_accent_keyword_tl \mathchar@type#1 \csname sym#2\endcsname #3 \scan_stop:
}
\luatex_if_engine:T {
\cs_new_nopar:Npn \um_wide_top_accent:Nnn #1 #2 #3 {
@@ -2206,11 +2243,9 @@ This work is "author-maintained" by Will Robertson.
\cs_new_nopar:Npn \um_wide_bottom_accent:Nnn #1 #2 #3 {
\Umathaccent bottom~ \mathchar@type #1 \use:c { sym #2 } #3 \scan_stop:
}
- \cs_new_protected_nopar:Npn \um_accent_keyword: {
- \bool_if:NF \l_um_growing_accents_bool { fixed~ }
- }
+ \tl_const:Nn \c_um_accent_keyword_tl { fixed }
} {
- \cs_new_nopar:Npn \um_accent_keyword: { }
+ \tl_const:Nn \c_um_accent_keyword_tl { }
}
}
% \end{macrocode}
@@ -2263,6 +2298,38 @@ This work is "author-maintained" by Will Robertson.
%
% \subsection{The main \cs{setmathfont} macro}
%
+% \begin{macro}{\um_saved_ltxe_glb_settings:}
+% Save the original definition of \cmd{\glb@settings} in a macro.
+% \begin{macrocode}
+\cs_new_eq:NN \um_saved_ltxe_glb_settings: \glb@settings
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\glb@settings}
+% We issue an error if the user tried to typeset math before setting a font.
+% \begin{macrocode}
+\CheckCommand * \glb@settings {
+ \expandafter\ifx\csname S@\f@size\endcsname\relax
+ \calculate@math@sizes
+ \fi
+ \csname S@\f@size\endcsname
+ \ifmath@fonts
+ \begingroup
+ \escapechar\m@ne
+ \csname mv@\math@version \endcsname
+ \globaldefs\@ne
+ \math@fonts
+ \let \glb@currsize \f@size
+ \endgroup
+ \the\every@math@size
+ \fi
+}
+\cs_set_protected_nopar:Npn \glb@settings {
+ \msg_error:nn { unicode-math } { no-font-selected }
+}
+% \end{macrocode}
+% \end{macro}
+%
% Using a |range| including large character sets such as \cmd\mathrel,
% \cmd\mathalpha, \etc, is \emph{very slow}!
% I hope to improve the performance somehow.
@@ -2279,6 +2346,10 @@ This work is "author-maintained" by Will Robertson.
% \begin{macrocode}
\let\glb@currsize\relax
% \end{macrocode}
+% \item Restore \LaTeXe\ kernel macro to apply settings instead of giving an error.
+% \begin{macrocode}
+ \cs_set_eq:NN \glb@settings \um_saved_ltxe_glb_settings:
+% \end{macrocode}
% \item To start with, assume we're defining the font for every math symbol character.
% \begin{macrocode}
\bool_set_true:N \l_um_init_bool
@@ -2298,6 +2369,7 @@ This work is "author-maintained" by Will Robertson.
% \item Grab the current size information
% (is this robust enough? Maybe it should be preceded by \cmd\normalsize).
% \begin{macrocode}
+ \cs_if_exist:cF { S@ \f@size } { \calculate@math@sizes }
\csname S@\f@size\endcsname
% \end{macrocode}
% \item Set the name of the math version being defined.
@@ -2338,7 +2410,7 @@ This work is "author-maintained" by Will Robertson.
% \end{itemize}
% \begin{macrocode}
\bool_if:NTF \l_um_init_bool {
- \tl_set:Nn \um_symfont_tl {um_allsym}
+ \tl_set:Nn \um_symfont_tl {operators}
\msg_trace:nnx {unicode-math} {default-math-font} {#2}
\cs_set_eq:NN \_um_sym:nnn \um_process_symbol_noparse:nnn
\cs_set_eq:NN \um_set_mathalphabet_char:Nnn \um_mathmap_noparse:Nnn
@@ -3025,6 +3097,7 @@ This work is "author-maintained" by Will Robertson.
}
% \end{macrocode}
%
+%
% \begin{macro}{\um_if_mathalph_decl:nTF}
% Possible forms of input:\\
% |\mathscr|\\
@@ -3040,7 +3113,7 @@ This work is "author-maintained" by Will Robertson.
% in the general case.
% \begin{macrocode}
\prg_new_conditional:Nnn \um_if_mathalph_decl:n {TF} {
- \KV_remove_surrounding_spaces:nw {\tl_set:Nf\l_um_tmpa_tl} #1 \q_nil
+ \tl_set:Nx \l_um_tmpa_tl { \trim@spaces@noexp {#1} }
\tl_clear:N \l_um_tmpb_tl
\tl_clear:N \l_um_tmpc_tl
\tl_if_in:NnT \l_um_tmpa_tl {->} {
@@ -3130,7 +3203,7 @@ This work is "author-maintained" by Will Robertson.
% \cmd\mathbf\ (\etc) \cmd\mathchar\ remappings.
% \begin{macrocode}
\if@tempswa
- \clist_put_right:Nx \l_um_char_num_range_clist { \intexpr_eval:n {#1} }
+ \clist_put_right:Nx \l_um_char_num_range_clist { \int_eval:n {#1} }
#4
\fi
\fi
@@ -3162,7 +3235,7 @@ This work is "author-maintained" by Will Robertson.
% \end{tabular}
% \begin{macrocode}
\expandafter\ifx\expandafter\@marker\@tempb\relax
- \intexpr_compare:nT {#4=#1} \@tempswatrue
+ \int_compare:nT {#4=#1} \@tempswatrue
\else
% \end{macrocode}
% \begin{tabular}{@{}ll}
@@ -3177,7 +3250,7 @@ This work is "author-maintained" by Will Robertson.
% \end{tabular}
% \begin{macrocode}
\ifx\@empty\@tempb
- \intexpr_compare:nT {#4>#1-1} \@tempswatrue
+ \int_compare:nT {#4>#1-1} \@tempswatrue
\else
% \end{macrocode}
% \begin{tabular}{@{}ll}
@@ -3192,7 +3265,7 @@ This work is "author-maintained" by Will Robertson.
% \end{tabular}
% \begin{macrocode}
\ifx\@empty\@tempa
- \intexpr_compare:nT {#4<#2+1} \@tempswatrue
+ \int_compare:nT {#4<#2+1} \@tempswatrue
% \end{macrocode}
% \begin{tabular}{@{}ll}
% \hline
@@ -3206,8 +3279,8 @@ This work is "author-maintained" by Will Robertson.
% \end{tabular}
% \begin{macrocode}
\else
- \intexpr_compare:nT {#4>#1-1} {
- \intexpr_compare:nT {#4<#2+1} \@tempswatrue
+ \int_compare:nT {#4>#1-1} {
+ \int_compare:nT {#4<#2+1} \@tempswatrue
}
\fi
\fi
@@ -4541,15 +4614,15 @@ This work is "author-maintained" by Will Robertson.
% back into their original meaning after the group has ended and |^|'s catcode returns to normal.
% \begin{macrocode}
\begingroup
- \char_make_other:N \^
+ \char_set_catcode_other:N \^
\cs_gset:Npn \um_cs_set_eq_active_char:Nw #1 = "#2 \q_nil {
\lowercase{
\tl_rescan:nn {
- \char_make_other:N \{
- \char_make_other:N \}
- \char_make_other:N \&
- \char_make_other:N \%
- \char_make_other:N \$
+ \char_set_catcode_other:N \{
+ \char_set_catcode_other:N \}
+ \char_set_catcode_other:N \&
+ \char_set_catcode_other:N \%
+ \char_set_catcode_other:N \$
}{
\global\let#1=^^^^^#2
}
@@ -4586,7 +4659,7 @@ This work is "author-maintained" by Will Robertson.
\AtBeginDocument{\um_define_math_chars:}
\cs_set:Nn \um_define_math_chars: {
\group_begin:
- \char_make_math_superscript:N \^
+ \char_set_catcode_math_superscript:N \^
\cs_set:Npn \_um_sym:nnn ##1##2##3 {
\bool_if:nF { \cs_if_eq_p:NN ##3 \mathaccent ||
\cs_if_eq_p:NN ##3 \mathopen ||
@@ -4596,7 +4669,7 @@ This work is "author-maintained" by Will Robertson.
\um_cs_set_eq_active_char:Nw ##2 = ##1 \q_nil \ignorespaces
}
}
- \char_make_other:N \#
+ \char_set_catcode_other:N \#
\um_input_math_symbol_table:
\group_end:
}
@@ -4606,8 +4679,8 @@ This work is "author-maintained" by Will Robertson.
% \begin{macrocode}
\group_begin:
\lccode`\*=`\\
- \char_make_escape:N \|
- \char_make_other:N \\
+ \char_set_catcode_escape:N \|
+ \char_set_catcode_other:N \\
|lowercase{
|AtBeginDocument{
|let|backslash=*
@@ -4889,7 +4962,7 @@ This work is "author-maintained" by Will Robertson.
\AtBeginDocument{\um_define_prime_commands: \um_define_prime_chars:}
\cs_set:Nn \um_define_prime_commands: {
\cs_set_eq:NN \prime \um_prime_single_mchar
- \cs_set_eq:NN \drime \um_prime_double_mchar
+ \cs_set_eq:NN \dprime \um_prime_double_mchar
\cs_set_eq:NN \trprime \um_prime_triple_mchar
\cs_set_eq:NN \qprime \um_prime_quad_mchar
\cs_set_eq:NN \backprime \um_backprime_single_mchar
@@ -4897,15 +4970,15 @@ This work is "author-maintained" by Will Robertson.
\cs_set_eq:NN \backtrprime \um_backprime_triple_mchar
}
\group_begin:
- \char_make_active:N \'
- \char_make_active:N \`
- \char_make_active:n {"2032}
- \char_make_active:n {"2033}
- \char_make_active:n {"2034}
- \char_make_active:n {"2057}
- \char_make_active:n {"2035}
- \char_make_active:n {"2036}
- \char_make_active:n {"2037}
+ \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 \um_define_prime_chars: {
\cs_set_eq:NN ' \um_scan_sup_prime:
\cs_set_eq:NN ^^^^2032 \um_scan_sup_prime:
@@ -4934,11 +5007,11 @@ This work is "author-maintained" by Will Robertson.
% \begin{macrocode}
\cs_set_nopar:Npn \r@@t ##1 ##2 {
\hbox_set:Nn \l_tmpa_box {
- \c_math_shift_token
+ \c_math_toggle_token
\m@th
##1
\sqrtsign { ##2 }
- \c_math_shift_token
+ \c_math_toggle_token
}
\um_mathstyle_scale:Nnn ##1 { \kern } {
\fontdimen 63 \l_um_font
@@ -5035,7 +5108,7 @@ This work is "author-maintained" by Will Robertson.
% \begin{macrocode}
\cs_set:Npn \um_setup_active_superscript:nn #1#2 {
\prop_gput:Nxn \g_um_supers_prop {\meaning #1} {#2}
- \char_make_active:N #1
+ \char_set_catcode_active:N #1
\char_gmake_mathactive:N #1
\scantokens{
\cs_gset:Npn #1 {
@@ -5071,7 +5144,7 @@ This work is "author-maintained" by Will Robertson.
% \begin{macrocode}
\cs_set:Npn \um_setup_active_subscript:nn #1#2 {
\prop_gput:Nxn \g_um_subs_prop {\meaning #1} {#2}
- \char_make_active:N #1
+ \char_set_catcode_active:N #1
\char_gmake_mathactive:N #1
\scantokens{
\cs_gset:Npn #1 {
@@ -5186,7 +5259,7 @@ This work is "author-maintained" by Will Robertson.
%
% \begin{macrocode}
\cs_new:Npn \um_define_active_frac:Nw #1 #2/#3 {
- \char_make_active:N #1
+ \char_set_catcode_active:N #1
\char_gmake_mathactive:N #1
\tl_rescan:nn {
\catcode`\_=11\relax
@@ -5250,6 +5323,7 @@ This work is "author-maintained" by Will Robertson.
\def\lor{\vee}
\def\owns{\ni}
\def\gets{\leftarrow}
+\def\mathring{\ocirc}
% \end{macrocode}
% These are somewhat odd: (and their usual Unicode uprightness does not match their amssymb glyphs)
% \begin{macrocode}
@@ -5391,28 +5465,6 @@ This work is "author-maintained" by Will Robertson.
% \end{macro}
% \end{macro}
%
-% \paragraph{\LaTeXe\ kernel}
-% \cs{frac} can be patched for \LuaTeX, but \cs{choose}, \cs{brack} and \cs{brace} should be discouraged.
-% Probably these fixes (and the analogous \pkg{amsmath} fixes below) should go into \pkg{luatextra} or a similar \LuaLaTeX\ package.
-% \begin{macrocode}
-\luatex_if_engine:T {
- \AtBeginDocument{\um_patch_amsmath:}
- \cs_set:Nn \um_patch_amsmath: {
- \@ifpackageloaded { amsmath } { } {
- \um_check_and_fix:NNnnn \frac \cs_set_nopar:Npn { ##1 ##2 } {
- {
- \begingroup ##1 \endgroup \over ##2
- }
- } {
- {
- \luatexUstack { \group_begin: ##1 \group_end: \over ##2 }
- }
- }
- }
- }
-}
-% \end{macrocode}
-%
% \paragraph{\pkg{url}}
% Simply need to get \pkg{url} in a state such that
% when it switches to math mode and enters \ascii\ characters, the maths
@@ -5438,12 +5490,14 @@ This work is "author-maintained" by Will Robertson.
% Since the mathcode of |`\-| is greater than eight bits, this piece of |\AtBeginDocument| code from \pkg{amsmath} dies if we try and set the maths font in the preamble:
% \begin{macrocode}
\AtEndOfPackageFile * {amsmath} {
- \tl_remove_in:Nn \@begindocumenthook {
- \mathchardef\std@minus\mathcode`\-\relax
- \mathchardef\std@equal\mathcode`\=\relax
+ \xetex_if_engine:T {
+ \tl_remove_in:Nn \@begindocumenthook {
+ \mathchardef\std@minus\mathcode`\-\relax
+ \mathchardef\std@equal\mathcode`\=\relax
+ }
+ \def\std@minus{\Umathcharnum\Umathcodenum`\-\relax}
+ \def\std@equal{\Umathcharnum\Umathcodenum`\=\relax}
}
- \def\std@minus{\Umathcharnum\Umathcodenum`\-\relax}
- \def\std@equal{\Umathcharnum\Umathcodenum`\=\relax}
% \end{macrocode}
%
% \begin{macrocode}
@@ -5452,83 +5506,60 @@ This work is "author-maintained" by Will Robertson.
% \end{macrocode}
% This isn't as clever as the \pkg{amsmath} definition but I think it works:
% \begin{macrocode}
- \def \resetMathstrut@ {%
- \setbox\z@\hbox{$($}%)
- \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@
+ \xetex_if_engine:T {
+ \def \resetMathstrut@ {%
+ \setbox\z@\hbox{$($}%)
+ \ht\Mathstrutbox@\ht\z@ \dp\Mathstrutbox@\dp\z@
+ }
}
% \end{macrocode}
% The |subarray| environment uses inappropriate font dimensions.
% \begin{macrocode}
- \um_check_and_fix:NNnnn \subarray \cs_set:Npn { #1 } {
- \vcenter
- \bgroup
- \Let@
- \restore@math@cr
- \default@tag
- \baselineskip \fontdimen 10~ \scriptfont \tw@
- \advance \baselineskip \fontdimen 12~ \scriptfont \tw@
- \lineskip \thr@@ \fontdimen 8~ \scriptfont \thr@@
- \lineskiplimit \lineskip
- \ialign
- \bgroup
- \ifx c #1 \hfil \fi
- $ \m@th \scriptstyle ## $
- \hfil
- \crcr
- } {
- \vcenter
- \c_group_begin_token
- \Let@
- \restore@math@cr
- \default@tag
- \skip_set:Nn \baselineskip {
+ \xetex_if_engine:T {
+ \um_check_and_fix:NNnnn \subarray \cs_set:Npn { #1 } {
+ \vcenter
+ \bgroup
+ \Let@
+ \restore@math@cr
+ \default@tag
+ \baselineskip \fontdimen 10~ \scriptfont \tw@
+ \advance \baselineskip \fontdimen 12~ \scriptfont \tw@
+ \lineskip \thr@@ \fontdimen 8~ \scriptfont \thr@@
+ \lineskiplimit \lineskip
+ \ialign
+ \bgroup
+ \ifx c #1 \hfil \fi
+ $ \m@th \scriptstyle ## $
+ \hfil
+ \crcr
+ } {
+ \vcenter
+ \c_group_begin_token
+ \Let@
+ \restore@math@cr
+ \default@tag
+ \skip_set:Nn \baselineskip {
% \end{macrocode}
% Here we use stack top shift + stack bottom shift, which sounds reasonable.
% \begin{macrocode}
- \um_stack_num_up:N \scriptstyle
- + \um_stack_denom_down:N \scriptstyle
- }
+ \um_stack_num_up:N \scriptstyle
+ + \um_stack_denom_down:N \scriptstyle
+ }
% \end{macrocode}
% Here we use the minimum stack gap.
% \begin{macrocode}
- \lineskip \um_stack_vgap:N \scriptstyle
- \lineskiplimit \lineskip
- \ialign
- \c_group_begin_token
- \token_if_eq_meaning:NNT c #1 { \hfil }
- \c_math_shift_token
- \m@th
- \scriptstyle
- \c_parameter_token \c_parameter_token
- \c_math_shift_token
- \hfil
- \crcr
- }
-% \end{macrocode}
-% For \LuaTeX, \cs{frac} and \cs{genfrac} should use \cs{Ustack} for correct math style selection.
-% \begin{macrocode}
- \um_check_and_fix_luatex:cNnnn { frac~ } \cs_set:Npn { #1 #2 } {
- {
- \begingroup #1 \endgroup \@@over #2
- }
- } {
- {
- \luatexUstack { \group_begin: #1 \group_end: \@@over #2 }
- }
- }
- \um_check_and_fix_luatex:NNnnn \@genfrac \cs_set_nopar:Npn {
- #1 #2 #3 #4 #5
- } {
- {
- #1 { \begingroup #4 \endgroup #2 #3 \relax #5 }
- }
- } {
- {
- #1 {
- \luatexUstack {
- \group_begin: #4 \group_end: #2 #3 \scan_stop: #5
- }
- }
+ \lineskip \um_stack_vgap:N \scriptstyle
+ \lineskiplimit \lineskip
+ \ialign
+ \c_group_begin_token
+ \token_if_eq_meaning:NNT c #1 { \hfil }
+ \c_math_toggle_token
+ \m@th
+ \scriptstyle
+ \c_parameter_token \c_parameter_token
+ \c_math_toggle_token
+ \hfil
+ \crcr
}
}
% \end{macrocode}
@@ -5552,10 +5583,10 @@ This work is "author-maintained" by Will Robertson.
\luatexUroot \l_um_radical_sqrt_tl { #1 } { #2 }
} {
\hbox_set:Nn \rootbox {
- \c_math_shift_token
+ \c_math_toggle_token
\m@th
\scriptscriptstyle { #1 }
- \c_math_shift_token
+ \c_math_toggle_token
}
\mathchoice
{ \r@@t \displaystyle { #2 } }
@@ -5579,21 +5610,21 @@ This work is "author-maintained" by Will Robertson.
\boxz@
} {
\hbox_set:Nn \l_tmpa_box {
- \c_math_shift_token
+ \c_math_toggle_token
\m@th
#1
\mskip \uproot@ mu
- \c_math_shift_token
+ \c_math_toggle_token
}
\luatexUroot \l_um_radical_sqrt_tl {
\box_move_up:nn { \box_wd:N \l_tmpa_box } {
\hbox:n {
- \c_math_shift_token
+ \c_math_toggle_token
\m@th
\mkern -\leftroot@ mu
\box_use:N \rootbox
\mkern \leftroot@ mu
- \c_math_shift_token
+ \c_math_toggle_token
}
}
} {
@@ -5601,18 +5632,18 @@ This work is "author-maintained" by Will Robertson.
}
} {
\hbox_set:Nn \l_tmpa_box {
- \c_math_shift_token
+ \c_math_toggle_token
\m@th
#1
\sqrtsign { #2 }
- \c_math_shift_token
+ \c_math_toggle_token
}
\hbox_set:Nn \l_tmpb_box {
- \c_math_shift_token
+ \c_math_toggle_token
\m@th
#1
\mskip \uproot@ mu
- \c_math_shift_token
+ \c_math_toggle_token
}
\mkern -\leftroot@ mu
\um_mathstyle_scale:Nnn #1 { \kern } {
@@ -5711,62 +5742,58 @@ This work is "author-maintained" by Will Robertson.
%
% \begin{macrocode}
\AtEndOfPackageFile * { mathtools } {
- \um_check_and_fix:NNnnnn \MT_cramped_internal:Nn \cs_set_nopar:Npn { #1 #2 } {
- \sbox \z@ {
- $
- \m@th
- #1
- \nulldelimiterspace = \z@
- \radical \z@ { #2 }
- $
- }
- \ifx #1 \displaystyle
- \dimen@ = \fontdimen 8 \textfont 3
- \advance \dimen@ .25 \fontdimen 5 \textfont 2
- \else
- \dimen@ = 1.25 \fontdimen 8
- \ifx #1 \textstyle
- \textfont
+ \xetex_if_engine:T {
+ \um_check_and_fix:NNnnn \MT_cramped_internal:Nn \cs_set_nopar:Npn { #1 #2 } {
+ \sbox \z@ {
+ $
+ \m@th
+ #1
+ \nulldelimiterspace = \z@
+ \radical \z@ { #2 }
+ $
+ }
+ \ifx #1 \displaystyle
+ \dimen@ = \fontdimen 8 \textfont 3
+ \advance \dimen@ .25 \fontdimen 5 \textfont 2
\else
- \ifx #1 \scriptstyle
- \scriptfont
+ \dimen@ = 1.25 \fontdimen 8
+ \ifx #1 \textstyle
+ \textfont
\else
- \scriptscriptfont
+ \ifx #1 \scriptstyle
+ \scriptfont
+ \else
+ \scriptscriptfont
+ \fi
\fi
+ 3
\fi
- 3
- \fi
- \advance \dimen@ -\ht\z@
- \ht\z@ = -\dimen@
- \box\z@
- } {
-% \end{macrocode}
-% \LuaTeX\ has primitives for setting material in cramped mode (thanks to Khaled Hosny for pointing this out).
-% Note we don’t use \cs{mathstyle} since we want to patch only a single command.
-% \begin{macrocode}
- \use:c { luatexcramped \cs_to_str:N #1 } #2
- } {
+ \advance \dimen@ -\ht\z@
+ \ht\z@ = -\dimen@
+ \box\z@
+ } {
% \end{macrocode}
% The \XeTeX\ version is pretty similar to the legacy version, only using the correct font dimensions.
% \begin{macrocode}
- \hbox_set:Nn \l_tmpa_box {
- \color@setgroup
- \c_math_shift_token
- \m@th
- #1
- \dim_zero:N \nulldelimiterspace
- \radical \c_zero { #2 }
- \c_math_shift_token
- \color@endgroup
- }
- \box_set_ht:Nn \l_tmpa_box {
- \box_ht:N \l_tmpa_box
+ \hbox_set:Nn \l_tmpa_box {
+ \color@setgroup
+ \c_math_toggle_token
+ \m@th
+ #1
+ \dim_zero:N \nulldelimiterspace
+ \radical \c_zero { #2 }
+ \c_math_toggle_token
+ \color@endgroup
+ }
+ \box_set_ht:Nn \l_tmpa_box {
+ \box_ht:N \l_tmpa_box
% \end{macrocode}
% Here we use the radical vertical gap.
% \begin{macrocode}
- - \um_radical_vgap:N #1
+ - \um_radical_vgap:N #1
+ }
+ \box_use_clear:N \l_tmpa_box
}
- \box_use_clear:N \l_tmpa_box
}
% \end{macrocode}
%
@@ -5887,6 +5914,15 @@ This work is "author-maintained" by Will Robertson.
{
Setup~ alphabet:~ #1.
}
+\msg_new:nnnn { unicode-math } { no-font-selected } {
+ You've~ loaded~ the~ unicode-math~ package,~ but~ you~ forgot~ to~ select \\
+ a~ Unicode~ math~ font.~ Please~ select~ one~ with~ the~ \token_to_str:N \setmathfont \\
+ command.
+} {
+ Loading~ the~ unicode-math~ package~ without~ using~ a~ Unicode~ math~ font \\
+ is~ not~ supported.~ Either~ select~ a~ Unicode~ math~ font,~ or~ don't~ load \\
+ the~ unicode-math~ package.
+}
\msg_new:nnn {unicode-math} {macro-expected}
{
I've~ expected~ that~ #1~ is~ a~ macro,~ but~ it~ isn't.