diff options
author | Karl Berry <karl@freefriends.org> | 2018-03-05 22:11:19 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-03-05 22:11:19 +0000 |
commit | bb7ef4b993327dd47fb8f1848e1603f93f12eb64 (patch) | |
tree | 444d575b3e1dfe4ab62a4e7a9f1a51bad8b2835c /Master/texmf-dist/tex | |
parent | 5be9113099c0cd49e0f0702753be415abdac12b0 (diff) |
tabstackengine (5mar18)
git-svn-id: svn://tug.org/texlive/trunk@46848 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty | 204 |
1 files changed, 193 insertions, 11 deletions
diff --git a/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty b/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty index 977bc1bca08..f559b7ab87b 100644 --- a/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty +++ b/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty @@ -1,4 +1,4 @@ -\def\tabstackengineversionnumber{V2.01} +\def\tabstackengineversionnumber{V2.10} % % THIS MATERIAL IS SUBJECT TO THE LaTeX Project Public License % @@ -34,8 +34,11 @@ % -\TABcell and \TABcellBox modified to remember recent use of % \ensureTABstackMath, which otherwise changes temporarily the % prevailing mode and style of the TABstack. +% V2.10 -Introduces \TABrule and [optionally] \TABcline{} +% -Allows tabbed nesting within other tabbed environments (achieved via +% replacing select \bgroup and \egroup with \ifnum brace hacks (TeXbook p.385) \ProvidesPackage{tabstackengine} -[2016/11/30 (\tabstackengineversionnumber) tabbed stacking] +[2018/03/05 (\tabstackengineversionnumber) tabbed stacking] \RequirePackage{stackengine}[2016-10-04] \RequirePackage{listofitems}[2016/11/18] \RequirePackage{etoolbox} @@ -48,6 +51,8 @@ \newtoks\TABcoltoks \newtoks\LstrutTABtoks \newtoks\RstrutTABtoks +\newtoks\TAB@toks +\newlength\TABruleshift \def\getTABcelltoks[#1,#2]{% \TABcelltoks=\expandafter\expandafter\expandafter{\TABcellRaw[#1,#2]}} @@ -68,7 +73,7 @@ \newcommand\setstackTAB[1]{\ifstrempty{#1}{\def\TAB@char{ }}{\def\TAB@char{#1}}} -\newcommand\readTABstack[1]{% +\newcommand\readTABstack@ORIG[1]{% \expandafter\expandafter\expandafter\setsepchar\expandafter\expandafter% \expandafter{\expandafter\SEP@char\expandafter/\TAB@char}% \greadlist*\TABcellRaw{#1}% @@ -106,7 +111,9 @@ \newcommand\TABstrut[1]{\ifnum#1<1\relax{}\else% \protect\rule[-\TABdp{#1}]{0pt}{\dimexpr\TABdp{#1}+\TABht{#1}\relax}\fi} -\newcommand\TABcell[2]{\stack@delim\recent@TAB@delim{\TABcellRaw[#1,#2]}\stack@delim} +\newcommand\TABcell[2]{% + \setTABrulecolumn{#2}% THIS LINE ADDED TO SET COLUMN FOR POSSIBLE \TABrule + \stack@delim\recent@TAB@delim{\TABcellRaw[#1,#2]}\stack@delim} \newcommand\TABcellBox[3][\relax]{\ifx\relax#1\relax% \TABcellBox@aux{\csuse{col#3TAB@stackalignment}}{#2}{#3}\else @@ -202,7 +209,8 @@ \newcommand\vertMatrixstack[2][\stackalignment]{% \ensureTABstackMath{\left|\@TAB@stack{#1}{#2}{D}{\Vectorstack}\right|}} -\newcommand\@TAB@stack[4]{\bgroup% +\newcommand\@TAB@stack[4]{{\ifnum`}=\z@\fi% + \set@TABrule@gap{#3}% \readTABstack{#2}% \edef\stackalignment{#1}% \setcounter{TABcolindex@}{0}% @@ -227,7 +235,7 @@ \expandafter#4\expandafter{\the\TABcoltoks}}}% {\expandafter#4\expandafter{\the\TABcoltoks}}% }% -\egroup} +\ifnum`{=\z@\fi}} \newcommand\tabbedstackon[3][\stackgap]{% \@TABstackonunder{#1}{#2}{#3}{D}{\stackon}} @@ -256,10 +264,14 @@ \newcommand\tabularstackanchor[4][\stackgap]{% \@TABstackonunder{#1}{#3}{#4}{#2}{\stackanchor}} -\newcommand\@TABstackonunder[5]{\bgroup% +\newcommand\@TABstackonunder[5]{{\ifnum`}=\z@\fi% + \set@TABrule@gap{#4}% \def\TAB@tmp{#2}% - \expandafter\g@addto@macro\expandafter\TAB@tmp\expandafter{\SEP@char#3}% - \readTABstack{\TAB@tmp}% + \ifnum\TAB@testcline#2\relax=0\relax + \expandafter\g@addto@macro\expandafter\TAB@tmp\expandafter{\SEP@char}% + \fi% + \g@addto@macro\TAB@tmp{#3}% + \expandafter\readTABstack\expandafter{\TAB@tmp}% \setcounter{TABcolindex@}{0}% \whileboolexpr{test {\ifnumless{\theTABcolindex@}{\TABstack@cols}}}{% COL LOOP \stepcounter{TABcolindex@}% @@ -275,7 +287,9 @@ {\TAB@delim{\TAB@strutL{1}\TABcellRaw[1,\theTABcolindex@]\TAB@strutR{1}}}% {\TAB@delim{\TAB@strutL{1}\TABcellRaw[2,\theTABcolindex@]\TAB@strutR{2}}}}% }% -\egroup} +\ifnum`{=\z@\fi}} + +\def\TAB@testcline#1#2\relax{\ifx\TABcline#1 1\else0\fi} \newcommand\@getTABalignment[2]{% \ifstrequal{#1}{D}{}{% T, DO NOTHING (USE \stackalignment) @@ -325,6 +339,160 @@ \newcommand\ensureTABstackMath[1]{% \let\sv@TABmode\TAB@delim\TABstackMath#1\let\TAB@delim\sv@TABmode} +%%% \TABrule + +\newcommand\TABrule[1][\TABruleshift]{% + \ifnum1=\value{TABcolindex@}\relax% + \makebox[\TABwd{\theTABcolindex@}][l]{% + \rule[\TABruleshift]{% + \dimexpr\TABwd{\theTABcolindex@}+.5\dimexpr\TAB@gap\relax}{\fboxrule}}% + \else% + \ifnum\TABcells{1}=\value{TABcolindex@}\relax% + \makebox[\TABwd{\theTABcolindex@}][r]{% + \rule[\TABruleshift]{% + \dimexpr\TABwd{\theTABcolindex@}+.5\dimexpr\TAB@gap\relax}{\fboxrule}}% + \else% + \makebox[\TABwd{\theTABcolindex@}][c]{% + \rule[\TABruleshift]{% + \dimexpr\TABwd{\theTABcolindex@}+1.\dimexpr\TAB@gap\relax}{\fboxrule}}% + \fi% + \fi% +} + +\newcommand\set@TABrule@gap[1]{% + \ifstrequal{#1}{D}{\gdef\TAB@gap{\tabbed@gap}}{% + \ifstrequal{#1}{A}{\gdef\TAB@gap{0pt}}{\gdef\TAB@gap{\tabular@gap}}% + }% +} + +\newcommand\setTABrulecolumn[1]{\setcounter{TABcolindex@}{#1}} + +%% \TABcline + +\newcommand\readTABstack@cline[1]{% + \expandafter\expandafter\expandafter\setsepchar\expandafter\expandafter% + \expandafter{\expandafter\SEP@char\expandafter/\TAB@char}% +% REMEMBER # COLUMNS IN ADVANCE + \greadlist*\TABcellRaw{#1}% + \edef\TABstack@cols{\listlen\TABcellRaw[1]}%[\TABstack@cols]% + \TAB@toks={}% + \setcounter{TABrowindex@}{0}% + \TAB@preread#1\relax\TABcline\relax\TAB@end% + \expandafter\expandafter\expandafter\setsepchar\expandafter\expandafter% + \expandafter{\expandafter\SEP@char\expandafter/\TAB@char}% +% THE FOLLOWING WILL FIX LINES ENDING IN EOL SEPARATOR (SHOULDN'T DO THAT!) + \pad@cols% +%% + \expandafter\greadlist\expandafter*\expandafter\TABcellRaw\expandafter{\the\TAB@toks}% + \edef\TABstack@rows{\TABcellRawlen}% + \def\maxTABwd{0pt}% + \setcounter{TABrowindex@}{0}% + \whileboolexpr{test {\ifnumless{\theTABrowindex@}{\TABstack@rows}}}{% ROW LOOP + \def\@accumulatedTAB{}% + \stepcounter{TABrowindex@}% + \setcounter{TABcolindex@}{0}% + \whileboolexpr{test {\ifnumless{\theTABcolindex@}{\TABstack@cols}}}{% COL LOOP + \stepcounter{TABcolindex@}% + \ifnum\value{TABrowindex@}=1\relax\csxdef{col\theTABcolindex@ TAB@wd}{0pt}\fi% + \getTABcelltoks[\theTABrowindex@,\theTABcolindex@]% + \expandafter\g@addto@macro\expandafter\@accumulatedTAB\expandafter{% + \the\TABcelltoks{}}% + \setbox0=\hbox{\stack@delim\TAB@delim{% + \TAB@strutL{0}\the\TABcelltoks\TAB@strutR{0}}\stack@delim}% + \ifdim\wd0>\csuse{col\theTABcolindex@ TAB@wd}\relax% + \csxdef{col\theTABcolindex@ TAB@wd}{\the\wd0}% + \ifdim\wd0>\maxTABwd\relax\xdef\maxTABwd{\the\wd0}\fi\fi% + \csxdef{col\theTABcolindex@ TAB@stackalignment}{c}% DEFAULT, LATER CHANGED + }% + \setbox0=\hbox{\stack@delim\TAB@delim{\@accumulatedTAB}\stack@delim}% + \csxdef{row\theTABrowindex@ TAB@ht}{\the\ht0}% + \csxdef{row\theTABrowindex@ TAB@dp}{\the\dp0}% + \global\let\recent@TAB@delim\TAB@delim% + }% +} + +\def\TAB@preread#1\TABcline#2#3\TAB@end{\TAB@toks=\expandafter{\the\TAB@toks#1}% + \stepcounter{TABrowindex@}% + \ifx\relax#2\relax% + \TAB@toks=\expandafter{\the\TAB@toks\unskip}% + \let\next\relax% + \else% + \discern@TABlines{#2}% + \setcounter{TABcolindex@}{0}% + \whileboolexpr{test {\ifnumless{\theTABcolindex@}{\TABline@colcount}}}{% COLUMN LOOP + \stepcounter{TABcolindex@}% + \ifnum\theTABcolindex@=1\relax\else% + \TAB@toks=\expandafter\expandafter\expandafter{% + \expandafter\the\expandafter\TAB@toks\TAB@char}% + \fi + \TAB@toks=\expandafter\expandafter\expandafter\expandafter\expandafter% + \expandafter\expandafter{\expandafter\expandafter\expandafter% + \the\expandafter\expandafter\expandafter\TAB@toks% + \csname TABline@[\theTABcolindex@]\endcsname}% + }% + \ifnum0=\TAB@testend#3\relax\relax% + \TAB@toks=\expandafter\expandafter\expandafter{% + \expandafter\the\expandafter\TAB@toks\SEP@char}% + \fi% + \def\next{\TAB@preread#3\TAB@end}% + \fi% + \next% +} + +\newcommand\discern@TABlines[1]{% + \setcounter{TABcolindex@}{0}% + \whileboolexpr{test {\ifnumless{\theTABcolindex@}{\TABstack@cols}}}{% COLUMN LOOP + \stepcounter{TABcolindex@}% + \expandafter\def\csname TABline@[\theTABcolindex@]\endcsname{\relax}% + }% + \setsepchar{,/-}% + \readlist\TABline@cols{#1}% + \def\TAB@endindex{0}% + \foreachitem\@TABindex\in\TABline@cols{% + \edef\TAB@startindex{\TABline@cols[\@TABindexcnt,1]}% + \ifnum\listlen\TABline@cols[\@TABindexcnt]=2\relax% + \edef\TAB@endindex{\TABline@cols[\@TABindexcnt,2]}% + \else + \edef\TAB@endindex{\TABline@cols[\@TABindexcnt,1]}% + \fi + \setcounter{TABcolindex@}{\numexpr\TAB@startindex-1\relax}% + \whileboolexpr{test {\ifnumless{\theTABcolindex@}{\TAB@endindex}}}{% COLUMN LOOP + \stepcounter{TABcolindex@}% + \expandafter\def\csname TABline@[\theTABcolindex@]\endcsname{% + \TABrule}% + }% + }% + \edef\TABline@colcount{\TABstack@cols}% +} + + +\def\TAB@testend#1#2\relax{\ifx\relax#1 1\else0\fi} + +\newcommand\relaxTABsyntax{% + \def\pad@cols{% + \setcounter{TABcolindex@}{1}% + \whileboolexpr{test {\ifnumless{\theTABcolindex@}{\TABstack@cols}}}{% COLUMN LOOP + \stepcounter{TABcolindex@}% + \TAB@toks=\expandafter\expandafter\expandafter{% + \expandafter\the\expandafter\TAB@toks\TAB@char}% + }% + }% +} + +\newcommand\@strictTABsyntax{\let\pad@cols\relax} + +\newcommand\TABcline@off{% + \def\TABcline##1{\ignorespaces}% + \let\readTABstack\readTABstack@ORIG% +} + +\newcommand\TABcline@on{% + \def\TABcline{}% + \let\readTABstack\readTABstack@cline% +} + +%% INITIALIZATIONS + \setstackEOL{\\}% DEFAULT ROW SEP \setstackTAB{&}% DEFAULT COL SEP \def\TAB@mathstyle{}% NOTHING ADDED TO DEFAULT TAB MATH STYLE @@ -335,5 +503,19 @@ \def\align@gap{1em}% DEFAULT ALIGN COL GAP \def\tabular@gap{\tabcolsep}% DEFAULT TABULAR COL GAP \fixTABwidth{F}% DEFAULT NON-FIXED WIDTH COLUMNS - +\setlength\TABruleshift{-0pt}% RELATIVE VERTICAL SHIFT OF \TABrule +\@strictTABsyntax% WITH \relaxTABsyntax, ADDS NCOL-1 COLUMN SEPARATORS TO END +% OF INPUT TOKEN LIST, TO AVOID ERROR ENDING INPUT WITH EOL. +% BASICALLY, ALLOWS BAD CODING STYLE WITH NEW \readTABstack + +% PROCESS PACKAGE OPTIONS +\newif\iftabstackengine@TABcline +\DeclareOption{TABcline}{\tabstackengine@TABclinetrue} +\ProcessOptions\relax +\iftabstackengine@TABcline% + \TABcline@on% ALLOW USE OF \TABcline +\else + \TABcline@off% DISALLOW USE OF \TABcline +\fi +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \endinput |