From 3c45700f44de3ee95c3e431a5e8df132b603c55c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 27 Oct 2012 23:10:42 +0000 Subject: lualatex-match (27oct12) git-svn-id: svn://tug.org/texlive/trunk@28101 c570f23f-e606-0410-a88d-b1316a301751 --- .../doc/lualatex/lualatex-math/lualatex-math.pdf | Bin 257240 -> 272656 bytes .../lualatex/lualatex-math/lualatex-math.dtx | 443 +++++++++++++-------- .../lualatex/lualatex-math/lualatex-math.ins | 2 +- .../tex/lualatex/lualatex-math/lualatex-math.sty | 100 +++-- 4 files changed, 331 insertions(+), 214 deletions(-) diff --git a/Master/texmf-dist/doc/lualatex/lualatex-math/lualatex-math.pdf b/Master/texmf-dist/doc/lualatex/lualatex-math/lualatex-math.pdf index b97a53992d5..db13d8c841d 100644 Binary files a/Master/texmf-dist/doc/lualatex/lualatex-math/lualatex-math.pdf and b/Master/texmf-dist/doc/lualatex/lualatex-math/lualatex-math.pdf differ diff --git a/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.dtx b/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.dtx index 91373001ce0..a4d2ea921f8 100644 --- a/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.dtx +++ b/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.dtx @@ -31,7 +31,7 @@ % % \fi % -% \CheckSum{887} +% \CheckSum{960} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -52,10 +52,12 @@ % % \changes{v0.1}{2011/04/22}{Initial version} % \changes{v0.3a}{2011/09/13}{Updated for changes in \pkg{l3kernel}} +% \changes{v1.0}{2012/08/27}{Switched to \pkg{l3docstrip}} % % \GetFileInfo{lualatex-math.sty} % -% \title{The \thispackage package\thanks{This document corresponds to \thispackage{}~\fileversion, dated~\filedate.}} +% \title{The \thispackage package\thanks{This document corresponds to +% \thispackage{}~\fileversion, dated~\filedate.}} % \author{Philipp Stephani \\ \texttt{p.stephani2@gmail.com}} % \date{\filedate} % @@ -111,11 +113,11 @@ % Unicode and legacy math typesetting. % % Currently patches for the \hologo{LaTeX2e} kernel and the \pkg{amsmath}, -% \pkg{mathtools} and \pkg{icomma} packages are provided. It is not relevant -% whether you load these packages before or after \thispackage. They should -% work as expected (and ideally you shouldn’t notice anything), but if you load -% other packages that by themselves overwrite commands patched by this package, -% bad things may happen, as it is usual with \hologo{LaTeX}. +% \pkg{amsopn}, \pkg{mathtools} and \pkg{icomma} packages are provided. It is +% not relevant whether you load these packages before or after \thispackage. +% They should work as expected (and ideally you shouldn’t notice anything), but +% if you load other packages that by themselves overwrite commands patched by +% this package, bad things may happen, as it is usual with \hologo{LaTeX}. % % One user-visible change is that the new % \DescribeMacros{\mathstyle\luatexmathstyle}\cmd{\mathstyle} primitive @@ -136,9 +138,10 @@ % % \begin{macrocode} %<*package> +%<@@=lltxmath> \NeedsTeXFormat{LaTeX2e}[2009/09/24] \RequirePackage{expl3}[2012/08/14] -\ProvidesExplPackage{lualatex-math}{2012/08/23}{0.3c}% +\ProvidesExplPackage{lualatex-math}{2012/10/13}{1.1}% {Patches for mathematics typesetting with LuaLaTeX} \RequirePackage { etoolbox } [ 2007/10/08 ] \RequirePackage { luatexbase } [ 2010/05/27 ] @@ -146,12 +149,12 @@ \RequireLuaModule { lualatex-math } [ 2011/05/05 ] % \end{macrocode} % -% \begin{macro}{\lltxmath_restore_catcode:N} +% \begin{macro}{\@@_restore_catcode:N} % Executing the exhaustive expansion of -% \cmd{\lltxmath_restore_catcode:N}\meta{character token} restores the -% category code of the \meta{character token} to its current value. +% \cmd{\@@_restore_catcode:N}\meta{character token} restores the category +% code of the \meta{character token} to its current value. % \begin{macrocode} -\cs_new_nopar:Npn \lltxmath_restore_catcode:N #1 { +\cs_new_nopar:Npn \@@_restore_catcode:N #1 { \char_set_catcode:nn { \int_eval:n { `#1 } } { \char_value_catcode:n { `#1 } } } @@ -162,7 +165,7 @@ % get loaded after the packages we are trying to patch. % \begin{macrocode} \exp_args:Nx \AtEndOfPackage { - \lltxmath_restore_catcode:N \$ + \@@_restore_catcode:N \$ } \char_set_catcode_math_toggle:N \$ % \end{macrocode} @@ -247,10 +250,10 @@ % % \subsection{Patching} % -% \begin{macro}{\lltxmath_temp:w} +% \begin{macro}{\@@_temp:w} % A scratch macro. % \begin{macrocode} -\cs_new_eq:NN \lltxmath_temp:w \prg_do_nothing: +\cs_new_eq:NN \@@_temp:w \prg_do_nothing: % \end{macrocode} % \end{macro} % @@ -270,13 +273,12 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\lltxmath_assert_eq:NN} -% The macro \cmd{\lltxmath_assert_eq:NN}\meta{first command}\meta{second -% command} tests whether the control sequences \meta{first command} and -% \meta{second command} have the same meaning, and prints an error message if -% they do not. +% \begin{macro}{\@@_assert_eq:NN} +% The macro \cmd{\@@_assert_eq:NN}\meta{first command}\meta{second command} +% tests whether the control sequences \meta{first command} and \meta{second +% command} have the same meaning, and prints an error message if they do not. % \begin{macrocode} -\cs_new_protected_nopar:Npn \lltxmath_assert_eq:NN #1 #2 { +\cs_new_protected_nopar:Npn \@@_assert_eq:NN #1 #2 { \cs_if_eq:NNF #1 #2 { \msg_error:nnxxxx { lualatex-math } { different-meanings } { \token_to_str:N #1 } { \token_to_meaning:N #1 } @@ -286,9 +288,9 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\lltxmath_patch:NNnnn} -% \begin{macro}{\lltxmath_patch:cNnnn} -% The auxiliary macro \cmd{\lltxmath_patch:NNnnn}\meta{command}\meta{factory +% \begin{macro}{\@@_patch:NNnnn} +% \begin{macro}{\@@_patch:cNnnn} +% The auxiliary macro \cmd{\@@_patch:NNnnn}\meta{command}\meta{factory % command}\marg{parameter text}\marg{expected replacement text}\marg{new % replacement text} tries to patch \meta{command}. If \meta{command} is % undefined, do nothing. Otherwise it must be a macro with the given @@ -297,12 +299,12 @@ % overwritten using the \meta{parameter text} and the \meta{new replacement % text}. Otherwise issue a warning and don’t overwrite. % \begin{macrocode} -\cs_new_protected_nopar:Npn \lltxmath_patch:NNnnn #1 #2 #3 #4 #5 { +\cs_new_protected_nopar:Npn \@@_patch:NNnnn #1 #2 #3 #4 #5 { \cs_if_exist:NT #1 { \token_if_macro:NTF #1 { \group_begin: - #2 \lltxmath_temp:w #3 { #4 } - \cs_if_eq:NNTF #1 \lltxmath_temp:w { + #2 \@@_temp:w #3 { #4 } + \cs_if_eq:NNTF #1 \@@_temp:w { \msg_info:nnx { lualatex-math } { patch-macro } { \token_to_str:N #1 } \group_end: @@ -310,7 +312,7 @@ } { \msg_warning:nnxxx { lualatex-math } { wrong-meaning } { \token_to_str:N #1 } { \token_to_meaning:N #1 } - { \token_to_meaning:N \lltxmath_temp:w } + { \token_to_meaning:N \@@_temp:w } \group_end: } } { @@ -319,21 +321,25 @@ } } } -\cs_generate_variant:Nn \lltxmath_patch:NNnnn { c } +\cs_generate_variant:Nn \@@_patch:NNnnn { c } % \end{macrocode} % \end{macro} % \end{macro} % -% \begin{macro}{\lltxmath_set_mathchar:NN} -% The macro \cmd{\lltxmath_set_mathchar:NN}\meta{control -% sequence}\meta{token} defines the \meta{control sequence} as an extended -% mathematical character shorthand whose mathematical code is given by the -% mathematical code of the character \texttt{\textasciigrave}\meta{token}. -% Since there is no \cmd{\Umathcharnumdef} primitive, we have to extract the -% class, family, and slot numbers separately. -% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to \cs{lua_now_x:n}} -% \begin{macrocode} -\cs_new_protected_nopar:Npn \lltxmath_set_mathchar:NN #1 #2 { +% \begin{macro}{\@@_set_mathchar:NN} +% The macro \cmd{\@@_set_mathchar:NN}\meta{control sequence}\meta{token} +% defines the \meta{control sequence} as an extended mathematical character +% shorthand whose mathematical code is given by the mathematical code of the +% character \texttt{\textasciigrave}\meta{token}. We cannot use the +% |\Umathcharnumdef| primitive here since we would then rely on the +% |\Umathcodenum| primitive which is currently +% broken.\footnote{\url{http://tug.org/pipermail/luatex/2012-October/003794.html}} +% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to +% \cs{lua_now_x:n}} +% \changes{v1.1}{2012/10/13}{Update reasoning why \cs{Umathcharnumdef} is not +% used here} +% \begin{macrocode} +\cs_new_protected_nopar:Npn \@@_set_mathchar:NN #1 #2 { \luatexUmathchardef #1 \lua_now_x:n { lualatex.math.print_class_fam_slot( \int_eval:n { `#2 } ) @@ -354,7 +360,7 @@ % % First we test whether \cmd{\newfam} and \cmd{\new@mathgroup} are equal. % \begin{macrocode} -\lltxmath_assert_eq:NN \newfam \new@mathgroup +\@@_assert_eq:NN \newfam \new@mathgroup % \end{macrocode} % % \begin{macro}{\new@mathgroup} @@ -362,8 +368,10 @@ % allocation system; the macro \cmd{\alloc@} takes care of the rest. This % would work even if the \pkg{etex} package weren’t loaded. % \begin{macrocode} -\lltxmath_patch:NNnnn \new@mathgroup \cs_set_nopar:Npn { } { +\@@_patch:NNnnn \new@mathgroup \cs_set_nopar:Npn { } { +%<@@=> \alloc@ 8 \mathgroup \chardef \sixt@@n +%<@@=lltxmath> } { \alloc@ 8 \mathgroup \chardef \c_two_hundred_fifty_six } @@ -401,7 +409,7 @@ % \begin{macrocode} \AtEndPreamble { \@ifpackageloaded { amsmath } { } { - \lltxmath_patch:NNnnn \frac \cs_set_nopar:Npn { #1 #2 } { + \@@_patch:NNnnn \frac \cs_set_nopar:Npn { #1 #2 } { { \begingroup #1 \endgroup \over #2 } @@ -460,29 +468,30 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\c_lltxmath_std_minus_mathcode_int} -% \begin{macro}{\c_lltxmath_std_equal_mathcode_int} +% \begin{macro}{\c_@@_std_minus_mathcode_int} +% \begin{macro}{\c_@@_std_equal_mathcode_int} % These constants contain the standard \hologo{TeX} mathematical codes for % the minus and the equal signs. We temporarily set the math codes to these % constants before loading the \pkg{amsmath} package so that it can request % the legacy math code without error. % \begin{macrocode} -\int_const:Nn \c_lltxmath_std_minus_mathcode_int { "2200 } -\int_const:Nn \c_lltxmath_std_equal_mathcode_int { "303D } +\int_const:Nn \c_@@_std_minus_mathcode_int { "2200 } +\int_const:Nn \c_@@_std_equal_mathcode_int { "303D } % \end{macrocode} % \end{macro} % \end{macro} % -% \begin{macro}{\lltxmath_char_dim:NN} -% The macro \cmd{\lltxmath_char_dim:NN}\meta{primitive}\meta{token} expands -% to a \meta{dimen} whose value is the metric of the mathematical character +% \begin{macro}{\@@_char_dim:NN} +% The macro \cmd{\@@_char_dim:NN}\meta{primitive}\meta{token} expands to a +% \meta{dimen} whose value is the metric of the mathematical character % corresponding to the character \texttt{\textasciigrave}\meta{token} % specified by \meta{primitive}, which must be one of \cmd{\fontcharwd}, % \cmd{\fontcharht} or \cmd{\fontchardp}, in the currently selected text % style font. -% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to \cs{lua_now_x:n}} +% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to +% \cs{lua_now_x:n}} % \begin{macrocode} -\cs_new_nopar:Npn \lltxmath_char_dim:NN #1 #2 { +\cs_new_nopar:Npn \@@_char_dim:NN #1 #2 { #1 \textfont \lua_now_x:n { lualatex.math.print_fam_slot( \int_eval:n { `#2 } ) @@ -491,8 +500,8 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\l_lltxmath_minus_mathchar} -% \begin{macro}{\l_lltxmath_equal_mathchar} +% \begin{macro}{\l_@@_minus_mathchar} +% \begin{macro}{\l_@@_equal_mathchar} % These mathematical characters are saved before \pkg{amsmath} is loaded so % that we can temporarily assign the \hologo{TeX} values to the mathematical % codes of the minus and equals signs. The \pkg{amsmath} package queries @@ -501,18 +510,18 @@ % can do, therefore we use the non-starred version of % \cmd{\AtBeginOfPackageFile}. % \begin{macrocode} -\chk_if_free_cs:N \l_lltxmath_minus_mathchar -\chk_if_free_cs:N \l_lltxmath_equal_mathchar +\chk_if_free_cs:N \l_@@_minus_mathchar +\chk_if_free_cs:N \l_@@_equal_mathchar \AtBeginOfPackageFile { amsmath } { - \lltxmath_set_mathchar:NN \l_lltxmath_minus_mathchar \- - \lltxmath_set_mathchar:NN \l_lltxmath_equal_mathchar \= + \@@_set_mathchar:NN \l_@@_minus_mathchar \- + \@@_set_mathchar:NN \l_@@_equal_mathchar \= % \end{macrocode} % \end{macro} % \end{macro} % Now we temporarily reset the mathematical codes. % \begin{macrocode} - \char_set_mathcode:nn { `\- } { \c_lltxmath_std_minus_mathcode_int } - \char_set_mathcode:nn { `\= } { \c_lltxmath_std_equal_mathcode_int } + \char_set_mathcode:nn { `\- } { \c_@@_std_minus_mathcode_int } + \char_set_mathcode:nn { `\= } { \c_@@_std_equal_mathcode_int } \AtEndOfPackageFile { amsmath } { % \end{macrocode} % \begin{macro}{\std@minus} @@ -521,15 +530,15 @@ % and \cmd{\std@equal} as mathematical character shorthands while loading, % but uses our restored mathematical codes, which must be fixed. % \begin{macrocode} - \cs_set_eq:NN \std@minus \l_lltxmath_minus_mathchar - \cs_set_eq:NN \std@equal \l_lltxmath_equal_mathchar + \cs_set_eq:NN \std@minus \l_@@_minus_mathchar + \cs_set_eq:NN \std@equal \l_@@_equal_mathchar % \end{macrocode} % \end{macro} % \end{macro} % Finally, we restore the original mathematical codes of the two signs. % \begin{macrocode} - \luatexUmathcodenum `\- \l_lltxmath_minus_mathchar - \luatexUmathcodenum `\= \l_lltxmath_equal_mathchar + \luatexUmathcodenum `\- \l_@@_minus_mathchar + \luatexUmathcodenum `\= \l_@@_equal_mathchar } } % \end{macrocode} @@ -546,8 +555,8 @@ \mathchardef \std@minus \mathcode `\- \relax \mathchardef \std@equal \mathcode `\= \relax } { - \lltxmath_set_mathchar:NN \std@minus \- - \lltxmath_set_mathchar:NN \std@equal \= + \@@_set_mathchar:NN \std@minus \- + \@@_set_mathchar:NN \std@equal \= } % \end{macrocode} % \end{macro} @@ -563,7 +572,7 @@ % furthermore we can avoid a temporary box because \hologo{eTeX} allows us to % query glyph metrics directly. % \begin{macrocode} - \lltxmath_patch:NNnnn \resetMathstrut@ \cs_set_nopar:Npn { } { + \@@_patch:NNnnn \resetMathstrut@ \cs_set_nopar:Npn { } { \setbox \z@ \hbox { \mathchardef \@tempa \mathcode `\( \relax % \) \def \@tempb ##1 "##2 ##3 { \the \textfont "##3 \char" } @@ -573,10 +582,10 @@ \dp \Mathstrutbox@ \dp \z@ } { \box_set_ht:Nn \Mathstrutbox@ { - \lltxmath_char_dim:NN \fontcharht \( % \) + \@@_char_dim:NN \fontcharht \( % \) } \box_set_dp:Nn \Mathstrutbox@ { - \lltxmath_char_dim:NN \fontchardp \) + \@@_char_dim:NN \fontchardp \) } } % \end{macrocode} @@ -591,7 +600,7 @@ % minimum vertical gap for stack for the minimum baseline distance % (\cmd{\lineskip}). % \begin{macrocode} - \lltxmath_patch:NNnnn \subarray \cs_set:Npn { #1 } { + \@@_patch:NNnnn \subarray \cs_set:Npn { #1 } { \vcenter \bgroup \Let@ @@ -599,7 +608,9 @@ \default@tag \baselineskip \fontdimen 10~ \scriptfont \tw@ \advance \baselineskip \fontdimen 12~ \scriptfont \tw@ +%<@@=> \lineskip \thr@@ \fontdimen 8~ \scriptfont \thr@@ +%<@@=lltxmath> \lineskiplimit \lineskip \ialign \bgroup @@ -637,13 +648,15 @@ % Since \cmd{\frac} is declared by \cmd{\DeclareRobustCommand}, we must patch % the macro \cmd{\frac\textvisiblespace}. % \begin{macrocode} - \lltxmath_patch:cNnnn { frac~ } \cs_set:Npn { #1 #2 } { + \@@_patch:cNnnn { frac~ } \cs_set:Npn { #1 #2 } { { +%<@@=> \begingroup #1 \endgroup \@@over #2 } } { { \luatexUstack { \group_begin: #1 \group_end: \@@over #2 } +%<@@=lltxmath> } } % \end{macrocode} @@ -652,7 +665,7 @@ % \begin{macro}{\@genfrac} % Generalized fractions are typeset by the internal \cmd{\@genfrac} command. % \begin{macrocode} - \lltxmath_patch:NNnnn \@genfrac \cs_set_nopar:Npn { + \@@_patch:NNnnn \@genfrac \cs_set_nopar:Npn { #1 #2 #3 #4 #5 } { { @@ -672,6 +685,48 @@ % \end{macro} % % +% \subsection{\pkg{amsopn}} +% +% \changes{v1.1}{2012/10/13}{Add fix and unit test for \pkg{amsopn}} +% The \pkg{amsopn} package can be used standalone, but is also loaded by +% \pkg{amsmath}. It provides the \cmd{\DeclareMathOperator} command which +% breaks when the minus character is a Unicode math character; this issue was +% brought to my attention by \Burnol. +% +% \begin{macro}{\newmcodes@} +% We only need to patch one usage of |\mathcode| in the internal macro +% |\newmcodes@|, which is called by all user-defined operators. +% \begin{macrocode} +\group_begin: +\char_set_catcode_other:N \" +\AtEndOfPackageFile * { amsopn } { + \@@_patch:NNnnn \newmcodes@ \cs_gset_nopar:Npn { } { + \mathcode `\' 39 + \mathcode `\* 42 + \mathcode `\. "613A + \ifnum \mathcode `\- = 45 ~ \else + \mathchardef \std@minus \mathcode `\- \relax + \fi + \mathcode `\- 45 + \mathcode `\/ 47 + \mathcode `\: "603A \relax + } { + \char_set_mathcode:nn { `\' } { 39 } + \char_set_mathcode:nn { `\* } { 42 } + \char_set_mathcode:nn { `\. } { "613A } + \int_compare:nNnF { \luatexUmathcodenum `\- } = { 45 } { + \@@_set_mathchar:NN \std@minus \- + } + \char_set_mathcode:nn { `\- } { 45 } + \char_set_mathcode:nn { `\/ } { 47 } + \char_set_mathcode:nn { `\: } { "603A } + } +} +\group_end: +% \end{macrocode} +% \end{macro} +% +% % \subsection{\pkg{mathtools}} % % \pkg{mathtools}’ \cmd{\cramped} command and others that make use of its @@ -705,7 +760,7 @@ % single command. % \begin{macrocode} \AtEndOfPackageFile * { mathtools } { - \lltxmath_patch:NNnnn \MT_cramped_internal:Nn + \@@_patch:NNnnn \MT_cramped_internal:Nn \cs_set_nopar:Npn { #1 #2 } { \sbox \z@ { $ @@ -755,7 +810,7 @@ % The \pkg{icomma} package uses |\mathchardef| to save the mathematical code of % the comma character. This breaks for Unicode fonts. The incompatibility was % noticed by -% \Breitfeld.\footnote{\url{https://groups.google.com/d/topic/de.comp.text.tex/Cputk-AJS5I/discussion}} +% \Breitfeld.\footnote{\url{https://groups.google.com/forum/\#!topic/de.comp.text.tex/Cputk-AJS5I/discussion}} % % \begin{macro}{\mathcomma} % \pkg{icomma} defines the mathemathical character shorthand \cmd{\icomma} at @@ -766,7 +821,7 @@ \tl_replace_once:Nnn \@begindocumenthook { \mathchardef \mathcomma \mathcode `\, } { - \lltxmath_set_mathchar:NN \mathcomma \, + \@@_set_mathchar:NN \mathcomma \, } } % @@ -840,6 +895,7 @@ end % % \begin{macrocode} %<*test> +%<@@=test> \documentclass[pagesize=auto]{scrartcl} % \end{macrocode} % Only \pkg{xparse} starting with 2008/08/03 has \cmd{\NewDocumentCommand}. @@ -857,11 +913,11 @@ end % \end{macrocode} % \end{l3message} % -% \begin{macro}{\test_pass:x} -% The macro \cmd{\test_pass:x}\marg{text} issues the \msg{pass} message with +% \begin{macro}{\@@_pass:x} +% The macro \cmd{\@@_pass:x}\marg{text} issues the \msg{pass} message with % description \meta{text}. % \begin{macrocode} -\cs_new_protected_nopar:Npn \test_pass:x #1 { +\cs_new_protected_nopar:Npn \@@_pass:x #1 { \msg_info:nnx { test } { pass } { #1 } } % \end{macrocode} @@ -874,11 +930,11 @@ end % \end{macrocode} % \end{l3message} % -% \begin{macro}{\test_fail:x} -% The macro \cmd{\test_fail:x}\marg{text} issues the \msg{fail} message with +% \begin{macro}{\@@_fail:x} +% The macro \cmd{\@@_fail:x}\marg{text} issues the \msg{fail} message with % description \meta{text}. % \begin{macrocode} -\cs_new_protected_nopar:Npn \test_fail:x #1 { +\cs_new_protected_nopar:Npn \@@_fail:x #1 { \msg_error:nnx { test } { fail } { #1 } } % \end{macrocode} @@ -891,57 +947,57 @@ end % \end{macrocode} % \end{macro} % -% \begin{macro}{\c_test_equal_tl} -% \begin{macro}{\c_test_not_equal_tl} +% \begin{macro}{\c_@@_equal_tl} +% \begin{macro}{\c_@@_not_equal_tl} % Two shorthands for pretty-printing test results. % \begin{macrocode} -\tl_const:Nx \c_test_equal_tl { \c_space_tl == \c_space_tl } -\tl_const:Nx \c_test_not_equal_tl { \c_space_tl != \c_space_tl } +\tl_const:Nx \c_@@_equal_tl { \c_space_tl == \c_space_tl } +\tl_const:Nx \c_@@_not_equal_tl { \c_space_tl != \c_space_tl } % \end{macrocode} % \end{macro} % \end{macro} % -% \begin{macro}{\test_equal_pass:nxnx} -% The macro \cmd{\test_equal_pass:nxnx}\marg{first expression}\marg{first +% \begin{macro}{\@@_equal_pass:nxnx} +% The macro \cmd{\@@_equal_pass:nxnx}\marg{first expression}\marg{first % value}\marg{second expression}\marg{second value} is called when the two % values arising from the two expressions are equal. % \begin{macrocode} -\cs_new_protected_nopar:Npn \test_equal_pass:nxnx #1 #2 #3 #4 { - \test_pass:x { +\cs_new_protected_nopar:Npn \@@_equal_pass:nxnx #1 #2 #3 #4 { + \@@_pass:x { \exp_not:n { #1 } - \c_test_equal_tl + \c_@@_equal_tl #2 - \c_test_equal_tl + \c_@@_equal_tl #4 - \c_test_equal_tl + \c_@@_equal_tl \exp_not:n { #3 } } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\test_equal_fail:nxnx} -% The macro \cmd{\test_equal_pass:nxnx}\marg{first expression}\marg{first +% \begin{macro}{\@@_equal_fail:nxnx} +% The macro \cmd{\@@_equal_pass:nxnx}\marg{first expression}\marg{first % value}\marg{second expression}\marg{second value} is called when the two % values arising from the two expressions are not equal. % \begin{macrocode} -\cs_new_protected_nopar:Npn \test_equal_fail:nxnx #1 #2 #3 #4 { - \test_fail:x { +\cs_new_protected_nopar:Npn \@@_equal_fail:nxnx #1 #2 #3 #4 { + \@@_fail:x { \exp_not:n { #1 } - \c_test_equal_tl + \c_@@_equal_tl #2 - \c_test_not_equal_tl + \c_@@_not_equal_tl #4 - \c_test_equal_tl + \c_@@_equal_tl \exp_not:n { #3 } } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\test_assert_equal:NNNNNnn} -% \begin{macro}{\test_assert_equal:cccccnn} -% The macro \cmd{\test_assert_equal:NNNNNnn}\meta{set command}\meta{use +% \begin{macro}{\@@_assert_equal:NNNNNnn} +% \begin{macro}{\@@_assert_equal:cccccnn} +% The macro \cmd{\@@_assert_equal:NNNNNnn}\meta{set command}\meta{use % command}\meta{compare command}\meta{first temporary command}\meta{second % temporary command}\marg{first expression}\marg{second expression} asserts % that the two expressions are equal. The \meta{set command} must have the @@ -949,41 +1005,41 @@ end % the \meta{compare command} \texttt{nNnTF}. % \begin{macrocode} \cs_new_protected_nopar:Npn -\test_assert_equal:NNNNNnn #1 #2 #3 #4 #5 #6 #7 { +\@@_assert_equal:NNNNNnn #1 #2 #3 #4 #5 #6 #7 { #1 #4 { #6 } #1 #5 { #7 } #3 { #4 } = { #5 } { - \test_equal_pass:nxnx { #6 } { #2 #4 } { #7 } { #2 #5 } + \@@_equal_pass:nxnx { #6 } { #2 #4 } { #7 } { #2 #5 } } { - \test_equal_fail:nxnx { #6 } { #2 #4 } { #7 } { #2 #5 } + \@@_equal_fail:nxnx { #6 } { #2 #4 } { #7 } { #2 #5 } } } -\cs_generate_variant:Nn \test_assert_equal:NNNNNnn { ccccc } +\cs_generate_variant:Nn \@@_assert_equal:NNNNNnn { ccccc } % \end{macrocode} % \end{macro} % \end{macro} % -% \begin{macro}{\test_assert_equal:nnn} -% The macro \cmd{\test_assert_equal:nnn}\marg{data type}\marg{first +% \begin{macro}{\@@_assert_equal:nnn} +% The macro \cmd{\@@_assert_equal:nnn}\marg{data type}\marg{first % expression}\marg{second expression} is a simplified version of -% \cmd{\test_assert_equal:NNNNNnn} for data types following the -% \hologo{LaTeX3} naming conventions; \meta{data type} must be \texttt{int}, -% \texttt{dim}, \etc +% \cmd{\@@_assert_equal:NNNNNnn} for data types following the \hologo{LaTeX3} +% naming conventions; \meta{data type} must be \texttt{int}, \texttt{dim}, +% \etc % \begin{macrocode} -\cs_new_protected_nopar:Npn \test_assert_equal:nnn #1 #2 #3 { - \test_assert_equal:cccccnn +\cs_new_protected_nopar:Npn \@@_assert_equal:nnn #1 #2 #3 { + \@@_assert_equal:cccccnn { #1 _set:Nn } { #1 _use:N } { #1 _compare:nNnTF } - { l_test_tmpa_ #1 } { l_test_tmpb_ #1 } { #2 } { #3 } + { l_@@_tmpa_ #1 } { l_@@_tmpb_ #1 } { #2 } { #3 } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\l_test_tmpa_int} -% \begin{macro}{\l_test_tmpb_int} +% \begin{macro}{\l_@@_tmpa_int} +% \begin{macro}{\l_@@_tmpb_int} % Scratch registers for numbers. % \begin{macrocode} -\int_new:N \l_test_tmpa_int -\int_new:N \l_test_tmpb_int +\int_new:N \l_@@_tmpa_int +\int_new:N \l_@@_tmpb_int % \end{macrocode} % \end{macro} % \end{macro} @@ -992,17 +1048,17 @@ end % expression} asserts that the two integral expressions are equal. % \begin{macrocode} \NewDocumentCommand \AssertIntEqual { m m } { - \test_assert_equal:nnn { int } { #1 } { #2 } + \@@_assert_equal:nnn { int } { #1 } { #2 } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\l_test_tmpa_int} -% \begin{macro}{\l_test_tmpb_int} +% \begin{macro}{\l_@@_tmpa_int} +% \begin{macro}{\l_@@_tmpb_int} % Scratch registers for dimensions. % \begin{macrocode} -\dim_new:N \l_test_tmpa_dim -\dim_new:N \l_test_tmpb_dim +\dim_new:N \l_@@_tmpa_dim +\dim_new:N \l_@@_tmpb_dim % \end{macrocode} % \end{macro} % \end{macro} @@ -1012,7 +1068,7 @@ end % expression} asserts that the two dimension expressions are equal. % \begin{macrocode} \NewDocumentCommand \AssertDimEqual { m m } { - \test_assert_equal:nnn { dim } { #1 } { #2 } + \@@_assert_equal:nnn { dim } { #1 } { #2 } } % \end{macrocode} % \end{macro} @@ -1028,31 +1084,31 @@ end % \end{macrocode} % \end{macro} % -% \begin{macro}{\test_assert_cramped:Nx} -% The macro \cmd{\test_assert_cramped:Nn}\meta{predicate}\marg{name} asserts +% \begin{macro}{\@@_assert_cramped:Nx} +% The macro \cmd{\@@_assert_cramped:Nn}\meta{predicate}\marg{name} asserts % that we are in math mode and that the current style fulfills the % \meta{predicate} (identified by the \meta{name}) which must have the % argument specification \texttt{n}. % \begin{macrocode} -\cs_new_protected_nopar:Npn \test_assert_cramped:Nx #1 #2 { - \int_set:Nn \l_test_tmpa_int { \luatexmathstyle } +\cs_new_protected_nopar:Npn \@@_assert_cramped:Nx #1 #2 { + \int_set:Nn \l_@@_tmpa_int { \luatexmathstyle } \bool_if:nTF { - \int_compare_p:nNn { \l_test_tmpa_int } > { \c_minus_one } + \int_compare_p:nNn { \l_@@_tmpa_int } > { \c_minus_one } && - #1 { \l_test_tmpa_int } + #1 { \l_@@_tmpa_int } } { - \test_pass:x { + \@@_pass:x { \exp_not:N \luatexmathstyle - \c_test_equal_tl - \int_use:N \l_test_tmpa_int + \c_@@_equal_tl + \int_use:N \l_@@_tmpa_int \c_space_tl is~ a~ #2~ style } } { - \test_fail:x { + \@@_fail:x { \exp_not:N \luatexmathstyle - \c_test_equal_tl - \int_use:N \l_test_tmpa_int + \c_@@_equal_tl + \int_use:N \l_@@_tmpa_int \c_space_tl is~ not~ a~ #2~ style } @@ -1066,7 +1122,7 @@ end % mathematical style is one of the non-cramped styles. % \begin{macrocode} \NewDocumentCommand \AssertNoncrampedStyle { } { - \test_assert_cramped:Nx \int_if_even_p:n { non-cramped } + \@@_assert_cramped:Nx \int_if_even_p:n { non-cramped } } % \end{macrocode} % \end{macro} @@ -1076,17 +1132,17 @@ end % style is one of the cramped styles. % \begin{macrocode} \NewDocumentCommand \AssertCrampedStyle { } { - \test_assert_cramped:Nx \int_if_odd_p:n { cramped } + \@@_assert_cramped:Nx \int_if_odd_p:n { cramped } } % \end{macrocode} % \end{macro} % -% \begin{macro}{\l_test_tmpa_box} -% \begin{macro}{\l_test_tmpb_box} +% \begin{macro}{\l_@@_tmpa_box} +% \begin{macro}{\l_@@_tmpb_box} % Scratch registers for box constructions. % \begin{macrocode} -\box_new:N \l_test_tmpa_box -\box_new:N \l_test_tmpb_box +\box_new:N \l_@@_tmpa_box +\box_new:N \l_@@_tmpb_box % \end{macrocode} % \end{macro} % \end{macro} @@ -1094,22 +1150,32 @@ end % \begin{function}{contains_space} % The function \func{contains_space}|(head, width)| returns |true| if the % node list starting at |head| or any of its sublists contain a glue or kern -% node of width |width| (or any glue or kern node if |width| is |nil|). +% node of width |width|. If |width| is |nil|, returns |true| if there is any +% glue or kern node. If |width| is the string |"nonzero"|, returns |true| if +% there is any glue node or kern node of nonzero with. +% \changes{v1.1}{2012/10/13}{Allow testing for nonzero kern nodes} % \begin{macrocode} \begin{luacode*} function contains_space(head, width) for n in node.traverse(head) do local id = n.id - if id == 10 or id == 11 then + if id == 10 then -- glue node if width then - if (id == 10 and n.spec.width == width) - or (id == 11 and n.kern == width) then + if width == "nonzero" or n.spec.width == width then + return true + end + end + elseif id == 11 then -- kern node + if width then + if width == "nonzero" then + if n.kern ~= 0 then + return true + end + elseif n.kern == width then return true end - else - return true end - elseif id == 0 or id == 1 then + elseif id == 0 or id == 1 then -- sublist if contains_space(n.head, width) then return true end @@ -1124,27 +1190,31 @@ end % \begin{macro}{\AssertNoSpace} % The command \cmd{\AssertNoSpace}\marg{text} asserts that the node list that % is the result of typesetting \meta{text} contains no glue or kern nodes. -% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to \cs{lua_now_x:n}} +% When called with a star, the command ignores zero-width kerns. +% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to +% \cs{lua_now_x:n}} +% \changes{v1.1}{2012/10/13}{Allow testing for nonzero kern nodes} % \begin{macrocode} -\NewDocumentCommand \AssertNoSpace { m } { - \hbox_set:Nn \l_test_tmpa_box { #1 } +\NewDocumentCommand \AssertNoSpace { s m } { + \hbox_set:Nn \l_@@_tmpa_box { #2 } \int_if_odd:nTF { \lua_now_x:n { - local~ b = tex.getbox(\int_use:N \l_test_tmpa_box) - if~ contains_space(b.head) then~ + local~ b = tex.getbox(\int_use:N \l_@@_tmpa_box) + if~ contains_space(b.head, + \IfBooleanTF { #1 } { "nonzero" } { nil }) then~ tex.sprint("0") else~ tex.sprint("1") end } } { - \test_pass:x { - \tl_to_str:n { #1 } ~ + \@@_pass:x { + \tl_to_str:n { #2 } ~ contains~ no~ skip~ or~ kern~ node } } { - \test_fail:x { - \tl_to_str:n { #1 } ~ + \@@_fail:x { + \tl_to_str:n { #2 } ~ contains~ a~ skip~ or~ kern~ node } } @@ -1156,16 +1226,17 @@ end % The command \cmd{\AssertMuSpace}\marg{text}\marg{muskip} asserts that the % node list that is the result of typesetting \meta{text} contains at least % one glue or kern node of with \meta{muskip}. -% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to \cs{lua_now_x:n}} +% \changes{v0.3c}{2012/08/23}{\pkg{l3kernel} renamed \cs{lua_now:x} to +% \cs{lua_now_x:n}} % \begin{macrocode} \makeatletter \NewDocumentCommand \AssertMuSpace { m m } { - \hbox_set:Nn \l_test_tmpa_box { #1 } - \hbox_set:Nn \l_test_tmpb_box { $ \mskip #2 \m@th $ } + \hbox_set:Nn \l_@@_tmpa_box { #1 } + \hbox_set:Nn \l_@@_tmpb_box { $ \mskip #2 \m@th $ } \int_if_odd:nTF { \lua_now_x:n { - local~ b = tex.getbox(\int_use:N \l_test_tmpa_box) - local~ s = tex.getbox(\int_use:N \l_test_tmpb_box) + local~ b = tex.getbox(\int_use:N \l_@@_tmpa_box) + local~ s = tex.getbox(\int_use:N \l_@@_tmpb_box) if~ contains_space(b.head, s.width) then~ tex.sprint("1") else~ @@ -1173,13 +1244,13 @@ end end } } { - \test_pass:x { + \@@_pass:x { \tl_to_str:n { #1 } ~ contains~ a~ skip~ or~ kern~ node~ of~ width~ \tl_to_str:n { #2 } } } { - \test_fail:x { + \@@_fail:x { \tl_to_str:n { #1 } ~ contains~ no~ skip~ or~ kern~ node~ of~ width~ \tl_to_str:n { #2 } @@ -1211,23 +1282,23 @@ end } { \prg_case_int:nnn { \int_mod:nn { #1 } { \c_three } } { { \c_zero } { - \chk_if_free_cs:N \g_test_family_int - \newfam \g_test_family_int - \AssertIntEqual { \g_test_family_int } { #1 } - \cs_undefine:N \g_test_family_int + \chk_if_free_cs:N \g_@@_family_int + \newfam \g_@@_family_int + \AssertIntEqual { \g_@@_family_int } { #1 } + \cs_undefine:N \g_@@_family_int } { \c_one } { - \chk_if_free_cs:N \g_test_mathgroup_int - \new@mathgroup \g_test_mathgroup_int - \AssertIntEqual { \g_test_mathgroup_int } { #1 } - \cs_undefine:N \g_test_mathgroup_int + \chk_if_free_cs:N \g_@@_mathgroup_int + \new@mathgroup \g_@@_mathgroup_int + \AssertIntEqual { \g_@@_mathgroup_int } { #1 } + \cs_undefine:N \g_@@_mathgroup_int } { \c_two } { \DeclareSymbolFont { Test #1 } { OT1 } { cmr } { m } { n } \exp_args:Nc \AssertIntEqual { sym Test #1 } { #1 } } } { - \test_fail:x { This~ cannot~ happen } + \@@_fail:x { This~ cannot~ happen } } } \DeclareSymbolFont { Test 255 } { OT1 } { cmr } { bx } { it } @@ -1298,9 +1369,11 @@ end % \end{macrocode} % % -% \subsection{\pkg{amsmath} and \pkg{mathtools}} +% \subsection{\pkg{amsmath}, \pkg{amsopn}, and \pkg{mathtools}} % -% Since \pkg{mathtools} loads \pkg{amsmath} anyway, we test both in one file. +% \changes{v1.1}{2012/10/13}{Add fix and unit test for \pkg{amsopn}} +% Since \pkg{mathtools} loads \pkg{amsmath} and \pkg{amsopn} anyway, we test +% all three in one file. % \begin{macro}{\testbox} % First a scratch box register. % \begin{macrocode} @@ -1318,6 +1391,12 @@ end \makeatletter \AssertIntEqual{\std@minus}{"33444444} \makeatother +% \end{macrocode} +% Check that we can still declare operators. +% \begin{macrocode} +\DeclareMathOperator{\Operator}{*-/'a-b} +\DeclareMathOperator*{\OperatorWithLimits}{01'*-/} +\DeclareMathOperator{\OperatorWithPunctuation}{a:b*/'-.} \usepackage{mathtools} % \end{macrocode} % The same for the document begin hook. @@ -1438,6 +1517,17 @@ end a^{\AssertMathStyle{4} a} \AssertMathStyle{2} \end{math} +% \end{macrocode} +% The \pkg{amsopn} package uses |\mathcode| when executing a user-defined +% operator command. Test that this was patched out. +% \begin{macrocode} +\AssertNoSpace*{$\Operator$} +\AssertNoSpace*{$\OperatorWithLimits$} +\AssertMuSpace{$\OperatorWithPunctuation$}{\thinmuskip} +\mathcode`\-=45 \relax +\AssertNoSpace*{$\Operator$} +\AssertNoSpace*{$\OperatorWithLimits$} +\AssertMuSpace{$\OperatorWithPunctuation$}{\thinmuskip} \end{document} % % \end{macrocode} @@ -1453,7 +1543,8 @@ end % \pkg{fontspec-patches} uses \cmd{\RenewDocumentCommand} from the \pkg{xparse} % package, which generates a warning that we don't want to turn into an error. % Therefore we treat the offending message \msg{redefine-command} specially. -% \changes{v0.3c}{2012/08/23}{Added special treatment for \msg{redefine-command} warning} +% \changes{v0.3c}{2012/08/23}{Added special treatment for +% \msg{redefine-command} warning} % % \begin{macrocode} %<*test-unicode> diff --git a/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.ins b/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.ins index 4c372443e0b..ffc3097af88 100644 --- a/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.ins +++ b/Master/texmf-dist/source/lualatex/lualatex-math/lualatex-math.ins @@ -15,7 +15,7 @@ % The Current Maintainer of this work is Philipp Stephani. % This work consists of all files listed in MANIFEST. -\input docstrip.tex +\input l3docstrip.tex \keepsilent \askforoverwritefalse diff --git a/Master/texmf-dist/tex/lualatex/lualatex-math/lualatex-math.sty b/Master/texmf-dist/tex/lualatex/lualatex-math/lualatex-math.sty index d0312d0a3f0..3620b363986 100644 --- a/Master/texmf-dist/tex/lualatex/lualatex-math/lualatex-math.sty +++ b/Master/texmf-dist/tex/lualatex/lualatex-math/lualatex-math.sty @@ -22,18 +22,18 @@ %% \NeedsTeXFormat{LaTeX2e}[2009/09/24] \RequirePackage{expl3}[2012/08/14] -\ProvidesExplPackage{lualatex-math}{2012/08/23}{0.3c}% +\ProvidesExplPackage{lualatex-math}{2012/10/13}{1.1}% {Patches for mathematics typesetting with LuaLaTeX} \RequirePackage { etoolbox } [ 2007/10/08 ] \RequirePackage { luatexbase } [ 2010/05/27 ] \RequirePackage { filehook } [ 2011/03/09 ] \RequireLuaModule { lualatex-math } [ 2011/05/05 ] -\cs_new_nopar:Npn \lltxmath_restore_catcode:N #1 { +\cs_new_nopar:Npn \__lltxmath_restore_catcode:N #1 { \char_set_catcode:nn { \int_eval:n { `#1 } } { \char_value_catcode:n { `#1 } } } \exp_args:Nx \AtEndOfPackage { - \lltxmath_restore_catcode:N \$ + \__lltxmath_restore_catcode:N \$ } \char_set_catcode_math_toggle:N \$ \msg_new:nnn { lualatex-math } { luatex-required } { @@ -66,23 +66,23 @@ \msg_error:nn { lualatex-math } { luatex-required } \endinput } -\cs_new_eq:NN \lltxmath_temp:w \prg_do_nothing: +\cs_new_eq:NN \__lltxmath_temp:w \prg_do_nothing: \luatexbase@ensure@primitive { Umathcode } \luatexbase@ensure@primitive { Umathcodenum } \luatexbase@ensure@primitive { Umathchardef } -\cs_new_protected_nopar:Npn \lltxmath_assert_eq:NN #1 #2 { +\cs_new_protected_nopar:Npn \__lltxmath_assert_eq:NN #1 #2 { \cs_if_eq:NNF #1 #2 { \msg_error:nnxxxx { lualatex-math } { different-meanings } { \token_to_str:N #1 } { \token_to_meaning:N #1 } { \token_to_str:N #2 } { \token_to_meaning:N #2 } } } -\cs_new_protected_nopar:Npn \lltxmath_patch:NNnnn #1 #2 #3 #4 #5 { +\cs_new_protected_nopar:Npn \__lltxmath_patch:NNnnn #1 #2 #3 #4 #5 { \cs_if_exist:NT #1 { \token_if_macro:NTF #1 { \group_begin: - #2 \lltxmath_temp:w #3 { #4 } - \cs_if_eq:NNTF #1 \lltxmath_temp:w { + #2 \__lltxmath_temp:w #3 { #4 } + \cs_if_eq:NNTF #1 \__lltxmath_temp:w { \msg_info:nnx { lualatex-math } { patch-macro } { \token_to_str:N #1 } \group_end: @@ -90,7 +90,7 @@ } { \msg_warning:nnxxx { lualatex-math } { wrong-meaning } { \token_to_str:N #1 } { \token_to_meaning:N #1 } - { \token_to_meaning:N \lltxmath_temp:w } + { \token_to_meaning:N \__lltxmath_temp:w } \group_end: } } { @@ -99,16 +99,16 @@ } } } -\cs_generate_variant:Nn \lltxmath_patch:NNnnn { c } -\cs_new_protected_nopar:Npn \lltxmath_set_mathchar:NN #1 #2 { +\cs_generate_variant:Nn \__lltxmath_patch:NNnnn { c } +\cs_new_protected_nopar:Npn \__lltxmath_set_mathchar:NN #1 #2 { \luatexUmathchardef #1 \lua_now_x:n { lualatex.math.print_class_fam_slot( \int_eval:n { `#2 } ) } \scan_stop: } -\lltxmath_assert_eq:NN \newfam \new@mathgroup -\lltxmath_patch:NNnnn \new@mathgroup \cs_set_nopar:Npn { } { +\__lltxmath_assert_eq:NN \newfam \new@mathgroup +\__lltxmath_patch:NNnnn \new@mathgroup \cs_set_nopar:Npn { } { \alloc@ 8 \mathgroup \chardef \sixt@@n } { \alloc@ 8 \mathgroup \chardef \c_two_hundred_fifty_six @@ -117,7 +117,7 @@ \luatexbase@ensure@primitive { Ustack } \AtEndPreamble { \@ifpackageloaded { amsmath } { } { - \lltxmath_patch:NNnnn \frac \cs_set_nopar:Npn { #1 #2 } { + \__lltxmath_patch:NNnnn \frac \cs_set_nopar:Npn { #1 #2 } { { \begingroup #1 \endgroup \over #2 } @@ -134,26 +134,26 @@ \luatexbase@ensure@primitive { Umathstacknumup } \luatexbase@ensure@primitive { Umathstackdenomdown } \luatexbase@ensure@primitive { Umathstackvgap } -\int_const:Nn \c_lltxmath_std_minus_mathcode_int { "2200 } -\int_const:Nn \c_lltxmath_std_equal_mathcode_int { "303D } -\cs_new_nopar:Npn \lltxmath_char_dim:NN #1 #2 { +\int_const:Nn \c__lltxmath_std_minus_mathcode_int { "2200 } +\int_const:Nn \c__lltxmath_std_equal_mathcode_int { "303D } +\cs_new_nopar:Npn \__lltxmath_char_dim:NN #1 #2 { #1 \textfont \lua_now_x:n { lualatex.math.print_fam_slot( \int_eval:n { `#2 } ) } } -\chk_if_free_cs:N \l_lltxmath_minus_mathchar -\chk_if_free_cs:N \l_lltxmath_equal_mathchar +\chk_if_free_cs:N \l__lltxmath_minus_mathchar +\chk_if_free_cs:N \l__lltxmath_equal_mathchar \AtBeginOfPackageFile { amsmath } { - \lltxmath_set_mathchar:NN \l_lltxmath_minus_mathchar \- - \lltxmath_set_mathchar:NN \l_lltxmath_equal_mathchar \= - \char_set_mathcode:nn { `\- } { \c_lltxmath_std_minus_mathcode_int } - \char_set_mathcode:nn { `\= } { \c_lltxmath_std_equal_mathcode_int } + \__lltxmath_set_mathchar:NN \l__lltxmath_minus_mathchar \- + \__lltxmath_set_mathchar:NN \l__lltxmath_equal_mathchar \= + \char_set_mathcode:nn { `\- } { \c__lltxmath_std_minus_mathcode_int } + \char_set_mathcode:nn { `\= } { \c__lltxmath_std_equal_mathcode_int } \AtEndOfPackageFile { amsmath } { - \cs_set_eq:NN \std@minus \l_lltxmath_minus_mathchar - \cs_set_eq:NN \std@equal \l_lltxmath_equal_mathchar - \luatexUmathcodenum `\- \l_lltxmath_minus_mathchar - \luatexUmathcodenum `\= \l_lltxmath_equal_mathchar + \cs_set_eq:NN \std@minus \l__lltxmath_minus_mathchar + \cs_set_eq:NN \std@equal \l__lltxmath_equal_mathchar + \luatexUmathcodenum `\- \l__lltxmath_minus_mathchar + \luatexUmathcodenum `\= \l__lltxmath_equal_mathchar } } \AtEndOfPackageFile * { amsmath } { @@ -161,10 +161,10 @@ \mathchardef \std@minus \mathcode `\- \relax \mathchardef \std@equal \mathcode `\= \relax } { - \lltxmath_set_mathchar:NN \std@minus \- - \lltxmath_set_mathchar:NN \std@equal \= + \__lltxmath_set_mathchar:NN \std@minus \- + \__lltxmath_set_mathchar:NN \std@equal \= } - \lltxmath_patch:NNnnn \resetMathstrut@ \cs_set_nopar:Npn { } { + \__lltxmath_patch:NNnnn \resetMathstrut@ \cs_set_nopar:Npn { } { \setbox \z@ \hbox { \mathchardef \@tempa \mathcode `\( \relax % \) \def \@tempb ##1 "##2 ##3 { \the \textfont "##3 \char" } @@ -174,13 +174,13 @@ \dp \Mathstrutbox@ \dp \z@ } { \box_set_ht:Nn \Mathstrutbox@ { - \lltxmath_char_dim:NN \fontcharht \( % \) + \__lltxmath_char_dim:NN \fontcharht \( % \) } \box_set_dp:Nn \Mathstrutbox@ { - \lltxmath_char_dim:NN \fontchardp \) + \__lltxmath_char_dim:NN \fontchardp \) } } - \lltxmath_patch:NNnnn \subarray \cs_set:Npn { #1 } { + \__lltxmath_patch:NNnnn \subarray \cs_set:Npn { #1 } { \vcenter \bgroup \Let@ @@ -219,7 +219,7 @@ \hfil \crcr } - \lltxmath_patch:cNnnn { frac~ } \cs_set:Npn { #1 #2 } { + \__lltxmath_patch:cNnnn { frac~ } \cs_set:Npn { #1 #2 } { { \begingroup #1 \endgroup \@@over #2 } @@ -228,7 +228,7 @@ \luatexUstack { \group_begin: #1 \group_end: \@@over #2 } } } - \lltxmath_patch:NNnnn \@genfrac \cs_set_nopar:Npn { + \__lltxmath_patch:NNnnn \@genfrac \cs_set_nopar:Npn { #1 #2 #3 #4 #5 } { { @@ -244,12 +244,38 @@ } } } +\group_begin: +\char_set_catcode_other:N \" +\AtEndOfPackageFile * { amsopn } { + \__lltxmath_patch:NNnnn \newmcodes@ \cs_gset_nopar:Npn { } { + \mathcode `\' 39 + \mathcode `\* 42 + \mathcode `\. "613A + \ifnum \mathcode `\- = 45 ~ \else + \mathchardef \std@minus \mathcode `\- \relax + \fi + \mathcode `\- 45 + \mathcode `\/ 47 + \mathcode `\: "603A \relax + } { + \char_set_mathcode:nn { `\' } { 39 } + \char_set_mathcode:nn { `\* } { 42 } + \char_set_mathcode:nn { `\. } { "613A } + \int_compare:nNnF { \luatexUmathcodenum `\- } = { 45 } { + \__lltxmath_set_mathchar:NN \std@minus \- + } + \char_set_mathcode:nn { `\- } { 45 } + \char_set_mathcode:nn { `\/ } { 47 } + \char_set_mathcode:nn { `\: } { "603A } + } +} +\group_end: \luatexbase@ensure@primitive { crampeddisplaystyle } \luatexbase@ensure@primitive { crampedtextstyle } \luatexbase@ensure@primitive { crampedscriptstyle } \luatexbase@ensure@primitive { crampedscriptscriptstyle } \AtEndOfPackageFile * { mathtools } { - \lltxmath_patch:NNnnn \MT_cramped_internal:Nn + \__lltxmath_patch:NNnnn \MT_cramped_internal:Nn \cs_set_nopar:Npn { #1 #2 } { \sbox \z@ { $ @@ -288,7 +314,7 @@ \tl_replace_once:Nnn \@begindocumenthook { \mathchardef \mathcomma \mathcode `\, } { - \lltxmath_set_mathchar:NN \mathcomma \, + \__lltxmath_set_mathchar:NN \mathcomma \, } } \endinput -- cgit v1.2.3