summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/titlesec/ttlkeys.def
blob: 02d44976628c773ef0a9d64bf9021ea4454efe3d (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
% +--------------------------------------------------+
% | Typeset titlesec.tex to get the documentation.   |
% +--------------------------------------------------+
%
% Copyright (c) 1998-2005 by Javier Bezos.
% All Rights Reserved.
%
% This file is part of the titlesec distribution release 2.6
% -----------------------------------------------------------
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.

\ProvidesFile{ttlkeys.def}[2005/01/22]

% This command takes a list in "keyval" format, \ttl@a containing the
% star spec, and returns \ttl@a with the full string name to be defined
% and \ttl@b with the string sectioning name (without tag).  But if the
% argument has no keys then simply does the last step.  Finally, an
% error is reported if the sectioning command does not exist.  All these
% testing must be improved (still).

\@ifundefined{define@key}{\RequirePackage{keyval}}{}%

\def\ttl@getkeys#1#2{%
  \let\ttl@a\@empty
  \if\expandafter @\@gobble#1@\@empty % if there is a single token
    \edef\ttl@b{\expandafter\@gobble\string#1}%
    \let\ttl@a\ttl@b
  \else
    \ttl@labelfalse  %  A temporary flag: true if there is page key
    \setkeys{#2}{#1}%
    \ifttl@label
      \@ifundefined{ttlp@\ttl@b}{%
        \expandafter\let\csname ttlp@\ttl@b\endcsname\@empty}{}%
    \fi
    \edef\ttl@a{\ttl@b\ttl@a}%
  \fi}

\define@key{titlesec}{name}{%
  \edef\ttl@b{\expandafter\@gobble\string#1}}

\define@key{titlesec}{numberless}[true]{%
  \csname @tempswa#1\endcsname
  \if@tempswa
    \edef\ttl@a{\ttl@a/*}%
  \fi}

\define@key{titlesec}{page}{%
  \ttl@labeltrue  % Used as flag
  \edef\ttl@a{/#1\ttl@a}}

\def\ttl@extra@numberless{\ttl@labeltrue}% The actual meaning

\let\ttl@key@numberless\@empty
%\let\ttl@key@matter\@empty

\let\ttlp@append\@gobbletwo

\def\ttl@setkeys#1{%
  \def\ttl@trylist{\ttl@try{}}%
  \@for\ttl@b:=#1\do{%
    \begingroup
      \let\ttl@a\relax
      \def\ttl@try##1{%
        \noexpand\ttl@try{##1\ttl@a{\ttl@b}}%
        \noexpand\ttl@try{##1}}%
      \xdef\ttl@trylist{\ttl@trylist}%
    \endgroup}}

\ttl@setkeys{page,numberless}  % matter

%___
\if@twoside

\newcounter{ttlp@side}
\newcount\ttlp@side

\def\ttlp@theside{\ifodd\c@page o\else e\fi}

\def\ttlp@append#1#2{%
 {\let\@elt\relax
  \expandafter\xdef\csname ttlp@#1\endcsname{%
     \csname ttlp@#1\endcsname\@elt #2}}}

\def\ttlp@write#1{%
  {\let\ttlp@theside\relax
   \protected@write\@auxout{}%
     {\string\ttlp@append{#1}{\ttlp@theside}}}}

\def\ttlp@fetch#1{%
   \stepcounter{ttlp@side}%
   \global\advance\ttlp@side\@ne
   \@whilenum\ttlp@side<\c@ttlp@side\do{%
      \expandafter\@next\expandafter\@tempa\csname ttlp@#1\endcsname{}{}%
      \global\advance\ttlp@side\@ne}%
   \expandafter\@next\expandafter\ttl@b\csname ttlp@#1\endcsname{%
      \xdef\ttl@key@page{/\if\ttl@b oodd\else even\fi}%
   }{%
      \xdef\ttl@key@page{/\ifodd\c@page odd\else even\fi}%
	  \@@warning{Unsynchronized `#1' title on page \thepage}}}

%___
\else

\let\ttlp@write\@gobble
\def\ttlp@fetch#1{\gdef\ttl@key@page{/odd}}

%___
\fi

\endinput