diff options
author | Karl Berry <karl@freefriends.org> | 2009-11-19 18:36:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-11-19 18:36:45 +0000 |
commit | ea6dc95d491201abe5f09dd2ce16ccc4bd9a9f69 (patch) | |
tree | 9f2fc24c9e5b751a76bd752b5f04b51d14fe95a0 /Master | |
parent | 7efd7dd40e467960756a4a1391f05ce085c0c196 (diff) |
widetable 1.1 (26oct09)
git-svn-id: svn://tug.org/texlive/trunk@16082 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/widetable/manifest.txt | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/widetable/widetable.pdf | bin | 240972 -> 255170 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/widetable/widetable.dtx | 167 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/widetable/widetable.sty | 63 |
4 files changed, 209 insertions, 26 deletions
diff --git a/Master/texmf-dist/doc/latex/widetable/manifest.txt b/Master/texmf-dist/doc/latex/widetable/manifest.txt index dcff5733324..f7f720ae83d 100644 --- a/Master/texmf-dist/doc/latex/widetable/manifest.txt +++ b/Master/texmf-dist/doc/latex/widetable/manifest.txt @@ -2,7 +2,8 @@ This small package is intended to be a second resource when typesetting tables that would look a little better if they were set with a specified width. It differs from tabularX since here all cells are widened by working on the inter column glue, not on the measure of certain specified textual cells as -it is done with tabularX. +it is done with tabularX. Computations may be executed by means of the e-TeX +extensions if they are available. This work may be distributed and/or modified under the @@ -31,4 +32,4 @@ The derived files are widetable.pdf (obtained by pdflatexing widetale.dtx) widetable.sty (obtained by (la)texing widetale.ins) -Claudio Beccari, 28 September 2009
\ No newline at end of file +Claudio Beccari, 26 October 2009
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/widetable/widetable.pdf b/Master/texmf-dist/doc/latex/widetable/widetable.pdf Binary files differindex dfd31717dd3..35e74407a27 100644 --- a/Master/texmf-dist/doc/latex/widetable/widetable.pdf +++ b/Master/texmf-dist/doc/latex/widetable/widetable.pdf diff --git a/Master/texmf-dist/source/latex/widetable/widetable.dtx b/Master/texmf-dist/source/latex/widetable/widetable.dtx index f2560db3f9f..282ead13f02 100644 --- a/Master/texmf-dist/source/latex/widetable/widetable.dtx +++ b/Master/texmf-dist/source/latex/widetable/widetable.dtx @@ -5,7 +5,7 @@ %<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01] %<package>\ProvidesPackage{widetable}% %<*package> - [2009/07/21 v.1.0 Package for typesetting specified width tables] + [2009/10/26 v.1.1 Package for typesetting specified width tables] %</package> %<*driver> \documentclass{ltxdoc} @@ -31,7 +31,7 @@ \end{document} %</driver> % \fi -% \CheckSum{222} +% \CheckSum{314} % \begin{abstract} % This package allows to typeset tables of specified width, provided they fit in one % page. Instead of introducing an infinite stretching glue, which has an @@ -51,7 +51,7 @@ % and version 1.3 or later is part of all distributions of LaTeX % version 2003/12/01 or later. % -% This work has the LPPL maintenance status "maintained". +% This work has the LPPL maintenance status ``maintained''. % % The Current Maintainer of this work is Claudio Beccari % @@ -59,7 +59,7 @@ % given in the file `manifest.txt'. % % The list of derived (unpacked) files belonging to the distribution -% and covered by LPPL is defined by the unpacking scripts (with +% and covered by the LPPL is defined by the unpacking scripts (with % extension .ins) which are part of the distribution. % %\section{Introduction} @@ -67,12 +67,12 @@ % a specified width, it is necessary to introduce in the delimiter declaration |@{...}| % of (possibly) the first cell of the model row a declaration such as % \begin{verbatim} -% \extraclosep{\fill} +% \extracolsep{\fill} % \end{verbatim} % in addition to other possible printable delimiters, such as vertical lines, and % other fixed spacing commands. The effect is that the extra stretchable glue % operates only on the left of each cell \emph{after} (to the \emph{right} of) -% the cell that received the declaration; the first cell will never get larger +% the cell that received the declaration; the first cell will never get larger % in spite of the presence of this glue. % % Another package, |tabularX|, normally distributed by the \LaTeX\,3 Team with @@ -80,7 +80,7 @@ % provided they contain only text. These expandable cells are identified with the % column identifier |X|; this identifier defines a paragraph-like cell, the width of % which gets determined after some runs of the typesetter on the same source -% tabular material, so as to find out the correct width of the textual columns. +% tabular material, so as to find out the correct width of the textual columns. % % The approach here is a little bit different: the cell contents need not be textual % and no cell width is determined in one or more runs of the typesetter; instead the @@ -176,11 +176,30 @@ % % Of course there is no limit to a better solution; nevertheless the one I % implemented never crashed in any real world situation I tested. +% +% \section{Using the \boldmath$\varepsilon$-\TeX\ facilies} +% On the other side if the |etex| facilies are available a different approach may +% be taken; |etex| natively performs several calculations connected by mathematical +% operations. In particular the scaling operation such as a dimension multiplied by +% a number ad immediately divided by another number is performed by storing the +% intermediate result into a 64-bit register, so that no overflow takes place if the +% operands represent lengths or the scaled-point numbers equivalent to these lengths. +% If the |etex| facilties are available, other calculations are more easily performed +% in order to determine directly the scaled length it is necessary to determine. % +% Therefore this package works equally well with old engines that do not have the +% |etex| functionality and with modern engines that possess this functionality; +% of course modern engines work much better and faster. +% % \section{Acknowledgements} % I must deeply thank Enrico Gregorio for the revision of this package macros and % for his wise suggestions about the correct programming style. If some glitch still % remains in the programming style, that is just my fault. +% +% I also thank very much Peter R.~Wilson who wrote the excellent class |memoir.cls| +% and its formidable decumentation. I copied from his code the necessary lines for +% testing the |etex| functionality of the engine that is processing this file. +% % \StopEventually{} % % \section{Implementation} @@ -213,6 +232,44 @@ \countdef\wt@Den=4 \countdef\wt@I=6 \def\wt@segno{} + +% \end{macrocode} +% +% We copy from |memoir.cls| the relevant lines and modify them in order to make +% them suitable for this |widetable| package. The relevant point is that a new |\if| +% is defined, |\ifetex|, and is immediately set to |true| or |false| depending on the +% fact that the engine being used has the |etex| functionalities. Actually all modern +% engines have these functionalites, but they might have been disabled; old engines +% lack these functionalites. May be, if a real \textsf{ifetex.sty} package existed, it +% would not be necessary to do any testing and to emulate its inner workings. May be +% this package could more efficiently detect it the current engine might be conforming +% to the |etex| specifications, but the latter have been disabled. In any case if the +% package existed, its macros would be used instead of the emulated ones. +% \begin{macrocode} +\newif\ifm@mifetex + \m@mifetexfalse +\IfFileExists{ifetex.sty}{\RequirePackage{ifetex}\relax}{% + \PackageWarningNoLine{widetable}{% + If there is an `ifetex' package then it is not installed.\MessageBreak + The package is being emulated}% +\m@mifetextrue +\newif\ifetex + \etexfalse +\ifx\eTeXversion\undefined +\else + \ifx\eTeXversion\@undefined + \else + \ifx\eTeXversion\relax + \else + \ifnum\eTeXversion>0\relax + \etextrue + \fi + \fi + \fi +\fi +%%\EmulatedPackage{ifetex}[2008/07/23]% from memoir.cls +} + % \end{macrocode} % % We then start the definition of the division algorithm; the name of the macro and @@ -238,7 +295,9 @@ % we need just use this name, instead of assigning strange numerical values; the % only thing we must pay attention to is to strip the ``pt'' information from this % ``infinite'' dimension, since the quotient must be a dimensionless signed -% fractional decimal number. +% fractional decimal number. Notice that in this apllication the denominator never +% vanishes, so that actually some of the tests are useless; nevertheless if the macro +% is copied and used in other packages they might turn up to be essential. % % Otherwise we load the operands in similarly named counter registers, effectively % transferring the dimension integer number of scaled points to integer variables @@ -282,6 +341,7 @@ \edef\x{\noexpand\endgroup\noexpand\def\noexpand#3{\wt@segno\wt@Q}} \x } + % \end{macrocode} % % The cycle for the long division consists in multiplying the remainder in @@ -297,17 +357,52 @@ \wt@Numer=10\wt@Numer \wt@Num=\wt@Numer \divide\wt@Num\wt@Den \edef\wt@q{\number\wt@Num}\edef\wt@Q{\wt@Q\wt@q}% \advance\wt@Numer -\wt@q\wt@Denom} + % \end{macrocode} % +% On the other hand for exploiting the facilites of the |etex| engine we define +% a new command |\scala| (`` imperative of the verb to scale'') that performs +% the scaling oepration by executing first a multiplication and then a division, +% while accumulating the intermediate result into a 64-bit register so as not to +% loose precision. Therefore this new command receives four arguments: the first +% is the length to be scaled, the second and the third are two lengths the ratio +% of which forms the scaling factore, and the foruth is the resulting scaled +% dimension. The numerator and the denominator lengths whose ratio defines the +% scaling factor are stored into two numerical registers as scaled points; +% therefore the length to be scaled is first multiplied by the numerator integer +% number of scaled points, and immediately divided by the denominator integer number +% of scaled points; the result is assigned to a temmporary dimension that on exit +% will be assigned to the fourth macro argument. in order to preserve all the +% variable and register contents, everything is done within a group and the final +% result is thrown out of the group by means of the usual trick already used in the +% |\dividi| macro above. +% \begin{macrocode} +\def\scala#1\per#2\diviso#3\in#4{\begingroup +\wt@Num #2\relax \wt@Den #3\relax +\ifnum\wt@Den<\z@ \wt@Den -\wt@Den \wt@Num -\wt@Num \fi +\ifnum\wt@Den=\z@ + \@tempdima\ifnum\wt@Num<0-\fi\maxdimen +\else + \@tempdima\dimexpr#1*\wt@Num/\wt@Den\relax +\fi +\edef\x{\noexpand\endgroup\noexpand\def\noexpand#4{\the\@tempdima}}% +\x} + +% \end{macrocode} +% At this point it will be the |widetable| environment responsibility to call |\scala| +% or |\dividi| according to the availaility of the |etex| facilities specified by the +% status of the |\ifetex| test. +% % Now we define the dimension register that is to contain the desired table width. -% We further define the start of the tabular typesetting that will be useful in a while. -% Actually the table preamble is being saved into a macro, so that when the +% We further define the start of the tabular typesetting that will be useful in +% a while. Actually the table preamble is being saved into a macro, so that when the % \meta{width} and the \meta{column descriptors} are given to the opening % environment statement, these saved quantities can be used again and again. -% % \begin{macrocode} \newdimen\wt@width + \def\wt@starttabular{\expandafter\tabular\expandafter{\wt@preamble}} + % \end{macrocode} % % The environment opening as well as the environment closing are defined by @@ -321,6 +416,7 @@ \def\widetable#1#2{% \def\@tempC{widetable}\setlength{\wt@width}{#1}% \def\wt@preamble{#2}\wt@getTable} + % \end{macrocode} % % A new boolean, |wt@scartare|, is defined; this boolean variable will be set true in @@ -332,6 +428,7 @@ % delimited by a pair of matching braces. % \begin{macrocode} \newif\ifwt@scartare\wt@scartarefalse + % \end{macrocode} % % The closing statement will acttually do the greatest part of the job. First of all if @@ -348,8 +445,10 @@ % The arbitrary constant of 1\,cm is $t_1$, and the specified width $l$ is the % dimension saved into |\wt@width|. The subtractions are operated directly on the % dimension registers |\wt@width| (the numerator) and on the auxiliary register -% |\@tempdimenb|; the |\dividi| command is executed in order to get the quotient -% in |\@tempA|, and the final definitive value of |\tabcolsep| is eventually computed. +% |\@tempdimenb|; the |\dividi| or the |\scala| command, depending on the |\ifetex| +% status, is executed in order to get the scaling ratio in |\@tempA|, if the |etex| +% facilites are not available, and, in any case, the final definitive value of +% |\tabcolsep| is eventually computed. % The table is finally typeset without using boxes, while the contents of box zero % and two are restored upon exiting the environment to any value they might have % contained before entering |widetable|. @@ -365,12 +464,17 @@ \advance\wt@width-\wd\z@ \@tempdimb=\wd\tw@ \advance\@tempdimb-\wd\z@ - \dividi\wt@width\per\@tempdimb\in\@tempA - \tabcolsep=\@tempA\tabcolsep + \ifetex + \scala\tabcolsep\per\wt@width\diviso\@tempdimb\in\tabcolsep\relax + \else + \dividi\wt@width\per\@tempdimb\in\@tempA + \tabcolsep=\@tempA\tabcolsep + \fi \wt@starttabular\the\toks@\endtabular \fi \ignorespacesafterend } + % \end{macrocode} % % Of course other actions must be performed before executing the closing @@ -378,6 +482,7 @@ % the ending environment statement. % \begin{macrocode} \def\wt@finetabella{\end{widetable}}% + % \end{macrocode} % % We finally can define the all important macro that gets the table body; it requires @@ -414,12 +519,14 @@ \MessageBreak The table is not typeset and is substituted% \MessageBreak - with a framed box} - \noindent\framebox[\wt@width]{The table was not typeset because - it contains a visible \texttt{\char`\\end} in one or more cells.}\par + with a framed box}% + \advance\wt@width-2\fboxsep + \noindent\fbox{\parbox{\wt@width}{The table was not typeset because + it contains a visible \texttt{\char`\\end} in one or more cells.}}\par \expandafter\wt@finishTable \fi } + % \end{macrocode} % % In order to avoid a complete mess, we have to iteratively gobble the rest of the @@ -437,6 +544,30 @@ \expandafter\wt@finishTable \fi } +% \end{macrocode} +% \section{Conclusion} +% Tables should always have their natural width, but\dots\ The default value of +%|\tabcolsep| is fixed by the document class, it is not prescribed by a supreme law: +% therefore what does it mean ``natural width''. Probably the one determined by the +% class default value of |\tabcolsep| so all tables have the same general look. +% +% Nevertheless sometimes a table is slightly wider than the current measure; why not +% shrink the table by shrinking |\tabcolsep| by the right ammount in order to fit the +% measure? The result might be a table where only the interculomn spaces are shrunk, +% not the whole table, fonts, drawings, and figures included, a result easily +% obtainable with a |\resizebox| command available throught th \textsf{graphicx.sty} +% package. Nobody forbids to follow this technique, of course, but the |widetable| +% route might yield a better result. +% +% The same is true when a natural width table is slightly shorter than the measure; +% enlarging it by retouching the |\tabcolsep| intercolumn space might be the right +% solution in order to avoid a multitude of slightly different indents or left margins. +% +% This package might be useful also for copying some macros so as to avoid some +% programming in other packages; this use is certainly permitted by the LaTeX Project +% Public License, which sets the observance of very light obbligations. +% \begin{macrocode} + \endinput % \end{macrocode} % diff --git a/Master/texmf-dist/tex/latex/widetable/widetable.sty b/Master/texmf-dist/tex/latex/widetable/widetable.sty index 985a41c8f23..499f033ccdc 100644 --- a/Master/texmf-dist/tex/latex/widetable/widetable.sty +++ b/Master/texmf-dist/tex/latex/widetable/widetable.sty @@ -26,13 +26,38 @@ %% \NeedsTeXFormat{LaTeX2e}[2005/12/01] \ProvidesPackage{widetable}% - [2009/07/21 v.1.0 Package for typesetting specified width tables] + [2009/10/26 v.1.1 Package for typesetting specified width tables] \dimendef\wt@Numer=2 \dimendef\wt@Denom=4 \countdef\wt@Num=2 \countdef\wt@Den=4 \countdef\wt@I=6 \def\wt@segno{} + +\newif\ifm@mifetex + \m@mifetexfalse +\IfFileExists{ifetex.sty}{\RequirePackage{ifetex}\relax}{% + \PackageWarningNoLine{widetable}{% + If there is an `ifetex' package then it is not installed.\MessageBreak + The package is being emulated}% +\m@mifetextrue +\newif\ifetex + \etexfalse +\ifx\eTeXversion\undefined +\else + \ifx\eTeXversion\@undefined + \else + \ifx\eTeXversion\relax + \else + \ifnum\eTeXversion>0\relax + \etextrue + \fi + \fi + \fi +\fi +%%\EmulatedPackage{ifetex}[2008/07/23]% from memoir.cls +} + \def\dividi#1\per#2\in#3{% \begingroup \wt@Numer #1\relax \wt@Denom #2\relax @@ -49,16 +74,33 @@ \edef\x{\noexpand\endgroup\noexpand\def\noexpand#3{\wt@segno\wt@Q}} \x } + \def\wt@dividiDec{% \wt@Numer=10\wt@Numer \wt@Num=\wt@Numer \divide\wt@Num\wt@Den \edef\wt@q{\number\wt@Num}\edef\wt@Q{\wt@Q\wt@q}% \advance\wt@Numer -\wt@q\wt@Denom} + +\def\scala#1\per#2\diviso#3\in#4{\begingroup +\wt@Num #2\relax \wt@Den #3\relax +\ifnum\wt@Den<\z@ \wt@Den -\wt@Den \wt@Num -\wt@Num \fi +\ifnum\wt@Den=\z@ + \@tempdima\ifnum\wt@Num<0-\fi\maxdimen +\else + \@tempdima\dimexpr#1*\wt@Num/\wt@Den\relax +\fi +\edef\x{\noexpand\endgroup\noexpand\def\noexpand#4{\the\@tempdima}}% +\x} + \newdimen\wt@width + \def\wt@starttabular{\expandafter\tabular\expandafter{\wt@preamble}} + \def\widetable#1#2{% \def\@tempC{widetable}\setlength{\wt@width}{#1}% \def\wt@preamble{#2}\wt@getTable} + \newif\ifwt@scartare\wt@scartarefalse + \def\endwidetable{% \ifwt@scartare \noindent\null @@ -70,13 +112,19 @@ \advance\wt@width-\wd\z@ \@tempdimb=\wd\tw@ \advance\@tempdimb-\wd\z@ - \dividi\wt@width\per\@tempdimb\in\@tempA - \tabcolsep=\@tempA\tabcolsep + \ifetex + \scala\tabcolsep\per\wt@width\diviso\@tempdimb\in\tabcolsep\relax + \else + \dividi\wt@width\per\@tempdimb\in\@tempA + \tabcolsep=\@tempA\tabcolsep + \fi \wt@starttabular\the\toks@\endtabular \fi \ignorespacesafterend } + \def\wt@finetabella{\end{widetable}}% + \def\wt@getTable#1\end#2{\def\@tempB{#2}% \ifx\@tempB\@tempC \toks@={#1}% @@ -89,12 +137,14 @@ \MessageBreak The table is not typeset and is substituted% \MessageBreak - with a framed box} - \noindent\framebox[\wt@width]{The table was not typeset because - it contains a visible \texttt{\char`\\end} in one or more cells.}\par + with a framed box}% + \advance\wt@width-2\fboxsep + \noindent\fbox{\parbox{\wt@width}{The table was not typeset because + it contains a visible \texttt{\char`\\end} in one or more cells.}}\par \expandafter\wt@finishTable \fi } + \def\wt@finishTable#1\end#2{% \def\@tempB{#2}% \ifx\@tempB\@tempC @@ -103,6 +153,7 @@ \expandafter\wt@finishTable \fi } + \endinput %% %% End of file `widetable.sty'. |