diff options
author | Karl Berry <karl@freefriends.org> | 2022-04-16 20:24:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-04-16 20:24:15 +0000 |
commit | cac8a949764a5646e8201c521340622219fa6748 (patch) | |
tree | 3f7047537aa5d2486dd48645e25f4e25adb895ee /Master/texmf-dist/tex/luatex | |
parent | d55468c2dfa6e5d2a697a4fd8fd1ad5eabdfb5a0 (diff) |
lutabulartools (16apr22)
git-svn-id: svn://tug.org/texlive/trunk@63043 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r-- | Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua | 36 | ||||
-rw-r--r-- | Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty | 8 |
2 files changed, 34 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua b/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua index 30165f89a97..fd783332a91 100644 --- a/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua +++ b/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.lua @@ -1,5 +1,5 @@ --% Kale Ewasiuk (kalekje@gmail.com) ---% 2022-02-27 +--% 2022-04-16 --% Copyright (C) 2021-2022 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,8 +22,23 @@ --% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE --% OR OTHER DEALINGS IN THE SOFTWARE. + +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}{}') +end + local ltt = {} + +ltt.debug = false +function ltt.debugtalk(s, ss) + ss = ss or '' + if ltt.debug then + pl.tex.help_wrt(s, ss..' (lutabulartools)') + end +end + ltt.col_spec1 = {} -- column spec if one column wide (since makcell nests a tabular, preserve col_spec below) ltt.col_spec = {} -- tab column spec if above 1 ltt.col = '' -- current column spec, single char, only applies to tabular with more than 1 column @@ -55,6 +70,7 @@ function ltt.set_col_num() ltt.col_num = 1 end ltt.col = ltt.col_spec[ltt.col_num] + ltt.debugtalk('col_num='..ltt.col_num..'; col_spec='..ltt.col,'set_col_num') end @@ -74,6 +90,7 @@ function ltt.set_col_spec(zz) else ltt.col_spec1 = _col_spec end + ltt.debugtalk(ltt.col_spec,'set_col_spec') end @@ -88,7 +105,7 @@ function ltt.MagicCell(s0,spec,mcspec,pre,content) ltt.set_col_num() -- register current column number and column spec local STR = '' - reset_bkt_cnt() + pl.tex.reset_bkt_cnt() local v, h, r, c, mrowsym, skipmakecell = ltt.parse_MagicCell_spec(spec) -- get v/h align, number rows/columns @@ -96,21 +113,23 @@ function ltt.MagicCell(s0,spec,mcspec,pre,content) h, mcspec, c = ltt.get_HColSpec(h, mcspec, c) -- infer horizontal alignment, num columns + 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 and c == '') then -- multicolumn cannot have {} around it STR = STR .. '{' -- multirow and makcell must have {} around it S column is used - add_bkt_cnt() + pl.tex.add_bkt_cnt() end if c ~= '' then STR = STR .. "\\multicolumn{"..c.."}{"..mcspec.."}{" - add_bkt_cnt() + pl.tex.add_bkt_cnt() end if r ~= '' then STR = STR .."\\multirow["..v.."]{"..r.."}{"..mrowsym.."}{" -- optional arg here - add_bkt_cnt() + pl.tex.add_bkt_cnt() end if not skipmakecell then @@ -119,14 +138,15 @@ function ltt.MagicCell(s0,spec,mcspec,pre,content) end STR = STR.."\\makecell[{"..v.."}{"..h.."}]{" - add_bkt_cnt() + pl.tex.add_bkt_cnt() else content = content:gsub('\\\\', '\\newline') end - STR = STR..content..close_bkt_cnt() + STR = STR..content..pl.tex.close_bkt_cnt() --Troubleshooting --help_wrt(STR..' <<< magic cell string') + ltt.debugtalk(STR,'MagicCell') tex.sprint(STR)--tex print the STR end @@ -252,6 +272,8 @@ function ltt.make1cmidrule(s, r, c, cmd) -- s=square r=round c=curly 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 diff --git a/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty b/Master/texmf-dist/tex/luatex/lutabulartools/lutabulartools.sty index bb72b660a8b..abeb1afdefb 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-02-27 +% 2022-04-16 % 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-02-27] +\ProvidesPackage{lutabulartools}[2022-04-16] \RequirePackage{booktabs} \RequirePackage{multirow} @@ -33,10 +33,12 @@ \RequirePackage{xcolor} \RequirePackage{colortbl} \RequirePackage{luacode} -\RequirePackage[pl,extras]{penlight} % NEEDED +\RequirePackage{penlight} % NEEDED, extras option must be used so penlight should be loaded before this... \luadirect{lutabt = require('lutabulartools')} +\newcommand{\lttdebugON}{\luadirect{lutabt.debug = true}} +\newcommand{\lttdebugOFF}{\luadirect{lutabt.debug = true}} \newcolumntype{\ltt@ltrim}{@{}} \newcolumntype{\ltt@rtrim}{@{}} |