• No results found

Index of /CTAN/macros/latex/contrib/layouts

N/A
N/A
Protected

Academic year: 2023

Share "Index of /CTAN/macros/latex/contrib/layouts"

Copied!
82
0
0

Loading.... (view fulltext now)

Full text

(1)

Author: Peter Wilson, Herries Press Maintainer: Will Robertson

will dot robertson at latex-project dot org 2009/09/02

Abstract

Thelayoutspackage provides facilities for document designers to exper- iment with various aspects of the layout of LATEXed documents. There is a separate user manual for the package.

Contents

1 Introduction 2

2 The layouts package 2

3 Counters and such 2

4 Initialisations 5

5 Utility commands 8

6 Drawing the layout of a page 10

7 Drawing the layout of a memoir page 20

8 Drawing the layout of a list 31

9 Drawing the layout of footnotes 39

10 Drawing the layout of paragraphs 43

11 Drawing the layout of section headings 46

12 Drawing the layouts of floats 51

12.0.1 Individual float layout . . . 51 12.0.2 Floats on a page . . . 56

This file (layouts.dtx) has version number v2.6d, last revised 2009/09/02.

1

(2)

13 Drawing the layout of a Table of Contents entry 60

14 Drawing a spread 65

15 Drawing a font box 68

1 Introduction

This document provides the commented source for a LATEX package file developed as part of a suite designed for the typesetting of documents according to the rules for ISO international standards [Wil96]. A separate document provides the user manual.

Section 2 describes a package to assist in the design of new LATEX classes and packages by graphically depicting the layout1of various logical elements of a doc- ument. This package has general applicability and is not restricted to typesetting ISO documents.

This manual is typeset according to the conventions of the LATEX doc- striputility which enables the automatic extraction of the LATEX macro source files [GMS94].

2 The layouts package

Announce the name and version of the package which requires LATEX 2ε.

1h∗laysi

2\NeedsTeXFormat{LaTeX2e}

3\ProvidesPackage{layouts}[2009/09/02 v2.6d graphical depiction of document elements]

4

The layouts package provides means of graphically displaying the layout of various logical elements of a document such as section headings, lists, floats, and others.

3 Counters and such

First we define some commands, counters, etc., that will be useful later on.

\bs We will be doing a lot of printing of LATEX commands, so we need a short command to print a backslash.

5\@ifundefined{bs}{\newcommand{\bs}{\texttt{\char‘\\}}}%

6 {\renewcommand{\bs}{\texttt{\char‘\\}}}

7

1With thanks to Frank Mittelbach for noticing some problems with version 2.4 and suggesting additional features.

(3)

\l@yoneinch

\l@yeighthalfinch

\l@yteninch

\l@yeleveninch

\l@yonepoint

Some generally useful values. \l@yonepointis set to 65536 sp and all the others are set to a value in pts.

8\newcommand{\l@yoneinch}{72}

9\newcommand{\l@yeighthalfinch}{615}

10\newcommand{\l@yteninch}{723}

11\newcommand{\l@yeleveninch}{795}

12\newcommand{\l@yonepoint}{65536}

\l@youtscale Internal command that stores the drawing scale factor. Initialised to half scale.

13\newcommand{\l@youtscale}{0.5}

14

\l@ylen A length.

15\newlength{\l@ylen}

\layoutsbox A box for storing something. There seems to be no reason why the user should not be able to use this.

16\newsavebox{\layoutsbox}

\l@youtunitlength This will be used for setting the\unitlengthfor apicture.

17\newlength{\l@youtunitlength}

\l@youtlinethick

\l@youtlinethickii

These will be used as parameters to a \linethicknesscommand.

18\newlength{\l@youtlinethick}

19\newlength{\l@youtlinethickii}

20

\l@ysetupparskip

\l@ysetupbaselineskip

Used for storing the document’s\parskipand \baselineskip.

21\newlength{\l@ysetupparskip}

22\newlength{\l@ysetupbaselineskip}

23

\l@yonem

\l@yonex

Used for storing the document’s value for 1em and 1ex.

24\newlength{\l@yonem}

25\newlength{\l@yonex}

26

\l@ylmarg

\l@yrmarg

\l@yitmindent

\l@ylblwidth

\l@ylblsep

\l@ylparindent

\l@ytsep

\l@ypskip

\l@yptsep

\l@ypsep

\l@yitmsep

We need to store a list environment’s values for use when tabulating the actual list values.

27\newlength{\l@ylmarg}

28\newlength{\l@yrmarg}

29\newlength{\l@yitmindent}

30\newlength{\l@ylblwidth}

31\newlength{\l@ylblsep}

32\newlength{\l@ylparindent}

33\newlength{\l@ytsep}

34\newlength{\l@ypskip}

35\newlength{\l@yptsep}

(4)

36\newlength{\l@ypsep}

37\newlength{\l@yitmsep}

38

\l@ytok A useful token

39\newtoks\l@ytok

40

\l@youtpw

\l@youtph

We use these for storing the page width and height.

41\newcount\l@youtpw

42\newcount\l@youtph

43

\l@youthpi

\l@youthpii

\l@youthpiii

\l@youthpiv

\l@youthpv

\l@youthpvi

\l@youthpvii

Counters for horizontal drawing parameters.

44\newcount\l@youthpi

45\newcount\l@youthpii

46\newcount\l@youthpiii

47\newcount\l@youthpiv

48\newcount\l@youthpv

49\newcount\l@youthpvi

50\newcount\l@youthpvii

51

\l@youtparskip

\l@youtvpi

\l@youtvpii

\l@youtvpiii

\l@youtvpiv

\l@youtvpv

\l@youtvpvi

\l@youtvpvii

Counters for vertical drawing parameters.

52\newcount\l@youtparskip

53\newcount\l@youtvpi

54\newcount\l@youtvpii

55\newcount\l@youtvpiii

56\newcount\l@youtvpiv

57\newcount\l@youtvpv

58\newcount\l@youtvpvi

59\newcount\l@youtvpvii

60

\l@youthdo

\l@youthdi

\l@youthdii

\l@youthdiii

\l@youthdiv

\l@youthdv

\l@youthdvi

\l@youthdvii

Horizontal dimensions.

61\newcount\l@youthdo

62\newcount\l@youthdi

63\newcount\l@youthdii

64\newcount\l@youthdiii

65\newcount\l@youthdiv

66\newcount\l@youthdv

67\newcount\l@youthdvi

68\newcount\l@youthdvii

69

\l@youtvdo

\l@youtvdi

\l@youtvdii

\l@youtvdiii

\l@youtvdiv

\l@youtvdv

\l@youtvdvi

\l@youtvdvii

\l@youtvdviii

Vertical dimensions.

70\newcount\l@youtvdo

71\newcount\l@youtvdi

(5)

72\newcount\l@youtvdii

73\newcount\l@youtvdiii

74\newcount\l@youtvdiv

75\newcount\l@youtvdv

76\newcount\l@youtvdvi

77\newcount\l@youtvdvii

78\newcount\l@youtvdviii

79

\l@youtxci

\l@youtxcii

\l@youtxciii

\l@youtxciv

\l@youtxcv

\l@youtxcvi

X coordinates.

80\newcount\l@youtxci

81\newcount\l@youtxcii

82\newcount\l@youtxciii

83\newcount\l@youtxciv

84\newcount\l@youtxcv

85\newcount\l@youtxcvi

86

\l@youtyci

\l@youtycii

\l@youtyciii

\l@youtyciv

\l@youtycv

\l@youtycvi

\l@youtycvii

\l@youtycviii

Y coordinates.

87\newcount\l@youtyci

88\newcount\l@youtycii

89\newcount\l@youtyciii

90\newcount\l@youtyciv

91\newcount\l@youtycv

92\newcount\l@youtycvi

93\newcount\l@youtycvii

94\newcount\l@youtycviii

95

\l@youtxco

\l@youtyco

For the (X,Y) coordinates of the bottom left hand corner of the page.

96\newcount\l@youtxco

97\newcount\l@youtyco

98

4 Initialisations

