| 1 |
%% |
| 2 |
%% This is file `luamathalign.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% luamathalign.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (C) 2019--2022 by Marcel Krueger |
| 10 |
%% |
| 11 |
%% This file may be distributed and/or modified under the |
| 12 |
%% conditions of the LaTeX Project Public License, either |
| 13 |
%% version 1.3c of this license or (at your option) any later |
| 14 |
%% version. The latest version of this license is in: |
| 15 |
%% |
| 16 |
%% http://www.latex-project.org/lppl.txt |
| 17 |
%% |
| 18 |
%% and version 1.3 or later is part of all distributions of |
| 19 |
%% LaTeX version 2005/12/01 or later. |
| 20 |
\NeedsTeXFormat{LaTeX2e} |
| 21 |
\ProvidesPackage |
| 22 |
{luamathalign} |
| 23 |
[2022-05-04 v0.3 additional math alignment tricks using Lua] |
| 24 |
\RequirePackage{iftex} |
| 25 |
\RequireLuaTeX |
| 26 |
\directlua{require'luamathalign'} |
| 27 |
\IfPackageLoadedTF{amsmath}{% |
| 28 |
\@firstofone |
| 29 |
}{% |
| 30 |
\AddToHook{package/amsmath/after} |
| 31 |
} |
| 32 |
{% |
| 33 |
\def\align@preamble{% |
| 34 |
&\hfil |
| 35 |
\strut@ |
| 36 |
\setboxz@h{\@lign$\m@th\displaystyle{% |
| 37 |
\LuaMathAlign@begin##\LuaMathAlign@end}$}% |
| 38 |
\ifmeasuring@\savefieldlength@\fi |
| 39 |
\set@field |
| 40 |
\tabskip\z@skip |
| 41 |
&\setboxz@h{\@lign$\m@th\displaystyle{{}##}$}% |
| 42 |
\ifmeasuring@\savefieldlength@\fi |
| 43 |
\set@field |
| 44 |
\hfil |
| 45 |
\tabskip\alignsep@ |
| 46 |
} |
| 47 |
\renewcommand{\start@aligned}[2]{% |
| 48 |
\RIfM@\else |
| 49 |
\nonmatherr@{\begin{\@currenvir}}% |
| 50 |
\fi |
| 51 |
\savecolumn@ % Assumption: called inside a group |
| 52 |
\alignedspace@left |
| 53 |
\if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi \bgroup |
| 54 |
\maxfields@#2\relax |
| 55 |
\ifnum\maxfields@>\m@ne |
| 56 |
\multiply\maxfields@\tw@ |
| 57 |
\let\math@cr@@@\math@cr@@@alignedat |
| 58 |
\alignsep@\z@skip |
| 59 |
\else |
| 60 |
\let\math@cr@@@\math@cr@@@aligned |
| 61 |
\alignsep@\minalignsep |
| 62 |
\fi |
| 63 |
\Let@ \chardef\dspbrk@context\@ne |
| 64 |
\default@tag |
| 65 |
\spread@equation % no-op if already called |
| 66 |
\global\column@\z@ |
| 67 |
\ialign\bgroup |
| 68 |
&\column@plus |
| 69 |
\hfil |
| 70 |
\strut@ |
| 71 |
$\m@th\displaystyle{\LuaMathAlign@begin##\LuaMathAlign@end}$% |
| 72 |
\tabskip\z@skip |
| 73 |
&\column@plus |
| 74 |
$\m@th\displaystyle{{}##}$% |
| 75 |
\hfil |
| 76 |
\tabskip\alignsep@ |
| 77 |
\crcr |
| 78 |
} |
| 79 |
\edef\math@cr@@@alignedat{\LuaMathAlign@end@early |
| 80 |
\unexpanded\expandafter{\math@cr@@@alignedat}} |
| 81 |
\edef\math@cr{\LuaMathAlign@end@early |
| 82 |
\unexpanded\expandafter{\math@cr}} |
| 83 |
\edef\endaligned{\LuaMathAlign@end@early |
| 84 |
\unexpanded\expandafter{\endaligned}} |
| 85 |
} |
| 86 |
\protected\def\AlignHere{\SetAlignmentPoint\m@ne} |
| 87 |
\begingroup |
| 88 |
\def\patch@finph@nt\setbox\tw@\null{% |
| 89 |
\LuaMathAlign@IsolateAlignmentPoints\z@ into \tw@ |
| 90 |
}% |
| 91 |
\expanded{\endgroup% |
| 92 |
\protected\def\noexpand\finph@nt{% |
| 93 |
\unexpanded\expandafter\expandafter\expandafter{% |
| 94 |
\expandafter\patch@finph@nt\finph@nt |
| 95 |
}% |
| 96 |
}} |
| 97 |
\ExplSyntaxOff |
| 98 |
\endinput |
| 99 |
%% |
| 100 |
%% End of file `luamathalign.sty'. |