summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/grabbox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-11-29 23:19:52 +0000
committerKarl Berry <karl@freefriends.org>2018-11-29 23:19:52 +0000
commitdc0bc16db5518a8c0eed4b652b1a79d109e2bd56 (patch)
treeddd59e907aa12d7cb2e5f3da9d69a9e2a6db6530 /Master/texmf-dist/tex/latex/grabbox
parent67346dfe318b0d3d08c7104eefd0a5bc34a84996 (diff)
grabbox (29nov18)
git-svn-id: svn://tug.org/texlive/trunk@49274 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/grabbox')
-rw-r--r--Master/texmf-dist/tex/latex/grabbox/grabbox.sty109
1 files changed, 60 insertions, 49 deletions
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
}
%%
%%