diff options
-rwxr-xr-x | Build/tools/tpm-ctan-check | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/polytable/README | 2 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/polytable/polytable.dtx | 1659 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/polytable/polytable.sty | 678 | ||||
-rw-r--r-- | Master/texmf-dist/tpm/polytable.tpm | 8 |
5 files changed, 1432 insertions, 917 deletions
diff --git a/Build/tools/tpm-ctan-check b/Build/tools/tpm-ctan-check index 54fa2bc50cf..94707322503 100755 --- a/Build/tools/tpm-ctan-check +++ b/Build/tools/tpm-ctan-check @@ -71,7 +71,7 @@ my @WorkingTPM = qw( papercdcase paresse parrun pauldoc pdf-trans pdfcprot pdfpages pdfscreen pdftex-def perception perltex permute pgf phaistos pict2e pictex pittetd placeins plari plates - poemscol polynom powerdot ppr-prv pracjourn preprint + poemscol polynom polytable powerdot ppr-prv pracjourn preprint prettyref preview probsoln program protocol pseudocode psfrag psnfss pspicture pst-3d pst-3dplot pst-bar pst-barcode pst-blur pst-eucl pst-fr3d pst-func pst-labo diff --git a/Master/texmf-dist/doc/latex/polytable/README b/Master/texmf-dist/doc/latex/polytable/README index b5f14da796d..88ba9301834 100644 --- a/Master/texmf-dist/doc/latex/polytable/README +++ b/Master/texmf-dist/doc/latex/polytable/README @@ -11,4 +11,4 @@ latex polytable.dtx Please report bugs to "polytable@andres-loeh.de". -Andres Loeh, March 2004 +Andres Loeh, November 2005 diff --git a/Master/texmf-dist/source/latex/polytable/polytable.dtx b/Master/texmf-dist/source/latex/polytable/polytable.dtx index 1f067051486..6f8601b7e09 100644 --- a/Master/texmf-dist/source/latex/polytable/polytable.dtx +++ b/Master/texmf-dist/source/latex/polytable/polytable.dtx @@ -2,18 +2,18 @@ %<*driver> \ProvidesFile{polytable.drv} \documentclass{ltxdoc} -\usepackage{polytable} +\usepackage[info]{polytable} \begin{document} \DocInput{polytable.dtx} \end{document} %</driver> % -% Copyright (C) 2003--2004 by Andres Loeh +% Copyright (C) 2003--2005 by Andres Loeh % % \fi % % \ProvidesFile{polytable.dtx} -% [2003/12/26 v0.7.2 `polytable' package (Andres Loeh)] +% [2005/04/26 v0.8.2 `polytable' package (Andres Loeh)] % \GetFileInfo{polytable.dtx} % % \title{The \textsf{polytable} package} @@ -23,7 +23,7 @@ % \maketitle % % \begin{abstract} -% This package implements a variant of tabular-like environments +% This package implements a variant of tabular/tabbing-like environments % where columns can be given a name and entries can flexibly % be placed between arbitrary columns. Complex alignment-based % layouts, for example for program code, are possible. @@ -40,6 +40,15 @@ % \changes{v0.6}{2003/07/24}{Depends on lazylist instead of lambda now.} % \changes{v0.7}{2003/11/20}{Check for undefined columns. Save counters.} % \changes{v0.7.1}{2003/12/26}{Counters have not been restored correctly.} +% \changes{v0.7.2}{2004/02/27}{Fix for conflict with amsmath package.} +% \changes{v0.7.3}{2004/06/21}{Balance last line in pboxed environment.} +% \changes{v0.8}{2004/06/24}{New environments pmboxed, ptboxed. +% Removed original ptabular and parray. +% Interface overhaul.} +% \changes{v0.8.1}{2004/11/11}{Fixed some problems with the new +% interface, added the external (disk) queue.} +% \changes{v0.8.2}{2005/04/26}{New interface command. +% Minor beautifications.} % % \section{Introduction} % @@ -65,7 +74,7 @@ % we could thus use the command\\ % |\fromto{foo}{bar}{I'm aligned}|\\ % Several |\fromto|-commands can be used to typeset a complete -% line of the table. A new line can be started with |\nextline|. +% line of the table. A new line can be started with |\\|. % % The strength of this approach is that it implicitly handles % cases where different lines have different alignment properties. @@ -80,37 +89,17 @@ % % \begin{figure}[htb] % \centering -% \begin{ptabular} -% \column{left}{|l|} -% \column{right}{l|} -% \column{m13}{l|} -% \column{m23}{l|} -% \column{m33}{l|} -% \column{m12}{r|} -% \column{m22}{r|} -% \column{end}{l} -% \fromto{left}{m13}{left} -% \fromto{m13}{m23}{first of three} -% \fromto{m23}{m33}{second of three} -% \fromto{m33}{right}{third of three} -% \fromto{right}{end}{right} -% \nextline -% \fromto{left}{m12}{left} -% \fromto{m12}{m22}{middle 1/2} -% \fromto{m22}{right}{middle 2/2} -% \fromto{right}{end}{right} -% \nextline -% \fromto{left}{m13}{left} -% \fromto{m13}{m23}{middle 1/3} -% \fromto{m23}{m33}{middle 2/3} -% \fromto{m33}{right}{middle 3/3} -% \fromto{right}{end}{right} -% \nextline -% \fromto{left}{m12}{left} -% \fromto{m12}{m22}{first of two middle columns} -% \fromto{m22}{right}{second of two middle columns} -% \fromto{right}{end}{right} -% \end{ptabular} +% \begin{ptboxed} +% \defaultcolumn{l|}\column{.}{|l|} +% \> left +% \=3 first of three \> second of three \> third of three +% \=r right \\ +% \defaultcolumn{r|}\> left \=2 middle 1/2 \> middle 2/2 \=r right \\ +% \> left \=3 middle 1/3 \> middle 2/3 \> middle 3/3 \=r right \\ +% \> left +% \=2 first of two middle columns \> second of two middle columns +% \=r right \\ +% \end{ptboxed} % \caption{Example table}% % \label{tab:example} % \end{figure} @@ -136,37 +125,17 @@ % % Let's have a look at the input for the example table: % \begin{verbatim} -% \begin{ptabular} -% \column{left}{|l|} -% \column{right}{l|} -% \column{m13}{l|} -% \column{m23}{l|} -% \column{m33}{l|} -% \column{m12}{r|} -% \column{m22}{r|} -% \column{end}{l} -% \fromto{left}{m13}{left} -% \fromto{m13}{m23}{first of three} -% \fromto{m23}{m33}{second of three} -% \fromto{m33}{right}{third of three} -% \fromto{right}{end}{right} -% \nextline -% \fromto{left}{m12}{left} -% \fromto{m12}{m22}{middle 1/2} -% \fromto{m22}{right}{middle 2/2} -% \fromto{right}{end}{right} -% \nextline -% \fromto{left}{m13}{left} -% \fromto{m13}{m23}{middle 1/3} -% \fromto{m23}{m33}{middle 2/3} -% \fromto{m33}{right}{middle 3/3} -% \fromto{right}{end}{right} -% \nextline -% \fromto{left}{m12}{left} -% \fromto{m12}{m22}{first of two middle columns} -% \fromto{m22}{right}{second of two middle columns} -% \fromto{right}{end}{right} -% \end{ptabular} +% \begin{ptboxed} +% \defaultcolumn{l|}\column{.}{|l|} +% \> left +% \=3 first of three \> second of three \> third of three +% \=r right \\ +% \defaultcolumn{r|}\> left \=2 middle 1/2 \> middle 2/2 \=r right \\ +% \> left \=3 middle 1/3 \> middle 2/3 \> middle 3/3 \=r right \\ +% \> left +% \=2 first of two middle columns \> second of two middle columns +% \=r right \\ +% \end{ptboxed} % \end{verbatim} % First, columns are declared, including the vertical lines. % Note that there is a final column |end| being declared @@ -175,12 +144,12 @@ % will probably get rid of the need to define % such a column. % After the column definitions, the lines are typeset by a -% series of |\fromto| commands, separated by |\nextline|. +% series of |\fromto| commands, separated by |\\|. % Note that the first and third column do not use |m12|, |m22|. % Similarly, the second and fourth column do not use % |m13|, |m23|, and |m33|. % -% So far, one could achieve the same with an ordinary |table| +% So far, one could achieve the same with an ordinary |tabular| % environment. The table would have 6 columns. One left and right, % the other four for the middle: the first and third line would % use the first of the four columns, then place the second entry @@ -204,7 +173,7 @@ % % \begin{figure}[htb] % \centering -% \begin{ptabular} +% \begin{ptboxed} % \column{left}{|l|} % \column{right}{l|} % \column{m13}{l|} @@ -218,25 +187,25 @@ % \fromto{m23}{m33}{second of three} % \fromto{m33}{right}{third of three} % \fromto{right}{end}{right} -% \nextline +% \\ % \fromto{left}{m12}{left} % \fromto{m12}{m22}{middle 1/2} % \fromto{m22}{right}{middle 2/2} % \fromto{right}{end}{right} -% \nextline +% \\ % \fromto{left}{m13}{left} % \fromto{m13}{m23}{middle 1/3} % \fromto{m23}{m33}{middle 2/3} % \fromto{m33}{right}{middle 3/3} % \fromto{right}{end}{right} -% \nextline +% \\ % \fromto{left}{m12}{left} % \fromto{m12}{m22}{first of two} % \fromto{m22}{right}{second of two} % \fromto{right}{end}{right} -% \end{ptabular} +% \end{ptboxed} % \par\bigskip -% \begin{ptabular} +% \begin{ptboxed} % \column{left}{|l|} % \column{right}{l|} % \column{m13}{l|} @@ -250,23 +219,23 @@ % \fromto{m23}{m33}{second of three} % \fromto{m33}{right}{third of three} % \fromto{right}{end}{right} -% \nextline +% \\ % \fromto{left}{m12}{left} % \fromto{m12}{m22}{middle 1/2} % \fromto{m22}{right}{middle 2/2} % \fromto{right}{end}{right} -% \nextline +% \\ % \fromto{left}{m13}{left} % \fromto{m13}{m23}{middle 1/3} % \fromto{m23}{m33}{middle 2/3} % \fromto{m33}{right}{middle 3/3} % \fromto{right}{end}{right} -% \nextline +% \\ % \fromto{left}{m12}{left} % \fromto{m12}{m22}{the first of two middle columns} % \fromto{m22}{right}{2/2} % \fromto{right}{end}{right} -% \end{ptabular} +% \end{ptboxed} % \caption{Variants of the example table}% % \label{tab:variation} % \end{figure} @@ -328,84 +297,82 @@ % % \begin{figure} % \[ -% \begin{parray} +% \begin{pmboxed} % \column{left}{l} % \column{body}{l} % \column{end}{l} % \column{rel}{c} % \column{rhs}{l} -% \fromto{left}{end}{\CLASS\ (\Eq\TA)\Rightarrow\Ord\TA\WHERE} -% \nextline -% \fromto{left}{body}{\qquad\ } -% \fromto{body}{rel}{\HsVar{compare}} -% \fromto{rel}{rhs}{::} -% \fromto{rhs}{end}{\TA\rightarrow\TA\rightarrow\HsCon{Ordering}} -% \nextline -% \fromto{left}{body}{\qquad\ } -% \fromto{body}{rel}{(<),(\leq),(\geq),(>)} -% \fromto{rel}{rhs}{::} -% \fromto{rhs}{end}{\TA\rightarrow\TA\rightarrow\HsCon{Bool}} -% \nextline -% \fromto{left}{body}{\qquad\ } -% \fromto{body}{rel}{\HsVar{max},\HsVar{min}} -% \fromto{rel}{rhs}{::} -% \fromto{rhs}{end}{\TA\rightarrow\TA\rightarrow\HsCon{Bool}} -% \nextline -% \nextline -% \fromto{body}{end}{\mbox{--- Minimal complete definition: -% $(\leq)$ or $\HsVar{compare}$}} -% \nextline -% \fromto{body}{end}{\mbox{--- using $\HsVar{compare}$ can be more efficient -% for complex types}} -% \nextline +% \>[left] \CLASS\ (\Eq\TA)\Rightarrow\Ord\TA\WHERE \\ +% \>[left] \qquad\ +% \>[body] \HsVar{compare} +% \>[rel] :: +% \>[rhs] \TA\rightarrow\TA\rightarrow\HsCon{Ordering} \\ +% \>[left] \qquad\ +% \>[body] (<),(\leq),(\geq),(>) +% \>[rel] :: +% \>[rhs] \TA\rightarrow\TA\rightarrow\HsCon{Bool} +% \\ +% \>[left] \qquad\ +% \>[body] \HsVar{max},\HsVar{min} +% \>[rel] :: +% \>[rhs] \TA\rightarrow\TA\rightarrow\HsCon{Bool} +% \\ +% \\ +% \>[body] \mbox{--- Minimal complete definition: +% $(\leq)$ or $\HsVar{compare}$} +% \\ +% \>[body] \mbox{--- using $\HsVar{compare}$ can be more efficient +% for complex types} +% \\ % \column{cgrd}{l} -% \fromto{body}{cgrd}{\HsVar{compare}\TX\TY} -% \fromto{cgrd}{rel}{\vert\ \TX\equiv\TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\HsCon{EQ}} -% \nextline -% \fromto{cgrd}{rel}{\vert\ \TX\leq\TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\HsCon{LT}} -% \nextline -% \fromto{cgrd}{rel}{\vert\ \HsVar{otherwise}} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\HsCon{GT}} -% \nextline -% \fromto{body}{rel}{\TX\leq\TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\HsVar{compare}\TX\TY\not\equiv\HsCon{GT}} -% \nextline -% \fromto{body}{rel}{\TX < \TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\HsVar{compare}\TX\TY\equiv\HsCon{LT}} -% \nextline -% \fromto{body}{rel}{\TX\geq\TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\HsVar{compare}\TX\TY\not\equiv\HsCon{LT}} -% \nextline -% \fromto{body}{rel}{\TX > \TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\HsVar{compare}\TX\TY\equiv\HsCon{GT}} -% \nextline -% \fromto{body}{cgrd}{\HsVar{max}\TX\TY} -% \fromto{cgrd}{rel}{\vert\ \TX\leq\TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\TY} -% \nextline -% \fromto{cgrd}{rel}{\vert\ \HsVar{otherwise}} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\TX} -% \nextline -% \fromto{body}{cgrd}{\HsVar{min}\TX\TY} -% \fromto{cgrd}{rel}{\vert\ \TX\leq\TY} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\TX} -% \nextline -% \fromto{cgrd}{rel}{\vert\ \HsVar{otherwise}} -% \fromto{rel}{rhs}{=} -% \fromto{rhs}{end}{\TY} -% \end{parray} +% \>[body] \HsVar{compare}\TX\TY +% \>[cgrd] \vert\ \TX\equiv\TY +% \>[rel] = +% \>[rhs] \HsCon{EQ} +% \\ +% \>[cgrd] \vert\ \TX\leq\TY +% \>[rel] = +% \>[rhs] \HsCon{LT} +% \\ +% \>[cgrd] \vert\ \HsVar{otherwise} +% \>[rel] = +% \>[rhs] \HsCon{GT} +% \\ +% \>[body] \TX\leq\TY +% \>[rel] = +% \>[rhs] \HsVar{compare}\TX\TY\not\equiv\HsCon{GT} +% \\ +% \>[body] \TX < \TY +% \>[rel] = +% \>[rhs] \HsVar{compare}\TX\TY\equiv\HsCon{LT} +% \\ +% \>[body] \TX\geq\TY +% \>[rel] = +% \>[rhs] \HsVar{compare}\TX\TY\not\equiv\HsCon{LT} +% \\ +% \>[body] \TX > \TY +% \>[rel] = +% \>[rhs] \HsVar{compare}\TX\TY\equiv\HsCon{GT} +% \\ +% \>[body] \HsVar{max}\TX\TY +% \>[cgrd] \vert\ \TX\leq\TY +% \>[rel] = +% \>[rhs] \TY +% \\ +% \>[cgrd] \vert\ \HsVar{otherwise} +% \>[rel] = +% \>[rhs] \TX +% \\ +% \>[body] \HsVar{min}\TX\TY +% \>[cgrd] \vert\ \TX\leq\TY +% \>[rel] = +% \>[rhs] \TX +% \\ +% \>[cgrd] \vert\ \HsVar{otherwise} +% \>[rel] = +% \>[rhs] \TY +% \end{pmboxed} % \] % \caption{Haskell code example} % \label{tab:haskell} @@ -436,52 +403,147 @@ % % \section{Reference} % +% \subsection{Setup} +% +% New in v0.8: We allow to implicitly define columns by just +% using the names during table content specification, without +% having declared them formally using |\column| (see below). +% +% \DescribeMacro{\nodefaultcolumn} +% By default, though, this behaviour is turned off, because the +% use of a misspelled column is often an error. Thus, by default +% or after the command |\nodefaultcolumn| is used, all columns +% must be declared. +% +% \DescribeMacro{\defaultcolumn} +% Using a statement of the form +% |\defaultcolumn{|\meta{spec}|}|, implicit columns can +% be activated. All undefined columns that are encountered +% will be assumed to have format string \meta{spec}. +% % \subsection{The environments} % +% \DescribeEnv{pboxed} +% \DescribeEnv{ptboxed} +% \DescribeEnv{pmboxed} % \DescribeEnv{ptabular} % \DescribeEnv{parray} -% \DescribeEnv{pboxed} -% There are currently three environments that this package provides: -% |ptabular| and |parray| are based on (and translated into) the usual -% |tabular| and |array| environments as provided by the |array| -% package. In particular, |parray| assumes math mode, whereas -% |ptabular| assumes text mode. The third environment, |pboxed|, +% New in v0.8: There are now five environments that this package +% provides: in addition to the former |ptabular|, |parray|, and +% |pboxed|, there is now also |ptboxed| and |pmboxed|. +% The environment |pboxed| % typesets the material in boxes of the calculated length, but in % normal paragraph mode. The advantage is that % there can be page breaks within the table. -% Note that you should start a new, nonindented -% paragraph before beginning a |pboxed|. All lines in a |pboxed| -% should be of equal length, so it might be possible to center -% or right-align the material, although this has not been -% extensively tested. -% -% One more environment is planned: |plongtable|, a poly-version -% of the |longtable| environment. +% Note that you should start a new (probably nonindented) +% paragraph before beginning a |pboxed|. All lines that a |pboxed| +% produces are of equal length, so it should be possible to center +% or right-align the material. + +% Both |ptboxed| and |pbmoxed| are like |pboxed|, but +% pre-wrapped in a |tabular| or |array| environment, +% respectively, and +% thus not page-breakable but less fragile (or should I just +% say: easier to use) than the unwrapped |pboxed|. +% With those, there +% is no need for |ptabular| and |parray| anymore -- +% which were directly based on (and translated into) usual +% |tabular| and |array| environments as provided by the |array| +% package. The environments are still supported, to ensure +% compatibility, but they are mapped to |ptboxed| and |pmboxed|, +% respectively. +% +% The |pmboxed| and |parray| environments assume math mode, whereas +% |ptboxed| and |ptabular| assume text mode. The |pboxed| environment +% works in both text and math modes and adapts to whatever is +% currently active. +% +% I wrote in previous versions that one additional environment, namely +% |plongtable|, a poly-version of the |longtable| environment, was planned. +% Page-breaking of |pboxed| works fine, and I do not see a +% real need for a |plongtable| environment anymore. If you would like +% it anyway, feel free to mail me and inform me about the advantages +% it would have over |pboxed|. % % The interface is the same for all of the environments. % -% \subsection{The commands} +% \subsection{The interface} +% +% \begin{center} +% \textbf{(Note: this has changed significantly in v0.8!)} +% \end{center} % % In each of the environments, the following commands can be -% used (and \emph{only} these commands should be used): +% used. All other commands should be used with care if placed +% directly inside such an environment: the contents of a polytable +% are processed multiple times; hence, if your commands generate +% output, the output will end up multiple times in the final +% document, and destroy your layout. % % \DescribeMacro{\column} -% With |\column{|\meta{columnid}|}{|\meta{spec}|}|, a new column +% With |\column[|\meta{dimen}|]{|\meta{columnid}|}{|\meta{spec}|}|, +% a new column % \meta{columnid} is specified. The name of the column can be % any sequence of alphanumerical characters. The \meta{spec} is % a format string for that particular column, and it can contain % the same constructs that can be used in format strings of normal -% tables or arrays (this also holds for the |pboxed| environment). -% However, it should only contain the description for \emph{one} -% column. (I've never tested what happens if you do something else, -% but you have been warned \dots) -% -% If the save/restore feature (explained below) is not used, |\column| -% definitions are always local to one table. -% One can define a column multiple times within one table. -% A warning will be produced, +% tables or arrays. +% However, it must only contain the description for \emph{one} +% column. +% +% As long as the save/restore feature (explained below) is not used, +% |\column| definitions are local to one table. +% One can define a column multiple times within one table: +% a warning will be produced, % and the second format string will be used for the complete table. % +% Columns must be defined before use when implicit columns using +% |\defaultcolumn| are disabled. +% +% A minimal horizontal position \meta{dimen} (relative to the +% beginning of the table) can be specified for a column, which +% defaults to 0pt. +% +% \DescribeMacro{\=} +% The command |\={|\meta{fromid}|}[|\meta{spec}|]| instructs the +% package to prepare for a new entry starting at column \meta{fromid}. +% Everything that follows the command, up to the next +% interface-command (except |\column|) or the end of the environment +% is interpreted as contents of the entry and can be arbitrary +% \LaTeX\ code that has balanced grouping. The column specifier +% \meta{spec} can be used to define a different formatting for this +% particular entry. If the specifier starts with an exclamation mark +% (|!|), it will be used as specifier for all entries of that column. +% The use of multiple exclamation-mark specifiers for the same +% column name gives precedence to the last one, but you should not +% rely on this behaviour as it may change in the future. +% +% Note that, contrary to normal \LaTeX\ behaviour, the second argument +% is the optional argument. Therefore, if an entry starts with an +% opening bracket |([)|, +% and the optional argument is omitted, a |\relax| should be inserted +% between command and opening bracket, as otherwise the entry would +% be treated as the optional argument. +% +% \DescribeMacro{\>} +% The command |\>[|\meta{fromid}|][|\meta{spec}|]| is a variant of +% |\=| where both arguments are optional. If no column name is given +% then the current column name, postfixed by a dot (|.|), is assumed +% as column name. At the beginning of a line, a single dot (|.|) +% will be assumed as a name. The \meta{spec} argument has the same +% behaviour as for |\=|. Note that if the specifier is given, the +% column name must be given as well, but may be left empty if the +% default choice is desired. For instance, |\>[][r]|, will move to +% the next column, which will be typeset right-aligned. +% +% \DescribeMacro{\<} +% The command |\<[|\meta{fromid}|]| ends the current entry at the +% boundary specified by \meta{fromid}. This macro can be used instead +% of |\>| or |\=| if an entry should be ended without immediately +% starting a new one. Differences in behaviour occur if \meta{fromid} +% is associated with a non-trivial column format string. +% TODO: Improve this explanation. +% % \DescribeMacro{\fromto} % The call |\fromto{|\meta{fromid}|}{|\meta{toid}|}{|\meta{text}|}| % will typeset \meta{text} in the current line, starting at column @@ -497,12 +559,13 @@ % current algorithm will loop, causing a |dimension too large| error % ultimately. TODO: catch this error. % +% \DescribeMacro{\\} % \DescribeMacro{\nextline} -% The command |\nextline| ends one line and begins the next. +% The command |\\| (or, now deprecated, |\nextline|) ends one line +% and begins the next. % There is no need to end the last line. One can pass an optional -% argument, as in |\nextline[|\meta{dimen}|]|, that will add -% \meta{dimen} extra space between the lines. TODO: make this -% command available as |\\|. +% argument, as in |\\[|\meta{dimen}|]|, that will add +% \meta{dimen} extra space between the lines. % % \subsection{A warning} % @@ -510,18 +573,12 @@ % the widths of the entries are measured. Global assigments that % modify registers and similar things can thus result in unexpected % behaviour. -% New in v0.7: \LaTeX\ counters (i.e. counters defined by +% New in v0.7: \LaTeX\ counters (i.e., counters defined by % |\newcounter|) are protected now. They will be reset after % each of the trial runs. % % \subsection{Saving column width information} % -% WARNING: this feature does \emph{only} work correctly with -% the |pboxed| environment right now. TODO: make this work -% with the other environments (this essentially amounts to -% implementing a |tabbing|-like |\kill| statement for |tabular| -% and |array|; does that already exist somewhere?). -% % Sometimes, one might want to reuse not only the same column, but % exactly the same alignment as in a previous table. An example % would be a fragment of program code, which has been broken into @@ -582,20 +639,20 @@ % \fromto{body}{rel}{\HsVar{compare}} % \fromto{rel}{rhs}{::} % \fromto{rhs}{end}{\TA\rightarrow\TA\rightarrow\HsCon{Ordering}} -% \nextline +% \\ % \fromto{left}{body}{\qquad\ } % \fromto{body}{rel}{(<),(\leq),(\geq),(>)} % \fromto{rel}{rhs}{::} % \fromto{rhs}{end}{\TA\rightarrow\TA\rightarrow\HsCon{Bool}} -% \nextline +% \\ % \fromto{left}{body}{\qquad\ } % \fromto{body}{rel}{\HsVar{max},\HsVar{min}} % \fromto{rel}{rhs}{::} % \fromto{rhs}{end}{\TA\rightarrow\TA\rightarrow\HsCon{Bool}} -% \nextline[1ex] +% \\[1ex] % \fromto{body}{end}{\mbox{--- Minimal complete definition: % $(\leq)$ or $\HsVar{compare}$}} -% \nextline +% \\ % \fromto{body}{end}{\mbox{--- using $\HsVar{compare}$ can be more efficient % for complex types}} % \end{pboxed} @@ -618,11 +675,11 @@ % \fromto{cgrd}{rel}{\vert\ \TX\equiv\TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\HsCon{EQ}} -% \nextline +% \\ % \fromto{cgrd}{rel}{\vert\ \TX\leq\TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\HsCon{LT}} -% \nextline +% \\ % \fromto{cgrd}{rel}{\vert\ \HsVar{otherwise}} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\HsCon{GT}} @@ -638,15 +695,15 @@ % \fromto{body}{rel}{\TX\leq\TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\HsVar{compare}\TX\TY\not\equiv\HsCon{GT}} -% \nextline +% \\ % \fromto{body}{rel}{\TX < \TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\HsVar{compare}\TX\TY\equiv\HsCon{LT}} -% \nextline +% \\ % \fromto{body}{rel}{\TX\geq\TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\HsVar{compare}\TX\TY\not\equiv\HsCon{LT}} -% \nextline +% \\ % \fromto{body}{rel}{\TX > \TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\HsVar{compare}\TX\TY\equiv\HsCon{GT}} @@ -663,16 +720,16 @@ % \fromto{cgrd}{rel}{\vert\ \TX\leq\TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\TY} -% \nextline +% \\ % \fromto{cgrd}{rel}{\vert\ \HsVar{otherwise}} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\TX} -% \nextline +% \\ % \fromto{body}{cgrd}{\HsVar{min}\TX\TY} % \fromto{cgrd}{rel}{\vert\ \TX\leq\TY} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\TX} -% \nextline +% \\ % \fromto{cgrd}{rel}{\vert\ \HsVar{otherwise}} % \fromto{rel}{rhs}{=} % \fromto{rhs}{end}{\TY} @@ -688,7 +745,7 @@ %<*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)] % \end{macrocode} % New in v0.7.2: % The \textsf{amsmath} package clashes with \textsf{lazylist}: @@ -710,26 +767,30 @@ % \end{macrocode} % % The option debug will cause (a considerable amount of) -% debugging output to be printed. The option silent, on +% debugging output to be printed. The option info is a +% compromise, printing some status information for each table, +% but no real debugging information. The option silent, on % the other hand, will prevent certain warnings from being % printed. % \begin{macrocode} -\DeclareOption{debug}{\AtEndOfPackage\PT@debug} +\DeclareOption{debug} {\AtEndOfPackage\PT@debug} +\DeclareOption{info} {\AtEndOfPackage\PT@info} \DeclareOption{silent}{\AtEndOfPackage\PT@silent} -\ProcessOptions % \end{macrocode} % % First, we declare a couple of registers that we will need later. % \begin{macrocode} \newdimen\PT@colwidth -%\newdimen\PT@delta \newcount\PT@cols \newcount\PT@table +\newtoks\PT@toks \newif\ifPT@changed +\newread\PT@in +\newwrite\PT@out % \end{macrocode} % In |\PT@allcols|, we will store the list of all columns, as a % list as provided by the \textsf{lazylist} package. We initialise -% it to the empty list, which is represented by |\Nil|. In v0.8, +% it to the empty list, which is represented by |\Nil|. In v0.9, % we will have a second list that only contains the public columns. % \begin{macrocode} \def\PT@allcols{\Nil} @@ -743,14 +804,62 @@ \def\PT@true{1} \let\PT@inrestore\PT@false % \end{macrocode} -% The dimension |\PT@delta| is currently not used. The dimension -% comparisons should probably have a small tolerance, to prevent -% infinite loops due to rounding errors. (Can this really happen?) +% +% \begin{macro}{\defaultcolumn} +% \begin{macro}{\nodefaultcolumn} +% \begin{macro}{\PT@defaultcolumnspec} +% The macro |\PT@defaultcolumnspec| contains, if defined, the +% current default specifier that is assumed for undefined columns. +% The other two commands can be used to set the specifier. % \begin{macrocode} -%\PT@delta\hfuzz +\newcommand{\defaultcolumn}[1]{\gdef\PT@defaultcolumnspec{#1}} +\newcommand{\nodefaultcolumn}{\global\let\PT@defaultcolumnspec\undefined} +\DeclareOption{defaultcolumns}{\defaultcolumn{l}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\memorytables} +% \begin{macro}{\disktables} +% \begin{macro}{\PT@add} +% \begin{macro}{\PT@split} +% \begin{macro}{\PT@prearewrite} +% \begin{macro}{\PT@preareread} +% \begin{macro}{\PT@finalize} +% These macros steer where the end-column queue is stored, which +% can be either in memory or on disk. The default is on disk, +% because that's more reliable for large tables. There is a package +% option |memory| to make |\memorytables| the default. +% \begin{macrocode} +\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 % \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\PT@debug} +% \begin{macro}{\PT@info} +% \begin{macro}{\PT@debug@} % \begin{macro}{\PT@typeout@} % \begin{macro}{\PT@silent} % \begin{macro}{\PT@warning} @@ -758,8 +867,12 @@ % print debugging information to the log. Depending on package % options, we can set or unset them. % \begin{macrocode} -\def\PT@debug +\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 @@ -769,10 +882,45 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\PT@aligndim} +% \begin{macro}{\PT@aligncol} +% The first is (almost) stolen from the \textsf{tabularx}-package, to nicely +% align dimensions in the log file. TODO: fix some issues. +% The other command is for column names. +% \begin{macrocode} +\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} +% \end{macrocode} +% \end{macro} +% \end{macro} % % \begin{macro}{\PT@rerun} % This macro can be called at a position where we know that -% we have to rerun LaTeX to get the column widths right. It +% we have to rerun \LaTeX\ to get the column widths right. It % issues a warning at the end of the document. % \begin{macrocode} \def\PT@rerun @@ -784,6 +932,16 @@ % \end{macrocode} % \end{macro} % +% \begin{macro}{\PT@currentcol} +% \begin{macro}{\PT@currentcolumn} +% Both macros are used during typesetting to store the current +% column. The differences are subtle. TODO: remove +% one of the two, if possible. The |\PT@currentcol| variant +% contains the internal name, whereas the |\PT@currentcolumn| +% variant contains the external name. +% \end{macro} +% \end{macro} +% % \subsection{Macro definition tools} % % \begin{macro}{\PT@listopmacro} @@ -808,57 +966,31 @@ % \end{macro} % \end{macro} % \end{macro} -% The follwing two macros can be used to add something to -% the beginning or the end of a constrol structure. +% The follwing macro can be used to add something to +% the end of a control structure. % \begin{macrocode} -\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}} -% \end{macrocode} -% \begin{macro}{\PT@enamedef} -% This is much like |\@namedef|, but it expands |#2| once. -% \begin{macrocode} -\def\PT@enamedef #1#2% sets name #1 to the expansion of #2 - {\expandafter\Twiddle\expandafter\@namedef\expandafter{#2}{#1}} + {\PT@expanded{\gdef #1}{#1#2}} % \end{macrocode} -% \end{macro} -% -% \begin{macro}{\PT@adddeftomacroas} -% Given the name of a control structure |#1| and a name of another -% control structure |#2| and an expression |#3|, we add the -% definition of |#2| to the expansion of |#3| to the macro |#1|. +% \begin{macro}{\PT@expanded} +% This macro expands its second argument once before passing +% it to the first argument. It is like |\expandafter|, but +% works on grouped arguments instead of tokens. % \begin{macrocode} -\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@expanded #1#2% + {\expandafter\Twiddle\expandafter\Identity\expandafter{#2}{#1}} % \end{macrocode} % \end{macro} -% -% \begin{macro}{\PT@adddeftomacro} -% This is a special case of |\PT@adddeftomacroas| where |#3| is -% the expansion of |#2|. +% \begin{macro}{\PT@enamedef} +% This is much like |\@namedef|, but it expands |#2| once. % \begin{macrocode} -\def\PT@adddeftomacro#1#2% - {\def\PT@temp{\PT@adddeftomacroas{#1}{#2}}% - \expandafter\PT@temp\csname #2\endcsname} +\def\PT@enamedef #1% sets name #1 to the expansion of #2 + {\PT@expanded{\@namedef{#1}}} % \end{macrocode} % \end{macro} % % \begin{macro}{\PT@addoptargtomacro} +% \begin{macro}{\PT@addargtomacro} % \begin{macrocode} \def\PT@addoptargtomacro {\PT@add@argtomacro\PT@makeoptarg} @@ -866,29 +998,14 @@ {\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}}} - -% -% \begin{macro}{\PT@mtimesn} -% Expands to |#1| times |#2|. (Work in progress.) -% \begin{macrocode} -% \def\PT@mtimesn #1#2% -% {\expandafter\PT@mtimtesn@\romannumeral #1011{#2}} -% \def\PT@mtimesn@ #1i#2% -% {\if#1m% -% #2\expandafter\PT@mtimesn@#1i#3} + {\PT@expanded{\def\PT@temp}{\expandafter{\PT@temp}}} % \end{macrocode} % \end{macro} % @@ -898,37 +1015,89 @@ \newcommand*{\PT@gobbleoptional}[1][]{\ignorespaces} % \end{macrocode} % \end{macro} +% \end{macro} % -% \begin{macro}{\PT@origomit} -% Save the original definition of omit. -% \begin{macrocode} -\let\PT@origomit\omit +% \begin{macro}{\PT@addmem} +% \begin{macro}{\PT@splitmem} +% \begin{macro}{\PT@addfile} +% \begin{macro}{\PT@splitfile} +% \begin{macro}{\PT@preparereadmem} +% \begin{macro}{\PT@preparereadfile} +% \begin{macro}{\PT@preparewrite} +% \begin{macro}{\PT@finalizefile} +% \begin{macro}{\PT@queuefilename} +% The following macros handle a simple queue of names. +% With |\PT@addmem|, a name is added to the end of the queue. Using +% |\PT@splitmem|, the first element of the queue is bound to another +% command. As a replacement, we also define |\PT@addfile| and +% |\PT@splitfile|, that implement the queue in a file. +% \begin{macrocode} +\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} + +% the \empty at the end consumes the newline space +\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\strip#1{\def #1{\expandafter\@strip #1\@dummy}} +%\def\@strip#1\@dummy{#1} + +\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 % \end{macrocode} % \end{macro} -% \begin{macro}{\PT@disableomitonce} -% Undefines the next use of omit. -% \begin{macrocode} -\def\PT@disableomitonce - {\def\omit - {\let\omit\PT@origomit}} -% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % \end{macro} % % \subsection{The environment} % % The general idea is to first scan the contents of the environment % and store them in a token register. In a few test runs, the positions -% of the column borders are determined. After that, the columns are sorted -% and the table is typeset, translating the named ranges into appropriate -% calls to |\multicolumn|. +% of the column borders are determined. After that, the table is +% typeset by producing boxes of appropriate size. % % \begin{macro}{\beginpolytable} % This macro starts the environment. It should, however, not % be called directly, but rather in a \LaTeX\ environment. -% We just initialize the +% We initialize the % token register to the empty string and then start scanning. % \begin{macrocode} -\newcommand{\beginpolytable}% +\newcommand*{\beginpolytable}% % \end{macrocode} % We save the current enclosing \LaTeX\ environment in % |\PT@environment|. This will be the |\end| we will be @@ -939,7 +1108,7 @@ \begingroup % new in v0.7: save counters \PT@savecounters - \toks@{}% initialise token register + \PT@toks{}% initialise token register \PT@scantoend} % \end{macrocode} % \end{macro} @@ -950,17 +1119,30 @@ % \end{macrocode} % \end{macro} % \begin{macro}{\PT@scantoend} -% We scan until the next occurence of |\endpolytable| and -% store the tokens. Then we continue with determining the -% column widths. -% \begin{macrocode} +% Whenenver an |\end| is encountered, we check if it really +% ends the current environment. We store the tokens we have +% read. Once we have found the end of the environment, we +% initialize the column queue and column reference, +% |\PT@columnqueue| and |\PT@columnreference|. The new interface +% commands build the queue during the first test run, containing +% the end columns of specific entries of the table. Later, the +% queue is copied to be the reference, and in the typesetting run, +% the information is used to compute the correct box widths. +% We start with an empty queue, and set the reference to |\undefined|, +% because it is not yet needed. TODO: queue and reference must be +% global variables at the moment; try to change that. +% \begin{macrocode} +\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} % \end{macrocode} @@ -974,35 +1156,48 @@ % We let the |\column| command initialize a column % in the first run. % \begin{macrocode} - {\let\column\PT@firstrun@column + {\let\column \PT@firstrun@column % \end{macrocode} % There is the possibility to save or restore columns. % This is new in v0.4. % \begin{macrocode} - \let\savecolumns\PT@savewidths - \let\restorecolumns\PT@restorewidths + \let\savecolumns \PT@savewidths + \let\restorecolumns \PT@restorewidths % \end{macrocode} % We \emph{always} define a pseudo-column |@begin@|. -% This denotes the begin of a row. +% This denotes the begin of a row. We also define a +% pseudo-column |@end@| denoting the end of a row (as +% of v0.8; and I'm not sure if |@begin@| is still +% needed). % \begin{macrocode} - \column{@begin@}{@{}l@{}} + \column{@begin@}{@{}l@{}}% + \column{@end@}{}% \PT@cols=0\relax% % \end{macrocode} % The two other commands that are allowed inside of the -% environment, namely |\fromto| and |\nextline| are +% environment, namely |\fromto| and |\\| are % initialized. The |\fromto| command may increase the % current widths of some columns, if necessary, whereas -% |\nextline| just resets the counter that keeps track -% of the ``current'' column, to |0|. -% \begin{macrocode} - \let\fromto\PT@fromto - \let\nextline\PT@resetcolumn - \PT@changedfalse % nothing has changed so far +% |\\| just resets the counter that keeps track +% of the ``current'' column, to |0|. The command +% |\nextline| is an old name for |\\|. +% \begin{macrocode} + \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 % \end{macrocode} % Now we are ready for a test run. % \begin{macrocode} - \the\toks@ + \the\PT@toks + \@ifundefined{PT@scanning}% + {}{\PT@resetcolumn\relax}% % \end{macrocode} % After the first run, we print extra information. % We use the contents of the macro |\column| to check @@ -1012,9 +1207,9 @@ \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 % \end{macrocode} @@ -1023,11 +1218,11 @@ % won't do much in the other runs. Also, saving and % restoring columns is no longer needed. % \begin{macrocode} - \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 % \end{macrocode} % New in v0.7.1: restore counters after each trial run. % \begin{macrocode} @@ -1041,10 +1236,11 @@ % \begin{macrocode} \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} % \end{macrocode} @@ -1085,7 +1281,8 @@ \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 % \end{macrocode} % Now, each column is assigned a number, starting from @@ -1093,9 +1290,11 @@ % \begin{macrocode} \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@}% % \end{macrocode} % Now is a good time to save table information, if needed later. % We will also compare our computed information with the restored @@ -1104,7 +1303,7 @@ \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 % \end{macrocode} % Finally, we can typeset the table. @@ -1113,41 +1312,52 @@ % \end{macrocode} % \end{macro} % \begin{macro}{\PT@typeset} +% We redefine |\fromto| and |\\| to their +% final meaning in the typesetting process. The +% |\fromto| statements will be replaced by appropriate +% calls to |\multicolumn|, whereas the |\\| will +% again reset the counter for the current column, but +% also call the table environment's newline macro. +% Again, |\nextline| is allowed as an old name for |\\|. % \begin{macrocode} \def\PT@typeset + {\PT@typeout@{Typesetting the table ...}% + \let\PT@processentry \PT@placeinbox + \let\PT@scanbegin \PT@scanbeginwidth + \let\\= \PT@resetandcr + \let\nextline \PT@resetandcr + \PT@prepareread\PT@columnreference\PT@columnqueue % \end{macrocode} -% As a first step, we generate the table's preamble and -% print it for debugging purposes. +% The environment that will be opened soon, can, if +% if happens to be |tabular| or |array|, redefines |\\| +% once more, and will redefine it to |\@arraycr|. To +% prevent this, we also set |\@arraycr| to our command. % \begin{macrocode} - {\PT@typeout@{Typesetting the table ...}% - \PT@prelazylist - \edef\PT@temp{@{}\Execute{\Map\PT@preamble\PT@sortedlist}}% - \PT@postlazylist - %\PT@typeout@{Preamble: \PT@temp}% + \let\@arraycr \PT@resetandcr % \end{macrocode} -% Now, we redefine |\fromto| and |\nextline| to their -% final meaning in the typesetting process. The -% |\fromto| statements will be replaced by appropriate -% calls to |\multicolumn|, whereas the |\nextline| will -% again reset the counter for the current column, but -% also call the table environment's newline macro. +% The array environments keep each line in a group; therefore +% |\PT@resetcolumn|, when executed during the linebreak, will +% not affect the current column counters. By having +% |\PT@resetcolumn| before entering the environment, we ensure +% that the group reset will have the correct effect anyway. % \begin{macrocode} - \let\fromto\PT@multicolumn \PT@resetcolumn % we are at the beginning of a line - \let\nextline=\PT@resetandcr % \end{macrocode} % Now we start the tabular environment with the -% computed preamble. +% computed preamble. We redefine the |\\| to whatever +% the environment dictates. % \begin{macrocode} - \expandafter\PT@begin\expandafter{\PT@temp}% + \PT@begin% % \end{macrocode} % Run, and this time, typeset, the contents. % \begin{macrocode} - \the\toks@ + \the\PT@toks + \PT@fill% new in 0.7.3: balance the last line % \end{macrocode} % End the array, close the group, close the environment. % We are done! % \begin{macrocode} + \PT@finalize% finalize the queue (possibly close file) \PT@end \endgroup \PT@typeout@{Finished.}% @@ -1155,12 +1365,173 @@ % \end{macrocode} % \end{macro} % +% \subsection{New interface} +% +% From v0.8 on, we offer a more convenient user interface +% for the programming of the columns. +% +% \begin{macro}{\PT@from} +% \begin{macro}{\PT@fromopt} +% \begin{macro}{\PT@toopt} +% The macro |\PT@from| is bound to |\=| in a polytable environment, +% and used to move to the named column specified by its argument. The +% previous column is closed. The variant |\PT@fromopt| is bound to +% |\>| and takes an optional argument instead of a mandatory, which defaults +% to the current column name followed by a single dot |.|. We use an +% empty default which is then redefined to make it easier for the +% user to use the default definition (TODO: explain better). +% Otherwise, it is like |\PT@from|. +% +% The macro |\PT@toopt| is bound to |\<|. Where |\PT@from| ends an +% entry if one is active, and starts a new one, the |\PT@toopt| +% variant only ends the currently active entry. +% \begin{macrocode} +\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} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\PT@dofrom} +% \begin{macrocode} +\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 +% \end{macrocode} +% Here, |\PT@scanbegin| will scan free or using the width, depending +% on the run we are in. +% \end{macro} +% +% \begin{macro}{\PT@fromto} +% This is the implementation for the old explicit |\fromto| +% macro. It takes the start and end columns, and the contents. +% It can be used for all runs. +% \begin{macrocode} +\newcommand*{\PT@fromto}[3]% +% \end{macrocode} +% We allow a |\fromto| to follow a new-style command, but we reset +% the current column to undefined, so no text may immediately +% follow a |\fromto| command. +% \begin{macrocode} + {\PT@checkendentry{#1}% + \let\PT@scanning\undefined +% \end{macrocode} +% We check a switch to prevent nested |\fromto|s. +% \begin{macrocode} + \PT@infromto + \def\PT@infromto{% + \PackageError{polytable}{Nested fromto}{}}% +% \end{macrocode} +% Here, the real work is done: +% \begin{macrocode} + \let\PT@currentpreamble\relax% necessary for preparescan + \PT@preparescan{#1}{#2}% + \PT@scanbegin #3\PT@scanend% defines \@curfield + \PT@processentry{#1}{#2}% +% \end{macrocode} +% The commands |\PT@scanbegin| and |\PT@processentry| will perform +% different tasks depending on which run we are in. +% +% We ignore spaces after the |\fromto| command. +% \begin{macrocode} + \let\PT@infromto\empty + \ignorespaces} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PT@checkendentry} +% This macro checks if we are currently scanning an entry. If so +% (this is detected by checking if |\PT@scanning| is defined), +% we close the entry and handle it (in |\PT@endentry|) +% before returning. The argument +% is the name of the column from which this macro is called. +% \begin{macrocode} +\newcommand*{\PT@checkendentry}% takes one argument + {\@ifundefined{PT@scanning}% + {\let\PT@temp\@gobble}% + {\let\PT@temp\PT@endentry}% + \PT@temp} +%\newcommand*{\PT@checkendentry}% takes one argument +% {\@ifundefined{PT@post@preamble}% +% {\let\PT@temp\PT@discardentry}% +% {\let\PT@temp\PT@endentry}% +% \PT@temp} + +%\newcommand*{\PT@discardentry}[1]% +% {\let\PT@postpreamble=\empty\PT@scanend} + +\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} +% \end{macrocode} +% \end{macro} +% % \subsection{The trial runs} % % For each column, we store information in macros that are -% based on the column name. We store a column's type (i.e.~its +% based on the column name. We store a column's type (i.e., its % contribution to the table's preamble), its current width -% (i.e.~its the horizontal position where the column will start +% (i.e., its the horizontal position where the column will start % on the page), and later, its number, which will be used for % the |\multicolumn| calculations. % @@ -1175,11 +1546,11 @@ % field to prevent warnings for columns that have been defined % via |\PT@setmaxwidth| -- see there for additional comments. % New in v0.4.2: We allow redefinition of width if explicitly -% specified, i.e. not equal to 0pt. +% specified, i.e., not equal to 0pt. % \begin{macrocode} \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 @@ -1188,7 +1559,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 @@ -1219,48 +1597,56 @@ % \end{macro} % \begin{macro}{\PT@checkcoldefined} % This macro verifies that a certain column is defined and -% produces an error message if it is not. +% produces an error message if it is not. New in v0.8: this +% macro implicitly defines the column if we have a default +% column specifier. % \begin{macrocode} \def\PT@checkcoldefined #1% {\@ifundefined{PT@col@#1.type}% - {\PackageError{polytable}{Undefined column #1}{}}{}}% + {\@ifundefined{PT@defaultcolumnspec}% + {\PackageError{polytable}{Undefined column #1}{}} + {\PT@debug@{Implicitly defining column #1}% + \PT@expanded{\column{#1}}{\PT@defaultcolumnspec}}}{}% +% \end{macrocode} +% We also have to define columns with empty specifiers. This +% situation can occur if save/restoring columns that are defined +% by default specifiers. +% \begin{macrocode} + \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} % \end{macrocode} % \end{macro} -% \begin{macro}{\PT@fromto} +% \begin{macro}{\PT@checkwidth} % Most of the work during the trial runs is done here. We increase % the widths of certain columns, if necessary. Note that there % are two conditions that have to hold if |\fromto{A}{B}| is encountered: % \begin{itemize} % \item the width of |A| has to be at least the width of the current -% (i.e.~previous) column. +% (i.e., previous) column. % \item the width of |B| has to be at least the width of |A|, plus the % width of the entry. % \end{itemize} % \begin{macrocode} -\def\PT@fromto #1#2#3% -% \end{macrocode} -% We start by checking a switch. -% \begin{macrocode} - {\PT@infromto - \def\PT@infromto{% - \PackageError{polytable}{Nested fromto}{}}% -% \end{macrocode} -% Next, we check that both columns are defined. -% \begin{macrocode} - \PT@checkcoldefined{#1}% - \PT@checkcoldefined{#2}% +\def\PT@checkwidth #1#2% + {\PT@checkcoldefined{#2}% first column should have been checked before % \end{macrocode} % Here, we check the first condition. % \begin{macrocode} \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 @@ -1271,62 +1657,35 @@ {\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 % \end{macrocode} -% To test the second condition, we have to test-typeset the contents of -% the column, contained in |#3|. We prepare a ``safe environment'' for these -% contents. We determine whether we are in math mode -% or not, put the contents into an hbox in the same mode, and we are -% typesetting the contents in the same environment as we will typeset the -% table in the end. -% \begin{macrocode} - \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 -% \end{macrocode} -% Now begins the real comparison. +% We assume that the current field is typeset in |\@curfield|; we +% can thus measure the width of the box and then test the second condition. % \begin{macrocode} + \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 @@ -1337,26 +1696,24 @@ \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 % \end{macrocode} -% Finally, we update the current column to |#2|, and, of course, we -% ignore spaces after the |\fromto| command. +% Finally, we update the current column to |#2|. % \begin{macrocode} - \def\PT@currentcol{PT@col@#2}% - \let\PT@infromto\empty - \ignorespaces}% + \def\PT@currentcol{PT@col@#2}} % \end{macrocode} % \end{macro} % \begin{macro}{\PT@checkrerun} @@ -1371,19 +1728,26 @@ % \end{macrocode} % \end{macro} % \begin{macro}{\PT@resetcolumn} -% At the end of a line, we reset the current column to the special -% column |@begin@|. +% If the end of a line is encountered, we stop scanning the current +% entry, and reset the current column. % \begin{macrocode} \newcommand*{\PT@resetcolumn}[1][]% - {\let\PT@currentcol\PT@nullcol} + {\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 + } % \end{macrocode} % \end{macro} % \begin{macro}{\PT@nullcol} % The name of the |@begin@| column as a macro, to be able to compare -% to it with |\ifx|. +% to it with |\ifx|; dito for the |@end@| column. % \begin{macrocode} -\def\PT@nullcol - {PT@col@@begin@} +\def\PT@nullcol{PT@col@@begin@} +\def\PT@endcol{PT@col@@end@} % \end{macrocode} % \end{macro} % @@ -1394,39 +1758,45 @@ % We just provide a few additional commands to facilitate % their use. % -% \begin{macro}{\Execute} -% \begin{macro}{\Sequence} -% With |\Execute|, a list of commands (with sideeffects) can +% \begin{macro}{\PT@Execute} +% \begin{macro}{\PT@Sequence} +% With |\PT@Execute|, a list of commands (with sideeffects) can % be executed in sequence. Usually, first a command will be % mapped over a list, and then the resulting list will be % executed. % \begin{macrocode} -\def\Execute{\Foldr\Sequence\empty} -\def\Sequence #1#2{#1#2} +\def\PT@Execute{\Foldr\PT@Sequence\empty} +\def\PT@Sequence #1#2{#1#2} % \end{macrocode} % \end{macro} % \end{macro} -% \begin{macro}{\ShowColumn} +% \begin{macro}{\PT@ShowColumn} % This is a debugging macro, that is used to output the list % of columns in a pretty way. The columns internally get % prefixes to their names, to prevent name conflicts with % normal commands. In the debug output, we gobble this prefix % again. % \begin{macrocode} -\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@ +\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} % \end{macrocode} % \end{macro} -% \begin{macro}{\Print} -% Prints a list of columns, using |\ShowColumn|. +% \begin{macro}{\PT@Print} +% Prints a list of columns, using |\PT@ShowColumn|. % \begin{macrocode} -\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}} % \end{macrocode} % \end{macro} % @@ -1469,192 +1839,70 @@ % % \subsection{Typesetting the table} % -% \begin{macro}{\PT@preamble} -% The table's preamble is created by mapping this function -% over the column list and then |\Execute|ing \dots -% New: We always use |l|, as the specific type is always -% given by the |\multicolumn|. -% Yet new: We use |@{}l@{}|, to prevent column separation -% space from being generated. -% \begin{macrocode} -\def\PT@preamble #1% -% {\csname #1.type\endcsname} -% {l} - {l@{}} -% \end{macrocode} -% \end{macro} -% % Remember that there are three important macros that % occur in the body of the polytable: |\column|, |\fromto|, -% and |\nextline|. The |\column| macro is only really used +% and |\\|. The |\column| macro is only really used % in the very first trial run, so there is nothing new % we have to do here, but the other two have to be % redefined. % % \begin{macro}{\PT@resetandcr} -% This is what |\nextline| does in the typesetting phase. -% It resets the current column, but it also calls the table -% environment's newline macro |\\| \dots +% This is what |\\| does in the typesetting phase. +% It resets the current column, but it also calls the surrounding +% environment's newline macro |\PT@cr| \dots % If we are \emph{not} in the last column, we insert % an implicit |fromto|. This is needed for the boxed environment to % make each column equally wide. Otherwise, if the boxed environment % is typeset in a centered way, things will go wrong. % \begin{macrocode} -\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]} -% \end{macrocode} -% \end{macro} -% -% \begin{macro}{\PT@multicolumn} -% All the |\fromto|s are expanded into |\multicolumn| calls, -% which is achieved by this quite tricky macro. Part of the -% trickyness stems from the fact that a |\multicolumn|'s -% expansion starts with |\omit| which is a plain \TeX\ primitive -% that causes the template for a table column to be ignored. -% But |\omit| has to be the first token (after expansion) -% in a column to be valid, which is why the alignment tabs |&| -% and the |\multicolumn| calls have to be close to each other. -% It would maybe be better to call |\omit| manually and hack -% |\multicolumn| later!! -% -% This macro gets three arguments. The first is the column -% in which the entry begins, the second is the column -% \emph{before} which the entry stops, and the third contains -% the contents that should be typeset in this range. -% \begin{macrocode} -\def\PT@multicolumn #1#2#3% -% \end{macrocode} -% We start by producing an |\omit| to indicate that we want -% to ignore the column format that has been specified in the -% table header. After that, we disable the |\omit| command, -% because we will later call |\multicolumn| which contains -% another one. A second |\omit| would usually cause an error. -% TODO: Make this work to simplify the rest. For now, we don't -% use this. -% \begin{macrocode} - {%\omit\PT@disableomitonce -% \end{macrocode} -% We skip ahead until we are in the column in which the entry -% should start. For this, we store the -% number of the column we want to start in and subtract -% the current columns number. If the current column is the -% null column, we have to adjust by $-1$ which is not nice, -% but necessary \dots -% In 0.4.3: added missing relax after |\global\advance|. -% \begin{macrocode} - % 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 -% \end{macrocode} -% We now skip by inserting alignment tabs and using a -% multicolumn with no content. It might be nicer to just -% use as many tabs as necessary, because we could do with -% less case distinctions. The current value of |\PT@cols| -% indicates how many tabs we have to insert, minus one. -% We will insert that one tab (which is the minimum we have -% to insert) just before we insert the content, and first -% deal with the extra tabs. -% \begin{macrocode} - \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 -% \end{macrocode} -% So there are extra tabs necessary. -% \begin{macrocode} - \ifnum\PT@cols>1\relax -% \end{macrocode} -% We can use a multicolumn to save time. -% \begin{macrocode} - \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 -% \end{macrocode} -% We now are in the correct column and can print the contents. Again, -% we have to check if we have to use a |\multicolumn|. If we do, we will -% use the formatting type of the first column that it spans, in contrast -% to normal |\multicolumn|s which always take an extra parameter to -% determine how to format their contents. An optional parameter should -% be introduced here to make overriding the default template possible!! -% New: we always use a |\multicolumn|, otherwise spacing will be -% inconsistent sometimes. -% \begin{macrocode} - \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 -% \end{macrocode} -% We reset the current column to |#2| and ignore spaces after -% the command. Then we are done \dots -% \begin{macrocode} - % set current column - \def\PT@currentcol{PT@col@#2}% - \ignorespaces}% + \let\PT@scanning\undefined% needed for resetcolumn + \PT@resetcolumn\PT@cr} % \end{macrocode} % \end{macro} % -% \begin{macro}{\PT@NextCol} -% We hide the tab |&| in a macro, mostly to be able to -% add debugging output. -% \begin{macrocode} -\def\PT@NextCol - {\PT@typeout@{ & }% - &}% +% \begin{macro}{\PT@fill} +% This variant of |\PT@resetandcr| is used at the end of +% the environment, to insert a blank box for the |pboxed| +% environment to balance the widths of all lines. It does +% not start a new line, and does nothing if the current +% column is |@begin@|. TODO: extract commonalities with +% |\PT@resetandcr| into a separate macro. +% \begin{macrocode} +\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} % \end{macrocode} % \end{macro} % % \begin{macro}{\PT@placeinbox} -% This macro is an alternative for |\PT@multicolumn|. It can be used -% to produce a simple box-based output instead of a table. We use +% This macro is the final-run replacement for |\PT@checkwidth|. We use % the precomputed width information to typeset the contents of the % table in aligned boxes. The arguments are the same as for -% |\PT@multicolumn|, i.e.~the start and the end columns, plus the contents. +% |\PT@checkwidth|, i.e., the start and the end columns, and the assumption +% that the entry is contained in the box |\@curfield|. % \begin{macrocode} -\def\PT@placeinbox#1#2#3% +\def\PT@placeinbox#1#2% % \end{macrocode} % We start by computing the amount of whitespace that % must be inserted before the entry begins. We then insert that amount @@ -1663,56 +1911,130 @@ {\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}% -% We continue by computing the width of the current entry. +% \end{macrocode} +% The important part is to use the pre-typeset box |\@curfield|. +% This produces real output! % \begin{macrocode} - \PT@colwidth=\@nameuse{PT@col@#2.max}% - \advance\PT@colwidth by -\@nameuse{PT@col@#1.max}\relax% + \PT@typeout@{adding box \space\space of width % + \expandafter\PT@aligndim\the\wd\@curfield\@@ + (\PT@aligncol{#1} -> \PT@aligncol{#2})}% + \box\@curfield % \end{macrocode} -% In the previous version, we really generated a hbox at this place. -% However, this is not so nice with respect to spacing and tabular -% specifiers. Therefore, we now use either an array or a tabular -% environment that can reuse the given specifier. +% Finally, we have to reset the current column and +% ignore spaces. % \begin{macrocode} + \def\PT@currentcol{PT@col@#2}% + \ignorespaces}% +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PT@preparescan} +% The macro |\PT@preparescan| sets the two macros |\PT@scanbegin| +% and |\PT@scanend| in such a way that they scan the input between +% those two macros and place it in a box. The width of the box is +% determined from the given column names. The name |@end@| can be +% used as a column name is a free scan (a scan without knowing the +% real end column) is desired. To allow redefinition of the preamble, +% we assume that |\PT@currentpreamble| is defined to |\relax| if +% we want it set normally dugin |\PT@preparescan|. +% \begin{macrocode} +\def\PT@preparescan#1#2% +% First, we check that both columns are defined. This will +% actually define the columns if implicit column definitions are +% enabled. +% \begin{macrocode} + {\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 + \ifx\PT@currentpreamble\relax + \PT@expanded{\PT@expanded{\def\PT@currentpreamble}}% + {\csname PT@col@#1.type\endcsname}% + \fi % \end{macrocode} -% Now we proceed very much like in the test run(s), but we -% really output the box, and we use a specific width. +% Now, we make a preamble using the macro |\@mkpream| from the +% \textsf{array} package. This macro takes a format string as +% argument, and defines |\@preamble| as a result, where |\@sharp| +% occurs in the positions of the column contents. +% We perform the operation in a group to prevent certain redefinitions +% from escaping. The |\@preamble| is set globally anyway. % \begin{macrocode} - \hb@xt@\PT@colwidth{% - \expandafter\@mkpream\expandafter{\PT@currentpreamble}% - \def\@sharp{\strut #3}% - %\show\@preamble - \@preamble}% + {\PT@expanded\@mkpream\PT@currentpreamble% + \@addtopreamble\@empty}% + \let\CT@row@color\relax% colortbl compatibility % \end{macrocode} -% Finally, we have to reset the current column and -% ignore spaces. +% We split the preamble at the position of the |\@sharp|, using +% some tricks to make sure that there really is precisely one +% occurrence of |\@sharp| in the resulting preamble code, and +% producing an error otherwise. The splitting defines +% |\PT@pre@preamble| and |\PT@post@preamble|. With those and +% the computed |\PT@colwidth|, the scan is successfully prepared. % \begin{macrocode} - \def\PT@currentcol{PT@col@#2}% - \ignorespaces}% + \expandafter\PT@splitpreamble\@preamble\@sharp\PT@nil} +% \end{macrocode} +% +% We now define the splitting of the preamble. +% \begin{macrocode} +\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}}% +% \end{macrocode} +% +% Finally, we can define the scan environment, which depends on +% all the other macros being defined correctly. The macro +% |\PT@scanbegin| is not defined directly, but will be set +% to |\PT@scanbeginfree| during the trial runs and to +% |\PT@scanbeginwidth| during the final run. +% \begin{macrocode} +\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} % \end{macrocode} % \end{macro} % @@ -1726,8 +2048,6 @@ % using the same information should have the same column widths, % which means that some information might need to be passed back. % Therefore, we need to write to an auxiliary file. -% TODO: As implemented now, this only really works in conjunction -% with the |pboxed| environment. % % Both |\savecolumns| and |\restorecolumns| are mapped to the internal % commands |\PT@savewidths| and |\PT@restorewidths|. Both take an @@ -1774,7 +2094,7 @@ \else \expandafter\let\csname PT@col@#2.trusted\endcsname=#1% \fi - \column{#2}{}} + \column{#2}{}}% % \end{macrocode} % \end{macro} % @@ -1797,16 +2117,11 @@ % % \begin{macro}{\PT@loadtablebyname} % Often, we want to access table information by a column width set -% name. We make the maximum column widths accessible, but also the -% information from the previous table that has been using the same -% column width set. +% name. % \begin{macrocode} \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}}% -% \advance\PT@cols by \PT@restoredcols\relax -% \expandafter\PT@appendmacro\expandafter\PT@allcols -% \expandafter{\PT@restoredallcols}} + \PT@loadtable{\csname PT@widths@#1\endcsname}}% % \end{macrocode} % \end{macro} % @@ -1816,13 +2131,12 @@ % all important information for further use. % \begin{macrocode} \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}} % \end{macrocode} @@ -1836,6 +2150,10 @@ \def\PT@temp{#2}% \ifx\PT@temp\PT@nullcol \PT@typeout@{skipping nullcol ...}% +% This was a bug: end column cannot be skipped, because +% it can change. +% \else\ifx\PT@temp\PT@endcol +% \PT@typeout@{skipping endcol ...}% \else \PT@typeout@{max=\csname #2.max\endcsname, % width=\csname #2.width\endcsname, % @@ -1847,15 +2165,16 @@ \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% +% \fi \fi } % \end{macrocode} @@ -1906,7 +2225,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}% @@ -1940,8 +2259,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}{}% @@ -1952,7 +2270,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}% @@ -1978,7 +2296,7 @@ {\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} % \end{macrocode} @@ -1989,35 +2307,58 @@ % \begin{macrocode} \def\PT@write@column #1#2% {\noexpand\maxcolumn^^J% - {\StripColumn{#2}}% + {\PT@StripColumn{#2}}% {\@nameuse{#2#1}}}% % \end{macrocode} % \end{macro} % % \subsection{The user environments} % -% It remains to define the three environments to be +% It remains to define the environments to be % called by the user. +% New in v0.8: we add the environments +% |ptboxed| and |pmboxed| for text-mode and math-mode +% boxed environments. In turn, we remove |ptabular| and +% |parray|, and make the point to their new counterparts. % \begin{macrocode} -\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 +% \end{macrocode} +% The following assignment is a hack. If |pboxed| is called +% from within another |tabular|- or |array|-environment, then +% this sometimes does the right thing. +% \begin{macrocode} + \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 + % \end{macrocode} % % That is all. 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'. diff --git a/Master/texmf-dist/tpm/polytable.tpm b/Master/texmf-dist/tpm/polytable.tpm index 237d2484b33..c1cc15f5ba7 100644 --- a/Master/texmf-dist/tpm/polytable.tpm +++ b/Master/texmf-dist/tpm/polytable.tpm @@ -3,7 +3,7 @@ <rdf:Description about="http://texlive.dante.de/texlive/Package/polytable.zip"> <TPM:Name>polytable</TPM:Name> <TPM:Type>Package</TPM:Type> - <TPM:Date>2006/01/11 23:56:17</TPM:Date> + <TPM:Date>2005/11/21 13:01:43</TPM:Date> <TPM:Version></TPM:Version> <TPM:Creator>rahtz</TPM:Creator> <TPM:Title>Tabular-like environments with named columns.</TPM:Title> @@ -17,12 +17,12 @@ layouts, for example for program code, are possible. <TPM:Author>Andres Loeh</TPM:Author> <TPM:Size>94376</TPM:Size> <TPM:Build/> - <TPM:RunFiles size="22195"> + <TPM:RunFiles size="27676"> texmf-dist/tex/latex/polytable/polytable.sty texmf-dist/tpm/polytable.tpm </TPM:RunFiles> - <TPM:DocFiles size="352">texmf-dist/doc/latex/polytable/README</TPM:DocFiles> - <TPM:SourceFiles size="71829"> + <TPM:DocFiles size="355">texmf-dist/doc/latex/polytable/README</TPM:DocFiles> + <TPM:SourceFiles size="84226"> texmf-dist/source/latex/polytable/polytable.dtx texmf-dist/source/latex/polytable/polytable.ins </TPM:SourceFiles> |