summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/skeyval/skeyval-testclass.cls
blob: 771d60160fe6e54c57eaeed4fd9ad44e6b28e0f4 (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
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
% This is file 'skeyval-testclass.cls', version 1.3, 2013/05/15.           %
%                                                                          %
% This package and accompanying files may be distributed and/or            %
% modified under the conditions of the LaTeX Project Public License,       %
% either version 1.3 of this license or any later version. The latest      %
% version of this license is in http://www.latex-project.org/lppl.txt      %
% and version 1.3 or later is part of all distributions of LaTeX           %
% version 2005/12/01 or later.                                             %
%                                                                          %
% The LPPL maintenance status of this software is 'author-maintained'.     %
%                                                                          %
% This software is provided 'as it is', without warranty of any kind,      %
% either expressed or implied, including, but not limited to, the          %
% implied warranties of merchantability and fitness for a particular       %
% purpose.                                                                 %
%                                                                          %
% The following files constitute the skeyval bundle and must be            %
% distributed as a whole:                                                  %
%                                                                          %
%  README, skeyval.sty, skeyval-core.tex, skeyval-for.tex,                 %
%  skeyval-view.sty, skeyval-ltxpatch.sty, skeyval-ltxcmds.tex,            %
%  skeyval-pstkey.sty, skeyval-pstkey.tex, skeyval-testclass.cls,          %
%  skeyval-testpkg.sty, skeyval-pokayoke1, skeyval-pokayoke2,              %
%  skeyval-view-pokayoke1.                                                 %
%                                                                          %
% Copyright (c) 2010-2013 Ahmed Musa (amusa22@gmail.com).                  %
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%

\ProvidesClass{skeyval-testclass}[2013/05/15 v1.3 skeyval test class (AM)]
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
\@ifpackageloaded{skeyval}{}{\RequirePackage{skeyval}}
\@ifpackageloaded{xcolor}{}{\RequirePackage{xcolor}}
\@ifpackageloaded{pifont}{}{\RequirePackage{pifont}}
\@ifpackageloaded{tikz}{}{\RequirePackage{tikz}}

\ifdefined\skvtestcnt\else\newcount\skvtestcnt\fi
\skvatbegineverypage{\skvcl@maybewm}
\let\skvcl@maybewm\relax
\def\skvcl@watermark{%
  \tikz[overlay,remember picture]{%
    \node [\skvcl@watermarkcolor,inner sep=0pt,rotate=45,align=center,
      scale=\skvcl@watermarkscale,font=\fontseries{b}\fontfamily{bch}%
      \fontsize{\skvcl@fontsize@a}{\skvcl@fontsize@b}\selectfont] at
      ([shift={(\skvcl@watermarkxshift,-\skvcl@watermarkyshift)}]%
      current page.north west){%
      \skvcl@watermarktext
    };
  }%
}

\skvrobustdef*\skvcl@titlecmds{%
  \setcounter{footnote}{0}%
  \def\do##1{\global\let##1\@empty}%
  \do\@thanks\do\@author\do\@date\do\@title
  \def\do##1{\global\let##1\relax}%
  \do\thanks\do\maketitle\do\@maketitle\do\title\do\author\do
  \date\do\and\let\do\relax
  \let\@fnsymbol\orig@fnsymbol
}
\let\orig@fnsymbol\@fnsymbol

\skvrobustredef*\skv@fnsymbol#1{%
  \unskip\ifcase#1\or\ding{'106}\or\ding{'110}\or\ding{'111}\or
  \ding{'112}\or\ding{'113}\or\ding{'114}\or\ding{'121}\or
  \ding{'122}\else\@ctrerr\fi
}
\skvrobustdef*\skvcl@newfootnotestyle{%
  \def\@makefnmark{%
    \rlap{\@textsuperscript{\normalfont\skv@fnsymbol\@thefnmark}}%
  }%
  \long\def\@makefntext##1{%
    \parindent1em\relax\noindent
    \hb@xt@1.8em{\hss\@textsuperscript{%
      \normalfont\skv@fnsymbol\@thefnmark}%
    }%
    ##1%
  }%
}
\skvnewlet\skv@sav@footnote\footnote
\skvnewlet\skv@sav@thanks\thanks
\AtEndOfPackage{%
  \skvdisablekeys[SKVC]{title}{insertwatermark}%
}
\AtBeginDocument{%
  \def\footnote{\unskip\skv@sav@footnote}%
  \def\thanks{\unskip\skv@sav@thanks}%
  \skvdisablekeys[SKVC]{textemphasis}{dummy-option}%
  \skvdisablekeys[SKVC]{title}{%
    maketitlepage,firstpagenumber,pagenumberstyle
  }%
}
\let\skvcl@settitlepageno\@gobble

