Debian Codegraph @

texmf-dist/source/latex/ntgclass/a4.dtx

raw
1 % \iffalse
2 %
3 % Copyright (C) 1994 -- 2026 by Nederlandstalige TeX Gebruikersgroep.
4 %
5 % This file is part of the NTG document classes distribution
6 % ----------------------------------------------------------
7 %
8 % It may be distributed and/or modified under the
9 % conditions of the LaTeX Project Public License, either version 1.3c
10 % of this license or (at your option) any later version.
11 % The latest version of this license is in
12 % http://www.latex-project.org/lppl.txt
13 % and version 1.3c or later is part of all distributions of LaTeX
14 % version 2008 or later.
15 %
16 % This work has the LPPL maintenance status "maintained".
17 %
18 % The Current Maintainer of this work is Johannes Braams.
19 %
20 % The list of all files belonging to the NTG document classes
21 % distribution is given in the file `manifest.txt.
22 %
23 % The list of derived (unpacked) files belonging to the distribution
24 % and covered by LPPL is defined by the unpacking scripts (with
25 % extension .ins) which are part of the distribution.
26 %
27 % \fi
28 % \CheckSum{153}
29 %
30 %\iffalse
31 %
32 % We begin by identifying the version of this file on the terminal and
33 % in the transcript file.
34 %<*package>
35 \ifx\ProvidesPackage\undefined
36 \def\ProvidesPackage#1[#2 #3 #4]{%
37 \wlog{LaTeX Package `#1' #3 <#2> #4}}
38 \fi
39 %</package>
40 %<*dtx>
41 \ProvidesFile{a4.dtx}
42 %</dtx>
43 %<package>\ProvidesPackage{a4}
44 [2025/12/29 v1.2g A4 based page layout]
45 %
46 % Copying of this file is authorized only if either
47 % (1) you make absolutely no changes to your copy, including name, or
48 % (2) if you do make changes, you name it something other than
49 % A4.doc or A4.sty.
50 % This restriction helps ensure that all files developed By NTG WG13
51 % are identical.
52 %
53 % Error reports for UNCHANGED versions please to:
54 % J.L. Braams
55 % texniek at texniek.nl
56 % or: N.A.F.M. Poppelier
57 %
58 %\fi
59 %
60 % \GetFileInfo{a4.dtx}
61 %
62 % \changes{1.0}{10 Jan 90}{Changed the margins for one-sided printing}
63 % \changes{1.1}{23 Jan 90}{Added \cs{WideMargins} macros}
64 % \changes{1.2}{26 Feb 90}{Consolidated setting of
65 % \cs{marginparwidth}}
66 % \changes{1.2a}{30 Nov 90}{replaced \cs{typeout} with \cs{wlog}}
67 % \changes{1.2b}{1994/02/28}{Update for \LaTeXe}
68 % \changes{1.2b}{1994/02/28}{Removed some ltugboat remnants}
69 % \changes{1.2c}{1994/03/15}{Provide package a4 instead of A4}
70 % \changes{1.2c}{1994/03/15}{Added \cs{ProcessOptions}}
71 % \changes{1.2c}{1994/03/15}{Moved \cs{wlog} to the \LaTeX2.09 case}
72 % \changes{1.2c}{1994/03/15}{Moved execution of \cs{ProcessOptions} to
73 % end of file}
74 % \changes{v1.2d}{1995/08/11}{Moved identification part to the top of
75 % the file}
76 % \changes{v1.2g}{2020/02/18}{Updated address info of authors}
77 %
78 % \title{A style option to adapt the standard \LaTeX\ document
79 % styles to A4 paper\thanks{This file
80 % has version number \fileversion --
81 % last revision \filedate.}}
82 %
83 % \author{Nico Poppelier\\
84 % \TeX nique \\
85 % Utrecht\\
86 % \and
87 % Johannes Braams\\
88 % \TeX niek\\
89 % Zoetermeer\\
90 % \texttt{[email protected]}}
91 %
92 % \date{Printed \today}
93 %
94 % \maketitle
95 %
96 % \begin{abstract}
97 % This article describes a new style option that can be used with the
98 % document styles that are distributed with the \LaTeX\ distributions.
99 % It modifies the page layout to conform to the paper format most
100 % commonly used in Europe, portrait A4.
101 % \end{abstract}
102 %
103 % \section{Introduction}
104 %
105 % This file is based on the document style options \file{A4.sty}
106 % and \file{A4wide.sty}, which can be found in the Rochester style
107 % archive. The original style option \file{A4.sty} we started from
108 % was written by John Pavel, and is dated May 1987. This option
109 % only changes the vertical size of the text somewhat, by
110 % increasing the number of lines on a page. The style option
111 % \file{A4wide.sty} was written by Jean-Francois Lamy, and is dated
112 % July 1986. This option only increases the width of the text.
113 %
114 % \section{Goals and design decisions}
115 %
116 % As many people before us, we found the page layout as implemented
117 % in the standard \LaTeX\ document styles too much geared towards
118 % the American-sized paper, which is somewhat wider than A4 paper,
119 % but also noticeably less high.
120 %
121 % Our goal was to get a page layout that was suitable for A4 paper,
122 % and produced legible texts. There are a number of layout
123 % parameters that influence the legibility of a text. A parameter
124 % of major importance is the number of words (or characters) on a
125 % line. The maximum number of words per line is ten to twelve for
126 % optimal legibility, a rule-of-thumb that can be found in
127 % typographic literature (we used~\cite{treebus}). This results in
128 % a number of characters per line which lies somewhere between
129 % sixty and seventy.
130 %
131 % Another important parameter is the amount of white space
132 % surrounding the text. Here we have to distinguish between texts
133 % that are printed one-sided and texts that are printed two-sided
134 % (back to back). In the first case the margins on odd and even
135 % pages should be equal; in the latter case care should be taken
136 % that the texts on both sides of the paper overlap. Also a printed
137 % document is likely to be bound some way or another, so there
138 % should be enough white space in the `inner' margin\footnote{For
139 % two-sided printing, this is the left margin on odd-numbered pages
140 % and the right margin on even-numbered ones; for one-sided
141 % printing, this is always the left margin.} of the text to allow
142 % this.
143 %
144 % There is yet one more thing to take into account when designing a
145 % page layout. \LaTeX\ offers the possibility of using marginal
146 % notes and if someone wants to use marginal notes, they should of
147 % course fit on the paper.
148 %
149 % So, we have the following goals:
150 % \begin{enumerate}
151 % \item Choose the text width such that there will be sixty to
152 % seventy characters on a line;
153 % \item See to it that in documents that are printed two-sided, the
154 % texts which end up on two sides of one sheet of paper overlap;
155 % \item Leave enough white space in the `inner' margin to allow for
156 % the binding of the document;
157 % \item Leave enough white space in the `outer' margin for marginal
158 % notes if they are going to be used.
159 % \end{enumerate}
160 %
161 % \section{Update for \LaTeXe}
162 %
163 % With the new document classes this package may not be needed much
164 % longer, because A4 paper is now supported through the standard
165 % option \Lopt{a4paper}. Yet this package additional functionality,
166 % not available in the standard document classes. With \LaTeXe, you
167 % can now use this package with the command:
168 % \begin{verbatim}
169 % \usepacke[widemargins]{a4}
170 % \end{verbatim}
171 % The option \Lopt{widemargins} executes the |\WideMargins|
172 % command.
173 %
174 % \section{The implementation}
175 %
176 % \subsection{The starting point}
177 %
178 % Thus we set out to modify some of the design decisions in the
179 % standard document styles. Because we knew that we were not the
180 % first to tackle the problem, we started by having a look at what
181 % was already available. We came up with the two options mentioned
182 % earlier, which are publicly available. Undoubtedly there will
183 % exist many more such files, some of them maybe modifications of
184 % those two files.
185 %
186 % We had a look at the layout produced by both options and were not
187 % satisfied with it. For one thing, both of the original options
188 % \Lopt{a4} and \Lopt{A4wide} modify only one aspect of the page
189 % layout. The first thing to do was to put these two files
190 % together. This resulted in a layout which was still
191 % unsatisfactory, since for the 10-point and 11-point options lines
192 % in the text contained on the average eighty characters or more.
193 %
194 % \subsection{What else?}
195 %
196 % \DescribeMacro\textwidth
197 % \DescribeMacro\marginparwidth
198 % Because the result so far gave us lines that contained too many
199 % characters, we decreased the |\textwidth| to get lines that
200 % contain about sixty to seventy characters for all three size
201 % options. Still more work had to be done. As it turned out, using
202 % our new \file{A4.sty} together with the option |twosided| had a
203 % drawback: when the document was printed two-sided the texts on
204 % both side of one piece of paper overlapped only partly, which
205 % does not look good. We solved this by modifying the width of the
206 % margins for two-sided printing. At the same time we modified the
207 % |\marginparwidth| so that if someone uses a marginal note it
208 % would completely fit on the paper instead of falling off the
209 % page, which obviously would render the note unreadable.
210 %
211 % \DescribeMacro\WideMargins
212 % The decisions described above allow for marginal notes to be printed
213 % along with the normal text, but if someone makes heavy use of
214 % marginal notes, the resultant layout will not be very
215 % satisfactory, because if the full width of the marginal notes is
216 % used, they will take up too much space in the `outer' margin. For
217 % this case we provide the macro |\WideMargins|. This macro
218 % modifies the page-layout parameters in such a way that the width
219 % reserved for marginal notes becomes 1.5 inches. To achieve this
220 % the width of the main body of the text is decreased. This macro
221 % is meant to be used only in the preamble of the document.
222 %
223 %\StopEventually{
224 % \section{Conclusion}
225 %
226 % We have presented a new approach to adapt the page layout of the
227 % document styles that are part of the standard \LaTeX\
228 % distributions to the dimensions of A4 paper. The width of
229 % marginal notes has been taken into account and a means to get
230 % wider marginal notes at the cost of shorter lines in the main
231 % body of the text has been provided.
232 %
233 % \begin{thebibliography}{9}
234 % \bibitem{treebus} K.F. Treebus.
235 % \emph{Tekstwijzer, een gids voor het grafisch verwerken van tekst.}
236 % SDU Uitgeverij ('s-Gravenhage, 1988). A Dutch book on layout
237 % design and typography.
238 % \end{thebibliography}
239 % }
240 %
241 %
242 % \subsection{The \textsc{docstrip} modules}
243 %
244 % The following modules are used in the implementation to direct
245 % \textsc{docstrip} in generating the external files:
246 % \begin{center}
247 % \begin{tabular}{ll}
248 % driver & produce a documentation driver file \\
249 % package & produce a package file \\
250 % \end{tabular}
251 % \end{center}
252 %
253 % \subsection{Producing the documentation}
254 %
255 % A short driver is provided that can be extracted if necessary by
256 % the \textsc{docstrip} program provided with \LaTeXe.
257 % \begin{macrocode}
258 %<*driver>
259 \NeedsTeXFormat{LaTeX2e}
260 \documentclass{ltxdoc}
261 \DisableCrossrefs
262
263 \CodelineIndex
264
265 \MakeShortVerb{\|}
266 \newcommand\Lopt[1]{\textsf{#1}}
267 \newcommand\file[1]{\texttt{#1}}
268 \begin{document}
269
270 \DocInput{a4.dtx}
271
272 \end{document}
273 %</driver>
274 % \end{macrocode}
275 %
276 % \subsection{The code}
277 %
278 % Declare the option \Lopt{widemargins}.
279 % \begin{macrocode}
280 %<*package>
281 \ifx\documentclass\undefined
282 \else
283 \DeclareOption{widemargins}{\WideMargins}
284 \fi
285 % \end{macrocode}
286 %
287 % \begin{macro}{\topmargin}
288
289 % First, we redefine the |\textheight| and |\topmargin|. The
290 % |\topmargin| is the distance from the reference point on the page
291 % to the top of the page of text. In most cases extra white space
292 % is not necessary since one inch of white space at the top of the
293 % page suffices.
294 % \begin{macrocode}
295 \topmargin 0pt
296 % \end{macrocode}
297 % \end{macro}
298 %
299 % \begin{macro}{\textheight}
300 % The dimension parameter |\textheight| gives the total height of
301 % the text, including footnotes and figures, excluding the running
302 % head and foot. This height is given as an integral number times
303 % the |\baselineskip|, which results in an integral number of lines
304 % on a page.
305 %
306 % We have to include definitions of all relevant dimension
307 % parameters for each of the cases 10-point, 11-point and
308 % 12-point. We do this with a case statement:
309 %
310 % \begin{macrocode}
311 \ifcase \@ptsize
312 \textheight 53\baselineskip
313 % \end{macrocode}
314 % which modifies the height of the text for texts to be produced
315 % with the ten-point typeface:
316 % \begin{macrocode}
317 \or
318 \textheight 46\baselineskip
319 % \end{macrocode}
320 % the same for eleven point:
321 % \begin{macrocode}
322 \or
323 \textheight 42\baselineskip
324 % \end{macrocode}
325 % and for twelve point. Finally we close the |\ifcase| statement:
326 % \begin{macrocode}
327 \fi
328 % \end{macrocode}
329 %
330 % The only thing left to be done is to add the |\topskip| to the
331 % |\textheight|. The value of |\topskip| appears always to be 10pt.
332 %
333 % \begin{macrocode}
334 \advance\textheight by \topskip
335 % \end{macrocode}
336 % \end{macro}
337 %
338 % \begin{macro}{\textwidth}
339 % \begin{macro}{\oddsidemargin}
340 % \begin{macro}{\evensidemargin}
341 % That was the `vertical part' of the work. Now we have some work
342 % to do to get things right horizontally. Again we have to
343 % distinguish between the various character sizes because sixty
344 % eleven-point characters take up more space than sixty ten-point
345 % characters. But there's more to take into account. If documents
346 % are printed two-sided, the texts on both sides of the paper
347 % should overlap completely. This can be done be assigning
348 % appropriate values to |\oddsidemargin| and |\evensidemargin|, the
349 % parameters that define the left margins on odd and even pages
350 % respectively.
351 %
352 % First we start a case statement to distinguish between the
353 % various typeface sizes.
354 % \begin{macrocode}
355 \ifcase \@ptsize
356 % \end{macrocode}
357 % Then we specify the width of the text.
358 % \begin{macrocode}
359 \textwidth 5.00in
360 % \end{macrocode}
361 % Also specify the width of marginal notes. They must have a
362 % reasonable width to be of any use, and this should be the same
363 % for either one-sided or two-sided printing.
364 % \begin{macrocode}
365 \marginparwidth 1.00in
366 % \end{macrocode}
367 % Here we need an if statement to test whether the option
368 % |twosided| has been specified.
369 % \begin{macrocode}
370 \if@twoside
371 % \end{macrocode}
372 % If it was, assign appropriate values to the margin parameters
373 % \begin{macrocode}
374 \oddsidemargin 0.55in
375 \evensidemargin 0.75in
376 \else
377 % \end{macrocode}
378 % If the option |twosided| was not used, both margin parameters
379 % must have the same value, for texts on consecutive pages have to
380 % be put in the same place on the paper.
381 % \begin{macrocode}
382 \oddsidemargin 0.55in
383 \evensidemargin 0.55in
384 % \end{macrocode}
385 % Now we close the if statement.
386 % \begin{macrocode}
387 \fi
388 % \end{macrocode}
389 % We are ready with the modifications for the ten-point typeface
390 % size, so now we do something similar for the eleven-point
391 % typeface.
392 % \begin{macrocode}
393 \or
394 \textwidth 5.20in
395 \marginparwidth 1.00in
396 \if@twoside
397 \oddsidemargin 0.45in
398 \evensidemargin 0.65in
399 \else
400 \oddsidemargin 0.45in
401 \evensidemargin 0.45in
402 \fi
403 % \end{macrocode}
404 % One more time, now for the twelve-point typeface.
405 % \begin{macrocode}
406 \or
407 \textwidth 5.70in
408 \marginparwidth 0.80in
409 \if@twoside
410 \oddsidemargin 0.20in
411 \evensidemargin 0.40in
412 \else
413 \oddsidemargin 0.20in
414 \evensidemargin 0.20in
415 \fi
416 % \end{macrocode}
417 % Finally we close the case statement.
418 % \begin{macrocode}
419 \fi
420 % \end{macrocode}
421 % \end{macro}
422 % \end{macro}
423 % \end{macro}
424 %
425 % \begin{macro}{\WideMargins}
426 % This macro is somewhat tricky: it has to find out
427 % which typeface size is used, whether the document should be printed
428 % two-sided, and whether the |\reversemarginpar| is in effect.
429 % |\reversemarginpar| makes the marginal notes appear in the
430 % margin on the opposite side of the normal placement.
431 % \begin{macrocode}
432 \def\WideMargins{%
433 % \end{macrocode}
434 % \noindent
435 % Because for each typeface size the changes to the parameters that
436 % need to be made are similar, the macro |\WideMargins|
437 % uses an internal macro |\@widemargins|.
438 %
439 % \begin{macro}{\ExtraWidth}
440 % In order to store the amount of extra width needed for the marginal
441 % notes an extra dimension parameter is defined.
442 %
443 % \begin{macrocode}
444 \newdimen\ExtraWidth
445 % \end{macrocode}
446 % \end{macro}
447 %
448 % \noindent
449 % First find out about the point size, then call |\@widemargins| to
450 % modify the margin widths by the amount given in |\ExtraWidth|.
451 % \begin{macrocode}
452 \ifcase \@ptsize
453 % \end{macrocode}
454 %
455 % \noindent
456 % For both 10-point and 11-point texts the width for marginal notes is
457 % already 1 inch, so we increase it by half an inch. We subtract half an
458 % inch from the text width and modify the margins appropriately.
459 %
460 % \begin{macrocode}
461 \ExtraWidth = 0.5in
462 \@widemargins
463 \or
464 \ExtraWidth = 0.5in
465 \@widemargins
466 \or
467 % \end{macrocode}
468 %
469 % \noindent
470 % For 12-point texts the marginal notes are only 0.8 inch wide, so
471 % now we have to add 0.7 inch to get them 1.5 inch wide.
472 %
473 % \begin{macrocode}
474 \ExtraWidth = 0.7in
475 \@widemargins
476 % \end{macrocode}
477 %
478 % \noindent
479 % This macro should only be called once, during the preamble of a
480 % document, so we |\let| it be equal to |\relax| as soon
481 % as the work is done.
482 % \begin{macrocode}
483 \fi\let\WideMargins\relax\let\@widemargins\relax}
484 % \end{macrocode}
485 % \end{macro}
486 %
487 % \begin{macro}{\@preamblecmds}
488 % We add |\WideMargins| to |\@preamblecmds|, which is a
489 % list of commands to be used only in the preamble of a document.
490 %
491 % \begin{macrocode}
492 {\def\do{\noexpand\do\noexpand}
493 \xdef\@preamblecmds{\@preamblecmds \do\WideMargins}
494 }
495 % \end{macrocode}
496 % \end{macro}
497 %
498 % \begin{macro}{\@widemargins}
499 % This macro modifies the margin parameters. To do this it uses
500 % the dimension variable |\ExtraWidth|, which was defined by
501 % |\WideMargins|.
502 %
503 % \noindent
504 % First the |\ExtraWidth| is subtracted from the |\textwidth|
505 % and added to the |\marginparwidth|.
506 % \begin{macrocode}
507 \def\@widemargins{%
508 \global\advance\textwidth by -\ExtraWidth
509 \global\advance\marginparwidth by \ExtraWidth
510 % \end{macrocode}
511 %
512 % \noindent
513 % Then we modify the margins, but the value of the switch
514 % |\if@twoside| has to be taken into account. Because
515 % we have to test another switch (|\if@reversemargin|)
516 % we add another level of macros to modify the margin parameters%
517 %
518 % \begin{macrocode}
519 \if@twoside
520 \tw@sidedwidemargins
521 \else
522 \@nesidedwidemargins
523 \fi}
524 % \end{macrocode}
525 % \end{macro}
526 %
527 % \begin{macro}{\tw@sidedwidemargins}
528 % Normally the marginal notes are printed in the `outer' margins, so
529 % we have to increase the |\evensidemargin| to keep the text
530 % balanced on both sides of the paper, but if |\reversemarginpar|
531 % is in effect we have to increase the |\oddsidemargin| and
532 % decrease the |\evensidemargin| accordingly.
533 %
534 % \begin{macrocode}
535 \def\tw@sidedwidemargins{%
536 \if@reversemargin
537 % \end{macrocode}
538 %
539 % \noindent
540 % Notice that for documents printed two-sided, the
541 % |\evensidemargin| is wider than the |\oddsidemargin|;
542 % this difference in width is transferred to the other margin.
543 %
544 % \begin{macrocode}
545 \@tempdima=\evensidemargin
546 \advance\@tempdima by -\oddsidemargin
547 \advance\oddsidemargin by \ExtraWidth
548 \advance\oddsidemargin by \@tempdima
549 \advance\evensidemargin by -\@tempdima
550 \else
551 % \end{macrocode}
552 %
553 % \noindent
554 % If the marginal notes go on the normal side of the paper, only the
555 % |\evensidemargin| has to be increased.
556 %
557 % \begin{macrocode}
558 \advance\evensidemargin by \ExtraWidth
559 \fi}
560 % \end{macrocode}
561 % \end{macro}
562 %
563 % \begin{macro}{\@nesidedwidemargins}
564 % For documents that are printed one-sided, both margins have the same
565 % width. The default placement for the marginal notes is in the right
566 % margin, so if |\reversemarginpar| is \emph{not} in effect the
567 % margin parameters need not be modified. If it is in effect, both the
568 % |\oddsidemargin| and the |\evensidemargin| need to be
569 % increased.
570 %
571 % \begin{macrocode}
572 \def\@nesidedwidemargins{%
573 \if@reversemargin
574 \advance\oddsidemargin by \ExtraWidth
575 \advance\evensidemargin by \ExtraWidth
576 \fi}
577 % \end{macrocode}
578 % \end{macro}
579 %
580 % The command |\ProcessOptions| can only be executed \emph{after}
581 % |\WideMargins| has been defined. Defering the execution of
582 % |\WideMargins| with |\AtBeginDocument| doesn't work, the changing
583 % of |\textwidth| then comes too late because of the time when the
584 % |\@begindocumenthook| gets executed by |\begin{document|.
585 % \begin{macrocode}
586 \ifx\documentclass\undefined
587 \else
588 \ProcessOptions
589 \fi
590 %</package>
591 % \end{macrocode}
592 %
593 % \Finale
594 %
595 \endinput