summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/cjw/cjwresize.sty
blob: 2934fde43d97793685f635c5b4928c5762394ceb (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
%%
% File: cjwresize.sty
%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cjwresize}
    [1995/05/09 v0.1  Change Default LaTeX Page Layouts -- CJW]

\newif \if@autocalc

\DeclareOption{auto} {\@autocalctrue}
\DeclareOption{final}{\@autocalctrue}
\DeclareOption*{%
  \PackageWarning{cjwresize}{Unknown option `\CurrentOption'}}

\ProcessOptions

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DISTRIBUTION NOTICE
%
%   This is file |cjwresize.sty| for use with \LaTeX2e.
%
%   Copyright (c) 1995 by Colin J. Wynne
%         cwynne@sage.wlu.edu, cwynne@lorien,princeton.edu,
%                     ua7o@rz.uni-karlsruhe.de
%   This file may be freely distributed in any form; electronic,
%   physical or otherwise; so long as the distributor provides this
%   file in its entirety (including this message) and the distributor
%   receives no money (except for a reasonable recompense for the
%   duplication process).  Fair 'nough?
%
%   This file is beer-ware.  If you use it and like it, then you
%   should buy me a beer if you ever meet me. :-)
%
%
% INTRO
%
%   This is a fairly simple file, so I am not going to bother with a
%   .dtx file.  Here is the whole documentation, right here. :-)  No
%   \docstrip{} hastle or anything...
%
%
% WHY THIS PACKAGE?
%
%   I think the default printable area used by \LaTeX{}, frankly,
%   sucks.  When I turn in three problem assignments for a math class
%   and it takes up eight pages, there is just too much blank space.
%   So, I hacked the relevant parts out of |classes.dtx| which deal
%   with setting printable area and balancing margins and fiddled with
%   some of the default values.  Not only that, but it is easily
%   customisable.
%
%
% HOW TO USE THIS PACKAGE
%
%   There are two basic ways to use this package.  Essentially, after
%   including the package, the macro |\resize| is available to the
%   user.  After altering any of the relevant page information, one
%   can invoke |\resize| to recalculate page margins.  |\resize|
%   should be called after changes to the following:
%
%       \textheight        \headheight        \footskip
%       \textwidth         \headsep
%
%   and optionally after changing |\topskip|.  These are the
%   dimensions on which the \LaTeX{} algorithms below depend.
%
%   This only half solves the problem, though.  Having to change the
%   height and width in every document is also not a particularly
%   ducky solution, so there is also a package option, namely |auto|.
%   In commented sections below, you will see where I have altered
%   some of the default values that \LaTeX{} uses for page layout
%   calculations.  Invoking the package with the |auto| option will
%   automatically do a resize with these defaults.  Of course, the
%   |\resize| command will still be available if further modifications 
%   are desired.  You should feel perfectly free to change these
%   defaults to something that will be more appropriate for you.
%   As the major advantage of \LaTeX's default, \emph{wide} margins is
%   the availability of |\marginpar| space, for draft annotations, I
%   also consider the revised margins of this package to be applicable
%   to final output.  Therefore the option |final| will be grabbed and
%   interpreted to mean the same thing as |auto|.
%
%
% BUGS
%
%   Well, I wouldn't call this a bug, but I haven't accounted for the
%   slight differences in these calculations specific to the |book|
%   class's options for size switching.  This package was written in
%   about twenty minutes, and I couldn't think of a way off the type
%   of my head to test for the invoked class.  If there is one (and
%   I'm fairly sure there is), please let me know.
%
%
% COMMENTS?
%
%   If you have any, send them to me at one of the e-mail addresses
%   above.  I hope this will be useful to somebody, somewhere.
%
%                                         CJW, 09.05.1995
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\resize{\relax%
      %
  \if@twoside
    \setlength\@tempdima        {\paperwidth}
    \addtolength\@tempdima      {-\textwidth}
    \setlength\oddsidemargin    {.4\@tempdima}
    \addtolength\oddsidemargin  {-1in}
      %
    \setlength\marginparwidth   {.6\@tempdima}
    \addtolength\marginparwidth {-0.4in}
  \else
    \setlength\@tempdima        {\paperwidth}
    \addtolength\@tempdima      {-\textwidth}
    \setlength\oddsidemargin    {.5\@tempdima}
    \addtolength\oddsidemargin  {-1in}
    \setlength\marginparwidth   {.5\@tempdima}
    \addtolength\marginparwidth {-.4in}
  \fi
      %
  \ifdim \marginparwidth >2in
    \setlength\marginparwidth{2in}
  \fi
      %
  \@settopoint\oddsidemargin
  \@settopoint\marginparwidth
      %
  \setlength\evensidemargin  {\paperwidth}
  \addtolength\evensidemargin{-2in}
  \addtolength\evensidemargin{-\textwidth}
  \addtolength\evensidemargin{-\oddsidemargin}
      %
  \@settopoint\evensidemargin
      %
      %
  \setlength\topmargin{\paperheight}
    \addtolength\topmargin{-2in}
    \addtolength\topmargin{-\headheight}
    \addtolength\topmargin{-\headsep}
    \addtolength\topmargin{-\textheight}
    \addtolength\topmargin{-\footskip}
      %
  \addtolength\topmargin{-.5\topmargin}
  \@settopoint\topmargin
}

%%%%
%%%%
%%
%% CODE for the |auto| option:
%%
%%%%
%%%%

\if@autocalc

%%
% Compute the |\textwidth|.
%%

  \setlength\@tempdima{\paperwidth}
  \addtolength\@tempdima{-2in}

%%
% This choice of |\@tempdimb| is the `default' page size used by the
% |auto| option.  The values from |classes.dtx| are 345pt, 360pt and
% 390pt respectively for 10pt, 11pt and 12pt document sizes.  Feel
% free to change these to taste.  I find that adding about 40--50pt to
% the original dimensions works pretty well.
%%
  \ifcase \@ptsize
    \setlength\@tempdimb{385\p@} \or
    \setlength\@tempdimb{400\p@} \else
    \setlength\@tempdimb{430\p@}
  \fi

  \if@twocolumn
    \ifdim\@tempdima>2\@tempdimb\relax
      \setlength\textwidth{2\@tempdimb}
    \else
      \setlength\textwidth{\@tempdima}
    \fi
  \else
    \ifdim\@tempdima>\@tempdimb\relax
      \setlength\textwidth{\@tempdimb}
    \else
      \setlength\textwidth{\@tempdima}
    \fi
  \fi

  \@settopoint\textwidth

%%
% Compute the |\textheight|.
%%

  \setlength\@tempdima{\paperheight}
%%
% These next two lines govern the `default' |\textheight| used by the
% |auto| option.  The values from |classes.dtx| are -2in for the
% margins and -1.5in for headers and footers.  I like reducing the
% extra space for headers/footers down to -1in.  Feel free, however,
% to change these values to taste.
%%						%%
    \addtolength\@tempdima{-2in}		% Minimum margins.
    \addtolength\@tempdima{-1in}		% Room for head/foot stuff.
						%	  
  \divide\@tempdima\baselineskip		% Compute size in 
    \@tempcnta=\@tempdima			% line numbers.
  						%
  \setlength\textheight{\@tempcnta\baselineskip}%
    \addtolength\textheight{\topskip}		% First line of text has
				   		% height |\topskip|.
%%						%%
% Now call resize.
%%
  \resize

\fi

\endinput
%%
% End of file: cjwresize.sty
%%