summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/novel/novel.cls
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-03-27 21:21:56 +0000
committerKarl Berry <karl@freefriends.org>2018-03-27 21:21:56 +0000
commit3e4f442d1ed8ac2a1395a7c1485740c3d2f66691 (patch)
tree9bf352dbb78f4536a00e8117fc0792573c3302e8 /Master/texmf-dist/tex/lualatex/novel/novel.cls
parent829f96cd9688f9aac395c58003ead406cdf29125 (diff)
novel (27mar18)
git-svn-id: svn://tug.org/texlive/trunk@47146 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/novel/novel.cls')
-rw-r--r--Master/texmf-dist/tex/lualatex/novel/novel.cls722
1 files changed, 393 insertions, 329 deletions
diff --git a/Master/texmf-dist/tex/lualatex/novel/novel.cls b/Master/texmf-dist/tex/lualatex/novel/novel.cls
index 78bdd95fbc8..23989dc380b 100644
--- a/Master/texmf-dist/tex/lualatex/novel/novel.cls
+++ b/Master/texmf-dist/tex/lualatex/novel/novel.cls
@@ -1,10 +1,6 @@
%%
-%% This is file `novel.cls', part of class `novel'.
-%% Copyright 2017 Robert Allgeyer. Contact: anytthree [at] gmail.com
-%%
-%% Wanted: Replacement maintainer. The original creator wants to move on.
-%% AFAIK this code is tested and suitable for general use.
-%% Contact CTAN (and me) if interested in taking over the maintenance.
+%% This is file `novel.cls', LuaLaTeX `novel' document class.
+%% Copyright 2017-2018 Robert Allgeyer. Contact: anytthree [at] gmail.com
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
@@ -17,9 +13,10 @@
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
% Actually needs LuaLaTeX, at least version 0.95 from TeXLive 2016.
-\ProvidesClass{novel}[2018/01/14 v1.46.2 LaTeX document class]
+\ProvidesClass{novel}[2018/03/28 v1.50 LaTeX document class]
%%
-%% Version 1.46: Possibly final version.
+%% Version 1.50: Improved image handled, sandbox, scripts.
+%% Version 1.46.2: Now called "novel-old" version.
%% Version 1.43: General cleanup of docs and code, for improved readbaility.
%% Version 1.42: Greatly improved HTML documentation.
%% Version 1.41: Improved HTML documentation.
@@ -38,7 +35,7 @@
%% DESCRIPTION:
-%% -----------------------------------------------------------------------------
+%% ----------------------------------------------------------------------------
%% Class `novel' is designed for print fiction: novels or short stories.
%% It cannot be used for e-books or for journal publication.
%% It is not suitable for most non-fiction, because routine academic features
@@ -63,25 +60,28 @@
%% REQUIRE LUATEX and do some preliminary setup.
-%% -----------------------------------------------------------------------------
+%% ----------------------------------------------------------------------------
%% These are not user settings.
%
\RequirePackage{ifluatex} % LuaTeX is required. Not XeTeX, dvips, or pdfTeX.
\RequirePackage{ifxetex} % For occasional hacks (hiss, boo).
-\RequirePackage{luatex85} % Needed for compatibility when using LuaTeX 0.95 etc.
+\RequirePackage{luatex85} % Needed for compatibility with LuaTeX 0.95 etc.
\RequirePackage{pdftexcmds} % compatibility
\ifluatex
% New with TeXlive 2016. Removes unnecessary File Data:
\pdfvariable suppressoptionalinfo 511 % writes only ID to PDF Catalog
\else
- \ClassError{novel}{Must compile with LuaLaTeX 0.95+}{Sorry, LuaLaTeX only.%
- No pdfTeX, dvips, or XeTeX.}
+ \ClassError{novel}{Must compile with LuaLaTeX 0.95+}%
+ {Sorry, LuaLaTeX only. No pdfTeX, dvips, or XeTeX.}
\fi
+\pdfimageresolution=300 % default dpi if image does not say
%
\RequirePackage{etoolbox} % general good stuff
\RequirePackage{xifthen} % improved ifthenelse handling
\RequirePackage{xstring} % parses strings
\RequirePackage{fp} % used everywhere for math calculations
+\RequirePackage{xfp} % more math calculations
+\RequirePackage{keyval} % used by drop cap
\FPmessagesfalse % eliminates numerous friendly messages from the log
%
\pdfminorversion=3 % might be reset later, depending on settings
@@ -90,26 +90,23 @@
\RequirePackage{silence} % Used here:
% hyperref draft mode is always on, even when novel is not in draft mode:
\WarningFilter{hyperref}{Draft mode on} % So, get rid of the hyperref warning.
-% Prevent complaints about no protrusion list for cmr, cmm, etc. in decimal pts:
+% Prevent complaints about no protrusion list for cmr, cmm, etc. in decimal pt:
\WarningFilter{microtype}{I cannot find a protrusion list} % It's not there!
%
\WarningsOff[Fancyhdr,fancyhdr] % complains about headheight when no header
\RequirePackage[relative]{textpos} % for inserting images
-\RequirePackage{noindentafter} % for unindented chapter and scene starts
\RequirePackage{calc} % allows length expression calculations
-\RequirePackage{changepage} % provides block indents, etc. Do not use strict!
-\RequirePackage{atbegshi} % for one-page header changes. Also used by hyperref.
-\RequirePackage{letltxmacro} % for re-defining some macros
-\RequirePackage{magaz} % special treatment of first lines
+\RequirePackage{atbegshi} % in oberdiek bundle. For one-page header changes. Also used by hyperref.
+\RequirePackage{letltxmacro} % in oberdiek bundle. For re-defining some macros
\RequirePackage{xparse} % for writing cool-looking commands
%
-% In addition, the following packages are required, but they are not loaded now.
-% They must wait for something else to happen first. They will be loaded
-% with suitable arguments, when the time comes:
+% In addition, the following packages are required, but not loaded yet.
+% They must wait for something else to happen first. Then they will be loaded
+% with suitable arguments, when the time comes:
% fontspec -- in novel-LayoutSettings.sty
% unicode-math -- in novel-LayoutSettings.sty
% polyglossia -- in novel-LayoutSettings.sty
-% microtype -- in novel-FontDefaults.sty
+% microtype -- in novel-Fonts.sty
% hyperref -- in novel-pdfx.sty
% fancyhdr -- in novel.HeadFootStyles.sty
% xcolor -- lower in this page
@@ -119,11 +116,28 @@
%%
+\newlength\@tempLength % scratch length for local calculations
+\newif \if@tempTF % scratch boolean for local tests
+
+
+%% Global lengths are often passed around in `novel'.
+%% But \setlength is not always global in effect.
+%% This code defines a global command.
+%% Via Heiko Oberdiek at tex.stackexchange.com:
+\gdef\gsetlength#1#2{% #1 is the length command, #2 is the length value
+ \begingroup%
+ \setlength\skip@{#2}% Local assignment to a TeX scratch register.
+ \global#1=\skip@% Global assignment to #1
+ \endgroup% \skip@ is restored by end of group.
+}% end \gsetlength
+%%
+
+
%% Process document class options.
-%% -----------------------------------------------------------------------------
+%% ----------------------------------------------------------------------------
% Allowed option list:
-% draft xml shademargins graytext greytext cropmarks cropview closecrop
-% coverart unblock
+% draft xml shademargins cropmarks cropview closecrop
+% coverart sandbox unblock mtoff polyoff test
% Yes, I realize that this could have been done another way, but I want
% to issue error messages from `novel' rather than (say) `keyval':
\gdef\@mycol{\@classoptionslist}
@@ -132,8 +146,8 @@
\StrDel{\@mycol}{draft}[\@mycol]
\StrDel{\@mycol}{xml}[\@mycol]
\StrDel{\@mycol}{shademargins}[\@mycol]
-\StrDel{\@mycol}{graytext}[\@mycol]
-\StrDel{\@mycol}{greytext}[\@mycol]
+\StrDel{\@mycol}{graytext}[\@mycol] % Obsolete. Now always allows graytext.
+\StrDel{\@mycol}{greytext}[\@mycol] % See above.
\StrDel{\@mycol}{cropmarks}[\@mycol]
\StrDel{\@mycol}{cropview}[\@mycol]
\StrDel{\@mycol}{closecrop}[\@mycol]
@@ -141,65 +155,53 @@
\StrDel{\@mycol}{unblock}[\@mycol]
\StrDel{\@mycol}{mtoff}[\@mycol]
\StrDel{\@mycol}{polyoff}[\@mycol]
+\StrDel{\@mycol}{test}[\@mycol]
+\StrDel{\@mycol}{sandbox}[\@mycol]
%
\ifthenelse{\equal{\@mycol}{}}{}{
- \ClassWarning{novel}{Unrecognized class option: \@mycol^^J%
- The unrecognized option was ignored!^^J%
- If `debug' it is obsolete from v.1.40.^^J%
- Note that font size, document size, and language^^J%
- are not `novel' class options. See documentation.}%
+ \ClassWarning{novel}{^^JUnrecognized class option: \@mycol. ^^J%
+ The unrecognized option was ignored! ^^J%
+ If `debug' it is obsolete from v.1.40. ^^J%
+ Note that font size, document size, and language ^^J%
+ are not `novel' class options. See documentation. ^^J}%
}
-%
% If used, option `draft' shows overflow rule.
-\newif \if@useDraftMode
+% Prior to v. 1.46.1, the following was \if@useDraftMode.
+% Changed for possible compatibility with packages that detect draft mode.
+\newif \ifdraftdoc
\setlength\overfullrule{0pt}
\DeclareOption{draft}{
\setlength\overfullrule{6pt}
- \@useDraftModetrue
- \ClassWarning{novel}{Compiled using draft mode. Not for final release!^^J}
+ \draftdoctrue
+ \ClassWarning{novel}{^^JCompiled with draft mode. Not for final release! ^^J}
}
+\newif \ifmsdoc % manuscript, always false. Compatibility with other packages.
% If used, option `xml' creates a file `\jobname-XMPasXML.xml` that contains
% the XMP metadata with an xml declaration and comments at top.
% Only works when \SetPDFX is not `off'. Note that you do not need to use
% this option to get PDF/X. It is only for your own usage.
\newif \if@wantXMPasXML
-\DeclareOption{xml}{
- \@wantXMPasXMLtrue
-}
+\DeclareOption{xml}{\@wantXMPasXMLtrue}
\DeclareOption{xmp}{ % in case you mis-type.
- \ClassError{novel}{No class option `xmp'. Want `xml' ?^^J}%
- {There is no class option named `xmp'. It is `xml'.^^J}
+ \ClassError{novel}{No class option `xmp'. Use `xml'}%
+ {There is no class option named `xmp'. It is `xml'.}
}
% Option `shademargins' does just that. Ignored unless in draft mode.
-% Does not matter if `graytext' option in use.
\newif \if@shademargins
-\DeclareOption{shademargins}{
- \@shademarginstrue
-}
-% Option `graytext' allows text in grayscale. Images unaffected.
-% If this option is not used, all text will be K black.
-\newif \if@graytext
-\DeclareOption{graytext}{
- \@graytexttrue
-}
-% For the Brits:
-\DeclareOption{greytext}{
- \@graytexttrue
-}
+\DeclareOption{shademargins}{\@shademarginstrue}
+%
+\newif \if@graytext % remains here for backwards compatibility
+\@graytexttrue % from v.1.50 always true, no longer an option.
+%
% Usually you do NOT want crop (trim) marks!
-% Configurable by \SetCropMarks[]{}.
\newif \if@cropmarks
-\DeclareOption{cropmarks}{
- \@cropmarkstrue
-}
+\DeclareOption{cropmarks}{\@cropmarkstrue}
% PDF viewers display CropBox, which normally is identical to MediaBox.
% Option `cropview', sets CropBox to TrimBox instead, so that's all you see.
% Only makes a difference when MediaBox is larger than TrimBox.
% Ignored unless in draft mode.
\newif \if@cropview
-\DeclareOption{cropview}{
- \@cropviewtrue
-}
+\DeclareOption{cropview}{\@cropviewtrue}
% With `closecrop', the TrimSize and margins are re-sized, to preserve the
% live area, but with reduced margins on all sides (same for verso/recto).
% This option is available only in draft mode, and disables shademargins.
@@ -207,53 +209,43 @@
% so you can think about edits while traveling. It is NOT an e-book, since
% it has no hyperlinks and is missing some features that an e-book should have.
\newif \if@closecrop
-\DeclareOption{closecrop}{
- \@cropviewtrue\@closecroptrue
-}
+\DeclareOption{closecrop}{\@cropviewtrue\@closecroptrue}
% New in version 1.2: `coverart' option. See documentation.
% This is used to create a 1-page file with no text, just an image.
% Intended purpose is PDF/X for novel cover.
\newif \if@coverart
-\DeclareOption{coverart}{
- \@coverarttrue
-}
+\DeclareOption{coverart}{\@coverarttrue}
% New in version 1.34: unblock option, for developer use only.
-% Normally, a number of packages known to be incompatible with this document class
+% Normally, a number of packages known to be incompatible with `novel'
% are blocked from loading. If the user tries to get them via \usepackage
% or \RequirePackage, or if they are called within some other loaded package,
% then compile halts with an error. The `unblock' option turns off blocking,
% and allows incompatible packages to load. Use only at own risk!
\newif \if@novelunblock % For developer use.
-\DeclareOption{unblock}{
- \@novelunblocktrue
-}
+\DeclareOption{unblock}{\@novelunblocktrue}
% New in version 1.44: mtoff option, primarily for developer use.
% With mtoff, the microtype package is not loaded.
\newif \if@mtoff
-\DeclareOption{mtoff}{
- \@mtofftrue
-}
+\DeclareOption{mtoff}{\@mtofftrue}
% New in version 1.44: polyoff option, primarily for developer use.
% With polyoff, the polyglossia package is not loaded.
% You may need to load babel, or not, via \RequirePackage[options]{babel}.
\newif \if@polyoff
-\DeclareOption{polyoff}{
- \@polyofftrue
-}
+\DeclareOption{polyoff}{\@polyofftrue}
% New in version 1.46: test option, primarily for developer use.
-% Throws error if Liberintus and Latin Modern Roman fonts are unavailable.
-% Throws error is file novel-testimage.png is not in same folder.
-% Lets \lettrine relax if `lettrine' package not loaded.
\newif \if@testsuite
-\DeclareOption{test}{
- \@testsuitetrue
-}
+\DeclareOption{test}{\@testsuitetrue}
+%
+% New in version 1.50: sandbox option, for artwork and tables. Max 4 pages.
+\newif \if@sandbox
+\DeclareOption{sandbox}{\@sandbox}
+%
%% Note that document size and normal font size are not class options.
%% They are set by commands in the Preamble, and have default values.
%
\ProcessOptions\relax
% Disable some options, depending on compatibilities:
-\if@useDraftMode\else
+\ifdraftdoc\else
\global\@shademarginsfalse
\global\@cropviewfalse
\global\@closecropfalse
@@ -270,64 +262,81 @@
\fi
%
\if@coverart
- \global\@useDraftModefalse
+ \global\draftdocfalse
\global\@shademarginsfalse
\global\@cropviewfalse
\global\@closecropfalse
- \global\@graytextfalse
+ \global\@sandboxfalse
+\fi
+%
+\if@sandbox
+ % Thanks to user Compholio at stackexchange.com:
+ \newcounter{sandboxcount}
+ \ifx\latex@outputpage\@undefined\relax%
+ \global\let\latex@outputpage\@outputpage%
+ \fi%
+ \gdef\@outputpage{%
+ \addtocounter{sandboxcount}{1}%
+ \ifnum\value{sandboxcount}>4\relax% no output after 4 pages
+ \else%
+ \latex@outputpage%
+ \fi%
+ }%
+ \AtEndPreamble{%
+ \gdef\@title{untitled interior artwork}%
+ }%
+ \AfterEndPreamble{%
+ \ifdraftdoc\else\thispagestyle{empty}\fi%
+ }%
\fi
%% end class options
+
+\RequirePackage{noindentafter} % for unindented chapter and scene starts
+\RequirePackage{changepage} % provides block indents, etc. Do not use strict!
+\RequirePackage{magaz} % special treatment of first lines
+
+
%% Activate xcolor, adjustbox, and eso-pic:
-%% -----------------------------------------------------------------------------
-% The final book must be monochrome (black and white only) for all text,
-% unless option `graytext' is used. Then, grayscale text is permitted.
-% Interior images must be raster monochrome or grayscale, whether or not
-% the `graytext' option is used. See documentation.
+%% ----------------------------------------------------------------------------
+% The final book must be black/white and gray only, for all text.
+% Interior images must be raster black/white or grayscale. See documentation.
% Vector graphics are strongly discouraged, in any case.
% In draft mode only, the `shademargins' option requires `grayscale',
% which will be temporarily enabled, even if not specifically requested.
-\newif \if@grayenabled
%
-\if@useDraftMode
- \RequirePackage[gray,hyperref]{xcolor} % allows some layout checks
- \global\@grayenabledtrue
-\else
- \if@graytext
- \RequirePackage[gray,hyperref]{xcolor} % black/white book block
- \global\@grayenabledtrue
- \else
- \RequirePackage[monochrome,hyperref]{xcolor} % black/white book block
- \fi
-\fi
+\RequirePackage[gray,hyperref]{xcolor}
+%
% adjustbox and eso-pic cannot precede xcolor.
\RequirePackage{adjustbox} % for scaling and moving
\RequirePackage{eso-pic} % background effects in draft mode
-%
+\RequirePackage{pdfpages} % only used for pdf pre-processed by novel-scripts
%% end activate xcolor and adjustbox
-%% Temporary normal font size
-%% -----------------------------------------------------------------------------
+%% Temporary normal font size, baselineskip, and fontspec
+%% ----------------------------------------------------------------------------
%% This normalsize is temporary, so that packages can load without complaint.
%% It will be modified later, during layout calculations.
%% Actual default font size will be 11pt-12pt, with 11.4pt average.
-%% But that is for typical book-weight fonts. The closest LMR eqivalent is 10pt.
-\def\Current@FontSizeNum{10}
-\def\Current@BaselineSkipNum{13}
+%% The small temporary size is to ensure that overly-large struts and skips
+%% are not created prior to page layout calculation.
+\gdef\@TentativeEmN{10}
+\gdef\@TentativeBLSkipN{13}
\renewcommand\normalsize{%
- \@setfontsize\normalsize{\Current@FontSizeNum}{\Current@BaselineSkipNum}%
+ \@setfontsize\normalsize{\@TentativeEmN}{\@TentativeBLSkipN}%
}
\normalsize
-%
-\RequirePackage{lipsum} % generates dummy text for examples
-%
-%% end temporary normal point size and baselineskip
+\RequirePackage[no-math]{fontspec} % For LuaLaTeX. NOT package `fontenc'.
+% The `novel' class is not intended for math. But TeX assumes you do math,
+% so it needs a math font, whether you like it or not.
+\RequirePackage{unicode-math}
+%% end temporary normal point size, baselineskip, and fontspec.
%% Define commands used for File Data, including PDF/X Settings.
-%% -----------------------------------------------------------------------------
+%% ----------------------------------------------------------------------------
%% As used here, `File Data' refers to PDF metadata as found in PDF/Info
%% and in XMP. This class does not write it to the PDF Catalog.
\RequirePackage{novel-FileData}
@@ -335,18 +344,39 @@
%% Physical Layout Commands and Settings.
-%% -----------------------------------------------------------------------------
-%% Define user commands that over-ride the class option pre-configured settings.
+%% ----------------------------------------------------------------------------
+%% Define user commands that over-ride class option pre-configured settings.
%% Also sets a variety of miscellaneous lengths:s \parsep, \parindent, etc.
\RequirePackage{novel-LayoutSettings}
-%%
-%% Additional Preamble Settings and Commands.
-%% -----------------------------------------------------------------------------
+%% Polyglossia.
+%% ----------------------------------------------------------------------------
+% Language-specific settings:
+\if@polyoff % polyoff is new in v 1.44.
+ \ClassWarning{novel}{^^JYou chose the `polyoff' class option. ^^J%
+ So, the polyglossia package was not loaded. But like it or not, ^^J%
+ the babel package was loaded, with generic hyphenation. ^^J%
+ This behavior, or choice of language, cannot be changed. ^^J%
+ If you want a specific language, you will have to use polyglossia. ^^J}%
+\else
+ \RequirePackage{polyglossia} % loading order changed in v. 1.40.3.
+ \setdefaultlanguage[variant=american]{english} % may be changed by user
+\fi
+%% end polyglossia
+
+
+%% Additional Macros, Loaded in Preamble.
+%% ----------------------------------------------------------------------------
+\RequirePackage{novel-Fonts} % font settings and defaults
+\if@coverart\else\RequirePackage{lipsum}\fi % generates dummy text for examples
+%% New in version 1.50:
+\RequirePackage{novel-DropCap}
% Macros for use in document body:
\RequirePackage{novel-TextMacros}
% Standard header footer styles, based on `fancyhdr':
+% Each pre-configured style will set these booleans true or false:
+\newif\if@HasHeader \newif\if@HasFooter
\RequirePackage{novel-HeadFootStyles}
% Chapter and Scene styles:
\RequirePackage{novel-ChapterScene}
@@ -354,240 +384,274 @@
\RequirePackage{novel-Images}
% Footnotes and endnotes:
\RequirePackage{novel-Footnotes}
+% Obsolete code. Do not use in new documents:
+\RequirePackage{novel-Obsolete}
+%%
+
+
+%% For convenience, from `article' class.
+%% ----------------------------------------------------------------------------
+\newenvironment{verse}{% Not very useful.
+ \let\\\@centercr
+ \list{}{%
+ \itemsep\z@
+ \itemindent -\parindent%
+ \listparindent\itemindent
+ \rightmargin \leftmargin
+ \advance\leftmargin \parindent%
+ }%
+ \item\relax%
+}{%
+ \endlist%
+}
+%%
+\newenvironment{quotation}{% Not very useful.
+ \list{}{%
+ \listparindent \parindent%
+ \itemindent \listparindent
+ \rightmargin \leftmargin
+ \parsep \z@%
+ }%
+ \item\relax%
+}{%
+ \endlist%
+}
%%
+\newenvironment{quote}{% Not very useful.
+ \list{}{%
+ \rightmargin\leftmargin%
+ }%
+ \item\relax%
+}{%
+ \endlist%
+}
+%
+%% end convenience.
-%% Special features of test suite.
-%% -----------------------------------------------------------------------------
+
+%% Special features of test suite (for developers and error reporting)
+%% ----------------------------------------------------------------------------
+% Files `novel-testsuite.tex' and `novel-testimage.png' are within the novel
+% documentation extras folder. To run the test suite, copy these files to
+% a writeable location (such as your home directory) and compile there.
\newcommand\testsuiteoops[1]{%
\ClassError{novel}{#1 missing}{Install the necessary file(s).}%
}
\if@testsuite
- \IfFontExistsTF{libertinusserif-regular.otf}{}{\testsuiteoops{`libertinus' fonts}}
+ \IfFontExistsTF{libertinusserif-regular.otf}{}{%
+ \testsuiteoops{`libertinus' fonts}%
+ }
\IfFileExists{lmodern.sty}{}{\testsuiteoops{`lmodern' package}}
\IfFileExists{novel-testimage.png}{}{\testsuiteoops{`novel-testimage.png'}}
\NewFontFamily\mustbelibertinus{Libertinus Serif}
\NewFontFamily\mustbelmodern{Latin Modern Roman}
\fi
-\AtBeginDocument{\@ifpackageloaded{lettrine}{}%
- {\DeclareDocumentCommand\lettrine{ O{} m m }{#2#3}}%
-}
%% end special features of test suite.
-%% \AtEndPreamble sets defaults and calculates layout
-%% -----------------------------------------------------------------------------
+%% \AtEndPreamble sets defaults, calculates layout, and writes PDF/X
+%% ----------------------------------------------------------------------------
+% This is prior to \AtBeginDocument, and ensures that the results are available
+% prior to any \AtBeginDocument routines from user macros or loaded packages.
\AtEndPreamble{
- % New in v. 1.44. Sets default resolution for images without internal dpi:
- \pdfimageresolution=\@novimgres % from \SetFlexResolution. Default 300.
- % If user did not choose language, default is here. Sorry, Brits:
- % Macro \xpg@main@language is gdef'd by \setdefaultlanguage in polyglossia.
- \if@polyoff\else % polyoff v 1.44.
- \@ifundefined{xpg@main@language}{\setdefaultlanguage[variant=american]{english}}{}
- \fi
- \RequirePackage{novel-CalculateLayout}
- \RequirePackage{novel-FontDefaults}
- \providecommand\textls[2][]{#2} % when mtoff option
- \renewcommand\textls[2][]{#2} % nullifies this microtype command (problems)
- \RequirePackage{novel-pdfx}%
+ \@ActivateFonts % in `novel-Fonts.sty'
+ \RequirePackage{novel-CalculateLayout} % may load novel-ChangeLayout.sty
+ \RequirePackage{novel-PostLayout} % calculates shademargins, cropmarks, etc.
+ \RequirePackage{novel-pdfx}% also provides an \AtBeginDocument macro
+ \AtEndDocument{%
+ \if@coverart\else%
+ \if@sandbox\else%
+ \cleartoend% adds 1 or 2 blanks, for final verso blank
+ \fi%
+ \fi%
+ }
+}%
+%% end AtEndPreamble
+
+
+%% Messages that may be issued by \AtBeginDocument routines:
+%% ----------------------------------------------------------------------------
+%
+%% Dealing with known incompatible packages:
+\gdef\really@no#1#2#3{ % cannot be used, even with unblock or sandbox
+ \@ifpackageloaded{#1}{%
+ \ClassError{novel}{Sorry, package `#1' cannot be used in `novel' class}%
+ {No exceptions. You are out of luck. ^^J%
+ Reason: `novel' has #2 ^^J%
+ See `novel' HTML documentation, section #3. ^^J%
+ Note: The offending package may have been loaded by another package.}%
+ }{}%
+} %
+%
+%% Command or environment native to LuaLaTeX, but banned except in sandbox:
+\gdef\@OnlySandbox#1{%
+ \ClassError{novel}{Use of `#1' page \thepage\space requires sandbox}%
+ {`novel' class prohibits command or environment `#1' ^^J%
+ unless you use class option `sandbox'. See documentation.}%
}
-%%
+%
+%% Package can be used, but Alert:
+\gdef\alert@nodisp#1{%
+ \@ifpackageloaded{#1}{%
+ \typeout{^^JClass `novel' Alert: Beware of package #1. ^^J%
+ Commands from this package may cause mis-positioning in main text. ^^J%
+ Maybe, maybe not. Best if usage is confined to display pages. ^^J}%
+ }%
+}
+%
+%% Dealing with blocked packages, allowed with `unblock':
+\if@novelunblock
+ \gdef\sorry@no#1{} % no package-specific errors, when unblock
+ \ClassWarning{novel}{Using `unblock' class option, at your own risk. ^^J%
+ The `unblock' option is for developer use, not production documents. ^^J%
+ If the unblocked packages and commands cause problems, ^^J%
+ they are not bugs. Do not report them. You have been warned. ^^J%
+ Perhaps your document will compile without error, and perhaps the ^^J%
+ results are OK. But in other cases, unexpected typesetting results. ^^J}%
+\else % package-specific errors, when no unblock
+ \gdef\sorry@no#1{
+ \@ifpackageloaded{#1}{%
+ \ClassError{novel}{Sorry, package `#1' cannot be used in `novel' class}%
+ {See `novel' HTML documentation, regarding `sandbox' option. ^^J%
+ Note: The offending package may have been loaded by another package.}%
+ }{}%
+ } %
+\fi
+%% end messages.
%% \AtBeginDocument finishes the setup
-%% -----------------------------------------------------------------------------
-\newlength\normalparindent
+%% ----------------------------------------------------------------------------
+%
+\gdef\@needsandboxmsg{%
+ \ClassError{novel}{Need `sandbox' for picture, figure, table environments}%
+ {You cannot use picture, figure, or table environments in `novel' unless ^^J%
+ you use the `sandbox' document class option. See docs.}%
+}
\AtBeginDocument{ %
- \@ifpackageloaded{lettrine}{%
- \LettrineOnGridtrue%
- \setlength\DiscardVskip{10\nbs}% effectively infinite
- \global\DiscardVskip=\DiscardVskip%
- \setlength\DefaultFindent{0.25em}% about one space
- \global\DefaultFindent=\DefaultFindent%
- \setlength\DefaultNindent{0em}% uniform gap
- \global\DefaultNindent=\DefaultNindent%
- \setcounter{DefaultLines}{3}% more likely than 2.
- }{}%
- % Find some useful measurements:
- \setlength\normalparindent{\parindent}
- \global\normalparindent=\parindent
- \gdef\@normalxheight{\heightof{x}}
- \setlength\normalxheight{\@normalxheight}
- \global\normalxheight=\normalxheight
- \gdef\@normalXheight{\heightof{X}}
- \setlength\normalXheight{\@normalXheight}
- \global\normalXheight=\normalXheight
- \gdef\@normalscxheight{\heightof{\textsc{x}}}
- \setlength\normalscxheight{\@normalscxheight}
- \global\normalscxheight=\normalscxheight
- \gdef\@normalAringheight{\heightof{Å}}
- \setlength\normalAringheight{\@normalAringheight}
- \global\normalAringheight=\normalAringheight
- \gdef\@normaldescender{\depthof{gjpqy}}
- \setlength\normaldescender{\@normaldescender}
- \global\normaldescender=\normaldescender
- % Activate user choice of whether or not to indent after scenebreak commands:
- \if@indentAfterScenebreak\else
- \NoIndentAfterCmd{\scenebreak}
- \NoIndentAfterCmd{\sceneline}
- \NoIndentAfterCmd{\scenestars}
- \fi
+ %% Mostly involve settings defaults:
+ \@ActivateTextLengths % in `novel-TextMacros.sty'
+ \@ActivateDropCaps % in `novel-DropCaps.sty'
+ \@ActivateChapterScene % in `novel-ChapterScene.sty'
+ \@ActivateHeadFootStyles % in file `novel-HeadFootStyles.sty'
+ \@ActivatePDFInfo % in file `novel-pdfx.sty'
+ \@ActivateTextMacros % in `novel-TextMacros.sty'
+ \@ActivateFootnotes % in `novel-Footnotes.sty'
+ \@DisableFontSizes % in file `novel-LayoutSettings.sty'
+ \@DisableLayoutSettings % in file `novel-LayoutSettings.sty'
+ \@DisableFileDataSettings % in file `novel-FileData.sty'
+ \@DisableChapterSceneSettings % in file `novel-ChapterScene.sty'
+ \@DisableHeadFootSettings % in file `novel-HeadFootStyles.sty'
+ %% List of always-blocked packages (not exhaustive, since TeX has so many):
+ \really@no{geometry}{its own layout commands.}{4}
+ \really@no{pdfx}{built-in PDF/X capability.}{3.4}
+ \really@no{xmpincl}{built-in PDF/X capability.}{3.4}
+ \really@no{hyperxmp}{built-in PDF/X capability.}{3.4}
+ \really@no{pdfxmult}{built-in PDF/X capability.}{3.4}
+ \really@no{inputenc}{utf-8 encoding always.}{1.2.1}
+ \really@no{fontenc}{`fontspec' and utf-8 encoding always.}{1.2.1, 1.2.3}
+ \really@no{biblatex}{no bibiography capability.}{1.2.5}
+ \really@no{showkeys}{an incompatible layout method.}{1.2.5}
+ \really@no{booktabs}{no capability for this, due to printer specs.}{3.4}
+ \really@no{pax}{no capability for this, due to printer specs.}{3.4}
+ \really@no{bookmark}{focus on paper books, not e-books.}{(top of file)}
+ \really@no{endnotes}{limited, built-in endnote methods.}{6.5}
+ \really@no{acronym}{focus on paper books, not e-books.}{(top of file)}
+ \really@no{embedfile}{incompatible print requirements.}{(top of file)}
%
- \@activateHeadFootStyles % in file `novel-HeadFootStyles.sty'
- \@novelPDFinfo % in file `novel-pdfx.sty'.
- % Commands that cannot be used after Preamble:
- \let\indentAfterScenebreak\relax
- \let\title\relax
- \let\author\relax
- \let\subtitle\relax
- % Dealing with known incompatible packages:
- \if@novelunblock
- \gdef\sorry@no#1{} % let them be used
- \else % block them (default)
- \gdef\sorry@no#1{\@ifpackageloaded{#1}{%
- \ClassError{novel}{Sorry, package `#1' cannot be used}%
- {The `novel' class does not allow use of package `#1'.^^J%
- You must remove it from the Preamble, and also remove its commands^^J%
- from the body of your document. In rare cases, the offending package^^J%
- was loaded by some other package.^^J}%
- }{}%
- }
- \fi
- % List of blocked packages (not exhaustive, since TeX has so many):
- \sorry@no{pdfx}
- \sorry@no{xmpincl}
- \sorry@no{hyperxmp}
- \sorry@no{pdfxmult}
- \sorry@no{inputenc}
- \sorry@no{fontenc}
- \sorry@no{showkeys}
- \sorry@no{wrapfigure}
- \sorry@no{wrapfig}
- \sorry@no{float}
- \sorry@no{morefloats}
- \sorry@no{footmisc}
- \sorry@no{footnote}
- \sorry@no{manyfoot}
- \sorry@no{caption}
- \sorry@no{subcaption}
- \sorry@no{multirow}
- \sorry@no{tabu}
- \sorry@no{tabularx}
- \sorry@no{tabulary}
- \sorry@no{array}
- \sorry@no{booktabs}
- \sorry@no{eqparbox}
- \sorry@no{pdfpages}
- \sorry@no{nth}
- \sorry@no{engord}
- \sorry@no{endnotes}
- %%
- %% Pertains to novel-LayoutSettings.sty:
- \ifcsname pagenumberstyle\endcsname\else
- \SetPageNumberStyle{\thepage}
- \fi
+ \if@sandbox%
+ \RequirePackage{novel-Sandbox}%
+ \fi%
%
- \def\@setchapterstartOK{false}%
- \ifthenelse{\equal{\@setchapterstart}{empty}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstart}{plain}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstart}{footer}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstart}{fancyplain}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstart}{fancy}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstart}{forcenumber}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstart}{dropfolioinside}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstart}{dropfoliobeneath}}{%
- \def\@setchapterstartOK{true}%
- }{}%
- \ifthenelse{\equal{\@setchapterstartOK}{true}}{}{%
- \ClassError{novel}{\string\SetChapterStartStyle\space bad argument}%
- {\string\SetChapterStartStyle\space only allows certain choices.^^J}%
- }%
- %%
- %% Pertains to novel-TextMacros.sty:
- \setlength\forceparlength{\parindent}
- \global\forceparlength=\forceparlength
- \gdef\forceindent{\ifvmode\else\unskip\fi\stake\hspace{\forceparlength}}
- \gdef\backindent{\ifvmode\else\unskip\fi\hspace{-\forceparlength}}
- %%
- %% Pertains to novel-footnotes.sty:
- \gdef\SetFootnoteMarker#1{%
- \typeout{^^JClass `novel' Alert: %
- \string\SetFootnoteMarker\space ineffective after Preamble.^^J}%
- }
- % Must wait for \nbs to be calculated:
- \setlength\footnotesep{0.8\nbs}
- % Must wait for main font and its size to be active:
- \newlength\@hoaring
- \setlength\@hoaring{\heightof{Å}}
- \global\@hoaring=\@hoaring
- \newlength\@twast % tweaks asterisk
- \setlength\@twast{\heightof{*}}
- \addtolength\@twast{-\@hoaring}
- \global\@twast=\@twast
- \newlength\@twdag % tweaks dagger
- \setlength\@twdag{\heightof{†}}
- \addtolength\@twdag{-0.2\@twdag}
- \addtolength\@twdag{-\@hoaring}
- \global\@twdag=\@twdag
- \newlength\@twdbldag % tweaks double dagger
- \setlength\@twdbldag{\heightof{‡}}
- \addtolength\@twdbldag{-0.2\@twdbldag}
- \addtolength\@twdbldag{-\@hoaring}
- \global\@twdbldag=\@twdbldag
- \newlength\@twsect % tweaks section mark
- \setlength\@twsect{\heightof{§}}
- \addtolength\@twsect{-0.2\@twsect}
- \addtolength\@twsect{-\@hoaring}
- \global\@twsect=\@twsect
- \newlength\@tweight % tweaks 8, reliably the tallest digit
- \setlength\@tweight{\heightof{8}}%
- \addtolength\@tweight{-0.2\@tweight}%
- \addtolength\@tweight{-\@hoaring}%
- \global\@tweight=\@tweight%
- % Must wait to see how \SetFootnoteMarker was used:
- \ifthenelse{\equal{\@myfnsymbols}{*}}{\setcounter{@maxfnsymbol}{8}}{}
- \ifthenelse{\equal{\@myfnsymbols}{†}}{\setcounter{@maxfnsymbol}{6}}{}
- %%
-}
-%% end AtBeginDocument
-
-
-%% New in version 1.2, coverart option. See documentation.
-\AfterEndPreamble{
- \if@coverart
- \AddToShipoutPictureBG{%
- \AtPageUpperLeft{%
- \InlineImage{\novelcoverimage}%
- }%
- }
- \null% without this, page has no "content"
+ %% Potential problem packages, allowed in sandbox or with unblock:
+ \if@sandbox\else
+ % Related to floats:
+ \sorry@no{floatflt}
+ \sorry@no{floatfig}
+ \sorry@no{flafter}
+ \sorry@no{float}
+ \sorry@no{morefloats}
+ \sorry@no{endfloat}
+ \sorry@no{placeins}
+ % Related to footnotes and endnotes:
+ \sorry@no{footmisc}
+ \sorry@no{footnote}
+ \sorry@no{manyfoot}
+ % Related to tables:
+ \sorry@no{multirow}
+ \sorry@no{tabu}
+ \sorry@no{tabularx}
+ \sorry@no{tabulary}
+ \sorry@no{longtable}
+ % Related to lists:
+ \sorry@no{array}
+ \sorry@no{easylist}
+ \sorry@no{listings}
+ \sorry@no{numitem}
+ \sorry@no{tasks}
+ % Related to graphics or layout:
+ \sorry@no{pagegrid}
+ \sorry@no{subfig}
+ \sorry@no{lpic}
+ \sorry@no{pinlabel}
+ \sorry@no{overpic}
+ \sorry@no{caption}
+ \sorry@no{sidecap}
+ \sorry@no{subcaption}
+ \sorry@no{paracol}
+ \sorry@no{scrextend}
+ \sorry@no{exsheets}
+ \sorry@no{eqparbox}
+ \sorry@no{colortbl}
+ \sorry@no{tikz}
+ \sorry@no{pstricks}
+ \sorry@no{xypic}
+ \sorry@no{xfig}
+ \sorry@no{pgfcalendar}
+ \sorry@no{pgfpages}
+ \sorry@no{pst-pdf}
+ \sorry@no{auto-pst-pdf}
+ \sorry@no{epstopdf}
+ \sorry@no{pdftricks}
+ \sorry@no{pdftricks2}
+ \sorry@no{mpgraphics}
+ \sorry@no{pict2e}
+ \sorry@no{picman}
+ \sorry@no{scalerel}
+ \sorry@no{pmgraph}
+ \sorry@no{reflectgraphics}
+ \fi % end if sandbox.
+ %
+ %% Commands and environments, only allowed in sandbox:
+ \if@sandbox\else
+ \gdef\mplibcode{\@OnlySandbox{mplibcode}}
\fi
-}
+ %
+ %% Alert packages, might cause minor layout problems, not enough to block:
+ \alert@nodisp{nth}
+ \alert@nodisp{engord}
+ \alert@nodisp{ulem}
+ \alert@nodisp{soul}
+ % end list of Alert packages.
+ %
+ %% Package `pagegrid' interacts with `shademargins' and `draft' options:
+ \@ifpackageloaded{pagegrid}{ % that is, if permitted by sandbox or unblock
+ \ifdraftdoc
+ \if@shademargins
+ \ClassWarning{novel}{^^JGrid from `pagegrid' is concealed. ^^J%
+ Document class option `shademargins' over-writes page grid. ^^J%
+ To see the grid, use `draft' but not `shademargins'. ^^J}
+ \else\fi
+ \else
+ \ClassError{novel}{Package `pagegrid' needs `draft' mode}%
+ {Package `pagegrid' only with document class option `draft'.}%
+ \fi
+ }{} % end if pagegrid
+}% end \AtBeginDocument
%%
-%% AtBeginShipout occurs at the completion of each page layout, in document body.
-\AtBeginShipout{%
- \gdef\@fnafter{}% Pertains to some standard LaTeX footnote code.
- \stepcounter{runningpages}%
- \global\@thispagestylesetfalse%
-}
-%%
-
%%
%% End of file `novel.cls'