summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty')
-rw-r--r--Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty62
1 files changed, 42 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty b/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty
index f1dea60c5a7..1d2522b099d 100644
--- a/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty
+++ b/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty
@@ -1,5 +1,5 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2022-10-22
+% 2022-11-27
% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,7 +23,7 @@
% OR OTHER DEALINGS IN THE SOFTWARE.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lutabulartools}[2022-10-22]
+\ProvidesPackage{lutabulartools}[2022-11-27]
\RequirePackage{booktabs}
\RequirePackage{multirow}
@@ -40,13 +40,8 @@
\newcommand{\lttdebugON}{\luadirect{lutabt.debug = true}}
\newcommand{\lttdebugOFF}{\luadirect{lutabt.debug = true}}
-\newcolumntype{\ltt@ltrim}{@{}}
-\newcolumntype{\ltt@rtrim}{@{}}
-\DeclareOption{notrim}{
- \newcolumntype{\ltt@ltrim}{}
- \newcolumntype{\ltt@rtrim}{}
-}
-
+\newcolumntype{\lttltrim}{}
+\newcolumntype{\lttrtrim}{}
%%% midrule every X rows
@@ -143,40 +138,67 @@
+\NewDocumentCommand{\midrulesat}{m}{\luadirect{lutabt.add_auto_midrules(\luastring{#1})}}
+
+
+
+
+\NewDocumentCommand{\settabular}{s m}{\luadirect{lutabt.set_tabular(\luastring{#2})}} % make kv interface for auto
+
+\def\ltt@resetrownum{\luadirect{lutabt.reset_rows()}}
+\def\ltt@autotoprule{\luadirect{lutabt.process_auto_topbot_rule('top')}}
+\def\ltt@autobotrule{\luadirect{lutabt.process_auto_topbot_rule('bottom')}}
+
\let\oldtabular\tabular
+\let\oldendtabular\endtabular
\RenewExpandableDocumentCommand{\tabular}{ O{l} m }{%
\luadirect{lutabt.set_col_spec(\luastringN{#2})}%
- \oldtabular[#1]{\ltt@ltrim#2\ltt@rtrim}%
+ \oldtabular[#1]{\lttltrim#2\lttrtrim}\ltt@inctablelevel\ltt@resetrownum\ltt@autotoprule%
}
+\def\endtabular{\ltt@autobotrule\ltt@dectablelevel\oldendtabular}
+
+
+
\expandafter\let\expandafter\oldtabulars\csname tabular*\endcsname
\expandafter\let\expandafter\endoldtabulars\csname endtabular*\endcsname
\RenewDocumentEnvironment{tabular*}{ m O{l} m }{%
\luadirect{lutabt.set_col_spec(\luastringN{#3})}%
- \begin{oldtabulars}{#1}[#2]{\ltt@ltrim#3\ltt@rtrim}%
+ \begin{oldtabulars}{#1}[#2]{\lttltrim#3\lttrtrim}\ltt@inctablelevel\ltt@resetrownum\ltt@autotoprule%
}{%
- \end{oldtabulars}%
+ \ltt@autobotrule\ltt@dectablelevel\end{oldtabulars}%
}
%%% NOTE tabularx uses tabular*, NO NEED TO CHANGE TABULARX!
\let\oldlongtable\longtable
\RenewExpandableDocumentCommand{\longtable}{ O{l} m }{%
+ \luadirect{lutabt.auto_topbot_old = lutabt.auto_topbot
+ lutabt.auto_topbot = false}%
\luadirect{lutabt.set_col_spec(\luastringN{#2})}%
- \oldlongtable[#1]{\ltt@ltrim#2\ltt@rtrim}%
+ \oldlongtable[#1]{\lttltrim#2\lttrtrim}\ltt@inctablelevel\ltt@resetrownum%
}
+\let\oldendlongtable\endlongtable
+\def\endlongtable{\luadirect{lutabt.auto_topbot = lutabt.auto_topbot_old}
+ \ltt@dectablelevel\oldendlongtable}% restore status of auto topbot rule
+
+\apptocmd{\@arraycr}{\luadirect{lutabt.process_auto_rules()}}{}{}
+
+\def\ltt@inctablelevel{\luadirect{lutabt.tablelevel = lutabt.tablelevel + 1}}
+\def\ltt@dectablelevel{\luadirect{lutabt.tablelevel = lutabt.tablelevel - 1}}
%s0,spec,mcspec,pre,content
% Magic Cell
-\NewExpandableDocumentCommand{\MC}{ s O{} D(){} D<>{} m }{%
+\NewExpandableDocumentCommand{\MC}{ s O{} O{} D<>{} D(){x} m }{%
% Magic cell *wraps with {} but automatically checks for SI column,
- % [column spec] (mult-column spec override) <pre-cell stuff> {cell content}
+ % [column spec] [mult-column spec override] <pre-cell stuff> (add rule) {cell content}
\luadirect{lutabt.MagicCell(
\luastring{#1},
\luastring{#2},
\luastringN{#3},
\luastringN{#4},
- \luastringN{#5}
+ \luastringN{#6},
+ \luastring{#5}
)}}
@@ -219,12 +241,12 @@
% \setcounter{RowNumCnt}{1}%
% \luadirect{lutabt.NumTabColsMX = 0}% fall back if calc doesnt work for some reason
%\DeclareOption{notrimx}{
-% \global\newcolumntype{\ltt@ltrim}{!{\stepcounter{RowNumCnt}}}
-%% \global\newcolumntype{\ltt@rtrim}{!{\luadirect{lutabt.get_TabColNum()}}}
+% \global\newcolumntype{\lttltrim}{!{\stepcounter{RowNumCnt}}}
+%% \global\newcolumntype{\lttrtrim}{!{\luadirect{lutabt.get_TabColNum()}}}
%}
%\DeclareOption{trimx}{
-% \newcolumntype{\ltt@ltrim}{@{\stepcounter{RowNumCnt}}}
-%% \newcolumntype{\ltt@rtrim}{@{\luadirect{lutabt.get_TabColNum()}}}
+% \newcolumntype{\lttltrim}{@{\stepcounter{RowNumCnt}}}
+%% \newcolumntype{\lttrtrim}{@{\luadirect{lutabt.get_TabColNum()}}}
%}