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
|
%%
%% This is file `novel-PostLayout.sty', part of `novel' document class.
%% Copyright 2017-2018 Robert Allgeyer.
%%
%% It 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-PostLayout.sty}%
[2018/04/26 v1.52 LaTeX file (post-layout modifications)]
%%
%%
%% This file is loaded \AtEndPreamble, which precedes \AtBeginDocument.
%%
% \@getPageXY is used by `shademargins' and `cropmarks' options.
% The 72.27pt compensates for built-in 1in TeX offsets.
% Position of left edge of TrimBox, rightwards from left edge of MediaBox:
\newlength\Trim@Left
% Position of bottom of TrimBox, upwards from bottom of MediaBox:
\newlength\Trim@Bottom
\gdef\@getPageXY{%
\ifodd\c@page% Adjusts for left-right margin switching, verso/recto,
% and also for horizontal position of TrimBox within MediaBox:
\gsetlength\Trim@Left{\oddsidemargin-\@InnerMargin+72.27pt}%
\else%
\gsetlength\Trim@Left{\evensidemargin-\@OuterMargin+72.27pt}%
\fi%
% Adjusts for vertical position of TrimBox within MediaBox:
\gsetlength\Trim@Bottom{0.5\paperheight-0.5\@TrimHeight+\hoffset}%
}%
%% end \@getPageXY.
%% ACTIVATE CLOSECROP CLASS OPTION
%% ----------------------------------------------------------------------------
% The `closecrop' class option is only effective in draft mode.
% It preserves the text layout, but removes most of the margin white space.
% The resulting file is more easily readable on a hand-held device.
% However, the cropped file is not suitable for distribution as an E-book,
% as it is missing reflow information, marketing metadata, etc.
\if@closecrop
\gsetlength\paperwidth{\textwidth+0.2in}
\if@HasHeader
\gsetlength\topmargin{-1in}
\else
\gsetlength\topmargin{-0.9in}
\fi
\if@HasFooter
\if@HasHeader
\gsetlength\paperheight{%
\textheight+\headsep+\headheight+\@FootJump\baselineskip+1pt%
}
\else
\gsetlength\paperheight{%
\textheight+\headsep+\headheight+\@FootJump\baselineskip+\@SetFontSize%
}
\fi
\else
\gsetlength\paperheight{\textheight+\headsep+\headheight+0.1in}
\fi
\fi
%% end closecrop
%% ACTIVATE SHADEMARGINS CLASS OPTION (Includes Unsafe Zone)
%% ----------------------------------------------------------------------------
%% With class option `shademargins' (only effective in draft mode):
% Based on code by Ulrike Fischer at tex.stackexchange.com, CC-by-sa-3.0:
% 0.542763, 0.883215 and 0.949123 are unlikely user choices.
% The re-defined \color command makes an exception for those values.
\definecolor[named]{hingledingle}{gray}{1} % fake white, when white disallowed
%
\if@shademargins
% Margins are visualized by filling the TrimBox background with gray.
% Then, the rectangle defining the Englosed area is filled with white.
% Then header and/or footer are filled with a lighter gray background.
% Then Unsafe Zone (UZ) sits atop the other background fills, as darker gray.
% The UZ is constructed from four strips, one at each side.
\AddToShipoutPictureBG{% fills trim area with medium gray
\@getPageXY%
\AtPageLowerLeft{\color[gray]{0.883215}%
\hspace{\Trim@Left}%
\rule[\Trim@Bottom]{\@TrimWidth}{\@TrimHeight}%
}%
}%
%
\AddToShipoutPictureBG{% fills enclosed area with white
\@getPageXY%
\AtPageLowerLeft{\color{hingledingle}%
\ifodd\c@page%
\hspace{\dimexpr\oddsidemargin+72.27pt}%
\else%
\hspace{\dimexpr\evensidemargin+72.27pt}%
\fi%
\rule[\dimexpr\Trim@Bottom+\@BottomMargin]%
{\textwidth}{\dimexpr\@TrimHeight-\@TopMargin-\@BottomMargin}
}%
}%
\if@HasHeader% fills header (and its jump) with light gray
\AddToShipoutPictureBG{%
\@getPageXY%
\AtPageLowerLeft{\color[gray]{0.949123}%
\ifodd\c@page%
\hspace{\dimexpr\oddsidemargin+72.27pt}%
\else%
\hspace{\dimexpr\evensidemargin+72.27pt}%
\fi%
\rule[\Trim@Bottom+\@TrimHeight-\@TopMargin-\@HeadJump\nbs]%
{\@TrimWidth-\@OuterMargin-\@InnerMargin}{\@HeadJump\nbs}%
}%
}%
\fi%
%
\if@HasFooter% fills footer (and its jump) with light gray
\AddToShipoutPictureBG{%
\@getPageXY%
\AtPageLowerLeft{\color[gray]{0.949123}%
\ifodd\c@page%
\hspace{\dimexpr\oddsidemargin+72.27pt}%
\else%
\hspace{\dimexpr\evensidemargin+72.27pt}%
\fi%
\rule[\Trim@Bottom+\@BottomMargin]%
{\@TrimWidth-\@OuterMargin-\@InnerMargin}{\@FootJump\nbs}%
}%
}%
\fi%
%
\if@UnsafeZone% fills unsafe zones with dark gray
\AddToShipoutPictureBG{% top unsafe zone
\@getPageXY%
\AtPageLowerLeft{\color[gray]{0.542763}%
\hspace{\Trim@Left}%
\rule[\Trim@Bottom+\@TrimHeight-\@TopUZWidth]%
{\@TrimWidth}{\@TopUZWidth}%
}%
}%
\AddToShipoutPictureBG{% outer unsafe zone
\@getPageXY%
\AtPageLowerLeft{\color[gray]{0.542763}%
\ifodd\c@page%
\hspace{\dimexpr\Trim@Left+\@TrimWidth-\@OuterUZWidth}%
\rule[\Trim@Bottom]{\@OuterUZWidth}{\@TrimHeight}%
\else%
\hspace{\dimexpr\Trim@Left+\@TrimWidth-\@InnerUZWidth}%
\rule[\Trim@Bottom]{\@InnerUZWidth}{\@TrimHeight}%
\fi%
}%
}%
\AddToShipoutPictureBG{% bottom unsafe zone
\@getPageXY%
\AtPageLowerLeft{\color[gray]{0.542763}%
\hspace{\Trim@Left}%
\rule[\Trim@Bottom]{\@TrimWidth}{\@BottomUZWidth}%
}%
}%
\AddToShipoutPictureBG{% inner unsafe zone
\@getPageXY%
\AtPageLowerLeft{\color[gray]{0.542763}%
\hspace{\Trim@Left}%
\ifodd\c@page%
\rule[\Trim@Bottom]{\@InnerUZWidth}{\@TrimHeight}%
\else%
\rule[\Trim@Bottom]{\@OuterUZWidth}{\@TrimHeight}%
\fi%
}%
}%
\fi% end \if@UnsafeZone
%
\fi % end \if@shademargins
%
%% end shademargins and unsafe zone
%% LABEL DRAFT OPTION
%% ----------------------------------------------------------------------------
% Writes DRAFT inside upper left of TrimBox, when in draft mode.
% This macro must go here, in order, so that the label is not over-shaded.
\ifdraftdoc
\AddToShipoutPictureBG{%
\@getPageXY%
\AtPageUpperLeft{%
\raisebox{-\@SetFontSize}{\textbf{~DRAFT}}%
}%
}%
\fi
%% end label draft.
%% ACTIVATE CROPMARKS CLASS OPTION
%% ----------------------------------------------------------------------------
% Cropmarks (trim marks, really) are not important in this document class.
% That's because the targeted printing services generally do not want them.
% But a minimal capability was easy to add. The far end of each mark is
% 0.25in from the trim area. The close end is separated by 0.125in.
% So the length of the marks essentially 1/8in. Width 0.25bp.
% The marks are turned on using `cropmarks' class option.
% When Media Size = Trim Size, cropmarks are disabled.
% Too late for \@cropviewfalse; OK since CropBox already calculated properly.
\ifthenelse{%
\dimtest{\@TrimWidth}{=}{\paperwidth} %
\AND \dimtest{\@TrimHeight}{=}{\paperheight}%
}{\global\@cropmarksfalse}{}
%
\if@cropmarks% Cropmark begins 0.125in from TrimBox, ends 0.25in from TrimBox.
% H top left:
\AddToShipoutPictureBG{\@getPageXY%
\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left-0.25in}%
\rule[0.5\paperheight+0.5\@TrimHeight]{0.25in-0.125in}{0.25bp}}}
% H bottom left:
\AddToShipoutPictureBG{\@getPageXY\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left-0.25in}%
\rule[\Trim@Bottom-0.5pt]{0.25in-0.125in}{0.25bp}}}
% H top right:
\AddToShipoutPictureBG{\@getPageXY\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left+\@TrimWidth+0.125in}%
\rule[0.5\paperheight+0.5\@TrimHeight]{0.25in-0.125in}{0.25bp}}}
% H bottom right:
\AddToShipoutPictureBG{\@getPageXY\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left+\@TrimWidth+0.125in}%
\rule[\Trim@Bottom-0.25bp]{0.25in-0.125in}{0.25bp}}}
% V top left:
\AddToShipoutPictureBG{\@getPageXY\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left-0.25bp}%
\rule[0.5\paperheight+0.5\@TrimHeight+0.125in]%
{0.25bp}{0.25in-0.125in}}}
% V bottom left:
\AddToShipoutPictureBG{\@getPageXY\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left-0.25bp}%
\rule[\Trim@Bottom-0.25in]{0.25bp}{0.25in-0.125in}}}
% V top right:
\AddToShipoutPictureBG{\@getPageXY\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left+\@TrimWidth}%
\rule[0.5\paperheight+0.5\@TrimHeight+0.125in]%
{0.25bp}{0.25in-0.125in}}}
% V bottom right:
\AddToShipoutPictureBG{\@getPageXY\AtPageLowerLeft{%
\hspace{\dimexpr\Trim@Left+\@TrimWidth}%
\rule[\Trim@Bottom-0.25in]{0.25bp}{0.25in-0.125in}}}
\fi
%
%% end cropmarks
%%
\endinput
%%
%% End of file `novel-PostLayout.sty'.
|