summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/xltabular/xltabular.sty
blob: a244ef7e17bcfca91c795aa7cc62664dde10aca9 (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
%%
%% 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 2018-2024 Herbert Voss    <hvoss@tug.org>
%                     Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
%%
\ProvidesPackage{xltabular}[2024/11/13 v0.2h `xltabular' package (hv,RN)]
\RequirePackage{tabularx}
\RequirePackage{etoolbox}
\let\XLT@i@tabularx=\tabularx
\let\XLT@i@endtabularx=\endtabularx
\let\XLT@i@TX@endtabularx=\TX@endtabularx
%
\RequirePackage{ltablex}
\keepXColumns% xltabular behaves like tabularx
%
\newif\ifXLT@normalPB \XLT@normalPBtrue
\newcommand*\normalLTpagebreak{\global\XLT@normalPBtrue}
\newcommand*\specialLTpagebreak{\global\XLT@normalPBfalse}
%
\let\XLT@ii@tabularx=\tabularx
\let\XLT@ii@TX@endtabularx=\TX@endtabularx
\let\XLT@longtable=\longtable
% prevents problematic behavior of longtable at page breaks (\XLT@normalPBfalse)
\patchcmd{\LT@start}{\vfil \break}{\ifXLT@normalPB \vfil \break \fi}{}{}
\patchcmd{\LT@start}{\penalty \z@}{\ifXLT@normalPB \penalty \z@ \fi}{}{}
\let\XLT@LT@start=\LT@start
\let\XLT@LT@array=\LT@array
\@ifundefined{scr@LT@array}{%
  \AtBeginDocument{%
    \@ifundefined{adl@LT@array}{}{\let\XLT@adl@LT@array=\adl@LT@array}
  }
}{\let\XLT@scr@LT@array=\scr@LT@array}%

%
% restore original tabularx
\renewenvironment{tabularx}%
{\let\TX@endtabularx=\XLT@i@TX@endtabularx\XLT@i@tabularx}
{\XLT@i@endtabularx}
%
% define a new tabularx like the one from "ltablex"
%
\newenvironment{xltabular}[1][x]%
{%
  \par
  \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=\XLT@ii@TX@endtabularx
  \let\endtabularx\endxltabular
  \XLT@ii@tabularx}
{\def\@currenvir{tabularx}}

\providecommand*\LTcaptype{table}% support of package "caption"
%\def\longtable{%
%  \ifXLT@HypRef
%    % revert to the unpatched version if \caption is not used
%    \global\let\LT@start=\XLT@LT@start
%  \fi
%  \XLT@longtable
%}

\endinput
%%
%% End of file `xltabular.sty'.