texlive[67671] Master/texmf-dist: lutabulartools (19jul23)

commits+karl at tug.org commits+karl at tug.org
Wed Jul 19 22:48:30 CEST 2023


Revision: 67671
          http://tug.org/svn/texlive?view=revision&revision=67671
Author:   karl
Date:     2023-07-19 22:48:30 +0200 (Wed, 19 Jul 2023)
Log Message:
-----------
lutabulartools (19jul23)

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	2023-07-19 20:48:21 UTC (rev 67670)
+++ trunk/Master/texmf-dist/doc/luatex/lutabulartools/lutabulartools.tex	2023-07-19 20:48:30 UTC (rev 67671)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2022-11-29
+% 2023-07-18
 % Copyright (C) 2021-2022 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -84,8 +84,6 @@
 
 \begin{document}
 
-%  todo: can improve naming... set col spec to a table instead of a string
-
 \maketitle
 
 \cmd{lutabulartools} is a package that contains a few useful Lua\LaTeX-based macros to help with tables.
@@ -169,7 +167,7 @@
 \cmd{\MC[+,2]}, if placed in the second column, occupies the second column to the end of the table and is two rows tall.\\
 In any of these examples, you can place the alignment letters anywhere.
 So, \cmd{\MC[l1,2b]} and \cmd{\MC[1,2 lb]} are both left-bottom aligned (spaces are ignored).\\
-Put an \cmd{_} as the last thing to add a \cmd{cmidrule} under, followed by a trim spec (the thing that goes in \cmd{()})
+Put an \cmd{_} as the last thing to add a \cmd{cmidrule} under, followed by a trim spec (the thing that goes in \cmd{cmidrule()})
 \cmd{\MC[+c_l]} will add a \cmd{cmidrule} underneath the cell (which fills until the end of the table), with the left side trimmed.
 
 \llcmd{[override mc]}%
@@ -344,18 +342,20 @@
 With this command, you can place a rule
 every X rows for the next table made (place command outside of table).
 You can configure the step size and what kind of midrule you prefer with the following key-val syntax, with default values below:\\
-\cmd{\midruleX{step=5,rule=midrule,cntr=0,head=0,long=false,longhead=0}}\\
-\cmd{step} is the number of rows (X) before applying the rule set by \cmd{rule}. \\
-Concering \cmd{longtable}s: If \cmd{long} is set to \cmd{true} (or the key is present),
-\cmd{\midruleX} will also add a unique \cmd{\label{}} on each row, and if the row starts on a newpage,
-resets the row counter to -1*\cmd{longhead}, to ensure you have the same X number of rows after the header of each page of a \cmd{longtable}.\\
+\cmd{\midruleX{step=5,rule=midrule,cntr=0,head=0,long=false}}\\
+\cmd{step} is the number of rows before applying the rule set by \cmd{rule}. \\
+
+Concerning \cmd{longtable}s: If \cmd{long} is set to \cmd{true} (or the key is present),
+\cmd{\midruleX} will also add a unique \cmd{\label{}} on each ro (to detect page changes), and if the row starts on a newpage,
+resets the row counter.
+
 Use optional parameter  \cmd{\midruleX*[o|n|f]{}}
 to control expansion of the key-val settings (\cmd{[n]} for not expanded is default).
 Before you want counting to begin, or anywhere in the table, you could
-apply \cmd{\resetmidruleX[cntr]} (\cmd{cnter} is incremented each row) to avoid header
-rows being counted and set the row \cmd{cntr} to an arbitrary value.
+apply \cmd{\resetmidruleX[cntr]} to an arbitrary value: \cmd{cntr} is normally incremented by 1 each row.
+You may want to avoid header rows being counted, or rows being underlined near the end of a table, for example.
 If you want to skip the first \cmd{x} rows with \cmd{\midruleX}, set \cmd{head=x} (which is equivalent to \cmd{cntr=-x}).
-If you want to add a \cmd{midrule} under row \cmd{x}, use \cmd{head*=x} instead.
+If you want to skip the auto-ruling at that ro \cmd{x} (say a gray one) and instead use a \cmd{midrule}, use \cmd{head*=x}.
 
 Note: Use \cmd{\noalign{\resetmiduleX}} if you need place a rule on the same line the reset takes place (ie. in a cell before \cmd{\\}).
 
@@ -421,8 +421,8 @@
 \end{verbatim}
 
 \midruleX{long=true,rule="\gcmidrules{1r,2-}"}
-\def\tblhead{\toprule No & Name & Place & other\\\midrule}
-\def\tblcontinued{\MC[+l]{Continued...}\\}
+\def\tblhead{\toprule No & Name & Place & other\\\\\midrule}
+\def\tblcontinued{\MC[+l]{...\\Continued...}\\\noalign{\resetmidruleX} } % reset added to avoid line in header
 \def\tblcontinues{\MC[+r]{...Continues}\\}
 \begin{longtable}{rclc}
   \tblhead\endfirsthead
