From 476d676a816ee6b8b116b2a0b4e49d69aabd6f56 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 20 Feb 2014 23:10:33 +0000 Subject: tabstackengine (19feb14) git-svn-id: svn://tug.org/texlive/trunk@33006 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/tabstackengine/README | 2 +- .../doc/latex/tabstackengine/tabstackengine.pdf | Bin 334466 -> 314836 bytes .../doc/latex/tabstackengine/tabstackengine.tex | 173 +++++++-------------- .../tex/latex/tabstackengine/tabstackengine.sty | 64 ++++++-- 4 files changed, 112 insertions(+), 127 deletions(-) diff --git a/Master/texmf-dist/doc/latex/tabstackengine/README b/Master/texmf-dist/doc/latex/tabstackengine/README index 1ff865d98fc..a394d8979e5 100644 --- a/Master/texmf-dist/doc/latex/tabstackengine/README +++ b/Master/texmf-dist/doc/latex/tabstackengine/README @@ -8,7 +8,7 @@ stackengine command may be prepended with the word "tabbed", "align" or Additionally, hooks are provided into the package's parser, so that (completely outside of any stacking constructions) tabbed strings of -data may be parsed, extracted, and reconstituted +data may be parsed, extracted, and reconstituted. Steven B. Segletes steven.b.segletes.civ@mail.mil diff --git a/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.pdf b/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.pdf index 28ac8d460c6..f4c2185ce2e 100644 Binary files a/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.pdf and b/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.pdf differ diff --git a/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.tex b/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.tex index 81264dd36cd..70f71e3cf6d 100644 --- a/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.tex +++ b/Master/texmf-dist/doc/latex/tabstackengine/tabstackengine.tex @@ -94,8 +94,7 @@ Note that these \cmd{setstack...gap} macros are for setting horizontal gaps between columns of a stack. They should not be confused with the \cmd{setstackgap} macro of {\ste} that sets the vertical gap for long and short stacks. - -\clearpage + \section{Command Summary} Below are the new commands introduced by this package. When there are @@ -150,6 +149,9 @@ brace may be selected. \begin{verbnobox}[\footnotesize] \fixTABwidth{T or F} \setstackTAB{tabbing character} +\TABunaryLeft (\TABbinaryRight) +\TABunaryRight (\TABbinaryLeft) +\TABbinary \end{verbnobox} The following macros are macros that can be used for parsing tabbed data outside of a TABstack. @@ -183,9 +185,9 @@ In an \texttt{align}-stack, the column alignments will always be \verb|rlrl...| The gap following the left-aligned columns is set by \verb|\setstackaligngap|. \verb|\stackMath$Z:\left\{\alignCenterstack{%|\\ -\verb| y&=mx+b,&0&=Ax+By+C\\y_1&=W_1,&y_2&=W_2}\right.$| +\verb| y=&mx+b,&0=&Ax+By+C\\y_1=&W_1,&y_2=&W_2}\right.$| -{\small\stackMath$Z:\left\{\alignCenterstack{y&=mx+b,&0&=Ax+By+C\\y_1&=W_1,&y_2&=W_2}\right.$} +{\small\stackMath$Z:\left\{\alignCenterstack{y=&mx+b,&0=&Ax+By+C\\y_1=&W_1,&y_2=&W_2}\right.$} \subsection*{Tabular End-of-Line (EOL)-delimited Stacks} @@ -222,11 +224,12 @@ as in the syntax of the \textsf{stackengine} package. This is for stacking two items with \texttt{rlrl...} alignment pattern. \verb|\stackMath\setstackaligngap{3em}|\\ -\verb|\alignstackunder[10pt]{y&=mx+b,&0&=Ax+By+C}{y_1&=W_1,&y_2&=W_2}| +\verb|\alignstackunder[10pt]{y=&mx+b,&0=&Ax+By+C}{y_1=&W_1,&y_2=&W_2}| {\small\stackMath\setstackaligngap{3em} -\alignstackunder[10pt]{y&=mx+b,&0&=Ax+By+C}{y_1&=W_1,&y_2&=W_2}} +\alignstackunder[10pt]{y=&mx+b,&0=&Ax+By+C}{y_1=&W_1,&y_2=&W_2}} +\clearpage \subsection*{Tabular Stack} This is for stacking two items with specifiable alignment pattern. @@ -240,7 +243,6 @@ This is for stacking two items with specifiable alignment pattern. \tabularstackanchor[4pt]{rcl}{\bullet\bullet\bullet&\belowbaseline[-2pt]{% \triangle}&\bullet\bullet\bullet}{1 + 2(4-3) & = & 6 - 6/2}} -\clearpage \subsection*{Fixed Tab Width (equal width columns, based on largest)} With this mode set, the stack will have fixed-width columns, based on the overall @@ -262,6 +264,48 @@ inside of an environment that already uses the \verb|&| character as a tab, such \verb|tabular| environment for text or the various math environments in the \textsf{amsmath} package. +\subsection*{Unary versus Binary Operators/Relations at Cell Ends} + +There are two things to keep in mind regarding TABstacked content. First, a TABstack cell has +no precise understanding up what content precedes it in the cell to the immediate left, nor what +content follows it in the cell to the immediate right. It does, however know the overall height/depth +of the content across the whole row and creates a vertical ``strut'' of that height and depth, which must, +in some way, be applied to every cell in the row. + +This vertical strut can be applied to the cell immediately +prior to or immediately following the cell content, as we shall see. However, such an action will +have an effect on math operators and relations found at the leading or trailing ends of the cell +content. + +Math operators and relations can be categorized as unary or binary; some +may be both, depending on their usage context, such as the minus sign. When used as $a-b$, the +relation is binary, because it connects $a$ and $b$ in a mathematical relationship. Note how space +appears both before and after the minus sign. Alternatively, when used as $-\pi$, the minus sign +operates only upon what follows, in this case $\pi$, to produce a negative. Note how no space is +introduced between the minus sign and $\pi$. + +Because a TABstack cell has no intimate knowledge of the adjacent cell content, it is up to +the user to employ his tabbing seperators in a way that produces the desired result. By default, +\textsf{tabstackengine} will place the strut after the cell content. This means that any trailing +math operator in a cell will present itself in its binary form (regardless of what comes in the +cell to the right), because the strut will appear as trailing data against which the operator can +be set. Similarly, any leading math operator will present itself as unary (regardless of what +content appears in the cell to the left). + +Thus, \verb|\tabbedLongstack{y =&-mx +& b}| will present as +{\tabbedLongstack{y =&-mx +& b}}, by default, +with the trailing equal and plus signs as binary, and the leading minus sign as unary. The package +can reverse the default with the following declarative modes: +\verb|\TABunaryRight| (identical to \verb|\TABbinaryLeft|); as well +as \verb|\TABbinary|, which will present both leading \textit{and} trailing operators in +their binary form. The default can be restored with +\verb|\TABunaryLeft| (identical to \verb|\TABbinaryRight|). + +Without changing any of the package strut modes, an operator, such as minus, can be +forced into its unary mode +by enclosing it in braces: \verb|{-}|. Likewise, it can be forced into its binary mode by +placing empty braces on both sides of it: \verb|{}-{}|. + \subsection*{The Macros \texttt{\textbackslash readTABrow}, \texttt{\textbackslash TABcell(s)}, and \texttt{\textbackslash TABstrut}} @@ -343,119 +387,13 @@ mode\mdseries. This is a good reason to avoid the ``TAB'' versions of these macros, unless employing them to parse data (and then, reset to \verb|\TABstackText| when you are done with parsing). -\clearpage \section{Known Bugs/Missing Features} \begin{enumerate} -\item \textbf{Ending on a} \verb|\frac| - -The following code demonstrates a bug when a row ends in \verb|\frac|, -when not followed by a space: - -\begin{verbnobox}[\footnotesize] -\documentclass{article} -\usepackage{tabstackengine} -\stackMath -\setstackgap{S}{6pt} -\newcommand\tfrac[2]{\frac{\textrm{#1}}{\textrm{#2}}} -\scriptsize -\begin{document} -\noindent space after tfrac, all is OK: -\par\medskip\noindent\tabbedShortstack[l]{ -\rho &= 2.04 &\tfrac{g}{cm$^3$} \\ -M &= 56.10 &\tfrac{g}{mol} \\ -c &= 0.05 &\tfrac{mol}{L} \\ -} -\par\noindent no space after tfrac results in tfrac set in displaystyle\\ -while the rest of the stack is in textstyle: -\par\medskip\noindent\tabbedShortstack[l]{ -\rho &= 2.04 &\tfrac{g}{cm$^3$}\\ -M &= 56.10 &\tfrac{g}{mol}\\ -c &= 0.05 &\tfrac{mol}{L}\\ -} -\end{document} -\end{verbnobox} - -Here is the result of the above code, showing the difference when a space -is included after the \verb|\frac| versus when one is omitted: - -{\stackMath -\setstackgap{S}{6pt} -\newcommand\tfrac[2]{\frac{\textrm{#1}}{\textrm{#2}}} -\scriptsize -\noindent space after tfrac, all is OK: -\par\medskip\noindent\tabbedShortstack[l]{ -\rho &= 2.04 &\tfrac{g}{cm$^3$} \\ -M &= 56.10 &\tfrac{g}{mol} \\ -c &= 0.05 &\tfrac{mol}{L} \\ -} -\par\noindent no space after tfrac results in tfrac set in displaystyle\\ -while the rest of the stack is in textstyle: -\par\medskip\noindent\tabbedShortstack[l]{ -\rho &= 2.04 &\tfrac{g}{cm$^3$}\\ -M &= 56.10 &\tfrac{g}{mol}\\ -c &= 0.05 &\tfrac{mol}{L}\\ -}} - -When the space is omitted, the stack is constructed in \verb|\textstyle|, whereas the -closing fractions appear to be constructed in \verb|\displaystyle|. The workaround is to not end -the \textsf{tabstackengine} field in a \verb|\frac| without an extra space. - -\item \textbf{Unary versus Binary Minus Sign} - -The package seems to want to use the minus sign that leads a number in binary -mode, that is, as an minus operator rather than as a negative sign. - -\begin{verbnobox}[\footnotesize] -\setstacktabbedgap{1ex} -$\bracketMatrixstack[r]{ --0.84 & 0.21 & -0.11 & 0.110 & 0.13 & 0.34\\ -0.21 & -0.43 & 0.14 & 0.06 & 0.30 & -0.22\\ -0.27 & 0.13 & -0.54 & 0.25 & -0.27 & 0.16\\ --0.27 & -0.23 & 0.43 & -0.46 & 0.53 & -0.05\\ -0.05 & 0.13 & -0.02 & -0.10 & -0.03 & -0.02\\ -0.23 & -0.32 & 0.21 & -0.11 & 0.41 & -0.34 -}$ -\end{verbnobox} - -\setstacktabbedgap{1ex} -$\bracketMatrixstack[r]{ --0.84 & 0.21 & -0.11 & 0.110 & 0.13 & 0.34\\ -0.21 & -0.43 & 0.14 & 0.06 & 0.30 & -0.22\\ -0.27 & 0.13 & -0.54 & 0.25 & -0.27 & 0.16\\ --0.27 & -0.23 & 0.43 & -0.46 & 0.53 & -0.05\\ -0.05 & 0.13 & -0.02 & -0.10 & -0.03 & -0.02\\ -0.23 & -0.32 & 0.21 & -0.11 & 0.41 & -0.34 -}$ - -\vspace*{\baselineskip} -The workaround is to enclose the minus signs in braces: - -\begin{verbnobox}[\footnotesize] -\setstacktabbedgap{1ex} -$\bracketMatrixstack[r]{ -{-}0.84 & 0.21 & {-}0.11 & 0.110 & 0.13 & 0.34\\ -0.21 & {-}0.43 & 0.14 & 0.06 & 0.30 & {-}0.22\\ -0.27 & 0.13 & {-}0.54 & 0.25 & {-}0.27 & 0.16\\ -{-}0.27 & {-}0.23 & 0.43 & {-}0.46 & 0.53 & {-}0.05\\ -0.05 & 0.13 & {-}0.02 & {-}0.10 & {-}0.03 & {-}0.02\\ -0.23 & {-}0.32 & 0.21 & {-}0.11 & 0.41 & {-}0.34 -}$ -\end{verbnobox} - -$\bracketMatrixstack[r]{ -{-}0.84 & 0.21 & {-}0.11 & 0.110 & 0.13 & 0.34\\ -0.21 & {-}0.43 & 0.14 & 0.06 & 0.30 & {-}0.22\\ -0.27 & 0.13 & {-}0.54 & 0.25 & {-}0.27 & 0.16\\ -{-}0.27 & {-}0.23 & 0.43 & {-}0.46 & 0.53 & {-}0.05\\ -0.05 & 0.13 & {-}0.02 & {-}0.10 & {-}0.03 & {-}0.02\\ -0.23 & {-}0.32 & 0.21 & {-}0.11 & 0.41 & {-}0.34 -}$ - \item \textbf{No Horizontal Equivalent of \textbackslash TABstrut} -As of the initial package release, there is no macro that provides the width of a +Currently, there is no macro that provides the width of a column's content. I hope to remedy this deficiency in a future release. \item \textbf{Nothing Equivalent to} \verb|\hline| @@ -466,7 +404,14 @@ there is nothing equivalent to \verb|\hline| available for use in \end{enumerate} +\section*{Acknowledgements} +I would like to thank Prof. Enrico Gregorio of \textsf{tex.stackexchange.com} for +his considerable assistance rendered. Many of the improvements he offered towards +my \textsf{stackengine} package were carried over directly into this package, as +well, resulting in a more robust implementation. + +\clearpage \section{Code Listing} \verbfilenobox[\footnotesize]{tabstackengine.sty} diff --git a/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty b/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty index 511bad54eb9..94a5428de67 100644 --- a/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty +++ b/Master/texmf-dist/tex/latex/tabstackengine/tabstackengine.sty @@ -1,13 +1,21 @@ -\def\tabstackengineversionnumber{V1.00} +\def\tabstackengineversionnumber{V1.10} % % tabstackengine initial release % % THIS MATERIAL IS SUBJECT TO THE LaTeX Project Public License % -% V1.00 - Adopted beta version 0.21 as initial release version 1.0 +% V1.00 -Adopted beta version 0.21 as initial release version 1.0 +% V1.10 -Corrected unary/binary problem for left end of tabbed cell content; +% -Added \TABunaryLeft (\TABbinaryRight) for " cell{} "; +% added \TABunaryRight (\TABbinaryLeft) for " {}cell "; +% added \TABbinary for " {}cell{} "; +% The default is \TABunaryLeft (V1.00 wrongly equivalent to \TABbinary) +% This removes need to brace unary negatives at lead of cell. +% -Corrected bug of trailing \frac, noted in V1.00, by adding a +% \relax to definition of \@postTAB in \readTABrow. % \ProvidesPackage{tabstackengine} -[2014/02/11 (\tabstackengineversionnumber) tabbed stacking] +[2014/02/19 (\tabstackengineversionnumber) tabbed stacking] \RequirePackage[usestackEOL]{stackengine}[2013-10-15] \RequirePackage{calc} @@ -32,7 +40,7 @@ \newcommand\readTABrow[2]{% \edef\row@ID{#1}% \togglefalse{@doneTABreads}% - \edef\@postTAB{\unexpanded{#2}\expandonce{\TAB@char}}% + \edef\@postTAB{\unexpanded{#2\relax}\expandonce{\TAB@char}}% \setcounter{TABcellindex@}{0}% \whileboolexpr{ test {\nottoggle{@doneTABreads}}}{% \stepcounter{TABcellindex@}% @@ -61,6 +69,38 @@ \global\csedef{@#1TABtextblob}{\expandonce\@accumulatedTAB}% } +\def\p@Tstrut#1{\protect\TABstrut{#1}} + +\newcommand\TABunaryLeft{% + \def\TAB@strutLeftA{}% + \def\TAB@strutRightA{\p@Tstrut{i}}% + \def\TAB@strutLeftB{}% + \def\TAB@strutRightB{\p@Tstrut{ii}}% + \def\TAB@strutLeftC{}% + \def\TAB@strutRightC{\p@Tstrut{\TAB@prefix}}% +} +\let\TABbinaryRight\TABunaryLeft + +\newcommand\TABunaryRight{% + \def\TAB@strutLeftA{\p@Tstrut{i}}% + \def\TAB@strutRightA{}% + \def\TAB@strutLeftB{\p@Tstrut{ii}}% + \def\TAB@strutRightB{}% + \def\TAB@strutLeftC{\p@Tstrut{\TAB@prefix}}% + \def\TAB@strutRightC{}% +} +\let\TABbinaryLeft\TABunaryRight + +\newcommand\TABbinary{% + \def\TAB@strutLeftA{{}}% + \def\TAB@strutRightA{\p@Tstrut{i}}% + \def\TAB@strutLeftB{{}}% + \def\TAB@strutRightB{\p@Tstrut{ii}}% + \def\TAB@strutLeftC{{}}% + \def\TAB@strutRightC{\p@Tstrut{\TAB@prefix}}% +} +\TABunaryLeft + \newcommand\TAB@delim[1]{#1}% \newcommand\TABstackMath{% \renewcommand\TAB@delim[1]{\ensuremath{##1}}% @@ -162,9 +202,9 @@ \setcounter{TABcellindex@}{0}% \whileboolexpr{test {\ifnumless{\theTABcellindex@}{\TABcells{i}}}}{% \def\col@stack{% - \protect\TABstrut{i}% + \TAB@strutLeftA% \TABcell{i}{\theTABcellindex@}% - \protect\TABstrut{i}% + \TAB@strutRightA% }% \stepcounter{TABcellindex@}% \@getTABalignment{#3}{\theTABcellindex@}% @@ -176,9 +216,9 @@ \stepcounter{TAB@stackindex}% \edef\TAB@prefix{\roman{TAB@stackindex}}% \protected@edef\col@stack{\col@stack\SEP@char% - \protect\TABstrut{\TAB@prefix}% + \TAB@strutLeftC% \TABcell{\TAB@prefix}{\theTABcellindex@}% - \protect\TABstrut{\TAB@prefix}% + \TAB@strutRightC% }% }% \iftoggle{fixed@TABwidth}% @@ -230,10 +270,10 @@ }{\add@TAB@gap{#4}{\theTABcellindex@}}{}% \iftoggle{fixed@TABwidth}% {\makebox[\the\maxTAB@width][\stackalignment]{% - #5[#1]{\TABstrut{i}\TABcell{i}{\theTABcellindex@}\TABstrut{i}}% - {\TABstrut{ii}\TABcell{ii}{\theTABcellindex@}\TABstrut{ii}}}}% - {#5[#1]{\TABstrut{i}\TABcell{i}{\theTABcellindex@}\TABstrut{i}}% - {\TABstrut{ii}\TABcell{ii}{\theTABcellindex@}\TABstrut{ii}}}% + #5[#1]{\TAB@strutLeftA\TABcell{i}{\theTABcellindex@}\TAB@strutRightA}% + {\TAB@strutLeftB\TABcell{ii}{\theTABcellindex@}\TAB@strutRightB}}}% + {#5[#1]{\TAB@strutLeftA\TABcell{i}{\theTABcellindex@}\TAB@strutRightA}% + {\TAB@strutLeftB\TABcell{ii}{\theTABcellindex@}\TAB@strutRightB}}% }% \let\stackalignment\sv@stackalignment% } -- cgit v1.2.3