A style option to adapt the standard L^{A}TEX document styles to A4 paper^{∗}

Nico Poppelier TEXnique Washingtondreef 153 3564 KD Utrecht

      Poppelier@elsevier.nl

Johannes Braams TEXniek Kooienswater 62 2715 AJ Zoetermeer

                               JLBraams@cistron.nl

Printed July 31, 1996

Abstract

This article describes a new style option that can be used with the document styles that are distributed with the L^{A}TEX distributions. It modifies the page layout to conform to the paper format most commonly used in Europe, portrait A4.

1 Introduction

This file is based on the document style options A4.sty and A4wide.sty, which can be found in the Rochester style archive. The original style option 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 A4wide.sty was written by Jean-Francois Lamy, and is dated July 1986. This option only increases the width of the text.

2 Goals and design decisions

As many people before us, we found the page layout as implemented in the standard L^{A}TEX 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 [1]). 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^{1} of the text to allow this.

∗This file has version number v1.2e– last revision 1995/09/25.

There is yet one more thing to take into account when designing a page layout. L^{A}TEX 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:

1. Choose the text width such that there will be sixty to seventy characters on a line;

2. 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;

3. Leave enough white space in the ‘inner’ margin to allow for the binding of the document;

4. Leave enough white space in the ‘outer’ margin for marginal notes if they are going to be used.

3 Update for L^{A}TEX 2ε

With the new document classes this package may not be needed much longer, because A4 paper is now supported through the standard option a4paper. Yet this package additional functionality, not available in the standard document classes. With L^{A}TEX 2ε, you can now use this package with the command:

     \usepacke[widemargins]{a4}

The option widemargins executes the \WideMargins command.

4 The implementation

4.1 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 a4 and 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.

1For 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.

4.2 What else?

\textwidth Because the result so far gave us lines that contained too many characters, we \marginparwidth decreased the \textwidth to get lines that contain about sixty to seventy charac-

ters for all three size options. Still more work had to be done. As it turned out, using our new 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.

\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.

4.3 The docstrip modules

The following modules are used in the implementation to direct docstrip in generating the external files:

driver  produce a documentation driver file
package produce a package file

4.4 Producing the documentation

A short driver is provided that can be extracted if necessary by the docstrip program provided with L^{A}TEX 2ε.

1 ⟨∗driver⟩

 2 \NeedsTeXFormat{LaTeX2e}
 3 \documentclass{ltxdoc}
 4 \DisableCrossrefs

5

 6 \CodelineIndex

7

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

12

13 \DocInput{a4.dtx}

14

15 \end{document}

16 ⟨/driver⟩

4.5 The code

Declare the option widemargins.

17 ⟨∗package⟩

18 \ifx\documentclass\undefined
19 \else
20 \DeclareOption{widemargins}{\WideMargins}
21 \fi
\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.

22 \topmargin 0pt

\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:

23 \ifcase \@ptsize
24  \textheight 53\baselineskip

which modifies the height of the text for texts to be produced with the ten-point typeface:

25 \or
26  \textheight 46\baselineskip

the same for eleven point:

27 \or
28  \textheight 42\baselineskip

and for twelve point. Finally we close the \ifcase statement:

29 \fi

The only thing left to be done is to add the \topskip to the \textheight. The value of \topskip appears always to be 10pt.

30 \advance\textheight by \topskip

\textwidth \oddsidemargin \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 twosided, 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.

31 \ifcase \@ptsize

Then we specify the width of the text.

32  \textwidth      5.00in

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.

33  \marginparwidth 1.00in

Here we need an if statement to test whether the option twosided has been specified.

34 \if@twoside

If it was, assign appropriate values to the margin parameters

35  \oddsidemargin  0.55in
36  \evensidemargin 0.75in
37 \else

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.

38  \oddsidemargin  0.55in
39  \evensidemargin 0.55in

Now we close the if statement.

40 \fi

We are ready with the modifications for the ten-point typeface size, so now we do something similar for the eleven-point typeface.

41 \or
42  \textwidth      5.20in
43  \marginparwidth 1.00in
44 \if@twoside
45  \oddsidemargin  0.45in
46  \evensidemargin 0.65in
47 \else
48  \oddsidemargin  0.45in
49  \evensidemargin 0.45in
50 \fi

One more time, now for the twelve-point typeface.

51 \or
52  \textwidth      5.70in
53  \marginparwidth 0.80in
54 \if@twoside
55  \oddsidemargin  0.20in
56  \evensidemargin 0.40in
57 \else
58  \oddsidemargin  0.20in
59  \evensidemargin 0.20in
60 \fi

Finally we close the case statement.

61 \fi

\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.

62 \def\WideMargins{%

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.

\ExtraWidth In order to store the amount of extra width needed for the marginal notes an extra dimension parameter is defined.

63 \newdimen\ExtraWidth

First find out about the point size, then call \@widemargins to modify the margin widths by the amount given in \ExtraWidth.

64 \ifcase \@ptsize

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.

65  \ExtraWidth = 0.5in
66  \@widemargins
67 \or
68  \ExtraWidth = 0.5in
69  \@widemargins
70 \or

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.

71  \ExtraWidth = 0.7in
72  \@widemargins

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.

73 \fi\let\WideMargins\relax\let\@widemargins\relax}
\@preamblecmds We add \WideMargins to \@preamblecmds, which is a list of commands to be

used only in the preamble of a document.

74 {\def\do{\noexpand\do\noexpand}
75 \xdef\@preamblecmds{\@preamblecmds \do\WideMargins}

76 }

\@widemargins This macro modifies the margin parameters. To do this it uses the dimension variable \ExtraWidth, which was defined by \WideMargins. First the \ExtraWidth is subtracted from the \textwidth and added to the

\marginparwidth.
77 \def\@widemargins{%
78  \global\advance\textwidth by -\ExtraWidth
79  \global\advance\marginparwidth by \ExtraWidth

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

80  \if@twoside
81  \tw@sidedwidemargins
82  \else
83  \@nesidedwidemargins
84  \fi}

\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.

85 \def\tw@sidedwidemargins{%
86  \if@reversemargin

Notice that for documents printed two-sided, the \evensidemargin is wider than the \oddsidemargin; this difference in width is transferred to the other margin.

87  \@tempdima=\evensidemargin
88  \advance\@tempdima by -\oddsidemargin
89  \advance\oddsidemargin by \ExtraWidth
90  \advance\oddsidemargin by \@tempdima
91  \advance\evensidemargin by -\@tempdima
92  \else

If the marginal notes go on the normal side of the paper, only the \evensidemargin has to be increased.

93  \advance\evensidemargin by \ExtraWidth
94  \fi}

\@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 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.

95 \def\@nesidedwidemargins{%
96  \if@reversemargin
97  \advance\oddsidemargin by \ExtraWidth
98  \advance\evensidemargin by \ExtraWidth
99  \fi}

The command \ProcessOptions can only be executed 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.
100 \ifx\documentclass\undefined
101 \else
102 \ProcessOptions
103 \fi

104 ⟨/package⟩

5 Conclusion

We have presented a new approach to adapt the page layout of the document styles that are part of the standard L^{A}TEX 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.

References

[1] K.F. Treebus. Tekstwijzer, een gids voor het grafisch verwerken van tekst. SDU Uitgeverij (’s-Gravenhage, 1988). A Dutch book on layout design and typography.