@@ -429,7 +429,6 @@
   \tblcontinued\tblhead\endhead % all the lines above this will be repeated on every page
   \tblcontinues\endfoot
   \bottomrule End.\endlastfoot
-  \resetmidruleX
 1       &           &       &  \\
 2       &  \MC[_]{hi}         &       &    \\
 3       &           &       &    \\
@@ -451,31 +450,11 @@
 19      &           &       &    \\
 \end{longtable}
 
-%\begin{tabular}{ll}
-%  a \\
-%  b \\
-%  v \\
-%  d \\
-%  r \\
-%\end{tabular}
 
-Long table X example
+%Long table X example
+%\LTXtable{\linewidth}{ltxexample}
 
-\LTXtable{\linewidth}{ltxexample}
 
-%\luadirect{pl.help_wrt(lutabt.actlvl, 'actlevel')}
-%\luadirect{pl.help_wrt(lutabt.row_num, 'row')}
-%\lttdebugprt
 
-%\settabular{tbrule} % glitch with LTX
-%\midrulesat{1,2,3}
-%\begin{tabular}{ll}
-%  a \\
-%  b \\
-%  c \\
-%  d \\
-%  e \\
-%\end{tabular}
 
-
 \end{document}

Modified: trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua	2023-07-19 20:48:21 UTC (rev 67670)
+++ trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua	2023-07-19 20:48:30 UTC (rev 67671)
@@ -1,5 +1,5 @@
 --% Kale Ewasiuk (kalekje at gmail.com)
---% 2022-11-29
+--% 2023-07-18
 --% Copyright (C) 2021-2022 Kale Ewasiuk
 --%
 --% Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -25,7 +25,7 @@
 
 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 extrasglobals) option must be loaded before this package}{}')
+    tex.sprint('\\PackageError{lutabulartools}{penlight package with extras (or extrasglobals) option must be loaded before this package}{}')
     tex.print('\\stop')
 end
 local T = pl.tablex
@@ -93,7 +93,6 @@
 end
 
 function __lutabt__debugprtall()
-    --pl.help_wrt(pl.tablex.filter({ lutabt }, function(v) return type(v) ~= 'function' end), '(lutabulartools state)')
     pl.help_wrt(lutabt, '(lutabulartools state)')
 end
 
@@ -420,11 +419,11 @@
 -----
 
 lutabt.mrX = {}
-lutabt.mrX.resets = {long=false, longhead=0, cntr=0, head=nil, longx=false, on=true} -- settings that reset when \setmidruleX used
+lutabt.mrX.resets = {long=false, cntr=0, head=nil, longx=false, on=true} -- settings that reset when \setmidruleX used
 lutabt.mrX.resets['head*'] = nil
 lutabt.mrX.settings = T.update(T.copy(lutabt.mrX.resets), {pgcntr=0, step=5, rule='midrule'}) -- current settings, not overwritten with each call
+lutabt.mrX.settings.on = false
 
-
 function lutabt.mrX.reset_midruleX(n)
     lutabt.mrX.settings.cntr = tonumber(n)
 end
@@ -459,7 +458,7 @@
     lutabt.debugtalk(lutabt.mrX.settings, 'midruleX here')
     local s = lutabt.mrX.settings
     local rule = s.rule
-    if pl.hasval(s.long) and lutabt.mrX.add_label_and_check_page_change() then lutabt.mrX.settings.cntr = -1*s.longhead end -- reset to number on page change
+    if pl.hasval(s.long) and lutabt.mrX.add_label_and_check_page_change() then lutabt.mrX.settings.cntr = 0 end -- reset to number on page change --  longhead not used anymore
     lutabt.mrX.settings.cntr = lutabt.mrX.settings.cntr + 1
     if lutabt.mrX.settings.cntr == s.step then
         if not rule:startswith('\\') then  rule = '\\'..rule end -- todo consider allowing \gmidrule syntax, possible issue with expansion
@@ -498,45 +497,3 @@
 
 
 
