summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ntgclass/a4.dtx
blob: e480bfbde994b8cc56f83a61d2edd8f468702f28 (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
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
% \iffalse
%
% Copyright (C) 1994 -- 2020 by Nederlandstalige TeX Gebruikersgroep.
%
% This file is part of the NTG document classes distribution
% ----------------------------------------------------------
%
% 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 2008 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is Johannes Braams.
%
% The list of all files belonging to the NTG document classes
% distribution is given in the file `manifest.txt.
%
% The list of derived (unpacked) files belonging to the distribution
% and covered by LPPL is defined by the unpacking scripts (with
% extension .ins) which are part of the distribution.
%
% \fi
% \CheckSum{153}
%
%\iffalse
%
% We begin by identifying the version of this file on the terminal and
% in the transcript file.
%<*package>
\ifx\ProvidesPackage\undefined
  \def\ProvidesPackage#1[#2 #3 #4]{%
    \wlog{LaTeX Package `#1' #3 <#2> #4}}
\fi
%</package>
%<*dtx>
\ProvidesFile{a4.dtx}
%</dtx>
%<package>\ProvidesPackage{a4}
       [2020/02/18 v1.2g A4 based page layout]
%
% Copying of this file is authorized only if either
% (1) you make absolutely no changes to your copy, including name, or
% (2) if you do make changes, you name it something other than
%     A4.doc or A4.sty.
% This restriction helps ensure that all files developed By NTG WG13
% are identical.
%
% Error reports for UNCHANGED versions please to:
%                          J.L. Braams
%                          texniek at braams.xs4all.nl
%                      or: N.A.F.M. Poppelier
%                          N.Poppelier@elsevier.nl
%
%
%\fi
%
% \GetFileInfo{a4.dtx}
%
% \changes{1.0}{10 Jan 90}{Changed the margins for one-sided printing}
% \changes{1.1}{23 Jan 90}{Added \cs{WideMargins} macros}
% \changes{1.2}{26 Feb 90}{Consolidated setting of
%    \cs{marginparwidth}}
% \changes{1.2a}{30 Nov 90}{replaced \cs{typeout} with \cs{wlog}}
% \changes{1.2b}{1994/02/28}{Update for \LaTeXe}
% \changes{1.2b}{1994/02/28}{Removed some ltugboat remnants}
% \changes{1.2c}{1994/03/15}{Provide package a4 instead of A4}
% \changes{1.2c}{1994/03/15}{Added \cs{ProcessOptions}}
% \changes{1.2c}{1994/03/15}{Moved \cs{wlog} to the \LaTeX2.09 case}
% \changes{1.2c}{1994/03/15}{Moved execution of \cs{ProcessOptions} to
%    end of file}
% \changes{v1.2d}{1995/08/11}{Moved identification part to the top of
%    the file}
% \changes{v1.2g}{2020/02/18}{Updated address info of authors}
%
% \title{A style option to adapt the standard \LaTeX\ document
%        styles to A4 paper\thanks{This file
%        has version number \fileversion --
%        last revision \filedate.}}
%
% \author{Nico Poppelier\\
%          \TeX nique         \\
%          Utrecht\\
%          \texttt{Poppelier@elsevier.nl}\\
%          \and
%          Johannes Braams\\
%          \TeX niek\\
%          Zoetermeer\\
%          \texttt{JLBraams@texniek@braams.xs4all.nl}}
%
% \date{Printed \today}
%
% \maketitle
%
% \begin{abstract}
%   This article describes a new style option that can be used with the
%   document styles that are distributed with the \LaTeX\ distributions.
%   It modifies the page layout to conform to the paper format most
%   commonly used in Europe, portrait A4.
% \end{abstract}
%
% \section{Introduction}
%
%    This file is based on the document style options \file{A4.sty}
%    and \file{A4wide.sty}, which can be found in the Rochester style
%    archive. The original style option \file{A4.sty} we started from
%    was written by John Pavel, and is dated May 1987. This option
%    only changes the vertical size of the text somewhat, by
%    increasing the number of lines on a page. The style option
%    \file{A4wide.sty} was written by Jean-Francois Lamy, and is dated
%    July 1986. This option only increases the width of the text.
%
% \section{Goals and design decisions}
%
%    As many people before us, we found the page layout as implemented
%    in the standard \LaTeX\ document styles too much geared towards
%    the American-sized paper, which is somewhat wider than A4 paper,
%    but also noticeably less high.
%
%    Our goal was to get a page layout that was suitable for A4 paper,
%    and produced legible texts. There are a number of layout
%    parameters that influence the legibility of a text. A parameter
%    of major importance is the number of words (or characters) on a
%    line. The maximum number of words per line is ten to twelve for
%    optimal legibility, a rule-of-thumb that can be found in
%    typographic literature (we used~\cite{treebus}). This results in
%    a number of characters per line which lies somewhere between
%    sixty and seventy.
%
%    Another important parameter is the amount of white space
%    surrounding the text. Here we have to distinguish between texts
%    that are printed one-sided and texts that are printed two-sided
%    (back to back). In the first case the margins on odd and even
%    pages should be equal; in the latter case care should be taken
%    that the texts on both sides of the paper overlap. Also a printed
%    document is likely to be bound some way or another, so there
%    should be enough white space in the `inner' margin\footnote{For
%    two-sided printing, this is the left margin on odd-numbered pages
%    and the right margin on even-numbered ones; for one-sided
%    printing, this is always the left margin.} of the text to allow
%    this.
%
%    There is yet one more thing to take into account when designing a
%    page layout. \LaTeX\ offers the possibility of using marginal
%    notes and if someone wants to use marginal notes, they should of
%    course fit on the paper.
%
%    So, we have the following goals:
%    \begin{enumerate}
%    \item Choose the text width such that there will be sixty to
%    seventy characters on a line;
%    \item See to it that in documents that are printed two-sided, the
%    texts which end up on two sides of one sheet of paper overlap;
%    \item Leave enough white space in the `inner' margin to allow for
%    the binding of the document; 
%    \item Leave enough white space in the `outer' margin for marginal
%    notes if they are going to be used.
% \end{enumerate}
%
% \section{Update for \LaTeXe}
%
%    With the new document classes this package may not be needed much
%    longer, because A4 paper is now supported through the standard
%    option \Lopt{a4paper}. Yet this package additional functionality,
%    not available in the standard document classes. With \LaTeXe, you
%    can now use this package with the command:
% \begin{verbatim}
%     \usepacke[widemargins]{a4}
% \end{verbatim}
%    The option \Lopt{widemargins} executes the |\WideMargins|
%    command. 
%
% \section{The implementation}
%
% \subsection{The starting point}
%
%    Thus we set out to modify some of the design decisions in the
%    standard document styles. Because we knew that we were not the
%    first to tackle the problem, we started by having a look at what
%    was already available. We came up with the two options mentioned
%    earlier, which are publicly available. Undoubtedly there will
%    exist many more such files, some of them maybe modifications of
%    those two files.
%
%    We had a look at the layout produced by both options and were not
%    satisfied with it. For one thing, both of the original options
%    \Lopt{a4} and \Lopt{A4wide} modify only one aspect of the page
%    layout. The first thing to do was to put these two files
%    together. This resulted in a layout which was still
%    unsatisfactory, since for the 10-point and 11-point options lines
%    in the text contained on the average eighty characters or more.
%
% \subsection{What else?}
%
% \DescribeMacro\textwidth
% \DescribeMacro\marginparwidth
%    Because the result so far gave us lines that contained too many
%    characters, we decreased the |\textwidth| to get lines that
%    contain about sixty to seventy characters for all three size
%    options. Still more work had to be done. As it turned out, using
%    our new \file{A4.sty} together with the option |twosided| had a
%    drawback: when the document was printed two-sided the texts on
%    both side of one piece of paper overlapped only partly, which
%    does not look good. We solved this by modifying the width of the
%    margins for two-sided printing. At the same time we modified the
%    |\marginparwidth| so that if someone uses a marginal note it
%    would completely fit on the paper instead of falling off the
%    page, which obviously would render the note unreadable.
%
% \DescribeMacro\WideMargins
% The decisions described above allow for marginal notes to be printed
%    along with the normal text, but if someone makes heavy use of
%    marginal notes, the resultant layout will not be very
%    satisfactory, because if the full width of the marginal notes is
%    used, they will take up too much space in the `outer' margin. For
%    this case we provide the macro |\WideMargins|. This macro
%    modifies the page-layout parameters in such a way that the width
%    reserved for marginal notes becomes 1.5 inches. To achieve this
%    the width of the main body of the text is decreased. This macro
%    is meant to be used only in the preamble of the document.
%
%\StopEventually{
% \section{Conclusion}
%
%    We have presented a new approach to adapt the page layout of the
%    document styles that are part of the standard \LaTeX\
%    distributions to the dimensions of A4 paper. The width of
%    marginal notes has been taken into account and a means to get
%    wider marginal notes at the cost of shorter lines in the main
%    body of the text has been provided.
%
% \begin{thebibliography}{9}
%   \bibitem{treebus} K.F. Treebus.
%   \emph{Tekstwijzer, een gids voor het grafisch verwerken van tekst.}
%   SDU Uitgeverij ('s-Gravenhage, 1988). A Dutch book on layout
%   design and typography.
% \end{thebibliography}
% }
%
%
% \subsection{The \textsc{docstrip} modules}
%
%    The following modules are used in the implementation to direct
%    \textsc{docstrip} in generating the external files:
%    \begin{center}
%      \begin{tabular}{ll}
%        driver   & produce a documentation driver file \\
%        package  & produce a package file \\
%      \end{tabular}
%    \end{center}
%
% \subsection{Producing the documentation}
%
%    A short driver is provided that can be extracted if necessary by
%    the \textsc{docstrip} program provided with \LaTeXe.
%    \begin{macrocode}
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass{ltxdoc}
\DisableCrossrefs

\CodelineIndex

\MakeShortVerb{\|}
\newcommand\Lopt[1]{\textsf{#1}}
\newcommand\file[1]{\texttt{#1}}
\begin{document}

\DocInput{a4.dtx}

\end{document}
%</driver>
%    \end{macrocode}
%
% \subsection{The code}
%
%    Declare the option \Lopt{widemargins}.
%    \begin{macrocode}
%<*package>
\ifx\documentclass\undefined
\else
  \DeclareOption{widemargins}{\WideMargins}
\fi
%    \end{macrocode}
%
% \begin{macro}{\topmargin}

%    First, we redefine the |\textheight| and |\topmargin|. The
%    |\topmargin| is the distance from the reference point on the page
%    to the top of the page of text. In most cases extra white space
%    is not necessary since one inch of white space at the top of the
%    page suffices.
%    \begin{macrocode}
\topmargin 0pt
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\textheight}
%    The dimension parameter |\textheight| gives the total height of
%    the text, including footnotes and figures, excluding the running
%    head and foot. This height is given as an integral number times
%    the |\baselineskip|, which results in an integral number of lines
%    on a page.
%
%    We have to include definitions of all relevant dimension
%    parameters for each of the cases 10-point, 11-point and
%    12-point. We do this with a case statement:
%
%    \begin{macrocode}
\ifcase \@ptsize
    \textheight 53\baselineskip
%    \end{macrocode}
%    which modifies the height of the text for texts to be produced
%    with the ten-point typeface:
%    \begin{macrocode}
\or
    \textheight 46\baselineskip
%    \end{macrocode}
%    the same for eleven point:
%    \begin{macrocode}
\or
    \textheight 42\baselineskip
%    \end{macrocode}
%     and for twelve point. Finally we close the |\ifcase| statement:
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%    The only thing left to be done is to add the |\topskip| to the
%    |\textheight|. The value of |\topskip| appears always to be 10pt.
%
%    \begin{macrocode}
\advance\textheight by \topskip
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\textwidth}
% \begin{macro}{\oddsidemargin}
% \begin{macro}{\evensidemargin}
%    That was the `vertical part' of the work. Now we have some work
%    to do to get things right horizontally. Again we have to
%    distinguish between the various character sizes because sixty
%    eleven-point characters take up more space than sixty ten-point
%    characters. But there's more to take into account. If documents
%    are printed two-sided, the texts on both sides of the paper
%    should overlap completely. This can be done be assigning
%    appropriate values to |\oddsidemargin| and |\evensidemargin|, the
%    parameters that define the left margins on odd and even pages
%    respectively.
%
%    First we start a case statement to distinguish between the
%    various typeface sizes.
%    \begin{macrocode}
\ifcase \@ptsize
%    \end{macrocode}
%    Then we specify the width of the text.
%    \begin{macrocode}
    \textwidth      5.00in
%    \end{macrocode}
%    Also specify the width of marginal notes. They must have a
%    reasonable width to be of any use, and this should be the same
%    for either one-sided or two-sided printing.
%    \begin{macrocode}
    \marginparwidth 1.00in
%    \end{macrocode}
%    Here we need an if statement to test whether the option
%    |twosided| has been specified.
%    \begin{macrocode}
  \if@twoside
%    \end{macrocode}
%    If it was, assign appropriate values to the margin parameters
%    \begin{macrocode}
    \oddsidemargin  0.55in
    \evensidemargin 0.75in
  \else
%    \end{macrocode}
%    If the option |twosided| was not used, both margin parameters
%    must have the same value, for texts on consecutive pages have to
%    be put in the same place on the paper.
%    \begin{macrocode}
    \oddsidemargin  0.55in
    \evensidemargin 0.55in
%    \end{macrocode}
%    Now we close the if statement.
%    \begin{macrocode}
  \fi
%    \end{macrocode}
%    We are ready with the modifications for the ten-point typeface
%    size, so now we do something similar for the eleven-point
%    typeface.
%    \begin{macrocode}
\or
    \textwidth      5.20in
    \marginparwidth 1.00in
  \if@twoside
    \oddsidemargin  0.45in
    \evensidemargin 0.65in
  \else
    \oddsidemargin  0.45in
    \evensidemargin 0.45in
  \fi
%    \end{macrocode}
%    One more time, now for the twelve-point typeface.
%    \begin{macrocode}
\or
    \textwidth      5.70in
    \marginparwidth 0.80in
  \if@twoside
    \oddsidemargin  0.20in
    \evensidemargin 0.40in
  \else
    \oddsidemargin  0.20in
    \evensidemargin 0.20in
  \fi
%    \end{macrocode}
%    Finally we close the case statement.
%    \begin{macrocode}
\fi
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\WideMargins}
%    This macro is somewhat tricky: it has to find out
%    which typeface size is used, whether the document should be printed
%    two-sided, and whether the |\reversemarginpar| is in effect.
%    |\reversemarginpar| makes the marginal notes appear in the
%    margin on the opposite side of the normal placement.
%    \begin{macrocode}
\def\WideMargins{%
%    \end{macrocode}
% \noindent
%    Because for each typeface size the changes to the parameters that
%    need to be made are similar, the macro |\WideMargins|
%    uses an internal macro |\@widemargins|.
%
% \begin{macro}{\ExtraWidth}
%    In order to store the amount of extra width needed for the marginal
%    notes an extra dimension parameter is defined.
%
%    \begin{macrocode}
  \newdimen\ExtraWidth
%    \end{macrocode}
% \end{macro}
%
% \noindent
%    First find out about the point size, then call |\@widemargins| to
%    modify the margin widths by the amount given in |\ExtraWidth|.
%    \begin{macrocode}
  \ifcase \@ptsize
%    \end{macrocode}
%
% \noindent
%    For both 10-point and 11-point texts the width for marginal notes is
%    already 1 inch, so we increase it by half an inch. We subtract half an
%    inch from the text width and modify the margins appropriately.
%
%    \begin{macrocode}
    \ExtraWidth = 0.5in
    \@widemargins
  \or
    \ExtraWidth = 0.5in
    \@widemargins
  \or
%    \end{macrocode}
%
% \noindent
%    For 12-point texts the marginal notes are only 0.8 inch wide, so
%    now we have to add 0.7 inch to get them 1.5 inch wide.
%
%    \begin{macrocode}
    \ExtraWidth = 0.7in
    \@widemargins
%    \end{macrocode}
%
% \noindent
%    This macro should only be called once, during the preamble of a
%    document, so we |\let| it be equal to |\relax| as soon
%    as the work is done.
%    \begin{macrocode}
  \fi\let\WideMargins\relax\let\@widemargins\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@preamblecmds}
%    We add |\WideMargins| to |\@preamblecmds|, which is a
%    list of commands to be used only in the preamble of a document.
%
%    \begin{macrocode}
{\def\do{\noexpand\do\noexpand}
 \xdef\@preamblecmds{\@preamblecmds \do\WideMargins}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@widemargins}
%    This macro modifies the margin parameters. To do this it uses
%    the dimension variable |\ExtraWidth|, which was defined by
%    |\WideMargins|.
%
% \noindent
%    First the |\ExtraWidth| is subtracted from the |\textwidth|
%    and added to the |\marginparwidth|.
%    \begin{macrocode}
\def\@widemargins{%
    \global\advance\textwidth by -\ExtraWidth
    \global\advance\marginparwidth by \ExtraWidth
%    \end{macrocode}
%
% \noindent
%    Then we modify the margins, but the value of the switch
%    |\if@twoside| has to be taken into account. Because
%    we have to test another switch (|\if@reversemargin|)
%    we add another level of macros to modify the margin parameters%
%
%    \begin{macrocode}
    \if@twoside
      \tw@sidedwidemargins
    \else
      \@nesidedwidemargins
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tw@sidedwidemargins}
%    Normally the marginal notes are printed in the `outer' margins, so
%    we have to increase the |\evensidemargin| to keep the text
%    balanced on both sides of the paper, but if |\reversemarginpar|
%    is in effect we have to increase the |\oddsidemargin| and
%    decrease the |\evensidemargin| accordingly.
%
%    \begin{macrocode}
\def\tw@sidedwidemargins{%
    \if@reversemargin
%    \end{macrocode}
%
% \noindent
%    Notice that for documents printed two-sided, the
%    |\evensidemargin| is wider than the |\oddsidemargin|;
%    this difference in width is transferred to the other margin.
%
%    \begin{macrocode}
      \@tempdima=\evensidemargin
      \advance\@tempdima by -\oddsidemargin
      \advance\oddsidemargin by \ExtraWidth
      \advance\oddsidemargin by \@tempdima
      \advance\evensidemargin by -\@tempdima
    \else
%    \end{macrocode}
%
% \noindent
%    If the marginal notes go on the normal side of the paper, only the
%    |\evensidemargin| has to be increased.
%
%    \begin{macrocode}
      \advance\evensidemargin by \ExtraWidth
    \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@nesidedwidemargins}
%    For documents that are printed one-sided, both margins have the same
%    width. The default placement for the marginal notes is in the right
%    margin, so if |\reversemarginpar| is \emph{not} in effect the
%    margin parameters need not be modified. If it is in effect, both the
%    |\oddsidemargin| and the |\evensidemargin| need to be
%    increased.
%
%    \begin{macrocode}
\def\@nesidedwidemargins{%
    \if@reversemargin
      \advance\oddsidemargin by \ExtraWidth
      \advance\evensidemargin by \ExtraWidth
    \fi}
%    \end{macrocode}
%    \end{macro}
%
%    The command |\ProcessOptions| can only be executed \emph{after}
%    |\WideMargins| has been defined. Defering the execution of
%    |\WideMargins| with |\AtBeginDocument| doesn't work, the changing
%    of |\textwidth| then comes too late because of the time when the
%    |\@begindocumenthook| gets executed by |\begin{document|.
%    \begin{macrocode}
\ifx\documentclass\undefined
\else
  \ProcessOptions
\fi
%</package>
%    \end{macrocode}
%
% \Finale
%
\endinput