texlive[49546] Master/texmf-dist: grabbox (30dec18)

commits+karl at tug.org commits+karl at tug.org
Sun Dec 30 23:13:00 CET 2018


Revision: 49546
          http://tug.org/svn/texlive?view=revision&revision=49546
Author:   karl
Date:     2018-12-30 23:12:59 +0100 (Sun, 30 Dec 2018)
Log Message:
-----------
grabbox (30dec18)

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-12-30 22:12:44 UTC (rev 49545)
+++ trunk/Master/texmf-dist/source/latex/grabbox/grabbox.dtx	2018-12-30 22:12:59 UTC (rev 49546)
@@ -77,8 +77,8 @@
 \end{document}
 %</driver>
 %<*pkg>
-\newcommand*\grabbox at date{2018-11-29}
-\newcommand*\grabbox at version{1.2}
+\newcommand*\grabbox at date{2018-12-29}
+\newcommand*\grabbox at version{1.3}
 \ProvidesPackage{grabbox}
   [%
     \grabbox at date\space v\grabbox at version\space utilities to get an argument as
@@ -104,7 +104,7 @@
 % \section{Introduction}
 %
 % Sometimes I happen to write macros and environments which don't care for the
-% exact contents of an argument but only for that contents typeset
+% 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 for macros. For environments this is quite easy to create thanks to
@@ -128,23 +128,39 @@
 % further -- because the user interface would've been too clumsy and require
 % strange markup like |\foo arg}| -- and therefore this package wouldn't have
 % been created.
+%
+% Additionally I want to thank David Carlisle for helping me making \cs{grabbox}
+% respect surrounding text colours.
 % 
 % \section{The macro}
 %
 % \begin{function}{\grabbox}
 %   \begin{syntax}
-%     \cs{grabbox}\meta{*}\marg{box register}\ignorespaces^^A
-%       \oarg{inject pre}\marg{box type}\oarg{inject post}\ignorespaces^^A
-%       \marg{afterwards}
+%     \cs{grabbox}\meta{*}\oarg{inject pre pre}\ignorespaces^^A
+%       \marg{box register}\oarg{inject pre}\marg{box type}\ignorespaces^^A
+%       \oarg{inject post}\marg{afterwards}
 %   \end{syntax}
 %   grabs the next braced argument and stores it inside of the box \meta{box
 %   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 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.
+%   or \cs{vbox} or \cs{vtop}. The contents of the box except for
+%   \meta{inject pre pre} and \meta{inject post} will be contained in an
+%   additional level of grouping to ensure colour safety (similar to \LaTeX's
+%   \cs{sbox}). \meta{inject pre pre} will be injected at the beginning of the
+%   box before this additional group is opened, \meta{inject pre} will be
+%   injected at the beginning of the box and can affect its contents,
+%   \meta{inject post} will be 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 -- \meta{inject pre pre} however can affect the
+%   contents of \meta{inject post}.
 %   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.
+%   The complete contents of the box will be something like:
+%   \begin{center}
+%     \csname verbatim at font\endcsname
+%     \meta{inject pre pre}^^A
+%     \{\cs{set at color}\meta{inject pre}\meta{argument}\}^^A
+%     \meta{inject post}
+%   \end{center}
 % \end{function}
 %
 %   \smallskip
@@ -159,8 +175,7 @@
 %
 %   Since \cs{grabbox} works by setting a boxregister using \cs{setbox} (and a
 %   bunch of temporary macros), it is of course not expandable and defined
-%   \cs{protected}. Bear in mind that macros created with \cs{grabbox} are
-%   not expandable.
+%   \cs{protected}.
 %
 % \section{Useless Example!}
 %
@@ -212,7 +227,7 @@
 %   }%
 % \examplecmd{Hi,}{my}{\verb|\name|}{Steve!}
 % \end{center}
-% One can see that \verb|\sffamily is| of \meta{inject post} is not affected by
+% One can see that \verb|\sffamily is| in \meta{inject post} is not affected by
 % the |\itshape| in \meta{inject pre}. The used code to generate that table was:
 %
 % \begin{verbatim}
@@ -246,8 +261,8 @@
 % \end{verbatim}
 %
 % As you can see, this macro uses \cs{grabbox} in a group delimited by
-% \cs{begingroup} and \cs{endgroup}. It should therefore be safe to nest it
-% inside other macros using \cs{grabbox}.
+% \cs{begingroup} and \cs{endgroup} -- like the useless example. It should
+% therefore be safe to nest it inside other macros using \cs{grabbox}.
 %
 % Finally a usage example of our new macro (with the \pkg{duckuments} package
 % loaded):
@@ -287,21 +302,21 @@
 %
 %    \begin{macrocode}
 \@ifdefinable{\if at grabbox@spaces@}{\newif\if at grabbox@spaces@}