-
---
---lutabt.tabular_row_pages_cntr = 0
---function lutabt.reset_midruleX_on_newpage(n)
---    local n = n or 0
---    lutabt.tabular_row_pages_cntr = lutabt.tabular_row_pages_cntr + 1
---    tex.print('\\noalign{\\label{tabular at row@'..lutabt.tabular_row_pages_cntr..'}}')
---    if lutabt.get_ref_page('tabular at row@'..lutabt.tabular_row_pages_cntr) -
---            lutabt.get_ref_page('tabular at row@'..(lutabt.tabular_row_pages_cntr-1)) == 1 then
---      tex.print('\\setcounter{midruleX}{'..n..'}')
---    end
---end
-
-
---help_wrt('TEST COL ')
---for _, s in ipairs{ 'll', '*{6}{s}', 'l*{6}{l}', 'lll', 'll[]', 'll[]*{6}{l}', '*{6}{l}', 'y*{6}{sq}x', } do
---    lutabt. set_col_spec(s)
---    help_wrt(lutabt.col_spec,s)
---end
-
-
--- todo move mrX mechanim to avoid @{}
---function lutabt.mrX.set_midruleX(new_sett, def)
---    def = def or ''
---    local curr_sett = {}
---    if def == pl.tex._xTrue then  -- default flag, if true, reset all non-used keys to default
---        curr_sett = lutabt.mrX.defaults
---    else
---        curr_sett = lutabt.mrX.settings
---    end
---    new_sett = luakeys.parse(new_sett)
---    lutabt.mrX.settings = T.union(curr_sett, new_sett)
---
---    lutabt.debugtalk(lutabt.mrX.settings, 'new midruleX settings')
---    lutabt.mrX.settings.cntr = tonumber(curr_sett.cntr) -- todo this needs to be a settings var
---    if new_sett.cntr ~= nil then -- todo fix the counter
---        lutabt.mrX.settings.cntr = tonumber(new_sett.cntr)
---    end
---    if new_sett.head ~= nil then -- todo fix the counter
---        lutabt.mrX.settings.cntr = -1*tonumber(new_sett.head)
---    end
---end

Modified: trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty
===================================================================
--- trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty	2023-07-19 20:48:21 UTC (rev 67670)
+++ trunk/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty	2023-07-19 20:48:30 UTC (rev 67671)
@@ -1,5 +1,5 @@
 % Kale Ewasiuk (kalekje at gmail.com)
-% 2022-11-29
+% 2023-07-18
 % Copyright (C) 2021-2022 Kale Ewasiuk
 %
 % Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -23,10 +23,11 @@
 % OR OTHER DEALINGS IN THE SOFTWARE.
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lutabulartools}[2022-11-29]
+\ProvidesPackage{lutabulartools}[2023-07-18]
 
 \RequirePackage{booktabs}
 \RequirePackage{multirow}
+\RequirePackage{longtable}
 \RequirePackage{makecell}
 \RequirePackage{xparse}
 \RequirePackage{array}
@@ -235,69 +236,3 @@
 \ProcessOptions
 
 
-
-
-
-
-
-%%%  OLD STUFF,
-%% before I had a fall-back for counting columns (just calculate current column on last column once)
-%%   and kept track of row numbers. I felt that this wasn't needed, so I've removed.
-%\newcommand{\TabColNum}{\luadirect{tex.print(lutabt.get_TabColNum())}} % prints the current column number of tabular
-%\newcommand{\NumTabCols}{\luadirect{tex.print(lutabt.NumTabCols)}} % prints the total num columns of tabular
-%\newcounter{RowNumCnt}
-%\setcounter{RowNumCnt}{1}
-%  \setcounter{RowNumCnt}{1}%
-%  \luadirect{lutabt.NumTabColsMX = 0}% fall back if calc doesnt work for some reason
-%  \setcounter{RowNumCnt}{1}%
-%  \luadirect{lutabt.NumTabColsMX = 0}% fall back if calc doesnt work for some reason
-%\DeclareOption{notrimx}{
-%  \global\newcolumntype{\lttltrim}{!{\stepcounter{RowNumCnt}}}
-%%  \global\newcolumntype{\lttrtrim}{!{\luadirect{lutabt.get_TabColNum()}}}
-%}
-%\DeclareOption{trimx}{
-%  \newcolumntype{\lttltrim}{@{\stepcounter{RowNumCnt}}}
-%%  \newcolumntype{\lttrtrim}{@{\luadirect{lutabt.get_TabColNum()}}}
-%}
-
-
-%% adapted from
-% https://tex.stackexchange.com/questions/182953/add-midrule-every-5-lines-automatically
-%% https://tex.stackexchange.com/questions/145084/what-is-the-function-of-noalign
-%
-%\def\midruleXstep{5}
-%\def\midruleXrule{\gmidrule}
-%
-%\newcounter{midruleX}
-%\newcommand*{\midruleXa}{%
-%  \aftergroup\aftergroup\aftergroup\midruleXaux
-%}
-%
-%\newif\ifmidruleX
-%
-%\newcommand*{\midruleXaux}{%
-%  \noalign{%
-%    \stepcounter{midruleX}%
-%    \ifnum\value{midruleX}=\midruleXstep %
-%      \global\midruleXtrue
-%      \resetmidruleX%
-%    \else
-%      \global\midruleXfalse
-%    \fi
-%  }
-%  \ifmidruleX\midruleXrule\fi
-%}
-
-%\newcommand*{\resetmidruleX}{\setcounter{midruleX}{0}}  %
-%\resetmidruleX
-
-%\NewDocumentCommand{\resetmidruleXonNP}{O{0}}{\luadirect{lutabt.reset_midruleX_on_newpage(\luastring{#1})}}
-
-%
-%\NewDocumentCommand{\IfmidruleX}{m m}{%  if a midruleX was placed, do #1, if not, do #2
-%  \ifnum\the\value{midruleX}=0
-%      #1
-%    \else
-%      #2
-%  \fi%
-%}
\ No newline at end of file



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