summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/novel/novel-ChapterScene.sty
blob: 7fdf5adb33c27b328b140e7ae95d78281c972b58 (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
%%
%% This is file `novel-ChapterScene.sty', part of class `novel'.
%% Copyright 2017 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}%
[2017/03/01 v1.0.6 LaTeX file (chapter and scene macros)]
%%


% Class `novel' does not use \maketitle.
\gdef\maketitle{%
  \ClassError{novel}{\string\maketitle does not exist in this class}%
   {Sorry, but there is no \string\maketitle command in `novel' class.^^J%
    You must make your own title pages!^^J}%
}
%


%% 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 \IndentAfterScenebreak in preamble to change this globally.
%   Either way, the local behavior can be changed using \indent or \noindent.
%   Note: The indent behavior is activated AtBeginDocument.
\newif\if@indentAfterScenebreak \@indentAfterScenebreakfalse
\newcommand\IndentAfterScenebreak{\@indentAfterScenebreaktrue}
%
\newcommand\scenebreak{\null}
%
\newcommand\sceneline{%
  \noindent\hfil%
  \raisebox{0.2em}{\rule{0.35\textwidth}{.4pt}}\hfil\par%
}
%
\newcommand\scenestars{%
  \noindent\hfil%
  \raisebox{-.3em}{*\quad\quad*\quad\quad*}\hfil\par%
}
%% end scene changes


