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
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
|
%%
%% This is file `novel-LayoutSettings.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-LayoutSettings.sty}%
[2017/10/04 v1.42 LaTeX file (layout settings)]
%%
%% Note that nearly all layout settings are preconfigured based on Trim Size.
%% In general, these user commands may be used to over-ride the presets.
\newlength\Old@TrimWidth % finished width of printed book
\newlength\Old@TrimHeight % finished height of printed book
\newlength\New@TrimWidth % Initialized to \Old@TrimWidth.
\newlength\New@TrimHeight % Initialized to \Old@TrimHeight.
\newlength\Old@TopMargin
\newlength\Old@OutsideMargin
\newlength\Old@BottomMargin
\newlength\Old@InsideMargin
\newlength\New@TopMargin
\newlength\New@OutsideMargin
\newlength\New@BottomMargin
\newlength\New@InsideMargin
\newlength\Old@MediaWidth % Defaults to trim width, but can be set larger.
\newlength\Old@MediaHeight % Defaults to trim height, but can be set larger.
\newlength\New@MediaWidth % Initialized to \Old@MediaWidth.
\newlength\New@MediaHeight % Initialized to \Old@MediaHeight.
\newlength\Old@FontSize
%
\gdef\my@HeadFootStyle{1} % default: header but not footer
\gdef\my@VersoEmblem{} % no default emblem
\gdef\my@RectoEmblem{} % no default emblem
\gdef\novel@checkfeatures#1{} % re-defined below
%
\newif \if@TrimSizeSet
\newif \if@MarginsSet
\newif \if@MediaSizeSet
\newif \if@LinesPerPageSet
\newif \if@FontSizeSet
\newif \if@ReworkTrimSet
\newif \if@ReworkMarginsSet
%
\newlength\normalxheight
\newlength\normalXheight
%%
%% SIZE-RELATED COMMANDS AVAILABLE IN PREAMBLE.
%% --------------------------------------------------------------------------
%% Use if necessary for customization.
%% If you like a class option that pre-sets these values,
%% then you do not have to use any of these commands.
%
% Note: This class does not ask you to set the width/height of the textblock.
% Instead, these values are automatically calculated from other dimensions.
%
%
% \SetTrimSize{}{} width and height of printed book.
\newcommand\SetTrimSize[2]{%
\global\@TrimSizeSettrue
\ifthenelse{\dimtest{#1}{<}{2.99in}}{
\ClassError{novel}{Unacceptably small Trim Width}%
{Trim Width must be at least 3in.}%
}{}
\ifthenelse{\dimtest{#2}{<}{2.99in}}{
\ClassError{novel}{Unacceptably small Trim Height}%
{Trim Height must be at least 3in.}%
}{}
\if@ReworkTrimSet
\ClassError{novel}{^^JCannot set Trim after reworking Trim or Margins}%
{\string\SetTrimSize\space cannot follow \string\ReworkTrimSize.}%
\fi
\if@ReworkMarginsSet
\ClassError{novel}{^^JCannot set Trim after reworking Trim or Margins}%
{\string\SetTrimSize\space cannot follow \string\ReworkTrimSize^^J%
and cannot follow \string\ReworkMargins.}%
\fi
\setlength\Old@TrimWidth{#1}%
\setlength\Old@TrimHeight{#2}%
\setlength\New@TrimWidth{#1}%
\setlength\New@TrimHeight{#2}%
\if@MediaSizeSet\else
\setlength\Old@MediaWidth{#1}%
\setlength\Old@MediaHeight{#2}%
\setlength\New@MediaWidth{#1}%
\setlength\New@MediaHeight{#2}%
\fi
}
%
% Retroactively change Trim Size after layout. See documentation:
\newcommand\ReworkTrimSize[2]{%
\if@coverart % New in version 1.2
\ClassError{novel}{Rework command cannot be used with coverart option}%
{Instead of reworking document size, you must re-do the artwork.}
\else
\global\@ReworkTrimSettrue
\setlength\New@TrimWidth{#1}%
\setlength\New@TrimHeight{#2}%
\setlength\New@MediaWidth{#1}%
\setlength\New@MediaHeight{#2}%
\typeout{^^J Class `novel' Info: %
Used \string\ReworkTrimSize{}{} command.^^J%
Carefully review your PDF to ensure that line breaks, paragraphs,^^J%
and page breaks are where you expect them to be.^^J}%
\fi
}
% Margins at top and bottom are relative to:
% top of header, or top of textblock if no header;
% bottom of footer, or bottom of textblock if no footer.
% Inside margin generally greater than outside, due to gutter.
% Standard margins command ("TOBI, or not TOBI, that is the question."):
\newcommand\SetMargins[4]{ % top, outside, bottom, inside
\global\@MarginsSettrue
\if@ReworkMarginsSet
\ClassError{novel}{^^JCannot set Margins after reworking them}%
{\string\SetMargins\space cannot follow \string\ReworkMargins.}%
\fi
\setlength\Old@TopMargin{#1}
\setlength\New@TopMargin{#1}
\setlength\Old@OutsideMargin{#2}
\setlength\New@OutsideMargin{#2}
\setlength\Old@BottomMargin{#3}
\setlength\New@BottomMargin{#3}
\setlength\Old@InsideMargin{#4}
\setlength\New@InsideMargin{#4}
}
% Retroactively change margins after layout. See documentation:
\newcommand\ReworkMargins[4]{
\if@coverart % New in version 1.2
\ClassError{novel}{Rework command cannot be used with coverart option}%
{Instead of reworking document size, you must re-do the artwork.}
\else
\global\@ReworkMarginsSettrue
\setlength\New@TopMargin{#1}
\setlength\New@OutsideMargin{#2}
\setlength\New@BottomMargin{#3}
\setlength\New@InsideMargin{#4}
\typeout{^^J Class novel Info: %
Used \string\ReworkMargins{}{} command.^^J%
Carefully review your PDF to ensure that line breaks, paragraphs,^^J%
and page breaks are where you expect them to be.^^J}%
\fi
}
% \SetMediaSize[]{}{} such as {8.5in}{11in}.
% This command is only used when the Trim Size must be placed in a larger
% Media Size. Otherwise, Media Size is automatically set to Trim Size.
% This command cannot be used until after Trim Size is set, either by
% class option or by \SetTrimSize{}{}.
% Trim will be horizontally and vertically centered in media.
% No `rework' is needed for Media Size, because interior layout is relative
% to Trim Size, not Media Size.
%
\newif \if@offcenterTrim \@offcenterTrimfalse
\newcommand\SetMediaSize[3][center]{ % [alignment] width, height
\ifthenelse{\equal{#1}{center} \OR \equal{#1}{edge}}{
\global\@MediaSizeSettrue
\setlength\Old@MediaWidth{#2}
\setlength\New@MediaWidth{#2}
\setlength\Old@MediaHeight{#3}
\setlength\New@MediaHeight{#3}
}{
\ClassError{novel}{Bad optional argument for \string\SetMediaSize}%
{\string\SetMediaSize\space optional argument must be `center' or `edge'.}%
}
\if@coverart\else % new in version 1.2
\ifthenelse{\equal{#1}{edge}}{\global\@offcenterTrimtrue}{}
\fi
}
% \SetLinesPerPage{} limited due to fontsize and Trim Size constraints.
% There is no `rework' command, because as long as the number of lines fit,
% the line spacing will be automatically changed to fit a reworked size.
% The only possible problem is if lines were originally so tight that
% a reworked size cannot fit. In that case, the user's best plan is remove
% header or footer (if possible), or reduce vertical margins (if possible).
\newcommand\SetLinesPerPage[1]{
\global\@LinesPerPageSettrue
\FPiflt{#1}{1}%
\ClassError{novel}{\string\SetLinesPerPage\ must be at least 1}%
{You requested less than one line per page. Naughty!^^J}%
\else\fi %
\FPround{\temp@IntegerLines}{#1}{0}
\def\my@LinesPerPage{\temp@IntegerLines}
}
% \SetFontSize{} may be in any units, even decimals: 12.2pt, 11.5bp, etc.
% When packages load, the font size is temporarily set to 11pt at 15pt skip,
% so that moldy-oldie packages don't get confused about metrics.
% Then the size is changed to its actual value based on this command, or on
% the defaults for Trim Size, or on the effects of \Rework.
\newcommand\SetFontSize[1]{
\global\@FontSizeSettrue
\global\setlength\Old@FontSize{#1}
}
%
%% End size-related commands available in Preamble.
%% RESERVE SPACE FOR HEADER/FOOTER, AND SET DEFAULT CHAPTER DISPLAY PAGE
%% --------------------------------------------------------------------------
%% At this point, `novel' needs to know whether or not header/footer used,
%% so that space can be reserved at top/bottom. Actual styling comes later.
%
% If the user wishes to tweak layout, these Preamble commands store info,
% that will be used in novel-CalculateLayout.sty.
% The jumps are scale factors, which increase/decrease headsep and footskip
% relative to normal baselineskip. Do not use \setlength\headsep or
% \setlength\footskip directly, because direct settings will lead to
% improper calculations.
% These "jumps" are measured baseline-to-baseline. So, \SetHeadJump{1} means
% that the baseline of the header is 1 baselineskip above the baseline of
% the first line of textblock. In other words, on-grid. Value 2 would be
% equivalent to double-spaced vertically. A value of 1.5 is default, based
% on observations of actual novels.
% If \SetHeadJump is less than 1, then a warning appears in the log.
\gdef\SetHeadJump#1{\gdef\@headjump{#1}}
\SetHeadJump{1.5} % default
\gdef\SetFootJump#1{\gdef\@footjump{#1}}
\SetFootJump{1.5} % default
% New in version 1.2, coverart.
\if@coverart % cover art has no header or footer
\gdef\SetHeadFootStyle#1{\gdef\my@HeadFootStyle{0}}
\gdef\SetHeadStyle#1{\gdef\my@HeadFootStyle{0}} % deprecated
\SetHeadFootStyle{0}
\else
% See docs for available layout choices:
\gdef\SetHeadFootStyle#1{\gdef\my@HeadFootStyle{#1}}
\gdef\SetHeadStyle#1{\gdef\my@HeadFootStyle{#1}} % deprecated
\fi
% See docs for what these emblems do, if used:
\newcommand\SetEmblems[2]{ % verso, recto
\gdef\my@VersoEmblem{{\headfont #1}}
\gdef\my@RectoEmblem{{\headfont #2}}
}
\let\SetEmblem\SetEmblems% for convenience
% If you want something fancier than \thepage:
\gdef\SetPageNumberStyle#1{\gdef\pagenumberstyle{#1}}
% See novel.cls for the accompanying AtBeginDocument routine.
%
\newif \if@gotHeader
\newif \if@gotFooter
\newif \if@styledHeader
\newif \if@styledFooter
\newif \if@validHF
%
\gdef\@reserveHFspace{ % used for layout calculations
\ifthenelse{\equal{\my@HeadFootStyle}{0}}{
\@gotHeaderfalse\@gotFooterfalse\@validHFtrue
}{}
\ifthenelse{\equal{\my@HeadFootStyle}{1}}{ % default
\@gotHeadertrue\@gotFooterfalse\@validHFtrue
}{}
\ifthenelse{\equal{\my@HeadFootStyle}{2}}{
\@gotHeaderfalse\@gotFootertrue\@validHFtrue
}{}
\ifthenelse{\equal{\my@HeadFootStyle}{3}}{
\@gotHeaderfalse\@gotFootertrue\@validHFtrue
}{}
\ifthenelse{\equal{\my@HeadFootStyle}{4}}{
\@gotHeadertrue\@gotFooterfalse\@validHFtrue
}{}
\ifthenelse{\equal{\my@HeadFootStyle}{5}}{
\@gotHeadertrue\@gotFootertrue\@validHFtrue
}{}
\ifthenelse{\equal{\my@HeadFootStyle}{6}}{
\@gotHeadertrue\@gotFootertrue\@validHFtrue
}{}
% Ensure that user choice was on the allowed list:
\if@validHF\else
\ClassError{novel}{Invalid choice for \string\SetHeadFootStyle}%
{\string\SetHeadFootStyle\space needs choice of 0,1,2,3,4,5,6,^^J%
even if you wish to customize using fancyhdr syntax.^^J}%
\fi
} % end \@reserveHFspace
% Each new chapter generally has its own header/footer style. This allows a
% default setting when chapters begin with ChapterStart environment:
\gdef\SetChapterStartStyle#1{\gdef\@setchapterstart{#1}} % from v1.40.3.
\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 must be integer GTE 4}%
{Height of ChapterStart must be integer, greater than or equal to 4}%
\fi%
\FPiflt{#1}{4}%
\ClassError{novel}{\string\SetChapterStartHeight\space must be integer GTE 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:
\newif\if@indentAfterScenebreak \@indentAfterScenebreakfalse
\newcommand\IndentAfterScenebreak{\@indentAfterScenebreaktrue} % deprected from v. 1.40.3
% \SetScenebreakIndent controls whether line after \scenebreak, \sceneline, or \scenestars
% will be indented. Set true or false, default false.
\newcommand\SetScenebreakIndent[1]{% true or false, default false. From v. 1.40.3
\def\ngoodarg{no}
\ifthenelse{\equal{#1}{true}}{%
\def\ngoodarg{yes}
\@indentAfterScenebreaktrue
}{}%
\ifthenelse{\equal{#1}{false}}{%
\def\ngoodarg{yes}
\@indentAfterScenebreakfalse
}{}%
\ifthenelse{\equal{\ngoodarg}{no}}{%
\ClassError{novel}{Bad argument for \string\SetScenebreakIndent\space}%
{\string\SetScenebreakIndent\space argument must be true or false.}%
}{}%
}
\SetScenebreakIndent{false} % default
%
%% End reserve space for header/footer and set default ChapterStart
%% New in version 1.2: cover image.
\newcommand\SetCoverImage[1]{
\def\coverimageok{false}
\IfSubStr{#1}{jpg}{\def\coverimageok{true}}{}
\IfSubStr{#1}{jpeg}{\def\coverimageok{true}}{}
\IfSubStr{#1}{JPG}{\def\coverimageok{true}}{}
\IfSubStr{#1}{JPEG}{\def\coverimageok{true}}{}
\ifthenelse{\equal{\coverimageok}{true}}{%
\gdef\novelcoverimage{#1}
}{%
\ClassError{novel}{Cover image has wrong file extension}%
{Cover image must be jpg, JPG, jpeg, or JPEG.}
}%
}
%%
%% Markers (superscript, subscripts):
\newtoggle{@usesymbolmark} % true when footnote markers are symbolic
\newtoggle{@realmarker} % true when OT features sups, sinf, subs requested
%
% \SetMarkerStyle does two things.
% Option real: OT features sups, sinf, subs requested. Fake if not available.
% Option fake: Always fake OT features sups, sinf, subs.
% Mandatory: asterisk, dagger, number. Pertains to footnote markers only.
% No matter real or fake, the asterisk symbol is always real, and the
% dagger, dbldagger, and section (when used as footnote markers)
% are always partially faked.
\newcommand\SetMarkerStyle[2][real]{
\def\@goodfnm{no}
\ifthenelse{\equal{#2}{asterisk}}{%
\def\@goodfnm{yes}\global\toggletrue{@usesymbolmark}%
\gdef\@myfnsymbols{*}}{}
\ifthenelse{\equal{#2}{dagger}}{%
\def\@goodfnm{yes}\global\toggletrue{@usesymbolmark}%
\gdef\@myfnsymbols{†}}{}
\ifthenelse{\equal{#2}{number}}{%
\def\@goodfnm{yes}\global\togglefalse{@usesymbolmark}}{}
\def\@goodfnk{no}
\ifthenelse{\equal{#1}{real}\OR\equal{#1}{}}{%
\def\@goodfnk{yes}\global\toggletrue{@realmarker}}{}
\ifthenelse{\equal{#1}{fake}}{%
\def\@goodfnk{yes}\global\togglefalse{@realmarker}}{}
\ifthenelse{\equal{\@goodfnm}{no}\OR\equal{\@goodfnk}{no}}{%
\ClassError{novel}{Bad choice for \string\SetMarkers}%
{Optional: real, fake. Required: asterisk, dagger, number.}%
}{}
}
\LetLtxMacro{\SetMarkers}{\SetMarkerStyle} % backwards compatibilty pre-v1.40.3.
%
\SetMarkerStyle[real]{asterisk} % default
%%
%% Sets the gap between cropmarks and trim area:
\newlength\@mygap
\def\SetCropmarkGap#1{
\ifthenelse{\lengthtest{#1 < 0pt}}{
\setlength\@mygap{0pt}
}{
\setlength\@mygap{#1}
}
}
\SetCropmarkGap{0.125in} % default
%%
%% Fake \microtypesetup until package is loaded later:
\newif \if@setmicrotype
\gdef\microtypesetup#1{
\gdef\@mymicrotypesetup{#1} % used in novel-FontDefaults.sty
\global\@setmicrotypetrue
}
%%
%% MISCELLANOUS SETTINGS. Mostly remove "glue". Best to leave as-is.
%% --------------------------------------------------------------------------
%%
%
\@twocolumnfalse
\@twosidetrue
\@mparswitchtrue
%
\abovedisplayskip \z@
\abovedisplayshortskip \z@
\belowdisplayshortskip \z@
\belowdisplayskip \abovedisplayskip
\global\@topnum \z@
%
\setlength\smallskipamount{0pt}
\setlength\medskipamount{0pt}
\setlength\bigskipamount{0pt}
\setlength\topsep{0pt}
\setlength\partopsep{0pt}
\setlength\parsep{0pt}
\setlength\marginparwidth{0pt}
\setlength\marginparsep{0pt}
\setlength\marginparpush{0pt}
\setlength\textfloatsep{0pt}
\setlength\dbltextfloatsep{0pt}
%
\setlength\lineskip{0pt}
\setlength\normallineskip{0pt}
\renewcommand\baselinestretch{1} % multiplier
\setlength\parskip{0pt}
\@lowpenalty 51
\@medpenalty 151
\@highpenalty 301
%
\setcounter{topnumber}{2}
\renewcommand\topfraction{.7}
\setcounter{bottomnumber}{1}
\renewcommand\bottomfraction{.3}
\setcounter{totalnumber}{3}
\renewcommand\textfraction{.2}
\renewcommand\floatpagefraction{.5}
\setcounter{dbltopnumber}{2}
\renewcommand\dbltopfraction{.7}
\renewcommand\dblfloatpagefraction{.5}
%
\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\normalfont\rmfamily}
\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\normalfont\sffamily}
\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\normalfont\ttfamily}
\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\normalfont\bfseries}
\DeclareOldFontCommand{\it}{\normalfont\itshape}{\normalfont\itshape}
\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\normalfont\slshape}
\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\normalfont\scshape}
%
\setlength\columnsep{12pt} % usually not needed, picked something at random
\setlength\columnseprule{0pt}
\pagestyle{empty} % will be over-ridden by fancyhead in separate file
\pagenumbering{arabic} % may be over-ridden in document
\flushbottom % may be over-ridden in document, but not advised
%
%% End miscellaneous settings.
% The following might become unnecessary if fontspec adds the capability to
% disable keys. For now: Color and Opacity cannot be used as font features,
% for a black/white printed book. Alas, fontspec over-rules xcolor.
% So, this code over-rules fontspec:
\gdef\novel@checkfeatures#1{%
\def\@featuresareok{yes}
\IfSubStr{#1}{Color}{\def\@featuresareok{no}}{}%
\IfSubStr{#1}{Colour}{\def\@featuresareok{no}}{}%
\IfSubStr{#1}{color}{\def\@featuresareok{no}}{}%
\IfSubStr{#1}{colour}{\def\@featuresareok{no}}{}%
\IfSubStr{#1}{Opacity}{\def\@featuresareok{no}}{}%
\IfSubStr{#1}{opacity}{\def\@featuresareok{no}}{}%
\ifthenelse{\equal{\@featuresareok}{yes}}{}{%
\ClassError{novel}{Color and Opacity forbidden as font features}%
{You defined a font, or added a font feature, with Color or Opacity.^^J%
That is disallowed in `novel' class.}%
}
}
%%
%% DEFINITION OF PARENT AND OTHER FONTS
%% --------------------------------------------------------------------------
%% Prior to v. 1.1, parentfont was known as masterfont. Backwards compatible.
%
\providecommand\rmdefault{lmr} % should be lmr anyway, at this point.
\LetLtxMacro\@noveloldrmdefault\rmdefault\relax % stored for later comparison.
% The `no-math' option prevents fontspec from tracking certain font changes.
% This is probably necessary, since novel does some of its own font tracking:
\RequirePackage[no-math]{fontspec} % For LuaLaTeX. NOT package `fontenc'.
% You shouldn't be doing math! You can use \setmathfont, if you wish.
% If you must load a math font package, it should be done using
% \RequirePackage before (yes, before) calling the document class.
\RequirePackage{unicode-math}
%
% Math font no kern:
\defaultfontfeatures{SmallCapsFeatures={Renderer=Basic},Ligatures=TeX,}
%
\IfFontExistsTF{Libertinus Math}
{\setmathfont{Libertinus Math}}
{\IfFontExistsTF{Asana Math}
{\setmathfont{Asana Math}}
{\IfFontExistsTF{STIX Math}
{\setmathfont{STIX Math}}
{\setmathfont{Latin Modern Math}} % last choice
}
}% end \IfFontExistsTF nest.
% For user-created font commands:
\defaultfontfeatures{SmallCapsFeatures={Renderer=Basic},Kerning=On,Ligatures=TeX,}%
%%
%% This could have been easier, but fontspec allows mandatory and optional
% arguments to appear in either order. We wish to store the fontnames
% and arguments, but need Expl syntax to tell which is which.
\ExplSyntaxOn
%% Store settings for the parent font:
% \AtEndPreamble, the parent font becomes becomes
% the default ancestor of all novel-defined fonts, except the deco font.
\newif \if@parentfontset
\gdef\@parentfontfeatures{}
\gdef\@parentfontname{}
\gdef\parentfontfeatures{} % for convenience
\gdef\parentfontname{} % for convenience
\DeclareDocumentCommand \SetParentFont { O{} m O{} } {% from version 1.1.
\novel@checkfeatures{#1,#3}
\gdef\@parentfontfeatures{#1,#3}
\gdef\@parentfontname{#2}
\gdef\parentfontfeatures{#1,#3} % for convenience
\gdef\parentfontname{#2} % for convenience
\global\@parentfontsettrue
}%
\DeclareDocumentCommand \SetMasterFont { O{} m O{} } {% DEPRECATED
\novel@checkfeatures{#1,#3}
\gdef\@parentfontfeatures{#1,#3}
\gdef\@parentfontname{#2}
\global\@parentfontsettrue
}%
%% Store settings for the chapterfont:
% The chapter font is used by the \ChapterTitle{} command.
\newif \if@chapterfontset
\gdef\@chapterfontfeatures{}
\gdef\@chapterfontname{}
\DeclareDocumentCommand \SetChapterFont { O{} m O{} } {%
\novel@checkfeatures{#1,#3}
\gdef\@chapterfontfeatures{#1,#3}
\gdef\@chapterfontname{#2}
\global\@chapterfontsettrue
}%
%% Store settings for the subchfont:
% The subch font is used by the \ChapterSubtitle{} command.
\newif \if@subchfontset
\gdef\@subchfontfeatures{}
\gdef\@subchfontname{}
\DeclareDocumentCommand \SetSubchFont { O{} m O{} } {%
\novel@checkfeatures{#1,#3}
\gdef\@subchfontfeatures{#1,#3}
\gdef\@subchfontname{#2}
\global\@subchfontsettrue
}%
%% Store settings for the headfont:
% The headfont is used in headers and footers.
\newif \if@headfontset
\gdef\@headfontfeatures{}
\gdef\@headfontname{}
\DeclareDocumentCommand \SetHeadFont { O{} m O{} } {%
\novel@checkfeatures{#1,#3}
\gdef\@headfontfeatures{WordSpace=\@looseheadword,LetterSpace=\@loosehead,#1,#3} % revised in v. 1.40.3.
\gdef\@headfontname{#2}
\global\@headfontsettrue
}%
%% Store settings for the deco font:
% The deco font is used for decorations and acronyms.
% It must be NovelDeco.otf or a font based on NovelDeco.otf. No other!
\newif \if@decofontset
\newif \if@gotdeco
\gdef\@decofontfeatures{}
\gdef\@decofontname{}
\DeclareDocumentCommand \SetDecoFont { O{} m O{} } {%
\novel@checkfeatures{#1,#3}
\gdef\@decofontfeatures{#1,#3}
\gdef\@decofontname{#2}
\global\@decofontsettrue
\global\@gotdecotrue
\newfontface\decofont[#1,#3]{#2}
}%
%
\msg_set:nnnn {fontspec} {font-not-found} { % rewrites the standard message
Font~ "#1"~ cannot~ be~ found.
}{
If~the~missing~font~is~Libertinus~or~Libertine~or~Biolinum~or~NovelDeco,\\
see~the~`novel'~class~documents~for~help.\\
If~the~missing~font~is~anything~else,~then~the~missing~font~is\\
not~caused~by~`novel'~class.\\
}%
%% For syntax consistency:
\cs_new_eq:NN \NewFontFamily \newfontfamily
\cs_new_eq:NN \NewFontFace \newfontface
\cs_new_eq:NN \SetSansFont \setsansfont
\cs_new_eq:NN \SetMonoFont \setmonofont
\cs_new_eq:NN \SetMathFont \setmathfont
\cs_new_eq:NN \AddFontFeatures \addfontfeatures
\cs_new_eq:NN \AddFontFeature \addfontfeatures
%%
%% \CreateFontFeature{substitutions}{feature code}
% Problem: Font has one or more alternate glyphs that you would like to use,
% but they are not listed in a feature set for the font.
% Solution: Create your own feature set, with \CreateFontFeature. The created
% feature may then be used like a real feature, in any font definition.
% The substitutions are a comma-separated list, char=char.alt and so forth.
% For example, the following substitutions are syntactically OK:
% emdash=emdah.alt, one=one.rev, ntilde=ntilde.03
% If a substitution is not available in a particular font, it is ignored.
% You have to look at the font in a font editor, to know what is available.
% It is possible to make silly substitutions, such as a=b, five=three without
% throwing an error, unless your code causes a cycle.
% The most useful application of this command is to reach alternate emdash,
% and alternate oldstyle one. Not every font has these.
% The feature code is a 4-character pseudo- Open Type code, otherwise unused.
% For example, the feature code might be myfs (my fake substitution)
% but it cannot be a pre-defined code such as lnum or smcp. It may be
% a style set such as ss03 if you are sure that the font in question
% do not already have ss03 (but this is taking a chance).
% Once defined, you may use it like this (for example):
% \SetParentFont[RawFeature=+myfs]{fontname}
% \NewFontFamily\myfake[RawFeature=+myfs]{fontname}
% In the document body: {\addfontfeature{myfs} text}
\DeclareDocumentCommand \CreateFontFeature { m m } {%
\IfEndWith{#1}{,}{\StrGobbleRight{#1}{1}[\@fakezero]}{\def\@fakezero{#1}}
\def\@fakeone{"\@fakezero"}
\StrSubstitute{\@fakeone}{=}{"]="}[\@fakeone]
\StrSubstitute{\@fakeone}{,}{",\space["}[\@fakeone]
\directlua{
fonts.handlers.otf.addfeature {
name = "#2",
type = "substitution",
data = {\@fakeone},
}
}
} %% end \CreateFontFeature. Above thanks to fontspec 2016.
%%
\ExplSyntaxOff
%%
%% end definition of parent and other fonts.
%% FRONTMATTER, MAINMATTER. BUT NO BACKMATTER!
%% --------------------------------------------------------------------------
%
\newif \ifWithinFrontmatter \WithinFrontmatterfalse
\newif \ifWithinMainmatter \WithinMainmatterfalse
\newcounter{frontmatterpages}
\newcounter{runningpages}
%
% See novel.cls for the AtBeginShipout routine.
%
\def\frontmatter{ % starts page count and frontmatter count at 1.
\ifWithinFrontmatter
\ClassError{novel}{\string\frontmatter\ used more than once}%
{You issued \string\frontmatter\ more than once.^^J}%
\fi
\ifWithinMainmatter
\ClassError{novel}{\string\frontmatter\ cannot follow \mainmatter}%
{In order: \string\frontmatter\ \string\mainmatter^^J%
but you do not need both of them.^^J}%
\fi
\WithinFrontmattertrue\WithinMainmatterfalse
\clearpage
\pagenumbering{roman}
\setcounter{page}{1}
\setcounter{frontmatterpages}{1}
}
%
\def\mainmatter{ % restarts page to 1, arabic numbers; freeze frontpagecount
\ifWithinMainmatter
\ClassError{novel}{\string\mainmatter\ used more than once}%
{You issued \string\mainmatter\ more than once.}%
\fi
\cleartorecto % added v. 1.40.1
\WithinFrontmatterfalse\WithinMainmattertrue
\setcounter{frontmatterpages}{\value{page}}
\addtocounter{frontmatterpages}{-1}
\pagenumbering{arabic}
\setcounter{page}{1}
}
%
\def\backmatter{\@ifstar\@backmatterst\@backmatterns} % asterisk obsolete from v. 1.40.
\def\@backmatterst{%
\ClassWarning{novel}{Command \string\backmatter*\ ignored. Do not use.^^J}%
}
%
\def\@backmatterns{%
\cleartorecto% v. 1.40.2
\typeout{Class `novel' Alert: \string\backmatter\space merely clears to recto. See docs.^^J}% v. 1.42
%
}
%
\def\Backmatter{\@ifstar\@Backmatterst\@Backmatterns} % obsolete from v. 1.40.
%
\def\@Backmatterst{% continues frontmatter count w/ uppercase Roman numerals
\ClassWarning{novel}{Command \string\Backmatter*\ ignored. Do not use.^^J}%
}
%
\def\@Backmatterns{%
\ClassWarning{novel}{Command \string\Backmatter\ ignored. Do not use.^^J}%
}
%
%% end frontmatter, mainmatter. No backmatter!
%% DISABLE OR NEUTRALIZE SOME STANDARD LATEX COMMANDS
%% --------------------------------------------------------------------------
% The `novel' class disallows these commands, or neutralizes them by simply
% repeating their arguments. In some cases, they request functionality that's
% not implemented in `novel'. In other cases, functionality is part of core,
% but would interfere with the `novel' emphasis on constant line skip.
% You may redefine the commands using your own Preamble code (discouraged).
%
\gdef\null{\hbox{\strut}} % May be important!
%
% Standard LaTeX font sizes are ineffective:
\let\small\relax
\let\footnotesize\relax
\let\scriptsize\relax
\let\tiny\relax
%
\let\large\relax
\let\Large\relax
\let\LARGE\relax
\let\huge\relax
\let\Huge\relax
\let\HUGE\relax
% All these do is echo the argument, if any:
\long\gdef\part#1{#1}
\long\gdef\chapter#1{#1}
\long\gdef\section#1{#1}
\long\gdef\subsection#1{#1}
\long\gdef\subsubsection#1{#1}
\long\gdef\paragraph#1{#1}
\long\gdef\subparagraph#1{#1}
% In some situations, the use will be interrupted:
\gdef\@nodocommand#1{
\ClassError{novel}{No command `\string\#1' in this class}%
{The `\string\#1' command is not implemented in `novel' class.^^J}%
}
% Here is the interruption list:
\long\gdef\maketitle\@nodocommand{maketitle}
\long\gdef\makeindex\@nodocommand{makeindex}
\long\gdef\tableofcontents\@nodocommand{tableofcontents}
\long\gdef\listoftables\@nodocommand{listoftables}
\long\gdef\listoffigures\@nodocommand{listoffigures}
%
%% end disable or neutralize.
%% polyglossia
% Language-specific settings:
\RequirePackage{polyglossia} % loading order changed in v. 1.40.3.
%% end polyglossia
%%
%% End of file `novel-LayoutSettings.sty'.
|