-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathkartei.cls
388 lines (373 loc) · 9.36 KB
/
kartei.cls
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
%
% * ----------------------------------------------------------------
% * "THE BEER-WARE LICENSE" (Revision 42/023):
% * Ronny Bergmann <[email protected]> wrote this file. As long as
% * you retain this notice you can do whatever you want with this
% * stuff. If we meet some day and you think this stuff is worth it,
% * you can buy me a beer or a coffee in return.
% * ----------------------------------------------------------------
%
%
% Kartei Source Code of A5 page style definition without rotation
%
% -- Version 1.9 --
%
% Last Change: Kartei 1.9, 2012/01/04
%
% An english manual will be available soon, up to that, at least all
% comments are in english
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{kartei}[2012/01/04 Karteikarten in LaTeX, Version 1.9]
\newcommand{\setcardpagelayout}{}
\makeatletter
%
\maxdeadcycles=1000
%
% lokale Variablen und Optionsträger
%
%Print Version oder nicht ?
\newif\ifcard@useprint%
%Standard: Kein Print
\card@useprintfalse%
%TOC Version oder nicht ?
\newif\ifcard@useTOC%
%Standard: Kein Print
\card@useTOCfalse%
% Card Sizes
% 0 = DIN A5
% 1 = DIN A6
% 2 = DIN A7
% 3 = DIN A8
% 4 = DIN A9
\newcount\card@papersize
%Standard: A6
\card@papersize=1%
% Rotation der Rückseite
% 0 = nicht gedreht
% 1 = 180° gedreht (überkopf)
\newcount\card@Rearsiderotation
%Standard: 0 Degree, nicht überkopf
\card@Rearsiderotation=0%
%
% Gittermaße
%
% Eigenschaften: Gitter vorne / hinten
\newif\ifcard@useFrontgrid
%Standard -> vorne kein Gitter
\card@useFrontgridfalse%
% Eigenschaften: Gitter vorne / hinten
\newif\ifcard@useReargrid
%Standard -> vorne kein Gitter
\card@useReargridtrue%
% Offsets
\newlength{\card@hoffset}
\newlength{\card@voffset}
\setlength{\card@hoffset}{0pt}
\setlength{\card@voffset}{0pt}
%
%-----------------
%
%
% Declare options
%
%Flip Rearsides
\DeclareOption{flip}{%
\card@Rearsiderotation=1%
}
%Print output
\DeclareOption{print}{%
\card@useprinttrue
}%
%TOC output
\DeclareOption{toc}{%
\card@useTOCtrue
}%
%A6 Cards
\DeclareOption{a5paper}{%
\card@papersize=0%
\PassOptionsToPackage{paper=a5,pagesize}{typearea}%
\setlength{\card@hoffset}{-28pt}\setlength{\card@voffset}{55pt}%
}
%A6 Cards
\DeclareOption{a6paper}{%
\card@papersize=1%
\PassOptionsToPackage{paper=a6,pagesize}{typearea}%
\setlength{\card@hoffset}{-28pt}\setlength{\card@voffset}{37.5pt}%
}
%A7 Cards
\DeclareOption{a7paper}{%
\card@papersize=2%
\PassOptionsToPackage{paper=a7,pagesize}{typearea}%
\setlength{\card@hoffset}{-27pt}\setlength{\card@voffset}{42.5pt}%
}%
%A8 Cards
\DeclareOption{a8paper}{
\card@papersize=3%
\PassOptionsToPackage{paper=a8,pagesize}{typearea}%
\setlength{\card@hoffset}{-33.75pt}\setlength{\card@voffset}{37pt}%
}%
%A9 Cards
\DeclareOption{a9paper}{
\card@papersize=4%
\PassOptionsToPackage{paper=a9,pagesize}{typearea}%
\setlength{\card@hoffset}{-36pt}\setlength{\card@voffset}{36.5pt}%
}
% Activate both grids
\DeclareOption{grid=both}{%
\card@useFrontgridtrue%
\card@useReargridtrue%
}
% Activate front grid only
\DeclareOption{grid=front}{%
\card@useFrontgridtrue%
\card@useReargridfalse%
}
% Activate Rearsidegrid only (Standard)
\DeclareOption{grid=rear}{%
\card@useFrontgridfalse%
\card@useReargridtrue%
}
% Activate no grid
\DeclareOption{grid=none}{%
\card@useFrontgridfalse%
\card@useReargridfalse%
}
%All unknown Options to article
\DeclareOption*{%
\PassOptionsToClass{\CurrentOption}{scrartcl}%
}
\ProcessOptions\relax
%
% Pakete laden
%
\PassOptionsToClass{twoside}{scrartcl}%
\PassOptionsToClass{cleardoublepage=plain,DIV=calc}{scrartcl}%
\LoadClass{scrartcl}
\RequirePackage[headsepline]{scrlayer-scrpage}
\RequirePackage{xargs}
\RequirePackage[landscape]{geometry}
%
% Packages rewquired for the print option
%
\RequirePackage{pgfpages,tikz}
\RequirePackage{ifthen}
\RequirePackage{atbegshi}
%
% Packages required for the TOC option
%
\RequirePackage{longtable}
\RequirePackage{array}
\RequirePackage{booktabs}
\RequirePackage{calc}
%
% Defining page style and margins
%
\ifcase \card@papersize% Din A5
\geometry{left=2em,top=3em,right=2em,bottom=1em,head=1.3\baselineskip, headsep=.7\baselineskip,footskip=1em}%
\or% DIN A6 because after or we are at 1
\geometry{left=2em,top=3em,right=2em,bottom=1em,head=1.3\baselineskip, headsep=.7\baselineskip,footskip=1em}%
\or% DIN A7 because 2
\geometry{left=2em,top=2.5em,right=2em,bottom=1em,head=1.3\baselineskip, headsep=.7\baselineskip,footskip=2em}%
\or% %DIN A8 because 3
\geometry{left=1em,top=2em,right=1em,bottom=1em,head=1.3\baselineskip, headsep=.7\baselineskip,footskip=1em}%
\or% DIN A9 because 4
\geometry{left=.5em,top=2em,right=.5em,bottom=1em,head=1.3\baselineskip, headsep=.7\baselineskip,footskip=1em}%
\fi%
%
% Load toc Commands
%
\ifcard@useTOC
\input{kartei.tableofcontents}
\fi
%
% Load print Commands
\ifcard@useprint%
\input{kartei.print}
\fi%
%
% -----------------
% Main Commands
% -----------------
%
\makeatletter
%
% Antwort
% Answer
\newcommand{\dieantwort}{%
\antwortstil{\card@antwort}\relax%
}
\newcommand{\antwort}[1]{\def\card@antwort{#1}}%
\newcommand{\antwortstil}{}
\global\let\card@antwort\@empty
%english names
\newcommand{\answer}{}
\let\answer=\antwort
\newcommand{\theanswer}{}
\let\theanswer=\dieantwort
\newcommand{\answerstyle}{}
\let\answerstyle=\antwortstil
%
% Fach
% CardSubject
\newcommand{\dasfach}[1]{%
\ifx\@empty#1%
\fachstil{\card@fach}\relax%
\else%
\fachstil{#1}%
\fi%
}
\newcommand{\fach}[1]{\def\card@fach{#1}}%
\newcommand{\fachstil}{\emph}
\global\let\card@fach\@empty
%english names
\newcommand{\cardsubject}{}
\let\cardsubject=\fach
\newcommand{\thesubject}{}
\let\thesubject=\dasfach
\newcommand{\subjectstyle}{}
\let\subjectstyle=\fachstil
%
% Kommentar
% Comment
\newcommand{\derkommentar}[1]{%
\ifx\@empty#1%
\kommentarstil\card@kommentar\relax%
\else%
\kommentarstil{#1}
\fi%
}
\newcommand{\kommentar}[1]{\def\card@kommentar{#1}}%
\newcommand{\kommentarstil}{\emph}
\global\let\card@kommentar\@empty
%english names
\newcommand{\comment}{}
\let\comment=\kommentar
\newcommand{\thecomment}{}
\let\thecomment=\derkommentar
\newcommand{\commentstyle}{}
\let\commentstyle=\kommentarstil
% Card Counter
\newcounter{CardID}
\renewcommand{\theCardID}{\emph{\# \arabic{CardID}}}
\makeatletter
% redefine section
\newcommand{\origsection}{}
\let\origsection=\section
\def\section{\@ifstar\card@unnumberedsection\card@numberedsection}
\def\card@unnumberedsection#1{%
\fach{#1}%
\ifcard@useTOC% only include these if toc is active
\card@addsec{}{#1}
\fi%
}%
\def\card@numberedsection#1{%
\refstepcounter{section}%
\fach{\thesection.\ #1}%
\ifcard@useTOC% only include these if toc is active
\card@addsec{\thesection.}{#1}
\fi%
}%
\def\unnumberedsection#1{%
\fach{#1}%
\card@addsec{}{#1}
}%
% redefine subsectiom
\newcommand{\origsubsection}{}
\let\origsubsection=\subsection
%
\def\subsection{\@ifstar\card@unnumberedsubsection\card@numberedsubsection}
\def\card@numberedsubsection#1{%
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\refstepcounter{subsection}%
\kommentar{\thesubsection. #1}
\ifcard@useTOC% only include these if toc is active
\card@addsubsec{\thesubsection.}{#1}
\fi%
}%
\def\card@unnumberedsubsection#1{%
\renewcommand{\thesubsection}{\arabic{subsection}}%
\kommentar{#1}%
\ifcard@useTOC% only include these if toc is active
\card@addsubsec{#1}
\fi%
}
\colorlet{CardHead}{blue!80!black!50}
% CardHooks
\newcommand{\card@fronthook}{\CardFrontImg}
\newcommand{\CardFrontImg}{}
\newcommand{\card@backhook}{\CardBackImg}
\newcommand{\CardBackImg}{}
% Karteikartenumgebung:
% #1 (optional) Kopfzeile vorne Links : Fach
% #2 Titel der Vorderseite
% #3 (optional) Kopfzeile vorne rechts : Kommentar
%
\newenvironmentx{karte}[3][1=\card@fach,3=\card@kommentar]
{%
\refstepcounter{CardID}
% Add a TOC-line if active
\ifcard@useTOC% only include these if toc is active
\card@add{\arabic{CardID}}{#2}%
\fi%
% Build Cover page before starting environment
%
\cohead{\color{CardHead}\theCardID}
\lohead{\color{CardHead}\dasfach{#1}}
\rohead{\color{CardHead}\derkommentar{#3}}
\thispagestyle{scrheadings}
~\vspace{2\baselineskip}\par{~\hfill \parbox[t]{.9\textwidth}{\centering \large #2}\hfill~}\vfill~
\card@fronthook
\newpage%
}% Start os usual content block
{
\card@backhook
% Build a warning if the page is too full (forcing a pagebreak)
% assure the next card starts on an odd page by doublepagebreak
\cohead{\color{CardHead}{\bfseries Achtung:} R\"uckseite von \theCardID\ ist zu voll.}%
\rohead{\color{CardHead}}%
\lohead{\color{CardHead}}%
~\cleardoublepage
}
\newcommand{\card@printTOC}{
\ifcard@useTOC % only include these if toc is active
\ifcard@useprint
% \pgfshipoutphysicalpage
\pgfpagesuselayout{resize to}[a4paper]
\newpage
\KOMAoptions{paper=a4,DIV=13}
\setlength{\pdfpagewidth}{21cm}
\setlength{\textwidth}{17.5cm}
\setlength{\pdfpageheight}{29.7cm}
\else
\KOMAoptions{paper=a4,DIV=13}
\fi
\thispagestyle{empty}
\card@makeTOC
\fi
}
%
% Init and Endstuff...
%
\setcardpagelayout
\AtBeginDocument{\setcardpagelayout}
%
% finally set the layout, if print was given this sets to the just defined 8on2
%
\AtEndDocument{\card@printTOC}
\makeatother
%
%
% Init
\antwort{Antwort}
\pagestyle{scrheadings}
\clearscrheadings
\lohead{\color{CardHead}Kartentitel}
\cohead{\color{CardHead}\theCardID}
\lehead{\color{CardHead}\theCardID}
\cehead{\color{CardHead}\dieantwort}%
%
% Border Definitions
%
\tikzset{front grid/.style={thin, gray}}
\tikzset{rear grid/.style={thin, black, loosely dashed}}