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
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
%%
%% This is file `interfaces-titlesec.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% interfaces.dtx (with options: `titlesec')
%%
%% This is a generated file.
%%
%% interfaces : 2011/02/19 v3.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-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: interfaces with keys for other packages (FC)
%% Copyright (C) 2010 by Florent Chervet <florent.chervet@free.fr>
%%
\ProvidesPackage{interfaces-titlesec}
[2011/02/19 v3.1 pgfkeys macros for titlesec (FC)]
\RequirePackage{interfaces-base}
\RequirePackage{auxhook}% <fix for \ttlp@append (odd/even pages)>
\RequirePackage{gettitlestring}
\itf@Check@Package{titlesec}
%% t i t l e s e c "p a t c h e s"
\robustify\titleclass \robustify\titleformat \robustify\titlespacing
\AddLineBeginMainAux{%
\string\providecommand\string\ttlp@append[2]{}%
}
\BeforeFile*{ttlkeys.def}{%
\expandafter\edef\csname itf@ttlkeys.def\endcsname{%
\catcode32 \the\catcode32\relax
\catcode37 \the\catcode37\relax
\endlinechar\the\endlinechar\relax}%
\catcode37 14\relax % percent=comment (inside .dtx files...)
\catcode32 9\relax % ignore spaces
\endlinechar\m@ne % and line feeds
}
\AfterFile*{ttlkeys.def}{\csname itf@ttlkeys.def\endcsname}%
%%-----------------------------------------------------------------------------
%% runinifempty => like hang but no paragraph break (like runin) if title is empty
\def\ttlh@runinifempty{%
\csname ttlh@\ifx\ttl@savetitle\@empty runin\else hang\fi\endcsname
}% \ttlh@runinifempty
\newrobustcmd*\sectionformat[1]{\@ifstar
{\itf@sectionformat{#1}{/*}}
{\itf@sectionformat{#1}{}}%
}% \sectionformat
\def\itf@sectionformat#1#2{\@testopt
{\expandafter\expandafter\expandafter%
\itf@sectionf@rmat\expandafter\@gobble\string#1\@nil{#2}}{}%
}% \sectionformat
\def\itf@sectionf@rmat#1\@nil#2[#3]#4{\itf@pgfkeys\ifblank{#3}
{\pgfqkeys{/itf/titlesec/#1#2}
{/itf/titlesec/@setup={#1}{#2},#4,/itf/titlesec/@update={#1}{#2}}}
{\pgfqkeys{/itf/titlesec/#1#2}
{/itf/titlesec/@setup={#1}{#2},#4,shape={#3},/itf/titlesec/@update={#1}{#2}}}%
}% \itf@ttl@sectionformat
%% private keys @setup and @update
\pgfqkeys{/itf/titlesec}{%
@setup/.code 2 args=\itf@ttl@setup{#1}{#2},%
@update/.code 2 args=\expandafter\itf@ttl@update
\csname#1\endcsname{/itf/titlesec/#1}{#2}%
}
\newrobustcmd*\itf@ttl@setup[2]{%
\pgfkeysifdefined{/itf/titlesec/#1#2/shape}{}
{\itf@ttl@newsection{#1}{#2}}%
\ifcsundef{ttls@#1#2}{}% no previous spacing settings
{\expandafter\expandafter\expandafter%
\itf@ttl@getspacing\csname ttls@#1#2\endcsname{/itf/titlesec/#1#2}}%
\ifcsundef{ttlf@#1#2}{}% no previous format settings
{\ifttl@explicit
\expandafter\expandafter\expandafter%
\itf@ttl@getformat\csname ttlf@#1#2\endcsname{}{/itf/titlesec/#1#2}%
\else
\expandafter\expandafter\expandafter%
\itf@ttl@getformat\csname ttlf@#1#2\endcsname{/itf/titlesec/#1#2}%
\fi}%
}% \itf@ttl@setup
\def\itf@ttl@setkey#1#2{\begingroup
\def\x{\pgfkeysvalueof{#1}}\def\y{#2}%
\expandafter\endgroup\ifx\x\y\else
\pgfkeyssetvalue{#1}{#2}\fi
}% \itf@ttl@setkey
\def\itf@ttl@getspacing#1#2#3#4#5#6{%
\itf@ttl@setkey{#6/left}{#1}%
\itf@ttl@setkey{#6/right}{#2}%
\itf@ttl@setkey{#6/top}{#3}%
\itf@ttl@setkey{#6/bottom}{#4}%
\itf@ttl@setkey{#6/indent first}{#5}%
}% \itf@ttl@getspacing
\def\itf@ttl@getformat#1#2{%
\csname ltx@\ifx\pgfkeysvalueof#1first\else second\fi oftwo\endcsname
{\itf@ttl@get@format{}}
{\itf@ttl@get@format{#1}{#2}}%
}% \itf@ttl@getformat
\def\itf@ttl@get@format#1#2#3#4#5#6#7{%
\if\relax\detokenize{#1}\relax\else
\pgfkeysEsetvalue{#7/shape}{\expandafter\itf@strip@at\string#1}%
\fi
\itf@ttl@setkey{#7/font}{#2}%
\itf@ttl@setkey{#7/label}{#3}%
\itf@ttl@setkey{#7/sep}{#4}%
\itf@ttl@setkey{#7/before}{#5}%
\itf@ttl@setkey{#7/after}{#6}%
}% \itf@ttl@get@format
\newrobustcmd*\itf@ttl@update[3]{%
\ifblank{#3}
{\ttl@getkeys{#1}{titlesec}}
{\ttl@getkeys{name=#1,numberless}{titlesec}}%
\pgfkeysgetvalue{#2#3/shape}\itf@tp
\ifcsundef{ttlh@\itf@tp}
{\begingroup \makeatletter
\InputIfFileExists{\itf@tp.tss}{}{%
\PackageError{titlesec}{Unknown shape}%
{Shapes are defined in files with extension tss\MessageBreak
Either you have misspelled the shape\MessageBreak
or there is no a \itf@tp.tss file}}%
\endgroup}
{}%
\ifttl@explicit \begingroup
\pgfkeysgetvalue{#2#3/before}\pgfkeys@temp
\toks@\expandafter{\pgfkeys@temp}%
\edef\x{\endgroup\def\noexpand\itf@tp####1{\the\toks@}}%
\x \pgfkeyslet{#2#3/before@cmd}\itf@tp
\@temptokena{\csdef{ttlf@\ttl@a}##1}%
\the\@temptokena{%
\pgfkeysvalueof{#2#3/shape@cs}%
{\pgfkeysvalueof{#2#3/font}}%
{\pgfkeysvalueof{#2#3/label}}%
{\pgfkeysvalueof{#2#3/sep}}%
{\pgfkeysvalueof{#2#3/before@cmd}{##1}}%
{\pgfkeysvalueof{#2#3/after}}}%
\else\@temptokena{\csdef{ttlf@\ttl@a}}%
\the\@temptokena{%
\pgfkeysvalueof{#2#3/shape@cs}%
{\pgfkeysvalueof{#2#3/font}}%
{\pgfkeysvalueof{#2#3/label}}%
{\pgfkeysvalueof{#2#3/sep}}%
{\pgfkeysvalueof{#2#3/before}}%
{\pgfkeysvalueof{#2#3/after}}}%
\fi
\csname ttl@compat\ttl@a\endcsname
\ttl@spacing@ii
{\pgfkeysvalueof{#2#3/indent first}}%
{\pgfkeysvalueof{#2#3/left}}%
{\pgfkeysvalueof{#2#3/top}}%
{\pgfkeysvalueof{#2#3/bottom}}%
[\pgfkeysvalueof{#2#3/right}]%
}% \itf@ttl@update
%%----------------------------------------------------------------------------
%% t i t l e c l a s s
\newrobustcmd*\itf@ttl@titleclass{\@ifstar
{\itf@ttl@titleclass@i*}
{\itf@ttl@titleclass@i{}}%
}% \itf@ttl@titleclass
\def\itf@ttl@titleclass@i#1#2#3[#4]#5\@nil{\ifblank{#4}
{%
\expandafter\titleclass\csname#2\endcsname{#3}%
}
{%
\expandafter\titleclass\csname#2\endcsname{#3}[{#4}]% #4 = sup-level
\if\relax#1\relax % not starred
\expandafter\expandafter\expandafter%
\itf@ttl@titleclass@ii\expandafter\@gobble\string#4\relax{#2}% \@addtoreset...
\fi
}%
\expandafter\providecommand\csname l@#2\endcsname[2]{}% no entry in toc
}% \itf@ttl@titleclass@i
\def\itf@ttl@titleclass@ii#1\relax#2{%
\ifcsundef{c@#2}
{\newcounter{#2}[{#1}]}% creates counter for #1
{\@addtoreset{#2}{#1}}%
\csxdef{the#2}{%
\expandafter\noexpand\csname the#1\endcsname
.\noexpand\@arabic\expandafter\noexpand\csname c@#2\endcsname
}% \the#2
\ifcsundef{l@#1}{}{%
\expandafter\providecommand\csname l@#2\endcsname[2]{%
\csname l@#1\endcsname{##1}{##2}%
}% \l@#2 = \l@newsection is (by default) the same as \l@sup-level
}%
}% \itf@ttl@titleclass@ii
%%-----------------------------------------------------------------------------
%% C r e a t i n g n e w s e c t i o n s
\def\itf@ttl@createsection#1{% sectionning command undefined: temporarily defined
\expandafter\titleclass\csname#1\endcsname{straight}[*]% in straight class
\itf@AfterPackage{hypbmsec}{%
\AfterPreamble{%
\csletcs{hbs@#1}{#1}%
\csxdef{#1}{\noexpand\hbs@do\expandafter\noexpand\csname hbs@#1\endcsname}%
}%
}%
\itf@AfterPackage{interfaces-tocloft}{%
\itf@cft@newsection{toc}{#1}%
}%
\itf@AfterPackage{interfaces-hypbmsec}{%
\expandafter\let\csname last#1title\endcsname\relax
\expandafter\let\csname last#1bookmark\endcsname\relax
\expandafter\let\csname last#1toc\endcsname\relax
}%
}% \itf@ttl@createsection
%%-----------------------------------------------------------------------------
%% D e f i n i n g k e y s f o r e a c h s e c t i o n
\def\itf@ttl@newsection#1#2{% #1=section, #2=/* or empty
\ifcsundef{#1}% sectionning command undefined: temporarily defined in straight class
{\itf@ttl@createsection{#1}}
{}%
\ifblank{#2}{%
\pgfqkeys{/itf/titlesec/#1}{% these keys do not exist for starred sections
class/.code=\itf@ttl@titleclass{#1}##1[]\@nil,% with \@addtoreset
class/.value required,% if sup-level is given
class*/.code=\itf@ttl@titleclass*{#1}##1[]\@nil,% without \@addtoreset
class*/.value required,% even if sup-level is given
shape/.initial=,% initial shapes set by titlesec.sty for not numbered sections.
the#1/.store in cs=the#1,%
the#1/.default=\pgfkeysvalueof{/itf/titlesec/#1/label},%
}}
{% starred section: unless titlesec, we do not put the default shape to hang,
\pgfkeysifdefined{/itf/titlesec/#1/shape}%but to the shape of the not starred
{\pgfkeysgetvalue{/itf/titlesec/#1/shape}\itf@tp}% sectionning command
{\def\itf@tp{hang}}%
\pgfkeyslet{/itf/titlesec/#1#2/shape}\itf@tp%
}%
\pgfqkeys{/itf/titlesec/#1#2}{%
shape/.value required,%
shape@cs/.initial=
\csname ttlh@\pgfkeysvalueof{/itf/titlesec/#1#2/shape}\endcsname,% constant
shape@cs/.is private=interfaces-titlesec,% constant
font/.store as code,%
format/.alias*=font,%
label/.store as code,%
sep/.estore as glue,%
labelsep/.alias*=sep,%
before/.store as code,%
before@cmd/.is private=interfaces-titlesec,%
after/.store as code,%
indent first/.true=\pgfkeyssetvalue{/itf/titlesec/#1#2/indent first}{\@ne},%
indent first/.false=\pgfkeyssetvalue{/itf/titlesec/#1#2/indent first}{\z@},%
identfirst/.alias=indent first,%
indent first=true,%
left/.estore as glue,%
top/.estore as glue,%
bottom/.estore as glue,%
right/.estore as glue,%
break/.code=\ifblank{##1}
{\cslet{#1break}\@empty}
{\protected\csdef{#1break}{##1}},%
break*/.code=\protected\csappto{#1break}{##1},%
break+/.alias=break*,%
mark/.code=\ifblank{##1}
{\cslet{#1mark}\@gobble}
{\protected\long\csdef{#1mark}####1{##1}},%
mark/.default=,%
}% \pgfkeys
\ifblank{#2}{% no default marks for stared (numberless) \section*
\itf@AfterPackage{interfaces-marks}{% requires interfaces-marks
\pgfkeys{/itf/titlesec/#1/mark/.default=\marksthe{#1}{##1}}%
}% AfterPackage interfaces-mark
\itf@AfterPackage{interfaces-bookmark}{% requires interfaces-bookmark
\pgfqkeys{/itf/titlesec/#1}{% does not exist for starred sections
bookmark/.is multiple choice,%
bookmark/level/.estore in cs=toclevel@#1,% depth of the bookmark
bookmark/level/.default=\ifcsvoid{ttll@#1}{99}{\csuse{ttll@#1}},%
bookmark/level/.blank=\ifcsvoid{toclevel@#1}
{\ifcsvoid{ttll@#1}{99}{\csuse{ttll@#1}}}{\csuse{toclevel@#1}},%
bookmark/toclevel/.alias=bookmark/level,%
bookmark/bold/.code=\ifblank{##1}
{\pgfkeyslet{/itf/titlesec/#1/bookmark/bold}\@empty}
{\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/bold}{bold=##1,}},%
bookmark/bold/.default=true,%
bookmark/bold*/.code=\ifblank{##1}
{\pgfkeyslet{/itf/titlesec/#1/bookmark/bold*}\@empty}
{\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/bold*}{bold*=##1,}},%
bookmark/bold*/.default=true,%
bookmark/italic/.code=\ifblank{##1}
{\pgfkeyslet{/itf/titlesec/#1/bookmark/italic}\@empty}
{\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/italic}{italic=##1,}},%
bookmark/italic/.default=true,%
bookmark/italic*/.code=\ifblank{##1}
{\pgfkeyslet{/itf/titlesec/#1/bookmark/italic*}\@empty}
{\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/italic}{italic*=##1,}},%
bookmark/italic*/.default=true,%
bookmark/color/.code=\ifblank{##1}
{\pgfkeyslet{/itf/titlesec/#1/bookmark/color}\@empty}
{\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/color}{color=##1,}},%
bookmark/color/.default=,%
bookmark/color*/.code=\ifblank{##1}
{\pgfkeyslet{/itf/titlesec/#1/bookmark/color*}\@empty}
{\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/color*}{color*=##1,}},%
bookmark/color*/.default=,%
bookmark/on/.code=\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/on}{disable=false,},%
bookmark/on/.value forbidden,%
bookmark/off/.code=\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/on}{disable=true,},%
bookmark/off/.value forbidden,%
bookmark/none/.alias=bookmark/off,%
bookmark/on*/.code=\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/on*}{disable*=false,},%
bookmark/off*/.code=\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/on*}{disable*=true,},%
bookmark/none*/.alias=bookmark/off*,%
bookmark/disable*/.alias=bookmark/off*,%
bookmark/style/.code=\ifblank{##1}
{\pgfkeyslet{/itf/titlesec/#1/bookmark/style}\@empty}
{\pgfkeyssetvalue{/itf/titlesec/#1/bookmark/style}{style=##1,}},%
bookmark/style/.default=,%
bookmark/.unknown/.code=\pgfkeysEsetvalue{/itf/titlesec/#1/bookmark/other}
{\pgfkeyscurrentname={##1}},%
bookmark/bold/.initial=,%
bookmark/bold*/.initial=,%
bookmark/italic/.initial=,%
bookmark/italic*/.initial=,%
bookmark/color/.initial=,%
bookmark/color*/.initial=,%
bookmark/on/.initial=,%
bookmark/on*/.initial=,%
bookmark/style/.initial=,%
}}% \AfterPackage*{interfaces-bookmark}
}% not starred (numberless) \section
{}% starred/numberless \section*: do not create the keys
}% \itf@ttl@newsection
%% bookmarks styles for sectionning commands:
\@makeother\#
\itf@AfterPackage{interfaces-bookmark}{%
\itf@patch\itf@preapptocmd\addcontentsline % #2=section name in
{\begingroup\itf@ttl@BKM{/itf/titlesec/#2/bookmark}}% \addcontentsline
{\endgroup}
{\@PackageInfoNoLine{interfaces-titlesec}
{\string\addcontentsline\space successfully patched!}}
{\@PackageWarningNoLine{interfaces-titlesec}
{Patch of \string\addcontentsline\space failed
\MessageBreak bookmark-style specs for sections
\MessageBreak will be unavailable}}%
}% AfterPackage interfaces-bookmark
\catcode`\#=6
\def\itf@ttl@BKM#1{%
\pgfkeysifdefined{#1/.@cmd}
{%
\edef\itf@tp{% do nothing if the keys are not set (shortcut)
\pgfkeysvalueof{#1/bold}%
\pgfkeysvalueof{#1/bold*}%
\pgfkeysvalueof{#1/italic}%
\pgfkeysvalueof{#1/italic*}%
\pgfkeysvalueof{#1/color}%
\pgfkeysvalueof{#1/color*}%
\pgfkeysvalueof{#1/on}%
\pgfkeysvalueof{#1/on*}%
\pgfkeysvalueof{#1/style}}%
\ifx\itf@tp\@empty
\else
\global\pgfkeyslet{#1/bold*}\@empty
\global\pgfkeyslet{#1/italic*}\@empty
\global\pgfkeyslet{#1/color*}\@empty
\global\pgfkeyslet{#1/on*}\@empty
\expandafter\bookmarksetup\expandafter{\itf@tp}%
\pgfkeysifdefined{/itf/bookmark/*}%
{% \bookmarksetup{color*=} overwrites \sectionformat...{bookmark/color*=}
\pgfkeysgetvalue{/itf/bookmark/*}\itf@tp
\expandafter\bookmarksetup\expandafter{\itf@tp}%
}
{}%
\fi}
{}%
}% \itf@ttl@BKM
%%-----------------------------------------------------------------------------
%% b o t t o m t i t l e s
\newrobustcmd*\bottomtitles{\@ifnextchar\bgroup
\itf@setbottomtitlespace
{\afterassignment\itf@set@bottomtitle@space\itf@sk}%
}% \bottomtitles
\def\itf@setbottomtitlespace#1{%
\@defaultunits\itf@sk#1\textheight\relax\@nnil
\itf@set@bottomtitle@space
}% \itf@setbottomtitlespace
\def\itf@set@bottomtitle@space{\xdef\bottomtitlespace{\the\dimexpr\itf@sk}}
\endinput
%%
%% End of file `interfaces-titlesec.sty'.
|