| 1 |
%% |
| 2 |
%% This is file `xfrac.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% xfrac.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (C) 2004,2008-2010 Morten Hoegholm |
| 10 |
%% (C) 2011-2024 The LaTeX Project |
| 11 |
%% |
| 12 |
%% It may be distributed and/or modified under the conditions of |
| 13 |
%% the LaTeX Project Public License (LPPL), either version 1.3c of |
| 14 |
%% this license or (at your option) any later version. The latest |
| 15 |
%% version of this license is in the file: |
| 16 |
%% |
| 17 |
%% http://www.latex-project.org/lppl.txt |
| 18 |
%% |
| 19 |
%% This file is part of the "l3packages bundle" (The Work in LPPL) |
| 20 |
%% and all files in that bundle must be distributed together. |
| 21 |
%% |
| 22 |
%% File: xfrac.dtx |
| 23 |
\RequirePackage{amstext,graphicx} |
| 24 |
\@ifundefined{ExplLoaderFileDate} |
| 25 |
{\RequirePackage{expl3}} |
| 26 |
{} |
| 27 |
\@ifl@t@r\ExplLoaderFileDate{2018-02-21} |
| 28 |
{} |
| 29 |
{% |
| 30 |
\PackageError{xfrac}{Support package expl3 too old} |
| 31 |
{% |
| 32 |
You need to update your installation of 'l3kernel'.\MessageBreak |
| 33 |
Loading~xfrac~will~abort!% |
| 34 |
}% |
| 35 |
\endinput |
| 36 |
}% |
| 37 |
\ProvidesExplPackage{xfrac}{2024-06-04}{} |
| 38 |
{Split-level fractions} |
| 39 |
\providecommand \IfFormatAtLeastTF { \@ifl@t@r \fmtversion } |
| 40 |
\IfFormatAtLeastTF { 2020-02-02 } |
| 41 |
{ } |
| 42 |
{ \RequirePackage { textcomp } } |
| 43 |
\IfFormatAtLeastTF { 2020-10-01 } |
| 44 |
{ } |
| 45 |
{ \RequirePackage { xparse } } |
| 46 |
\keys_define:nn { xfrac } |
| 47 |
{ |
| 48 |
cm-recommended .choice:, |
| 49 |
cm-recommended / |
| 50 |
false .code:n = |
| 51 |
{ \bool_set_true:N \l__xfrac_cm_std_bool }, |
| 52 |
cm-recommended / |
| 53 |
true .code:n = |
| 54 |
{ \bool_set_false:N \l__xfrac_cm_std_bool }, |
| 55 |
cm-recommended .default:n = { true }, |
| 56 |
cm-standard .bool_set:N = \l__xfrac_cm_std_bool |
| 57 |
} |
| 58 |
\IfFormatAtLeastTF { 2022-06-01 } |
| 59 |
{ \ProcessKeyOptions } |
| 60 |
{ |
| 61 |
\RequirePackage { l3keys2e } |
| 62 |
\ProcessKeysOptions { xfrac } |
| 63 |
} |
| 64 |
\IfFormatAtLeastTF { 2024-06-01 } |
| 65 |
{ } |
| 66 |
{ \RequirePackage { xtemplate } } |
| 67 |
\cs_if_exist:NF \IfInstanceExistsTF |
| 68 |
{ \cs_new_eq:NN \IfInstanceExistsTF \IfInstanceExistTF } |
| 69 |
\box_new:N \l__xfrac_slash_box |
| 70 |
\box_new:N \l__xfrac_tmp_box |
| 71 |
\cs_new:Npn \__xfrac_tmp:w { } |
| 72 |
\dim_new:N \l__xfrac_denominator_bot_sep_dim |
| 73 |
\dim_new:N \l__xfrac_numerator_bot_sep_dim |
| 74 |
\dim_new:N \l__xfrac_numerator_top_sep_dim |
| 75 |
\dim_new:N \l__xfrac_slash_left_sep_dim |
| 76 |
\dim_new:N \l__xfrac_slash_right_sep_dim |
| 77 |
\muskip_new:N \l__xfrac_slash_left_muskip |
| 78 |
\muskip_new:N \l__xfrac_slash_right_muskip |
| 79 |
\fp_new:N \l__xfrac_hscale_fp |
| 80 |
\fp_new:N \l__xfrac_scale_factor_fp |
| 81 |
\fp_new:N \l__xfrac_vscale_fp |
| 82 |
\tl_new:N \l__xfrac_denominator_font_tl |
| 83 |
\tl_new:N \l__xfrac_numerator_font_tl |
| 84 |
\tl_new:N \l__xfrac_phantom_tl |
| 85 |
\tl_new:N \l__xfrac_slash_symbol_tl |
| 86 |
\tl_new:N \l__xfrac_slash_symbol_font_tl |
| 87 |
\cs_new:Npn \__xfrac_fontscale: { } |
| 88 |
\cs_new:Npn \__xfrac_math:n #1 { } |
| 89 |
\cs_new:Npn \__xfrac_denominator_font_change: { } |
| 90 |
\cs_new:Npn \__xfrac_denominator_format:n #1 { } |
| 91 |
\cs_new:Npn \__xfrac_numerator_font_change: { } |
| 92 |
\cs_new:Npn \__xfrac_numerator_format:n #1 { } |
| 93 |
\cs_new:Npn \__xfrac_relscale: { } |
| 94 |
\cs_new:Npn \__xfrac_slash_symbol_font_change: { } |
| 95 |
\cs_new:Npn \__xfrac_slash_symbol_format:n #1 { } |
| 96 |
\cs_new:Npn \__xfrac_text_or_math:n #1 { } |
| 97 |
\IfFormatAtLeastTF { 2024-06-01 } |
| 98 |
{ \NewTemplateType } |
| 99 |
{ \DeclareObjectType } |
| 100 |
{ xfrac } { 3 } |
| 101 |
\DeclareTemplateInterface { xfrac } { text } { 3 } |
| 102 |
{ |
| 103 |
denominator-bot-sep : length = \c_max_dim , |
| 104 |
denominator-font : tokenlist = \f@family , |
| 105 |
denominator-format : function 1 = #1 , |
| 106 |
h-scale : real = 1 , |
| 107 |
math-mode : choice { false , true } |
| 108 |
= false , |
| 109 |
numerator-font : tokenlist = \f@family , |
| 110 |
numerator-format : function 1 = #1 , |
| 111 |
numerator-bot-sep : length = \c_max_dim , |
| 112 |
numerator-top-sep : length = \c_max_dim , |
| 113 |
phantom : tokenlist = 8 , |
| 114 |
scale-factor : real = 0.83333 , |
| 115 |
scale-relative : choice { false , true } |
| 116 |
= true , |
| 117 |
scaling : choice { false , true } |
| 118 |
= true , |
| 119 |
slash-left-kern : length = 0 pt , |
| 120 |
slash-left-mkern : muskip = -2 mu , |
| 121 |
slash-right-kern : length = 0 pt , |
| 122 |
slash-right-mkern : muskip = -1 mu , |
| 123 |
slash-symbol : tokenlist = \textfractionsolidus , |
| 124 |
slash-symbol-font : tokenlist = \f@family , |
| 125 |
slash-symbol-format : function 1 = #1 , |
| 126 |
v-scale : real = 1 , |
| 127 |
} |
| 128 |
\DeclareTemplateCode { xfrac } { text } { 3 } |
| 129 |
{ |
| 130 |
denominator-bot-sep = \l__xfrac_denominator_bot_sep_dim , |
| 131 |
denominator-font = \l__xfrac_denominator_font_tl , |
| 132 |
denominator-format = \__xfrac_denominator_format:n , |
| 133 |
h-scale = \l__xfrac_hscale_fp , |
| 134 |
math-mode = |
| 135 |
{ |
| 136 |
false = \cs_set_eq:NN \__xfrac_math:n \use:n, |
| 137 |
true = \cs_set_eq:NN \__xfrac_math:n \ensuremath |
| 138 |
}, |
| 139 |
numerator-font = \l__xfrac_numerator_font_tl , |
| 140 |
numerator-format = \__xfrac_numerator_format:n , |
| 141 |
numerator-bot-sep = \l__xfrac_numerator_bot_sep_dim , |
| 142 |
numerator-top-sep = \l__xfrac_numerator_top_sep_dim , |
| 143 |
phantom = \l__xfrac_phantom_tl , |
| 144 |
scale-factor = \l__xfrac_scale_factor_fp , |
| 145 |
scale-relative = |
| 146 |
{ |
| 147 |
false = |
| 148 |
\cs_set:Npn \__xfrac_relscale: |
| 149 |
{ |
| 150 |
\dim_eval:n |
| 151 |
{ \box_ht:N \l__xfrac_tmp_box + \box_dp:N \l__xfrac_tmp_box } |
| 152 |
}, |
| 153 |
true = |
| 154 |
\cs_set:Npn \__xfrac_relscale: |
| 155 |
{ \dim_eval:n { \box_ht:N \l__xfrac_slash_box } } |
| 156 |
}, |
| 157 |
scaling = |
| 158 |
{ |
| 159 |
false = \cs_set_eq:NN \__xfrac_fontscale: \prg_do_nothing:, |
| 160 |
true = |
| 161 |
\cs_set:Npn \__xfrac_fontscale: |
| 162 |
{ |
| 163 |
\fontsize |
| 164 |
{ \fp_to_dim:n { \l__xfrac_scale_factor_fp * \__xfrac_relscale: } } |
| 165 |
{ \c_zero_dim } |
| 166 |
\selectfont |
| 167 |
} |
| 168 |
}, |
| 169 |
slash-left-kern = \l__xfrac_slash_left_sep_dim , |
| 170 |
slash-left-mkern = \l__xfrac_slash_left_muskip , |
| 171 |
slash-right-kern = \l__xfrac_slash_right_sep_dim , |
| 172 |
slash-right-mkern = \l__xfrac_slash_right_muskip , |
| 173 |
slash-symbol = \l__xfrac_slash_symbol_tl , |
| 174 |
slash-symbol-font = \l__xfrac_slash_symbol_font_tl , |
| 175 |
slash-symbol-format = \__xfrac_slash_symbol_format:n , |
| 176 |
v-scale = \l__xfrac_vscale_fp |
| 177 |
} |
| 178 |
{ |
| 179 |
\mode_if_math:TF |
| 180 |
{ |
| 181 |
\cs_set_eq:NN \__xfrac_text_or_math:n \text |
| 182 |
\cs_set:Npe \__xfrac_denominator_font_change: |
| 183 |
{ \tex_fam:D \l__xfrac_denominator_font_tl } |
| 184 |
\cs_set:Npe \__xfrac_numerator_font_change: |
| 185 |
{ \tex_fam:D \l__xfrac_numerator_font_tl } |
| 186 |
\cs_set:Npe \__xfrac_slash_symbol_font_change: |
| 187 |
{ \tex_fam:D \l__xfrac_slash_symbol_font_tl } |
| 188 |
} |
| 189 |
{ |
| 190 |
\cs_set_eq:NN \__xfrac_text_or_math:n \mbox |
| 191 |
\cs_set:Npn \__xfrac_denominator_font_change: |
| 192 |
{ |
| 193 |
\fontfamily { \l__xfrac_denominator_font_tl } |
| 194 |
\selectfont |
| 195 |
} |
| 196 |
\cs_set:Npn \__xfrac_numerator_font_change: |
| 197 |
{ |
| 198 |
\fontfamily { \l__xfrac_numerator_font_tl } |
| 199 |
\selectfont |
| 200 |
} |
| 201 |
\cs_set:Npn \__xfrac_slash_symbol_font_change: |
| 202 |
{ |
| 203 |
\fontfamily { \l__xfrac_slash_symbol_font_tl } |
| 204 |
\selectfont |
| 205 |
} |
| 206 |
} |
| 207 |
\__xfrac_text_or_math:n |
| 208 |
{ |
| 209 |
\m@th |
| 210 |
\hbox_set:Nn \l__xfrac_tmp_box |
| 211 |
{ \__xfrac_math:n { \vphantom { ( ) } } } |
| 212 |
\hbox_set:Nn \l__xfrac_slash_box |
| 213 |
{ |
| 214 |
\__xfrac_math:n |
| 215 |
{ |
| 216 |
\__xfrac_slash_symbol_format:n |
| 217 |
{ |
| 218 |
\__xfrac_math:n |
| 219 |
{ |
| 220 |
\__xfrac_slash_symbol_font_change: |
| 221 |
\IfNoValueTF {#2} |
| 222 |
{ \l__xfrac_slash_symbol_tl } {#2} |
| 223 |
} |
| 224 |
} |
| 225 |
} |
| 226 |
} |
| 227 |
\cs_set:Npn \__xfrac_tmp:w |
| 228 |
{ |
| 229 |
\raisebox |
| 230 |
{ |
| 231 |
\dim_eval:n |
| 232 |
{ |
| 233 |
\box_ht:N \l__xfrac_slash_box |
| 234 |
- \box_dp:N \l__xfrac_slash_box |
| 235 |
- \height |
| 236 |
} |
| 237 |
} |
| 238 |
} |
| 239 |
\dim_compare:nNnTF |
| 240 |
{ \l__xfrac_numerator_top_sep_dim } = { \c_max_dim } |
| 241 |
{ |
| 242 |
\dim_compare:nNnF |
| 243 |
{ \l__xfrac_numerator_bot_sep_dim } = { \c_max_dim } |
| 244 |
{ |
| 245 |
\cs_set:Npn \__xfrac_tmp:w |
| 246 |
{ |
| 247 |
\raisebox |
| 248 |
{ \dim_use:N \l__xfrac_numerator_bot_sep_dim } |
| 249 |
} |
| 250 |
} |
| 251 |
} |
| 252 |
{ |
| 253 |
\dim_compare:nNnTF |
| 254 |
{ \l__xfrac_numerator_bot_sep_dim } = { \c_max_dim } |
| 255 |
{ |
| 256 |
\cs_set:Npn \__xfrac_tmp:w |
| 257 |
{ |
| 258 |
\raisebox |
| 259 |
{ |
| 260 |
\dim_eval:n |
| 261 |
{ |
| 262 |
\box_ht:N \l__xfrac_slash_box |
| 263 |
- \dim_use:N \l__xfrac_numerator_top_sep_dim |
| 264 |
- \height |
| 265 |
} |
| 266 |
} |
| 267 |
} |
| 268 |
} |
| 269 |
{ |
| 270 |
\msg_error:nn { xfrac } |
| 271 |
{ over-specified-numerator-sep } |
| 272 |
} |
| 273 |
} |
| 274 |
\__xfrac_tmp:w |
| 275 |
{ |
| 276 |
\__xfrac_fontscale: |
| 277 |
\__xfrac_numerator_format:n |
| 278 |
{ |
| 279 |
\scalebox |
| 280 |
{ \fp_use:N \l__xfrac_hscale_fp } |
| 281 |
[ \fp_use:N \l__xfrac_vscale_fp ] |
| 282 |
{ |
| 283 |
\__xfrac_math:n |
| 284 |
{ |
| 285 |
\__xfrac_numerator_font_change: |
| 286 |
{ |
| 287 |
\vphantom { \l__xfrac_phantom_tl } |
| 288 |
#1 |
| 289 |
} |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
} |
| 294 |
\__xfrac_math:n |
| 295 |
{ % THIS IS JUST WRONG! |
| 296 |
\mode_if_math:TF |
| 297 |
{ \tex_mskip:D \l__xfrac_slash_right_muskip } |
| 298 |
{ \tex_hskip:D \l__xfrac_slash_right_sep_dim } |
| 299 |
} |
| 300 |
\box_use:N \l__xfrac_slash_box |
| 301 |
\__xfrac_math:n |
| 302 |
{ |
| 303 |
\mode_if_math:TF |
| 304 |
{ \tex_mskip:D \l__xfrac_slash_left_muskip } |
| 305 |
{ \tex_hskip:D \l__xfrac_slash_left_sep_dim } |
| 306 |
} |
| 307 |
\dim_compare:nNnTF |
| 308 |
{ \l__xfrac_denominator_bot_sep_dim } = { \c_max_dim } |
| 309 |
{ |
| 310 |
\cs_set:Npn \__xfrac_tmp:w |
| 311 |
{ \raisebox { - \box_dp:N \l__xfrac_slash_box } } |
| 312 |
} |
| 313 |
{ |
| 314 |
\cs_set:Npn \__xfrac_tmp:w |
| 315 |
{ |
| 316 |
\raisebox |
| 317 |
{ \dim_use:N \l__xfrac_denominator_bot_sep_dim } |
| 318 |
} |
| 319 |
} |
| 320 |
\__xfrac_tmp:w |
| 321 |
{ |
| 322 |
\__xfrac_fontscale: |
| 323 |
\__xfrac_denominator_format:n |
| 324 |
{ |
| 325 |
\scalebox |
| 326 |
{ \fp_use:N \l__xfrac_hscale_fp } |
| 327 |
[ \fp_use:N \l__xfrac_vscale_fp ] |
| 328 |
{ |
| 329 |
\__xfrac_math:n |
| 330 |
{ |
| 331 |
\__xfrac_denominator_font_change: |
| 332 |
{ |
| 333 |
\vphantom { \l__xfrac_phantom_tl } |
| 334 |
#3 |
| 335 |
} |
| 336 |
} |
| 337 |
} |
| 338 |
} |
| 339 |
} |
| 340 |
} |
| 341 |
} |
| 342 |
\IfFormatAtLeastTF { 2024-06-01 } |
| 343 |
{ |
| 344 |
\DeclareTemplateCopy { xfrac } { math } { text } |
| 345 |
\EditTemplateDefaults { xfrac } { math } |
| 346 |
} |
| 347 |
{ \DeclareRestrictedTemplate { xfrac } { text } { math } } |
| 348 |
{ |
| 349 |
numerator-font = \number \fam , |
| 350 |
slash-symbol = / , |
| 351 |
slash-symbol-font = \number \fam , |
| 352 |
denominator-font = \number \fam , |
| 353 |
scale-factor = 0.7 , |
| 354 |
scale-relative = false , |
| 355 |
scaling = true , |
| 356 |
denominator-bot-sep = 0 pt , |
| 357 |
math-mode = true , |
| 358 |
phantom = ( % ) |
| 359 |
} |
| 360 |
\DeclareInstance { xfrac } { default } { text } { } |
| 361 |
\DeclareInstance { xfrac } { mathdefault } { math } |
| 362 |
{ numerator-top-sep = 0pt } |
| 363 |
\DeclareInstance { xfrac } { cmr } { text } |
| 364 |
{ |
| 365 |
denominator-bot-sep = 0 pt , |
| 366 |
numerator-top-sep = 0.2 ex , |
| 367 |
slash-left-kern = -0.1 em , |
| 368 |
slash-right-kern = -0.1 em |
| 369 |
} |
| 370 |
\DeclareInstance { xfrac } { cmss } { text } |
| 371 |
{ |
| 372 |
denominator-bot-sep = 0 pt , |
| 373 |
numerator-top-sep = 0.2 ex , |
| 374 |
slash-left-kern = -0.1 em , |
| 375 |
slash-right-kern = -0.1 em |
| 376 |
} |
| 377 |
\DeclareInstance { xfrac } { cmtt } { text } |
| 378 |
{ |
| 379 |
denominator-bot-sep = 0 pt , |
| 380 |
numerator-top-sep = 0.2 ex , |
| 381 |
slash-left-kern = -0.1 em , |
| 382 |
slash-right-kern = -0.1 em |
| 383 |
} |
| 384 |
\bool_if:NF \l__xfrac_cm_std_bool |
| 385 |
{ |
| 386 |
\DeclareInstance { xfrac } { cmr } { text } |
| 387 |
{ slash-symbol-font = ptm } |
| 388 |
\DeclareInstance { xfrac } { cmss } { text } |
| 389 |
{ slash-symbol-font = ptm } |
| 390 |
\DeclareInstance { xfrac } { cmtt } { text } |
| 391 |
{ slash-symbol-font = ppl } |
| 392 |
} |
| 393 |
\DeclareInstance { xfrac } { lmr } { text } |
| 394 |
{ |
| 395 |
denominator-bot-sep = 0 pt , |
| 396 |
numerator-top-sep = 0.1 ex , |
| 397 |
slash-left-kern = -0.15 em , |
| 398 |
slash-right-kern = -0.15 em |
| 399 |
} |
| 400 |
\DeclareInstance { xfrac } { lmss } { text } |
| 401 |
{ |
| 402 |
denominator-bot-sep = 0 pt , |
| 403 |
numerator-top-sep = 0 pt , |
| 404 |
slash-left-kern = -0.15 em , |
| 405 |
slash-right-kern = -0.15 em |
| 406 |
} |
| 407 |
\DeclareInstance { xfrac } { lmtt } { text } |
| 408 |
{ |
| 409 |
denominator-bot-sep = 0 pt , |
| 410 |
numerator-top-sep = 0 pt , |
| 411 |
slash-left-kern = -0.15 em , |
| 412 |
slash-right-kern = -0.15 em |
| 413 |
} |
| 414 |
\NewDocumentCommand \sfrac { o m o m } |
| 415 |
{ |
| 416 |
\mode_if_math:TF |
| 417 |
{ |
| 418 |
\IfInstanceExistsTF { xfrac } { mathfam \number \fam } |
| 419 |
{ \UseInstance { xfrac } { mathfam \number \fam } } |
| 420 |
{ \UseInstance { xfrac } { mathdefault } } |
| 421 |
{#2} {#3} {#4} |
| 422 |
} |
| 423 |
{ |
| 424 |
\IfInstanceExistsTF { xfrac } {#1} |
| 425 |
{ \UseInstance { xfrac } {#1} } |
| 426 |
{ |
| 427 |
\IfInstanceExistsTF { xfrac } { \f@family } |
| 428 |
{ \UseInstance { xfrac } { \f@family } } |
| 429 |
{ \UseInstance { xfrac } { default } } |
| 430 |
} |
| 431 |
{#2} {#3} {#4} |
| 432 |
} |
| 433 |
} |
| 434 |
\msg_new:nnnn { xfrac } { over-specified-numerator-sep } |
| 435 |
{ You~have~specified~both~"numerator-top-sep"~and~"numerator-bot-sep". } |
| 436 |
{ I~will~pretend~that~you~didn't~specify~either~of~them. } |
| 437 |
%% |
| 438 |
%% |
| 439 |
%% End of file `xfrac.sty'. |