The following are used to set up default conditions.

\ifoddpagelayout Set TRUE to draw an oddside page.

99\newif\ifoddpagelayout

100 \oddpagelayouttrue

\iftwocolumnlayout Set TRUE to draw a two column page.

101\newif\iftwocolumnlayout

102 \twocolumnlayoutfalse

\ifdrawmarginpars Set TRUE to draw marginpars on a page.

103\newif\ifdrawmarginpars

104 \drawmarginparstrue

(6)

\ifdrawparameters Set TRUE to draw a layout with marked dimension lines.

105\newif\ifdrawparameters

106 \drawparameterstrue

\iflistaspara Set TRUE to draw lists as stand-alone paragraph.

107\newif\iflistaspara

108 \listasparatrue

\ifruninhead Set TRUE to draw a run-in heading.

109\newif\ifruninhead

110 \runinheadfalse

\ifprintparameters Set TRUE to print table of actual parameter values

111\newif\ifprintparameters

112 \printparameterstrue

\ifdrawdimensions Set TRUE to draw dimension lines

113\newif\ifdrawdimensions

114 \drawdimensionsfalse

\ifprintheadings Set TRUE to print text about dashed lines.

115\newif\ifprintheadings

116 \printheadingstrue

\ifl@ytempif A scratch\if.

117\newif\ifl@ytempif

\l@yor \l@yor{hifAi}{hifBi} sets \ifl@ytempif to TRUE unless hifAi is FALSE and hifBiis FALSE (i.e.,\ifl@tempif=hifAiORhifBi).

118\newcommand{\l@yor}[2]{%

119 \l@ytempiftrue

120 #1

121 \else

122 #2

123 \else

124 \l@ytempiffalse

125 \fi

126 \fi}

\l@ynnand \l@ynnand{hifAi}{hifBi}sets\ifl@ytempifto FALSE unlesshifAiis FALSE and hifBiis TRUE

127\newcommand{\l@ynnand}[2]{%

128 \l@ytempiffalse

129 #1

130 \else

131 #2

132 \l@ytempiftrue

133 \fi

134 \fi}

(7)

\l@ynox \l@ynox{hifAi}{hifBi} sets \ifl@ytempif to TRUE unless hifAi is TRUE and hifBiis FALSE.

135\newcommand{\l@ynox}[2]{%

136 \l@ytempiftrue

137 #1

138 #2

139 \else

140 \l@ytempiffalse

141 \fi

142 \fi}

\testdrawdimensions

\testprintparameters 143\newcommand{\testdrawdimensions}{%

144 \l@yor{\ifdrawparameters}{\ifdrawdimensions}}

145\newcommand{\testprintparameters}{%

146 \l@ynnand{\ifdrawparameters}{\ifprintparameters}}

147

\setlabelfont

\l@ylabelfont

The font for labels in the diagrams.