%% Repair \FirstLine{} command from `magaz' package.
% Problem: Conflict with \noindent\nov@AfterGroup as used in ChapterDisplay.
%   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 debug 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%
}
%%



%% ChapterDisplay 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.
\newif \if@addCTline \@addCTlinetrue
\newcounter{@linequarter}
\newif \if@csalignok \@csalignokfalse
%
% The argument is the number of normal baselineskips high:
\newenvironment{ChapterDisplay}[1][10]
{%
  \FPsub{\@fixlines}{#1}{3}%
  \FPsub{\@fixlines}{\@fixlines}{0.001}% fudge to avoid rounding problems
  \if@thispagestyleset\else\thispagestyle{\@setchapterdisplay}\fi%
  \null%
  \ResetFootnoteSymbol% resets symbolic markers, but not numeric markers
  \if@addCTline\null\else\fi% used with dropfolio
  \setcounter{@linequarter}{0}%
  \begin{textblock*}{\textwidth}[0,0](0pt,0pt)%
}{%
  \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}%
  \nov@AfterGroup\NoIndentAfterThis% etextools and noindentafter
}
%%


%
\newcommand\ChapterTitle[2][c]{% optional alignment l, c, r
  \vspace{0.5\nbs}\addtocounter{@linequarter}{2}
  \@csalignokfalse%
  \ifthenelse{\equal{#1}{l}}{\let\@csalign\relax\@csalignoktrue}{}
  \ifthenelse{\equal{#1}{c}}{\let\@csalign\centering\relax\@csalignoktrue}{}
  \ifthenelse{\equal{#1}{r}}{\let\@csalign\hfill\relax\@csalignoktrue}{}
  \if@csalignok\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}
  \@csalignokfalse%
  \ifthenelse{\equal{#1}{l}}{\let\@csalign\relax\@csalignoktrue}{}
  \ifthenelse{\equal{#1}{c}}{\let\@csalign\centering\relax\@csalignoktrue}{}
  \ifthenelse{\equal{#1}{r}}{\let\@csalign\hfill\relax\@csalignoktrue}{}
  \if@csalignok\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
  \StrDel{#1}{ }[\temp@cds]% may use space separator
  \StrDel{\temp@cds}{,}[\temp@cd]% may use comma separator
  \IfSubStr{#1}{l}{%
    \let\@csalign\relax\@csalignoktrue%
    \StrDel{\temp@cd}{l}[\temp@cd]%
  }{}%
  \IfSubStr{#1}{c}{%
    \let\@csalign\centering\relax\@csalignoktrue%
    \StrDel{\temp@cd}{c}[\temp@cd]%
  }{}%
  \IfSubStr{#1}{r}{%
    \let\@csalign\hfill\relax\@csalignoktrue%
    \StrDel{\temp@cd}{r}[\temp@cd]%
  }{}%
  \if@csalignok\else%
    \let\@csalign\centering\relax\@csalignoktrue%
  \fi%
  \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}
%% Not to be confused with lowercase \epigraph from package of same name.
%%
% \Epigraph takes one optional argument, which will be parsed for
%   comma-separated values. You may use one, two, or all three values.
% First value is l, c, or r. Position of Epigraph in the textblock. Default c.
%   If l or c, the text within the Epigraph is either left-aligned or justified,
%   depending on whether the third value is given. Note that value c does not
%   center each line of the Epigraph; if that is what you want, then simply
%   use the centering command. If first value is r, text is right-aligned.
% Second value, if given, changes the text size and internal baseline skip.
%   Thus, the text will go off-grid, but that's OK for the purpose.
%   The second value is a number, being scale relative to normal font size.
%   Default is 1. A good value for chapter displays might be around 0.92,
%   equivalent to about 1pt smaller text size (and skip) than normal.
%   A front page, near the book title, might use a value greater than 1.
% If no third value is given, the macro uses the tabular environment to set
%   ragged text at its natural width. Good for verse in particular.
%   If a third value is given, it must be a number that does not exceed 1.
%   This is the portion of textwidth that will be used. Within the Epigraph,
%   text will be justified to the specified width. So, for example, using 0.5
%   creates a justified Epigraph as half the textwidth. Its position will be
%   determined by the first value, l, c, or r.
% The mandatory text argument is the Epigraph, as well as its attribution.
%   More than one paragraph is permitted.
%   Use ordinary \\ and \par for breaks. You will need to use either \par
%   or \\\par before the attribution. Use \hfill to shift the attribution to
%   the right edge of the Epigraph.
%   The text may be styled with the usual simple commands such as \emph{}.
% There is no provision for a horizontal line.
% If used on a stand-alone page, or in the ChapterDisplay environment,
%   then the vertical extent of the Epigraph does not much matter.
% If mingled with main text (not recommended) you may have to correct
%   the line grid using some amount of \vspace{}. That's your problem.
%
\newcommand\Epigraph[2][c]{% note capital E
  \StrDel{#1}{ }[\@onens]
  \StrCut{\@onens}{,}{\@onealigna}{\@onemore}
  \StrCut{\@onemore}{,}{\@onefsa}{\@onewsa}
  \ifthenelse{\equal{\@onealigna}{c}\OR\equal{\@onealigna}{}}{\def\@onealign{c}}{\def\@onealign{\@onealigna}}
  \ifthenelse{\equal{\@onealign}{c}\OR\equal{\@onealign}{l}\OR\equal{\@onealign}{r}}{}{%
    \ClassError{novel}{Wrong syntax in \string\epigraph\space on page \string\thepage}%
    {Optional argument of \string\epigraph\space must begin with l, c, or r.}%
  }
  \IfEndWith{\@onefsa}{.}{\StrGobbleRight{\@onefsa}{1}[\@onefsb]}{\def\@onefsb{\@onefsa}}
  \IfEndWith{\@onewsa}{.}{\StrGobbleRight{\@onewsa}{1}[\@onewsb]}{\def\@onewsb{\@onewsa}}
  \ifthenelse{\equal{\@onefsb}{}}{\def\@onefs{1}}{\def\@onefs{\@onefsb}}
  \IfDecimal{\@onefs}{}{%
    \ClassError{novel}{Wrong syntax in \string\epigraph\space on page \string\thepage}%
    {Optional argument of \string\epigraph\space cannot be parsed for number(s).}%
  }
  \ifthenelse{\equal{\@onewsb}{}}{\def\@onews{-1}}{\def\@onews{\@onewsb}}
  \IfDecimal{\@onews}{}{%
    \ClassError{novel}{Wrong syntax in \string\epigraph\space on page \string\thepage}%
    {Optional argument of \string\epigraph\space cannot be parsed for number(s).}%
  }
  %
  \ifthenelse{\equal{\@onews}{-1}}{% ragged text, no particular width
    \begin{parascale}[\@onefs]
    \ifthenelse{\equal{\@onealign}{c}}{\begin{center}\begin{tabular}{l}}{}%
    \ifthenelse{\equal{\@onealign}{l}}{\begin{tabular}{l}}{}%
    \ifthenelse{\equal{\@onealign}{r}}{\hfill\begin{tabular}{r}}{}%
    \ifvmode\else\unskip\fi#2\par
    \ifthenelse{\equal{\@onealign}{r}}{\end{tabular}}{}%
    \ifthenelse{\equal{\@onealign}{l}}{\end{tabular}}{}%
    \ifthenelse{\equal{\@onealign}{c}}{\end{tabular}\end{center}}{}%
    \end{parascale}\par
  }{% justified text at specified width fraction
    %
    \newlength\@thistw
    \setlength\@thistw{\@onews\textwidth}
    \newlength\@exctw
    \setlength\@exctw{\textwidth}
    \addtolength\@exctw{-\@thistw}
    %
    \ifthenelse{\equal{\@onealign}{l}}{%
      \begin{adjustwidth}{0pt}{\@exctw}
      \setlength\parindent{0pt}
      \ifvmode\else\unskip\fi#2\par
      \end{adjustwidth}\par
    }{}
    %
    \ifthenelse{\equal{\@onealign}{r}}{%
      \begin{adjustwidth}{\@exctw}{0pt}
      \setlength\parindent{0pt}
      \ifvmode\else\unskip\fi#2\par
      \end{adjustwidth}\par
    }{}
    %
    \ifthenelse{\equal{\@onealign}{c}}{%
      \begin{adjustwidth}{0.5\@exctw}{0.5\@exctw}
      \setlength\parindent{0pt}
      \ifvmode\else\unskip\fi#2\par
      \end{adjustwidth}\par
    }{}
    %
  }% end ifthenelse
  %
} % end \Epigraph
%%
\providecommand\epigraph{% to avoid confusion with epigraph package
  \ClassError{novel}{No command \string\epigraph. Try \string\Epigraph}%
   {The `novel' built-in \string\Epigraph\space command uses capital E.}%
}
%%


%% \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.
\newlength\@tempscfx%
\newcommand\QuickChapter[2][]{%
  \null%
  \def\@qctweak{0.3} % raise above grid, em of subchfont
  \noindent{\subchfont\charscale[1,0pt,\@qctweak em]{#2}%
    \setlength\@tempscfx{\heightof{x}}%
    \global\@tempscfx=\@tempscfx%
  }% end subchfont
  \def\@tempscfxnum{\strip@pt\@tempscfx}%
  \def\nxhnum{\strip@pt\normalxheight}%
  \FPdiv{\@qclineth}{\@tempscfxnum}{\nxhnum}% scale of subchfont
  \FPmul{\@howthick}{\@qclineth}{0.049}% typical emdash thickness, em.
  \FPadd{\@howraise}{\@qctweak}{0.23}% typical emdash height em raised.
  \FPmul{\@howraise}{\@howraise}{\@qclineth}%
  \def\@tempscfxnum{\strip@pt\@tempscfx}%
  \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
%%




%
%% End of file `novel-ChapterScene.sty'.