diff options
author | Karl Berry <karl@freefriends.org> | 2011-09-06 23:40:37 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2011-09-06 23:40:37 +0000 |
commit | 86431735f0e1623beae96cd8a9f0fcd809fe08bf (patch) | |
tree | cd525a5d3f2cdeb2d6724391799658f9a9eb91da /Master/texmf-dist/tex/latex/collectbox | |
parent | b4916617184100381af6a2ce45ac54d2ee295ae7 (diff) |
collectbox (6sep11)
git-svn-id: svn://tug.org/texlive/trunk@23848 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/collectbox')
-rw-r--r-- | Master/texmf-dist/tex/latex/collectbox/collectbox.sty | 127 |
1 files changed, 122 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/latex/collectbox/collectbox.sty b/Master/texmf-dist/tex/latex/collectbox/collectbox.sty index 373b59e25ab..d41ae01318f 100644 --- a/Master/texmf-dist/tex/latex/collectbox/collectbox.sty +++ b/Master/texmf-dist/tex/latex/collectbox/collectbox.sty @@ -26,7 +26,7 @@ %% and the derived file collectbox.sty. %% \NeedsTeXFormat{LaTeX2e}[1999/12/01] -\ProvidesPackage{collectbox}[2011/08/11 v0.3a Collect macro arguments as boxes] +\ProvidesPackage{collectbox}[2011/08/23 v0.4 Collect macro arguments as boxes] \newsavebox\collectedbox \newcommand*\collectbox{% \@ifstar @@ -59,14 +59,26 @@ \aftergroup\@temptokena \collectbox@bgroup } +\let\collectbox@macro\collectbox@ +\newcommand\collectbox@env[3]{% + \collectbox@mode + \def\collectboxenvend{#3\collectbox@end#2\collectbox@currenvir}% + \setbox\collectedbox\collect@box\bgroup + \collectbox@setgroup + \collectbox@reset + \ignorespaces + #1% +} +\def\collectbox@currenvir{% + \edef\@currenvir{\@currenvir}% +} \def\collectbox@macro@bgroup{% \@ifnextchar\bgroup {\let\@let@token=}% {\collectbox@arg}% } \def\collectbox@env@bgroup{% - \let\collectbox@endcode\relax - \let\collectbox@bgroup\collectbox@macro@bgroup + \collectbox@reset \ignorespaces } \let\collectbox@bgroup\collectbox@macro@bgroup @@ -101,8 +113,16 @@ \collectbox@protecteddef\totalheight{\@ovri}% \totalheight\height \advance\totalheight\depth + \ifcollectboxenv + \collectbox@reset + \collectbox@currenvir + \fi +} +\def\collectbox@reset{% \let\collectbox@endcode\relax \let\collectbox@bgroup\collectbox@macro@bgroup + \let\collectbox@\collectbox@macro + \collectboxenvfalse } \begingroup \expandafter\ifx\csname protected\endcsname\relax @@ -167,18 +187,115 @@ } \def\@collectboxisenv#1{% \noindent - \begingroup \collectboxenvtrue \edef\@currenvir{\@currenvir\noexpand\empty}% \let\collectbox@bgroup\collectbox@env@bgroup \let\collectbox@endcode\collectbox@env@endcode + \let\collectbox@\collectbox@env \expandafter\ifx\csname end#1\endcsname\relax \expandafter\let\csname end#1\endcsname\collectbox@envend \fi } \newif\ifcollectboxenv \def\collectbox@env@endcode{\ifhmode\unskip\fi}% -\def\collectbox@envend{\egroup\endgroup}% +\def\collectbox@envend{\collectboxenvend}% +\def\collectboxenvend{% + \egroup + \collectbox@currenvir +}% +\newcommand\collectboxtabular[3][c]{% + \collectbox@tab{tabular}{[#1]{#2}}{}{#3}{}% +} +\newcommand\collectboxtabularstar[4][c]{% + \collectbox@tab{tabular*}{[#1]{#2}{#3}}{}{#4}{}% +} +\newcommand\collectboxarray[2]{% + \collectbox@tab{array}{{#1}}{\(}{#2}{\)}% +} +\def\collectbox@checkarray{% +\@ifpackageloaded{array}{% + \let\collectbox@realarraycr\@arraycr + \def\collectbox@setarraycr{% + \let\@arraycr\collebox@cr + \def\ialign{\let\@arraycr\collectbox@realarraycr \everycr {}\tabskip \z@skip \halign}% + }% +}{% + \let\collectbox@realarraycr\@tabularcr + \def\collectbox@setarraycr{% + \let\@tabularcr\collebox@cr + \def\ialign{\let\noexpand\@tabularcr\noexpand\collectbox@realarraycr \everycr {}\tabskip \z@skip \halign}% + }% +}% +} +\collectbox@checkarray +\AtBeginDocument{\collectbox@checkarray}% +\def\collectbox@dorealarraycr{% + \expandafter\collectbox@realarraycr\collectbox@aftercrstuff +} +\let\collectbox@aftercrstuff\empty +\def\collectbox@tab#1#2#3#4#5{% + \begingroup + \collectbox@mode + \def\collectbox@codeafter{#4\endgroup}% + \def\collectbox@endtabenv{\end{#1}#5\collectbox@end}% + \def\collectbox@dotab{#3\begin{#1}#2}% + \setbox\collectedbox\collect@box\bgroup + \collectbox@setgroup + \collectbox@setarraycr + \afterassignment\collectbox@dotab + \let\@let@token=% +} +\def\collebox@cr{% + \@ifstar\collebox@@cr\collebox@@cr% +} +\def\collebox@@cr{% + \@ifnextchar[% + \collebox@@cr@opt + {\collebox@@@cr{}}% +} +\def\collebox@@cr@opt[#1]{% + \collebox@@@cr{[#1]}% +} +\def\collebox@@@cr#1{% + \def\collectbox@aftercrstuff{#1}% + \expandafter\collebox@@@@cr + \romannumeral-`0% +} +\def\collebox@@@@cr{% + \@ifnextchar\egroup{\collectbox@dorealarraycr\collectbox@aftertab}{% + \ifx\@let@token\noalign + \expandafter\collectbox@handlenoalign + \else + \expandafter\collectbox@dorealarraycr + \fi + }% +} +\def\collectbox@handlenoalign#1#2{% + \collectbox@dorealarraycr + \noalign{\bgroup\aftergroup\collectbox@afternoalign#2}% +} +\def\collectbox@handlenextnoalign#1#2{% + \egroup + \noalign{\bgroup\aftergroup\collectbox@afternoalign#2}% +} +\def\collectbox@afternoalign{% + \expandafter\collectbox@@afternoalign + \romannumeral-`0% +} +\def\collectbox@@afternoalign{% + \@ifnextchar\egroup{\egroup\collectbox@aftertab}{% + \ifx\@let@token\noalign + \expandafter\collectbox@handlenextnoalign + \else + \expandafter\egroup + \fi + }% +} +\def\collectbox@aftertab{% + \collectbox@endtabenv + \afterassignment\collectbox@codeafter + \let\@let@token=% +} \endinput %% %% End of file `collectbox.sty'. |