% \iffalse meta-comment/*%    \end{macrocode}*/
%
% Copyright (C) 2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
% ---------------------------------------------------------------------------
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% 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.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Sigitas Tolu\v{s}is.
%
% This work consists of the files stabular.dtx and stabular.ins
% and the derived filebase stabular.sty.
%
% \fi
%
% \iffalse
%<*internal>
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent\askforoverwritefalse
\preamble
%%
%% This is file `stabular.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% stabular.dtx  (with options: `package')
%% 
\endpreamble
\generate{\file{stabular.sty}{\from{stabular.dtx}{package}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{stabular.ins}{\from{stabular.dtx}{batchfile}}}
\endgroup
%</internal>
%<*driver>
\ProvidesFile{stabular.dtx}
%</driver>
%<*package>
%% Copyright (C) 1998-2021 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
%% UAB VTeX, Mokslininkų 2A, LT-08412 Vilnius, Lithuania
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% 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.
%%
%% PURPOSE:   Improve tabular environment.
%%
%</package>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{stabular}
%<*package>
    [2021/10/04 v2.1 Improve tabular environment]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{stabular}[2021/10/04]
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{stabular.dtx}
  %%\PrintChanges
  %%\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{239}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%
% \changes{v1.1}{2012/05/29}{Converted to DTX file}
% \changes{v1.2}{2014/01/13}{Fixed bug in the '@sarray' macro}
% \changes{v2.0}{2014/03/20}{Minimized code and extra functionality}
% \changes{v2.1}{2021/10/04}{Sync with array bugfix version for tabular}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{stabular.dtx}
% \title{The \textsf{stabular} package}
% \author{Sigitas Tolu\v{s}is \\ \url{sigitas@vtex.lt}}
% \date{\fileversion~from \filedate}
%
% \maketitle
%
% \section{Introduction}
%
% \textbf{Purpose}: improve tabular environment by allowing page break.
%
% \section{Usage}
%
% Just insert |\noalign{\eject}| after command |\\| to do a page break inside
% |stabular| environment.
%
% \DescribeMacro{stabular}
% \DescribeMacro{stabular*}
% Provides new environments: |stabular| and |stabular*|. 
% It is one more multi-page version of tabular.
%
% \subsection{Package options}
%
% \DescribeMacro{array}
%   \indent It is used to support tabular environment defined in array
%   package.
% 
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{stabular}[2014/03/20]
%    \end{macrocode}
%
%
%    \begin{macrocode}
\def\use@@pkg@@array@@variant{0}
\DeclareOption{array}{\def\use@@pkg@@array@@variant{1}}
\ProcessOptions*
%    \end{macrocode}
% 
%
% \begin{macro}{stabular}
%    \begin{macrocode}
\def\stabular{\let\@halignto\@empty\@stabular}
\def\endstabular{\crcr\egroup\egroup\egroup}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{stabular*}
%    \begin{macrocode}
\@namedef{stabular*}#1{%
  \setlength\dimen@{#1}%
  \edef\@halignto{to\the\dimen@}%
  \@tabular
  }
\expandafter\let\csname endstabular*\endcsname\endstabular
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@stabular}
%    \begin{macrocode}
\def\@stabular{\leavevmode 
  \bgroup 
    \let\@acol\@tabacol
    \let\@classz\@tabclassz
    \let\@classiv\@tabclassiv
    \let\\\@tabularcr
    \@stabarray
  }
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@stabarray}
%    \begin{macrocode}
\def\@stabarray{\m@th\@ifnextchar[\@sarray{\@sarray[c]}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@sarray}
%    \begin{macrocode}
\def\@sarray[#1]#2{%
  \bgroup
    \setbox\@arstrutbox\hbox{%
      \vrule \@height\arraystretch\ht\strutbox
             \@depth\arraystretch \dp\strutbox
             \@width\z@
             }%
  \@mkpream{#2}%
  \edef\@preamble{%
    \ialign \noexpand\@halignto
      \bgroup \@arstrut \@preamble \tabskip\z@skip \cr
    }%
  \let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
  \let\tabularnewline\\
  %%\let\par\@empty
  \let\@sharp##%
  \set@typeset@protect
  \lineskip\z@skip \baselineskip\z@skip
  \@preamble
  }
%    \end{macrocode}
% \end{macro}
%
% Definitions to provide |array| package support. 
%
%    \begin{macrocode}
\def\pkgarray@@sarray[#1]#2{%
  \@tempdima \ht \strutbox
  \advance \@tempdima by\extrarowheight
  \setbox \@arstrutbox \hbox{\vrule
             \@height \arraystretch \@tempdima
             \@depth \arraystretch \dp \strutbox
             \@width \z@}%
  \begingroup
    \@mkpream{#2}%
    \xdef\@preamble{\noexpand \ialign \@halignto
                    \bgroup \@arstrut \@preamble
                          \tabskip \z@ \cr}%
  \endgroup
  \@arrayleft
  \bgroup
    \let\@sharp##\let\protect\relax
    \lineskip\z@ \baselineskip\z@
    \m@th
    \let\\\@arraycr \let\tabularnewline\\
    %%\let\par\@empty 
    \@preamble
  }
\def\pkgarray@@stabarray{\@ifnextchar[{\pkgarray@@sarray}{\pkgarray@@sarray[c]}}
\def\pkgarray@stabular{\def\@halignto{}\pkgarray@@stabular}
\expandafter\def\csname pkgarray@stabular*\endcsname#1{%
       \setlength\dimen@{#1}%
       \edef\@halignto{to\the\dimen@}\pkgarray@@stabular}
\def\pkgarray@@stabular{%
  \leavevmode
  \bgroup 
    \col@sep\tabcolsep 
    \let\d@llarbegin\begingroup
    \let\d@llarend\endgroup
    \pkgarray@@stabarray
  }
\def\pkgarray@endstabular{\crcr\egroup\egroup\gdef\@preamble{}\egroup}
\expandafter\let\csname pkgarray@endstabular*\endcsname\pkgarray@endstabular
%    \end{macrocode}
%
%
%    \begin{macrocode} 
\ifcase\use@@pkg@@array@@variant
\else
  \@ifpackageloaded{array}{}{\RequirePackage{array}}%
  \let\stabular\pkgarray@stabular
  \expandafter\let\csname stabular*\expandafter\endcsname
    \csname pkgarray@stabular*\endcsname 
  \let\endstabular\pkgarray@endstabular
  \expandafter\let\csname endstabular*\expandafter\endcsname
    \csname pkgarray@endstabular*\endcsname 
\fi
%    \end{macrocode} 
%
% \iffalse
%</package>
% \fi
%
% \Finale
