texlive[49274] Master/texmf-dist: grabbox (29nov18)
commits+karl at tug.org
commits+karl at tug.org
Fri Nov 30 00:19:52 CET 2018
Revision: 49274
http://tug.org/svn/texlive?view=revision&revision=49274
Author: karl
Date: 2018-11-30 00:19:52 +0100 (Fri, 30 Nov 2018)
Log Message:
-----------
grabbox (29nov18)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/grabbox/grabbox.pdf
trunk/Master/texmf-dist/source/latex/grabbox/grabbox.dtx
trunk/Master/texmf-dist/tex/latex/grabbox/grabbox.sty
Modified: trunk/Master/texmf-dist/doc/latex/grabbox/grabbox.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/grabbox/grabbox.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/grabbox/grabbox.dtx 2018-11-29 23:19:26 UTC (rev 49273)
+++ trunk/Master/texmf-dist/source/latex/grabbox/grabbox.dtx 2018-11-29 23:19:52 UTC (rev 49274)
@@ -57,7 +57,7 @@
%<*driver>
\ProvidesFile{grabbox.dtx}
[%
- \csname grabbox at date\endcsname\
+ \csname grabbox at date\endcsname\space
utilities to get an argument as a box%
]
\expandafter\def\csname @classoptionslist\endcsname{}
@@ -77,10 +77,13 @@
\end{document}
%</driver>
%<*pkg>
-\newcommand*\grabbox at date{2018-10-18}
-\newcommand*\grabbox at version{1.0b}
+\newcommand*\grabbox at date{2018-11-29}
+\newcommand*\grabbox at version{1.2}
\ProvidesPackage{grabbox}
- [\grabbox at date\ v\grabbox at version\ utilities to get an argument as a box]
+ [%
+ \grabbox at date\space v\grabbox at version\space utilities to get an argument as
+ a box%
+ ]
%</pkg>
% \fi
%
@@ -104,7 +107,9 @@
% 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 @@
% 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 @@
% \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 @@
%
% \begin{macrocode}
\@ifdefinable{\if at grabbox@spaces@}{\newif\if at grabbox@spaces@}
-\newcommand\grabbox at def[2]
+
+\@ifdefinable{\grabbox at def}{\long\def\grabbox at def#1#2#{\grabbox at def@a{#1}{#2}}}
+\@ifdefinable{\grabbox at def@a}
{%
- \@ifdefinable#1{\protected\def#1{#2}}%
+ \protected\long\def\grabbox at def@a#1#2#3%
+ {\@ifdefinable#1{\protected\def#1#2{#3}}}%
}
\newcommand\grabbox at def@step[4]
{%
- \@ifdefinable#1{\protected\def#1##1{\def#2{##1}\grabbox at opt#3#4}}%
+ \@ifdefinable#1{\grabbox at def#1##1{\def#2{##1}\grabbox at opt#3#4}}%
}
-\long\def\grabbox at check@bracket #1[#2\endgrabbox at check@bracket
+\long\def\grabbox at afterelsefi#1\else#2\fi{\fi#1}
+\long\def\grabbox at afterfi#1\fi{\fi#1}
+\long\def\grabbox at afterelsefiA\else#1\fi#2#3{\fi#2}
+\long\def\grabbox at afterfiB\fi#1#2{\fi#2}
+\grabbox at def\grabbox at opt#1#2%
{%
- \if\relax\detokenize{#2}\relax
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
- }
-\protected\def\grabbox at opt#1#2%
- {%
\@ifnextchar[
{\grabbox at opt@get#1#2}
{\def#1{}#2}%
}
-\long\def\grabbox at opt@get#1#2#3]%
+\protected\long\def\grabbox at opt@get#1#2[#3]%
{%
- \expandafter\grabbox at opt@get at a\expandafter{\@gobble#3}#1#2%
+ \def#1{#3}#2%
}
-\protected\long\def\grabbox at opt@get at a#1#2#3%
- {%
- \grabbox at check@bracket #1[\endgrabbox at check@bracket
- {\def#2{#1}#3}
- {\grabbox at opt@get at b#2#3{#1]}}%
- }
-\protected\long\def\grabbox at opt@get at b#1#2#3#4]%
- {%
- \grabbox at check@bracket #4[\endgrabbox at check@bracket
- {\def#1{#3#4}#2}
- {\grabbox at opt@get at b#1#2{#3#4]}}%
- }
\grabbox at def\grabbox at unpack
{%
- \expandafter\ifx\grabbox at type\hbox
- \expandafter\@firstoftwo
+ \begingroup
+ \edef\grabbox at test{\grabbox at type}%
+ \expandafter\ifx\grabbox at test\hbox
+ \endgroup
+ \grabbox at afterelsefi\unhbox
\else
- \expandafter\@secondoftwo
+ \endgroup
+ \grabbox at afterfi\unvbox
\fi
- \unhbox
- \unvbox
\grabbox at name
}
\grabbox at def\grabbox
@@ -345,8 +339,29 @@
\afterassignment\grabbox at intermediate
\setbox\grabbox at name\grabbox at type
}
+\grabbox at def\grabbox at set@color
+ {%
+ \@ifundefined{set at color}{}
+ {\global\let\grabbox at set@color\set at color\grabbox at set@color}%
+ }
+\AtBeginDocument
+ {%
+ \@ifundefined{set at color}
+ {\gdef\grabbox at set@color{}}
+ {\global\let\grabbox at set@color\set at color}%
+ }%
+\newcommand*\grabbox at unskip@space
+ {%
+ \ifhmode\unskip\fi
+ }
\grabbox at def\grabbox at intermediate
{%
+ \bgroup
+ \if at grabbox@spaces@
+ \else
+ \aftergroup\grabbox at unskip@space
+ \fi
+ \grabbox at set@color
\aftergroup\grabbox at after
\grabbox at into@pre
\if at grabbox@spaces@
@@ -354,23 +369,21 @@
\ignorespaces
\fi
}
+\newcommand*\grabbox at after@aux at b[1]
+ {%
+ \grabbox at after@aux at a
+ }
+\grabbox at def\grabbox at after@aux at a
+ {%
+ \@ifnextchar\reset at color
+ {\reset at color\grabbox at after@aux at b}
+ {\egroup\grabbox at final}%
+ }
\grabbox at def\grabbox at after
{%
- \if at grabbox@spaces@
- \setbox\grabbox at name\grabbox at type
- {%
- \grabbox at unpack
- \grabbox at into@post
- }%
- \else
- \setbox\grabbox at name\grabbox at type
- {%
- \grabbox at unpack
- \ifhmode\unskip\fi
- \grabbox at into@post
- }%
- \fi
- \grabbox at final
+ \grabbox at into@post
+ \endgraf
+ \grabbox at after@aux at a
}
% \end{macrocode}
%
Modified: trunk/Master/texmf-dist/tex/latex/grabbox/grabbox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/grabbox/grabbox.sty 2018-11-29 23:19:26 UTC (rev 49273)
+++ trunk/Master/texmf-dist/tex/latex/grabbox/grabbox.sty 2018-11-29 23:19:52 UTC (rev 49274)
@@ -29,58 +29,50 @@
%% and the derived files grabbox.pdf and
%% grabbox.sty.
%%
-\newcommand*\grabbox at date{2018-10-18}
-\newcommand*\grabbox at version{1.0b}
+\newcommand*\grabbox at date{2018-11-29}
+\newcommand*\grabbox at version{1.2}
\ProvidesPackage{grabbox}
- [\grabbox at date\ v\grabbox at version\ utilities to get an argument as a box]
+ [%
+ \grabbox at date\space v\grabbox at version\space utilities to get an argument as
+ a box%
+ ]
\@ifdefinable{\if at grabbox@spaces@}{\newif\if at grabbox@spaces@}
-\newcommand\grabbox at def[2]
+
+\@ifdefinable{\grabbox at def}{\long\def\grabbox at def#1#2#{\grabbox at def@a{#1}{#2}}}
+\@ifdefinable{\grabbox at def@a}
{%
- \@ifdefinable#1{\protected\def#1{#2}}%
+ \protected\long\def\grabbox at def@a#1#2#3%
+ {\@ifdefinable#1{\protected\def#1#2{#3}}}%
}
\newcommand\grabbox at def@step[4]
{%
- \@ifdefinable#1{\protected\def#1##1{\def#2{##1}\grabbox at opt#3#4}}%
+ \@ifdefinable#1{\grabbox at def#1##1{\def#2{##1}\grabbox at opt#3#4}}%
}
-\long\def\grabbox at check@bracket #1[#2\endgrabbox at check@bracket
+\long\def\grabbox at afterelsefi#1\else#2\fi{\fi#1}
+\long\def\grabbox at afterfi#1\fi{\fi#1}
+\long\def\grabbox at afterelsefiA\else#1\fi#2#3{\fi#2}
+\long\def\grabbox at afterfiB\fi#1#2{\fi#2}
+\grabbox at def\grabbox at opt#1#2%
{%
- \if\relax\detokenize{#2}\relax
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
- }
-\protected\def\grabbox at opt#1#2%
- {%
\@ifnextchar[
{\grabbox at opt@get#1#2}
{\def#1{}#2}%
}
-\long\def\grabbox at opt@get#1#2#3]%
+\protected\long\def\grabbox at opt@get#1#2[#3]%
{%
- \expandafter\grabbox at opt@get at a\expandafter{\@gobble#3}#1#2%
+ \def#1{#3}#2%
}
-\protected\long\def\grabbox at opt@get at a#1#2#3%
- {%
- \grabbox at check@bracket #1[\endgrabbox at check@bracket
- {\def#2{#1}#3}
- {\grabbox at opt@get at b#2#3{#1]}}%
- }
-\protected\long\def\grabbox at opt@get at b#1#2#3#4]%
- {%
- \grabbox at check@bracket #4[\endgrabbox at check@bracket
- {\def#1{#3#4}#2}
- {\grabbox at opt@get at b#1#2{#3#4]}}%
- }
\grabbox at def\grabbox at unpack
{%
- \expandafter\ifx\grabbox at type\hbox
- \expandafter\@firstoftwo
+ \begingroup
+ \edef\grabbox at test{\grabbox at type}%
+ \expandafter\ifx\grabbox at test\hbox
+ \endgroup
+ \grabbox at afterelsefi\unhbox
\else
- \expandafter\@secondoftwo
+ \endgroup
+ \grabbox at afterfi\unvbox
\fi
- \unhbox
- \unvbox
\grabbox at name
}
\grabbox at def\grabbox
@@ -97,8 +89,29 @@
\afterassignment\grabbox at intermediate
\setbox\grabbox at name\grabbox at type
}
+\grabbox at def\grabbox at set@color
+ {%
+ \@ifundefined{set at color}{}
+ {\global\let\grabbox at set@color\set at color\grabbox at set@color}%
+ }
+\AtBeginDocument
+ {%
+ \@ifundefined{set at color}
+ {\gdef\grabbox at set@color{}}
+ {\global\let\grabbox at set@color\set at color}%
+ }%
+\newcommand*\grabbox at unskip@space
+ {%
+ \ifhmode\unskip\fi
+ }
\grabbox at def\grabbox at intermediate
{%
+ \bgroup
+ \if at grabbox@spaces@
+ \else
+ \aftergroup\grabbox at unskip@space
+ \fi
+ \grabbox at set@color
\aftergroup\grabbox at after
\grabbox at into@pre
\if at grabbox@spaces@
@@ -106,23 +119,21 @@
\ignorespaces
\fi
}
+\newcommand*\grabbox at after@aux at b[1]
+ {%
+ \grabbox at after@aux at a
+ }
+\grabbox at def\grabbox at after@aux at a
+ {%
+ \@ifnextchar\reset at color
+ {\reset at color\grabbox at after@aux at b}
+ {\egroup\grabbox at final}%
+ }
\grabbox at def\grabbox at after
{%
- \if at grabbox@spaces@
- \setbox\grabbox at name\grabbox at type
- {%
- \grabbox at unpack
- \grabbox at into@post
- }%
- \else
- \setbox\grabbox at name\grabbox at type
- {%
- \grabbox at unpack
- \ifhmode\unskip\fi
- \grabbox at into@post
- }%
- \fi
- \grabbox at final
+ \grabbox at into@post
+ \endgraf
+ \grabbox at after@aux at a
}
%%
%%
More information about the tex-live-commits
mailing list