summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/grabbox/grabbox.sty
blob: 22ab1b7880bfa89ad3c0ae8a059db2b546ee71bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
%%
%% This is file `grabbox.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% grabbox.dtx  (with options: `pkg')
%% 
%% --------------------------------------------------------------
%% grabbox -- utilities to get an argument as a box
%% E-mail: jspratte@yahoo.de
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%% 
%% Copyright (C) 2018 Jonathan P. Spratte
%% 
%% This  work may be  distributed and/or  modified under  the conditions  of the
%% LaTeX Project Public License (LPPL),  either version 1.3c  of this license or
%% (at your option) any later version.  The latest version of this license is in
%% the file:
%% 
%%   http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%%   Jonathan P. Spratte.
%% 
%% This work consists of the file  grabbox.dtx
%% and the derived files           grabbox.pdf and
%%                                 grabbox.sty.
%% 
\newcommand*\grabbox@date{2018-10-18}
\newcommand*\grabbox@version{1.0b}
\ProvidesPackage{grabbox}
  [\grabbox@date\ v\grabbox@version\ utilities to get an argument as a box]
\@ifdefinable{\if@grabbox@spaces@}{\newif\if@grabbox@spaces@}
\newcommand\grabbox@def[2]
  {%
    \@ifdefinable#1{\protected\def#1{#2}}%
  }
\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
  }
\protected\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%
  {%
    \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]}}%
  }
\grabbox@def\grabbox@unpack
  {%
    \expandafter\ifx\grabbox@type\hbox
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
    \unhbox
    \unvbox
    \grabbox@name
  }
\grabbox@def\grabbox
  {%
    \@ifstar
      {\@grabbox@spaces@true\grabbox@a}
      {\@grabbox@spaces@false\grabbox@a}%
  }
\grabbox@def@step\grabbox@a\grabbox@name\grabbox@into@pre\grabbox@b
\grabbox@def@step\grabbox@b\grabbox@type\grabbox@into@post\grabbox@c
\protected\long\def\grabbox@c#1%
  {%
    \def\grabbox@final{#1}%
    \afterassignment\grabbox@intermediate
    \setbox\grabbox@name\grabbox@type
  }
\grabbox@def\grabbox@intermediate
  {%
    \aftergroup\grabbox@after
    \grabbox@into@pre
    \if@grabbox@spaces@
    \else
      \ignorespaces
    \fi
  }
\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
  }
%% 
%%
%% End of file `grabbox.sty'.