diff options
Diffstat (limited to 'macros/luatex/generic/lutabulartools/lutabulartools.lua')
-rw-r--r-- | macros/luatex/generic/lutabulartools/lutabulartools.lua | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.lua b/macros/luatex/generic/lutabulartools/lutabulartools.lua index 361530bc97..24c8d5598e 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.lua +++ b/macros/luatex/generic/lutabulartools/lutabulartools.lua @@ -1,5 +1,5 @@ --% Kale Ewasiuk (kalekje@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 @@ function ltt.MagicCell(s0,spec,mcspec,pre,content) 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 @@ function ltt.make1cmidrule(s, r, c, cmd) -- s=square r=round c=curly 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,28 +302,34 @@ function ltt.mrX.set_midruleX(new_sett, def) 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 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@tabular@row@'..ltt.mrX.pgcntr..'}}') - local _, pgcurr = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr) - local _, pgprev = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr-1) - if pgcurr ~= pgprev then + local rcurr = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr) + local rprev = pl.tex.get_ref_info('ltt@tabular@row@'..ltt.mrX.pgcntr-1) + --local rcurrc, _, _ = pl.tex.get_ref_info_all_cref('ltt@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 |