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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
% \iffalse meta-comment
%
% Copyright (C) 2012 by Raphaël Pinson <raphink@gmail.com>
% ---------------------------------------------------------------------------
% 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
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Raphaël Pinson.
%
% This work consists of the files impnattypo.dtx and impnattypo.ins
% and the derived filebase impnattypo.sty.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{scrjrnl.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesClass{scrjrnl}
%<*package>
[2012/09/24 0.1 A class to typeset diaries or journals]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[english]{babel}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\usepackage{metalogo}
\usepackage[all]{nowidow}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{scrjrnl.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{355}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
%
% \changes{0.1}{2012/09/16}{First version}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
% \providecommand*{\url}{\texttt}
% \GetFileInfo{scrjrnl.dtx}
% \title{The \textsf{scrjrnl} class}
% \author{Raphaël Pinson \\ \url{raphink@gmail.com}}
% \date{\fileversion~from \filedate}
%
% \maketitle
%
% \section{Introduction}
%
% The \textsf{scrjrnl} class is based of the \textsf{scrbook} class,
% and inherits all of its commands and settings.
% Please refer to the Koma-Script documentation for the detail of
% all of these. Note that the \textsf{scrjrnl} class is not an
% official Koma-Script class.
%
% \section{Usage}
%
% \begin{verbatim}
% \documentclass[<options>]{scrjrnl}
% \end{verbatim}
%
% \subsection{Options}
%
% The class options are described below.
%
% \DescribeMacro{monthpages}
%
% By default, the month pages are skiped and only the days are typeset.
% If you wish to display a page for each starting month, use this setting.
%
% \DescribeMacro{fancytabs}
%
% This class can automatically make use of the \textsf{fancytabs} package
% to typeset tabs on the side of every odd page, with the name of the current month.
%
% \subsection{The \texttt{journal} environment}
%
% The \texttt{journal} environment is the main addition of this class.
% It provides an environment in which to typeset journal entries.
%
% The \texttt{journal} environment takes the following options:
%
% \DescribeMacro{startmonth}
%
% The month in which to start the journal. Defaults to 1.
%
% \DescribeMacro{startday}
%
% The day in which to start the journal. Defaults to 1.
%
% \subsection{Typesetting months}
%
% Once the \texttt{journal} environment in initiated, you can use
% the \texttt{jrnlmonth} and \texttt{jrnlday} commands
% to typeset journal entries.
%
% \DescribeMacro{\jrnlmonth}
%
% The \verb!\jrnlmonth! command starts a new month. It takes the following options:
%
% \DescribeMacro{month}
%
% Forces the current month instead of simply incrementing from the previous one. This parameter is an integer between 1 and 12.
%
% \DescribeMacro{startday}
%
% Start month at a given day, instead of 1.
%
% \subsection{Typesetting a journal entry}
%
% \DescribeMacro{\jrnlday}
%
% In order to typeset a single journal entry, use the \verb!\jrnlday! command. This command takes a mandatory argument which is the journal entry's title, as well as the following options:
%
% \DescribeMacro{day}
%
% Forces the current day instead of simply incrementing from the preivous one. This parameter is an integer.
%
% \DescribeMacro{ante}
%
% Add a text before the date.
%
% \DescribeMacro{post}
%
% Add a text after the date.
%
% \subsection{Index}
%
% When typesetting a journal, you might want to rely only on day entries
% to relate to pages and turn off completely page numbers by using
% an \texttt{empty} page style.
%
% In this situation, if you have to create an index, you might want index entries
% to link to dates in the journal rather than page numbers.
%
% The \textsf{scrjrnl} class records each typeset day in macros so they can be used to generate an index. The macros are named \verb!jrnldaydate\thejrnlday!, with the page day corresponding to the entry, numbered from the first typeset day in the journal.
%
% Below is an example of an index generated using the \textsf{bibleref} package, and linking to journal entries instead of pages:
%
% \begin{verbatim}
%% Index by day
%\renewcommand*{\bvidxpgformat}{transform}
%
%% Get the date for the recorded day
%\newcommand\getdaydate[1]{\csname jrnldaydate#1\endcsname}
%
%% Go through index items
%\newcommand{\transform}[1]{%
% \def\secondparam{0}%
% \forcsvlist\decodesec{#1}}
%\newcommand{\decodesec}[1]{%
% \ifthenelse{\secondparam=1}{, }{}%
% \mbox{\textsc{\getdaydate{#1}}}
% \def\secondparam{1}}
%
%% Patch imakeidx to map journal entry instead of page
%\makeatletter
%\patchcmd{\@index}{\@wrindex}{\@Wrindex}{}{}
%\let\@Wrindex\@wrindex
%\patchcmd{\@Wrindex}{\thepage}{\thejrnltotalday}{}{}
%\let\protected@iwrite\protected@write
%\patchcmd{\protected@iwrite}{\write}{\immediate\write}{}{}
%\patchcmd{\@Wrindex}{\protected@write}{\protected@iwrite}{}{}
%\makeatother
% \end{verbatim}
%
% \StopEventually{}
%
% \section{Implementation}
%
% \iffalse
%<*package>
% \fi
%
% \begin{macrocode}
\ProvidesClass{scrjrnl}
\DeclareOption{scrartcl}{\def\jrnl@class{scrartcl}}
\DeclareOption{scrreprt}{\def\jrnl@class{scrreprt}}
\DeclareOption{scrbook}{\def\jrnl@class{scrbook}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\jrnl@class}}
\ExecuteOptions{scrbook}
\newif\if@jrnl@monthpages
\DeclareOption{monthpages}{\@jrnl@monthpagestrue}
\newif\if@jrnl@fancytabs
\DeclareOption{fancytabs}{\@jrnl@fancytabstrue}
\newif\if@jrnl@cleardaypages
\DeclareOption{cleardaypages}{\@jrnl@cleardaypagestrue}
\ProcessOptions\relax
\LoadClass{\jrnl@class}
\RequirePackage{titlesec}
% \end{macrocode}
%
% \marginpar{Load datetime after babel}
%
% \begin{macrocode}
\AfterPackage!{babel}{\RequirePackage{datetime}}
\newcommand\jrnlformatdate\formatdateny
\newcommand\jrnlformatindexdate\formatdateny
% \end{macrocode}
%
% \marginpar{More datetime}
%
% \begin{macrocode}
% formatdate without year
\def\formatdateny{\csname noyear\languagename\expandafter\endcsname\formatdate}
\def\noyearenglish#1, \the\@year{#1}
\let\noyearamerican\noyearenglish
\let\noyearbritish\noyearenglish
\def\noyearfrench#1\space\number\@year{#1}
\let\noyeargerman\noyearfrench
\let\noyearaustrian\noyeargerman
\let\noyearswedish\noyearfrench
\let\noyearbreton\noyearfrench
\def\noyearrussian#1\ \number\@year~\cyrg.{#1}
\def\noyearspanish#1\ de~\number\@year{#1}
\let\noyearcatalan\noyearspanish
\def\noyearbasque#1\number\@year.eko\space{#1}
% \end{macrocode}
%
% \marginpar{Set default lengths}
%
% \begin{macrocode}
\newlength{\jrnldaysepskip}
\setlength{\jrnldaysepskip}{0pt}
\newlength{\jrnldayafterskip}
\setlength{\jrnldayafterskip}{2\baselineskip}
% \end{macrocode}
%
% \marginpar{Load fancytabs}
%
% \begin{macrocode}
%%\if@jrnl@fancytabs
\RequirePackage{fancytabs}[2012/09/24]
%%\fi
% \end{macrocode}
%
% \marginpar{Month names}
%
% \begin{macrocode}
\newcommand{\jrnl@monthname}[1]{\monthname[#1]}
\newcommand{\jrnl@curmonth}{\jrnl@monthname{\thejrnlmonth}}
% \end{macrocode}
%
% \marginpar{Setup counters}
%
% \begin{macrocode}
\newcounter{jrnlstartchapter}
\newcounter{jrnlday}
\newcounter{jrnlmonth}
\newcounter{jrnlyear}
\newcounter{jrnltotalday}
% \end{macrocode}
%
% \marginpar{HTML hooks for TeX4HT}
%
% \begin{macrocode}
\newcommand{\HTMLchapHook}[1]{}
\newcommand{\HTMLsecHook}[2]{}
% \end{macrocode}
%
% \marginpar{Define jrnlmonth}
%
% \begin{macrocode}
\newcounter{jrnlmonthstartday}
\define@key{jrnlmonth}{month}{\setcounter{jrnlmonth}{#1}\addtocounter{jrnlmonth}{-1}}
\define@key{jrnlmonth}{startday}{\setcounter{jrnlmonthstartday}{#1}\addtocounter{jrnlmonthstartday}{-1}}
\newcommand{\jrnlmonth}[1][]{%
% Use \thejrnlstatday if first month of journal
\setcounter{jrnlmonthstartday}{\thejrnlstartday}%
\setcounter{jrnlstartday}{0}%
\setkeys{jrnlmonth}{#1}%
\stepcounter{jrnlmonth}%
\HTMLchapHook{\jrnl@curmonth}%
\if@jrnl@monthpages
\chapter{\jrnl@curmonth}%
\cleardoublepage%
\else
\refstepcounter{chapter}%
\@maybeautodot\thechapter
\addchaptertocentry{\thechapter}{\jrnl@curmonth}%
\fi
\setcounter{jrnlday}{\thejrnlmonthstartday}%
}
% \end{macrocode}
%
%
% \marginpar{Define jrnlday}
%
% \begin{macrocode}
\newcommand{\jrnl@pagedate}{%
\jrnlformatdate{\thejrnlday}{\thejrnlmonth}{\thejrnlyear}%
}
\define@key{jrnlday}{day}{\setcounter{jrnlday}{#1}\addtocounter{jrnlday}{-1}}
\define@key{jrnlday}{ante}{\def\jrnlday@ante{#1}}
\define@key{jrnlday}{post}{\def\jrnlday@post{#1}}
\newcommand{\jrnlday}[2][]{%
\def\jrnlday@ante{}%
\def\jrnlday@post{}%
\setkeys{jrnlday}{#1}%
\stepcounter{jrnlday}%
\stepcounter{jrnltotalday}%
\if@jrnl@cleardaypages
\cleardoublepage
\fi
\newpage\section{#2}%
% TODO: provide index macros to be used with jrnlpagedate\thepage
\expandafter\xdef\csname jrnldaydate\thejrnltotalday\endcsname{%
\noexpand\jrnlformatindexdate{\thejrnlday}{\thejrnlmonth}{\thejrnlyear}%
}%
\HTMLsecHook{\jrnlday@ante\jrnlformatdate{\thejrnlday}{\thejrnlmonth}{\thejrnlyear}\jrnlday@post}{#2}%
}
% \end{macrocode}
%
%
% \marginpar{Define fonts}
%
% \begin{macrocode}
\newcommand\dayheadfont{}
\newcommand\monthheadfont{}
% \end{macrocode}
%
%
% \marginpar{Chapter/section styles}
%
% \begin{macrocode}
\newcommand\jrnl@titlestrut{\vrule height 25pt width0pt\relax}
\newcommand{\jrnl@secstyle}{\filcenter\dayheadfont\huge}
\newcommand{\jrnl@seclblstyle}{\raggedright\normalfont\scshape\Large}
\newcommand{\jrnl@seclbl}{\jrnl@seclblstyle\jrnlday@ante\jrnl@pagedate\jrnlday@post\\}
\newcommand{\jrnl@chapstyle}{\filcenter\monthheadfont\Huge\textsc}
% \end{macrocode}
%
%
% \marginpar{Define journal environment}
%
% \begin{macrocode}
\newcounter{jrnlstartmonth}
\newcounter{jrnlstartday}
\define@key{jrnl}{startmonth}{\setcounter{jrnlstartmonth}{#1}\addtocounter{jrnlstartmonth}{-1}}
\define@key{jrnl}{startday}{\setcounter{jrnlstartday}{#1}\addtocounter{jrnlstartday}{-1}}
\newlength{\jrnl@bleed}
\define@key{jrnl}{bleed}{\setlength{\jrnl@bleed}{#1}}
\newenvironment{journal}[1][]%
{%
\setcounter{jrnlstartmonth}{0}%
\setcounter{jrnlstartday}{0}%
\setkeys{jrnl}{#1}%
\setcounter{jrnlstartchapter}{\thechapter}
\addtocounter{jrnlmonth}{\thejrnlstartmonth}
\titleformat{\chapter}[block]
{\vfill}
{}{0pt}
{\jrnl@chapstyle}
[\vfill\vfill]
\if@jrnl@fancytabs
% We know \paperheight and bleed
% Calculation base:
% 6*fancytabsHeight+2*fancytabsTop+5*fancytabsGap = paperheight
% fancytabsHeight = 10*fancytabsGap
% fancytabsTop = 5*fancytabsGap + 2*bleed
% Calculate \calcfancytabsGap as (\the\paperheight-2*bleed)/75
\newlength{\calcfancytabsGap}
\pgfmathsetlength{\calcfancytabsGap}{\the\paperheight-2*\the\jrnl@bleed)/75}
\fancytabsGap{\the\calcfancytabsGap}
% Calculate \calcfancytabsHeight as 10*\calcfancytabsGap
\newlength{\calcfancytabsHeight}
\pgfmathsetlength{\calcfancytabsHeight}{10*\calcfancytabsGap}
\fancytabsHeight{\the\calcfancytabsHeight}
% Calculate \calcfancytabsTop as (5*\calcfancytabsGap+2\jrnl@bleed)
\newlength{\calcfancytabsTop}
\pgfmathsetlength{\calcfancytabsTop}{5*\calcfancytabsGap+2*\the\jrnl@bleed}
\fancytabsTop{\the\calcfancytabsTop}
% Calculate \fancytabsWidth, without bleed
\newlength{\calcfancytabsWidth}
\pgfmathsetlength{\calcfancytabsWidth}{\the\paperwidth/12}
% Calculate \fancytabsWidthBleed, with bleed
\newlength{\calcfancytabsWidthBleed}
\pgfmathsetlength{\calcfancytabsWidthBleed}{\the\calcfancytabsWidth+\the\jrnl@bleed}
\fancytabsWidth{\the\calcfancytabsWidthBleed}
\fancytabsTextVPos{0.5}
% Put text more inside
% \fancytabsTextHPos = (\fancytabsWidth/2)/\fancytabsWidthBleed
\pgfmathsetmacro{\calcfancytabsTextHPos}{(\the\calcfancytabsWidth/2)/(\the\calcfancytabsWidthBleed)}
\fancytabsTextHPos{\calcfancytabsTextHPos}
\newcommand{\jrnl@fancytab}{%
\ifthenelse{\isodd{\thepage}}%
{\fancytab{\jrnl@curmonth}{\thejrnlmonth}}%
{}%
}
\else
\newcommand{\jrnl@fancytab}{}%
\fi
\titleformat{\section}[display]
{\jrnl@secstyle} % format
{\jrnl@seclbl} % label
{\jrnldaysepskip} %sep
{\jrnl@fancytab%
\jrnl@titlestrut\filcenter} %before
[\vspace{\jrnldayafterskip}] %after
\titlespacing{\section}{0pt}{*}{-3pt}
} % end of \begin{devotional}
{} % end of \end{devotional}
% \end{macrocode}
%
% \iffalse
%</package>
% \fi
%
% \Finale
\endinput
|