texlive[64780] Master/texmf-dist: lutabulartools (22oct22)

commits+karl at tug.org commits+karl at tug.org
Sat Oct 22 22:19:45 CEST 2022


Revision: 64780
          http://tug.org/svn/texlive?view=revision&revision=64780
Author:   karl
Date:     2022-10-22 22:19:45 +0200 (Sat, 22 Oct 2022)
Log Message:
-----------
lutabulartools (22oct22)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/luatex/lutabulartools/lutabulartools.pdf
    trunk/Master/texmf-dist/doc/luatex/lutabulartools/lutabulartools.tex
    trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua
    trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty

Modified: trunk/Master/texmf-dist/doc/luatex/lutabulartools/lutabulartools.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/luatex/lutabulartools/lutabulartools.tex
===================================================================
--- trunk/Master/texmf-dist/doc/luatex/lutabulartools/lutabulartools.tex	2022-10-22 20:19:19 UTC (rev 64779)
+++ trunk/Master/texmf-dist/doc/luatex/lutabulartools/lutabulartools.tex	2022-10-22 20:19:45 UTC (rev 64780)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2022-10-15
+% 2022-10-22
 % Copyright (C) 2021-2022 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -62,9 +62,12 @@
 \newcommand{\tMC}{\cmd{\\MC}}
 
 
+\usepackage{caption}
+
+\usepackage{ltxtable}
 \usepackage{longtable}
 
-\usepackage[pl,extrasnoglobals]{penlight}
+\usepackage[pl,extras]{penlight}
 
 
 \RequirePackage{lutabulartools}
@@ -78,6 +81,7 @@
 
 \usepackage{hyperref}
 
+
 \begin{document}
 
 %  todo: can improve naming... set col spec to a table instead of a string
@@ -85,10 +89,9 @@
 
 \maketitle
 
-lutabulartools is a package that contains a few useful macros to help with tables.
-Most functions require LuaLaTeX.
+lutabulartools is a package that contains a few useful Lua\LaTeX-based macros to help with tables.
 This package redefines the {\ttfamily tabular} and {\ttfamily tabular*} environments.
-The following packages are loaded:
+The following packages are loaded if not already, so if you have specific settings for these packages, load this package after:
 \texttt{
 {booktabs},
 {multirow},
@@ -186,7 +189,6 @@
 S is included by default.
 
 
-\newpage
 
 \subsection{Examples}
 
@@ -350,11 +352,14 @@
 resets the row counter to \cmd{resetnum}, to ensure you have the same X number of rows after the header of each page of a \cmd{longtable}.\\
 The starred version of first reverts the settings to default, then loads your inputted settings, which the non-starred
 version only overwrites the settings specified. \cmd{\setmidruleX*{}} will restore to default.
+Use optional parameter  \cmd{\setmidruleX*[o|n|f]{}}
+to control expansion of the key-val settings (\cmd{[n]} for not expanded is default).
 Before you want counting to begin, you should
 apply \cmd{\resetmidruleX}  to avoid header rows being counted.
 Use \cmd{\noalign{\resetmiduleX}} if you need place a rule on the same line the reset takes place, or in a cell before \cmd{\\}.
 Note that \cmd{\resetmidruleX} resets the row counter to 0, and is in effect, a short-cut for \cmd{\setmidruleX{}} or \cmd{\setmidruleX{cntr=0}}
 
+
 %
 %\begin{tabular}{l@{\luadirect{tex.print('\\midrule')}}}
 %  Hello \\
@@ -395,7 +400,7 @@
 
 Here's an example with long table. Notice the gray rules reliably appear 3 rows after each header.
 \begin{verbatim}
-\setmidruleX{reset=true,resetnum=0}
+\setmidruleX{reset=true,resetnum=0,rule="\gcmidrules{1r,2-}"}
 \def\tblhead{\toprule No & Name & Place & other\\\midrule}
 \def\tblcontinued{\MC[+l]{Continued...}\\}
 \def\tblcontinues\MC[+r]{...Continues}\\}
@@ -421,13 +426,13 @@
 14      &           &       &    \\
 15      &           &       &    \\\newpage
 16      &           &       &    \\
-17      &           &       &    \\\resetmidruleX
-18      &           &       &    \\
+17      &           &       &    \\
+18      &           &       &    \\\resetmidruleX
 19      &           &       &    \\
 \end{longtable}
 \end{verbatim}
 