148\newcommand{\setlabelfont}[1]{\renewcommand{\l@ylabelfont}{#1}}

149 \newcommand{\l@ylabelfont}{\normalfont}

\setparametertextfont

\l@yparamfont

The font size for parameters.

150\newcommand{\setparametertextfont}[1]{\renewcommand{\l@yparamfont}{#1}}

151 \newcommand{\l@yparamfont}{\footnotesize}

\setvaluestextsize

\l@yvalsize

The font size for value tables.

152\newcommand{\setvaluestextsize}[1]{\renewcommand{\l@yvalsize}{#1}}

153 \newcommand{\l@yvalsize}{\normalsize}

\setlayoutscale A user command to set the drawing scale. The scale is initialised to half size.

154\newcommand{\setlayoutscale}[1]{\setlength{\l@youtunitlength}{1pt}

155 \l@youtunitlength = #1\l@youtunitlength

156 \renewcommand{\l@youtscale}{#1}

157 \PackageWarning{layouts}{Layout scale set to #1}}

158%%%\setlayoutscale{0.5}

\setuplayouts The\setuplayoutscommand should be called immediately at the\begin{document}.

It must be called before any command that changes font sizes or makes any change to the document layout. It stores relevant skips.

159\newcommand{\setuplayouts}{%

160 \setlength{\l@ysetupparskip}{\parskip}

161 \setlength{\l@ysetupbaselineskip}{\baselineskip}

162 \setlength{\l@yonem}{1em}

163 \setlength{\l@yonex}{1ex}

164 \setlayoutscale{0.5}

165%%% \PackageWarning{layouts}{Layout scale set to 0.5}

166}

167\AtBeginDocument{\setuplayouts}

(8)

5 Utility commands

A variety of utility commands.

\l@yltoc \l@yltoc{hlengthi}{hcounteri} converts a length into a counter value. The counter value is to the nearest pt of the length.

168\newcommand{\l@yltoc}[2]{\setlength{\l@ylen}{#1}%

169 \ifdim\l@ylen > \z@ \advance\l@ylen by 0.5\p@ \else

170 \ifdim\l@ylen < \z@ \advance\l@ylen by -0.5\p@

171 \fi

172 \fi

173 #2=\l@ylen

174 \divide #2 by \l@yonepoint\relax}

\l@yvuda

\l@yhrda

\l@yvuda{hxi}{hyi}{hdistancei}draws a line vertically upwards from (hxi,hyi) a hdistanceiwith an outward pointing arrowhead at each end of the line. \l@yhrda is similar except that a horizontal line is drawn to the right. Simplistically, the commands produce something like<---->.

175\newcommand{\l@yvuda}[3]{\put(#1,#2){\vector(0,1){#3}}

176 \put(#1,#2){\vector(0,-1){0}}}

177\newcommand{\l@yhrda}[3]{\put(#1,#2){\vector(1,0){#3}}

178 \put(#1,#2){\vector(-1,0){0}}}

\l@yvudia

\l@yhrdia

\l@yvudia{hxi}{hyi}{hdistancei}draws two vertical arrowheads pointing to each other. One is at (hxi,hyi) and the other is at (hxi,hy + distancei). \l@yhrdiais similar except that the arrowheads are horizontal. Simplistically, the commands produce something like> <.

179\newcommand{\l@yvudia}[3]{\begingroup

180 \l@youthpvii=#1\relax

181 \l@youtvpvii=#2\relax

182 \l@youthdvii=#3\relax

183 \put(\l@youthpvii,\l@youtvpvii){\vector(0,1){0}}

184 \advance\l@youtvpvii by \l@youthdvii

185 \put(\l@youthpvii,\l@youtvpvii){\vector(0,-1){0}}

186 \endgroup}

187\newcommand{\l@yhrdia}[3]{\begingroup

188 \l@youthpvii=#1\relax

189 \l@youtvpvii=#2\relax

190 \l@youthdvii=#3\relax

191 \put(\l@youthpvii,\l@youtvpvii){\vector(1,0){0}}

192 \advance\l@youthpvii by \l@youthdvii

193 \put(\l@youthpvii,\l@youtvpvii){\vector(-1,0){0}}

194 \endgroup}

\l@ypcmd

\l@ycmd

\l@ypcmd{hcmdnamei}typesets a commandhcmdnamei(which does not include the backslash) (in a picture). For example, \l@ypcmd{fred} prints\fred. The font size is given by\l@yparamfont. The\l@ycmdmacro is similar but does not set the font size.

(9)

195\newcommand{\l@ypcmd}[1]{{\l@yparamfont\texttt{\bs #1}}}

196\newcommand{\l@ycmd}[1]{\texttt{\bs #1}}

197

\printinunitsof

\l@yunitperpt

\l@yunits

\printinunitsof{huniti}sets\l@yunitsto the value ofhunitiand\l@yunitperpt to the number of hunitiin 1pt.

198\newcommand{\printinunitsof}[1]{%

199 \def\l@yunitperpt{1.0}\def\l@yunits{pt}%

200 \def\l@yta{#1}\def\l@ytb{pt}%

201 \ifx \l@yta\l@ytb

202 \def\l@yunitperpt{1.0}\def\l@yunits{pt}%

203 \else

204 \def\l@ytb{pc}%

205 \ifx \l@yta\l@ytb

206 \def\l@yunitperpt{0.083333}\def\l@yunits{pc}%

207 \else

208 \def\l@ytb{in}%

209 \ifx \l@yta\l@ytb

210 \def\l@yunitperpt{0.013837}\def\l@yunits{in}%

211 \else

212 \def\l@ytb{mm}%

213 \ifx \l@yta\l@ytb

214 \def\l@yunitperpt{0.351459}\def\l@yunits{mm}%

215 \else

216 \def\l@ytb{cm}%

217 \ifx \l@yta\l@ytb

218 \def\l@yunitperpt{0.0351459}\def\l@yunits{cm}%

219 \else

220 \def\l@ytb{bp}%

221 \ifx \l@yta\l@ytb

222 \def\l@yunitperpt{0.996264}\def\l@yunits{bp}%

223 \else

224 \def\l@ytb{dd}%

225 \ifx \l@yta\l@ytb

226 \def\l@yunitperpt{0.9345718}\def\l@yunits{dd}%

227 \else

228 \def\l@ytb{cc}%

229 \ifx \l@yta\l@ytb

230 \def\l@yunitperpt{0.0778809}\def\l@yunits{cc}%

231 \else

232 \def\l@ytb{PT}%

233 \ifx \l@yta\l@ytb

234 \def\l@yunitperpt{1.0}\def\l@yunits{PT}%

235 \fi

236 \fi

237 \fi

238 \fi

239 \fi

240 \fi

241 \fi

(10)

242 \fi

243 \fi

244}

245\printinunitsof{pt}

246

\l@ytempdima

\prntlen

\l@ytempdimais a scratch length. \prntlen{hlengthi}prints the value ofhlengthi in the units set by\printinunitsof.

247\newlength{\l@ytempdima}

248\newcommand{\prntlen}[1]{%

249 \def\l@yta{pt}\ifx\l@yta\l@yunits\the#1\else

250 \def\l@yta{PT}%

251 \l@ytempdima=\l@yunitperpt #1\relax\strip@pt\l@ytempdima

252 \ifx\l@yta\l@yunits pt\else\l@yunits\fi\fi}

253

\l@yval \l@yval{hlcmdi}prints a value of the (length) commandhlcmdi(which includes the backslash); for example\l@yval{\mylength}.

254%%% \newcommand{\l@yval}[1]{\the#1}

255\newcommand{\l@yval}[1]{\prntlen{#1}}

256

6 Drawing the layout of a page

A variety of commands are used to draw the layout of a page.

First some utility commands for setting the layout dimensions.

\trypaperwidth Sets thepaperwidth and stores the result in\l@youtpw.

257%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

258%%%% PAGE LAYOUT

259%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

260\newcommand{\trypaperwidth}[1]{\l@yltoc{#1}{\l@youtpw}}

\trypaperheight Sets thepaperheight and stores the result in\l@youtph.

261\newcommand{\trypaperheight}[1]{\l@yltoc{#1}{\l@youtph}}

\tryhoffset Sets thehoffsetand stores the result in \l@youthpi.

262\newcommand{\tryhoffset}[1]{\l@yltoc{#1}{\l@youthpi}}

\tryvoffset Sets thevoffsetand stores the result in \l@youtvpi.

263\newcommand{\tryvoffset}[1]{\l@yltoc{#1}{\l@youtvpi}}

\trytopmargin Sets thetopmarginand stores the result in\l@youtvpii.

264\newcommand{\trytopmargin}[1]{\l@yltoc{#1}{\l@youtvpii}}

\tryheadheight Sets theheadheight and stores the result in\l@youtvpiii.

265\newcommand{\tryheadheight}[1]{\l@yltoc{#1}{\l@youtvpiii}}

(11)

\tryheadsep Sets the headsepand stores the result in \l@youtvpiv.

266\newcommand{\tryheadsep}[1]{\l@yltoc{#1}{\l@youtvpiv}}

\trytextheight Sets the textheightand stores the result in\l@youtvpv.

267\newcommand{\trytextheight}[1]{\l@yltoc{#1}{\l@youtvpv}}

\tryfootskip Sets the footskipand stores the result in \l@youtvpvi.

268\newcommand{\tryfootskip}[1]{\l@yltoc{#1}{\l@youtvpvi}}

\tryoddsidemargin Sets the oddsidemarginand stores the result in\l@youthpv.

269\newcommand{\tryoddsidemargin}[1]{\l@yltoc{#1}{\l@youthpv}}

\tryevensidemargin Sets the evensidemarginand stores the result in \l@youthpiv.

270\newcommand{\tryevensidemargin}[1]{\l@yltoc{#1}{\l@youthpiv}}

\trytextwidth Sets the textwidthand stores the result in \l@youthpii.

271\newcommand{\trytextwidth}[1]{\l@yltoc{#1}{\l@youthpii}}

\trymarginparsep Sets the marginparsepand stores the result in\l@youthpvi.

272\newcommand{\trymarginparsep}[1]{\l@yltoc{#1}{\l@youthpvi}}

\trymarginparwidth Sets the marginparwidthand stores the result in \l@youthpvii.

273\newcommand{\trymarginparwidth}[1]{\l@yltoc{#1}{\l@youthpvii}}

\trymarginparpush Sets the marginparpushand stores the result in\l@youtvpvii.

274\newcommand{\trymarginparpush}[1]{\l@yltoc{#1}{\l@youtvpvii}}

\trycolumnsep Sets the columnsepand stores the result in \l@youthpiii.

275\newcommand{\trycolumnsep}[1]{\l@yltoc{#1}{\l@youthpiii}}

\trycolumnseprule Sets the columnsepruleand stores the result in\l@youtlinethick.

276\newcommand{\trycolumnseprule}[1]{\setlength{\l@youtlinethick}{#1}}

\setfootbox Sets the height and depth of the footer box and stores the results in\l@youtvdv and\l@youtvdvi.

277\newcommand{\setfootbox}[2]{\l@yltoc{#1}{\l@youtvdv}\l@yltoc{#2}{\l@youtvdvi}}

\ifreversemarginpar

\ifmarginparswitch

Flags for where marginpars should go.

278\newif\ifreversemarginpar

279 \reversemarginparfalse

280\newif\ifmarginparswitch

281 \marginparswitchtrue

282

\ifl@yrightmpars Internal flag for marginpar location

283\newif\ifl@yrightmpars

284 \l@yrightmparstrue

(12)

\currentpage This routine sets the layout page parameters to those specified for the document, specifically as on the current page.

285\newcommand{\currentpage}{%

286 \@ifundefined{paperwidth}{\trypaperwidth{8.5in}}%

287 {\trypaperwidth{\paperwidth}}%

288 \@ifundefined{paperheight}{\trypaperheight{11in}}%

289 {\trypaperheight{\paperheight}}%

290 \tryhoffset{\hoffset}% % typically 0pt

291 \tryvoffset{\voffset}% % typically 0pt

292 \tryoddsidemargin{\oddsidemargin}% % typically 21-63pt

293 \tryevensidemargin{\evensidemargin}% % typically 39-82pt

294 \trytopmargin{\topmargin}% % typically 27pt

295 \commonl@ypage%

296}

\commonl@ypage This routine sets the layout page parameters common to both the standard and memoir classes, to those specified for the document, specifically as on the current page.

297\newcommand{\commonl@ypage}{%

298 \trymarginparwidth{\marginparwidth}% % typically 68-107pt

299 \trymarginparsep{\marginparsep}% % typically 10-11pt

300 \trymarginparpush{\marginparpush}% % typically 5-7pt

301 \tryheadheight{\headheight}% % typically 12pt

302 \tryheadsep{\headsep}% % typically 25pt

303 \tryfootskip{\footskip}% % typically 30pt

304 \trytextheight{\textheight}% % typically 36-43 times baselineskip

305 \trytextwidth{\textwidth}% % typically 345-390pt

306 \trycolumnsep{\columnsep}% % typically 10pt

307 \trycolumnseprule{\columnseprule}% % typically 0pt

308 \setfootbox{\baselineskip}{0pt}% % footheight = 1 line

309 \reversemarginparfalse % reversemargin

310 \if@reversemargin \reversemarginpartrue \fi

311 \marginparswitchfalse % mparswitch

312 \if@mparswitch \marginparswitchtrue \fi

313 \twocolumnlayoutfalse

314 \if@twocolumn \twocolumnlayouttrue \fi

315 \oddpagelayouttrue

316 \if@twoside

317 \ifodd\count\z@

318 \else

319 \oddpagelayoutfalse

320 \fi

321 \fi

322}

\drawpage This routine draws a page layout.

323\newcommand{\drawpage}{%

First set some default vertical and horizontal dimension values.

(13)

324 \l@youtvdiii=\l@yteninch\relax

325 \divide\l@youtvdiii by 24\relax

326 \l@youthdii=\l@youtvdiii

327 \ifdrawparameters

Whendrawparametersis TRUE, we draw a generic layout showing the controlling layout variables.

328 \l@youtph=\l@yeleveninch\relax % page height

329 \l@youtpw=\l@yeighthalfinch\relax % page width

330 \l@youtvpi=\z@ % voffset

331 \l@youtvpii=\l@youtvdiii % topmargin

332 \l@youtvpiii=\l@youtvdiii % headheight

333 \l@youtvpiv=\l@youtvdiii % headsep

334 \l@youtvpv=\l@yoneinch\relax % textheight

335 \multiply\l@youtvpv by 6\relax

336 \l@youtvpvi=\l@youtvdiii % footskip

337 \multiply\l@youtvpvi by \tw@

338 \l@youtvdv=\l@youtvdiii % default footboxheight

339 \l@youtvdvi=\z@ % default footboxdepth

340 \l@youtvpvii=\l@youtvdiii % marginparpush

341 \l@youthpi=\z@ % hoffset

342 \l@youthpii=\l@youthdii % textwidth

343 \multiply\l@youthpii by 13\relax

344 \l@youthpiii=\l@youthdii % columnsep

345 \l@youthpiv=\l@youthdii % evensidemargin

346 \l@youthpv=\l@youthdii % oddsidemargin

347 \l@youthpvi=\l@youthdii % marginparsep

348 \l@youthpvii=\l@youthdii % marginparwidth

349 \multiply\l@youthpvii by \tw@

350 \fi

Calculate coordinates for use in the drawing.

351 \l@youtycvi=\l@youtph % one inch below top of page

352 \advance\l@youtycvi by -\l@yoneinch\relax

353 \l@youtxci=\l@youthpi % hofref

354 \advance\l@youtxci by \l@yoneinch\relax

355 \l@youtycv=\l@youtycvi % vofref

356 \advance\l@youtycv by -\l@youtvpi

357 \l@youtyciv=\l@youtycv % headref

358 \advance\l@youtyciv by -\l@youtvpii

359 \advance\l@youtyciv by -\l@youtvpiii

360 \l@youtycii=\l@youtyciv % bodyref

361 \advance\l@youtycii by -\l@youtvpiv

362 \advance\l@youtycii by -\l@youtvpv

363 \ifnum\l@youtvdv>\l@youtvpvi

364 \PackageWarning{layouts}{The footbox is higher than the footskip}

365 \l@youtvdv=\l@youtvpvi

366 \fi

367 \l@youtyci=\l@youtycii % footref

368 \advance\l@youtyci by -\l@youtvpvi

(14)

369 \advance\l@youtyci by -\l@youtvdvi % box depth

370 \l@youtvdvii=\l@youtvdv % box height

371 \advance\l@youtvdvii by \l@youtvdvi % plus depth

372 \l@youtvdii=\l@youtvpv % noteheight

373 \divide\l@youtvdii by 4\relax

374 \l@youtyciii=\l@youtycii % noteref

375 \advance\l@youtyciii by \l@youtvdii

376 \advance\l@youtyciii by \l@youtvpvii

377 \l@youtxcii=\l@youtxci % marginref

378 \ifoddpagelayout

Some values are different on odd and even pages

379 \advance\l@youtxcii by \l@youthpv

380 \else

381 \advance\l@youtxcii by \l@youthpiv

382 \fi

383 \l@youtxciv=\l@youtxcii % margnoteref

The next part of the code was supplied by Frank Mittelbach2 to add facilities for reversed marginpars. Now find where the marginpars go. \@tempcnta = (1 — right, -1 — left) corresponds to the treatment in the kernel.

384 \@tempcnta\@ne

385 \ifmarginparswitch

386 \ifoddpagelayout \else \@tempcnta\m@ne \fi

387 \fi

388 \ifreversemarginpar \@tempcnta -\@tempcnta \fi Change layout values to suit.

389 \ifnum\@tempcnta > \z@

390 \l@yrightmparstrue

391 \advance\l@youtxciv by \l@youthpii

392 \advance\l@youtxciv by \l@youthpvi

393 \else

394 \l@yrightmparsfalse

395 \advance\l@youtxciv by -\l@youthpvi

396 \advance\l@youtxciv by -\l@youthpvii

397 \fi

Back to my code. Do column dependent values.

398 \l@youthdi=\l@youthpii % columnwidth

399 \l@youtxciii=\l@youtxcii % colref

400 \iftwocolumnlayout

401 \advance\l@youthdi by -\l@youthpiii

402 \divide\l@youthdi by \tw@

403 \advance\l@youtxciii by \l@youthdi

404 \advance\l@youtxciii by \l@youthpiii

405 \l@youtxcv=\l@youthpiii % centre of gutter

406 \divide\l@youtxcv by \tw@

407 \advance\l@youtxcv by \l@youtxcii

408 \advance\l@youtxcv by \l@youthdi

2Email dated 2002/05/18.

(15)

409 \fi

Print the caption for the top of the drawing.

410 \l@yor{\ifdrawparameters}{\ifprintheadings}

411 \begin{center}

412 \ifl@ytempif

413 \begin{small} The circle is at 1 inch from the top and left of the

414 page. Dashed lines represent (\texttt{\bs hoffset + 1 inch}) and

415 (\texttt{\bs voffset + 1 inch}) from the top and left of the

416 page.

417 \end{small} \\

418 \medskip

419 \fi

Draw the picture!

420 \setlength{\unitlength}{\l@youtunitlength}

421 \begin{picture}(\l@youtpw,\l@youtph)

422 \thicklines

Either reference lines for the page top and side, or the page.

423 \ifdrawparameters

424 \put(0,0){\line(0,1){\l@youtph}}

425 \put(0,\l@youtph){\line(1,0){\l@youtpw}}

426 \else

427 \put(0,0){\framebox(\l@youtpw,\l@youtph){}}

428 \fi

Draw the offset lines and a circle 1 inch from the top LH corner of the page.

429 \put(\l@yoneinch,\l@youtycvi){\circle{12}}

430 \put(0,\l@youtycv){\dashbox{10}(\l@youtpw,0){}}

431 \put(\l@youtxci,0){\dashbox{10}(0,\l@youtph){}}

Draw the header. put(marginref,headref){framebox(textwidth,headheight)}

432 \put(\l@youtxcii,\l@youtyciv){\framebox(\l@youthpii,\l@youtvpiii)%

433 {\l@ylabelfont Header}}

Draw the body.

434 \iftwocolumnlayout

put(marginref,bodyref){framebox(columnwidth,textheight)} and put(colref,bodyref){framebox(columnwidth,textheight)}.

435 \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)%

436 {\l@ylabelfont Col. 1}}

437 \put(\l@youtxciii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)%

438 {\l@ylabelfont Col. 2}}

439 \linethickness{\l@youtscale\l@youtlinethick}

440 \put(\l@youtxcv,\l@youtycii){\line(0,1){\l@youtvpv}}

441 \thicklines

442 \else

put(marginref,bodyref){framebox(textwidth,textheight)}.

443 \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthpii,\l@youtvpv)%

(16)

444 {\l@ylabelfont Body}}

445 \fi

Draw the footer. put(marginref,footref){framebox(textwidth,footheight)}

Draw this as an open box as there is no defined height for this.

446 \put(\l@youtxcii,\l@youtyci){\framebox(\l@youthpii,\l@youtvdvii)%

447 {\l@ylabelfont Footer}}

Marginal notes (two examples), if asked for.

put(margnoteref,bodyref){framebox(marginparwidth,noteheight)}and put(margnoteref,noteref){framebox(marginparwidth,noteheight)}.

448 \ifdrawmarginpars

449 \ifdrawparameters

450 \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii){}}

451 \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%

452 {\l@ylabelfont\shortstack{Margin\\Note}}}

453 \else

454 \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii)%

455 {\l@ylabelfont Note}}

456 \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%

457 {\l@ylabelfont Margin}}

458 \fi

459 \fi

If the footbox has a depth, draw a dashed line to mark the footskip.

460 \ifnum\l@youtvdvi > \z@

461 \thinlines

462 \advance\l@youtyci by \l@youtvdvi

463 \put(\l@youtxcii,\l@youtyci){\dashbox{10}(\l@youthpii,0){}}

464 \fi

We now draw labelled vectors indicating the layout parameters. Life gets tedious as we have to calculate a few more coordinate and length values. The code below is fairly incomprehensible as we are trying to minimise the number of counters.

465 \testdrawdimensions

466 \ifl@ytempif

467 \thinlines Calculate more coordinates

468 \l@youtxcv=\l@youtxcii % X coord for vertical dimensions

469 \advance\l@youtxcv by \l@youthdii

470 \l@youtxcvi=\l@youthpvii % X coord for marginparpush

471 \divide\l@youtxcvi by \tw@

472 \advance\l@youtxcvi by \l@youtxciv

473 \l@youtvdviii=\l@youtvdiii % half l@youtvdiii

474 \divide\l@youtvdviii by \tw@

475 \l@youtycvii=\l@youtycii % Y coord for low dimensions

476 \advance\l@youtycvii by \l@youtvdiii

477 \l@youtycviii=\l@youtycvii % Y coord for mid dimensions

478 \advance\l@youtycviii by \l@youtvdiii

479 \l@youtvdi=\l@youtvpv % Y coord for top dimensions

(17)

480 \multiply\l@youtvdi by \tw@

481 \divide\l@youtvdi by 3\relax

482 \advance\l@youtvdi by \l@youtycii Draw the vertical dimensional parameters.

Topmargin. put(x,voffset){vector(0,-1){topmargin}}

483 \put(\l@youtxcv,\l@youtycv){\vector(0,-1){\l@youtvpii}}

484 \put(\l@youtxcv,\l@youtycv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

485 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{topmargin}}

486 \end{picture}}

Headheight. put(x,voffset-topmargin){vector(0,-1){headheight}}

487 \put(\l@youtxcv,\l@youtyciv){\line(0,1){\l@youtvpiii}}

488 \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){0}}

489 \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

490 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{headheight}}

491 \end{picture}}

Headsep. put(x,headref){vector(0,-1){headsep}}

492 \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){\l@youtvpiv}}

493 \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

494 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{headsep}}

495 \end{picture}}

Textheight. put(x,top_of_text){vector(0,-1){textheight}}

496 \put(\l@youtxcv,\l@youtycii){\line(0,1){\l@youtvpv}}

497 \put(\l@youtxcv,\l@youtycii){\vector(0,-1){0}}

498 \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

499 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{textheight}}

500 \end{picture}}

Footskip. put(x,bodyref){vector(0,-1){footskip}}

501 \put(\l@youtxcv,\l@youtycii){\vector(0,-1){\l@youtvpvi}}

502 \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

503 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{footskip}}

504 \end{picture}}

Marginparpush. put(X,noteref){vector(0,-1){marginparpush}} where X = margnoteref + 1/2 notewidth.

505 \ifdrawmarginpars

506 \put(\l@youtxcvi,\l@youtyciii){\vector(0,-1){\l@youtvpvii}}

507 \put(\l@youtxcvi,\l@youtyciii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

508 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{marginparpush}}

509 \end{picture}}

510 \fi

Now for all the horizontal dimensions.

Marginparwidth. put(margnoteref,low){vector(1,0){marginparwidth}

511 \ifdrawmarginpars

512 \put(\l@youtxciv,\l@youtycvii){\vector(1,0){\l@youthpvii}}

513 \put(\l@youtxciv,\l@youtycvii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

514 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparwidth}}

(18)

515 \end{picture}}

516 \fi

Different placements for marginwidth depending on the oddness of the page.

Odd page —put(hoffref,mid){\vector(1,0){oddsidemargin}

Even page —put(hoffref,mid){\vector(1,0){evensidemargin}.

517 \ifoddpagelayout

518 \put(\l@youtxci,\l@youtvdi){\vector(1,0){\l@youthpv}}

519 \else

520 \put(\l@youtxci,\l@youtvdi){\vector(1,0){\l@youthpiv}}

521 \fi

522 \put(\l@youtxci,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

523 \ifoddpagelayout

524 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{oddsidemargin}}

525 \else

526 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{evensidemargin}}

527 \fi

528 \end{picture}}

Different placements for marginparsep, depending on the particular margin.

Right margin —put(margnoteref-marginparsep,mid){vector(1,0){marginparsep}

Left margin —put(marginref,top){vector(-1,0){marginparsep}

529 \ifdrawmarginpars

530 \ifl@yrightmpars

531 \put(\l@youtxciv,\l@youtycviii){\line(-1,0){\l@youthpvi}}

532 \put(\l@youtxciv,\l@youtycviii){\vector(1,0){0}}

533 \put(\l@youtxciv,\l@youtycviii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

534 \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparsep}}

535 \end{picture}}

536 \else

537 \put(\l@youtxcii,\l@youtycviii){\vector(-1,0){\l@youthpvi}}

538 \put(\l@youtxcii,\l@youtycviii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

539 \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparsep}}

540 \end{picture}}

541 \fi

542 \fi

Textwidth. put(marginref,noteref){vector(1,0){textwidth}}

543 \put(\l@youtxcii,\l@youtyciii){\vector(1,0){\l@youthpii}}

544 \put(\l@youtxcv,\l@youtyciii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

545 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{textwidth}}

546 \end{picture}}

Columnsep. put(colref-colsep,mid){vector(1,0){colsep}}

547 \iftwocolumnlayout

548 \put(\l@youtxciii,\l@youtvdi){\line(-1,0){\l@youthpiii}}

549 \put(\l@youtxciii,\l@youtvdi){\vector(1,0){0}}

550 \put(\l@youtxciii,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

551 \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{columnsep}}

552 \end{picture}}

553 \fi

(19)

Have finished drawing the parameters.

554 \fi

555 \end{picture}

556 \end{center}

557 \setlength{\unitlength}{1pt}

Print the actual parameter values.

558 \testprintparameters

559 \ifl@ytempif

560 \begin{center}

561 \begin{footnotesize}

562 Lengths are to the nearest pt. \\

563 \begin{ttfamily}

564 \begin{tabular}{l@{\hspace{20pt}}l}

565 \textrm{page height} = \number\l@youtph pt &

566 \textrm{page width} = \number\l@youtpw pt \\

567 \l@ycmd{hoffset} = \number\l@youthpi pt &

568 \l@ycmd{voffset} = \number\l@youtvpi pt \\

569 \ifoddpagelayout

570 \l@ycmd{oddsidemargin} = \number\l@youthpv pt

571 \else

572 \l@ycmd{evensidemargin} = \number\l@youthpiv pt

573 \fi

574 & \l@ycmd{topmargin} = \number\l@youtvpii pt \\

575 \l@ycmd{headheight} = \number\l@youtvpiii pt &

576 \l@ycmd{headsep} = \number\l@youtvpiv pt \\

577 \l@ycmd{textheight} = \number\l@youtvpv pt &

578 \l@ycmd{textwidth} = \number\l@youthpii pt \\

579 \l@ycmd{footskip} = \number\l@youtvpvi pt &

580 \l@ycmd{marginparsep} = \number\l@youthpvi pt \\

581 \l@ycmd{marginparpush} = \number\l@youtvpvii pt &

582 \l@ycmd{columnsep} = \number\l@youthpiii pt \\

583 \l@ycmd{columnseprule} = \the\l@youtlinethick & \\

584 \end{tabular}

585 \end{ttfamily}\end{footnotesize}

586 \end{center}

587 \fi

The end of the definition for\drawpage.

588}

589

\pagediagram

\pagedesign

Shorthands.

590\newcommand{\pagediagram}{\drawparameterstrue\drawpage}

591\newcommand{\pagedesign}{\drawparametersfalse\drawpage}

592

\pagevalues This macro produces a table of the current page layout actual values.

593\newcommand{\pagevalues}{%

594%% \begin{center}

(20)

595 \ifprintheadings

596 Actual page layout values.\\[\baselineskip]

597 \fi

598 \begingroup\l@yvalsize

599 \begin{tabular}{l@{\hspace{20pt}}l}

600 \l@ycmd{paperheight} = \@ifundefined{paperheight}{??}{\l@yval{\paperheight}} &

601 \l@ycmd{paperwidth} = \@ifundefined{paperwidth}{??}{\l@yval{\paperwidth}} \\

602 \l@ycmd{hoffset} = \l@yval{\hoffset} &

603 \l@ycmd{voffset} = \l@yval{\voffset} \\

604 \l@ycmd{evensidemargin} = \l@yval{\evensidemargin} &

605 \l@ycmd{oddsidemargin} = \l@yval{\oddsidemargin} \\

606 \l@ycmd{topmargin} = \l@yval{\topmargin} &

607 \l@ycmd{headheight} = \l@yval{\headheight} \\

608 \l@ycmd{headsep} = \l@yval{\headsep} &

609 \l@ycmd{textheight} = \l@yval{\textheight} \\

610 \l@ycmd{textwidth} = \l@yval{\textwidth} &

611 \l@ycmd{footskip} = \l@yval{\footskip} \\

612 \l@ycmd{marginparsep} = \l@yval{\marginparsep} &

613 \l@ycmd{marginparpush} = \l@yval{\marginparpush} \\

614 \l@ycmd{columnsep} = \l@yval{\columnsep} &

615 \l@ycmd{columnseprule} = \l@yval{\columnseprule} \\

616 1em = \l@yval{\l@yonem} & 1ex = \l@yval{\l@yonex} \\

617 \end{tabular}

618 \endgroup

619%% \end{center}

620}

621

7 Drawing the layout of a memoir page

A variety of commands are used to draw the layout of a page as defined in the memoir class. We can reuse quite a lot from the previous page layout code.

622

623%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

624%%%% STOCK LAYOUT

625%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

626

\stockwidth

\stockwidth

\trimedge

\trimtop

\uppermargin

\spinemargin

The memoir class has some page layout parameters that are not in the standard classes. Provide these so the package will at least compile with the standard classes but is highly likely to die at runtime if this part of the code is used in other than the memoir class.

627\@ifundefined{stockwidth}{\newlength{\stockwidth}}{}

628\@ifundefined{stockheight}{\newlength{\stockheight}}{}

629\@ifundefined{trimedge}{\newlength{\trimedge}}{}

630\@ifundefined{trimtop}{\newlength{\trimtop}}{}

631\@ifundefined{uppermargin}{\newlength{\uppermargin}}{}

632\@ifundefined{spinemargin}{\newlength{\spinemargin}}{}

(21)

633

Now some utility commands for setting the layout dimensions.

\trystockwidth Sets the stockwidthand stores the result in\l@youthdo.

634\newcommand{\trystockwidth}[1]{\l@yltoc{#1}{\l@youthdo}}

\trystockheight Sets the stockheightand stores the result in\l@youtvdo.

635\newcommand{\trystockheight}[1]{\l@yltoc{#1}{\l@youtvdo}}

\trytrimedge Sets the trimedgeand stores the result in \l@youthpi.

636\newcommand{\trytrimedge}[1]{\l@yltoc{#1}{\l@youthpi}}

\trytrimtop Sets the trimtopand stores the result in \l@youtvpi.

637\newcommand{\trytrimtop}[1]{\l@yltoc{#1}{\l@youtvpi}}

\tryuppermargin Sets the uppermarginand stores the result in\l@youtvpii.

638\newcommand{\tryuppermargin}[1]{\l@yltoc{#1}{\l@youtvpii}}

\tryspinemargin Sets the spinemarginand stores the result in\l@youthpv.

639\newcommand{\tryspinemargin}[1]{\l@yltoc{#1}{\l@youthpv}}

640

\currentstock This routine sets the stock layout page parameters to those specified for the doc- ument.

641\newcommand{\currentstock}{%

642 \trystockwidth{\stockwidth}% % typically 8.5in

643 \trystockheight{\stockheight}% % typically 11in

644 \trypaperwidth{\paperwidth}% % typically 8.5in

645 \trypaperheight{\paperheight}% % typically 11in

646 \trytrimedge{\trimedge}% % typically 0pt

647 \trytrimtop{\trimtop}% % typically 0pt

648 \tryspinemargin{\spinemargin}% % typically 110pt

649 \tryuppermargin{\uppermargin}% % typically 125pt

650 \commonl@ypage

651}

652

\drawstock This routine draws a stock page layout.

653\newcommand{\drawstock}{%

First set some default vertical and horizontal dimension values.

654 \l@youtvdiii=\l@yteninch\relax

655 \divide\l@youtvdiii by 24\relax

656 \l@youthdii=\l@youtvdiii

657

658 \ifdrawparameters

(22)

Whendrawparametersis TRUE, we draw a generic layout showing the controlling layout variables.

659 \l@youtvdo=\l@yeleveninch\relax % stock height

660 \l@youthdo=\l@yeighthalfinch\relax % stock width

661 \l@youtvpi=\z@ % trimtop

662 \advance\l@youtvpi by \l@youtvdiii

663 \l@youthpi=\z@ % trimedge

664 \advance\l@youthpi by \l@youtvdiii

665 \l@youtph=\l@youtvdo % page height (= stock height)

666 \advance\l@youtph by -\l@youtvpi % minus trimtop

667 \advance\l@youtph by -\l@youtvpi % minus trimtop

668 \advance\l@youtph by -\l@youtvpi % minus trimtop

669 \l@youtpw=\l@youthdo % page width (= stock width)

670 \advance\l@youtpw by -\l@youthpi % minus trimedge

671 \advance\l@youtpw by -\l@youthpi % minus trimedge

672 \advance\l@youtpw by -\l@youthpi % minus trimedge

673 \l@youtvpiii=\l@youtvdiii % headheight

674 \l@youtvpiv=\l@youtvdiii % headsep

675 \l@youtvpii=\l@youtvdiii % uppermargin

676 \advance\l@youtvpii by \l@yoneinch % plus 1in

677 \advance\l@youtvpii by \l@youtvpiii % plus headheight

678 \advance\l@youtvpii by \l@youtvpiv % plus headsep

679 \l@youtvpv=\l@yoneinch\relax % textheight

680 \multiply\l@youtvpv by 6\relax

681 \l@youtvpvi=\l@youtvdiii % footskip

682 \multiply\l@youtvpvi by \tw@

683 \l@youtvdv=\l@youtvdiii % default footboxheight

684 \l@youtvdvi=\z@ % default footboxdepth

685 \l@youtvpvii=\l@youtvdiii % marginparpush

686 \l@youthpii=\l@youthdii % textwidth

687 \multiply\l@youthpii by 12\relax

688 \l@youthpv=\l@youthdii % spine margin

689 \advance\l@youthpv by \l@yoneinch % plus 1in

690 \multiply\l@youthpv by 7\relax % and take 70%

691 \divide\l@youthpv by 10\relax

692 \l@youthpiii=\l@youthdii % columnsep

693 \l@youthpvi=\l@youthdii % marginparsep

694 \l@youthpvii=\l@youthdii % marginparwidth

695 \multiply\l@youthpvii by \tw@

696 \fi

697

Calculate coordinates for use in the drawing. Some of these X coordinates depend on whether the page is odd or even.

698 \ifoddpagelayout

699 \l@youtxco=\l@youthdo % X coord of page bottom left (= stockwidth)

700 \advance\l@youtxco by -\l@youthpi % minus trimedge

701 \advance\l@youtxco by -\l@youtpw % minus page width

702 \else

703 \l@youtxco=\l@youthpi % X coord of page bottom left = trimedge

(23)

704 \fi

705 \l@youtyco=\l@youtvdo % Y coord of page bottom left (= stockheight)

706 \advance\l@youtyco by -\l@youtvpi % minus trimtop

707 \advance\l@youtyco by -\l@youtph % minus page height

708 \l@youtxcii=\l@youtxco % X coord of left of textblock (= left of page)

709 \ifoddpagelayout

710 \advance\l@youtxcii by \l@youthpv % plus spinemargin

711 \else

712 \advance\l@youtxcii by \l@youtpw % plus pagewidth

713 \advance\l@youtxcii by -\l@youthpv % minus spinemargin

714 \advance\l@youtxcii by -\l@youthpii % minus textwidth

715 \fi

716 \l@youtxciv=\l@youtxcii % X coord of left of marginnote (= left of textblock)

717 \l@youtxciv=\l@youtxcii

718 \@tempcnta\@ne

719 \ifmarginparswitch

720 \ifoddpagelayout \else \@tempcnta\m@ne \fi

721 \fi

722 \ifreversemarginpar \@tempcnta -\@tempcnta \fi

723 \ifnum\@tempcnta >\z@

724 \l@yrightmparstrue

725 \advance\l@youtxciv by \l@youthpii % plus textwidth

726 \advance\l@youtxciv by \l@youthpvi % plus marginnotesep

727 \else

728 \l@yrightmparsfalse

729 \advance\l@youtxciv by -\l@youthpvii % minus marginparwidth

730 \advance\l@youtxciv by -\l@youthpvi % minus marginnotesep

731 \fi

732 \l@youtycii=\l@youtvdo % Y coord of bottom of text (= stockheight)

733 \advance\l@youtycii by -\l@youtvpi % minus trimtop

734 \advance\l@youtycii by -\l@youtvpii % minus uppermargin

735 \advance\l@youtycii by -\l@youtvpv % minus textheight

736 \ifnum\l@youtvdv>\l@youtvpvi

737 \PackageWarning{layouts}{The footbox is higher than the footskip}

738 \l@youtvdv=\l@youtvpvi

739 \fi

740 \l@youtyci=\l@youtycii % Y coord of bottom of footer (= bottom of text)

741 \advance\l@youtyci by -\l@youtvpvi % minus footskip

742 \advance\l@youtyci by -\l@youtvdvi % minus box depth

743 \l@youtvdvii=\l@youtvdv % box height

744 \advance\l@youtvdvii by \l@youtvdvi % plus depth

745 \l@youtyciv=\l@youtycii % Y coord of bottom of header (= bottom of text)

746 \advance\l@youtyciv by \l@youtvpv % plus textheight

747 \advance\l@youtyciv by \l@youtvpiv % plus headsep

748

749 \l@youtvdii=\l@youtvpv % height of a marginal note

750 \divide\l@youtvdii by 4\relax

751 \l@youtyciii=\l@youtycii % Y coord of bottom of top note (= bottom of bottom note)

752 \advance\l@youtyciii by \l@youtvdii % plus note height

753 \advance\l@youtyciii by \l@youtvpvii % plus marginparpush

(24)

Now for column dependent values.

754 \l@youthdi=\l@youthpii % columnwidth = textwidth

755 \l@youtxciii=\l@youtxcii % X coord of right col

756 \iftwocolumnlayout

757 \advance\l@youthdi by -\l@youthpiii % colwidth = textwidth - colsep

758 \divide\l@youthdi by \tw@ % divided in half

759 \advance\l@youtxciii by \l@youthdi % X coord of right col X coord of text + col width

760 \advance\l@youtxciii by \l@youthpiii % plus colsep

761 \l@youtxcv=\l@youthpiii % centre of gutter

762 \divide\l@youtxcv by \tw@

763 \advance\l@youtxcv by \l@youtxcii

764 \advance\l@youtxcv by \l@youthdi

765 \fi

Print the caption for the top of the drawing.

766 \begin{center}

767 \l@yor{\ifdrawparameters}{\ifprintheadings}

768 \ifl@ytempif

769 \begin{small} Dashed lines represent the actual page size after trimming

770 the stock. \end{small} \\

771 \medskip

772 \fi

Draw the picture!

773 \setlength{\unitlength}{\l@youtunitlength}

774 \begin{picture}(\l@youthdo,\l@youtvdo)

775 \thicklines

Draw the stock, paper, etc.

776 \put(0,0){\framebox(\l@youthdo,\l@youtvdo){}} % the stock

777 \put(\l@youtxco,\l@youtyco){\dashbox{10}(\l@youtpw,\l@youtph){}} % the page

778 \put(\l@youtxcii,\l@youtyciv){\framebox(\l@youthpii,\l@youtvpiii)% % the header

779 {\l@ylabelfont Header}}

Draw the body, either one or two columns, then the footer.

780 \iftwocolumnlayout

781 \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)% % col 1

782 {\l@ylabelfont Col. 1}}

783 \put(\l@youtxciii,\l@youtycii){\framebox(\l@youthdi,\l@youtvpv)% % col2

784 {\l@ylabelfont Col. 2}}

785 \linethickness{\l@youtscale\l@youtlinethick}

786 \put(\l@youtxcv,\l@youtycii){\line(0,1){\l@youtvpv}} % rule

787 \linethickness{1pt}

788 \else

789 \put(\l@youtxcii,\l@youtycii){\framebox(\l@youthpii,\l@youtvpv)% % one col

790 {\l@ylabelfont Body}}

791 \fi

792 \put(\l@youtxcii,\l@youtyci){\framebox(\l@youthpii,\l@youtvdvii)% % footer

793 {\l@ylabelfont Footer}}

Marginal notes (two examples), if asked for

(25)

794 \ifdrawmarginpars

795 \ifdrawparameters

796 \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii){}}

797 \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%

798 {\l@ylabelfont\shortstack{Margin\\Note}}}

799 \else

800 \put(\l@youtxciv,\l@youtycii){\framebox(\l@youthpvii,\l@youtvdii)%

801 {\l@ylabelfont Note}}

802 \put(\l@youtxciv,\l@youtyciii){\framebox(\l@youthpvii,\l@youtvdii)%

803 {\l@ylabelfont Margin}}

804 \fi

805 \fi

806

If the footbox has a depth, draw a dashed line to mark the footskip.

807 \ifnum\l@youtvdvi > \z@

808 \thinlines

809 \advance\l@youtyci by \l@youtvdvi

810 \put(\l@youtxcii,\l@youtyci){\dashbox{10}(\l@youthpii,0){}}

811 \fi

That finishes the general drawing. We may have to now draw the parameters

812 \testdrawdimensions

813 \ifl@ytempif

814 \thinlines

We now draw labelled vectors indicating the layout parameters. Life gets tedious as we have to calculate a few more coordinate and length values. The code below is fairly incomprehensible as we are trying to minimise the number of counters.

815 \l@youtycv=\l@youtyco % Y coord of top of page (= page bottom)

816 \advance\l@youtycv by \l@youtph % plus pageheight

817 \l@youtvdviii=\l@youtvdiii % half l@youtvdiii (a small distance)

818 \divide\l@youtvdviii by \tw@

819 \l@youtxcv=\l@youtxcii % X coord for vertical dimensions

820 \advance\l@youtxcv by \l@youthdii % for ‘standard’ vertical vectors

821 %% do headheight

822 \put(\l@youtxcv,\l@youtyciv){\vector(0,1){\l@youtvpiii}}

823 \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){0}}

824 \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

825 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{headheight}}

826 \end{picture}}

827 %% do headsep

828 \put(\l@youtxcv,\l@youtyciv){\vector(0,-1){\l@youtvpiv}}

829 \put(\l@youtxcv,\l@youtyciv){\vector(0,1){0}}

830 \put(\l@youtxcv,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

831 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{headsep}}

832 \end{picture}}

833 %% do textheight

834 \put(\l@youtxcv,\l@youtycii){\vector(0,1){\l@youtvpv}}

835 \put(\l@youtxcv,\l@youtycii){\vector(0,-1){0}}

836 \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

(26)

837 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{textheight}}

838 \end{picture}}

839 %% do footskip

840 \put(\l@youtxcv,\l@youtycii){\vector(0,-1){\l@youtvpvi}}

841 \put(\l@youtxcv,\l@youtycii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

842 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{footskip}}

843 \end{picture}}

844 \ifdrawmarginpars

845 \l@youtxcv=\l@youthpvii % X coord for marginparpush

846 \divide\l@youtxcv by \tw@

847 \advance\l@youtxcv by \l@youtxciv

848 %% do marginparpush

849 \put(\l@youtxcv,\l@youtyciii){\vector(0,-1){\l@youtvpvii}}

850 \put(\l@youtxcv,\l@youtyciii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

851 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{marginparpush}}

852 \end{picture}}

853 \fi

854%% calculate X coord for uppermargin/trimtop parameters

855 \ifoddpagelayout

856 \ifl@yrightmpars

857 \l@youtxcv=\l@youtxciv % X coord for uppermargin, etc (= edge of note)

858 \else

859 \l@youtxcv=\l@youtxciv

860 \advance\l@youtxcv by \l@youthpvii % plus marginparwidth

861 \fi

862 \else

863 \ifl@yrightmpars

864 \l@youtxcv=\l@youtxciv

865 \else

866 \l@youtxcv=\l@youtxciv

867 \advance\l@youtxcv by \l@youthpvii % plus marginparwidth

868 \fi

869 \fi

870 %% do uppermargin

871 \put(\l@youtxcv,\l@youtycv){\vector(0,-1){\l@youtvpii}}

872 \put(\l@youtxcv,\l@youtycv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

873 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{uppermargin}}

874 \end{picture}}

875 %% do trimtop

876 \put(\l@youtxcv,\l@youtvdo){\vector(0,-1){\l@youtvpi}}

877 \put(\l@youtxcv,\l@youtvdo){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

878 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{trimtop}}

879 \end{picture}}

880%% X coord for stock height

881 \ifoddpagelayout

882 \ifl@yrightmpars

883 \l@youtxcv=\l@youtxco % X coord for stock height

884 \divide\l@youtxcv by \tw@ % 1/2 stock/paper left edges

885 \else

886 \l@youtxcv=\l@youtxco % X coord for stock height

(27)

887 \advance\l@youtxcv by \l@youtpw % plus page width

888 \advance\l@youtxcv by \l@youthpi % plus trimedge

889 \fi

890 \else

891 \ifl@yrightmpars

892 \l@youtxcv=\l@youtxco % X coord for stock height

893 \divide\l@youtxcv by \tw@ % 1/2 stock/paper left edges

894 \else

895 \l@youtxcv=\l@youtxco % X coord for stock height

896 \advance\l@youtxcv by \l@youtpw % plus page width

897 \advance\l@youtxcv by \l@youthpi % plus trimedge

898 \fi

899 \fi

900 %% do stockheight

901 \put(\l@youtxcv,0){\vector(0,1){\l@youtvdo}}

902 \put(\l@youtxcv,0){\vector(0,-1){0}}

903 \put(\l@youtxcv,\l@youtvdo){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

904 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{stockheight}}

905 \end{picture}}

906%% X coord for paper height

907 \ifoddpagelayout

908 \ifl@yrightmpars

909 \l@youtxcv=\l@youtxco % X coord for paper height

910 \advance\l@youtxcv by \l@youtxcii % plus left edge of text

911 \divide\l@youtxcv by \tw@

912 \else

913 \l@youtxcv=\l@youtxco % X coord for paper height

914 \advance\l@youtxcv by \l@youtpw % plus page width

915 \advance\l@youtxcv by \l@youtxcii % plus left edge of text

916 \advance\l@youtxcv by \l@youthpii % plus text width

917 \divide\l@youtxcv by \tw@

918 \fi

919 \else

920 \ifl@yrightmpars

921 \l@youtxcv=\l@youtxco % X coord for paper height

922 \advance\l@youtxcv by \l@youtxcii % plus left edge of text

923 \divide\l@youtxcv by \tw@

924 \else

925 \l@youtxcv=\l@youtxco % X coord for paper height

926 \advance\l@youtxcv by \l@youtpw % plus page width

927 \advance\l@youtxcv by \l@youtxcii % plus left edge of text

928 \advance\l@youtxcv by \l@youthpii % plus text width

929 \divide\l@youtxcv by \tw@

930 \fi

931 \fi

932 %% do paperheight

933 \put(\l@youtxcv,\l@youtyco){\vector(0,1){\l@youtph}}

934 \put(\l@youtxcv,\l@youtyco){\vector(0,-1){0}}

935 \put(\l@youtxcv,\l@youtycv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

936 \put(\l@youtvdviii,-\l@youtvdviii){\l@ypcmd{paperheight}}

(28)

937 \end{picture}}

938

939 \l@youtvpiii=\l@youtycii % Y coord for low dimensions

940 \advance\l@youtvpiii by \l@youtvdiii

941 \l@youtvpiv=\l@youtvpiii % Y coord for mid dimensions

942 \advance\l@youtvpiv by \l@youtvdiii

943 \l@youtvdi=\l@youtvpv % Y coord for top dimensions

944 \multiply\l@youtvdi by \tw@ % 2/3 of text height

945 \divide\l@youtvdi by 3\relax

946 \advance\l@youtvdi by \l@youtycii

947 \ifdrawmarginpars

948 %% do marginparwidth

949 \put(\l@youtxciv,\l@youtvpiii){\vector(1,0){\l@youthpvii}}

950 \put(\l@youtxciv,\l@youtvpiii){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

951 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{marginparwidth}}

952 \end{picture}}

953 \fi

954 \ifoddpagelayout

955 %% do spinemargin

956 \put(\l@youtxco,\l@youtvdi){\vector(1,0){\l@youthpv}}

957 \put(\l@youtxco,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

958 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{spinemargin}}

959 \end{picture}}

960 %% do trimedge

961 \put(\l@youthdo,\l@youtyciv){\vector(-1,0){\l@youthpi}}

962 \put(\l@youthdo,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

963 \put(-\l@youtvdviii,\l@youtvdviii){\l@ypcmd{trimedge}}

964 \end{picture}}

965 \else

966 \l@youtxcv=\l@youtxcii % X coord of right edge of text

967 \advance\l@youtxcv by \l@youthpii

968 %% do spinemargin

969 \put(\l@youtxcv,\l@youtvdi){\line(1,0){\l@youthpv}}

970 \put(\l@youtxcv,\l@youtvdi){\vector(-1,0){0}}

971 \put(\l@youtxcv,\l@youtvdi){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

972 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{spinemargin}}

973 \end{picture}}

974 %% do trimedge

975 \put(0,\l@youtyciv){\vector(1,0){\l@youthpi}}

976 \put(0,\l@youtyciv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

977 \put(\l@youtvdviii,\l@youtvdviii){\l@ypcmd{trimedge}}

978 \end{picture}}

979 \fi

980 %% marginal elements

981 \ifdrawmarginpars

982 %% do marginparsep

983 \ifl@yrightmpars

984 \put(\l@youtxciv,\l@youtvpiv){\line(-1,0){\l@youthpvi}}

985 \put(\l@youtxciv,\l@youtvpiv){\vector(1,0){0}}

986 \put(\l@youtxciv,\l@youtvpiv){\begin{picture}(\l@youtvdviii,\l@youtvdviii)

References

Related documents

[r]

Rational curves also allow to draw exact conics like ellipses, circles, parabolas and