| 1 |
%% |
| 2 |
%% This is file `lualatex-math.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% lualatex-math.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% This is a generated file. |
| 10 |
%% |
| 11 |
%% Copyright 2011-2020 Philipp Stephani |
| 12 |
%% |
| 13 |
%% This file may be distributed and/or modified under the |
| 14 |
%% conditions of the LaTeX Project Public License, either |
| 15 |
%% version 1.3c of this license or (at your option) any later |
| 16 |
%% version. The latest version of this license is in |
| 17 |
%% |
| 18 |
%% http://www.latex-project.org/lppl.txt |
| 19 |
%% |
| 20 |
%% and version 1.3c or later is part of all distributions of |
| 21 |
%% LaTeX version 2009/09/24 or later. |
| 22 |
%% |
| 23 |
\NeedsTeXFormat{LaTeX2e}[2020/02/02] |
| 24 |
\RequirePackage{expl3}[2018/06/18] |
| 25 |
\ProvidesExplPackage{lualatex-math}{2022/01/01}{1.12}% |
| 26 |
{Patches for mathematics typesetting with LuaLaTeX} |
| 27 |
\RequirePackage { etoolbox } [ 2007/10/08 ] |
| 28 |
\cs_if_exist:NF \newluabytecode |
| 29 |
{ \RequirePackage { luatexbase } [ 2010/05/27 ] } |
| 30 |
\directlua{require("lualatex-math")} |
| 31 |
\cs_new_nopar:Npn \__lltxmath_restore_catcode:N #1 { |
| 32 |
\char_set_catcode:nn { \int_eval:n { `#1 } } |
| 33 |
{ \char_value_catcode:n { `#1 } } |
| 34 |
} |
| 35 |
\exp_args:Nx \AtEndOfPackage { |
| 36 |
\__lltxmath_restore_catcode:N \$ |
| 37 |
} |
| 38 |
\char_set_catcode_math_toggle:N \$ |
| 39 |
\msg_new:nnn { lualatex-math } { luatex-required } { |
| 40 |
The~ lualatex-math~ package~ requires~ LuaTeX. \\ |
| 41 |
I~ will~ stop~ loading~ now. |
| 42 |
} |
| 43 |
\msg_new:nnn { lualatex-math } { macro-expected } { |
| 44 |
I've~ expected~ that~ #1~ is~ a~ macro,~ but~ it~ isn't. |
| 45 |
} |
| 46 |
\msg_new:nnn { lualatex-math } { wrong-meaning } { |
| 47 |
I've~ expected~ #1~ to~ have~ the~ meaning \\ |
| 48 |
#3, \\ |
| 49 |
but~ it~ has~ the~ meaning \\ |
| 50 |
#2. |
| 51 |
} |
| 52 |
\msg_new:nnn { lualatex-math } { patch-macro } { |
| 53 |
I'm~ going~ to~ patch~ macro~ #1. |
| 54 |
} |
| 55 |
\sys_if_engine_luatex:F { |
| 56 |
\msg_error:nn { lualatex-math } { luatex-required } |
| 57 |
\endinput |
| 58 |
} |
| 59 |
\cs_new_eq:NN \__lltxmath_temp:w \prg_do_nothing: |
| 60 |
\cs_new_protected_nopar:Npn \__lltxmath_patch:NNnnn #1 #2 #3 #4 #5 { |
| 61 |
\cs_if_exist:NT #1 { |
| 62 |
\token_if_macro:NTF #1 { |
| 63 |
\group_begin: |
| 64 |
#2 \__lltxmath_temp:w #3 { #4 } |
| 65 |
\cs_if_eq:NNTF #1 \__lltxmath_temp:w { |
| 66 |
\msg_info:nnx { lualatex-math } { patch-macro } |
| 67 |
{ \token_to_str:N #1 } |
| 68 |
\group_end: |
| 69 |
#2 #1 #3 { #5 } |
| 70 |
} { |
| 71 |
\msg_warning:nnxxx { lualatex-math } { wrong-meaning } |
| 72 |
{ \token_to_str:N #1 } { \token_to_meaning:N #1 } |
| 73 |
{ \token_to_meaning:N \__lltxmath_temp:w } |
| 74 |
\group_end: |
| 75 |
} |
| 76 |
} { |
| 77 |
\msg_warning:nnx { lualatex-math } { macro-expected } |
| 78 |
{ \token_to_str:N #1 } |
| 79 |
} |
| 80 |
} |
| 81 |
} |
| 82 |
\cs_generate_variant:Nn \__lltxmath_patch:NNnnn { c } |
| 83 |
\cs_new_protected_nopar:Npn \__lltxmath_set_mathchar:NN #1 #2 { |
| 84 |
\Umathchardef #1 |
| 85 |
\lua_now:e { |
| 86 |
lualatex.math.print_class_fam_slot( \int_eval:n { `#2 } ) |
| 87 |
} |
| 88 |
\scan_stop: |
| 89 |
} |
| 90 |
\@ifl@t@r \fmtversion { 2021/11/15 } { |
| 91 |
\cs_new_protected_nopar:Npn \__lltxmath_before_package:nn #1 #2 { |
| 92 |
\AddToHook { package/#1/before } { #2 } |
| 93 |
} |
| 94 |
\cs_new_protected_nopar:Npn \__lltxmath_after_package:nn #1 #2 { |
| 95 |
\AddToHook { package/#1/after } { #2 } |
| 96 |
} |
| 97 |
}{ |
| 98 |
\@ifl@t@r \fmtversion { 2020/10/01 } { |
| 99 |
\cs_new_protected_nopar:Npn \__lltxmath_before_package:nn #1 #2 { |
| 100 |
\AddToHook { package/before/#1 } { #2 } |
| 101 |
} |
| 102 |
\cs_new_protected_nopar:Npn \__lltxmath_after_package:nn #1 #2 { |
| 103 |
\AddToHook { package/after/#1 } { #2 } |
| 104 |
} |
| 105 |
} { |
| 106 |
\RequirePackage { filehook } [ 2011/03/09 ] |
| 107 |
\cs_new_protected_nopar:Npn \__lltxmath_before_package:nn #1 #2 { |
| 108 |
\AtBeginOfPackageFile { #1 } { #2 } |
| 109 |
} |
| 110 |
\cs_new_protected_nopar:Npn \__lltxmath_after_package:nn #1 #2 { |
| 111 |
\AtEndOfPackageFile { #1 } { #2 } |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
\cs_new_protected_nopar:Npn \__lltxmath_after_package_or_now:nn #1 #2 { |
| 116 |
\@ifpackageloaded { #1 } { #2 } { \__lltxmath_after_package:nn { #1 } { #2 } } |
| 117 |
} |
| 118 |
\AtEndPreamble { |
| 119 |
\@ifpackageloaded { amsmath } { } { |
| 120 |
\__lltxmath_patch:cNnnn { frac~ } \cs_set:Npn { #1 #2 } { |
| 121 |
{ |
| 122 |
\begingroup #1 \endgroup \over #2 |
| 123 |
} |
| 124 |
} { |
| 125 |
{ |
| 126 |
\Ustack { \group_begin: #1 \group_end: \over #2 } |
| 127 |
} |
| 128 |
} |
| 129 |
} |
| 130 |
} |
| 131 |
\int_const:Nn \c__lltxmath_std_minus_mathcode_int { "2200 } |
| 132 |
\int_const:Nn \c__lltxmath_std_equal_mathcode_int { "303D } |
| 133 |
\tl_new:N \l__lltxmath_minus_mathchar |
| 134 |
\tl_new:N \l__lltxmath_equal_mathchar |
| 135 |
\__lltxmath_before_package:nn { amsmath } { |
| 136 |
\@ifpackagelater { amsmath } { 2020/08/24 } { } { |
| 137 |
\__lltxmath_set_mathchar:NN \l__lltxmath_minus_mathchar \- |
| 138 |
\__lltxmath_set_mathchar:NN \l__lltxmath_equal_mathchar \= |
| 139 |
\char_set_mathcode:nn { `\- } { \c__lltxmath_std_minus_mathcode_int } |
| 140 |
\char_set_mathcode:nn { `\= } { \c__lltxmath_std_equal_mathcode_int } |
| 141 |
\__lltxmath_after_package:nn { amsmath } { |
| 142 |
\cs_set_eq:NN \std@minus \l__lltxmath_minus_mathchar |
| 143 |
\cs_set_eq:NN \std@equal \l__lltxmath_equal_mathchar |
| 144 |
\Umathcodenum `\- \l__lltxmath_minus_mathchar |
| 145 |
\Umathcodenum `\= \l__lltxmath_equal_mathchar |
| 146 |
} |
| 147 |
} |
| 148 |
} |
| 149 |
\__lltxmath_after_package_or_now:nn { amsmath } { |
| 150 |
\@ifpackagelater { amsmath } { 2020/08/24 } { } { |
| 151 |
\tl_replace_once:Nnn \@begindocumenthook { |
| 152 |
\mathchardef \std@minus \mathcode `\- \relax |
| 153 |
\mathchardef \std@equal \mathcode `\= \relax |
| 154 |
} { |
| 155 |
\__lltxmath_set_mathchar:NN \std@minus \- |
| 156 |
\__lltxmath_set_mathchar:NN \std@equal \= |
| 157 |
} |
| 158 |
} |
| 159 |
\@ifpackagelater { amsmath } { 2020/09/23 } { } { |
| 160 |
\__lltxmath_patch:NNnnn \subarray \cs_set:Npn { #1 } { |
| 161 |
\vcenter |
| 162 |
\bgroup |
| 163 |
\Let@ |
| 164 |
\restore@math@cr |
| 165 |
\default@tag |
| 166 |
\baselineskip \fontdimen 10~ \scriptfont \tw@ |
| 167 |
\advance \baselineskip \fontdimen 12~ \scriptfont \tw@ |
| 168 |
\lineskip \thr@@ \fontdimen 8~ \scriptfont \thr@@ |
| 169 |
\lineskiplimit \lineskip |
| 170 |
\ialign |
| 171 |
\bgroup |
| 172 |
\ifx c #1 \hfil \fi |
| 173 |
$ \m@th \scriptstyle ## $ |
| 174 |
\hfil |
| 175 |
\crcr |
| 176 |
} { |
| 177 |
\vcenter |
| 178 |
\c_group_begin_token |
| 179 |
\Let@ |
| 180 |
\restore@math@cr |
| 181 |
\default@tag |
| 182 |
\skip_set:Nn \baselineskip { |
| 183 |
\Umathstacknumup \scriptstyle |
| 184 |
+ \Umathstackdenomdown \scriptstyle |
| 185 |
} |
| 186 |
\lineskip \Umathstackvgap \scriptstyle |
| 187 |
\lineskiplimit \lineskip |
| 188 |
\ialign |
| 189 |
\c_group_begin_token |
| 190 |
\token_if_eq_meaning:NNT c #1 { \hfil } |
| 191 |
\Ustartmath |
| 192 |
\m@th |
| 193 |
\scriptstyle |
| 194 |
\alignmark \alignmark |
| 195 |
\Ustopmath |
| 196 |
\hfil |
| 197 |
\crcr |
| 198 |
} |
| 199 |
\__lltxmath_patch:cNnnn { frac~ } \cs_set:Npn { #1 #2 } { |
| 200 |
{ |
| 201 |
\begingroup #1 \endgroup \@@over #2 |
| 202 |
} |
| 203 |
} { |
| 204 |
{ |
| 205 |
\Ustack { \group_begin: #1 \group_end: \@@over #2 } |
| 206 |
} |
| 207 |
} |
| 208 |
\__lltxmath_patch:cNnnn { genfrac~ } \cs_set:Npn { |
| 209 |
#1 #2 #3 #4 #5 #6 |
| 210 |
} { |
| 211 |
{ |
| 212 |
\@mathstyle { #4 } |
| 213 |
\genfrac@choice o { #1 } |
| 214 |
{ |
| 215 |
\begingroup #5 \endgroup |
| 216 |
\ifx @ #3 @ \@@over \else \@@above \fi #3 \relax |
| 217 |
#6 |
| 218 |
} |
| 219 |
\genfrac@choice c { #2 } |
| 220 |
} |
| 221 |
} { |
| 222 |
{ |
| 223 |
\@mathstyle { #4 } |
| 224 |
\genfrac@choice o { #1 } |
| 225 |
{ |
| 226 |
\Ustack { |
| 227 |
\group_begin: #5 \group_end: |
| 228 |
\tl_if_empty:nTF { #3 } { |
| 229 |
\@@over |
| 230 |
} { |
| 231 |
\@@above #3 \scan_stop: |
| 232 |
} |
| 233 |
#6 |
| 234 |
} |
| 235 |
} |
| 236 |
\genfrac@choice c { #2 } |
| 237 |
} |
| 238 |
} |
| 239 |
} |
| 240 |
} |
| 241 |
\__lltxmath_after_package_or_now:nn { mathtools } { |
| 242 |
\@ifpackagelater { mathtools } { 2021/03/28 } { } { |
| 243 |
\__lltxmath_patch:NNnnn \MT_cramped_internal:Nn |
| 244 |
\cs_set_nopar:Npn { #1 #2 } { |
| 245 |
\setbox \z@ \hbox { |
| 246 |
$ |
| 247 |
\m@th |
| 248 |
#1 |
| 249 |
\kern -\nulldelimiterspace |
| 250 |
\radical \z@ { #2 } |
| 251 |
$ |
| 252 |
} |
| 253 |
\ifx #1 \displaystyle |
| 254 |
\dimen@ = \fontdimen 8 \textfont 3 |
| 255 |
\advance \dimen@ .25 \fontdimen 5 \textfont 2 |
| 256 |
\else |
| 257 |
\dimen@ = 1.25 \fontdimen 8 |
| 258 |
\ifx #1 \textstyle |
| 259 |
\textfont |
| 260 |
\else |
| 261 |
\ifx #1 \scriptstyle |
| 262 |
\scriptfont |
| 263 |
\else |
| 264 |
\scriptscriptfont |
| 265 |
\fi |
| 266 |
\fi |
| 267 |
3 |
| 268 |
\fi |
| 269 |
\advance \dimen@ -\ht\z@ |
| 270 |
\ht\z@ = -\dimen@ |
| 271 |
\ifvmode \leavevmode \fi |
| 272 |
{ } |
| 273 |
\box\z@ |
| 274 |
} { |
| 275 |
{ |
| 276 |
\ensuremath { |
| 277 |
\use:c { cramped \cs_to_str:N #1 } #2 |
| 278 |
} |
| 279 |
} |
| 280 |
} |
| 281 |
} |
| 282 |
} |
| 283 |
\__lltxmath_after_package_or_now:nn { icomma } { |
| 284 |
\@ifl@t@r \fmtversion { 2020/10/01 } { |
| 285 |
\hook_gput_code:nnn { begindocument } { lualatex-math } { |
| 286 |
\__lltxmath_set_mathchar:NN \mathcomma \, |
| 287 |
\mathcode `\, = "8000 ~ |
| 288 |
} |
| 289 |
\hook_gset_rule:nnnn |
| 290 |
{ begindocument } { lualatex-math } { voids } { icomma } |
| 291 |
} { |
| 292 |
\tl_replace_once:Nnn \@begindocumenthook { |
| 293 |
\mathchardef \mathcomma \mathcode `\, |
| 294 |
} { |
| 295 |
\__lltxmath_set_mathchar:NN \mathcomma \, |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
\endinput |
| 300 |
%% |
| 301 |
%% End of file `lualatex-math.sty'. |