Debian Codegraph @

texmf-dist/source/latex/vmargin/vmargin.dtx

raw
1 % \iffalse meta-comment
2 % %%----------------------------------------------------------------------------
3 %
4 %% File: vmargin.dtx Copyright (C) 1993, 1994, 1995, 1996, 1999, 2000, 2002,
5 %% 2004
6 %% by Volker Kuhlmann <[email protected]>
7 %% All rights are reserved.
8 %%
9 %
10 %<*dtx>
11 \NeedsTeXFormat{LaTeX2e}[1999/06/01]
12 \ProvidesFile{vmargin.dtx}
13 %</dtx>
14 %
15 %<driver> \ProvidesFile{vmargin.drv}
16 %
17 %^^A<package>\NeedsTeXFormat{LaTeX2e}[1998/06/01]
18 %^^A<package>\ProvidesPackage{vmargin}
19 %^^A Can't have these 2 lines if package is to work with LaTeX 2.09
20 %
21 % ^^A NOTE: VERSION INFO DUPLICATED BELOW AND IN PACKAGE MACROCODE SECTION !!!
22 % ^^A search tag: mAcRoVeRsIoN (total of 4 places to change!)
23 %<*dtx|driver>
24 % \ProvidesFile{vmargin.dtx}
25 [2004/07/15 v2.5 set document margins (VK)]
26 %^^A need to uncomment above line to get it into the .drv
27 %^^A alternatively we could scrap it altogether!
28 %</dtx|driver>
29 %
30 % \fi
31 % ^^A The following 2 lines are required for the .drv file to correctly generate
32 % ^^A the documentation from the .dtx. It's needed for \GetFileInfo.
33 % ^^A The 2nd line generally is uncommented, but that would mean it ends up in
34 % ^^A the .sty which we can't allow for 2.09 compatibility.
35 % \ProvidesFile{vmargin.dtx}
36 % [2004/07/15 V2.5 set document margins (VK)] %^^A mAcRoVeRsIoN
37 %
38 %%
39 %% \CharacterTable
40 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
41 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
42 %% Digits \0\1\2\3\4\5\6\7\8\9
43 %% Exclamation \! Double quote \" Hash (number) \#
44 %% Dollar \$ Percent \% Ampersand \&
45 %% Acute accent \' Left paren \( Right paren \)
46 %% Asterisk \* Plus \+ Comma \,
47 %% Minus \- Point \. Solidus \/
48 %% Colon \: Semicolon \; Less than \<
49 %% Equals \= Greater than \> Question mark \?
50 %% Commercial at \@ Left bracket \[ Backslash \\
51 %% Right bracket \] Circumflex \^ Underscore \_
52 %% Grave accent \` Left brace \{ Vertical bar \|
53 %% Right brace \} Tilde \~}
54 %%
55 %
56 % \iffalse
57 %<*driver>
58
59 \NeedsTeXFormat{LaTeX2e}[1999/06/01]
60 \documentclass{ltxdoc}
61 %%\IfFileExists{ltxdoc.cfg}{}{\OnlyDescription\RecordChanges\CodelineIndex}
62
63 \IfFileExists{vmargin.sty}{%
64 \usepackage{vmargin}%
65 \setpapersize[portrait]{A4}%
66 \setmarginsrb{55mm}{15mm}{22mm}{15mm}{10pt}{7mm}{}{12mm}%
67 \marginparsep 3mm
68 \relax
69 }{}
70
71 %\OnlyDescription % uncomment to suppress code line listing
72 \RecordChanges % uncomment for a change history
73 \CodelineIndex\EnableCrossrefs % uncomment for command index
74 \GetFileInfo{vmargin.dtx}
75
76 \begin{document}
77 \DocInput{vmargin.dtx}
78 %%\IfFileExists{ltxdoc.cfg}{}{\PrintChanges\PrintIndex}
79 \PrintChanges % uncomment for a change history
80 \PrintIndex % uncomment for command index
81 \end{document}
82
83 %</driver>
84 % \fi
85 %
86 %
87 % \GetFileInfo{vmargin.dtx}
88 % \CheckSum{395}
89 %
90 % %^^A This command extracts all index entries:
91 % %^^A sed < vmargin.idx -e 's,indexentry{,,' -e 's,=.*$,,'
92 %
93 % \date{\filedate}
94 % \title{The \textsf{vmargin} Package\thanks
95 % {This file has version number \fileversion,
96 % last modified \filedate.}}
97 % \author{Volker Kuhlmann\thanks{%^^A
98 % ^^AEmail:\ \url{[email protected]}.
99 % Email:\ \url{[email protected]}.
100 % For a postal address refer to the license section.}}
101 %
102 %
103 % %%%^^A MACROS used for this document
104 % \let\package\textsf
105 % \let\env\textsf
106 % \let\url\texttt
107 % \newcommand\optmeta[1]{[\meta{#1}]}
108 % \begingroup
109 % \catcode`\^^M\active^^A% Has to be active during definition!
110 % \gdef\makeNLnl{\catcode`\^^M\active \def^^M{\par}}
111 % \endgroup
112 % \newenvironment{pckcmd}{%^^A
113 % \ifvmode \else \par\vspace{-\parskip}\fi
114 % \vspace{1mm}\noindent \hangindent 4em\hangafter 0\ignorespaces
115 % }{%^^A
116 % \par\vspace{1mm}\vspace{-\parskip}}
117 % \newcommand\MargWord[1]{\marginpar{\raggedleft\PrintDescribeEnv{#1}}}
118 %
119 %
120 % ^^A search tag: mAcRoVeRsIoN (adjust changelog)
121 %
122 % \changes{v2.5}{2004/07/15}
123 % {\cs{margin@offset} now uses \hbox{-1truein} instead of -1in}
124 %
125 % \changes{v2.4.2}{2002/11/08}
126 % {documentation only}
127 %
128 % \changes{v2.4}{2002/01/23}
129 % {minor changes, mostly cosmetic}
130 %
131 % \changes{v2.3b}{2000/08/29}
132 % {screen output of version info.}
133 %
134 % \changes{v2.3}{2000/08/01}
135 % {Now setting page size for pdflatex.}
136 %
137 % \changes{v2.2b}{2000/03/14}
138 % {Changed into docstrip format.
139 % Improved documentation.}
140 %
141 % \changes{V2.2}{1999/05/31}
142 % {Released under LPPL.
143 % Changed references to Vmargin to vmargin.
144 % \LaTeX2e\ package options introduced.}
145 %
146 % \changes{V2.13}{1996/06/26}
147 % {Fixed comment for \cs{setmarginsrb}.}
148 %
149 % \changes{V2.12}{1995/03/28}
150 % {Fixed documentation for \cs{setmargrb}.}
151 %
152 % \changes{V2.1}{1994/09/20}
153 % {\cs{@defmetricpaper} now defines \cs{w}, \cs{h}, \cs{s} locally.
154 % Thanks to \url{[email protected]}!}
155 %
156 % \changes{V2.0}{1994/06/28}
157 % {Added support for \LaTeX2e\ \cs{paperwidth}, \cs{paperheight}.}
158 %
159 % \changes{V1.9}{1994/06/22}
160 % {Corrected spelling in comment.}
161 %
162 % \changes{V1.8}{1994/05/28}
163 % {Commented \cs{chk@dimen};
164 % reduced load on \TeX'sparameter stack (changed \cs{chk@dimen});
165 % put a conditional around references to \cs{footheight}.}
166 %
167 % \changes{V1.72}{1994/05/21}
168 % {Fixed bug in \cs{setpapersize\{custom\}}.}
169 %
170 % \changes{V1.7}{1994/05/21}
171 % {Changed file header.}
172 %
173 % \changes{1.0}{1993}
174 % {Created out of Vpage.sty V2.2, 18 June 1993}
175 %
176 %
177 % \maketitle
178 %
179 % \begin{abstract}
180 % LaTeX package which introduces paper sizes and provides macros for
181 % setting document margins. It still works with \LaTeX\ 2.09.
182 % This package supersedes package vpage.
183 %
184 % This package file can be made part of a format by typing |\input vmargin.sty|
185 % before dumping the format.
186 % \end{abstract}
187 %
188 % \tableofcontents
189 %
190 %
191 % \section{License}
192 %
193 % This package is copyright \textcopyright\ 1993, 1994, 1995, 1996, 1999, 2000,
194 % 2002, 2004 by:
195 %
196 % \begin{quote}
197 % Volker Kuhlmann,
198 % c/o University of Canterbury,
199 % ELEC Dept, Creyke Road,
200 % Christchurch, New Zealand\\
201 % ^^AE-Mail: \url{[email protected]}
202 % E-Mail: \url{[email protected]}
203 % \end{quote}
204 %
205 % This program can be redistributed and/or modified under the terms
206 % of the LaTeX Project Public License, distributed from CTAN
207 % archives as macros/latex/base/lppl.txt; either
208 % version 1 of the License, or (at your option) any later version.
209 %
210 %
211 % \section{History}
212 %
213 % This is the first package I ever wrote, to save a lot of typing when dealing
214 % with \TeX's 1in/1in margin offset, proper margin alignment for doublesided
215 % printing, and page layout parameters I always used. As there wasn't anything
216 % similar on CTAN I submitted the package, then called \package{Vpage}. I
217 % never heard back, and wasn't looking for it in the right place, so I
218 % thought it hadn't been accepted and never thought any more of it.
219 %
220 % In the meantime I realised its general-purpose potential and took the page
221 % layout code out, renaming it to \package{Vmargin}. First time I heard it
222 % was on CTAN was when I read the list of 3rd-party packages in the \LaTeX\
223 % Companion and it had \package{vpage} in it (CTAN doesn't deal in uppercase
224 % letters). So sorry for any confusion the name change caused\ldots
225 %
226 % Further development essentially ceased because I didn't see much scope
227 % for improvements. \package{vmargin} was doing its job. I could have gone
228 % overboard with package options, but didn't because I was more interested
229 % in a short efficient tool which doesn't load half of the tools and/or
230 % graphics bundle. It still works under both \LaTeX\ 2.09 and \LaTeXe.
231 %
232 %
233 % \section{User manual}
234 %
235 % \subsection{Page Size}
236 %
237 % These macros make it easy to set page margins for a chosen paper size.
238 % Actual dimensions of the most common paper sizes are stored and need
239 % not be remembered.
240 %
241 % Two sided printing is supported, meaning that if on odd pages the left
242 % margin is, say, 30mm and the right margin is 20mm, it will be vice
243 % versa on even pages. This gives equal margins on the outer and equal
244 % margins on the inner edge of the paper, as expected e.g.\ for a book.
245 %
246 % \package{vmargin} is designed to be reasonably restricted in both memory
247 % usage and processing time, so that the common task of setting margins
248 % is not too distracting. If you are looking for something fancier try the
249 % \package{geometry} package.
250 %
251 % The basic procedure of using \package{vmargin} is to first set a paper size,
252 % and then to set the margins. The margin setting functions depend on the paper
253 % size. Setting the paper size and margins are two independent operations,
254 % i.e.\ setting the paper size does not directly affect the margins but will
255 % affect the following margin setting command.
256 %
257 % \DescribeMacro{\setpapersize}
258 % The size of the paper can be set with
259 % ^^A
260 % \begin{pckcmd}
261 % |\setpapersize{|\meta{size}|}|
262 % \end{pckcmd}
263 % ^^A
264 % \meta{size} can be A0, A1, ..., A9, B0, B1, ..., B9, C0, ..., C9, USletter,
265 % USlegal, and USexecutive. The metric paper sizes are not stored but
266 % calculated. |\setpapersize| by default sets the orientation to portrait.
267 %
268 % Landscape format is selected by using the optional argument
269 % ^^A
270 % \begin{pckcmd}
271 % |\setpapersize[landscape]{|\meta{size}|}|
272 % \end{pckcmd}
273 % ^^A
274 % which swaps the width and height dimensions of the paper.
275 % \begin{pckcmd}
276 % |\setpapersize[portrait]{|\meta{size}|}|
277 % \end{pckcmd}
278 % is allowed but is the default.
279 %
280 % If you have a size which is not pre-defined use
281 % ^^A
282 % \begin{pckcmd}
283 % |\setpapersize{custom}{|\meta{width}|}{|\meta{height}|}|
284 % \end{pckcmd}
285 % ^^A
286 % For \meta{width} and \meta{height} insert the respective dimensions of your
287 % paper.
288 %
289 % \DescribeMacro{\PaperWidth}
290 % \DescribeMacro{\PaperHeight}
291 % |\setpapersize| stores the actual dimensions of the paper in the length
292 % variables
293 % ^^A
294 % \begin{pckcmd}
295 % |\PaperWidth| \\
296 % |\PaperHeight|
297 % \end{pckcmd}
298 %
299 % \DescribeMacro{\ifLandscape}
300 % which can be used further, if desired.
301 % ^^A
302 % \begin{pckcmd}
303 % |\ifLandscape|
304 % \end{pckcmd}
305 % ^^A
306 % yields true if a landscape format is selected. Do not write to
307 % |\PaperWidth|, |\PaperHeight|, or call |\Landscapetrue| or |\Landscapefalse|,
308 % it will not work!!
309 %
310 % \package{vmargin} detects when it runs under pdflatex, and in that case also
311 % sets the pdf page size (variables |\pdfpagewidth| and |\pdfpageheight|).
312 %
313 % Default for the paper size is A4 portrait.
314 %
315 %
316 % \subsection{Margins}
317 %
318 % \DescribeMacro{\setmargins}
319 % Once the paper size is selected, margins can be set with
320 % \begin{pckcmd}
321 % |\setmargins{|\meta{leftmargin}|}{|\meta{topmargin}^^A
322 % |}{|\meta{textwidth}|}{|\meta{textheight}|}%| \\
323 % | {|\meta{headheight}|}{|\meta{headsep}|}{|\meta{footheight}^^A
324 % |}{|\meta{footskip}|}|
325 % \end{pckcmd}
326 % or with
327 % \begin{pckcmd}
328 % |\setmarginsrb{|\meta{leftmargin}|}{|\meta{topmargin}^^A
329 % |}{|\meta{rightmargin}|}{|\meta{bottommargin}|}%| \\
330 % | {|\meta{headheight}|}{|\meta{headsep}^^A
331 % |}{|\meta{footheight}|}{|\meta{footskip}|}|
332 % \end{pckcmd}
333 % \DescribeMacro{\setmarginsrb}
334 % In the latter case |\textwidth| and |\textheight| are calculated using the
335 % width and height of the selected paper such as to effectively result in
336 % \meta{rightmargin} and \meta{bottommargin}. The first four parameters of the
337 % above two commands are used to set |\oddsidemargin|, |\evensidemargin|,
338 % |\textwidth|, |\topmargin|, and |\textheight|.
339 %
340 % \DescribeMacro{\setmargnohf}
341 % \DescribeMacro{\setmargnohfrb}
342 % |\setmargnohf|, |\setmargnohfrb|
343 % provide a page with no header and footer. They work the same as
344 % |\setmargins|, |\setmarginsrb| except that they only need the first 4
345 % parameters. The last 4 parameters are set to 0pt. These 2 commands set
346 % the pagestyle to empty (|\pagestyle{empty}|) as there is no space for
347 % headers or footers.
348 % \begin{pckcmd}
349 % |\setmargnohf{|\meta{leftmargin}|}{|\meta{topmargin}^^A
350 % |}{|\meta{textwidth}|}{|\meta{textheight}|}%| \\
351 % |\setmargnohfrb{|\meta{leftmargin}|}{|\meta{topmargin}^^A
352 % |}{|\meta{rightmargin}|}{|\meta{bottommargin}|}%|
353 % \end{pckcmd}
354 %
355 % \DescribeMacro{\setmarg}
356 % \DescribeMacro{\setmargrb}
357 % |\setmarg|, |\setmargrb|
358 % are the same as |\setmargnohf|, |\setmargnohfrb| except that
359 % \meta{headheight}, \meta{headsep}, \meta{footheight}, and \meta{footskip} are
360 % unchanged instead of being set to 0pt.
361 % \begin{pckcmd}
362 % |\setmarg{|\meta{leftmargin}|}{|\meta{topmargin}^^A
363 % |}{|\meta{textwidth}|}{|\meta{textheight}|}%| \\
364 % |\setmargrb{|\meta{leftmargin}|}{|\meta{topmargin}^^A
365 % |}{|\meta{rightmargin}|}{|\meta{bottommargin}|}%|
366 % \end{pckcmd}
367 %
368 % Example:
369 %
370 % A4 paper, left margin 30mm, top, right, and bottom margin 20mm
371 % each, no headers or footers:
372 % \begin{pckcmd}
373 % |\setpapersize{A4}| \\
374 % |\setmarginsrb{30mm}{20mm}{20mm}{20mm}{0pt}{0mm}{0pt}{0mm}| \\
375 % |\pagestyle{empty}|
376 % \end{pckcmd}
377 % The same settings would result with:
378 % \begin{pckcmd}
379 % |\setpapersize{A4}| \\
380 % |\setmargnohfrb{30mm}{20mm}{20mm}{20mm}|
381 % \end{pckcmd}
382 %
383 % Defaults are
384 % \begin{pckcmd}
385 % |\setmarginsrb{35mm}{20mm}{25mm}{15mm}{12pt}{11mm}{0pt}{11mm}|
386 % \end{pckcmd}
387 % or with package option nohf
388 % \begin{pckcmd}
389 % |\setmargnohfrb{35mm}{20mm}{25mm}{15mm}|
390 % \end{pckcmd}
391 %
392 %
393 % \subsection{Dealing with \TeX's Margin Offset}
394 %
395 % The default top and left margins of TeX are +1in. |\setmargXXX| call
396 % ^^A
397 % |\margin@offset|
398 % ^^A
399 % \DescribeMacro{\margin@offset}
400 % \DescribeMacro{\hoffset}
401 % \DescribeMacro{\voffset}
402 % which initialises |\hoffset|, |\voffset| to -1truein and |\oddsidemargin|,
403 % |\evensidemargin|, |\topmargin| to 0in. |\setmargXXX| then add the given
404 % dimensions to |\topmargin|, |\oddsidemargin|, |\evensidemargin|. In some
405 % cases it might be desired to use |\XXXmargin| instead of |\Xoffset| for
406 % compensation. This can be achieved by telling |\margin@offset| to
407 % initialise |\Xoffset| to 0in and |\XXXmargin| to -1truein.
408 % This is what
409 % %^^A
410 % |\shiftmargins|
411 % %^^A
412 % does.
413 %
414 % If |\margin@offset| is already defined at the time \package{vmargin} is loaded
415 % it is \emph{not} redefined! Therefore if |\margin@offset| is defined before
416 % \package{vmargin} is loaded the above mentioned compensation can be replaced
417 % by a different mechanism. In any case |\setmargXXX| call |\margin@offset| and
418 % then expect that |\XXXmargin| are set to useful values. |\Xoffset| are not
419 % touched by |\setmargXXX|. |\margin@offset| should be defined in a separate
420 % file which is included \emph{before} \package{vmargin}, i.e. appears in the
421 % list of document-substyles of the |\documentstyle| command before
422 % \package{vmargin}.
423 % %^^A
424 % Any better way of doing this? (grumble)
425 %
426 % Example:
427 % \begin{pckcmd}
428 % |\documentclass[...]{...}| \\
429 % |\usepackage{...,margins,vmargin,...}|
430 % \end{pckcmd}
431 % if |\margin@offset| is defined in a file called margins.sty.
432 %
433 % or with \LaTeX\ 2.09:
434 % \begin{pckcmd}
435 % |\documentstyle[...,margins,vmargin,...]{...}|
436 % \end{pckcmd}
437 %
438 %
439 % \subsection{\LaTeXe}
440 %
441 % This package now uses some of the new \LaTeX2e\ features for package
442 % programming. It will still work with \LaTeX\ 2.09 (in which case the new
443 % features are not used).
444 %
445 % \LaTeX2e\ (unless in compatibility mode) does not know |\footheight| any
446 % more. \package{vmargin} does not set this variable if it does not exist, and sets
447 % it if it does. As |\footheight| was not used by \LaTeX\ 2.09 all this has
448 % little significance.
449 %
450 % \LaTeXe\ now has the dimensions |\paperwidth|, |\paperheight| which
451 % hold the size of the paper. |\PaperWidth|, |\PaperHeight| are copied
452 % into |\paperwidth|, |\paperheight| if the latter exist. This makes
453 % \package{vmargin} work correctly with anything that expects |\paperwidth|,
454 % |\paperheight| to be set properly. The names |\PaperWidth|, |\PaperHeight|
455 % had been chosen in the first place to avoid clashes with style files that
456 % also use these names (namely \package{pageframe.sty}).
457 %
458 % The following package options are available with \LaTeXe:
459 %
460 % \begin{description}
461 % \item[shiftmargins] \MargWord{shiftmargins}
462 % Same as |\shiftmargins|.
463 % \item[portrait] \MargWord{portrait}
464 % Keep the default of a portrait page layout.
465 % \item[landscape] \MargWord{landscape}
466 % Change the default page orientation to landscape.
467 % Note: using |\setpapersize|
468 % after |\usepackage| causes package option landscape to be ignored.
469 % \item[A4, etc] \MargWord{A4}
470 % Same as using |\setpapersize[...]{...}|.
471 % Note: |\setpapersize| always sets the orientation to
472 % portrait unless landscape is given as an optional argument to
473 % |\setpapersize|.
474 % \item[nohf] \MargWord{nohf}
475 % Do not make space for header and footer lines; this also
476 % sets the pagestyle to |empty|.
477 % \end{description}
478 %
479 % All unknown options are treated as a paper size, if necessary
480 % generating an error that the requested paper size is not defined.
481 %
482 %
483 % \subsection{Inclusion in \TeX\ formats}
484 %
485 % This file may be loaded in initex before dumping the format, by typing
486 % \begin{verbatim}
487 % \makeatletter
488 % \input vmargin.sty
489 % \makeatother
490 % \end{verbatim}\vspace{-\bigskipamount}
491 % Be aware that this generates a non-standard format. It is really only useful
492 % for slow computers. This feature has not been tested with \LaTeXe.
493 %
494 %
495 % \subsection{Hints for using pageframe.sty}
496 %
497 % \package{vmargin.sty} and \package{pageframe.sty} can be used together if the
498 % following points are considered:
499 %
500 % \package{vmargin} uses |\hoffset| and |\voffset| and writes negative values
501 % into it, \package{pageframe} expects them to be zero to give a 1in space
502 % on the left and the top where it prints additional information. Initially,
503 % set both to 0mm (in the preamble of your text) and adjust them later on.
504 %
505 % \package{pageframe} needs to know the trimmed height of the paper (= the
506 % height of the ``page frame''). Unless the trimmed(!) size of the paper is
507 % equivalent to one of the standard paper sizes (unlikely\ldots) the size
508 % should be specified with
509 %
510 % |\setpapersize{custom}{|\meta{width}|}{|\meta{height}|}|
511 %
512 % The correct height of the trimmed page can then be given to
513 % \package{pageframe} using
514 %
515 % |\paperheight{\PaperHeight}|
516 %
517 % and the margins of the final product (inside the page frame) can be
518 % specified using |\setmargXXX|.
519 %
520 % Warning: if |\setmargXXXrb| is used the 3rd parameter (right margin) is
521 % ignored. Instead, the dimension of the right margin has to be assigned to
522 % |\evensidemargin|. This is because \package{pageframe} re-defines the meaning
523 % of |\evensidemargin| to be the right margin of your text, on all pages.
524 %
525 % Remember: all these assignments and macro calls have to be in the
526 % preamble of the document.
527 %
528 %
529 % \subsection{Bugs and To Do}
530 %
531 % I have not tested this with older versions of \LaTeXe\ because I don't
532 % have any. If there are any problems please let me know and I'll do
533 % something about it.
534 %
535 % The way the metric paper sizes are stored takes up a lot of space.
536 % A metric size could be computed by |\setpapersize|.
537 %
538 % If you have any comments (positive or negative) please let me know!
539 %
540 %
541 % \subsection{Summary}
542 %
543 % \begin{verbatim}
544 % new lengths:
545 % \PaperWidth (read-only)
546 % \PaperHeight (read-only)
547 %
548 % new ifs:
549 % \ifLandscape (read-only)
550 %
551 % new macros:
552 % \setpapersize[<orientation>]{<size>},
553 % \setpapersize[<orientation>]{custom}{<width>}{<height>}
554 % <orientation> (optional) = landscape or portrait (default)
555 % <size> = A4, B5, ...
556 % <width>, <height> = actual dimensions of the paper
557 % \setmargins{leftmargin}{topmargin}{textwidth}{textheight}%
558 % {headheight}{headsep}{footheight}{footskip}
559 % \setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%
560 % {headheight}{headsep}{footheight}{footskip}
561 % \setmargnohf{leftmargin}{topmargin}{textwidth}{textheight}
562 % \setmargnohfrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
563 % \setmarg{leftmargin}{topmargin}{textwidth}{textheight}
564 % \setmargrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
565 %
566 % \margin@offset
567 % \shiftmargins
568 %
569 % LaTeX2e package options:
570 % shiftmargins
571 % portrait
572 % landscape
573 % nohf
574 % all other options are treated as paper sizes
575 % \end{verbatim}\vspace{-\bigskipamount}
576 %
577 %
578 % \DoNotIndex{\ ,\.,\_}%^^A DOES NOT WORK!!
579 % \DoNotIndex{\@ifnextchar,\@ifundefined,\@nameuse,\CurrentOption}
580 % \DoNotIndex{\DeclareOption,\NeedsTeXFormat,\PackageError}
581 % \DoNotIndex{\ProcessOptions,\ProvidesPackage,\advance,\begingroup}
582 % \DoNotIndex{\catcode,\count,\csname,\def,\dimen,\edef,\else}
583 % \DoNotIndex{\endcsname,\endgroup,\endinput,\evensidemargin}
584 % \DoNotIndex{\everyjob,\expandafter,\fi,\footheight,\footskip}
585 % \DoNotIndex{\headheight,\headsep,\if,\ifnum,\let,\loop}
586 % \DoNotIndex{\newcommand,\newdimen,\newif,\noexpand,\oddsidemargin}
587 % \DoNotIndex{\pagestyle,\relax,\repeat,\space,\string,\textheight}
588 % \DoNotIndex{\textwidth,\the,\topmargin,\typeout,\usename,\xdef}
589 % \DoNotIndex{\z@}
590 %
591 % \StopEventually{}
592 %
593 %
594 %
595 % \section{Implementation}
596 %
597 % \begin{macrocode}
598 %<*package>
599 % \end{macrocode}
600 %
601 %
602 % We use macros for the version info here.
603 %
604 % ^^A search tag: mAcRoVeRsIoN
605 % \begin{macrocode}
606 %\def\filename{Vmargin}
607 \def\filename{vmargin}
608 \def\fileversion{V2.5}
609 \def\filedate{2004/07/15}
610 % \end{macrocode}
611 %
612 % Allow \package{vmargin} to be |input| more than once.
613 % Important for embedding in formats.
614 % \begin{macrocode}
615 \@ifundefined{Vmargin}{}{\endinput}
616 % \end{macrocode}
617 %
618 % Make use of \LaTeX2e\ commands, but only if we are actually running with it.
619 % \begin{macrocode}
620 \@ifundefined{documentclass}{
621 \edef\Vmargin{Style `\filename', \fileversion, \filedate}
622 \expandafter\everyjob\expandafter{\the\everyjob\typeout{\Vmargin}}
623 \typeout{\Vmargin}
624 }{
625 \NeedsTeXFormat{LaTeX2e}[1994/06/01]
626 \edef\Vmargin{\filedate\space\fileversion\space set document margins (VK)}
627 \ProvidesPackage{\filename}[\Vmargin]
628 \edef\Vmargin{Package: \filename\space\Vmargin}
629 \expandafter\everyjob\expandafter{\the\everyjob\typeout{\Vmargin}}
630 \typeout{\Vmargin}
631 }
632 % \end{macrocode}
633 %
634 %
635 % \begin{macro}{\PaperWidth}
636 % \begin{macro}{\PaperHeight}
637 % \begin{macro}{\ifLandscape}
638 % New lengths for paper width and height, and a new if, as flag for using
639 % landscape orientation.
640 %
641 % \begin{macrocode}
642 \newdimen\PaperWidth
643 \newdimen\PaperHeight
644 \newif\ifLandscape
645 % \end{macrocode}
646 % \end{macro}
647 % \end{macro}
648 % \end{macro}
649 %
650 %
651 % \begin{macro}{\setpapersize}
652 % Setting a paper size. Kind of a data base lookup. Well, it looks up whether
653 % the control sequence is defined\ldots
654 %
655 % When running pdflatex we also set the pdf page size (|\pdfpagewidth| and
656 % |\pdfpageheight|).
657 % \begin{macrocode}
658 \def\setpapersize{\@ifnextchar[{\@@setps}{\@@setps[portrait]}}
659 \def\@@setps[#1]{%
660 \@ifundefined{po@#1}{\@name@err{#1}}{\@nameuse{po@#1}}%
661 \@@@setps}
662 \def\@@@setps#1{%
663 \@ifundefined{paper@#1}{\@name@err{#1}}{}%
664 \csname paper@#1\endcsname}
665 % \usename{paper@#1} inside arg to \@ifundefined does not work
666 % with papersize "custom".
667 \def\po@portrait{\Landscapefalse}
668 \def\po@landscape{\Landscapetrue}
669 \def\@po@{\ifLandscape
670 \dimen0\PaperWidth\PaperWidth\PaperHeight\PaperHeight\dimen0
671 \fi
672 \@ifundefined{paperwidth}{}{\paperwidth\PaperWidth}%
673 \@ifundefined{paperheight}{}{\paperheight\PaperHeight}%
674 \@ifundefined{pdfpagewidth}{}{\pdfpagewidth\PaperWidth}%
675 \@ifundefined{pdfpageheight}{}{\pdfpageheight\PaperHeight}%
676 }
677 \@ifundefined{PackageError}{
678 \def\@name@err#1{%
679 \typeout{*****> \string\setpapersize: illegal parameter: #1}}
680 }{
681 \def\@name@err#1{\PackageError{\filename}%
682 {Paper size or orientation unknown: #1}{}}
683 }
684 % \end{macrocode}
685 % \end{macro}
686 %
687 %
688 % \begin{macro}{\@defmetricpaper}
689 % Calculate smaller sizes from largest one.
690 %
691 % \begin{macrocode}
692 \def\@defmetricpaper#1#2#3{%
693 \begingroup
694 \count0=0
695 \def\w{\dimen1 }\def\h{\dimen2 }\def\s{\dimen3 }%
696 \w#2\h#3
697 \def\l{11}
698 \loop
699 \begingroup
700 \def\t{\the\count0}
701 \catcode`\t=11 % letter
702 \expandafter\xdef\csname paper@#1\the\count0\endcsname{%
703 \PaperWidth\the\w\PaperHeight\the\h\noexpand\@po@}
704 \endgroup
705 \s\w\w.5\h\h\s
706 \ifnum\the\count0<9
707 \advance\count0 by 1
708 \repeat
709 \endgroup
710 }
711 % \end{macrocode}
712 % \end{macro}
713 %
714 % Pre-defined paper/envelope sizes:
715 %
716 % A0, A1, A2, ..., A9, B0, B1, ..., B9, C0, C1, ..., C9
717 % \begin{macrocode}
718 \@defmetricpaper{A}{840.9mm}{1189.2mm}
719 \@defmetricpaper{B}{1000mm}{1414mm}
720 \@defmetricpaper{C}{917mm}{1297mm}
721 % \end{macrocode}
722 %
723 % delete definition to save memory
724 % \begin{macrocode}
725 \let\@defmetricpaper=\relax
726 % \end{macrocode}
727 %
728 % USletter, USlegal, USexecutive
729 % \begin{macrocode}
730 \def\paper@USletter{\PaperWidth 8.5in \PaperHeight 11in \@po@}
731 \def\paper@USlegal{\PaperWidth 8.5in \PaperHeight 14in \@po@}
732 \def\paper@USexecutive{\PaperWidth 7.25in\PaperHeight 10.5in \@po@}
733 % \end{macrocode}
734 %
735 % custom
736 % \begin{macrocode}
737 \def\paper@custom#1#2{\PaperWidth#1\PaperHeight#2\@po@}
738 % \end{macrocode}
739 %
740 %
741 % \begin{macro}{\margin@offset}
742 % Initialise left margins (odd and even) and |\hoffset|, |\voffset|.
743 % Compensates for the +1in/+1in top/left corner used by \TeX\
744 % by either reducing the margins or |\hoffset|, |\voffset| by 1truein.
745 % This macro is only defined here if it is not already defined! Define this
746 % macro before loading \package{vmargin} to use your own definition.
747 %
748 % \begin{macrocode}
749 \@ifundefined{margin@offset}{%
750 \def\margin@offset{%
751 \if@shiftmargins
752 \oddsidemargin -1truein\evensidemargin\oddsidemargin\topmargin\oddsidemargin
753 \hoffset\z@\voffset\z@
754 \else
755 \oddsidemargin\z@\evensidemargin\z@\topmargin\z@
756 \hoffset -1truein\voffset\hoffset
757 \fi
758 }}{}
759 % \end{macrocode}
760 % \end{macro}
761 % \begin{macro}{\shiftmargins}
762 % A new if, as flag for when to use margins instead of |\hoffset|/|\voffset| to
763 % compensate, and a user-command to set the flag.
764 % \begin{macrocode}
765 \newif\if@shiftmargins
766 \@shiftmarginsfalse % this MUST be default (pageframe.sty)
767 \def\shiftmargins{\@shiftmarginstrue}
768 % \end{macrocode}
769 % \end{macro}
770 %
771 %
772 % Setting margins
773 %
774 % \begin{macro}{\setmargins}
775 % |\setmargins{leftmargin}{topmargin}{textwidth}{textheight}% |\\
776 % | {headheight}{headsep}{footheight}{footskip}|
777 %
778 % \begin{macrocode}
779 \newcommand\setmargins[8]{%
780 \margin@offset
781 \advance\oddsidemargin #1
782 \advance\evensidemargin \PaperWidth % = paperwidth - left - width
783 \advance\evensidemargin -#1
784 \advance\evensidemargin -#3
785 \advance\topmargin #2
786 \textwidth #3
787 \textheight #4
788 \headheight #5
789 \headsep #6
790 \@ifundefined{footheight}{}{\footheight=#7}%
791 \footskip #8
792 \chk@dimen{#1}{#2}{#3}{#4}%
793 }
794 % \end{macrocode}
795 % \end{macro}
796 %
797 % \begin{macro}{\setmarginsrb}
798 % |\setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%|\\
799 % | {headheight}{headsep}{footheight}{footskip}|
800 %
801 % \begin{macrocode}
802 \newcommand\setmarginsrb[8]{%
803 \margin@offset
804 \textwidth \PaperWidth % = paperwidth
805 \advance\textwidth -#1 % - left - right
806 \advance\textwidth -#3
807 \textheight \PaperHeight % = paperheight - top
808 \advance\textheight -#2 % - headheight
809 \advance\textheight -#5 % - headsep
810 \advance\textheight -#6 % - footskip - bottom
811 \advance\textheight -#8
812 \advance\textheight -#4
813 \advance\oddsidemargin #1
814 \advance\evensidemargin \PaperWidth % = paperwidth - left - width
815 \advance\evensidemargin -#1
816 \advance\evensidemargin -\textwidth
817 \advance\topmargin #2
818 \headheight #5
819 \headsep #6
820 \@ifundefined{footheight}{}{\footheight=#7}%
821 \footskip #8
822 \chk@dimen{#1}{#2}{#3}{#4}%
823 }
824 % \end{macrocode}
825 % \end{macro}
826 %
827 % \begin{macro}{\setmargnohf}
828 % |\setmargnohf{leftmargin}{topmargin}{textwidth}{textheight}| \\
829 % headheight, headsep, footheight, footskip set to 0pt
830 % \begin{macrocode}
831 \newcommand\setmargnohf[4]{%
832 \setmargins{#1}{#2}{#3}{#4}\z@\z@\z@\z@
833 \pagestyle{empty}}
834 % \end{macrocode}
835 % \end{macro}
836 %
837 % \begin{macro}{\setmargnohfrb}
838 % |\setmargnohfrb{leftmargin}{topmargin}{rightmargin}{bottommargin}| \\
839 % headheight, headsep, footheight, footskip set to 0pt
840 % \begin{macrocode}
841 \newcommand\setmargnohfrb[4]{%
842 \setmarginsrb{#1}{#2}{#3}{#4}\z@\z@\z@\z@
843 \pagestyle{empty}}
844 % \end{macrocode}
845 % \end{macro}
846 %
847 % \begin{macro}{\setmarg}
848 % |\setmarg{leftmargin}{topmargin}{textwidth}{textheight}| \\
849 % headheight, headsep, footheight, footskip unchanged
850 % \begin{macrocode}
851 \newcommand\setmarg[4]{%
852 \setmargins{#1}{#2}{#3}{#4}%
853 \headheight\headsep\footheight\footskip}
854 % \end{macrocode}
855 % \end{macro}
856 %
857 % \begin{macro}{\setmargrb}
858 % |\setmargrb{leftmargin}{topmargin}{rightmargin}{bottommargin}| \\
859 % headheight, headsep, footheight, footskip unchanged
860 % \begin{macrocode}
861 \newcommand\setmargrb[4]{%
862 \setmarginsrb{#1}{#2}{#3}{#4}%
863 \headheight\headsep\footheight\footskip}
864 % \end{macrocode}
865 % \end{macro}
866 %
867 %
868 % \begin{macro}{\chk@dimen}
869 % A brief plausability check.\\
870 % h-warning:\\
871 % \null\quad if [leftmarg + textwidth $>$ paperwidth] resp.\\
872 % \null\quad if [leftmarg + rightmarg $>$ paperwidth].\\
873 % v-warning:\\
874 % \null\quad if [topmarg + textheight $>$ paperheight] resp.\\
875 % \null\quad if [topmarg + bottommarg $>$ paperheight].
876 % \begin{macrocode}
877 \def\chk@dimen#1#2#3#4{%
878 \dimen0= #1
879 \advance\dimen0 by#3
880 \advance\dimen0 -\PaperWidth
881 \dimen1= #2
882 \advance\dimen1 by#4
883 \advance\dimen1 \headheight
884 \advance\dimen1 \headsep
885 \advance\dimen1 \footskip
886 \advance\dimen1 -\PaperHeight
887 \chk@dimen@err
888 }
889 % \end{macrocode}
890 % \end{macro}
891 %
892 % \begin{macro}{\chk@dimen@err}
893 % Make this work with both \LaTeX\ 2.09 and \LaTeXe.
894 % \begin{macrocode}
895 \@ifundefined{PackageError}{
896 \def\chk@dimen@err{%
897 \ifnum\dimen0>\z@\typeout{vmargin Warning: Horizontal dimensions
898 exceed paper width by \the\dimen0}\fi
899 \ifnum\dimen1>\z@\typeout{vmargin Warning: Vertical dimensions
900 exceed paper height by \the\dimen1}\fi
901 }
902 }{
903 \def\chk@dimen@err{%
904 \ifnum\dimen0>\z@\PackageError{\filename}{%
905 Horizontal dimensions exceed paper width by \the\dimen0}{}\fi
906 \ifnum\dimen1>\z@\PackageError{\filename}{%
907 Vertical dimensions exceed paper height by \the\dimen1}{}\fi
908 }
909 }
910 % \end{macrocode}
911 % \end{macro}
912 %
913 %
914 % Defaults, and \LaTeXe\ package options (ignored for 2.09).
915 % \begin{macrocode}
916 \setpapersize{A4}
917 \def\@hf@dflt{}
918 \@ifundefined{DeclareOption}{
919 }{
920 \DeclareOption{shiftmargins}{\shiftmargins}
921 \DeclareOption{portrait}{\Landscapefalse}
922 \DeclareOption{landscape}{\Landscapetrue}
923 \DeclareOption{nohf}{\def\@hf@dflt{y}}
924 \DeclareOption*{\@@@setps{\CurrentOption}}
925 \ProcessOptions\relax % process options in order of declaration!
926 }
927 \if y\@hf@dflt
928 \setmargnohfrb{35mm}{20mm}{25mm}{15mm}%
929 \else
930 \setmarginsrb{35mm}{20mm}{25mm}{15mm}{12pt}{11mm}{0pt}{11mm}%
931 \fi
932 % \end{macrocode}
933 %
934 %
935 % \begin{macrocode}
936 %</package>
937 % \end{macrocode}
938 %
939 %
940 % \Finale
941 %
942 % \iffalse
943 % %% EOF vmargin.dtx
944 % %%----------------------------------------------------------------------------
945 % \fi