summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/correctmathalign/tex/correctmathalign.sty
blob: 181f7123148d07955465e16453bd081ef6f66f26 (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
101
102
103
104
105
106
107
108
109
110
111
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{correctmathalign}
   [2017/04/04 v1.1 style file ``correctmathalign.sty''^^J
    by Yuwsuke Kieda]

\newif\if@fleqn \@fleqnfalse

\DeclareOption{latexorg}{\endinput}
\DeclareOption{fleqn}{\@fleqntrue}

\ProcessOptions

\if@fleqn
  \renewenvironment{eqnarray}{% fleqn.clo
    \stepcounter{equation}%
    \def\@currentlabel{\p@equation\theequation}%
    \global\@eqnswtrue\m@th
    \global\@eqcnt\z@
    \tabskip\mathindent
    \let\\=\@eqncr
    \setlength\abovedisplayskip{\topsep}%
    \ifvmode
      \addtolength\abovedisplayskip{\partopsep}%
    \fi
    \addtolength\abovedisplayskip{\parskip}%
    \setlength\belowdisplayskip{\abovedisplayskip}%
    \setlength\belowdisplayshortskip{\abovedisplayskip}%
    \setlength\abovedisplayshortskip{\abovedisplayskip}%
    $$\everycr{}\halign to\linewidth% $$
    \bgroup
      \hskip\@centering
      $\displaystyle\tabskip\z@skip{##}$\@eqnsel&%
      \global\@eqcnt\@ne\hfil$\displaystyle{{}##{}}$\hfil&%
      \global\@eqcnt\tw@$\displaystyle{##}$\hfil\tabskip\@centering&%
      \global\@eqcnt\thr@@\hb@xt@\z@\bgroup\hss##\egroup\tabskip\z@skip\cr}%
      {\@@eqncr
    \egroup
    \global\advance\c@equation\m@ne$$% $$
    \@ignoretrue
    }
\else
  \def\eqnarray{% latex.ltx
    \stepcounter{equation}%
    \def\@currentlabel{\p@equation\theequation}%
    \global\@eqnswtrue
    \m@th
    \global\@eqcnt\z@
    \tabskip\@centering
    \let\\\@eqncr
    $$\everycr{}\halign to\displaywidth\bgroup
        \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel
       &\global\@eqcnt\@ne\hfil$\displaystyle{{}##{}}$\hfil
       &\global\@eqcnt\tw@$\displaystyle{##}$\hfil\tabskip\@centering
       &\global\@eqcnt\thr@@\hb@xt@\z@\bgroup\hss##\egroup
          \tabskip\z@skip
       \cr
  }
\fi

\@ifpackageloaded{amsmath}{%
  \@ifpackagelater{amsmath}{2016/11/05}{\relax}{%
    \renewcommand{\start@aligned}[2]{%
      \RIfM@\else
          \nonmatherr@{\begin{\@currenvir}}%
      \fi
      \savecolumn@ % Assumption: called inside a group
      \null%
      \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{##}$%
              \tabskip\z@skip
             &\column@plus
              $\m@th\displaystyle{{}##}$%
              \hfil
              \tabskip\alignsep@
              \crcr
    }
    \renewenvironment{gathered}[1][c]{%
      \RIfM@\else
          \nonmatherr@{\begin{gathered}}%
      \fi
      \null%
      \if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi \bgroup
          \Let@ \chardef\dspbrk@context\@ne \restore@math@cr
          \spread@equation
          \ialign\bgroup
              \hfil\strut@$\m@th\displaystyle##$\hfil
              \crcr
    }{%
      \endaligned
    }%
  }
}{\relax}

\endinput