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