diff options
author | Norbert Preining <norbert@preining.info> | 2022-04-17 03:03:02 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-04-17 03:03:02 +0000 |
commit | e247b78b2fce9bdb26193826aca0a62ae26c8a8b (patch) | |
tree | 723e4d7093f616ab30d8a9a18f39b13b601002d6 /macros/luatex | |
parent | 86cbf2acabad1f9258b372dbf8f494f710ad64fd (diff) |
CTAN sync 202204170303
Diffstat (limited to 'macros/luatex')
16 files changed, 168 insertions, 61 deletions
diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.lua b/macros/luatex/generic/lutabulartools/lutabulartools.lua index 30165f89a9..fd783332a9 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-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/macros/luatex/generic/lutabulartools/lutabulartools.pdf b/macros/luatex/generic/lutabulartools/lutabulartools.pdf Binary files differindex 770fb8045b..bf53cad818 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.pdf +++ b/macros/luatex/generic/lutabulartools/lutabulartools.pdf diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.sty b/macros/luatex/generic/lutabulartools/lutabulartools.sty index bb72b660a8..abeb1afdef 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.sty +++ b/macros/luatex/generic/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}{@{}} diff --git a/macros/luatex/generic/lutabulartools/lutabulartools.tex b/macros/luatex/generic/lutabulartools/lutabulartools.tex index 54af32f78d..8a2b5f8569 100644 --- a/macros/luatex/generic/lutabulartools/lutabulartools.tex +++ b/macros/luatex/generic/lutabulartools/lutabulartools.tex @@ -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 @@ -57,6 +57,9 @@ \newcommand{\tMC}{\cmd{\\MC}} +\usepackage[pl,extrasnoglobals]{penlight} + + \RequirePackage{lutabulartools} \title{lutabulartools} \subtitle{some useful tabular tools (LuaLaTeX-based)} @@ -64,6 +67,8 @@ \usepackage{tabularx} \usepackage{siunitx} +\lttdebugON + \begin{document} % todo: can improve naming... set col spec to a table instead of a string @@ -99,6 +104,14 @@ you can manually fix it in a \cmd{tabular} with \cmd{!{}} like so: Xyz\\\bottomrule \end{tabular} \end{LTXexample} +\subsection{Debugging} +You can toggle log output debugging with \cmd{\lttdebugON} and \cmd{\lttdebugOFF}. +The messages will be printed in a format like so: +\begin{verbatim} +vvvvv msg1 (lutabulartools) +msg2 +^^^^^ +\end{verbatim} \section{\texttt{\textbackslash MC} -- Magic Cell} \texttt{\textbackslash MC} (magic cell) combines the facilities of diff --git a/macros/luatex/generic/penlight/penlight.pdf b/macros/luatex/generic/penlight/penlight.pdf Binary files differindex 3fcd22c54e..55eda4b6fe 100644 --- a/macros/luatex/generic/penlight/penlight.pdf +++ b/macros/luatex/generic/penlight/penlight.pdf diff --git a/macros/luatex/generic/penlight/penlight.sty b/macros/luatex/generic/penlight/penlight.sty index a73948af29..04cb66a482 100644 --- a/macros/luatex/generic/penlight/penlight.sty +++ b/macros/luatex/generic/penlight/penlight.sty @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-03-15 +% 2022-04-16 % Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,7 +22,7 @@ % OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE % OR OTHER DEALINGS IN THE SOFTWARE. -\ProvidesPackage{penlight}[2022-03-15] +\ProvidesPackage{penlight}[2022-04-16] \RequirePackage{luacode} @@ -65,7 +65,7 @@ end }}{ \luadirect{ __PDFmetadata__ = __PDFmetadata__ or {} - table.update(__PDFmetadata__, luakeys.parse(\luastring{#2}) + table.update(__PDFmetadata__, luakeys.parse(\luastring{#2})) writePDFmetadata() }} } diff --git a/macros/luatex/generic/penlight/penlight.tex b/macros/luatex/generic/penlight/penlight.tex index d70fc258f3..f1c07a00cb 100644 --- a/macros/luatex/generic/penlight/penlight.tex +++ b/macros/luatex/generic/penlight/penlight.tex @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-03-15 +% 2022-04-16 % Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/macros/luatex/generic/penlight/penlightextras.lua b/macros/luatex/generic/penlight/penlightextras.lua index e021567c13..253527cc52 100644 --- a/macros/luatex/generic/penlight/penlightextras.lua +++ b/macros/luatex/generic/penlight/penlightextras.lua @@ -1,5 +1,5 @@ --% Kale Ewasiuk (kalekje@gmail.com) ---% 2022-03-15 +--% 2022-04-16 --% Copyright (C) 2021-2022 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy @@ -30,6 +30,7 @@ __PL_EXTRAS__ = 1 -- requires penlight local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl +luakeys = require'luakeys' -- some bonus string operations, % text operator, and functional programming pl.stringx.import() diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.lua b/macros/luatex/latex/autopuncitems/autopuncitems.lua index 07b68e3ed4..4eabc5868d 100644 --- a/macros/luatex/latex/autopuncitems/autopuncitems.lua +++ b/macros/luatex/latex/autopuncitems/autopuncitems.lua @@ -1,5 +1,5 @@ --% Kale Ewasiuk (kalekje@gmail.com) ---% 2022-01-30 +--% 2022-04-16 --% Copyright (C) 2021-2022 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy @@ -110,4 +110,17 @@ function ap.go(s) return s end +function ap.gotab(s) + -- very simple, does not work if \\ in tabular, doesn't factor in header or footer + local s, c = s:gsub('%s*\\\\', '\0') + if c > 2 then + s = s:gsub('\0', ap.punc[0]..'\\\\', c-2) + end + if c > 1 then + s = s:gsub('\0', ap.punc[2]..'\\\\', 1) + end + s = s:gsub('\0', ap.punc[1]..'\\\\', 1) + return s +end + return ap
\ No newline at end of file diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.pdf b/macros/luatex/latex/autopuncitems/autopuncitems.pdf Binary files differindex c377b41f50..29b5f6d627 100644 --- a/macros/luatex/latex/autopuncitems/autopuncitems.pdf +++ b/macros/luatex/latex/autopuncitems/autopuncitems.pdf diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.sty b/macros/luatex/latex/autopuncitems/autopuncitems.sty index 11a4c66f69..e444adf0d5 100644 --- a/macros/luatex/latex/autopuncitems/autopuncitems.sty +++ b/macros/luatex/latex/autopuncitems/autopuncitems.sty @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-01-30 +% 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. -\ProvidesPackage{autopuncitems}[2022-01-30] +\ProvidesPackage{autopuncitems}[2022-04-16] \RequirePackage{luacode} \RequirePackage{etoolbox} @@ -68,3 +68,6 @@ after=\endAutoPuncItemsE, } } + +\NewDocumentEnvironment{AutoPuncTabular}{ +b }{\luadirect{tex.print(autopuncitems.gotab(\luastringN{#1}))}}{} % does not expand + diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.tex b/macros/luatex/latex/autopuncitems/autopuncitems.tex index e30c85e26f..89552c0db5 100644 --- a/macros/luatex/latex/autopuncitems/autopuncitems.tex +++ b/macros/luatex/latex/autopuncitems/autopuncitems.tex @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-01-30 +% 2022-04-16 % Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy @@ -208,24 +208,36 @@ If you disable auto-pass nested lists, and don't use \cmd{\APpass}, here is what \end{itemize} \end{LTXexample} -You may want to use the \cmd{AutoPuncItems} environment outside a list environment instead, -say perhaps if you're using the \cmd{beamer}. -Note that nested lists are normally not punctuated, and since the first-level list is inside the environment, it's considered nested. -If you would like to disable the prevention of auto-punctuating all nested lists, use the \cmd{\disableAPprotectnest}. -Note that nested lists will cause an error to occur. - +\subsection{Expanding list contents} \begin{LTXexample} -\disableAPprotectnest -\begin{AutoPuncItems} -\begin{itemize} +\def\listexample{ \item one \item two \item three \item four +} +--will work fine (expand once) +\begin{itemize}[autopuncO] + \listexample \end{itemize} -\end{AutoPuncItems} + +--will throw error + (author to fix this) +%\begin{itemize}[autopuncE] +% \listexample +%\end{itemize} + +--does not give desired result + (no items found) +\begin{itemize}[autopunc] + \listexample +\end{itemize} + \end{LTXexample} + +\subsection{Using the environment} + The normal way to use the environment should be inside the first list, like so. \begin{LTXexample} @@ -240,6 +252,27 @@ The normal way to use the environment should be inside the first list, like so. \end{itemize} \end{LTXexample} +You may want to use the \cmd{AutoPuncItems} environment outside a list environment instead, +say perhaps if you're using the \cmd{beamer}. +Note that nested lists are normally not punctuated, and since the first-level list is inside the environment, it's considered nested. +If you would like to disable the prevention of auto-punctuating all nested lists, use the \cmd{\disableAPprotectnest}. +Note that nested lists will cause an error to occur. + +\begin{LTXexample} +\disableAPprotectnest +\begin{AutoPuncItems} +\begin{itemize} + \item one + \item two + \item three + \item four +\end{itemize} +\end{AutoPuncItems} +\end{LTXexample} + + + + \end{document} diff --git a/macros/luatex/latex/yamlvars/yamlvars.lua b/macros/luatex/latex/yamlvars/yamlvars.lua index b485236d10..a46b47e725 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.lua +++ b/macros/luatex/latex/yamlvars/yamlvars.lua @@ -1,5 +1,5 @@ --% Kale Ewasiuk (kalekje@gmail.com) ---% 2022-03-15 +--% 2022-04-16 --% Copyright (C) 2021-2022 Kale Ewasiuk --% --% Permission is hereby granted, free of charge, to any person obtaining a copy @@ -92,6 +92,24 @@ function YAMLvars.pkgerr(m) end + + +-- todo need distinction beyyween table and penlight list ??? + --val = pl.array2d.map_slice1(_1..'\\\\', val, 1,-2) + --return val:join('') + --return pl.tablex.reduce(_1.._2, val, '') + +function YAMLvars.xfm.markdown(var, val) + --return '\\begin{markdown} '..val..'\n \\end{markdown}' + pl.tex.help_wrt(val, md) + return [[begin markdown ..val.. + + par end markdown]] +end + + + + -- xfm functions (transforms) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- function YAMLvars.xfm.addxspace(var, val) return val .. '\\xspace' @@ -106,15 +124,14 @@ function YAMLvars.xfm.arrsort2ZA(var, val) end function YAMLvars.xfm.addrule2arr(var, val) - return pl.array2d.map_slice2(_1..'\\\\\\'.. YAMLvars.tabmidrule..' ', val, 1,-1,-2,-1) -- todo make gmidrule + return pl.array2d.map_slice2(_1..'\\\\\\'.. YAMLvars.tabmidrule..' ', val, 1,-1,-2,-1) end function YAMLvars.xfm.arr2tabular(var, val) return pl.array2d.toTeX(val)..'\\\\' end - -function YAMLvars.xfm.list2items(var, val) -- todo should be list2item +function YAMLvars.xfm.list2items(var, val) return pl.List(val):map('\\item '.._1):join(' ') end YAMLvars.xfm.arr2itemize = YAMLvars.xfm.list2items @@ -140,7 +157,6 @@ function YAMLvars.xfm.arrsortlastnameAZ(var, val) return val end --- todo need distinction beyyween table and penlight list ??? function YAMLvars.xfm.list2nl(var, val) if type(val) == 'string' then return val @@ -155,29 +171,25 @@ function YAMLvars.xfm.list2and(var, val) -- for doc vars like author, publisher return pl.List(val):join('\\and ') end - --val = pl.array2d.map_slice1(_1..'\\\\', val, 1,-2) - --return val:join('') - --return pl.tablex.reduce(_1.._2, val, '') - -function YAMLvars.xfm.lb2nl(var, val) --linebreak in text 2 new line +function YAMLvars.xfm.lb2nl(var, val) --linebreak in text 2 newline \\ val, _ = val:gsub('\n','\\\\ ') return val end -function YAMLvars.xfm.lowercase(var, val) - return val:lower() +function YAMLvars.xfm.lb2newline(var, val) --linebreak in text 2 newline \\ + val, _ = val:gsub('\n','\\newline ') + return val end - -function YAMLvars.xfm.markdown(var, val) - --return '\\begin{markdown} '..val..'\n \\end{markdown}' - pl.tex.help_wrt(val, md) - return [[begin markdown ..val.. - - par end markdown]] +function YAMLvars.xfm.lb2par(var, val) --linebreak in text 2 new l + val, _ = val:gsub('\n%s*\n','\\par ') + return val end +function YAMLvars.xfm.lowercase(var, val) + return val:lower() +end -- dec laration functions, -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- @@ -211,7 +223,6 @@ function YAMLvars.prc.gdef(var, val) end function YAMLvars.prc.yvdef(var, val) - --token.set_macro('yv--'..var, val, 'global') -- todo fix with csname hack? pl.tex.defmacro('yv--'..var, val) YAMLvars.debugtalk('yv--'..var..' = '..val, 'prc yvdef') end @@ -236,13 +247,11 @@ end - function YAMLvars.prc.setATvar(var, val) -- set a @var directly: eg \gdef\@title{val} pl.tex.defcmdAT('@'..var, val) end - function YAMLvars.prc.setdocvar(var, val) -- call a document var \var{val} = \title{val} -- YAML syntax options -- k: v -> \k{v} @@ -264,10 +273,9 @@ function YAMLvars.prc.setdocvar(var, val) -- call a document var \var{val} = \ti end - function YAMLvars.prc.setPDFdata(var, val) - --update pdf metat data table - -- requires a table + --update pdf meta data table (via penlight), uses pdfx xmpdata + -- requires a table input for k, v in pairs(val) do if type(v) == 'table' then v = pl.List(v):join('\\sep ') @@ -276,9 +284,6 @@ function YAMLvars.prc.setPDFdata(var, val) end end - - - -- with hyperref package function YAMLvars.prc.PDFtitle(var, val) tex.print('\\hypersetup{pdftitle={'..val..'}}') @@ -288,6 +293,13 @@ function YAMLvars.prc.PDFauthor(var, val) tex.print('\\hypersetup{pdfauthor={'..val..'}}') end +-- -- + + +-- ?? +--token.set_macro('yv--'..var, val, 'global') -- todo fix with csname hack? + + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- diff --git a/macros/luatex/latex/yamlvars/yamlvars.pdf b/macros/luatex/latex/yamlvars/yamlvars.pdf Binary files differindex 6fc0c5ce7e..58f7899f5f 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.pdf +++ b/macros/luatex/latex/yamlvars/yamlvars.pdf diff --git a/macros/luatex/latex/yamlvars/yamlvars.sty b/macros/luatex/latex/yamlvars/yamlvars.sty index 852b0de8cc..92d5fbef2e 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.sty +++ b/macros/luatex/latex/yamlvars/yamlvars.sty @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-03-15 +% 2022-04-16 % Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy @@ -25,7 +25,7 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{YAMLvars}[2022-03-15] +\ProvidesPackage{YAMLvars}[2022-04-16] \IfFileExists{markdown-tinyyaml.lua}{}{\PackageError{YAMLvars}{This package requires installation of the 'markdown' package, please install it and try again}{}} diff --git a/macros/luatex/latex/yamlvars/yamlvars.tex b/macros/luatex/latex/yamlvars/yamlvars.tex index 344185dd5f..f6aa0893fb 100644 --- a/macros/luatex/latex/yamlvars/yamlvars.tex +++ b/macros/luatex/latex/yamlvars/yamlvars.tex @@ -1,5 +1,5 @@ % Kale Ewasiuk (kalekje@gmail.com) -% 2022-03-15 +% 2022-04-16 % Copyright (C) 2021-2022 Kale Ewasiuk % % Permission is hereby granted, free of charge, to any person obtaining a copy @@ -385,5 +385,13 @@ Items: Sunscreen: 5 Hat: 12 \end{verbatim} + + + +\clearpage +\section{xfm, dec, prc functions (from yamlvars.lua)} + +\lstinputlisting[linerange=113-296]{yamlvars.lua} + \end{document} |