-\setmidruleX{reset=true,resetnum=0}
+\setmidruleX{reset=true,resetnum=0,rule="\gcmidrules{1r,2-}"}
 \def\tblhead{\toprule No & Name & Place & other\\\midrule}
 \def\tblcontinued{\MC[+l]{Continued...}\\}
 \def\tblcontinues{\MC[+r]{...Continues}\\}
@@ -459,4 +464,7 @@
 \end{longtable}
 
 
+\LTXtable{\linewidth}{ltxexample}
+
+
 \end{document}

Modified: trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua	2022-10-22 20:19:19 UTC (rev 64779)
+++ trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua	2022-10-22 20:19:45 UTC (rev 64780)
@@ -1,5 +1,5 @@
 --% Kale Ewasiuk (kalekje at gmail.com)
---% 2022-10-15
+--% 2022-10-22
 --% Copyright (C) 2021-2022 Kale Ewasiuk
 --%
 --% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -25,7 +25,8 @@
 
 local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
 if (__PL_EXTRAS__ == nil) or  (__PENLIGHT__ == nil) then
-    tex.sprint('\\PackageError{yamlvars}{penlight package with extras (or extrasnoglobals) option must be loaded before this package}{}')
+    tex.sprint('\\PackageError{yamlvars}{penlight package with extras (or extrasglobals) option must be loaded before this package}{}')
+    tex.print('\\stop')
 end
 
 local ltt = {}
@@ -111,7 +112,7 @@
     ltt.debugtalk(pl.List{v, h, r, c, mcspec}:join'; ','v, h, r, c, mcspec')
 
     --help_wrt(_CurTabColAbv,'current column')
-    if s0 == _xTrue or (pl.List(ltt.SI_cols):contains(ltt.col) -- special columns for SI
+    if s0 == pl.tex._xTrue or (pl.List(ltt.SI_cols):contains(ltt.col) -- special columns for SI
             and c == '') then -- multicolumn cannot have {} around it
         STR = STR .. '{'                                       -- multirow and makcell must have {} around it S column is used
         pl.tex.add_bkt_cnt()
@@ -266,8 +267,6 @@
     end
     c = ltt.get_midrule_col(t[1])..'-'..ltt.get_midrule_col(t[2])
     cmd = cmd..'{'..c..'}'
-    --help_wrt(cmd)
-
     ltt.debugtalk(cmd,'make1cmidrule')
     tex.print(cmd)
 end
@@ -303,7 +302,7 @@
     end
     new_sett = luakeys.parse(new_sett)
     ltt.mrX.settings = T.union(curr_sett, new_sett)
-    ltt.debugtalk{ltt.mrX.settings, 'new settings'}
+    ltt.debugtalk(ltt.mrX.settings, 'new midruleX settings')
     ltt.mrX.cntr = curr_sett.cntr
 end
 
@@ -310,21 +309,27 @@
 function ltt.mrX.midruleX(n)
     n = n or '' -- todo placeholder for noalign ?
     local s = ltt.mrX.settings
+    local rule = s.rule
     if pl.hasval(s.reset) and ltt.mrX.add_label_and_check_page_change() then ltt.mrX.cntr = s.resetnum end
     ltt.mrX.cntr = ltt.mrX.cntr + 1
     if ltt.mrX.cntr == s.step then
-        ltt.debugtalk{s.rule, 'apply midruleX'}
-        tex.sprint('\\'..s.rule)
+        if not rule:startswith('\\') then  rule = '\\'..rule end -- todo consider allowing \gmidrule syntax, possible issue with expansion
+        ltt.debugtalk(rule, 'apply midruleX')
+        tex.sprint(rule)
         ltt.mrX.cntr = 0
     end
 end
 
 function ltt.mrX.add_label_and_check_page_change()
-   ltt.mrX.pgcntr = ltt.mrX.pgcntr + 1
+    ltt.mrX.pgcntr = ltt.mrX.pgcntr + 1
     tex.print('\\noalign{\\label{ltt at tabular@row@'..ltt.mrX.pgcntr..'}}')
-    local _, pgcurr = pl.tex.get_ref_info('ltt at tabular@row@'..ltt.mrX.pgcntr)
-    local _, pgprev = pl.tex.get_ref_info('ltt at tabular@row@'..ltt.mrX.pgcntr-1)
-    if  pgcurr ~= pgprev then
+    local rcurr = pl.tex.get_ref_info('ltt at tabular@row@'..ltt.mrX.pgcntr)
+    local rprev = pl.tex.get_ref_info('ltt at tabular@row@'..ltt.mrX.pgcntr-1)
+    --local rcurrc, _, _ = pl.tex.get_ref_info_all_cref('ltt at tabular@row@'..ltt.mrX.pgcntr)
+    ltt.debugtalk('curr: '..rcurr[2]..'   prev: '..rprev[2]..'   row: '..ltt.mrX.pgcntr, 'check midruleX page change')
+    ltt.debugtalk(rcurr, 'miduleX current reference info for row: '..ltt.mrX.pgcntr)
+    --ltt.debugtalk(rcurrc, 'miduleX current cleveref cref info')
+    if  rcurr[2] ~= rprev[2] then  -- pg no is second element
         return true
     end
     return false

Modified: trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty	2022-10-22 20:19:19 UTC (rev 64779)
+++ trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty	2022-10-22 20:19:45 UTC (rev 64780)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2022-10-15
+% 2022-10-22
 % 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-15]
