|
@@ -1,6 +1,6 @@
|
1
|
1
|
% \iffalse meta-comment
|
2
|
2
|
%
|
3
|
|
-% File: boxgrab.dtx Copyright (C) 2018 Jonathan P. Spratte
|
|
3
|
+% File: grabbox.dtx Copyright (C) 2018 Jonathan P. Spratte
|
4
|
4
|
%
|
5
|
5
|
% It may be distributed and/or modified under the conditions of the LaTeX
|
6
|
6
|
% Project Public License (LPPL), either version 1.3c of this license or (at your
|
|
@@ -20,7 +20,7 @@
|
20
|
20
|
\preamble
|
21
|
21
|
|
22
|
22
|
--------------------------------------------------------------
|
23
|
|
-boxgrab -- utilities to get an argument as a box
|
|
23
|
+grabbox -- utilities to get an argument as a box
|
24
|
24
|
E-mail: jspratte@yahoo.de
|
25
|
25
|
Released under the LaTeX Project Public License v1.3c or later
|
26
|
26
|
See http://www.latex-project.org/lppl.txt
|
|
@@ -38,15 +38,15 @@ the file:
|
38
|
38
|
This work is "maintained" (as per LPPL maintenance status) by
|
39
|
39
|
Jonathan P. Spratte.
|
40
|
40
|
|
41
|
|
-This work consists of the file boxgrab.dtx
|
42
|
|
-and the derived files boxgrab.pdf and
|
43
|
|
- boxgrab.sty.
|
|
41
|
+This work consists of the file grabbox.dtx
|
|
42
|
+and the derived files grabbox.pdf and
|
|
43
|
+ grabbox.sty.
|
44
|
44
|
|
45
|
45
|
\endpreamble
|
46
|
46
|
% stop docstrip adding \endinput
|
47
|
47
|
\postamble
|
48
|
48
|
\endpostamble
|
49
|
|
-\generate{\file{boxgrab.sty}{\from{boxgrab.dtx}{pkg}}}
|
|
49
|
+\generate{\file{grabbox.sty}{\from{grabbox.dtx}{pkg}}}
|
50
|
50
|
\ifx\fmtname\nameofplainTeX
|
51
|
51
|
\expandafter\endbatchfile
|
52
|
52
|
\else
|
|
@@ -55,39 +55,39 @@ and the derived files boxgrab.pdf and
|
55
|
55
|
%</driver>
|
56
|
56
|
%
|
57
|
57
|
%<*driver>
|
58
|
|
-\ProvidesFile{boxgrab.dtx}
|
|
58
|
+\ProvidesFile{grabbox.dtx}
|
59
|
59
|
[%
|
60
|
|
- \csname boxgrab@date\endcsname\
|
|
60
|
+ \csname grabbox@date\endcsname\
|
61
|
61
|
utilities to get an argument as a box%
|
62
|
62
|
]
|
63
|
63
|
\documentclass{l3doc}
|
64
|
64
|
\usepackage{duckuments}
|
65
|
|
-\usepackage{boxgrab}
|
|
65
|
+\usepackage{grabbox}
|
66
|
66
|
\author{Jonathan P. Spratte\thanks{Email: jspratte@yahoo.de}}
|
67
|
|
-\title{The \pkg{boxgrab} package}
|
|
67
|
+\title{The \pkg{grabbox} package}
|
68
|
68
|
\makeatletter
|
69
|
|
-\date{\boxgrab@date\ v\boxgrab@version}
|
|
69
|
+\date{\grabbox@date\ v\grabbox@version}
|
70
|
70
|
\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
|
71
|
71
|
\makeatother
|
72
|
72
|
\begin{document}
|
73
|
|
- \DocInput{boxgrab.dtx}
|
|
73
|
+ \DocInput{grabbox.dtx}
|
74
|
74
|
\end{document}
|
75
|
75
|
%</driver>
|
76
|
76
|
%<*pkg>
|
77
|
|
-\newcommand*\boxgrab@date{2018-10-17}
|
78
|
|
-\newcommand*\boxgrab@version{1.0}
|
79
|
|
-\ProvidesPackage{boxgrab}
|
80
|
|
- [\boxgrab@date\ v\boxgrab@version\ utilities to get an argument as a box]
|
|
77
|
+\newcommand*\grabbox@date{2018-10-17}
|
|
78
|
+\newcommand*\grabbox@version{1.0}
|
|
79
|
+\ProvidesPackage{grabbox}
|
|
80
|
+ [\grabbox@date\ v\grabbox@version\ utilities to get an argument as a box]
|
81
|
81
|
%</pkg>
|
82
|
82
|
% \fi
|
83
|
83
|
%
|
84
|
84
|
% \begin{center}
|
85
|
|
-% \LARGE The \pkg{boxgrab} package\\[\bigskipamount]
|
|
85
|
+% \LARGE The \pkg{grabbox} package\\[\bigskipamount]
|
86
|
86
|
% \large
|
87
|
87
|
% \setcounter{footnote}{1}%
|
88
|
88
|
% Jonathan P. Spratte\footnotemark\\[\medskipamount]
|
89
|
|
-% Version \csname boxgrab@version\endcsname\\[\smallskipamount]
|
90
|
|
-% Released \csname boxgrab@date\endcsname
|
|
89
|
+% Version \csname grabbox@version\endcsname\\[\smallskipamount]
|
|
90
|
+% Released \csname grabbox@date\endcsname
|
91
|
91
|
% \end{center}
|
92
|
92
|
% \footnotetext{E-mail: jspratte@yahoo.de}
|
93
|
93
|
%
|
|
@@ -97,20 +97,20 @@ and the derived files boxgrab.pdf and
|
97
|
97
|
%
|
98
|
98
|
% \section{Introduction}
|
99
|
99
|
%
|
100
|
|
-% This package provides \cs{boxgrab} to grab an argument inside of a box. The
|
|
100
|
+% This package provides \cs{grabbox} to grab an argument inside of a box. The
|
101
|
101
|
% used mechanism allows category code changes in that argument as long as it is
|
102
|
102
|
% used in a place allowing category code changes (so not inside of another
|
103
|
103
|
% argument).
|
104
|
104
|
%
|
105
|
|
-% It is written as a docstrip file: executing |latex boxgrab.dtx| generates the
|
106
|
|
-% \file{boxgrab.sty} file and typesets this documentation; execute
|
107
|
|
-% |tex boxgrab.dtx| to only generate \file{boxgrab.sty}.
|
|
105
|
+% It is written as a docstrip file: executing |latex grabbox.dtx| generates the
|
|
106
|
+% \file{grabbox.sty} file and typesets this documentation; execute
|
|
107
|
+% |tex grabbox.dtx| to only generate \file{grabbox.sty}.
|
108
|
108
|
%
|
109
|
109
|
% \section{The macro}
|
110
|
110
|
%
|
111
|
|
-% \begin{function}{\boxgrab}
|
|
111
|
+% \begin{function}{\grabbox}
|
112
|
112
|
% \begin{syntax}
|
113
|
|
-% \cs{boxgrab}\meta{*}
|
|
113
|
+% \cs{grabbox}\meta{*}
|
114
|
114
|
% \marg{box register}\oarg{inject pre}\marg{box type}\oarg{inject post}
|
115
|
115
|
% \marg{next}\oarg{save args}
|
116
|
116
|
% \end{syntax}
|
|
@@ -131,18 +131,18 @@ and the derived files boxgrab.pdf and
|
131
|
131
|
%
|
132
|
132
|
% \smallskip
|
133
|
133
|
% All assignments are made local. Currently it is not safe to nest macros
|
134
|
|
-% which use \cs{boxgrab}. It should become save if you're macros use
|
135
|
|
-% \cs{boxgrab} inside of a group, so the local assignments don't affect the
|
|
134
|
+% which use \cs{grabbox}. It should become save if you're macros use
|
|
135
|
+% \cs{grabbox} inside of a group, so the local assignments don't affect the
|
136
|
136
|
% outer macro.
|
137
|
137
|
%
|
138
|
|
-% \cs{boxgrab} uses \cs{afterassignment} and \cs{aftergroup} to do its magic.
|
|
138
|
+% \cs{grabbox} uses \cs{afterassignment} and \cs{aftergroup} to do its magic.
|
139
|
139
|
% The \cs{afterassignment} should be safe where it is used, the
|
140
|
140
|
% \cs{aftergroup} is used inside of the boxed argument before any contents are
|
141
|
141
|
% inserted.
|
142
|
142
|
%
|
143
|
|
-% Since \cs{boxgrab} works by setting a boxregister using \cs{setbox} (and a
|
|
143
|
+% Since \cs{grabbox} works by setting a boxregister using \cs{setbox} (and a
|
144
|
144
|
% bunch of temporary macros), it is of course not expandable and defined
|
145
|
|
-% \cs{protected}. Bear in mind that macros created with \cs{boxgrab} are
|
|
145
|
+% \cs{protected}. Bear in mind that macros created with \cs{grabbox} are
|
146
|
146
|
% not expandable.
|
147
|
147
|
%
|
148
|
148
|
% \section{Useless Example!}
|
|
@@ -159,11 +159,11 @@ and the derived files boxgrab.pdf and
|
159
|
159
|
% \newcommand\examplecmd[2]
|
160
|
160
|
% {%
|
161
|
161
|
% \begingroup
|
162
|
|
-% \boxgrab\ourbox[\itshape]\hbox[ \sffamily is]\examplecmdOut[{#1}{#2}]
|
|
162
|
+% \grabbox\ourbox[\itshape]\hbox[ \sffamily is]\examplecmdOut[{#1}{#2}]
|
163
|
163
|
% }
|
164
|
164
|
% \end{verbatim}
|
165
|
165
|
%
|
166
|
|
-% And we need our helper macro which is executed after \cs{boxgrab}:
|
|
166
|
+% And we need our helper macro which is executed after \cs{grabbox}:
|
167
|
167
|
%
|
168
|
168
|
% \begin{verbatim}
|
169
|
169
|
% \newcommand\examplecmdOut[3]
|
|
@@ -186,7 +186,7 @@ and the derived files boxgrab.pdf and
|
186
|
186
|
% \newcommand\examplecmd[2]
|
187
|
187
|
% {%
|
188
|
188
|
% \begingroup
|
189
|
|
-% \boxgrab\ourbox[\itshape]\hbox[ \sffamily is]\examplecmdOut[{#1}{#2}]
|
|
189
|
+% \grabbox\ourbox[\itshape]\hbox[ \sffamily is]\examplecmdOut[{#1}{#2}]
|
190
|
190
|
% }%
|
191
|
191
|
% \newcommand\examplecmdOut[3]
|
192
|
192
|
% {%
|
|
@@ -220,7 +220,7 @@ and the derived files boxgrab.pdf and
|
220
|
220
|
% \newcommand\Rectangle[1][4]
|
221
|
221
|
% {%
|
222
|
222
|
% \begingroup
|
223
|
|
-% \boxgrab\RectangleBox\hbox\RectangleOut[{#1}]
|
|
223
|
+% \grabbox\RectangleBox\hbox\RectangleOut[{#1}]
|
224
|
224
|
% }
|
225
|
225
|
% % Defining the secondary macro
|
226
|
226
|
% \newcommand\RectangleOut[1]
|
|
@@ -233,9 +233,9 @@ and the derived files boxgrab.pdf and
|
233
|
233
|
% }
|
234
|
234
|
% \end{verbatim}
|
235
|
235
|
%
|
236
|
|
-% As you can see, this macro uses \cs{boxgrab} in a group delimited by
|
|
236
|
+% As you can see, this macro uses \cs{grabbox} in a group delimited by
|
237
|
237
|
% \cs{begingroup} and \cs{endgroup}. It should therefore be safe to nest it
|
238
|
|
-% inside other macros using \cs{boxgrab}.
|
|
238
|
+% inside other macros using \cs{grabbox}.
|
239
|
239
|
%
|
240
|
240
|
% Finally a usage example of our new macro (with the \pkg{duckuments} package
|
241
|
241
|
% loaded):
|
|
@@ -250,7 +250,7 @@ and the derived files boxgrab.pdf and
|
250
|
250
|
% \newcommand\Rectangle[1][4]
|
251
|
251
|
% {%
|
252
|
252
|
% \begingroup
|
253
|
|
-% \boxgrab\RectangleBox\hbox\RectangleOut[{#1}]
|
|
253
|
+% \grabbox\RectangleBox\hbox\RectangleOut[{#1}]
|
254
|
254
|
% }%
|
255
|
255
|
% \newcommand\RectangleOut[1]
|
256
|
256
|
% {%
|
|
@@ -275,17 +275,17 @@ and the derived files boxgrab.pdf and
|
275
|
275
|
% \end{macrocode}
|
276
|
276
|
%
|
277
|
277
|
% \begin{macrocode}
|
278
|
|
-\@ifdefinable{\if@boxgrab@spaces@}{\newif\if@boxgrab@spaces@}
|
279
|
|
-\newcommand*\boxgrab@args{}%
|
280
|
|
-\newcommand\boxgrab@def[2]
|
|
278
|
+\@ifdefinable{\if@grabbox@spaces@}{\newif\if@grabbox@spaces@}
|
|
279
|
+\newcommand*\grabbox@args{}%
|
|
280
|
+\newcommand\grabbox@def[2]
|
281
|
281
|
{%
|
282
|
282
|
\@ifdefinable#1{\protected\def#1{#2}}%
|
283
|
283
|
}
|
284
|
|
-\newcommand\boxgrab@def@step[4]
|
|
284
|
+\newcommand\grabbox@def@step[4]
|
285
|
285
|
{%
|
286
|
|
- \@ifdefinable#1{\protected\def#1##1{\def#2{##1}\boxgrab@opt#3#4}}%
|
|
286
|
+ \@ifdefinable#1{\protected\def#1##1{\def#2{##1}\grabbox@opt#3#4}}%
|
287
|
287
|
}
|
288
|
|
-\long\def\boxgrab@check@bracket #1[#2\endboxgrab@check@bracket
|
|
288
|
+\long\def\grabbox@check@bracket #1[#2\endgrabbox@check@bracket
|
289
|
289
|
{%
|
290
|
290
|
\if\relax\detokenize{#2}\relax
|
291
|
291
|
\expandafter\@firstoftwo
|
|
@@ -293,80 +293,80 @@ and the derived files boxgrab.pdf and
|
293
|
293
|
\expandafter\@secondoftwo
|
294
|
294
|
\fi
|
295
|
295
|
}
|
296
|
|
-\protected\def\boxgrab@opt#1#2%
|
|
296
|
+\protected\def\grabbox@opt#1#2%
|
297
|
297
|
{%
|
298
|
298
|
\@ifnextchar[
|
299
|
|
- {\boxgrab@opt@get#1#2}
|
|
299
|
+ {\grabbox@opt@get#1#2}
|
300
|
300
|
{\def#1{}#2}%
|
301
|
301
|
}
|
302
|
|
-\long\def\boxgrab@opt@get#1#2#3]%
|
|
302
|
+\long\def\grabbox@opt@get#1#2#3]%
|
303
|
303
|
{%
|
304
|
|
- \expandafter\boxgrab@opt@get@a\expandafter{\@gobble#3}#1#2%
|
|
304
|
+ \expandafter\grabbox@opt@get@a\expandafter{\@gobble#3}#1#2%
|
305
|
305
|
}
|
306
|
|
-\protected\long\def\boxgrab@opt@get@a#1#2#3%
|
|
306
|
+\protected\long\def\grabbox@opt@get@a#1#2#3%
|
307
|
307
|
{%
|
308
|
|
- \boxgrab@check@bracket #1[\endboxgrab@check@bracket
|
|
308
|
+ \grabbox@check@bracket #1[\endgrabbox@check@bracket
|
309
|
309
|
{\def#2{#1}#3}
|
310
|
|
- {\boxgrab@opt@get@b#2#3{#1]}}%
|
|
310
|
+ {\grabbox@opt@get@b#2#3{#1]}}%
|
311
|
311
|
}
|
312
|
|
-\protected\long\def\boxgrab@opt@get@b#1#2#3#4]%
|
|
312
|
+\protected\long\def\grabbox@opt@get@b#1#2#3#4]%
|
313
|
313
|
{%
|
314
|
|
- \boxgrab@check@bracket #4[\endboxgrab@check@bracket
|
|
314
|
+ \grabbox@check@bracket #4[\endgrabbox@check@bracket
|
315
|
315
|
{\def#1{#3#4}#2}
|
316
|
|
- {\boxgrab@opt@get@b#1#2{#3#4]}}%
|
|
316
|
+ {\grabbox@opt@get@b#1#2{#3#4]}}%
|
317
|
317
|
}
|
318
|
|
-\boxgrab@def\boxgrab@unpack
|
|
318
|
+\grabbox@def\grabbox@unpack
|
319
|
319
|
{%
|
320
|
|
- \expandafter\ifx\boxgrab@type\hbox
|
|
320
|
+ \expandafter\ifx\grabbox@type\hbox
|
321
|
321
|
\expandafter\@firstoftwo
|
322
|
322
|
\else
|
323
|
323
|
\expandafter\@secondoftwo
|
324
|
324
|
\fi
|
325
|
325
|
\unhbox
|
326
|
326
|
\unvbox
|
327
|
|
- \boxgrab@name
|
|
327
|
+ \grabbox@name
|
328
|
328
|
}
|
329
|
|
-\boxgrab@def\boxgrab
|
|
329
|
+\grabbox@def\grabbox
|
330
|
330
|
{%
|
331
|
331
|
\@ifstar
|
332
|
|
- {\@boxgrab@spaces@true\boxgrab@a}
|
333
|
|
- {\@boxgrab@spaces@false\boxgrab@a}%
|
|
332
|
+ {\@grabbox@spaces@true\grabbox@a}
|
|
333
|
+ {\@grabbox@spaces@false\grabbox@a}%
|
334
|
334
|
}
|
335
|
|
-\boxgrab@def@step\boxgrab@a\boxgrab@name\boxgrab@into@pre\boxgrab@b
|
336
|
|
-\boxgrab@def@step\boxgrab@b\boxgrab@type\boxgrab@into@post\boxgrab@c
|
337
|
|
-\boxgrab@def@step\boxgrab@c\boxgrab@final\boxgrab@args\boxgrab@d
|
338
|
|
-\boxgrab@def\boxgrab@d
|
|
335
|
+\grabbox@def@step\grabbox@a\grabbox@name\grabbox@into@pre\grabbox@b
|
|
336
|
+\grabbox@def@step\grabbox@b\grabbox@type\grabbox@into@post\grabbox@c
|
|
337
|
+\grabbox@def@step\grabbox@c\grabbox@final\grabbox@args\grabbox@d
|
|
338
|
+\grabbox@def\grabbox@d
|
339
|
339
|
{%
|
340
|
|
- \afterassignment\boxgrab@intermediate
|
341
|
|
- \setbox\boxgrab@name\boxgrab@type
|
|
340
|
+ \afterassignment\grabbox@intermediate
|
|
341
|
+ \setbox\grabbox@name\grabbox@type
|
342
|
342
|
}
|
343
|
|
-\boxgrab@def\boxgrab@intermediate
|
|
343
|
+\grabbox@def\grabbox@intermediate
|
344
|
344
|
{%
|
345
|
|
- \aftergroup\boxgrab@after
|
346
|
|
- \boxgrab@into@pre
|
|
345
|
+ \aftergroup\grabbox@after
|
|
346
|
+ \grabbox@into@pre
|
347
|
347
|
}
|
348
|
|
-\boxgrab@def\boxgrab@after
|
|
348
|
+\grabbox@def\grabbox@after
|
349
|
349
|
{%
|
350
|
|
- \if@boxgrab@spaces@
|
351
|
|
- \setbox\boxgrab@name\boxgrab@type
|
|
350
|
+ \if@grabbox@spaces@
|
|
351
|
+ \setbox\grabbox@name\grabbox@type
|
352
|
352
|
{%
|
353
|
|
- \boxgrab@unpack
|
354
|
|
- \boxgrab@into@post
|
|
353
|
+ \grabbox@unpack
|
|
354
|
+ \grabbox@into@post
|
355
|
355
|
}%
|
356
|
356
|
\else
|
357
|
|
- \setbox\boxgrab@name\boxgrab@type
|
|
357
|
+ \setbox\grabbox@name\grabbox@type
|
358
|
358
|
{%
|
359
|
|
- \boxgrab@unpack
|
|
359
|
+ \grabbox@unpack
|
360
|
360
|
\ifhmode\unskip\fi
|
361
|
|
- \boxgrab@into@post
|
|
361
|
+ \grabbox@into@post
|
362
|
362
|
}%
|
363
|
363
|
\fi
|
364
|
|
- \expandafter\boxgrab@final@exp@args\expandafter{\boxgrab@args}%
|
|
364
|
+ \expandafter\grabbox@final@exp@args\expandafter{\grabbox@args}%
|
365
|
365
|
}
|
366
|
|
-\newcommand\boxgrab@final@exp@args[1]
|
|
366
|
+\newcommand\grabbox@final@exp@args[1]
|
367
|
367
|
{%
|
368
|
|
- \def\boxgrab@args{}%
|
369
|
|
- \boxgrab@final#1%
|
|
368
|
+ \def\grabbox@args{}%
|
|
369
|
+ \grabbox@final#1%
|
370
|
370
|
}
|
371
|
371
|
% \end{macrocode}
|
372
|
372
|
%
|