% Example of option and nonoption keys:
\skvordkeys[KV]{fam}{testkey1,testkey2}[value]{}
\skvoptionkeys[KV]{fam}{testkey1}
\skvnonoptionkeys[KV]{fam}{testkey2}

% LaTeX will zap spaces in key name, anyway. So our options don't have
% spaces within themselves.

\directkeys*{%
  .every unknown option={
    \PassOptionsToClass{\CurrentOption}{article}
  },
  .message type when disabled option is invoked=error,
  .prefix=SKVC,
  % Extended text emphasis:
  .family=textemphasis,
  .hp=xem@,
  .new options={
    .initialize keys after define,
    .ord/{testkey1,testkey2,testkey3}/default,
    .bool/useitalic/true,
    .bool/usebold/true,
    .bool/usecolor/true,
    .cmd/color/red,
    .bool/make-textemphasis-inactive/true/
      \ifskvindef\else
        \skvifbool xem@make-textemphasis-inactive\then
          \PackageInfo{skeyval-testclass}
            {Extended text emphasis has been made inactive}
          \let\xem\emph
        \fi
      \fi
    ,
    .ord/dummy-option/\@nil,
  },
  .links={
    useitalics/useitalic,
    usecolour/usecolor,
    colour/color,
  },
  .option keys = {testkey1},
  .nonoption keys = {testkey2,testkey3},
  % Modifying the article title:
  .change family=title,
  .hp=skvcl@,
  .new options={
    .bool/putdate/true,
    .cmd/datefont/\large,
    .bool/clearpage/true,
    .bool/maketitlepage/true/
      \skvifbool skvcl@maketitlepage\then
        \ifskvindef\else
          \PassOptionsToClass{titlepage}{article}
        \fi
      \fi
    ,
    .cmd/firstpagenumber/\@nil/
      \ifx\skvcl@firstpagenumber\@nnil\else
        \skvensureinteger{page number}\skvcl@firstpagenumber
        \AtBeginDocument{%
          \gdef\pagenumbering##1{%
            \global\c@page\skvcl@firstpagenumber\relax
            \gdef\thepage{\csname @##1\endcsname\c@page}%
          }%
          % Default:
          \pagenumbering{arabic}%
          \let\skvcl@settitlepageno\@iden
        }%
      \fi
    ,
    .cmd/pagenumberstyle/\@nil/
      \ifx\skvcl@pagenumberstyle\@nnil\else
        \skvafterbegindocument{\pagenumbering{#1}}%
      \fi
    ,
    .cmd/pretitleskip/10pt,
    .cmd/posttitleskip/10pt,
    .cmd/authorfont/\large,
    .cmd/titlefont/\huge,
    .bool/insertwatermark/true/
      \skvifbool skvcl@insertwatermark\then
        \ifskvindef\else
          \let\skvcl@maybewm\skvcl@watermark
        \fi
      \fi
    ,
    .cmd/watermarkxshift/.5\paperwidth,
    .cmd/watermarkyshift/.5\paperheight,
    .cmd/watermarktext/DRAFT/
      \skvstripouterbraces{2}\skvcl@watermarktext
    ,
    .cmd/fontsize/{14.4,17}/
      \def\skvcl@fontsize@a{#1}\def\skvcl@fontsize@b{#2}
    ,
    .arg/fontsize/{#1,#2},
    .cmd/watermarkscale/5,
    .cmd/watermarkcolor/gray!55,
  },
  .slots={
    showdate/putdate=#1,
    first-page-number/firstpagenumber=#1,
    titlepage/maketitlepage=#1,
  },
  % Ececute the options in the current family. If any of the options
  % isn't found, report error (ie, don't save the key to the list of
  % 'remaining keys'). Unknown options should be flagged immediately.
  % Use '.execute options+' or '.execute options in all families' to
  % execute options in multiple families.
  .execute options={
    putdate,datefont,clearpage=false,pretitleskip,posttitleskip,
    authorfont,titlefont,watermarkscale,firstpagenumber,
    insertwatermark=false,watermarkxshift,watermarkyshift,
    watermarktext,watermarkcolor,fontsize
  },
  .families={textemphasis,title},
  .process options in all families,
}
%\show\skvcurrentpoxkeys

% testkey1 is an option key: don't set it outside option list:
% \skvsetkeys[SKVC]{textemphasis}{testkey1}

\skvrobustdef*\setupskvtestclass{%
  \skvsetkeys*+[SKVC]{textemphasis,title}%
}

% Setting up extended text emphasis:
\skvrobustdef*\setuptextemphasis#1{\skvsetkeys[SKVC]{textemphasis}{#1}}
\newcommand*\xem[1]{\xem@emph{\xem@bold{\xem@colortext{\xem@color}{#1}}}}
\newcommand*\xem@emph{%
  \skvifbool xem@useitalic\then
    \expandafter\emph
  \else
    \expandafter\@firstofone
  \fi
}
\newcommand*\xem@bold{%
  \skvifbool xem@usebold\then
    \expandafter\textbf
  \else
    \expandafter\@firstofone
  \fi
}
\newcommand*\xem@colortext{%
  \skvifbool xem@usecolor\then
    \expandafter\textcolor
  \else
    \expandafter\@secondoftwo
  \fi
}

\LoadClass{article}

\if@titlepage
  \renewcommand\maketitle{%
    \ifskvcl@clearpage
      \clearpage
    \fi
    \begin{titlepage}%
      \skvcl@newfootnotestyle
      \let\footnotesize\small
      \let\footnoterule\relax
      \let\footnote\thanks
      \null\vfil
      \vskip\skvcl@pretitleskip\relax
      \begin{center}%
        {\skvcl@titlefont\@title\par}%
        \vskip\skvcl@posttitleskip\relax
        {%
          \skvcl@authorfont
          \lineskip.75em\relax
          \begin{tabular}[t]{c}%
            \@author
          \end{tabular}\par
        }%
        \vskip1.5em\relax
        \skvifbool skvcl@putdate\then{{\skvcl@datefont\@date}}\fi
      \end{center}\par
      \@thanks
      \vfil\null
    \end{titlepage}%
    \skvcl@settitlepageno{\c@page\skvcl@firstpagenumber\relax}%
    \skvcl@titlecmds
  }
\else
  \renewcommand\maketitle{%
    \par
    \begingroup
    \skvcl@newfootnotestyle
    \if@twocolumn
      \ifnum\col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
    \endgroup
    \skvcl@titlecmds
  }
  \def\@maketitle{%
    \newpage
    \null
    \vskip\skvcl@pretitleskip\relax
    \begin{center}%
      \let\footnote\thanks
      {\skvcl@titlefont\@title\par}%
      \vskip\skvcl@posttitleskip\relax
      {\skvcl@authorfont
        \lineskip.5em\relax
        \begin{tabular}[t]{c}%
          \@author
        \end{tabular}\par
      }%
      \vskip1em\relax
      \skvifbool skvcl@putdate\then{\skvcl@datefont\@date}\fi
    \end{center}%
    \par
    \vskip1.5em\relax
  }
\fi

\endinput