ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/doc/tex/manual/Vmargin.sty
Revision: 1.2
Committed: Fri Jan 14 17:36:41 2011 UTC (14 years, 4 months ago) by muzaffar
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
merged SCRAM_V2 branch in to head

File Contents

# Content
1 %%----------------------------------------------------------------------
2 %% Vmargin.sty
3 %
4 % LaTeX style file providing macros to aid margin setting. Also
5 % introduces paper sizes. Supersedes Vpage.sty.
6 % This file can be made part of a format by typing \input Vmargin.sty
7 % before dumping the format.
8 %
9 % Documentation & history after (last) \endinput.
10 %
11 % Works with both LaTeX2.09 and LaTeX2e.
12 % Supported = yes.
13 %
14 %
15 % (C) Copyright 1993, 1994 by:
16 %
17 % Volker Kuhlmann
18 % University of Canterbury
19 % EEE Dept
20 % Christchurch, New Zealand
21 % E-Mail: VOLKER@ELEC.CANTERBURY.AC.NZ
22 %
23 % Permission is granted to use this file free of charge, and to
24 % distribute it provided no charge is made for distribution.
25 % This file must not be altered without changing its name.
26 %
27 %%----------------------------------------------------------------------
28
29 \def\filename{Vmargin}
30 \def\fileversion{V2.1}
31 \def\filedate{20 Sep 1994}
32
33 \@ifundefined{Vmargin}{}{\endinput}
34
35 \edef\Vmargin{Style `\filename', \fileversion, \filedate}
36
37 \expandafter\everyjob\expandafter{\the\everyjob\typeout{\Vmargin}}
38 \typeout{\Vmargin}
39
40
41
42 % new lengths: \PaperWidth, \PaperHeight
43 % new if: \ifLandscape
44 %
45 \newdimen\PaperWidth
46 \newdimen\PaperHeight
47 %
48 \newif\ifLandscape
49
50
51 % \setpapersize
52 %
53 \def\setpapersize{\@ifnextchar[{\@@setps}{\@@setps[portrait]}}
54 \def\@@setps[#1]#2{%
55 \@ifundefined{po@#1}{\@name@err{#1}}{\@nameuse{po@#1}}%
56 \@ifundefined{paper@#2}{\@name@err{#2}}{}%
57 \csname paper@#2\endcsname}
58 % \usename{paper@#2} inside arg to \@ifundefined does not work
59 % with papersize "custom".
60 \def\po@portrait{\Landscapefalse}
61 \def\po@landscape{\Landscapetrue}
62 \def\@po@{\ifLandscape\dimen0\PaperWidth
63 \PaperWidth\PaperHeight\PaperHeight\dimen0\fi\relax
64 \@ifundefined{paperwidth}{}{\paperwidth\PaperWidth}%
65 \@ifundefined{paperheight}{}{\paperheight\PaperHeight}}
66 \def\@name@err#1{%
67 \typeout{*****> \string\setpapersize: illegal parameter: #1}}
68
69
70 % pre-defined paper/envelope sizes
71 %
72 % A0, A1, A2, ..., A9, B0, B1, ..., B9, C0, C1, ..., C9
73 % USletter, USlegal, USexecutive
74 % custom
75 %
76 \def\@defmetricpaper#1#2#3{%
77 \begingroup
78 \count0=0
79 \def\w{\dimen1 }\def\h{\dimen2 }\def\s{\dimen3 }%
80 \w#2\h#3
81 \def\l{11}
82 \loop
83 \begingroup
84 \def\t{\the\count0}
85 \catcode`\t=11 % letter
86 \expandafter\xdef\csname paper@#1\the\count0\endcsname{%
87 \PaperWidth\the\w\PaperHeight\the\h\noexpand\@po@}
88 \endgroup
89 \s\w\w.5\h\h\s
90 \ifnum\the\count0<9
91 \advance\count0 by 1
92 \repeat
93 \endgroup
94 }
95 %
96 \@defmetricpaper{A}{840.9mm}{1189.2mm}
97 \@defmetricpaper{B}{1000mm}{1414mm}
98 \@defmetricpaper{C}{917mm}{1297mm}
99 %
100 \let\@defmetricpaper=\relax % delete definition to save memory
101 %
102 \def\paper@USletter{\PaperWidth 8.5in \PaperHeight 11in \@po@}
103 \def\paper@USlegal{\PaperWidth 8.5in \PaperHeight 14in \@po@}
104 \def\paper@USexecutive{\PaperWidth 7.25in\PaperHeight 10.5in \@po@}
105 %
106 \def\paper@custom#1#2{\PaperWidth#1\PaperHeight#2\@po@}
107
108
109 % margin@offset
110 %
111 % Compensates for the +1in/+1in top/left corner
112 % by either reducing the margins or \hoffset, \voffset by 1in.
113 % This macro is only defined here if it is not already defined!
114 % (see documentation at the end)
115 %
116 \newif\if@shiftmargins
117 \@shiftmarginsfalse % this MUST be default (pageframe.sty)
118 %
119 \@ifundefined{margin@offset}{
120 \def\margin@offset{
121 \if@shiftmargins
122 \oddsidemargin -1in\evensidemargin -1in\topmargin -1in
123 \hoffset 0in\voffset 0in\relax
124 \else
125 \oddsidemargin 0in\evensidemargin 0in\topmargin 0in
126 \hoffset -1in\voffset -1in\relax
127 \fi
128 }}{}
129 %
130 \def\shiftmargins{\@shiftmarginstrue}
131
132
133 % Setting margins
134 %
135 % \setmargins{leftmargin}{topmargin}{textwidth}{textheight}%
136 % {headheight}{headsep}{footheight}{footskip}
137 %
138 \newcommand\setmargins[8]{%
139 \margin@offset
140 \advance\oddsidemargin #1
141 \advance\evensidemargin \PaperWidth % = paperwidth - left
142 \advance\evensidemargin -#1 % - width
143 \advance\evensidemargin -#3
144 \advance\topmargin #2
145 \textwidth #3
146 \textheight #4
147 \headheight #5
148 \headsep #6
149 \@ifundefined{footheight}{}{\footheight=#7}%
150 \footskip #8
151 \chk@dimen{#1}{#2}{#3}{#4}%
152 }
153 %
154 % \setmargins{leftmargin}{topmargin}{rightmargin}{bottommargin}%
155 % {headheight}{headsep}{footheight}{footskip}
156 %
157 \newcommand\setmarginsrb[8]{%
158 \margin@offset
159 \textwidth \PaperWidth % = paperwidth
160 \advance\textwidth -#1 % - left - right
161 \advance\textwidth -#3
162 \textheight \PaperHeight % = paperheight - top
163 \advance\textheight -#2 % - headheight
164 \advance\textheight -#5 % - headsep
165 \advance\textheight -#6 % - footskip - bottom
166 \advance\textheight -#8
167 \advance\textheight -#4
168 \advance\oddsidemargin #1
169 \advance\evensidemargin \PaperWidth % = paperwidth
170 \advance\evensidemargin -#1 % - left - width
171 \advance\evensidemargin -\textwidth
172 \advance\topmargin #2
173 \headheight #5
174 \headsep #6
175 \@ifundefined{footheight}{}{\footheight=#7}%
176 \footskip #8
177 \chk@dimen{#1}{#2}{#3}{#4}%
178 }
179 %
180 % \setmargnohf{leftmargin}{topmargin}{textwidth}{textheight}
181 % headheight, headsep, footheight, footskip set to 0pt
182 \newcommand\setmargnohf[4]{%
183 \setmargins{#1}{#2}{#3}{#4}{0pt}{0mm}{0pt}{0mm}%
184 \pagestyle{empty}}
185 %
186 % \setmargnohfrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
187 % headheight, headsep, footheight, footskip set to 0pt
188 \newcommand\setmargnohfrb[4]{%
189 \setmarginsrb{#1}{#2}{#3}{#4}{0pt}{0mm}{0pt}{0mm}%
190 \pagestyle{empty}}
191 %
192 % \setmarg{leftmargin}{topmargin}{textwidth}{textheight}
193 % headheight, headsep, footheight, footskip unchanged
194 \newcommand\setmarg[4]{%
195 \setmargins{#1}{#2}{#3}{#4}%
196 \headheight\headsep\footheight\footskip}
197 %
198 % \setmargnohfrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
199 % headheight, headsep, footheight, footskip unchanged
200 \newcommand\setmargrb[4]{%
201 \setmarginsrb{#1}{#2}{#3}{#4}%
202 \headheight\headsep\footheight\footskip}
203 %
204 % h-warning if [leftmarg + textwidth > paperwidth] resp.
205 % if [letmarg + rightmarg > paperwidth].
206 % v-warning if [topmarg + textheight > paperheight] resp.
207 % if [topmarg + bottommarg > paperheight].
208 \def\chk@dimen#1#2#3#4{%
209 \dimen0= #1
210 \advance\dimen0 by#3
211 \advance\dimen0 -\PaperWidth
212 \dimen1= #2
213 \advance\dimen1 by#4
214 \advance\dimen1 \headheight
215 \advance\dimen1 \headsep
216 \advance\dimen1 \footskip
217 \advance\dimen1 -\PaperHeight
218 \ifnum\dimen0>\z@\typeout{Vmargin Warning: Horizontal dimensions
219 exceed paper width by \the\dimen0}\fi\relax
220 \ifnum\dimen1>\z@\typeout{Vmargin Warning: Vertical dimensions
221 exceed paper height by \the\dimen1}\fi\relax
222 }
223
224
225 %
226 % DEFAULTS:
227 %
228 \setpapersize{A4}
229 \setmarginsrb{35mm}{20mm}{25mm}{15mm}{12pt}{11mm}{0pt}{11mm}
230
231
232 \endinput
233
234 %%----------------------------------------------------------------------
235
236 Page Size and Margins
237 =====================
238
239 These macros make it easy to set page margins for a chosen paper size.
240 Actual dimensions of the most common paper sizes are stored and need
241 not be remembered.
242
243 Two sided printing is supported, meaning that if on odd pages the left
244 margin is, say, 30mm and the right margin is 20mm, it will be vice
245 versa on even pages. This gives equal margins on the outer and the
246 inner edge of the paper, as expected e.g. for a book.
247
248 The size of the paper can be set with
249
250 \setpapersize{<size>}
251
252 <size> can be A0, A1, ..., A9, B0, B1, ..., B9, C0, ..., C9,
253 USletter, USlegal, and USexecutive. The metric paper sizes are not
254 stored but calculated.
255
256 Landscape format is selected by using the optional argument
257
258 \setpapersize[landscape]{<size>}
259
260 which swaps the width and height dimensions of the paper.
261 \setpapersize[portrait]{<size>} is allowed but is the default.
262
263 If you have a size which is not pre-defined use
264
265 \setpapersize{custom}{<width>}{<height>}
266
267 For <width> and <height> insert the respective dimensions of your
268 paper.
269
270 \setpapersize stores the actual dimensions of the paper in the length
271 variables
272
273 \PaperWidth
274 \PaperHeight
275
276 which can be used further, if desired.
277
278 \ifLandscape
279
280 yields true if a landscape format is selected. Do not write
281 \PaperWidth, \PaperHeight, or call \Landscapetrue or \Landscapefalse,
282 it will not work!!
283
284 The margins can be set with
285
286 \setmargins{leftmargin}{topmargin}{textwidth}{textheight}%
287 {headheight}{headsep}{footheight}{footskip}
288
289 or with
290
291 \setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%
292 {headheight}{headsep}{footheight}{footskip}
293
294 In the latter case \textwidth and \textheight are calculated using the
295 width and height of the selected paper. The first four parameters of
296 the above two commands are used to set \oddsidemargin, \evensidemargin,
297 \textwidth, \topmargin, and \textheight.
298
299 \setmargnohf, \setmargnohfrb
300
301 Provide a page with no header and footer. They work the same as
302 \setmargins, \setmarginsrb except that they only need the first 4
303 parameter. The last 4 parameter are set to 0pt. These 2 commands set
304 the pagestyle to empty (\pagestyle{empty}) as there is no space for
305 headers or footers.
306
307 \setmarg, \setmargrb
308
309 are the same as \setmargnohf, \setmargnohfrb apart from that the last 4
310 parameter to \setmargins, \setmarginsrb are unchanged.
311
312 Example:
313
314 A4 paper, left margin 30mm, top, right, and bottom margin 20mm
315 each, no headers or footers:
316
317 \setpapersize{A4}
318 \setmarginsrb{30mm}{20mm}{20mm}{20mm}{0pt}{0mm}{0pt}{0mm}
319 \pagestyle{empty}
320
321 The same settings would result by:
322
323 \setpapersize{A4}
324 \setmargnohfrb{30mm}{20mm}{20mm}{20mm}
325
326 For the default settings please see the part after "DEFAULTS:" (last
327 part before \endinput).
328
329 The default top and left margins of TeX are +1in. \setmargXXX call
330
331 \margin@offset
332
333 which initialises \hoffset, \voffset to -1in and \oddsidemargin,
334 \evensidemargin, \topmargin to 0in. \setmargXXX then add the given
335 dimensions to \topmargin, \oddsidemargin, \evensidemargin. In some
336 cases it might be desired to use \XXXmargin instead of \Xoffset for
337 compensation. This can be achieved by telling \margin@offset to
338 initialise \Xoffset to 0in and \XXXmargin to -1in. This is done by
339 %
340 \shiftmargins.
341 %
342 If \margin@offset is already defined at the time Vmargin is loaded it
343 is NOT redefined! Therefore if \margin@offset is defined before Vmargin
344 is loaded the above mentioned compensation can be replaced by a
345 different mechanism. In any way \setmargXXX call \margin@offset and
346 then expect that \XXXmargin are set to useful values. \Xoffset are not
347 touched by \setmargXXX. \margin@offset should be defined in a separate
348 file which is included BEFORE Vmargin, i.e. appears in the list of
349 document-substyles of the \documentstyle command before Vmargin.
350 %
351 Any better way of doing this? (grumble)
352
353 Example: \documentstyle[...,margins,Vmargin,...]{...}
354 if \margin@offset is defined in a file called margins.sty.
355
356 LaTeX2e: \documentclass[...]{...}
357 \usepackage{...,margins,Vmargin,...}
358
359
360 LaTeX2e
361 -------
362
363 This style (or package) works with LaTeX2e. To keep it working under
364 LaTeX2.09 none of the special LaTeX2e package interface features have
365 been used. There will probably be a new version (under a new name) that
366 is specialised for LaTeX2e.
367
368 LaTeX2e (unless in compatibility mode) does not know \footheight any
369 more. This dimension is not set if it is not defined, but is set
370 otherwise (i.e. it is set in LaTeX2e compatibility mode).
371
372 LaTeX2e now has the dimensions \paperwidth, \paperheight which hold the
373 size of the paper. \PaperWidth, \PaperHeight are copied into
374 \paperwidth, \paperheight if the latter exist. This makes Vmargin work
375 correctly with anything that expects \paperwidth, \paperheight to be
376 set properly. The names \PaperWidth, \PaperHeight had been chosen in
377 the first place to avoid clashes with style files that also use these
378 names (namely pageframe.sty).
379
380
381 Inclusion in TeX formats
382 ------------------------
383
384 This file may be loaded in initex before dumping the format, by typing
385 \makeatletter
386 \input Vmargin.sty
387 \makeatother
388 Note: this produces a non-standard format.
389
390
391 Hints for using pageframe.sty
392 -----------------------------
393
394 Vmargin.sty and pageframe.sty can be used together if the following
395 points are considered:
396
397 Vmargin uses \hoffset and \voffset and writes negative values into it,
398 pageframe expects them to be zero to give a 1in space on the left and
399 the top where it prints additional information. Initially, set both to
400 0mm (in the pre-amble of your text) and adjust them later on.
401
402 pageframe needs to know the trimmed height of the paper (= the height
403 of the "page frame"). Unless the trimmed(!) size of the paper is
404 equivalent to one of the standard paper sizes (unlikely...) the size
405 should be specified with
406
407 \setpapersize{custom}{<width>}{<height>}
408
409 The correct height of the trimmed page can then be given to pageframe
410 using
411
412 \paperheight{\PaperHeight}
413
414 and the margins of the final product (inside the page frame) can be
415 specified using \setmargXXX.
416
417 Warning: if \setmargXXXrb is used the 3rd parameter (right margin) is
418 ignored. Instead, the dimension of the right margin has to be assigned
419 to \evensidemargin. This is because pageframe.sty re-defines the meaning
420 of \evensidemargin to be the right margin of your text, on all pages.
421
422 Remember: all these assignments and macro calls have to be in the
423 pre-amble of the document.
424
425
426 To do:
427 ------
428
429 * The way how the metric paper sizes are stored takes up a lot of
430 space. A metric size could be computed by \setpapersize.
431
432 * Make use of new LaTeX2e features.
433 If I do I will probably give the package a new name.
434
435
436 SUMMARY:
437 ========
438
439 new lengths:
440 \PaperWidth
441 \PaperHeight
442
443 new ifs:
444 \ifLandscape
445
446 new macros:
447 \setpapersize[<orientation>]{<size>},
448 \setpapersize[<orientation>]{custom}{<width>}{<height>}
449 <orientation> (optional) = landscape or portrait (default)
450 <size> = A4, B5, ...
451 <width>, <height> = actual dimensions of the paper
452 \setmargins{leftmargin}{topmargin}{textwidth}{textheight}%
453 {headheight}{headsep}{footheight}{footskip}
454 \setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%
455 {headheight}{headsep}{footheight}{footskip}
456 \setmargnohf{leftmargin}{topmargin}{textwidth}{textheight}
457 \setmargnohfrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
458 \setmarg{leftmargin}{topmargin}{textwidth}{textheight}
459 \setmargrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
460 %
461 \margin@offset
462 \shiftmargins
463
464
465 If you have any comments (positive or negative) please let me know!
466
467
468
469 HISTORY:
470 ========
471
472 .
473 . Created out of Vpage.sty.
474 .
475 V1.7 21 May 1994 Changed file header.
476 V1.72 21 May 1994 Fixed bug in \setpapersize{custom}
477 V1.8 28 May 94 Commented \chk@dimen; reduced load on TeX's
478 parameter stack (changed \chk@dimen).
479 Put a conditional around references
480 to \footheight.
481 V1.9 22 Jun 94 Corrected spelling in comment.
482 V2.0 28 Jun 94 Added support for LaTeX2e \paperwidth,
483 \paperheight.
484 V2.1 20 Sep 94 \@defmetricpaper now defines \w, \h, \s locally.
485 Thanks to branderhorst@fgg.eur.nl!
486 %
487 %% EOF Vmargin.sty
488 %%----------------------------------------------------------------------