summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/collectbox/collectbox.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/collectbox/collectbox.dtx')
-rw-r--r--Master/texmf-dist/source/latex/collectbox/collectbox.dtx95
1 files changed, 74 insertions, 21 deletions
diff --git a/Master/texmf-dist/source/latex/collectbox/collectbox.dtx b/Master/texmf-dist/source/latex/collectbox/collectbox.dtx
index 9286a59bdee..a87ed38f16b 100644
--- a/Master/texmf-dist/source/latex/collectbox/collectbox.dtx
+++ b/Master/texmf-dist/source/latex/collectbox/collectbox.dtx
@@ -21,9 +21,9 @@
%
% \iffalse
%<*driver>
-\ProvidesFile{collectbox.dtx}[2011/07/30 v0.2a DTX File of collectbox]
+\ProvidesFile{collectbox.dtx}[2011/08/06 v0.3 DTX File of collectbox]
\documentclass{ydoc}
-\usepackage{collectbox}[2011/07/30]
+\usepackage{collectbox}[2011/08/06]
\EnableCrossrefs
\CodelineIndex
\RecordChanges
@@ -59,6 +59,7 @@
% \changes{v0.2}{2011/07/20}{Added \cs{collectboxto} and \cs{@collectboxto} macros.}
% \changes{v0.2}{2011/07/23}{Added \cs{collectboxcheckenv}.}
% \changes{v0.2a}{2011/07/30}{Small bugfix.}
+% \changes{v0.3}{2011/08/06}{Some internal modifications required by related packages.}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
@@ -278,7 +279,7 @@
% \fi
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-\ProvidesPackage{collectbox}[2011/07/30 v0.2a Collect macro arguments as boxes]
+\ProvidesPackage{collectbox}[2011/08/06 v0.3 Collect macro arguments as boxes]
% \end{macrocode}
%
% \begin{macro}{\collectedbox}
@@ -330,6 +331,19 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\collect@box}
+% The box primitive used. Might be locally redefined to \Macro\vbox if required.
+% \begin{macrocode}
+\let\collect@box\hbox
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\collectbox@mode}
+%
+% \begin{macrocode}
+\let\collectbox@mode\leavevmode
+% \end{macrocode}
+% \end{macro}
%
% \begin{macro}{\collectbox@}
% The box is saved using |\setbox|. Color is supported by using |\collectbox@setgroup|.
@@ -340,9 +354,9 @@
% \begin{macrocode}
\newcommand\collectbox@[3]{%
\begingroup
- \leavevmode
+ \collectbox@mode
\@temptokena{#3\collectbox@end#2\endgroup}%
- \setbox\collectedbox\hbox\bgroup
+ \setbox\collectedbox\collect@box\bgroup
\collectbox@setgroup
#1\bgroup
\aftergroup\the
@@ -405,9 +419,9 @@
% \begin{macrocode}
\newcommand\@collectbox[1]{%
\begingroup
- \leavevmode
+ \collectbox@mode
\@temptokena{\collectbox@end#1\endgroup}%
- \setbox\collectedbox\hbox\bgroup
+ \setbox\collectedbox\collect@box\bgroup
\collectbox@setgroup\bgroup
\aftergroup\the
\aftergroup\@temptokena
@@ -508,8 +522,8 @@
% Installs code and starts to collect the box.
% \begin{macrocode}
\newcommand\collectboxto@[4]{%
- \leavevmode
- \setbox#1\hbox\bgroup
+ \collectbox@mode
+ \setbox#1\collect@box\bgroup
\def\collectbox@code{#4\collectbox@endgroup\egroup#3}%
\collectbox@setgroup#2\bgroup
\aftergroup\collectbox@code
@@ -523,8 +537,8 @@
% Collects the next brace group as hbox into box register |#1| and executes token |#2| afterwards.
% \begin{macrocode}
\newcommand\@collectboxto[2]{%
- \leavevmode
- \setbox#1\hbox\bgroup
+ \collectbox@mode
+ \setbox#1\collect@box\bgroup
\def\collectbox@code{\collectbox@endgroup\egroup#2}%
\collectbox@setgroup\bgroup
\aftergroup\collectbox@code
@@ -538,8 +552,8 @@
% Turns a brace group into \Macro\hbox{<code at begin><content><code at end>}<code>.
% \begin{macrocode}
\newcommand\nocollectbox@[3]{%
- \leavevmode
- \hbox\bgroup
+ \collectbox@mode
+ \collect@box\bgroup
\def\collectbox@code{#3\egroup#2}%
#1\bgroup
\aftergroup\collectbox@code
@@ -549,26 +563,65 @@
% \end{macro}
%
%
+% \begin{macro}{\nocollectbox@to}[4]{<length>}{<code at begin>}{<code>}{<code at end>}
+% Turns a brace group into \Macro\hbox' to '<length>{<code at begin><content><code at end>}<code>.
+% \begin{macrocode}
+\newcommand\nocollectbox@to[4]{%
+ \collectbox@mode
+ \collect@box to #1\bgroup
+ \def\collectbox@code{#4\egroup#3}%
+ #2\bgroup
+ \aftergroup\collectbox@code
+ \collectbox@bgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
% \begin{macro}{\collectboxcheckenv}
% Checks if current macro is used as environment given by |#1|.
% If so the |bgroup| eating macro is redefined.
% A suitable end-macro is provided if non exists. All of this is done inside
% a group to keep thing local.
+% The \Macro\@currenvir macro is redefined to contain \Macro\empty so that
+% macros with the same name can be used inside the environment without collisions.
+% This requires an extra internal group so that this change is reverted before the
+% \Macro\end macro.
% \begin{macrocode}
\newcommand*\collectboxcheckenv[1]{%
\begingroup
\def\@tempa{#1}%
+ \expandafter\endgroup
\ifx\@currenvir\@tempa
- \edef\@currenvir{\@currenvir\noexpand\empty}%
- \let\collectbox@bgroup\collectbox@env@bgroup
- \def\collectbox@endcode{\ifhmode\unskip\fi}%
- \ifcsname end#1\endcsname\else
- \@namedef{end#1}{\egroup\endgroup}%
- \fi
- \else
- \endgroup
+ \@collectboxisenv{#1}%
+ \fi
+}
+\def\@collectboxisenv#1{%
+ \noindent
+ \begingroup
+ \collectboxenvtrue
+ \edef\@currenvir{\@currenvir\noexpand\empty}%
+ \let\collectbox@bgroup\collectbox@env@bgroup
+ \let\collectbox@endcode\collectbox@env@endcode
+ \expandafter\ifx\csname end#1\endcsname\relax
+ \expandafter\let\csname end#1\endcsname\collectbox@envend
\fi
}
+\newif\ifcollectboxenv
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\collectbox@env@endcode}
+% \begin{macrocode}
+\def\collectbox@env@endcode{\ifhmode\unskip\fi}%
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\collectbox@envend}
+% \begin{macrocode}
+\def\collectbox@envend{\egroup\endgroup}%
% \end{macrocode}
% \end{macro}
%