summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/grabbox/grabbox.pdfbin334270 -> 335310 bytes
-rw-r--r--Master/texmf-dist/source/latex/grabbox/grabbox.dtx127
-rw-r--r--Master/texmf-dist/tex/latex/grabbox/grabbox.sty109
3 files changed, 130 insertions, 106 deletions
diff --git a/Master/texmf-dist/doc/latex/grabbox/grabbox.pdf b/Master/texmf-dist/doc/latex/grabbox/grabbox.pdf
index 6409fece942..88fef938d98 100644
--- a/Master/texmf-dist/doc/latex/grabbox/grabbox.pdf
+++ b/Master/texmf-dist/doc/latex/grabbox/grabbox.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/grabbox/grabbox.dtx b/Master/texmf-dist/source/latex/grabbox/grabbox.dtx
index 66a814cb724..e2a89b96537 100644
--- a/Master/texmf-dist/source/latex/grabbox/grabbox.dtx
+++ b/Master/texmf-dist/source/latex/grabbox/grabbox.dtx
@@ -57,7 +57,7 @@ and the derived files grabbox.pdf and
%<*driver>
\ProvidesFile{grabbox.dtx}
[%
- \csname grabbox@date\endcsname\
+ \csname grabbox@date\endcsname\space
utilities to get an argument as a box%
]
\expandafter\def\csname @classoptionslist\endcsname{}
@@ -77,10 +77,13 @@ and the derived files grabbox.pdf and
\end{document}
%</driver>
%<*pkg>
-\newcommand*\grabbox@date{2018-10-18}
-\newcommand*\grabbox@version{1.0b}
+\newcommand*\grabbox@date{2018-11-29}
+\newcommand*\grabbox@version{1.2}
\ProvidesPackage{grabbox}
- [\grabbox@date\ v\grabbox@version\ utilities to get an argument as a box]
+ [%
+ \grabbox@date\space v\grabbox@version\space utilities to get an argument as
+ a box%
+ ]
%</pkg>
% \fi
%
@@ -104,7 +107,9 @@ and the derived files grabbox.pdf and
% exact contents of an argument but only for that contents typeset
% representation and its dimensions. In that case I personally dislike the fact
% that those arguments couldn't contain verbatim material if coded straight
-% forward. Thus the macros distributed hereby came into existence.
+% forward for macros. For environments this is quite easy to create thanks to
+% \env{lrbox}, for macros this approach unfortunately doesn't work without the
+% enduser's cooperation. Thus the macros distributed hereby came into existence.
%
% This package provides \cs{grabbox} to grab an argument inside of a box. The
% used mechanism allows category code changes in that argument as long as it is
@@ -136,10 +141,10 @@ and the derived files grabbox.pdf and
% register}. The box is of \meta{box type}, which should be one of \cs{hbox}
% or \cs{vbox} or \cs{vtop}. \meta{inject pre} will be injected at the
% beginning of the box and can affect its contents, \meta{inject post} will be
-% injected after the box but can't be affected by stuff inside of \meta{inject
-% pre}. Unless the \meta{*} is given leading and trailing spaces will be
-% stripped from the box. After the box is read in \meta{afterwards} will be
-% inserted.
+% injected at the end of the box but can't be affected by stuff inside of
+% \meta{inject pre} or added content unless they are using global definitions.
+% Unless the \meta{*} is given leading and trailing spaces will be stripped
+% from the box. After the box is read in \meta{afterwards} will be inserted.
% \end{function}
%
% \smallskip
@@ -205,13 +210,13 @@ and the derived files grabbox.pdf and
% \end{tabular}%
% \endgroup
% }%
-% \examplecmd{Hi,}{my}{\verb|name|}{Steve!}
+% \examplecmd{Hi,}{my}{\verb|\name|}{Steve!}
% \end{center}
% One can see that \verb|\sffamily is| of \meta{inject post} is not affected by
% the |\itshape| in \meta{inject pre}. The used code to generate that table was:
%
% \begin{verbatim}
-% \examplecmd{Hi,}{my}{\verb|name|}{Steve!}
+% \examplecmd{Hi,}{my}{\verb|\name|}{Steve!}
% \end{verbatim}
%
% \section{Useful Example?}
@@ -282,53 +287,42 @@ and the derived files grabbox.pdf and
%
% \begin{macrocode}
\@ifdefinable{\if@grabbox@spaces@}{\newif\if@grabbox@spaces@}
-\newcommand\grabbox@def[2]
+
+\@ifdefinable{\grabbox@def}{\long\def\grabbox@def#1#2#{\grabbox@def@a{#1}{#2}}}
+\@ifdefinable{\grabbox@def@a}
{%
- \@ifdefinable#1{\protected\def#1{#2}}%
+ \protected\long\def\grabbox@def@a#1#2#3%
+ {\@ifdefinable#1{\protected\def#1#2{#3}}}%
}
\newcommand\grabbox@def@step[4]
{%
- \@ifdefinable#1{\protected\def#1##1{\def#2{##1}\grabbox@opt#3#4}}%
- }
-\long\def\grabbox@check@bracket #1[#2\endgrabbox@check@bracket
- {%
- \if\relax\detokenize{#2}\relax
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
+ \@ifdefinable#1{\grabbox@def#1##1{\def#2{##1}\grabbox@opt#3#4}}%
}
-\protected\def\grabbox@opt#1#2%
+\long\def\grabbox@afterelsefi#1\else#2\fi{\fi#1}
+\long\def\grabbox@afterfi#1\fi{\fi#1}
+\long\def\grabbox@afterelsefiA\else#1\fi#2#3{\fi#2}
+\long\def\grabbox@afterfiB\fi#1#2{\fi#2}
+\grabbox@def\grabbox@opt#1#2%
{%
\@ifnextchar[
{\grabbox@opt@get#1#2}
{\def#1{}#2}%
}
-\long\def\grabbox@opt@get#1#2#3]%
+\protected\long\def\grabbox@opt@get#1#2[#3]%
{%
- \expandafter\grabbox@opt@get@a\expandafter{\@gobble#3}#1#2%
- }
-\protected\long\def\grabbox@opt@get@a#1#2#3%
- {%
- \grabbox@check@bracket #1[\endgrabbox@check@bracket
- {\def#2{#1}#3}
- {\grabbox@opt@get@b#2#3{#1]}}%
- }
-\protected\long\def\grabbox@opt@get@b#1#2#3#4]%
- {%
- \grabbox@check@bracket #4[\endgrabbox@check@bracket
- {\def#1{#3#4}#2}
- {\grabbox@opt@get@b#1#2{#3#4]}}%
+ \def#1{#3}#2%
}
\grabbox@def\grabbox@unpack
{%
- \expandafter\ifx\grabbox@type\hbox
- \expandafter\@firstoftwo
+ \begingroup
+ \edef\grabbox@test{\grabbox@type}%
+ \expandafter\ifx\grabbox@test\hbox
+ \endgroup
+ \grabbox@afterelsefi\unhbox
\else
- \expandafter\@secondoftwo
+ \endgroup
+ \grabbox@afterfi\unvbox
\fi
- \unhbox
- \unvbox
\grabbox@name
}
\grabbox@def\grabbox
@@ -345,8 +339,29 @@ and the derived files grabbox.pdf and
\afterassignment\grabbox@intermediate
\setbox\grabbox@name\grabbox@type
}
+\grabbox@def\grabbox@set@color
+ {%
+ \@ifundefined{set@color}{}
+ {\global\let\grabbox@set@color\set@color\grabbox@set@color}%
+ }
+\AtBeginDocument
+ {%
+ \@ifundefined{set@color}
+ {\gdef\grabbox@set@color{}}
+ {\global\let\grabbox@set@color\set@color}%
+ }%
+\newcommand*\grabbox@unskip@space
+ {%
+ \ifhmode\unskip\fi
+ }
\grabbox@def\grabbox@intermediate
{%
+ \bgroup
+ \if@grabbox@spaces@
+ \else
+ \aftergroup\grabbox@unskip@space
+ \fi
+ \grabbox@set@color
\aftergroup\grabbox@after
\grabbox@into@pre
\if@grabbox@spaces@
@@ -354,23 +369,21 @@ and the derived files grabbox.pdf and
\ignorespaces
\fi
}
+\newcommand*\grabbox@after@aux@b[1]
+ {%
+ \grabbox@after@aux@a
+ }
+\grabbox@def\grabbox@after@aux@a
+ {%
+ \@ifnextchar\reset@color
+ {\reset@color\grabbox@after@aux@b}
+ {\egroup\grabbox@final}%
+ }
\grabbox@def\grabbox@after
{%
- \if@grabbox@spaces@
- \setbox\grabbox@name\grabbox@type
- {%
- \grabbox@unpack
- \grabbox@into@post
- }%
- \else
- \setbox\grabbox@name\grabbox@type
- {%
- \grabbox@unpack
- \ifhmode\unskip\fi
- \grabbox@into@post
- }%
- \fi
- \grabbox@final
+ \grabbox@into@post
+ \endgraf
+ \grabbox@after@aux@a
}
% \end{macrocode}
%
diff --git a/Master/texmf-dist/tex/latex/grabbox/grabbox.sty b/Master/texmf-dist/tex/latex/grabbox/grabbox.sty
index 22ab1b7880b..c7eb787ae35 100644
--- a/Master/texmf-dist/tex/latex/grabbox/grabbox.sty
+++ b/Master/texmf-dist/tex/latex/grabbox/grabbox.sty
@@ -29,58 +29,50 @@
%% and the derived files grabbox.pdf and
%% grabbox.sty.
%%
-\newcommand*\grabbox@date{2018-10-18}
-\newcommand*\grabbox@version{1.0b}
+\newcommand*\grabbox@date{2018-11-29}
+\newcommand*\grabbox@version{1.2}
\ProvidesPackage{grabbox}
- [\grabbox@date\ v\grabbox@version\ utilities to get an argument as a box]
+ [%
+ \grabbox@date\space v\grabbox@version\space utilities to get an argument as
+ a box%
+ ]
\@ifdefinable{\if@grabbox@spaces@}{\newif\if@grabbox@spaces@}
-\newcommand\grabbox@def[2]
+
+\@ifdefinable{\grabbox@def}{\long\def\grabbox@def#1#2#{\grabbox@def@a{#1}{#2}}}
+\@ifdefinable{\grabbox@def@a}
{%
- \@ifdefinable#1{\protected\def#1{#2}}%
+ \protected\long\def\grabbox@def@a#1#2#3%
+ {\@ifdefinable#1{\protected\def#1#2{#3}}}%
}
\newcommand\grabbox@def@step[4]
{%
- \@ifdefinable#1{\protected\def#1##1{\def#2{##1}\grabbox@opt#3#4}}%
+ \@ifdefinable#1{\grabbox@def#1##1{\def#2{##1}\grabbox@opt#3#4}}%
}
-\long\def\grabbox@check@bracket #1[#2\endgrabbox@check@bracket
- {%
- \if\relax\detokenize{#2}\relax
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
- }
-\protected\def\grabbox@opt#1#2%
+\long\def\grabbox@afterelsefi#1\else#2\fi{\fi#1}
+\long\def\grabbox@afterfi#1\fi{\fi#1}
+\long\def\grabbox@afterelsefiA\else#1\fi#2#3{\fi#2}
+\long\def\grabbox@afterfiB\fi#1#2{\fi#2}
+\grabbox@def\grabbox@opt#1#2%
{%
\@ifnextchar[
{\grabbox@opt@get#1#2}
{\def#1{}#2}%
}
-\long\def\grabbox@opt@get#1#2#3]%
- {%
- \expandafter\grabbox@opt@get@a\expandafter{\@gobble#3}#1#2%
- }
-\protected\long\def\grabbox@opt@get@a#1#2#3%
+\protected\long\def\grabbox@opt@get#1#2[#3]%
{%
- \grabbox@check@bracket #1[\endgrabbox@check@bracket
- {\def#2{#1}#3}
- {\grabbox@opt@get@b#2#3{#1]}}%
- }
-\protected\long\def\grabbox@opt@get@b#1#2#3#4]%
- {%
- \grabbox@check@bracket #4[\endgrabbox@check@bracket
- {\def#1{#3#4}#2}
- {\grabbox@opt@get@b#1#2{#3#4]}}%
+ \def#1{#3}#2%
}
\grabbox@def\grabbox@unpack
{%
- \expandafter\ifx\grabbox@type\hbox
- \expandafter\@firstoftwo
+ \begingroup
+ \edef\grabbox@test{\grabbox@type}%
+ \expandafter\ifx\grabbox@test\hbox
+ \endgroup
+ \grabbox@afterelsefi\unhbox
\else
- \expandafter\@secondoftwo
+ \endgroup
+ \grabbox@afterfi\unvbox
\fi
- \unhbox
- \unvbox
\grabbox@name
}
\grabbox@def\grabbox
@@ -97,8 +89,29 @@
\afterassignment\grabbox@intermediate
\setbox\grabbox@name\grabbox@type
}
+\grabbox@def\grabbox@set@color
+ {%
+ \@ifundefined{set@color}{}
+ {\global\let\grabbox@set@color\set@color\grabbox@set@color}%
+ }
+\AtBeginDocument
+ {%
+ \@ifundefined{set@color}
+ {\gdef\grabbox@set@color{}}
+ {\global\let\grabbox@set@color\set@color}%
+ }%
+\newcommand*\grabbox@unskip@space
+ {%
+ \ifhmode\unskip\fi
+ }
\grabbox@def\grabbox@intermediate
{%
+ \bgroup
+ \if@grabbox@spaces@
+ \else
+ \aftergroup\grabbox@unskip@space
+ \fi
+ \grabbox@set@color
\aftergroup\grabbox@after
\grabbox@into@pre
\if@grabbox@spaces@
@@ -106,23 +119,21 @@
\ignorespaces
\fi
}
+\newcommand*\grabbox@after@aux@b[1]
+ {%
+ \grabbox@after@aux@a
+ }
+\grabbox@def\grabbox@after@aux@a
+ {%
+ \@ifnextchar\reset@color
+ {\reset@color\grabbox@after@aux@b}
+ {\egroup\grabbox@final}%
+ }
\grabbox@def\grabbox@after
{%
- \if@grabbox@spaces@
- \setbox\grabbox@name\grabbox@type
- {%
- \grabbox@unpack
- \grabbox@into@post
- }%
- \else
- \setbox\grabbox@name\grabbox@type
- {%
- \grabbox@unpack
- \ifhmode\unskip\fi
- \grabbox@into@post
- }%
- \fi
- \grabbox@final
+ \grabbox@into@post
+ \endgraf
+ \grabbox@after@aux@a
}
%%
%%