summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/interfaces/interfaces-makecell.sty
blob: 3ffd767fe77d91909af83c038baa67b539fca2a3 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
%%
%% This is file `interfaces-makecell.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% interfaces.dtx  (with options: `makecell')
%% 
%% This is a generated file.
%% 
%% interfaces : 2010/11/15 v2.1 - interfaces : interfaces with keys for other packages (FC)
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version. The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%% 
%% This work consists of the main source file interfaces.dtx
%% and the derived files
%%     interfaces.sty, interfaces.pdf, interfaces.ins,
%%     interfaces-base.sty,
%%     interfaces-LaTeX.sty,
%%     interfaces-tikz.sty,
%%     interfaces-titlesec.sty,
%%     interfaces-hyperref.sty,
%%     interfaces-bookmark.sty,
%%     interfaces-hypbmsec.sty,interfaces-hypbmsec.code.tex,
%%     interfaces-fancyhdr.sty,
%%     interfaces-marks.sty,
%%     interfaces-tocloft.sty,
%%     interfaces-makecell.sty,
%%     interfaces-enumitem.sty,
%%     interfaces-truncate.sty,
%%     interfaces-appendix.sty,
%%     interfaces-embedfile.sty,
%%     interfaces-environ.sty,
%%     interfaces-umrand.sty,
%%     interfaces-scrlfile.sty,
%%     interfaces-pgfkeys.sty,
%%     interfaces-etoolbox.sty,
%%     interfaces-fancyvrb.sty
%% 
%% interfaces: interfaces with keys for other packages (FC)
%% Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
%% 
\ProvidesPackage{interfaces-makecell}
   [2010/10/27 v1.2 more control on tabular cells (FC)]
