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
|
%%
%% This is file `novel-ChapterScene.sty', part of `novel' document class.
%% Copyright 2017-2018 Robert Allgeyer.
%%
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% 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.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%%
\ProvidesFile{novel-ChapterScene.sty}%
[2018/04/26 v1.52 LaTeX file (chapter and scene macros)]
%%
% Each new chapter generally has its own header/footer style. This allows a
% default setting when chapters begin with ChapterStart environment:
\gdef\SetChapterStartStyle#1{% from v. 1.40.3
\@tempTFfalse%
\ifthenelse{\equal{#1}{fancy}}{\@tempTFtrue}{}%
\ifthenelse{\equal{#1}{empty}}{\@tempTFtrue}{}%
\ifthenelse{\equal{#1}{plain} %
\OR \equal{#1}{fancyplain} \OR \equal{#1}{footer}}{%
\@tempTFtrue%
}{}%
\ifthenelse{\equal{#1}{forcenumber}}{\@tempTFtrue}{}%
\ifthenelse{\equal{#1}{dropfolioinside} %
\OR \equal{#1}{dropfolio} \OR \equal{#1}{dropfoliolater}}{%
\@tempTFtrue%
}{}%
\ifthenelse{\equal{#1}{dropfoliobeneath}}{\@tempTFtrue}{}%
\if@tempTF%
\gdef\@setchapterstart{#1}%
\else%
\ClassError{novel}{Invalid choice for \string\SetChapterStartStyle}%
{Choose: fancy, empty, plain, footer, forcenumber, %
dropfolioinside, dropfoliobeneath.}%
\fi%
}
\let\SetChapterStart\SetChapterStartStyle\relax % deprecated from v1.40.3.
\SetChapterStartStyle{footer} % default
% New in version 1.40.2:
\gdef\SetChapterStartHeight#1{%
\FPifint{#1}\else%
\ClassError{novel}{\string\SetChapterStartHeight\space integer >= 4}%
{Height of ChapterStart must be integer, greater than or equal to 4.}%
\fi%
\FPiflt{#1}{4}%
\ClassError{novel}{\string\SetChapterStartHeight\space integer >= 4}%
{Height of ChapterStart must be integer, greater than or equal to 4.}%
\else\fi%
\gdef\@setchapterstartheight{#1}%
}
\SetChapterStartHeight{10} % default
% See novel.cls for the accompanying AtBeginDocument routine.
% Scene breaks:
% \SetScenebreakIndent controls whether line after \scenebreak, \sceneline,
% or \scenestars will be indented. Set true or false, default false.
%% End reserve space for header/footer and set default ChapterStart
\newif\if@IndentAfterScenebreak
\newcommand\SetScenebreakIndent[1]{% true or false, default false.
\@tempTFfalse
\ifthenelse{\equal{#1}{true}}{%
\@tempTFtrue
\global\@IndentAfterScenebreaktrue
}{}%
\ifthenelse{\equal{#1}{false}}{%
\@tempTFtrue
\global\@IndentAfterScenebreakfalse
}{}%
\if@tempTF\else%
\ClassError{novel}{Bad argument for \string\SetScenebreakIndent\space}%
{\string\SetScenebreakIndent\space argument must be true or false.}%
\fi%
}
\SetScenebreakIndent{false} % default
% Deprected from v. 1.40.3:
\newcommand\IndentAfterScenebreak{\global\@IndentAfterScenebreaktrue}
%% SCENE CHANGES
%% ----------------------------------------------------------------------------
% \scenebreak \sceneline \scenestars
% Use anywhere in document body.
% These commands skip a line.
% \scenebreak leaves the gap empty.
% \sceneline centers a line, about 1/3 textwidth.
% \scenestars centers three widely-spaced asterisks.
% Default behavior is \noindent for following paragraph.
% Use \SetScenebreakIndent{true or false} in Preamble to change globally.
% Either way, local behavior changed using \forceindent or \backindent.
% \newcommand\scenebreak{\null}
%
\newcommand\scenebreak{% revised in version 1.52.
\leavevmode\getBreakpos{scenebreak}~\par
}
%
\newcommand\sceneline{%
\noindent\getBreakpos{sceneline}\hfil%
\raisebox{0.2em}{\rule{0.35\textwidth}{.4pt}}\hfil\par%
}
%
\newcommand\scenestars{%
\noindent\getBreakpos{scenestars}\hfil%
\raisebox{-.3em}{*\quad\quad*\quad\quad*}\hfil\par%
}
%
\gdef\getBreakpos#1{%
\begingroup%
\savepos%
\protected@write\@auxout{}{%
\protect\@getBreakpos{\noexpand\number\lastypos}{\thepage}{#1}%
}%
\endgroup%
}
%
\newlength\CurrentBreakpos
\gdef\@getBreakpos#1#2#3{} % nothing, when reading aux at beginning
\gdef\@RedefineBreakpos{ % called by `novel.cls' \AtBeginDocument
\gdef\@getBreakpos##1##2##3{% numerical position sp, page, break type
\gsetlength\CurrentBreakpos{##1sp}% measured up from very bottom of page.
\FPsub{\@BreakLines}{\strip@pt\TotalYpos}{\strip@pt\CurrentBreakpos}
\FPdiv{\@BreakLines}{\@BreakLines}{\strip@pt\nbs}%
\FPround{\@BreakLines}{\@BreakLines}{0}% integer lines from text top
\ifthenelse{\equal{##3}{scenebreak}}{%
\xdef\thisline{\@BreakLines}%
\ifnum\@BreakLines=1%
\ClassWarning{novel}{Replace \string\scenebreak\space at top of ^^J%
page ##2 with \string\sceneline\space or \string\scenestars.}%
\fi%
\ifnum\@BreakLines=\@LinesPerPage%
\ClassWarning{novel}{Replace \string\scenebreak\space at bottom of ^^J%
page ##2 with \string\sceneline\space or \string\scenestars.}%
\fi%
}{}%
\FPsub{\@nearthebottom}{\@LinesPerPage}{1}%
\ifnum\@BreakLines=2%
\ClassWarning{novel}{\string\ ##3 too close to top of page ##2.}%
\fi%
\ifnum\@BreakLines=\@nearthebottom%
\ClassWarning{novel}{\string\ ##3 too close to bottom of page ##2.}%
\fi%
}%
} % end @RedefineBreakpos
%%
%% Repair \FirstLine{} command from `magaz' package.
% Problem: Conflict with \noindent\nov@AfterGroup as used in ChapterStart.
% The \noindent is carried past \FirstLine to the following paragraph.
% Solution: After FirstLine completes, back up one line vertically, then insert
% and empty line to restore grid and absorb the noindent.
% Starred version uses the original \FirstLine definition, just in case
% the following paragraph has some exotic feature.
% Thanks to user `egreg' at tex.stackexchange.com for assistance.
\let\oldFirstLine\FirstLine
\def\FirstLine{\@ifstar\FirstLineFoo\@FirstLineFoo} % improved
\def\FirstLineFoo#1{\oldFirstLine{#1}} % starred restores original def.
\def\@FirstLineFoo#1{%
\oldFirstLine{#1}\par\vspace{-\nbs}\strut\par%
}
%%
%% Chapter number count. New in version 1.44. See documentation.
%% Do NOT use for "chapter-like" sections, only numbered chapters.
\newcounter{novelcn}
\setcounter{novelcn}{1}
%%
%% ChapterStart environment.
% The most useful way to start a new chapter. Occupies a fixed amount of
% vertical space. Also self-adjust when used with dropfolio. Automatically
% calls \thispagestyle if set for all chapter displays.
% This environment is not restricted to chapters. It is also used for
% chapter-like sections in front matter or main matter,
% as long as they are styled like a chapter.
\newcounter{@linequarter}
%
% The argument is the number of normal baselineskips high.
\newif\if@WithinChapterStart
\DeclareDocumentEnvironment {ChapterStart} %
{ O{\@setchapterstartheight} O{\@setchapterstart} }{%
\if@ThisPageStyle\else%
\gdef\@thiscsstyle{#2}%
\thispagestyle{\@thiscsstyle}%
\fi%
\global\@WithinChapterStarttrue%
\suppressfloats[t]% ensures that a floated image does not go on top
\gsetlength\parindent{0pt}% within environment
\ResetFootnoteSymbol% resets symbolic markers, but not numerical markers
\IfStrEq{#1}{*}{%
\gdef\@thiscsheight{\@setchapterstartheight}%
}{%
\gdef\@thiscsheight{#1}%
}%
\FPsub{\@fixlines}{\@thiscsheight}{2}%
\FPsub{\@fixlines}{\@fixlines}{0.001}% fudge to avoid rounding problems
\FPround{\@thiscsheight}{\@thiscsheight}{0}%
\FPiflt{\@thiscsheight}{4}%
\def\@smcserr{%
\ClassError{novel}{ChapterStart height insufficient for thispagestyle}%
{With your choice for thispagestyle, the height must be at least 4.}%
}%
\IfStrEq{\@thiscsstyle}{dropfolioinside}{\@smcserr}{}%j
\IfStrEq{\@thiscsstyle}{plain}{\@smcserr}{}%
\IfStrEq{\@thiscsstyle}{fancyplain}{\@smcserr}{}%
\else\fi%
\FPiflt{\@thiscsheight}{3}%
\ClassError{novel}{ChapterStart height must be at least 3}%
{If you need height less than 3, consider \string\QuickChapter.}%
\else\fi%
\null% always a line above the first thing to appear within the environment
\setcounter{@linequarter}{0}%
\begin{textblock*}{\textwidth}[0,0](0pt,0pt)%
}{% close the environment:
\ifthenelse{%
\equal{\value{@linequarter}}{1} \OR \equal{\value{@linequarter}}{5}%
\OR \equal{\value{@linequarter}}{9} \OR \equal{\value{@linequarter}}{13}%
}{\vspace{0.75\nbs}}{}%
\ifthenelse{%
\equal{\value{@linequarter}}{2} \OR \equal{\value{@linequarter}}{6}%
\OR \equal{\value{@linequarter}}{10} \OR \equal{\value{@linequarter}}{14}%
}{\vspace{0.5\nbs}}{}%
\ifthenelse{%
\equal{\value{@linequarter}}{3} \OR \equal{\value{@linequarter}}{7}%
\OR \equal{\value{@linequarter}}{11} \OR \equal{\value{@linequarter}}{15}%
}{\vspace{0.25\nbs}}{}%
\end{textblock*}%
\vspace{\@fixlines\nbs}%
\if@DeleteCSline\else\null\fi% adjusts when dropfolioinside
\global\@WithinChapterStartfalse%
\vspace{0.1pt plus 0pt minus 0.2pt}% caulk
\gsetlength\parindent{\normalparindent}% restored
\nov@AfterGroup\NoIndentAfterThis% etextools and noindentafter
}
% end ChapterStart environment
%%
\LetLtxMacro\ChapterDisplay\ChapterStart\relax % deprecated
\LetLtxMacro\endChapterDisplay\endChapterStart\relax % deprecated
%
\newcommand\ChapterTitle[2][c]{% optional alignment l, c, r
\ignorespaces%
\vspace{0.5\nbs}\addtocounter{@linequarter}{2}%
\@tempTFfalse%
\ifthenelse{\equal{#1}{l}}{\let\@csalign\relax\@tempTFtrue}{}%
\ifthenelse{\equal{#1}{c}}{\let\@csalign\centering\relax\@tempTFtrue}{}%
\ifthenelse{\equal{#1}{r}}{\let\@csalign\hfill\relax\@tempTFtrue}{}%
\if@tempTF\else%
\ClassError{novel}{Chapter Title, Deco, Subtitle align must be l, c, or r}%
{On page \thepage you wrote a Chapter command with alignment ^^J%
other than the allowed l, c, or r.}%
\fi%
{\@csalign\stake\smash{{\chapterfont{}#2}}\par}%
}
%
\newcommand\ChapterSubtitle[2][c]{% optional alignment l, c, r
\vspace{0.25\nbs}\addtocounter{@linequarter}{1}
\@tempTFfalse%
\ifthenelse{\equal{#1}{l}}{\let\@csalign\relax\@tempTFtrue}{}
\ifthenelse{\equal{#1}{c}}{\let\@csalign\centering\relax\@tempTFtrue}{}
\ifthenelse{\equal{#1}{r}}{\let\@csalign\hfill\relax\@tempTFtrue}{}
\if@tempTF\else%
\ClassError{novel}{Chapter Title, Deco, Subtitle align must be l, c, or r}%
{On page \thepage you wrote a Chapter command with alignment ^^J%
other than the allowed l, c, or r.}%
\fi%
{\@csalign{\stake\smash{\subchfont #2}}\par}%
}
% In ChapterDeco, a trick is used. Instead of two optional arguments, and
% instead of using expl3 syntax to create different argument delimiters,
% the arguments for alignment and scale are passed as a single option.
% This works because one is a letter, and the other is a number.
% So it is easy to separte them by parsing.
\newcommand\ChapterDeco[2][c1]{% optional alignment and scale, either order
\@tempTFfalse
\StrDel{#1}{ }[\temp@cds]% may use space separator
\StrDel{\temp@cds}{,}[\temp@cd]% may use comma separator
\IfSubStr{#1}{l}{% left align
\let\@csalign\relax\@tempTFtrue%
\StrDel{\temp@cd}{l}[\temp@cd]%
}{}%
\IfSubStr{#1}{c}{% centered
\let\@csalign\centering\relax\@tempTFtrue%
\StrDel{\temp@cd}{c}[\temp@cd]%
}{}%
\IfSubStr{#1}{r}{% right align
\let\@csalign\hfill\relax\@tempTFtrue%
\StrDel{\temp@cd}{r}[\temp@cd]%
}{}%
\if@tempTF\else%
\let\@csalign\centering\relax\@tempTFtrue%
\fi%
% Now for scaling, with adjusted vertical position:
\IfEndWith{\temp@cd}{.}{\StrSubstitute{\temp@cd}{.}{.0}[\temp@cd]}{}%
\IfBeginWith{\temp@cd}{.}{\StrSubstitute{\temp@cd}{.}{1.}[\temp@cd]}{}%
\IfDecimal{\temp@cd}{\def\@thisScale{\temp@cd}}{\def\@thisScale{1}}%
{\@csalign\charscale[\@thisScale,0pt,0.2\nbs]{#2}\par}%
}
%
%%
%% \Epigraph[align,scale,width]{text} OBSOLETE IN CODE VERSION 1.2
%% \QuickChapter[line style]{text} intended for a story consisting of numerous
% short chapters without page breaks. Two blank lines are inserted. In the gap
% is the text, using subchfont. Optional line follows using \bigemdash style.
% If option is empty, no line. If a length, then the line is that length.
% If option * then the line fills to end of text line.
\newcommand\QuickChapter[2][]{%
\null%
\noindent{\subchfont\charscale[1,0pt,0.3em]{#2}%
\gsetlength\@tempLength{\heightof{x}}% height of x in subchfont
}% end subchfont
\FPdiv{\@qclineth}{\strip@pt\@tempLength}{\strip@pt\normalxheight}% fontscale
\FPmul{\@howthick}{\@qclineth}{0.049}% typical emdash thickness, em.
\FPmul{\@howraise}{0.23}{\@qclineth}% typical emdash height em raised.
\ifthenelse{\equal{#1}{} \OR \equal{#1}{ }}{}{% no line, else:
\ifthenelse{\equal{#1}{*}}{% line fills:
~\leaders%
\hbox{\smash{\rule[\@howraise em]{1pt}{\@howthick em}}}%
\hfill\stake\par%
}{% else line at specific length:
~\makebox[#1][l]{%
\leaders\hbox{\smash{\rule[\@howraise em]{1pt}{\@howthick em}}}\hfill%
}%
}%
}%
\NoIndentAfterThis%
} % end \QuickChapter
%%
%% New in version 1.40: \cleartorecto and \cleartoend
% \cleartorecto works same as \clearpage when next page is recto.
% If next page would be verso, a blank verso is inserted,
% so that the following material is recto.
% \cleartoend is used at very end of book.
% It adds a blank page. If the blank is verso, end of book.
% But if that blank is recto, it adds a second blank page, end of book.
% So, the book always ends with a blank verso.
\gdef\cleartorecto{
\clearpage
\ifodd\c@page
\else
\thispagestyle{empty}
\null
\clearpage
\fi
}
\newif \if@cleartoend
\gdef\cleartoend{
\if@cleartoend\else
\clearpage
\ifodd\c@page
\thispagestyle{empty}
\null
\clearpage
\fi
\thispagestyle{empty}
\null
\clearpage
\fi
\global\@cleartoendtrue
}
%
%%
\gdef\@ActivateChapterScene{% called by `novel.cls' \AtBeginDocument
% Activate user choice of whether or not to indent after scenebreak commands:
\if@IndentAfterScenebreak\else
\NoIndentAfterCmd{\scenebreak}
\NoIndentAfterCmd{\sceneline}
\NoIndentAfterCmd{\scenestars}
\fi
}% end \@ActivateChapterScene
%%
%% Neutralize settings commands:
\gdef\@DisableChapterSceneSettings{% called by `novel.cls' \AtBeginDocument
\LetLtxMacro\SetHeadFootStyle\relax
\LetLtxMacro\IndentAfterScenebreak\relax
\LetLtxMacro\SetScenebreakIndent\relax
}% end \@DisableChapterSceneSettings
%%
%%
\endinput
%%
%% End of file `novel-ChapterScene.sty'.
|