+\ProvidesPackage{lutabulartools}[2022-10-22]
 
 \RequirePackage{booktabs}
 \RequirePackage{multirow}
@@ -53,7 +53,10 @@
 
 \def\midruleX{\aftergroup\aftergroup\aftergroup\midruleX at aux}
 \def\midruleX at aux{\luadirect{lutabt.mrX.midruleX('')}}  % todo argument for vadjust or noalign??
-\NewDocumentCommand{\setmidruleX}{s m}{\luadirect{lutabt.mrX.set_midruleX(\luastring{#2}, \luastring{#1})}}
+\NewDocumentCommand{\setmidruleX}{s O{N} m}{%
+  \MakeluastringCommands[N]{#2}%
+  \luadirect{lutabt.mrX.set_midruleX(\plluastringA{#3}, \luastring{#1})}%
+}
 \NewDocumentCommand{\midruleXreset}{O{0}}{\luadirect{lutabt.mrX.cntr = tonumber(\luastring{#1})}}
 \NewCommandCopy\resetmidruleX\midruleXreset
 
@@ -141,7 +144,7 @@
 
 
 \let\oldtabular\tabular
-\RenewExpandableDocumentCommand{\tabular}{ O{c} m }{%
+\RenewExpandableDocumentCommand{\tabular}{ O{l} m }{%
   \luadirect{lutabt.set_col_spec(\luastringN{#2})}%
   \oldtabular[#1]{\ltt at ltrim#2\ltt at rtrim}%
 }
@@ -148,7 +151,7 @@
 
 \expandafter\let\expandafter\oldtabulars\csname tabular*\endcsname
 \expandafter\let\expandafter\endoldtabulars\csname endtabular*\endcsname
-\RenewDocumentEnvironment{tabular*}{ m O{c} m }{%
+\RenewDocumentEnvironment{tabular*}{ m O{l} m }{%
   \luadirect{lutabt.set_col_spec(\luastringN{#3})}%
   \begin{oldtabulars}{#1}[#2]{\ltt at ltrim#3\ltt at rtrim}%
 }{%
@@ -156,7 +159,13 @@
 }
 %%% NOTE tabularx uses tabular*, NO NEED TO CHANGE TABULARX!
 
+\let\oldlongtable\longtable
+\RenewExpandableDocumentCommand{\longtable}{ O{l} m }{%
+  \luadirect{lutabt.set_col_spec(\luastringN{#2})}%
+  \oldlongtable[#1]{\ltt at ltrim#2\ltt at rtrim}%
+}
 
+
 %s0,spec,mcspec,pre,content
 % Magic Cell
 \NewExpandableDocumentCommand{\MC}{ s O{} D(){} D<>{} m }{%
@@ -184,8 +193,12 @@
   lutabt.SI_cols[\string##lutabt.SI_cols+1] = '#1'
 }}
 
+\NewDocumentCommand{\forcecolspec}{ m }{\luadirect{
+  lutabt.col_spec = (\luastring{#1}):totable()
+}}
 
 
+
 \ProcessOptions
 
 



More information about the tex-live-commits mailing list.