%% $Id: xltabular.sty 602 2017-10-01 13:47:08Z herbert $
%%
%% This file is distributed under the terms of the LaTeX Project Public
%% License from CTAN archives in directory  macros/latex/base/lppl.txt.
%% Either version 1.3 or, at your option, any later version.
%%
% Copyright 2017 Herbert Voss <hvoss@tug.org>
%                Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
%%
\def\xltabular@version{0.03 }
\ProvidesPackage{xltabular}
          [2017/10/01 v\xltabular@version `xltabular' package (hv,rn)]

\RequirePackage{tabularx}
\let\ORIGi@tabularx=\tabularx
\let\ORIGi@endtabularx=\endtabularx
\let\ORIGi@TX@endtabularx=\TX@endtabularx
%
\RequirePackage{ltablex}
\let\ORIGii@tabularx=\tabularx
\let\ORIGii@TX@endtabularx=\TX@endtabularx
%
\let\ORIG@longtable=\longtable
\let\ORIG@LT@c@ption=\LT@c@ption
%
% restore original tabularx
\let\tabularx=\ORIGi@tabularx
\let\endtabularx=\ORIGi@endtabularx
\let\TX@endtabularx=\ORIGi@TX@endtabularx
%
% define a new tabularx like the one from "ltablex" 
%
\newenvironment{xltabular}[1][x]
  {\if l#1%
     \LTleft\z@ \LTright\fill
   \else\if r#1%
    \LTleft\fill \LTright\z@
   \else\if c#1%
    \LTleft\fill \LTright\fill
   \fi\fi\fi
   \let\TX@endtabularx=\ORIGii@TX@endtabularx
   \let\endtabularx\endxltabular
   \ORIGii@tabularx}
  {\def\@currenvir{tabularx}}
%
% In "longtable" increase the counter "table" only if "\caption" is used 

\def\LT@c@ption#1{%
  \noalign{%
    \ifx#1\@firstofone
      \refstepcounter{table}%
    \fi}%
  \ORIG@LT@c@ption{#1}%
} 
%
\def\longtable{%
  \addtocounter{table}\m@ne
  \ORIG@longtable
}  
%
\endinput
%%
%% End of file `xltabular.sty'.