\RequirePackage{interfaces-base}
\itf@Check@Package{makecell}
\edef\itf@AtEnd{\catcode126 \the\catcode126}% 126 = ~
\AtEndOfPackage{\itf@AtEnd}
\catcode126 \active % 126 = ~
\itf@pgfkeys
\def\countvalues#1{\number\numexpr
   \expandafter\itf@countvalues\expandafter0#1,\countvalues\@nnil
}% \countvalues
\def\itf@countvalues#1#2,#3\@nnil{%
   \ifx\countvalues#3%
      +#1\expandafter\remove@to@nnil
   \else
      +1\expandafter\itf@countvalues
   \fi1#3\@nnil
}% \itf@countvalues
\def\itf@getvalue#1#2{%
   \romannumeral-`\q\expandafter\itf@getv@lue\expandafter0#1,\itf@getvalue\@nil{#2-1}\@nnil
}% \itf@getvalue
\def\itf@getv@lue#1#2,#3\@nil#4\@nnil{%
   \ifnum\numexpr#1=\numexpr#4\relax
      #2\expandafter\remove@to@nnil
   \else\ifx\itf@getvalue#3%
      \expandafter\expandafter\expandafter\remove@to@nnil
   \else
      \expandafter\expandafter\expandafter\itf@getv@lue
   \fi\fi{#1+1}#3\@nil#4\@nnil
}% \itf@getv@lue
\newif\ifitf@celltranspose
\def\itf@ampactive{%
   \def\tab{&}%
   \lccode`\~=38\lowercase{\def~{&}}%
}% \itf@ampactive
\newrobustcmd*\repeatcell{\begingroup
   \let\tab\relax
   \catcode38\active
   \itf@repeatcell
}% \repeatcell
\newrobustcmd*\itf@repeatcell[3][]{%
   \ifblank{#1}% alignment option ?
      {\let\itf@makecell\@firstofone}
      {\def\itf@makecell##1{\noexpand\makecell[{#1}]{##1}}}%
   \countdef\itf@col=100% local
   \countdef\itf@row=101% local
   \countdef\itf@cnt=102% local
   \toksdef\itf@cell=1% local
   \itf@pgfkeys
   \pgfqkeys{/itf/makecell/repeatcell}{@reset={#2},#3}%
   \toks@{}% local
   \ifnum\itf@row>\z@ % number
      \edef\itf@rowloop{\noexpand\@whilenum\itf@row<\the\itf@row}%
      \def\itf@cell@init{\def\r{\row}\let\R\@empty}%
   \else % list
      \def\itf@rowloop{\@for\r:=\itf@rows}%
      \expandafter\def\expandafter\itf@cell@init\expandafter{%
         \expandafter\def\expandafter\R\expandafter{%
            \expandafter\itf@getvalue\expandafter{\expandafter\@empty\itf@rows}}}%
   \fi
   \ifnum\itf@col>\z@ % number
      \edef\itf@colloop{\noexpand\@whilenum\itf@col<\the\itf@col}%
      \expandafter\def\expandafter\itf@cell@init\expandafter{%
         \itf@cell@init\def\c{\column}\let\C\@empty}%
   \else % list
      \def\itf@colloop{\@for\c:=\itf@cols}%
      \expandafter\expandafter\expandafter\def
         \expandafter\expandafter\expandafter\itf@cell@init
            \expandafter\expandafter\expandafter{%
               \expandafter\itf@cell@init
               \expandafter\def\expandafter\C\expandafter{%
                     \expandafter\itf@getvalue\expandafter{\expandafter\@empty\itf@cols}}}%
   \fi
   \itf@cell@init % in case they are used in formulas
   \ifitf@celltranspose
      \itf@col\z@
      \itf@colloop\do{%
         \ifnum\itf@col>\z@
         \pgfkeysifdefined{/itf/makecell/repeatcell/cr/row\the\itf@col}%
            {\pgfkeysgetvalue{/itf/makecell/repeatcell/cr/row\the\itf@col}\itf@thecr}
            {\pgfkeysgetvalue{/itf/makecell/repeatcell/cr}\itf@thecr}%
         \toks@\expandafter\expandafter\expandafter{%
                     \expandafter\the\expandafter\toks@\itf@thecr}%
         \fi
         \advance\itf@col\@ne
         \itf@row\z@
         \itf@rowloop\do{%
            \advance\itf@row\@ne
            \ifnum\itf@row>\@ne
               \toks@\expandafter{\the\toks@&}%
            \fi
            \toks@\expandafter\expandafter\expandafter{%
               \expandafter\the\expandafter\toks@
               \itf@cell@init\itf@ampactive}%
            \itf@cell@insert}%
      }%
   \else
   \itf@row\z@
   \itf@rowloop\do{%
      \ifnum\itf@row>\z@
         \pgfkeysifdefined{/itf/makecell/repeatcell/cr/row\the\itf@row}%
            {\pgfkeysgetvalue{/itf/makecell/repeatcell/cr/row\the\itf@row}\itf@thecr}
            {\pgfkeysgetvalue{/itf/makecell/repeatcell/cr}\itf@thecr}%
         \toks@\expandafter\expandafter\expandafter{%
                   \expandafter\the\expandafter\toks@\itf@thecr}%
      \fi
      \advance\itf@row\@ne
      \itf@col\z@
      \itf@colloop\do{%
         \advance\itf@col\@ne
         \ifnum\itf@col>\@ne
            \toks@\expandafter{\the\toks@&}%
         \fi
         \toks@\expandafter\expandafter\expandafter{%
                  \expandafter\the\expandafter\toks@
                  \itf@cell@init\itf@ampactive}%
         \itf@cell@insert}%
      }%
   \fi
   \itf@message{Code introduced by repeatcell in the \@currenvir:\the\toks@}% (to see the code...)
   \expandafter\endgroup\the\toks@
   \ignorespaces
}% \itf@repeatcell
\let\itf@message\@gobble
\def\itf@cell@rowcolkey{%
   \removefromstart\pgfkeyscurrentname{row}%
   \ifin@\else
      \removefromstart\pgfkeyscurrentname{col}%
   \fi
   \ifin@
      \itf@number\itf@cnt\pgfkeyscurrentname\relax\@nnil
         {\pgfkeyslet\pgfkeyscurrentkey\pgfkeyscurrentvalue}
         \in@false
   \fi
   \ifin@\else
      \pgfkeysvalueof{/errors/unknown key/.@cmd}\pgfkeyscurrentkey
                                                \pgfkeyscurrentvalue
                                                \pgfeov
   \fi
}% \itf@cell@rowcolkey
\pgfqkeys{/itf/makecell/repeatcell}{%
   font/.store in=\itf@cellfont,%
   font/.unknown/.code=\itf@cell@rowcolkey,%
   text/.store in=\itf@celltext,%
      text/.default=\ifdefined\C\C\column\fi,%
   text/.unknown/.code=\itf@cell@rowcolkey,%
   cr/.initial=\\,%
      cr/.default=\crcr,cr/.blank=\\,end/.alias=cr,%
   cr/.unknown/.code=\itf@cell@rowcolkey,%
   rows/.code=\itf@number\itf@row#1\relax\@nnil
                  {\ifnum\itf@row<\z@\itf@row\@ne\fi}
                  {\itf@row\z@
                  \def\itf@rows{#1}\itf@expandonceifcs\itf@rows},%
      rows/.default=1,rows/.blank=1,%
   @cols/.is private=interfaces-makecell,%
   column/.is private=interfaces-makecell,%
   row/.is private=interfaces-makecell,%
   transpose/.is if=itf@celltranspose,%
   .unknown/.code=%
      \ifx\pgfkeyscurrentvalue\pgfkeysnovalue@text \itf@cell@formulaerror{}\z@ \fi
      \ifx\pgfkeyscurrentvalue\@empty \itf@cell@formulaerror{}\@ne \fi
      \pgfkeysifdefined{\pgfkeyscurrentkey/@calc}%
            {\itf@cell@formulaerror{}\tw@}
            {\pgfkeyslet{\pgfkeyscurrentkey/@calc}\relax}%
      \itf@cell@getformula{#1}%
      \pgfkeysEaddvalue{/itf/makecell/repeatcell/@calc}{}
         {\the\toks@\expandafter\noexpand\csname\pgfkeyscurrentname\endcsname}%
      \expandafter\let\csname\pgfkeyscurrentname\endcsname\@undefined,% (order of evaluation => "undefined cs")
   @reset/.code=% #1 are the columns
      \itf@celltransposefalse
      \let\itf@celltext\@empty
      \let\itf@cellfont\@empty
      \pgfkeyssetvalue{/itf/makecell/repeatcell/cr}{\\}%
      \itf@row\@ne
      \pgfkeyssetvalue{/itf/makecell/repeatcell/@calc}{%
         \itf@cell@numcalc\itf@col\column
         \itf@cell@numcalc\itf@row\row}%
      \itf@number\itf@col#1\relax\@nnil
         {\ifnum\itf@col<\z@\itf@col\@ne\fi}
         {\itf@col\z@
         \def\itf@cols{#1}\itf@expandonceifcs\itf@cols},%
}% keys for \repeatcell
\def\itf@cell@getformula#1{%
   \itf@cell@getf@rmula #1$$$\itf@cell@getformula$\relax\@nnil
   \expandafter\ifx\expandafter\toks@\the\toks@
      \itf@cell@formulaerror{#1}\thr@@
   \fi
}% \itf@cell@getformula
\def\itf@cell@getf@rmula #1$#2$#3$#4#5$#6{%
   \toks@{\toks@}%
   \ifx\itf@cell@getformula #4%
      \toks@{\itf@cell@numcalc{#1}}%
   \else\ifx $#4%
      \ifx\itf@cell@getformula #6%
         \ifdefined\pgfmathparse\else\itf@cell@formulaerror{#2}4\fi
         \toks@{\itf@cell@pgfcalc{#2}}%
      \else\ifx $#6%
         \ifdefined\FPeval\else\itf@cell@formulaerror{#3}5\fi
         \toks@{\itf@cell@FPcalc{#3}}%
      \fi\fi
   \fi\fi\remove@to@nnil
}% \itf@cell@getf@rmula
\def\itf@cell@formulaerror#1#2{%
   \def\itf@tp{#1}\@onelevel@sanitize\itf@tp
   \ifcase#2% 0
   \PackageError{interfaces-makecell}
      {Missing formula for key \pgfkeyscurrentname!}\@ehd
   \or %1
   \PackageError{interfaces-makecell}
      {Computed key \pgfkeyscurrentname\space wes left blank!}\@ehd
   \or %2
   \PackageError{interfaces-makecell}
      {Duplicate definition for computed key \pgfkeyscurrentname
      \MessageBreak\string\repeatcell\space will redefine the key}\@eha
   \or %3
   \PackageError{interfaces-makecell}
      {Incorrect formula in \string\repeatcell
      \MessageBreak Check: \itf@tp
      \MessageBreak Take care of commas and equal signs...}\@ehd
   \or %4
   \PackageError{interfaces-makecell}
      {Formula: \itf@tp
      \MessageBreak requires \string\pgfmathparse:\space\string\usetikz{pgfmath}}\@ehd
   \or %5
   \PackageError{interfaces-makecell}
      {Formula: \itf@tp
      \MessageBreak requires \string\FPeval:\space\string\usepackage{fp}}\@ehd
   \else
   \PackageError{interfaces-makecell}
      {Impossible value!}\@ehd
   \fi
}% \itf@cell@formulaerror
\protected\def\itf@cell@calc#1#2{%
   \edef#1{\def\noexpand#1{#2}}%
   \toks@\expandafter\expandafter\expandafter{%
                     \expandafter\the\expandafter\toks@#1}%
   #1%
}% \itf@cell@calc
\protected\def\itf@cell@numcalc#1#2{%
   \itf@cell@calc#2{\number\numexpr#1}%
}% \itf@cell@numcalc
\protected\def\itf@cell@pgfcalc#1#2{%
   \pgfmathparse{#1}%
   \itf@cell@calc#2\pgfmathresult
}% \itf@cell@pgfcalc
\protected\def\itf@cell@FPcalc#1#2{%
   \begingroup
   \setbox\z@\vbox{%\FPeval introduces some weird code, hence the calculation in a \vbox
      \FPeval\FPresult{#1}%
      \global\let\FPresult\FPresult}%
   \endgroup
   \itf@cell@calc#2\FPresult
}% \itf@cell@FPcalc
\def\itf@cell@getifdefined#1#2{%
   \pgfkeysifdefined{/itf/makecell/repeatcell/#1}
      {\pgfkeysgetvalue{/itf/makecell/repeatcell/#1}#2}
      {\let#2\@empty}%
}%
\def\itf@cell@insert{%
   \pgfkeysvalueof{/itf/makecell/repeatcell/@calc}%
   \ifx\R\@empty\else
      \toks@\expandafter\expandafter\expandafter{%
         \expandafter\the\expandafter\toks@
         \expandafter\def\expandafter\r\expandafter{\r}}%
   \fi
   \ifx\C\@empty\else
      \toks@\expandafter\expandafter\expandafter{%
         \expandafter\the\expandafter\toks@
         \expandafter\def\expandafter\c\expandafter{\c}}%
   \fi
   \itf@cell@getifdefined{font/row\the\itf@row}\itf@cellfontrow
   \itf@cell@getifdefined{font/col\the\itf@col}\itf@cellfontcol
   \itf@cell@getifdefined{text/row\the\itf@row}\itf@cellrow
   \itf@cell@getifdefined{text/col\the\itf@col}\itf@cellcol
   \toks@\expandafter\expandafter\expandafter{%
          \expandafter\the\expandafter\toks@\itf@cellfont}%
   \ifx\itf@cellrow\@empty
      \ifx\itf@cellcol\@empty
         \itf@cell\expandafter\expandafter\expandafter{%
            \expandafter\itf@cellfontcol\itf@cellfontrow}%
         \let\itf@tp\itf@celltext
      \else
         \itf@cell\expandafter{\itf@cellfontcol}%
         \let\itf@tp\itf@cellcol
      \fi
   \else
      \ifx\itf@cellcol\@empty
         \itf@cell\expandafter{\itf@cellfontrow}%
         \let\itf@tp\itf@cellrow
      \else
         \itf@cell{}%
         \ifitf@celltranspose
         \edef\itf@tp{\noexpand\itf@diaghead(-2,1)
            {\expandonce\itf@cellfontrow\expandonce\itf@cellrow}
            {\expandonce\itf@cellfontcol\expandonce\itf@cellcol}}%
         \else
         \edef\itf@tp{\noexpand\itf@diaghead(-2,1)
            {\expandonce\itf@cellfontcol\expandonce\itf@cellcol}
            {\expandonce\itf@cellfontrow\expandonce\itf@cellrow}}%
         \fi
      \fi
   \fi
   \itf@cell\expandafter\expandafter\expandafter{%
               \expandafter\the\expandafter\itf@cell\itf@tp}%
   \edef\itf@tp{\itf@makecell{\the\itf@cell}}%
   \toks@\expandafter\expandafter\expandafter{%
               \expandafter\the\expandafter\toks@\itf@tp}%
}% \itf@cell@insert
\def\itf@diaghead(#1)#2#3{%
   \begingroup
   \edef\itf@tp{%
   \noexpand\diaghead({#1}){\unexpanded{#2 #3}}%
                  {\unexpanded{#2}}
                  {\unexpanded{#3}}}%
   \expandafter\endgroup\itf@tp
}% \itf@diaghead
\AfterPackage*{colortbl}{%
\def\CT@cellc#1[#2]#3{%  #1 is either \@firstofone or \@gobble, [#2]#3 = color spec
   \xdef\CT@cell@color{\noexpand\CT@color#1{[{#2}]}{#3}%
   \global\let\noexpand\CT@cell@color\relax}%
}}
\endinput
%%
%% End of file `interfaces-makecell.sty'.