-
-\@ifdefinable{\grabbox at def}{\long\def\grabbox at def#1#2#{\grabbox at def@a{#1}{#2}}}
+\@ifdefinable{\grabbox at def}
+  {\long\def\grabbox at def#1#2#{\grabbox at def@a{}#1{#2}}}
+\@ifdefinable{\grabbox at ldef}
+  {\long\def\grabbox at ldef#1#2#{\grabbox at def@a\long#1{#2}}}
 \@ifdefinable{\grabbox at def@a}
   {%
-    \protected\long\def\grabbox at def@a#1#2#3%
-      {\@ifdefinable#1{\protected\def#1#2{#3}}}%
+    \protected\long\def\grabbox at def@a#1#2#3#4%
+      {\@ifdefinable#2{\protected#1\def#2#3{#4}}}%
   }
 \newcommand\grabbox at def@step[4]
   {%
-    \@ifdefinable#1{\grabbox at def#1##1{\def#2{##1}\grabbox at opt#3#4}}%
+    \grabbox at def#1##1{\def#2{##1}\grabbox at opt#3#4}%
   }
 \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%
   {%
     \@ifnextchar[
@@ -308,10 +323,25 @@
       {\grabbox at opt@get#1#2}
       {\def#1{}#2}%
   }
-\protected\long\def\grabbox at opt@get#1#2[#3]%
+\grabbox at ldef\grabbox at opt@get#1#2[#3]%
   {%
     \def#1{#3}#2%
   }
+\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 unpack
   {%
     \begingroup
@@ -331,31 +361,21 @@
       {\@grabbox at spaces@true\grabbox at a}
       {\@grabbox at spaces@false\grabbox at a}%
   }
-\grabbox at def@step\grabbox at a\grabbox at name\grabbox at into@pre\grabbox at b
-\grabbox at def@step\grabbox at b\grabbox at type\grabbox at into@post\grabbox at c
-\protected\long\def\grabbox at c#1%
+\grabbox at def\grabbox at a
   {%
+    \grabbox at opt\grabbox at into@prepre\grabbox at b
+  }
+\grabbox at def@step\grabbox at b\grabbox at name\grabbox at into@pre\grabbox at c
+\grabbox at def@step\grabbox at c\grabbox at type\grabbox at into@post\grabbox at d
+\grabbox at ldef\grabbox at d#1%
+  {%
     \def\grabbox at final{#1}%
     \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
   {%
+    \grabbox at into@prepre
     \bgroup
     \if at grabbox@spaces@
     \else

Modified: trunk/Master/texmf-dist/tex/latex/grabbox/grabbox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/grabbox/grabbox.sty	2018-12-30 22:12:44 UTC (rev 49545)
+++ trunk/Master/texmf-dist/tex/latex/grabbox/grabbox.sty	2018-12-30 22:12:59 UTC (rev 49546)
@@ -29,8 +29,8 @@
 %% and the derived files           grabbox.pdf and
 %%                                 grabbox.sty.
 %% 
-\newcommand*\grabbox at date{2018-11-29}
-\newcommand*\grabbox at version{1.2}
+\newcommand*\grabbox at date{2018-12-29}
+\newcommand*\grabbox at version{1.3}
 \ProvidesPackage{grabbox}
   [%
     \grabbox at date\space v\grabbox at version\space utilities to get an argument as
@@ -37,21 +37,21 @@
     a box%
   ]
 \@ifdefinable{\if at grabbox@spaces@}{\newif\if at grabbox@spaces@}
-
-\@ifdefinable{\grabbox at def}{\long\def\grabbox at def#1#2#{\grabbox at def@a{#1}{#2}}}
+\@ifdefinable{\grabbox at def}
+  {\long\def\grabbox at def#1#2#{\grabbox at def@a{}#1{#2}}}
+\@ifdefinable{\grabbox at ldef}
+  {\long\def\grabbox at ldef#1#2#{\grabbox at def@a\long#1{#2}}}
 \@ifdefinable{\grabbox at def@a}
   {%
-    \protected\long\def\grabbox at def@a#1#2#3%
-      {\@ifdefinable#1{\protected\def#1#2{#3}}}%
+    \protected\long\def\grabbox at def@a#1#2#3#4%
+      {\@ifdefinable#2{\protected#1\def#2#3{#4}}}%
   }
 \newcommand\grabbox at def@step[4]
   {%
-    \@ifdefinable#1{\grabbox at def#1##1{\def#2{##1}\grabbox at opt#3#4}}%
+    \grabbox at def#1##1{\def#2{##1}\grabbox at opt#3#4}%
   }
 \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%
   {%
     \@ifnextchar[
@@ -58,10 +58,25 @@
       {\grabbox at opt@get#1#2}
       {\def#1{}#2}%
   }
-\protected\long\def\grabbox at opt@get#1#2[#3]%
+\grabbox at ldef\grabbox at opt@get#1#2[#3]%
   {%
     \def#1{#3}#2%
   }
+\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 unpack
   {%
     \begingroup
@@ -81,31 +96,21 @@
       {\@grabbox at spaces@true\grabbox at a}
       {\@grabbox at spaces@false\grabbox at a}%
   }
-\grabbox at def@step\grabbox at a\grabbox at name\grabbox at into@pre\grabbox at b
-\grabbox at def@step\grabbox at b\grabbox at type\grabbox at into@post\grabbox at c
-\protected\long\def\grabbox at c#1%
+\grabbox at def\grabbox at a
   {%
+    \grabbox at opt\grabbox at into@prepre\grabbox at b
+  }
+\grabbox at def@step\grabbox at b\grabbox at name\grabbox at into@pre\grabbox at c
+\grabbox at def@step\grabbox at c\grabbox at type\grabbox at into@post\grabbox at d
+\grabbox at ldef\grabbox at d#1%
+  {%
     \def\grabbox at final{#1}%
     \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
   {%
+    \grabbox at into@prepre
     \bgroup
     \if at grabbox@spaces@
     \else



More information about the tex-live-commits mailing list