diff options
author | Norbert Preining <preining@logic.at> | 2006-11-09 13:57:52 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2006-11-09 13:57:52 +0000 |
commit | 526c6d732015d94832a2c7fc3f4bc9a87cedf59c (patch) | |
tree | 0a7c4bdc5e3b7641304df22d8ce87240187c5e1b /Master/texmf-dist/tex | |
parent | c1a86fa11e01fbbdabf00c7116bc56b06bee98c3 (diff) |
polytable update
git-svn-id: svn://tug.org/texlive/trunk@2417 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/polytable/polytable.sty | 678 |
1 files changed, 426 insertions, 252 deletions
diff --git a/Master/texmf-dist/tex/latex/polytable/polytable.sty b/Master/texmf-dist/tex/latex/polytable/polytable.sty index 2072c64614d..d5b0685cedd 100644 --- a/Master/texmf-dist/tex/latex/polytable/polytable.sty +++ b/Master/texmf-dist/tex/latex/polytable/polytable.sty @@ -6,9 +6,10 @@ %% %% polytable.dtx (with options: `package') %% + \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{polytable}% - [2004/02/27 v0.7.2 `polytable' package (Andres Loeh)] + [2005/04/26 v0.8.2 `polytable' package (Andres Loeh)] \let\PT@original@And\And \RequirePackage{lazylist} \let\PT@And\And @@ -18,25 +19,74 @@ {\let\And\PT@original@And} \PT@postlazylist \RequirePackage{array} -\DeclareOption{debug}{\AtEndOfPackage\PT@debug} +\DeclareOption{debug} {\AtEndOfPackage\PT@debug} +\DeclareOption{info} {\AtEndOfPackage\PT@info} \DeclareOption{silent}{\AtEndOfPackage\PT@silent} -\ProcessOptions \newdimen\PT@colwidth \newcount\PT@cols \newcount\PT@table +\newtoks\PT@toks \newif\ifPT@changed +\newread\PT@in +\newwrite\PT@out \def\PT@allcols{\Nil} \let\PT@infromto\empty \let\PT@currentwidths\empty \def\PT@false{0} \def\PT@true{1} \let\PT@inrestore\PT@false -\def\PT@debug +\newcommand{\defaultcolumn}[1]{\gdef\PT@defaultcolumnspec{#1}} +\newcommand{\nodefaultcolumn}{\global\let\PT@defaultcolumnspec\undefined} +\DeclareOption{defaultcolumns}{\defaultcolumn{l}} +\newcommand{\memorytables}{% + \let\PT@preparewrite\@gobble + \let\PT@add \PT@addmem + \let\PT@prepareread \PT@preparereadmem + \let\PT@split \PT@splitmem + \let\PT@finalize \relax +} +\newcommand{\disktables}{% + \let\PT@preparewrite\PT@preparewritefile + \let\PT@add \PT@addfile + \let\PT@prepareread \PT@preparereadfile + \let\PT@split \PT@splitfile + \let\PT@finalize \PT@finalizefile +} +\DeclareOption{memory}{\AtEndOfPackage\memorytables} +\ProcessOptions +\newcommand*{\PT@debug} + {\def\PT@debug@ ##1{\typeout{(polytable) ##1}} + \PT@info} +\newcommand*{\PT@info} {\def\PT@typeout@ ##1{\typeout{(polytable) ##1}}} +\let\PT@debug@\@gobble \let\PT@typeout@\@gobble \def\PT@warning{\PackageWarning{polytable}}% \def\PT@silent {\let\PT@typeout@\@gobble\let\PT@warning\@gobble} +\def\PT@aligndim#1#2#3\@@{% + \ifnum#1=0 + \if #2p% + \PT@aligndim@0.0pt\space\space\space\space\space\@@ + \else + \PT@aligndim@#1#2#3\space\space\space\space\space\space\space\space\@@ + \fi + \else + \PT@aligndim@#1#2#3\space\space\space\space\space\space\space\space\@@ + \fi} + +\def\PT@aligndim@#1.#2#3#4#5#6#7#8#9\@@{% + \ifnum#1<10 \space\fi + \ifnum#1<100 \space\fi + \ifnum#1<\@m\space\fi + \ifnum#1<\@M\space\fi + #1.#2#3#4#5#6#7#8\space\space} + +\def\PT@aligncol#1{% + \PT@aligncol@#1\space\space\space\space\space\space\space\space\@@} + +\def\PT@aligncol@#1#2#3#4#5#6#7#8#9\@@{% + #1#2#3#4#5#6#7#8\space\space} \def\PT@rerun {\PT@typeout@{We have to rerun LaTeX ...}% \AtEndDocument @@ -52,104 +102,127 @@ \def\PT@consmacro{\PT@listopmacro\Cons} \def\PT@appendmacro{\PT@listopmacro\Cat} -\def\PT@addbeginmacro #1#2% add #2 to the beginning of #1 - {\def\PT@temp{#2}% - \expandafter\expandafter\expandafter - \def\expandafter\expandafter\expandafter - #1\expandafter\expandafter\expandafter - {\expandafter\PT@temp #1}} - \def\PT@gaddendmacro #1#2% add #2 to the end of #1 - {\expandafter\gdef\expandafter #1\expandafter{#1#2}} -\def\PT@enamedef #1#2% sets name #1 to the expansion of #2 - {\expandafter\Twiddle\expandafter\@namedef\expandafter{#2}{#1}} -\def\PT@adddeftomacroas#1#2#3% - {\expandafter\expandafter\expandafter - \def\expandafter\expandafter\expandafter\PT@temp - \expandafter\expandafter\expandafter - {\expandafter\expandafter\expandafter\def - \expandafter\expandafter\csname #2\endcsname - \expandafter{#3}}% - \expandafter\expandafter\expandafter\PT@gaddendmacro - \expandafter\expandafter\expandafter - {\expandafter\expandafter\csname #1\endcsname - \expandafter}\expandafter{\PT@temp}} -\def\PT@adddeftomacro#1#2% - {\def\PT@temp{\PT@adddeftomacroas{#1}{#2}}% - \expandafter\PT@temp\csname #2\endcsname} + {\PT@expanded{\gdef #1}{#1#2}} +\def\PT@expanded #1#2% + {\expandafter\Twiddle\expandafter\Identity\expandafter{#2}{#1}} +\def\PT@enamedef #1% sets name #1 to the expansion of #2 + {\PT@expanded{\@namedef{#1}}} \def\PT@addoptargtomacro {\PT@add@argtomacro\PT@makeoptarg} \def\PT@addargtomacro {\PT@add@argtomacro\PT@makearg} \def\PT@add@argtomacro#1#2#3% - {\expandafter\expandafter\expandafter\gdef - \expandafter\expandafter\expandafter\PT@temp - \expandafter\expandafter\expandafter{\csname #3\endcsname}% + {\PT@expanded{\PT@expanded{\gdef\PT@temp}}{\csname #3\endcsname}% #1% - \expandafter\PT@gaddendmacro\expandafter - {\expandafter#2\expandafter}\expandafter{\PT@temp}} + \PT@expanded{\PT@gaddendmacro{#2}}{\PT@temp}} \def\PT@makeoptarg% - {\expandafter\def\expandafter\PT@temp\expandafter - {\expandafter[\PT@temp]}} + {\PT@expanded{\def\PT@temp}{\expandafter[\PT@temp]}} \def\PT@makearg% - {\expandafter\def\expandafter\PT@temp\expandafter - {\expandafter{\PT@temp}}} - + {\PT@expanded{\def\PT@temp}{\expandafter{\PT@temp}}} \newcommand*{\PT@gobbleoptional}[1][]{\ignorespaces} -\let\PT@origomit\omit -\def\PT@disableomitonce - {\def\omit - {\let\omit\PT@origomit}} -\newcommand{\beginpolytable}% +\def\PT@addmem#1#2{\PT@gaddendmacro #2{\PT@elt{#1}}} +\def\PT@splitmem#1#2{#1\PT@nil{#2}{#1}} + +\def\PT@elt#1#2\PT@nil#3#4{\gdef #3{#1}\gdef #4{#2}} + +\def\PT@queuefilename{\jobname.ptb} + +\def\PT@addfile#1#2{% + \immediate\write #2{\string\def\string\PTtemp{#1}\string\empty}} + +\def\PT@splitfile#1#2{% + \ifeof #1% + \let #2=\empty + \else + \read #1 to#2% + %\show #2% + #2% hack, because it essentially ignores #2 + \PT@expanded{\def #2}{\PTtemp}% + %\show #2% + \fi} + + +\def\PT@preparereadmem#1#2{% + \global\let #1=#2} + +\def\PT@preparewritefile#1{% + \immediate\openout\PT@out\PT@queuefilename\relax + \let #1\PT@out} + +\def\PT@preparereadfile#1#2{% + \immediate\closeout\PT@out + \openin\PT@in\PT@queuefilename\relax + \let #1\PT@in} + +\def\PT@finalizefile{% + \closein\PT@in} + +\disktables +\newcommand*{\beginpolytable}% {\edef\PT@environment{\@currenvir}% \begingroup % new in v0.7: save counters \PT@savecounters - \toks@{}% initialise token register + \PT@toks{}% initialise token register \PT@scantoend} \let\endpolytable=\relax +\newcommand{\PT@scantoend}% LaTeX check \long\def\PT@scantoend #1\end #2% - {\toks@\expandafter{\the\toks@ #1}% + {\PT@toks\expandafter{\the\PT@toks #1}% \def\PT@temp{#2}% \ifx\PT@temp\PT@environment + \global\let\PT@columnqueue \empty + \global\let\PT@columnreference \undefined + \PT@preparewrite\PT@columnqueue \expandafter\PT@getwidths \else - \toks@\expandafter{\the\toks@\end{#2}}% + \PT@toks\expandafter{\the\PT@toks\end{#2}}% \expandafter\PT@scantoend \fi} \def\PT@getwidths - {\let\column\PT@firstrun@column - \let\savecolumns\PT@savewidths - \let\restorecolumns\PT@restorewidths - \column{@begin@}{@{}l@{}} + {\let\column \PT@firstrun@column + \let\savecolumns \PT@savewidths + \let\restorecolumns \PT@restorewidths + \column{@begin@}{@{}l@{}}% + \column{@end@}{}% \PT@cols=0\relax% - \let\fromto\PT@fromto - \let\nextline\PT@resetcolumn - \PT@changedfalse % nothing has changed so far + \let\fromto \PT@fromto + \let\PT@processentry \PT@checkwidth + \let\PT@scanbegin \PT@scanbeginfree + \let\\= \PT@resetcolumn + \let\nextline \PT@resetcolumn + \let\>= \PT@fromopt + \let\== \PT@from + \let\<= \PT@toopt + \global\PT@changedfalse % nothing has changed so far \PT@resetcolumn % we are at the beginning of a line - \the\toks@ + \the\PT@toks + \@ifundefined{PT@scanning}% + {}{\PT@resetcolumn\relax}% \ifx\column\PT@otherrun@column \else % we are in first run, print extra info - \PT@typeout@{Number of columns: \the\PT@cols}% \PT@prelazylist - \PT@typeout@{Column list: \Print\PT@allcols}% + \PT@typeout@{\PT@environment: \the\PT@cols\space columns, % + \PT@Print\PT@allcols}% \PT@postlazylist \fi - \let\PT@firstrun@column\PT@otherrun@column - \let\savecolumns\PT@gobbleoptional - \let\restorecolumns\PT@gobbleoptional - \let\PT@savewidths\PT@gobbleoptional - \let\PT@restorewidths\PT@gobbleoptional + \let\PT@firstrun@column \PT@otherrun@column + \let\savecolumns \PT@gobbleoptional + \let\restorecolumns \PT@gobbleoptional + \let\PT@savewidths \PT@gobbleoptional + \let\PT@restorewidths \PT@gobbleoptional \PT@restorecounters \ifPT@changed % we need to rerun if something has changed + \PT@typeout@{There were changes; another trial run needed.}% \expandafter\PT@getwidths \else % we are done and can do the sorting - \PT@typeout@{Reached fixpoint.}% + \PT@typeout@{There were no changes; reached fixpoint.}% \expandafter\PT@sortcols \fi} \def\PT@savecounters @@ -163,37 +236,128 @@ \edef\PT@sortedlist {\Foldr{\noexpand\Cons}{\noexpand\Nil}% {\Insertsort\PT@ltmax\PT@allcols}}% - \PT@typeout@{Sorted columns: \Print\PT@sortedlist}% + \PT@typeout@{Sorted columns:}% + \PT@PrintWidth\PT@sortedlist \PT@postlazylist \PT@cols=0\relax% \PT@prelazylist - \Execute{\Map\PT@numbercol\PT@sortedlist}% + \PT@Execute{\Map\PT@numbercol\PT@sortedlist}% \PT@postlazylist - \PT@typeout@{Numbered successfully, last column is \StripColumn\PT@lastcol}% + \edef\PT@lastcol@{\PT@StripColumn\PT@lastcol}% + \PT@typeout@{Numbered successfully, % + last column is \PT@lastcol@}% \ifx\PT@currentwidths\empty \else \PT@typeout@{Saving table information for \PT@currentwidths .}% - \expandafter\PT@saveinformation\expandafter{\PT@currentwidths}% + \PT@expanded\PT@saveinformation\PT@currentwidths \fi \PT@typeset} \def\PT@typeset {\PT@typeout@{Typesetting the table ...}% - \PT@prelazylist - \edef\PT@temp{@{}\Execute{\Map\PT@preamble\PT@sortedlist}}% - \PT@postlazylist - %\PT@typeout@{Preamble: \PT@temp}% - \let\fromto\PT@multicolumn + \let\PT@processentry \PT@placeinbox + \let\PT@scanbegin \PT@scanbeginwidth + \let\\= \PT@resetandcr + \let\nextline \PT@resetandcr + \PT@prepareread\PT@columnreference\PT@columnqueue + \let\@arraycr \PT@resetandcr \PT@resetcolumn % we are at the beginning of a line - \let\nextline=\PT@resetandcr - \expandafter\PT@begin\expandafter{\PT@temp}% - \the\toks@ + \PT@begin% + \the\PT@toks + \PT@fill% new in 0.7.3: balance the last line + \PT@finalize% finalize the queue (possibly close file) \PT@end \endgroup \PT@typeout@{Finished.}% \expandafter\end\expandafter{\PT@environment}}% +\newcommand{\PT@from}[1]% + {\PT@checkendentry{#1}\PT@dofrom{#1}} + +\newcommand{\PT@fromopt}[1][]% + {\def\PT@temp{#1}% + \ifx\PT@temp\empty + % set default column name + \def\PT@temp{\PT@currentcolumn .}% + \fi + \PT@expanded\PT@from\PT@temp} + +\newcommand{\PT@toopt}[1][]% + {\def\PT@temp{#1}% + \ifx\PT@temp\empty + % set default column name + \def\PT@temp{\PT@currentcolumn .}% + \fi + \PT@expanded\PT@checkendentry\PT@temp + \let\PT@scanning\undefined} +\newcommand*{\PT@dofrom}[1]% + {\edef\PT@currentcolumn{#1}% + \let\PT@scanning\PT@currentcolumn + \let\PT@currentpreamble\relax% necessary for preparescan + \@ifnextchar[%] + {\PT@expanded\PT@dospecfrom\PT@currentcolumn}% + {\PT@expanded\PT@dodofrom \PT@currentcolumn}} + +\newcommand*{\PT@dospecfrom}{}% LaTeX check +\def\PT@dospecfrom #1[#2]% + {\PT@checkglobalfrom #2\PT@nil{#1}% + \PT@dodofrom{#1}} + +\newcommand*{\PT@checkglobalfrom}{}% LaTeX check +\def\PT@checkglobalfrom + {\@ifnextchar!\PT@getglobalfrom\PT@ignorefrom} + +\newcommand*{\PT@getglobalfrom}{}% LaTeX check +\def\PT@getglobalfrom!#1\PT@nil#2% + {\column{#2}{#1}} + +\newcommand*{\PT@ignorefrom}{}% LaTeX check +\def\PT@ignorefrom #1\PT@nil#2% + {\def\PT@currentpreamble{#1}} + +\newcommand*{\PT@dodofrom}[1]% + {\@ifundefined{PT@columnreference}% + {% trial run + \ifx\column\PT@otherruncolumn + \else + % first run + \let\PT@storeendcolumn\PT@add + \fi + \def\PT@temp{@end@}}% + {% final run + \PT@split\PT@columnreference\PT@temp + %\PT@typeout@{splitted: \PT@temp} + }% + \PT@expanded{\PT@expanded\PT@preparescan\PT@currentcolumn}\PT@temp + \PT@scanbegin} + +\let\PT@storeendcolumn\@gobbletwo +\newcommand*{\PT@fromto}[3]% + {\PT@checkendentry{#1}% + \let\PT@scanning\undefined + \PT@infromto + \def\PT@infromto{% + \PackageError{polytable}{Nested fromto}{}}% + \let\PT@currentpreamble\relax% necessary for preparescan + \PT@preparescan{#1}{#2}% + \PT@scanbegin #3\PT@scanend% defines \@curfield + \PT@processentry{#1}{#2}% + \let\PT@infromto\empty + \ignorespaces} +\newcommand*{\PT@checkendentry}% takes one argument + {\@ifundefined{PT@scanning}% + {\let\PT@temp\@gobble}% + {\let\PT@temp\PT@endentry}% + \PT@temp} + + +\newcommand*{\PT@endentry}[1]% + {\PT@scanend + \edef\PT@temp{#1}% + \PT@expanded\PT@storeendcolumn\PT@temp\PT@columnqueue + \let\PT@storeendcolumn\@gobbletwo + \PT@expanded{\PT@expanded\PT@processentry\PT@currentcolumn}\PT@temp} \newcommand\PT@firstrun@column[3][0pt]% {\@ifundefined{PT@col@#2.type}% - {\PT@typeout@{Defining column #2 at #1.}% + {\PT@typeout@{Defining column \PT@aligncol{#2} at #1.}% \@namedef{PT@col@#2.type}{#3}% \@namedef{PT@col@#2.width}{#1}% initialize the width of the column % add the new column to the (sortable) list of all columns @@ -202,7 +366,14 @@ {\expandafter\ifx\csname PT@col@#2.type\endcsname\empty \relax % will be defined in a later table of the same set \else - \PT@warning{Redefining column #2}% + \begingroup + \def\PT@temp{PT@col@#2}% + \ifx\PT@temp\PT@endcol + \relax % end column is always redefined + \else + \PT@warning{Redefining column #2}% + \fi + \endgroup \fi \@namedef{PT@col@#2.type}{#3}% \expandafter\ifdim#1>0pt\relax @@ -218,22 +389,29 @@ {\ignorespaces} \def\PT@checkcoldefined #1% {\@ifundefined{PT@col@#1.type}% - {\PackageError{polytable}{Undefined column #1}{}}{}}% -\def\PT@fromto #1#2#3% - {\PT@infromto - \def\PT@infromto{% - \PackageError{polytable}{Nested fromto}{}}% - \PT@checkcoldefined{#1}% - \PT@checkcoldefined{#2}% + {\@ifundefined{PT@defaultcolumnspec}% + {\PackageError{polytable}{Undefined column #1}{}} + {\PT@debug@{Implicitly defining column #1}% + \PT@expanded{\column{#1}}{\PT@defaultcolumnspec}}}{}% + \expandafter\ifx\csname PT@col@#1.type\endcsname\empty\relax + \@ifundefined{PT@defaultcolumnspec}{}% + {\PT@debug@{Implicitly defining column #1}% + \PT@expanded{\column{#1}}{\PT@defaultcolumnspec}}% + \fi} +\def\PT@checkwidth #1#2% + {\PT@checkcoldefined{#2}% first column should have been checked before \def\PT@temp{PT@col@#1}% \ifx\PT@currentcol\PT@temp - \PT@typeout@{No need to skip columns.}% + \PT@debug@{No need to skip columns.}% \else \PT@colwidth=\expandafter\@nameuse\expandafter {\PT@currentcol.width}\relax \ifdim\PT@colwidth>\csname PT@col@#1.width\endcsname\relax % we need to change the width - \PT@typeout@{s #1: old=\@nameuse{PT@col@#1.width} new=\the\PT@colwidth}% + \PT@debug@{s \PT@aligncol{#1}: % + old=\expandafter\expandafter\expandafter + \PT@aligndim\csname PT@col@#1.width\endcsname\@@% + new=\expandafter\PT@aligndim\the\PT@colwidth\@@}% \PT@changedtrue \PT@enamedef{PT@col@#1.width}{\the\PT@colwidth}% \fi @@ -241,51 +419,31 @@ {\PT@currentcol.max}\relax \ifdim\PT@colwidth>\csname PT@col@#1.max\endcsname\relax % we need to change the width - \PT@typeout@{S #1: old=\@nameuse{PT@col@#1.max} new=\the\PT@colwidth}% + \PT@debug@{S \PT@aligncol{#1}: % + old=\expandafter\expandafter\expandafter + \PT@aligndim\csname PT@col@#1.max\endcsname\@@% + new=\expandafter\PT@aligndim\the\PT@colwidth\@@}% \PT@changedtrue \PT@checkrerun \PT@enamedef{PT@col@#1.max}{\the\PT@colwidth}% \fi \ifnum\csname PT@col@#1.trusted\endcsname=\PT@false\relax \ifdim\PT@colwidth=\csname PT@col@#1.max\endcsname\relax - \PT@typeout@{#1=\the\PT@colwidth\space is now trusted}% + \PT@debug@{#1=\the\PT@colwidth\space is now trusted}% \expandafter\let\csname PT@col@#1.trusted\endcsname\PT@true% \fi \fi \fi - \begingroup - \ifmmode - \let\d@llarbegin=$%$ - \let\d@llarend=$%$ - \let\col@sep=\arraycolsep - \else - \let\d@llarbegin=\begingroup - \let\d@llarend=\endgroup - \let\col@sep=\tabcolsep - \fi - %\def\PT@currentcol{PT@col@#1}% - %\ifx\PT@currentcol\PT@nullcol - %\else - % \PT@addbeginmacro\PT@currentpreamble{@{}}% - %\fi - \expandafter\expandafter\expandafter - \def\expandafter\expandafter\expandafter\PT@currentpreamble - \expandafter\expandafter\expandafter - {\csname PT@col@#1.type\endcsname}% - \setbox0=\hbox{% - \expandafter\@mkpream\expandafter{\PT@currentpreamble}% - \def\@sharp{\strut #3}% - %\show\@preamble - \@preamble}% - \expandafter\gdef\expandafter\PT@temp\expandafter{\the\wd0}% - \endgroup + \PT@expanded{\def\PT@temp}{\the\wd\@curfield}% \global\PT@colwidth=\@nameuse{PT@col@#1.width}% \global\advance\PT@colwidth by \PT@temp\relax% \ifdim\PT@colwidth>\csname PT@col@#2.width\endcsname\relax % we need to change the width - \PT@typeout@{c #2: - old=\@nameuse{PT@col@#2.width} - new=\the\PT@colwidth}% + \PT@debug@{#2 (width \PT@temp) starts after #1 (at \csname PT@col@#1.width\endcsname)}% + \PT@debug@{c \PT@aligncol{#2}: % + old=\expandafter\expandafter\expandafter + \PT@aligndim\csname PT@col@#2.width\endcsname\@@% + new=\expandafter\PT@aligndim\the\PT@colwidth\@@}% \PT@changedtrue \PT@enamedef{PT@col@#2.width}{\the\PT@colwidth}% \fi @@ -293,41 +451,53 @@ \global\advance\PT@colwidth by \PT@temp\relax% \ifdim\PT@colwidth>\csname PT@col@#2.max\endcsname\relax % we need to change the width - \PT@typeout@{C #2: - old=\@nameuse{PT@col@#2.max} - new=\the\PT@colwidth}% + \PT@debug@{C \PT@aligncol{#2}: % + old=\expandafter\expandafter\expandafter + \PT@aligndim\csname PT@col@#2.max\endcsname\@@% + new=\expandafter\PT@aligndim\the\PT@colwidth\@@}% \PT@changedtrue \PT@checkrerun \PT@enamedef{PT@col@#2.max}{\the\PT@colwidth}% \fi \ifnum\csname PT@col@#2.trusted\endcsname=\PT@false\relax \ifdim\PT@colwidth=\csname PT@col@#2.max\endcsname\relax - \PT@typeout@{#2=\the\PT@colwidth\space is now trusted}% + \PT@debug@{#2=\the\PT@colwidth\space is now trusted}% \expandafter\let\csname PT@col@#2.trusted\endcsname\PT@true% \fi \fi - \def\PT@currentcol{PT@col@#2}% - \let\PT@infromto\empty - \ignorespaces}% + \def\PT@currentcol{PT@col@#2}} \def\PT@checkrerun {\ifnum\PT@inrestore=\PT@true\relax \PT@rerun \fi} \newcommand*{\PT@resetcolumn}[1][]% - {\let\PT@currentcol\PT@nullcol} -\def\PT@nullcol - {PT@col@@begin@} -\def\Execute{\Foldr\Sequence\empty} -\def\Sequence #1#2{#1#2} -\def\ShowColumn #1% - {\ShowColumn@#1\ShowColumn@} -\def\ShowColumn@ PT@col@#1\ShowColumn@ - {#1 } -\def\StripColumn #1% - {\expandafter\StripColumn@#1\StripColumn@} -\def\StripColumn@ PT@col@#1\StripColumn@ + {\PT@checkendentry{@end@}% + \let\PT@currentcolumn\empty% + \let\PT@scanning\undefined + \let\PT@currentcol\PT@nullcol + % TODO: remove these lines if they don't work + %\let\PT@pre@preamble\empty + %\PT@scanbeginfree + } +\def\PT@nullcol{PT@col@@begin@} +\def\PT@endcol{PT@col@@end@} +\def\PT@Execute{\Foldr\PT@Sequence\empty} +\def\PT@Sequence #1#2{#1#2} +\def\PT@ShowColumn #1#2% + {\PT@ShowColumn@{#1}#2\PT@ShowColumn@} +\def\PT@ShowColumn@ #1PT@col@#2\PT@ShowColumn@ + {#1{#2} } +\def\PT@ShowColumnWidth #1% + {\PT@typeout@{% + \PT@ShowColumn\PT@aligncol{#1}: + \expandafter\expandafter\expandafter + \PT@aligndim\csname #1.max\endcsname\@@}} +\def\PT@StripColumn #1% + {\expandafter\PT@StripColumn@#1\PT@StripColumn@} +\def\PT@StripColumn@ PT@col@#1\PT@StripColumn@ {#1} -\def\Print#1{\Execute{\Map\ShowColumn#1}} +\def\PT@Print#1{\PT@Execute{\Map{\PT@ShowColumn\Identity}#1}} +\def\PT@PrintWidth#1{\PT@Execute{\Map\PT@ShowColumnWidth#1}} \def\PT@TeXif #1% {\expandafter\@gobble#1\relax \PT@gobblefalse @@ -343,115 +513,107 @@ \PT@enamedef{#1.num}{\the\PT@cols}% \def\PT@lastcol{#1}% \advance\PT@cols by 1\relax} -\def\PT@preamble #1% - {l@{}} -\newcommand{\PT@resetandcr}[1][0pt]% - {\ifx\PT@currentcol\PT@lastcol +\newcommand{\PT@resetandcr}% + {\PT@expanded\PT@checkendentry\PT@lastcol@% + \ifx\PT@currentcol\PT@lastcol \else \ifx\PT@currentcol\PT@nullcol \edef\PT@currentcol{\Head{\Tail\PT@sortedlist}}% \fi - \edef\PT@currentcol@{\StripColumn\PT@currentcol}% - \edef\PT@lastcol@ - {\StripColumn\PT@lastcol}% - \PT@typeout@{adding implicit fromto from \PT@currentcol@ - \space to \PT@lastcol@}% - \expandafter\expandafter\expandafter\fromto - \expandafter\expandafter\expandafter{% - \expandafter\expandafter\expandafter\PT@currentcol@ - \expandafter}\expandafter{\PT@lastcol@}{}% + \edef\PT@currentcol@{\PT@StripColumn\PT@currentcol}% + \PT@typeout@{adding implicit fromto at eol from \PT@currentcol@ + \space to \PT@lastcol@}% + \PT@expanded{\PT@expanded\fromto\PT@currentcol@}\PT@lastcol@ \fi \PT@typeout@{Next line ...}% - \PT@resetcolumn\\[#1]} -\def\PT@multicolumn #1#2#3% - {%\omit\PT@disableomitonce - % skip to current position - \global\PT@cols=\@nameuse{PT@col@#1.num}% - \global\advance\PT@cols - by -\expandafter\csname\PT@currentcol.num\endcsname\relax - \ifx\PT@currentcol\PT@nullcol - \global\advance\PT@cols by -1\relax% - \fi - \PT@typeout@{skipping: - nf=\expandafter\ShowColumn - \expandafter{\PT@currentcol}nt=#1 % - from=\expandafter - \csname\PT@currentcol.num\endcsname\space - to=\@nameuse{PT@col@#1.num}}% - \ifnum\PT@cols>0\relax - \ifnum\PT@cols>1\relax - \global\advance\PT@cols by -1\relax - \PT@typeout@{after next &, multicolumn \the\PT@cols\space blank}% - \PT@NextCol - \multicolumn{\the\PT@cols}{@{}l@{}}{}% - \fi - \PT@NextCol - \fi - \global\PT@cols=\@nameuse{PT@col@#2.num}% - \global\advance\PT@cols by -\@nameuse{PT@col@#1.num}\relax% - %\ifnum\PT@cols>1\relax - % we always skip one column - \PT@typeout@{after next &, - putting text in \the\PT@cols\space multicol}% - \PT@typeout@{nf=#1 nt=#2 % - from=\@nameuse{PT@col@#1.num} - to=\@nameuse{PT@col@#2.num}}% - \expandafter\global\expandafter\let\expandafter\PT@temp - \csname PT@col@#1.type\endcsname% - \PT@NextCol - % use multicolumn - \expandafter\multicolumn - \expandafter{\expandafter\the\expandafter\PT@cols - \expandafter}\expandafter{\PT@temp}{#3}% - %\PT@typeout@{!!!!}% - %\else - % \PT@NextCol - % #3% - %\fi - % set current column - \def\PT@currentcol{PT@col@#2}% - \ignorespaces}% -\def\PT@NextCol - {\PT@typeout@{ & }% - &}% -\def\PT@placeinbox#1#2#3% + \let\PT@scanning\undefined% needed for resetcolumn + \PT@resetcolumn\PT@cr} +\newcommand{\PT@fill}% + {\PT@expanded\PT@checkendentry\PT@lastcol@% + \ifx\PT@currentcol\PT@lastcol + \else + \ifx\PT@currentcol\PT@nullcol + \else + \edef\PT@currentcol@{\PT@StripColumn\PT@currentcol}% + \PT@typeout@{adding implicit fromto from \PT@currentcol@ + \space to \PT@lastcol@}% + \PT@expanded{\PT@expanded\fromto\PT@currentcol@}\PT@lastcol@ + \fi\fi} +\def\PT@placeinbox#1#2% {\PT@colwidth=\@nameuse{PT@col@#1.max}% \advance\PT@colwidth by -\expandafter\csname\PT@currentcol.max\endcsname \leavevmode + \edef\PT@temp{\PT@StripColumn\PT@currentcol}% + \PT@typeout@{adding space of width % + \expandafter\PT@aligndim\the\PT@colwidth\@@ + (\expandafter\PT@aligncol\expandafter{\PT@temp} % + -> \PT@aligncol{#1})}% \hb@xt@\PT@colwidth{% - \expandafter\@mkpream\expandafter{@{}l@{}}% + {\@mkpream{@{}l@{}}\@addtopreamble\@empty}% + \let\CT@row@color\relax% colortbl compatibility \let\@sharp\empty% %\show\@preamble \@preamble}% + \PT@typeout@{adding box \space\space of width % + \expandafter\PT@aligndim\the\wd\@curfield\@@ + (\PT@aligncol{#1} -> \PT@aligncol{#2})}% + \box\@curfield + \def\PT@currentcol{PT@col@#2}% + \ignorespaces}% +\def\PT@preparescan#1#2% + {\PT@checkcoldefined{#1}% + \PT@checkcoldefined{#2}% \PT@colwidth=\@nameuse{PT@col@#2.max}% \advance\PT@colwidth by -\@nameuse{PT@col@#1.max}\relax% \ifmmode - \PT@typeout@{*math mode*}% + \PT@debug@{*math mode*}% \let\d@llarbegin=$%$ \let\d@llarend=$%$ \let\col@sep=\arraycolsep \else - \PT@typeout@{*text mode*}% + \PT@debug@{*text mode*}% \let\d@llarbegin=\begingroup \let\d@llarend=\endgroup \let\col@sep=\tabcolsep \fi - %\def\PT@currentcol{PT@col@#1}% - \expandafter\expandafter\expandafter - \def\expandafter\expandafter\expandafter\PT@currentpreamble - \expandafter\expandafter\expandafter - {\csname PT@col@#1.type\endcsname}% - %\ifx\PT@currentcol\PT@nullcol - %\else - % \PT@addbeginmacro\PT@currentpreamble{@{}}% - %\fi - \hb@xt@\PT@colwidth{% - \expandafter\@mkpream\expandafter{\PT@currentpreamble}% - \def\@sharp{\strut #3}% - %\show\@preamble - \@preamble}% - \def\PT@currentcol{PT@col@#2}% - \ignorespaces}% + \ifx\PT@currentpreamble\relax + \PT@expanded{\PT@expanded{\def\PT@currentpreamble}}% + {\csname PT@col@#1.type\endcsname}% + \fi + {\PT@expanded\@mkpream\PT@currentpreamble% + \@addtopreamble\@empty}% + \let\CT@row@color\relax% colortbl compatibility + \expandafter\PT@splitpreamble\@preamble\@sharp\PT@nil} +\def\PT@splitpreamble #1\@sharp #2\PT@nil{% + \let\@sharp=\relax% needed for the following assignment + \def\PT@terp{#2}% + \ifx\PT@terp\empty% + \PackageError{polytable}{Illegal preamble (no columns)}{}% + \fi + \PT@splitsplitpreamble{#1}#2\PT@nil} + +\def\PT@splitsplitpreamble #1#2\@sharp #3\PT@nil{% + \def\PT@temp{#3}% + \ifx\PT@temp\empty% + \else + \PackageError{polytable}{Illegal preamble (multiple columns)}{}% + \fi + \def\PT@pre@preamble{#1}% + \def\PT@post@preamble{#2}}% +\def\PT@scanbeginwidth + {\PT@scanbegin@{\hbox to \PT@colwidth}} + +\def\PT@scanbeginfree + {\PT@scanbegin@{\hbox}} + +\def\PT@scanbegin@#1% + {\setbox\@curfield #1% + \bgroup + \PT@pre@preamble\strut\ignorespaces} + +\def\PT@scanend + {\PT@post@preamble + \egroup} \newcommand*{\PT@setmaxwidth}[3][\PT@false]% #2 column name, #3 maximum width {\@namedef{PT@col@#2.max}{#3}% \ifdim#3=0pt\relax @@ -459,7 +621,7 @@ \else \expandafter\let\csname PT@col@#2.trusted\endcsname=#1% \fi - \column{#2}{}} + \column{#2}{}}% \def\PT@loadtable#1% #1 table id number {%\expandafter\show\csname PT@restore@\romannumeral #1\endcsname %\show\column @@ -471,15 +633,14 @@ \csname PT@restore@\romannumeral #1\endcsname} \def\PT@loadtablebyname#1% #1 set name {\PT@typeout@{Loading table information for column width set #1.}% - \expandafter\PT@loadtable\expandafter{\csname PT@widths@#1\endcsname}}% + \PT@loadtable{\csname PT@widths@#1\endcsname}}% \def\PT@saveinformation#1% #1 set name - {\expandafter\def\expandafter\PT@temp\expandafter - {\csname PT@widths@#1\endcsname}% - \expandafter\def\expandafter\PT@temp\expandafter - {\csname PT@restore@\romannumeral\PT@temp\endcsname}% + {\PT@expanded{\def\PT@temp}{\csname PT@widths@#1\endcsname}% + \PT@expanded{\def\PT@temp}% + {\csname PT@restore@\romannumeral\PT@temp\endcsname}% \expandafter\gdef\PT@temp{}% start empty - % this is: \Execute{\Map{\PT@savecolumn{\PT@temp}}\PT@sortedlist} - \expandafter\Execute\expandafter{\expandafter + % this is: \PT@Execute{\Map{\PT@savecolumn{\PT@temp}}\PT@sortedlist} + \expandafter\PT@Execute\expandafter{\expandafter \Map\expandafter{\expandafter\PT@savecolumn \expandafter{\PT@temp}}\PT@sortedlist}} \def\PT@savecolumn#1#2% #1 macro name, #2 column name @@ -498,12 +659,12 @@ \ifnum\csname #2.trusted\endcsname=\PT@true\relax \PT@gaddendmacro{#1}{[\PT@true]}% \fi - \edef\PT@temp{\StripColumn{#2}}% + \edef\PT@temp{\PT@StripColumn{#2}}% \PT@addargtomacro{#1}{PT@temp}% \PT@addargtomacro{#1}{#2.max}% \PT@gaddendmacro{#1}{\column}% \PT@addoptargtomacro{#1}{#2.width}% - \edef\PT@temp{\StripColumn{#2}}% + \edef\PT@temp{\PT@StripColumn{#2}}% \PT@addargtomacro{#1}{PT@temp}% \PT@addargtomacro{#1}{#2.type}% %\show#1% @@ -528,7 +689,7 @@ {\@ifundefined{#1.max}% {\PT@typeout@{computed width for #1 is fine ...}}% {\ifdim\csname #1.max\endcsname>\csname #1.width\endcsname\relax - \PT@typeout@{Preferring saved width for \StripColumn{#1}.}% + \PT@typeout@{Preferring saved width for \PT@StripColumn{#1}.}% \PT@changedtrue \PT@colwidth=\@nameuse{#1.max}\relax \PT@enamedef{#1.width}{\the\PT@colwidth}% @@ -548,8 +709,7 @@ \PT@typeout@{Scheduling set #1 for verification at end of document.}% \AtEndDocument{\PT@verifywidths{#1}}}% {\PT@typeout@{Verifying column width set #1.}% - \expandafter\PT@verify@widths\expandafter - {\csname PT@widths@#1\endcsname}{#1}}} + \PT@expanded\PT@verify@widths{\csname PT@widths@#1\endcsname}{#1}}} \def\PT@verify@widths#1#2% #1 set id number, #2 set name {\@ifundefined{PT@restore@\romannumeral #1}{}% @@ -560,7 +720,7 @@ \PT@loadtablebyname{#2}% \PT@table=#1\relax % nullcolumn is not loaded, therefore: - \expandafter\def\csname\PT@nullcol .width\endcsname{0pt}% + \@namedef{\PT@nullcol .width}{0pt}% % checking trust \PT@prelazylist \All{\PT@trustedmax}{\PT@allcols}% @@ -579,32 +739,46 @@ {\immediate\write\@auxout{% \gdef\expandafter\noexpand \csname PT@restore@\romannumeral\PT@table\endcsname - {\Execute{\Map{\PT@write@column{#1}}\PT@allcols}}}}% + {\PT@Execute{\Map{\PT@write@column{#1}}\PT@allcols}}}}% \PT@postlazylist \fi} \def\PT@write@column #1#2% {\noexpand\maxcolumn^^J% - {\StripColumn{#2}}% + {\PT@StripColumn{#2}}% {\@nameuse{#2#1}}}% -\newenvironment{ptabular}[1][c]% - {\def\PT@begin{\tabular[#1]}% - \let\PT@end\endtabular - \beginpolytable} - {\endpolytable} - -\newenvironment{parray}[1][c]% - {\def\PT@begin{\array[#1]}% - \let\PT@end\endarray - \beginpolytable} - {\endpolytable} - \def\pboxed{% - \let\PT@begin\@gobble - \let\PT@end\empty - \let\PT@multicolumn\PT@placeinbox + \let\PT@begin \empty + \let\PT@end \empty + \ifx\\\PT@arraycr + \let\PT@cr \PT@normalcr + \else + \let\PT@cr \\% + \fi \expandafter\beginpolytable\ignorespaces} \let\endpboxed\endpolytable + +\def\ptboxed{% + \def\PT@begin {\tabular{@{}l@{}}}% + \let\PT@end \endtabular + \let\PT@cr \@arraycr + \expandafter\beginpolytable\ignorespaces} + +\let\endptboxed\endpolytable + +\def\pmboxed{% + \def\PT@begin {\array{@{}l@{}}}% + \let\PT@end \endarray + \let\PT@cr \@arraycr + \expandafter\beginpolytable\ignorespaces} + +\let\endpmboxed\endpolytable + +\let\ptabular \ptboxed +\let\endptabular \endptboxed +\let\parray \pmboxed +\let\endparray \endpmboxed + \endinput %% %% End of file `polytable.sty'. |