Displaying Page Layout Variables: Kent Mcpherson A.O. 2000/09/25
Displaying Page Layout Variables: Kent Mcpherson A.O. 2000/09/25
Displaying Page Layout Variables: Kent Mcpherson A.O. 2000/09/25
Introduction
The implementation
This package prints a figure to illustrate the layout that is implemented by the
document class. In the figure several words appear. They are stored in control
sequences to be able to select a different language.
hpackagei
\DeclareOption{dutch}{%
3
\def\Headertext{Kopregel}
4
\def\Bodytext{Broodtekst}
5
\def\Footertext{Voetregel}
6
\def\MarginNotestext{Marge\\Notities}
7
\def\oneinchtext{een inch}
8
\def\notshown{niet getoond}
9
}
10 \DeclareOption{german}{%
11
\def\Headertext{Kopfzeile}
12
\def\Bodytext{Haupttext}
13
\def\Footertext{Fu{\ss}zeile}
14
\def\MarginNotestext{Rand-\\ notizen}
15
\def\oneinchtext{ein Zoll}
16
\def\notshown{ohne Abbildung}
17
}
18 \DeclareOption{ngerman}{\ExecuteOptions{german}}
1
Converted
4i
6
i
?
?
?Header
6
6
i
Margin
Notes
Body
i
-
10
i-
11
?
Footer
1i-
1
3
5
7
9
11
2
4
6
8
10
\DeclareOption{english}{%
\def\Headertext{Header}
21
\def\Bodytext{Body}
22
\def\Footertext{Footer}
23
\def\MarginNotestext{Margin\\Notes}
24
\def\oneinchtext{one inch}
25
\def\notshown{not shown}
26
}
27 \DeclareOption{french}{%
28
\def\Headertext{Ent\^{e}te}
29
\def\Bodytext{Corps}
30
\def\Footertext{Pied de page}
31
\def\MarginNotestext{Marge\\Notes}
32
\def\oneinchtext{un pouce}
33
\def\notshown{non affich\{e}}
34
}
35 \DeclareOption{francais}{\ExecuteOptions{french}}
36 \DeclareOption{spanish}{%
37
\def\Headertext{Encabezamiento}
38
\def\Bodytext{Cuerpo}
39
\def\Footertext{Pie de p\agina}
40
\def\MarginNotestext{Notas\\ Marginales}
41
\def\oneinchtext{una pulgada}
42
\def\notshown{no mostradas}
43
}
44 \DeclareOption{portuguese}{%
45
\def\Headertext{Cabe\c{c}alho}
46
\def\Bodytext{Corpo}
47
\def\Footertext{Rodap\e}
48
\def\MarginNotestext{Notas\\ Marginais}
49
\def\oneinchtext{uma polegada}
50
\def\notshown{n\~ao mostradas}
51
}
52 \DeclareOption{brazilian}{%
53
\def\Headertext{Cabe\c{c}alho}
54
\def\Bodytext{Corpo}
55
\def\Footertext{Rodap\e}
56
\def\MarginNotestext{Notas\\ Marginais}
57
\def\oneinchtext{uma polegada}
58
\def\notshown{n\~ao mostradas}
59
}
60 \DeclareOption{italian}{%
61
\def\Headertext{Testatina}
62
\def\Bodytext{Corpo}
63
\def\Footertext{Piedino}
64
\def\MarginNotestext{Note\\ Marginali}
65
\def\oneinchtext{un pollice}
66
\def\notshown{non mostrato}
67
}
19
20
This package has an option verbose. Using it will make the command \layout
type some of the parameters on the terminal.
68
69
\DeclareOption{verbose}{\let\LayOuttype\typeout}
\DeclareOption{silent}{\let\LayOuttype\@gobble}
The normal behaviour of this package when showing the values of the parameters is to truncate them. However, if you want to see the real parameter values
you can use the option reals to get that effect.
\def\lay@value{}
\DeclareOption{integers}{%
72
\renewcommand*{\lay@value}[2]{%
73
\expandafter\number\csname #1@#2\endcsname pt}}
74 \DeclareOption{reals}{%
75
\renewcommand*{\lay@value}[2]{\the\csname #2\endcsname}}
70
71
The default language is English, the default mode is silent and the default way
of showing parameter values is to use integers.
76
77
\LayOutbs
\ConvertToCount
\ExecuteOptions{english,silent,integers}
\ProcessOptions
\newcommand\LayOutbs{}
\chardef\LayOutbs\\
\def\ConvertToCount#1#2{%
#1=#2
\divide #1 by 65536}
The result of this is that the count register holds the value of the length register
in points.
\SetToHalf
\SetToQuart
\Identify
\def\SetToHalf#1#2{#1=#2\relax\divide#1by\tw@}
\def\SetToQuart#1#2{#1=#2\relax\divide#1by4}
\InsideHArrow
This macro is used to produce two horizontal arrows inside a box. The argument
gives the width of the box.
89
\def\InsideHArrow#1{{%
\ArrowLength = #1
\divide\ArrowLength by \tw@
92
\advance\ArrowLength by -10
93
\advance\PositionX by -10
94
\ifnum\ArrowLength<\z@
95
\put(\PositionX,\PositionY){\vector(1,0){-\ArrowLength}}
96
\advance\PositionX by 20
97
\put(\PositionX,\PositionY){\vector(-1,0){-\ArrowLength}}
98
\else
99
\put(\PositionX,\PositionY){\vector(-1,0){\ArrowLength}}
100
\advance\PositionX by 20
101
\put(\PositionX,\PositionY){\vector(+1,0){\ArrowLength}}
102
\fi
103 }}
90
91
\InsideVArrow
This macro is used to produce two vertical arrows inside a box. The argument
gives the height of the box.
\def\InsideVArrow#1{{%
\ArrowLength = #1
106
\divide\ArrowLength by \tw@
107
\advance\ArrowLength by -10
108
\advance\PositionY by -10
109
\put(\PositionX,\PositionY){\vector(0,-1){\ArrowLength}}
110
\advance\PositionY by 20
111
\put(\PositionX,\PositionY){\vector(0,+1){\ArrowLength}}
112 }}
104
105
\OutsideHArrow
This macro is used to produce two horizontal arrows to delimit a length. The first
argument is the position for the right arrow, the second argument gives the length
and the third specifies the length of the arrows.
\def\OutsideHArrow#1#2#3{{%
\PositionX = #1
115
\advance\PositionX by #3
116
\put(\PositionX,\PositionY){\vector(-1,0){#3}}
117
\PositionX = #1 \advance\PositionX-#2
118
\advance\PositionX by -#3
119
\put(\PositionX,\PositionY){\vector(+1,0){#3}}
120 }}
113
114
\OutsideVArrow
This macro is used to produce two vertical arrows to delimit a length. The first
argument is the position for the lower arrow, the second argument gives the length
and the third and fourth specify the lenghts of the lower and upper arrow.
\def\OutsideVArrow#1#2#3#4{{%
\PositionY = #1
123
\advance\PositionY by -#3
124
\put(\PositionX,\PositionY){\vector(0,+1){#3}}
125
\PositionY = #1
126
\advance\PositionY#2
127
\advance\PositionY#4
121
122
\put(\PositionX,\PositionY){\vector(0,-1){#4}}
128
129
\Show
\def\Show#1#2{\LayOutbs #2 = \lay@value{#1}{#2}}
\oneinch
}}
Macro used in the table that shows the setting of the parameters.
130
\Type
\def\Type#1#2{%
\LayOuttype{#2 = \lay@value{#1}{#2}}}
\newcount\oneinch
\oneinch=72
136
\cnt@hoffset
\cnt@voffset
the offsets,
\newcount\cnt@hoffset
\newcount\cnt@voffset
141 \ConvertToCount\cnt@hoffset\hoffset
142 \ConvertToCount\cnt@voffset\voffset
139
140
\cnt@textheight
\cnt@textwidth
\cnt@topmargin
\cnt@oddsidemargin
\cnt@evensidemargin
\cnt@headheight
\cnt@headsep
margins,
\newcount\cnt@topmargin
\newcount\cnt@oddsidemargin
147 \newcount\cnt@evensidemargin
145
146
\cnt@marginparsep
\cnt@marginparwidth
\cnt@marginparpush
\newcount\cnt@textheight
\newcount\cnt@textwidth
\newcount\cnt@headheight
\newcount\cnt@headsep
marginal paragraphs,
\newcount\cnt@marginparsep
\newcount\cnt@marginparwidth
152 \newcount\cnt@marginparpush
150
151
\cnt@footskip
\newcount\cnt@footskip
and the height of the footers, which is needed here to display a box, but which
isnt used by LATEX.
\fheight
154
155
\newcount\fheight
\fheight=12
Apart from integer representations of the page layout parameters we also need
registers to store reference values in.
\ref@top
The position of the top of the printable area is one inch below the top of the
paper by default. The value of \ref@top is relative to the lower left corner of the
picture environment that will be used.
156
157
\ref@hoffset
\ref@voffset
\newcount\ref@top
\ref@top=\cnt@paperheight \advance\ref@top by -\oneinch
\newcount\ref@hoffset
\newcount\ref@voffset
The \hoffset and \voffset values are added to the default offset of one inch.
160
161
\ref@hoffset=\cnt@hoffset
\ref@voffset=\cnt@voffset
\advance\cnt@hoffset by \oneinch
\ref@head
\ref@body
\ref@foot
\newcount\ref@body
\ref@margin
\ref@marginwidth
\ref@marginpar
\newcount\ref@head
\newcount\ref@foot
These are different for even and odd pages, so they are computed by \layout.
\newcount\ref@margin
\newcount\ref@marginwidth
169 \newcount\ref@marginpar
167
168
The following are a number of scratch registers, used in the positioning of the
various pices of the picture.
\newcount\Interval
\newcount\ExtraYPos
172 \newcount\PositionX
173 \newcount\PositionY
174 \newcount\ArrowLength
170
171
\lay@getvalues
All values that might change during the document are computed by calling the
macro \lay@getvalues. By default this macro is executed at \begin{document}.
\def\lay@getvalues{%
\ConvertToCount\cnt@textheight\textheight
177
\ConvertToCount\cnt@textwidth\textwidth
178
\ConvertToCount\cnt@topmargin\topmargin
179
\ConvertToCount\cnt@oddsidemargin\oddsidemargin
180
\ConvertToCount\cnt@evensidemargin\evensidemargin
181
\ConvertToCount\cnt@headheight\headheight
182
\ConvertToCount\cnt@headsep\headsep
183
\ConvertToCount\cnt@marginparsep\marginparsep
184
\ConvertToCount\cnt@marginparwidth\marginparwidth
185
\ConvertToCount\cnt@marginparpush\marginparpush
186
\ConvertToCount\cnt@footskip\footskip
187
\ref@head=\ref@top
188
\advance\ref@head by -\ref@voffset
189
\advance\ref@head by -\cnt@topmargin
190
\advance\ref@head by -\cnt@headheight
191
\ref@body=\ref@head
192
\advance\ref@body by -\cnt@headsep
193
\advance\ref@body by -\cnt@textheight
194
\ref@foot=\ref@body
195
\advance\ref@foot by -\cnt@footskip
196
}
197 \AtBeginDocument{\lay@getvalues}
175
176
\computevalues
\layout
\layout*
The command \layout makes the picture and table that display the current settings of the layout parameters.
\newcommand\layout{%
\@ifstar{\lay@getvalues\lay@xlayout}{\lay@xlayout}}
200 \def\lay@xlayout{%
201
\lay@layout
202
\if@twoside
203
\lay@layout
204
\fi}
198
199
\lay@layout
\newcommand\lay@layout{%
\thispagestyle{empty}
\if@twoside
\ifodd\count\z@
\ref@marginwidth=\cnt@oddsidemargin
\ref@marginpar=\oneinch
212
213
214
215
216
217
218
219
220
221
222
\advance\ref@marginpar by \ref@hoffset
\advance\ref@marginpar by \cnt@oddsidemargin
\ref@margin\ref@marginpar
\if@reversemargin
\advance\ref@marginpar by -\cnt@marginparsep
\advance\ref@marginpar by -\cnt@marginparwidth
\else
\advance\ref@marginpar by \cnt@textwidth
\advance\ref@marginpar by \cnt@marginparsep
\fi
\else
\ref@marginwidth=\cnt@evensidemargin
\ref@marginpar=\oneinch
\advance\ref@marginpar by \ref@hoffset
\advance\ref@marginpar by \cnt@evensidemargin
\ref@margin\ref@marginpar
\if@reversemargin
\advance\ref@marginpar by \cnt@textwidth
\advance\ref@marginpar by \cnt@marginparsep
\else
\advance\ref@marginpar by -\cnt@marginparsep
\advance\ref@marginpar by -\cnt@marginparwidth
\fi
\fi
\else
Now we begin the picture environment; dividing all the lengths by two is done
by setting \unitlength to 0.5pt
252
253
254
255
10
\setlength{\unitlength}{.5pt}
\begin{picture}(\cnt@paperwidth,\cnt@paperheight)
\centering
\thicklines
\put(0,0){\framebox(\cnt@paperwidth,\cnt@paperheight){\mbox{}}}
\put(0,\cnt@voffset){\dashbox{10}(\cnt@paperwidth,0){\mbox{}}}
\put(\cnt@hoffset,0){\dashbox{10}(0,\cnt@paperheight){\mbox{}}}
\put(\ref@margin,\ref@head){%
\framebox(\cnt@textwidth,\cnt@headheight)%
{\footnotesize\Headertext}}
\put(\ref@margin,\ref@body){%
\framebox(\cnt@textwidth,\cnt@textheight){\Bodytext}}
the footer
264
265
\put(\ref@margin,\ref@foot){%
\framebox(\cnt@textwidth,\fheight){\footnotesize\Footertext}}
\put(\ref@marginpar,\ref@body){%
\framebox(\cnt@marginparwidth,\cnt@textheight)%
{\footnotesize\shortstack{\MarginNotestext}}}
Then we start putting in arrows to mark the various parameters. From here
we use \thinlines.
269
\thinlines
\PositionX and \PositionY will be the coordinates of the center of the arrow
displaying \textwidth.
270
271
\SetToHalf\PositionX\cnt@textwidth
\advance\PositionX by \ref@margin
The arrow should be a bit above the bottom of the body box.
272
273
\PositionY = \ref@body
\advance\PositionY by 50
\Identify{8}
\InsideHArrow\cnt@textwidth
\SetToHalf\PositionY\cnt@textheight
\advance\PositionY by \ref@body
The x-psition of the arrow is at 4/5 of the width of the body box.
278
279
280
281
\PositionX = \cnt@textwidth
\divide\PositionX by 5
\multiply \PositionX by 4
\advance\PositionX by \ref@margin
\Identify{7}
\InsideVArrow\cnt@textheight
The \hoffset,
284
285
286
287
\PositionY = 50
\SetToHalf\PositionX\cnt@hoffset
\Identify{1}
\InsideHArrow\cnt@hoffset
\SetToQuart\PositionY\cnt@textheight
\advance\PositionY by \ref@body
\ifnum\ref@marginwidth > 0
\OutsideHArrow\ref@margin\ref@marginwidth{20}
\PositionX = \cnt@hoffset
\else
\OutsideHArrow\cnt@hoffset{-\ref@marginwidth}{20}
\PositionX = \ref@margin
\fi
\advance\PositionX by -30
\Identify{3}
the \marginparwidth,
299
300
\SetToQuart\PositionY\cnt@textheight
\advance\PositionY by \ref@body
This arrow has to be bit below the one for the \oddsidemargin or
\evensidemargin.
301
302
303
304
305
\advance\PositionY by 30
\SetToHalf\PositionX\cnt@marginparwidth
\advance\PositionX by \ref@marginpar
\Identify{10}
\InsideHArrow\cnt@marginparwidth
\advance\PositionY by 30
\if@twoside
\if@reversemargin
\ifodd\count\z@
\OutsideHArrow\ref@margin\cnt@marginparsep{20}
\PositionX = \ref@margin
\else
\OutsideHArrow\ref@marginpar\cnt@marginparsep{20}
11
314
315
316
12
\PositionX = \ref@marginpar
\fi
\else
Not reversemargin;
317
318
319
320
321
322
323
324
325
\ifodd\count\z@
\OutsideHArrow\ref@marginpar\cnt@marginparsep{20}
\PositionX = \ref@marginpar
\else
\OutsideHArrow\ref@margin\cnt@marginparsep{20}
\PositionX = \ref@margin
\fi
\fi
\else
\if@reversemargin
\OutsideHArrow\ref@margin\cnt@marginparsep{20}
\PositionX = \ref@margin
\else
\OutsideHArrow\ref@marginpar\cnt@marginparsep{20}
\PositionX = \ref@marginpar
\fi
\fi
\advance\PositionX by -\cnt@marginparsep
\advance\PositionX by -30
\Identify{9}
Identify the \footskip. The arrow will be located on 1/8th of the \textwidth.
337
338
339
340
341
342
343
344
\PositionX = \cnt@textwidth
\divide\PositionX by 8
\advance\PositionX by \ref@margin
\OutsideVArrow\ref@foot\cnt@footskip{20}{20}
\PositionY = \ref@foot
\advance\PositionY by \cnt@footskip
\advance\PositionY by 30
\Identify{11}
Identify the \voffset. The arrow will be located a bit to the left of the edge
of the paper.
345
346
347
348
349
350
351
352
353
\PositionX = \cnt@paperwidth
\advance\PositionX by -50
\PositionY = \cnt@paperheight
\ExtraYPos = \PositionY
\advance\ExtraYPos by -\cnt@voffset
\advance\PositionY by \cnt@voffset
\divide\PositionY by \tw@
\Identify{2}
\InsideVArrow\ExtraYPos
13
The arrows will be located on 1/8th of the \textwidth, with intervals of the
same size, stored in \Interval.
354
355
356
357
\Interval = \cnt@textwidth
\divide\Interval by 8
\PositionX = \ref@margin
\advance\PositionX by \Interval
First the \topmargin. If \topmargin has a positive value, the arrow is upward.
Otherwise, it is downward. The number label is always placed at the base of the
arrow.
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
\OutsideVArrow\ref@head\cnt@headheight{20}{20}
\PositionY = \ref@head
\advance\PositionY by \cnt@headheight
\advance\PositionY by 30
\Identify{5}
\advance\PositionX by \Interval
\ExtraYPos=\ref@body
\advance\ExtraYPos\cnt@textheight
\OutsideVArrow\ExtraYPos\cnt@headsep{20}{20}
\PositionY = \ref@body
\advance\PositionY by \cnt@textheight
\advance\PositionY by -30
\Identify{6}
Here we can end the picture environment and insert a little space.
386
\end{picture}
387
388
\medskip
Below the picture we put a table to show the actual values of the parameters.
Note that fractional points are truncated, i.e., 72.27pt is displayed as 72pt
14
The table is typeset inside a box with a depth of 0 to always keep it on the
same page as the picture.
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
\vtop to 0pt{%
\@minipagerestore\footnotesize\ttfamily
\begin{tabular}{@{}rl@{\hspace{20pt}}rl}
1 & \oneinchtext\ + \LayOutbs\texttt{hoffset}
& 2 & \oneinchtext\ + \LayOutbs\texttt{voffset} \\
3 & \if@twoside
\ifodd\count\z@ \Show{cnt}{oddsidemargin}
\else \Show{cnt}{evensidemargin}
\fi
\else
\Show{cnt}{oddsidemargin}
\fi
& 4 & \Show{cnt}{topmargin} \\
5 & \Show{cnt}{headheight} & 6 & \Show{cnt}{headsep} \\
7 & \Show{cnt}{textheight} & 8 & \Show{cnt}{textwidth} \\
9 & \Show{cnt}{marginparsep}&10& \Show{cnt}{marginparwidth} \\
11& \Show{cnt}{footskip}
&
& \Show{cnt}{marginparpush}
\rlap{(\notshown)}\\
& \Show{ref}{hoffset}
&
& \Show{ref}{voffset} \\
& \Show{cnt}{paperwidth} &
& \Show{cnt}{paperheight} \\
408
409
\end{tabular}\vss}
When the option verbose was used the following lines will show dimensions on the
terminal.
410
411
412
413
\Type{ref}{hoffset}
\Type{ref}{voffset}
\Type{cnt}{textheight}
\Type{cnt}{textwidth}