| 1 |
% \iffalse |
| 2 |
% !TEX TS-program = pdflatex |
| 3 |
% !TEX encoding = UTF-8 Unicode |
| 4 |
%^^A Ho cercato di renderlo indipendente da m0,emoir (2022-10-24) |
| 5 |
% \fi |
| 6 |
% \iffalse |
| 7 |
%<*internal> |
| 8 |
\begingroup |
| 9 |
\input docstrip.tex |
| 10 |
\keepsilent |
| 11 |
\preamble |
| 12 |
______________________________________________________ |
| 13 |
The canoniclayout package for LaTeX |
| 14 |
Copyright (C) 2010 Claudio Beccari |
| 15 |
All rights reserved |
| 16 |
|
| 17 |
License information appended |
| 18 |
|
| 19 |
\endpreamble |
| 20 |
\postamble |
| 21 |
Copyright 2010 Claudio Beccari |
| 22 |
|
| 23 |
Distributable under the LaTeX Project Public License, |
| 24 |
version 1.3c or higher (your choice). The latest version of |
| 25 |
this license is at: http://www.latex-project.org/lppl.txt |
| 26 |
|
| 27 |
This work is "author-maintained" |
| 28 |
|
| 29 |
This work consists of this file canoniclayout.dtx, a README file |
| 30 |
and the derived files canoniclayout.sty and canoniclayout.pdf. |
| 31 |
|
| 32 |
\endpostamble |
| 33 |
\askforoverwritefalse |
| 34 |
% |
| 35 |
\generate{\file{canoniclayout.sty}{\from{canoniclayout.dtx}{package}}} |
| 36 |
% |
| 37 |
\def\tmpa{plain} |
| 38 |
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi |
| 39 |
\endgroup |
| 40 |
%</internal> |
| 41 |
% \fi |
| 42 |
% |
| 43 |
% \iffalse |
| 44 |
%<*driver> |
| 45 |
\ProvidesFile{canoniclayout.dtx} |
| 46 |
%</driver> |
| 47 |
%<package>\NeedsTeXFormat{LaTeX2e}[2009/01/01] |
| 48 |
%<package>\ProvidesPackage{canoniclayout}% |
| 49 |
%<*package> |
| 50 |
[2022/11/01 v.1.0 Text block height equal to paper width] |
| 51 |
%</package> |
| 52 |
%<*driver> |
| 53 |
\documentclass{ltxdoc} |
| 54 |
\paperwidth=220mm\paperheight=280mm |
| 55 |
\pdfpagewidth=\paperwidth \pdfpageheight=\paperheight |
| 56 |
%\usepackage[utf8]{inputenc} |
| 57 |
\usepackage[T1]{fontenc} |
| 58 |
\usepackage{lmodern} |
| 59 |
\usepackage{textcomp} |
| 60 |
\usepackage{multicol} |
| 61 |
\usepackage{amsmath,array,booktabs} |
| 62 |
\usepackage{pict2e}[2009/06/01]% |
| 63 |
\usepackage{color} |
| 64 |
\hfuzz 10pt |
| 65 |
|
| 66 |
\newcommand*\class[1]{\textsf{#1}} |
| 67 |
\newcommand*\pack[1]{\textsf{#1}} |
| 68 |
\newcommand*\prog[1]{\textsl{#1}} |
| 69 |
\newcommand*\file[1]{\texttt{#1}} |
| 70 |
\renewcommand*\meta[1]{{\normalfont\textlangle#1\textrangle}} |
| 71 |
\renewcommand*\marg[1]{\texttt{\{\meta{#1}\}}} |
| 72 |
\newcommand*\Marg[1]{\texttt{\{#1\}}} |
| 73 |
\renewcommand*\oarg[1]{\texttt{[\meta{#1]}}} |
| 74 |
\newcommand*\Oarg[1]{\texttt{[#1]}} |
| 75 |
\renewcommand*\cs[1]{\texttt{\char92#1}} |
| 76 |
\newcommand*\eTeX{$varepsilon$\TeX} |
| 77 |
|
| 78 |
\definecolor{grigio}{gray}{.75} |
| 79 |
\allowdisplaybreaks |
| 80 |
\begin{document} |
| 81 |
\GetFileInfo{canoniclayout.dtx} |
| 82 |
\title{Package \pack{canoniclayout}\\[0.5\baselineskip]{\normalsize Version number \fileversion; last |
| 83 |
revision \filedate.}} |
| 84 |
\author{Claudio Beccari\thanks{e-mail: \texttt{claudio dot beccari at gmail dot com}}} |
| 85 |
\maketitle |
| 86 |
\DocInput{canoniclayout.dtx} |
| 87 |
\end{document} |
| 88 |
%</driver> |
| 89 |
% \fi |
| 90 |
% |
| 91 |
% \CheckSum{466} |
| 92 |
% \begin{abstract} |
| 93 |
% This package may be used as an extension to the \class{memoir} or as a |
| 94 |
% standalone package that might work with any standard class. It tests if |
| 95 |
% \class{memoir} was loaded within the preamble, otherwise it does all the |
| 96 |
% necessary calculations with the usual facilities of a recent |
| 97 |
% \LaTeX\ based engine. |
| 98 |
% |
| 99 |
% This package computes the page parameters for a canonical layout where |
| 100 |
% the text block is placed onto the page in such a way that: $(a)$ its, |
| 101 |
% diagonal coincides with the page relevant diagonal, and $(b)$ the circle, |
| 102 |
% vertically inscribed within the text block, is also tangent to the page |
| 103 |
% sides. The text block width to height ratio is kept equal to the page |
| 104 |
% ratio, as well as the inner to outer and the top to bottom margin |
| 105 |
% ratios. See figure~\ref{fig:canoniclayout} |
| 106 |
% |
| 107 |
% \end{abstract} |
| 108 |
% |
| 109 |
% \begin{multicols}{2} |
| 110 |
% \tableofcontents |
| 111 |
% \end{multicols} |
| 112 |
% |
| 113 |
% \section{Introduction} |
| 114 |
% As any user of the \class{memoir} class knows well, this class allows |
| 115 |
% to customise the page layout virtually without any limitation; such |
| 116 |
% limitations are connected mainly with the user inconsistent data that |
| 117 |
% miss to specify necessary information or give unnecessary and |
| 118 |
% conflicting information. The same happens when \class{memoir} is not |
| 119 |
% being used. In facts, if \class{memoir} is not used, the package computes |
| 120 |
% the necessary data that turn out to be correct with the standard document |
| 121 |
% classes; they might be correct also with other classes, and users can |
| 122 |
% check the correctness by using some commands that are described below, |
| 123 |
% within the code documented section. |
| 124 |
% |
| 125 |
% Many packages exist in order to specify a specific layout; this package |
| 126 |
% \pack{canoniclayout} is another one that computes the page parameters |
| 127 |
% to determine the horizontal and vertical dimensions of the margins and |
| 128 |
% the text block. All other details shall be specified by the user, for |
| 129 |
% example the dimensions of the stock paper, the trimming widths, and |
| 130 |
% therefore the position of the page onto the stock paper, and so on. |
| 131 |
% This package deals only with the trimmed page, not with the page and |
| 132 |
% stock paper relationship. See the documentation of class \class{memoir} |
| 133 |
% in order to deal with stock paper and the details for configuring the |
| 134 |
% position of the page to be trimmed on the stock paper. With the standard |
| 135 |
% document classes this package works with the standard paper sizes |
| 136 |
% that \LaTeX\ can handle. An attempt to use package \pack{geometry} was |
| 137 |
% made, but it was abandoned, because this package has limitations due to |
| 138 |
% the two digit integer values of element ratios; may be in the future |
| 139 |
% it might be resumed. |
| 140 |
% |
| 141 |
% \begin{figure} |
| 142 |
% \makebox[\textwidth]{\makebox[1.1\textwidth][r]{% |
| 143 |
% \unitlength=0.0015\textwidth |
| 144 |
% \let\ul\unitlength |
| 145 |
% \begin{picture}(184,320)(0,-20) |
| 146 |
% \put(0,0){\framebox(184,297){}} |
| 147 |
% \put(27,70){\makebox(0,0)[bl]{\color{grigio}\rule{113\ul}{184\ul}}} |
| 148 |
% \put(92,-20){\makebox(0,0)[t]{Golden number canonical layout}} |
| 149 |
% \color{red} |
| 150 |
% \put(92,162){\circle{184}} |
| 151 |
% \linethickness{.2pt} |
| 152 |
% \multiput(0,297)(1.98918918919,-3.21081081082){93}{\line(184,-297){1}} |
| 153 |
% \end{picture}% |
| 154 |
% \hfill |
| 155 |
% \unitlength0.0015\textwidth |
| 156 |
% \let\ul\unitlength |
| 157 |
% \begin{picture}(210,330)(0,-20) |
| 158 |
% \put(0,0){\framebox(210,297){}} |
| 159 |
% \put(25,51){\makebox(0,0)[bl]{\color{grigio}\rule{149\ul}{210\ul}}} |
| 160 |
% \put(105,-35){\makebox(0,0)[b]{ISO canonical layout}} |
| 161 |
% \color{red} |
| 162 |
% \put(105,156){\circle{210}} |
| 163 |
% \multiput(0,297)(2.27027027027,-3.21081081082){93}{\line(210,-297){1}} |
| 164 |
% \end{picture}% |
| 165 |
% \hfill |
| 166 |
% \unitlength0.001591\textwidth |
| 167 |
% \let\ul=\unitlength |
| 168 |
% \begin{picture}(220,330)(0,-20) |
| 169 |
% \put(0,0){\framebox(220,280){}} |
| 170 |
% \put(20.742,33.6){\makebox(0,0)[bl]{\color{grigio}\rule{172.86\ul}{220\ul}}} |
| 171 |
% \put(110,-35){\makebox(0,0)[b]{Letter paper canonical layout}} |
| 172 |
% \color{red} |
| 173 |
% \put(110,143.6){\circle{220}} |
| 174 |
% \multiput(0,280)(2.37837837838,-3.02702702703){93}{\line(220,-280){1}} |
| 175 |
% \end{picture} |
| 176 |
% }}% |
| 177 |
% \caption{A right page with the relevant diagonal, the text block and the |
| 178 |
% canonical circle. In this figure the important pieces of information are |
| 179 |
% the page proportions, not the drawing scale; matter of fact the letter |
| 180 |
% paper is 17.6~mm shorter than the A4 paper, but the drawings to the same |
| 181 |
% height emphasises the relative proportions of the various page parts.} |
| 182 |
% \label{fig:canoniclayout} |
| 183 |
% \end{figure} |
| 184 |
% |
| 185 |
% Figure~\ref{fig:canoniclayout} depicts the situation described above; |
| 186 |
% the grey rectangle represents the type block; the dotted page diagonal, |
| 187 |
% as it can be seen, passes through the diagonal vertices of the type |
| 188 |
% block; at the same time the circle is tangent to both the type block |
| 189 |
% and the page contour\footnote{Geometrically speaking this sentence is |
| 190 |
% meaningless, but the drawings in the picture show what we mean.}. |
| 191 |
%. |
| 192 |
% It must also be noticed, in the sketch on the left, that the page |
| 193 |
% rectangle is a golden one; therefore also the type block is a golden |
| 194 |
% rectangle; the inner to the outer margin ratio is the golden section |
| 195 |
% value so as this same ratio exists between the top and the bottom margin. |
| 196 |
% |
| 197 |
% This canonical layout implies that the type block height is equal to the |
| 198 |
% page width. Therefore this canonical layout is not suited when the page |
| 199 |
% width is small compared to the page height: with the golden |
| 200 |
% section\footnote{Here we denote $\phi=1,618\dots$ with the name of |
| 201 |
% \emph{golden number}, and its reciprocal $\varphi=0.618\dots$ with the |
| 202 |
% name of \emph{golden section}.} this ratio is 0.618. |
| 203 |
% |
| 204 |
% With the ISO paper shape, in the sketch on the center, this ratio is |
| 205 |
% 0.707, and so on. |
| 206 |
% |
| 207 |
% But it is also evident that this layout is unsuitable with squarish |
| 208 |
% pages, such as the sketch on the right where the page proportions are |
| 209 |
% those of the USA letter paper size: the type block leaves little space |
| 210 |
% for the margins, as it is evident from the properties of the canonical |
| 211 |
% circle, which is tangent to the page lateral sides and to the type block |
| 212 |
% horizontal sides; to the limit in a square trimmed page the type block |
| 213 |
% fills he whole page so that the margins vanish. |
| 214 |
% |
| 215 |
% \section{The mathematics of the canonical layout} |
| 216 |
% With reference to the drawing on figure~\ref{fig:canoniclayout} |
| 217 |
% and what has been described in the Introduction, the following formulas |
| 218 |
% may be easily derived: |
| 219 |
%\begin{align} |
| 220 |
% &\text{Page shape ratio:} & x &=b/h \label{equ:1} \\ |
| 221 |
% &\text{Inner margin:} & I &=bx(1-x)/(1+x) \\ |
| 222 |
% &\text{External margin:} & E &=b(1-x)/(1+x) \\ |
| 223 |
% &\text{Top margin:} & T &=hx(1-x)/(1+x) \\ |
| 224 |
% &\text{Bottom margin:} & B &=h(1-x)/(1+x) \\ |
| 225 |
% &\text{Text width:} & W &=xb \\ |
| 226 |
% &\text{Text height:} & H &=b \\ |
| 227 |
% &\text{Circle center abscissa:}& C_x&=b/2 \\ |
| 228 |
% &\text{Circle center ordinate:}& C_y&=h(1-x)/(1+x)+b/2 \\ |
| 229 |
% &\text{Circle radius:} & R &=b/2 \label{equ:10} |
| 230 |
%\end{align} |
| 231 |
% Notice that the circle center coordinates are referred to the lower |
| 232 |
% left corner of the trimmed page. |
| 233 |
% |
| 234 |
% The results of the above formulas are summarised in |
| 235 |
% table~\ref{tab:canoniclayout} for four values of the shape factor |
| 236 |
% including the USA letter paper, that is 8.5~inches wide and 11~inches |
| 237 |
% high. |
| 238 |
% |
| 239 |
%\begin{table}[!b]\centering\let~\enspace |
| 240 |
%\hrule |
| 241 |
%\caption{Canonical layout ratios referred to the the base (or width, $b$) |
| 242 |
% of the trimmed page and its height ($h$). |
| 243 |
% The circle coordinates are referred to the lower left corner of the |
| 244 |
% trimmed page.}\label{tab:canoniclayout} |
| 245 |
%\bigskip |
| 246 |
%\begin{tabular}{l@{\qquad}*4{>{$}c<{$}}} |
| 247 |
%\toprule |
| 248 |
% &\multicolumn4c{Page ratio $h/b$} \\ |
| 249 |
%\multicolumn1c{Quantity}& \phi:1 & 3:2 & \sqrt2:1 & 11:8.5\\ |
| 250 |
%\midrule |
| 251 |
% Base to height ratio &0.6180 &0.6666 &0.7071 &0.7727~\\ |
| 252 |
% Inner margin &0.146b &0.133b &0.121b &0.099b \\ |
| 253 |
% External margin &0.236b &0.200b &0.172b &0.128b \\ |
| 254 |
% Top margin &0.146h &0.133h &0.121h &0.099h \\ |
| 255 |
% Bottom margin &0.236h &0.200h &0.172h &0.128h \\ |
| 256 |
% Text width &0.618b &0.666b &0.707b &0.773b \\ |
| 257 |
% Text height & b & b & b &b \\ |
| 258 |
% Circle center abscissa & b/2 & b/2 & b/2 &b/2 \\ |
| 259 |
% Circle center ordinate & 0.545h &0.533h &0.526h &0.515h \\ |
| 260 |
% Circle diameter & b & b & b & b \\ |
| 261 |
%\bottomrule |
| 262 |
%\end{tabular} |
| 263 |
%\end{table} |
| 264 |
% |
| 265 |
% Actually the formulas~\ref{equ:1}--\ref{equ:10}, and their numerical |
| 266 |
% values reported in table~\ref{tab:canoniclayout}, are just for general |
| 267 |
% information. The actual computations are performed by this package, by |
| 268 |
% means of the package built-in facilities. But it can be easily seen that |
| 269 |
% as the trimmed page becomes more squarish, the page size ratio tends to |
| 270 |
% one, and the margins become smaller and tend to vanish. Therefore it |
| 271 |
% seems that this layout is most suited for intermediate page ratios, such |
| 272 |
% as the ISO one or the common European book page size of 170\,mm |
| 273 |
% by~240\,mm with a ratio $b/h=0.708$. |
| 274 |
% |
| 275 |
% \section{Usage} |
| 276 |
% This package is invoked as usual with: |
| 277 |
%\begin{verbatim} |
| 278 |
% \usepackahe{canoniclayout} |
| 279 |
%\end{verbatim} |
| 280 |
% No options are required; but it is necessary to invoke the package only |
| 281 |
% after the page dimensions are known, be they specified by a class option, |
| 282 |
% such as, for example, \texttt{a4paper}, or by means of explicit |
| 283 |
% \verb|\paperwidth| and \verb|\paperheight| assignments. |
| 284 |
% |
| 285 |
% At a convenient moment after calling this package, the trimming margins |
| 286 |
% with respect to the trimmed page may be computed and the layout |
| 287 |
% rechecked and fixed for consistency. The convenient moment is chosen by |
| 288 |
% the package to be at the \cs{begin}\Marg{document} statement execution, |
| 289 |
% because only at that moment all required packages are loaded and |
| 290 |
% possibly the user's macros are defined and settings are~set. |
| 291 |
% |
| 292 |
% \section{Font normal size} |
| 293 |
% At the same time, if this page layout is chosen, the font normal size |
| 294 |
% should be selected on the actual text block width; it is possible that |
| 295 |
% the golden ratio type block, on a golden rectangle paper obtained by |
| 296 |
% trimming an ISO A4 stock paper, might be suitable with a 10pt normal |
| 297 |
% font size (exactly 66 characters per line with 10pt Latin Modern fonts), |
| 298 |
% while a full ISO A4 paper yields a type block that might be more suited |
| 299 |
% for a 12pt normal font size (about 86 characters with 10pt Latin Modern |
| 300 |
% fonts). The computations might be left, for example, to the used class |
| 301 |
% \class{memoir} commands or to the user specifications, but it is |
| 302 |
% important that the user is aware of this particular point. |
| 303 |
% |
| 304 |
% For the user's sake this package provides the command |
| 305 |
% |\currentfontletters| (to be used only after |\begin{document}|, |
| 306 |
% because this package computations are available only after the |
| 307 |
% \cs{begin}\Marg{document} delayed computations are done; in any case the |
| 308 |
% command types out a sentence such as “The number of characters in one |
| 309 |
% text line with the current font is $n$'', where the $n$ is the actual |
| 310 |
% number printed out. If such number is much outside the ideal Bringhurst |
| 311 |
% range of $66\pm5$, it is wiser to chose a larger or smaller normal font |
| 312 |
% size. |
| 313 |
% |
| 314 |
% In any case the alternative command |\charactersperpage| types out the |
| 315 |
% same above information, the number of lines and the estimated number of |
| 316 |
% characters per page. These commands are supposed to be useful while |
| 317 |
% setting up or revise the complete preliminary parameters for the page |
| 318 |
% layout. |
| 319 |
% |
| 320 |
% Just to have a comparison, table~\ref{tab:sizes} displays the number of |
| 321 |
% characters in one line of text for several fonts and for page sizes A4, |
| 322 |
% A5, and~B5. |
| 323 |
% |
| 324 |
%\begin{table} |
| 325 |
%\caption{Text line lengths measured in average number |
| 326 |
% of characters in different fonts}\label{tab:sizes} |
| 327 |
% \bigskip |
| 328 |
% |
| 329 |
% \centering |
| 330 |
% \let\b\bfseries \let\i\itshape\tabcolsep=5pt |
| 331 |
% \makebox[\textwidth]{\small\begin{tabular}{l*9c} |
| 332 |
% \toprule |
| 333 |
% Font collection & \multicolumn3c{A4 paper size} |
| 334 |
% & \multicolumn3c{A5 paper size} |
| 335 |
% &\multicolumn3c{B5 paper size}\\ |
| 336 |
% & 10\,pt & 11\,pt & 12\,pt & 10\,pt & 11\,pt & 12\,pt & 10\,pt & 11\,pt & 12\,pt \\ |
| 337 |
% \midrule |
| 338 |
% Times eXtended & \i92 & \i84 & \i77 & \b64 & 59 & \i54 & \i77 & \b70 & \b64 \\ |
| 339 |
% Latin Modern & \i86 & \i79 & 73 & 60 & \i55 & \i51 & 72 & \b66 & \b61 \\ |
| 340 |
% Kepler Project & \i83 & 76 & \b69 & 58 & \i53 & \i48 & \b69 & \b63 & 58 \\ |
| 341 |
% Palatino eXtended& \i82 & 75 & \b69 & 58 & \i53 & \i48 & \b69 & \b63 & 57 \\ |
| 342 |
% \bottomrule |
| 343 |
% \end{tabular}} |
| 344 |
%\end{table} |
| 345 |
% |
| 346 |
% It can be seen that the bold typeset numbers satisfy the Bringhurst rule |
| 347 |
% with such numbers falling within the range $66\pm5$; the computed numbers |
| 348 |
% typeset in normal series and shape are slightly out of the optimal |
| 349 |
% Bringhurst range, and may be considered acceptable; those typeset in |
| 350 |
% italics are completely out of the interval $66\pm10$ and should not be |
| 351 |
% accepted. |
| 352 |
% This means that the large A4 paper size may be best used with |
| 353 |
% intrinsically large fonts such as the Palatino eXtended (package |
| 354 |
% \pack{pxfonts} or \pack{newpxtext}) and the Kepler Project (package |
| 355 |
% \pack{kpfonts}). |
| 356 |
% |
| 357 |
% With the smaller A5 paper size with 10\,pt size fonts, the best ones are |
| 358 |
% the Times eXtended (package \pack{txfonts} or \pack{newtxtext}), but |
| 359 |
% substantially all the examined fonts are acceptable except those in |
| 360 |
% 12\,pt size. |
| 361 |
% |
| 362 |
% With an intermediate sized paper, such as a B5 ISO size, all the |
| 363 |
% considered fonts are acceptable inside or just outside the optimal |
| 364 |
% Bringhurst interval. |
| 365 |
% |
| 366 |
% Many books have trimmed pages sized close the B5 paper size, therefore |
| 367 |
% the page layout produced with this package is most useful with medium and |
| 368 |
% smaller paper sizes (at least with the ISO ones). |
| 369 |
|
| 370 |
% \section{Conclusion} |
| 371 |
% We don't think this package should set also the header and footer |
| 372 |
% distances, for example, or should set any specification for the page |
| 373 |
% “decorations”, such as underlined headers, or over lined footers, or |
| 374 |
% the font size, family, series and shape of the header and footer |
| 375 |
% contents. These specifications are of course important, but have nothing |
| 376 |
% to do with the relationship between the paper size, the page size and the |
| 377 |
% type block size. |
| 378 |
% |
| 379 |
% |
| 380 |
% \StopEventually{}^^A================================================== |
| 381 |
% |
| 382 |
% \section{Documented code} |
| 383 |
% The package preliminaries are already in place. We are going to make some |
| 384 |
% computations in order to determine the page shape factor $x$; |
| 385 |
% to this end we use the functionalities of the \LaTeX\,3 language, already |
| 386 |
% contained in the \LaTeX\ kernel since 2020; even dimensions and skip |
| 387 |
% calculations are being available since June 2022. But the first thing |
| 388 |
% to do is to verify if the package is being used with a sufficiently |
| 389 |
% recent version of the \LaTeX\ engine; we test if the kernel has |
| 390 |
% a date of at least 2022/06/01 |
| 391 |
% |
| 392 |
% We exploit also the \eTeX\ dimensional computing capabilities, that are |
| 393 |
% already embedded in the most recent implementations of the program |
| 394 |
% \prog{pdftex}; in fact it must be remarked that these facilities are |
| 395 |
% being embedded into the \LaTeX\ based typesetting engine since the |
| 396 |
% \TeX~Live distribution of the year 2005. If these facilities are not |
| 397 |
% available, either because the \TeX\ distribution is a little too old, or |
| 398 |
% because the real \prog{tex} typesetting interpreter, not \prog{pdftex}, |
| 399 |
% or\prog{luatex}, or \prog{xetex}, is being used, then this entire |
| 400 |
% package contents is skipped and nothing is done, except issuing a |
| 401 |
% suitable warning. |
| 402 |
%\iffalse |
| 403 |
%<*package> |
| 404 |
%\fi |
| 405 |
% \begin{macrocode} |
| 406 |
\IfFormatAtLeastTF{2022/06/01}{}{% |
| 407 |
\PackageWarning{canoniclayout}{% |
| 408 |
The format file is not suited\MessageBreak |
| 409 |
for working with this package.\MessageBreak |
| 410 |
This package is being skipped and \MessageBreak |
| 411 |
its functionalities are not available |
| 412 |
\expandafter\endinput} |
| 413 |
\fi} |
| 414 |
|
| 415 |
% \end{macrocode} |
| 416 |
% Then we test if the \class{memoir} class is being used; if that is the |
| 417 |
% case, we use its code (identical to the one of the previous package |
| 418 |
% version), otherwise we set up the code for this package internal |
| 419 |
% computations.. |
| 420 |
% |
| 421 |
% We delay both codes to the \cs{begin}\Marg{document} statement execution, |
| 422 |
% so% we are sure that there are no interferences between the document |
| 423 |
% preamble settings and the \pack{canoniclayout}~ones. |
| 424 |
% |
| 425 |
% The user might start his main document \file{.tex} file according to the |
| 426 |
% following model: |
| 427 |
% \begin{flushleft}\obeylines |
| 428 |
% \cs{documentclass}\Oarg{...,a4paper,...}\marg{class} |
| 429 |
% ... |
| 430 |
% \cs{usepackage}\Marg{canoniclayout} |
| 431 |
% ... |
| 432 |
% \cs{begin}\Marg{document} |
| 433 |
% \meta{main document body} |
| 434 |
% \cs{end}\Marg{document} |
| 435 |
% \end{flushleft} |
| 436 |
% It is very important that the paper size be established within the |
| 437 |
% options of the \cs{documentclass} statement, because this package |
| 438 |
% needs the dimensions of the page to deal with. |
| 439 |
% \subsection[Using the memoir class]{Using the \class{memoir} class} |
| 440 |
% \begin{macrocode} |
| 441 |
\@ifclassloaded{memoir}{% |
| 442 |
\AtBeginDocument{% |
| 443 |
% \end{macrocode} |
| 444 |
% Now we can determine the page shape factor and we save it into the |
| 445 |
% control sequence \cs{CLshape}. The trick of multiplying by \cs{p@}, a |
| 446 |
% length of 1\,pt, is a simple trick for reducing the shape ratio to a |
| 447 |
% length whose numerical value is exactly the ratio we are interested in. |
| 448 |
% By stripping the `pt' part from this dimension value we remain with the |
| 449 |
% real number we want to keep in memory. Of course we need also the |
| 450 |
% reciprocal value so that we have to perform this calculation two times |
| 451 |
% with different factors. This “strange” way of computing real ratios |
| 452 |
% derives from the ability of the \eTeX\ engine to scale lengths with a |
| 453 |
% higher computational precision than “normal” \TeX\ can do with the |
| 454 |
% standard dimension and integer operations. In facts all the computational |
| 455 |
% operations are performed within the computer CPU and the intermediate |
| 456 |
% first result of the multiplication is kept into a double length register, |
| 457 |
% so that no bits are rounded or truncated; the division operation is |
| 458 |
% therefore performed with a double length numerator and a single length |
| 459 |
% denominator, so that, again, almost no information is lost at the |
| 460 |
% inevitable end of the division algorithm with a non vanishing remainder. |
| 461 |
% \begin{macrocode} |
| 462 |
\dimen@=\dimexpr \p@ * \paperwidth / \paperheight\relax |
| 463 |
\edef\CLshape{\strip@pt\dimen@} |
| 464 |
\dimen@=\dimexpr \p@ * \p@ / \dimen@\relax |
| 465 |
\edef\CLinvshape{\strip@pt\dimen@} |
| 466 |
% \end{macrocode} |
| 467 |
% We then assign the text height, thanks to the fact that the canonical |
| 468 |
% layout has the block height just as long as the page width, thanks to the |
| 469 |
% circle property mentioned in the Introduction; in any case |
| 470 |
% formulas~\ref{equ:1}--\ref{equ:10} and table~\ref{tab:canoniclayout} |
| 471 |
% confirm this property for any shape. |
| 472 |
% \begin{macrocode} |
| 473 |
\textheight=\paperwidth |
| 474 |
% \end{macrocode} |
| 475 |
% |
| 476 |
% This done, we can use the internal \class{memoir} commands to determine |
| 477 |
% the other layout dimensions. |
| 478 |
% \begin{macrocode} |
| 479 |
\settypeblocksize{\textheight}{*}{\CLshape} |
| 480 |
\setlrmargins{*}{*}{\CLinvshape} |
| 481 |
\setulmargins{*}{*}{\CLinvshape} |
| 482 |
\setmarginnotes{7pt}{\dimexpr \foremargin-3\marginparsep}{\onelineskip} |
| 483 |
|
| 484 |
% \end{macrocode} |
| 485 |
% |
| 486 |
% We now use the \cs{checkandfixthelayout} so that it prints the page |
| 487 |
% parameters to the \file{.log} file. |
| 488 |
% \begin{macrocode} |
| 489 |
\checkandfixthelayout |
| 490 |
}}% memoir class end code; start code for standard classes |
| 491 |
% \end{macrocode} |
| 492 |
% |
| 493 |
% \subsection{Using a standard class} |
| 494 |
% Now we define the code in case \class{memoir} is not being used; the |
| 495 |
% various computations require a longer code. We need the |
| 496 |
% \pack{pict2e} package in order to use the |picture| environment with the |
| 497 |
% upgrades foreseen by Leslie Lamport himself and available since 2003. |
| 498 |
% We need also package \pack{etoolbox} in order to have an easy access to |
| 499 |
% the recent \LaTeX\ kernel hooks. In particular we use the |
| 500 |
% \cs{AtEndPreamble} hook command so as to be sure that all settings |
| 501 |
% for the paper size and the user preamble settings are already fixed. |
| 502 |
% |
| 503 |
% \begin{macrocode} |
| 504 |
% |
| 505 |
{\RequirePackage{etoolbox,pict2e}% |
| 506 |
\AtEndPreamble{% |
| 507 |
% |
| 508 |
% \end{macrocode} |
| 509 |
% If we use a standard class, we miss the powerful \class{memoir} commands; |
| 510 |
% we do not copy them into this package, but we make our own calculations; |
| 511 |
% by so doing we have full control also on the necessary parameters for |
| 512 |
% drawing the circles and the relevant diagonals. The necessary code is |
| 513 |
% going to be longer that that required for the \class{memoir} class, |
| 514 |
% also because we have to redefine the four standard page styles. |
| 515 |
% |
| 516 |
% We compute the relevant values by using equations from~\ref{equ:1} |
| 517 |
% to~\ref{equ:10}. Notice that we also create the service macros for |
| 518 |
% drawing the circle and the relevant page diagonal in case the user |
| 519 |
% wants them to appear in certain pages; see below for more details. |
| 520 |
% In any case we must check if the |\color| macro is available; in case |
| 521 |
% it is not, we load the \pack{xcolor} package without any options. |
| 522 |
% |
| 523 |
% Attention: if users want to use colors in their document, they should |
| 524 |
% load either package \pack{color} or package \pack{xcolor} with their |
| 525 |
% options \textcolor{red}{before} loading this package |
| 526 |
% \pack{canoniclayout}. If this is done, users are sure that the package |
| 527 |
% loaded within this module will not override their settings; notice that |
| 528 |
% \pack{xcolor} redefines some macros that have the same name as those of |
| 529 |
% \pack{color}; therefore \pack{color} might be loaded before |
| 530 |
% \pack{canoniclayout}, absolutely not \textcolor{red}{after}, otherwise |
| 531 |
% some \pack{xcolor} functionalities get corrupted; see the \pack{xcolor} |
| 532 |
% documentation. In a different wording: \textcolor{red}{avoid loading |
| 533 |
% package \pack{color}, because its functionalities are given |
| 534 |
% by \pack{xcolor} and \pack{color} is not required any more!} |
| 535 |
% \begin{macrocode} |
| 536 |
\unless\ifcsname color\endcsname \RequirePackage{xcolor}\fi |
| 537 |
\newlength\CLinner \newlength\CLouter % new length registers |
| 538 |
\newlength\CLtop \newlength\CLbottom % other new registers |
| 539 |
\edef\CLx{\fpeval{\paperwidth/\paperheight}}% equation 1 |
| 540 |
\edef\CLxx{\fpeval{(1-\CLx)/(1+\CLx)}}% for equations 2, 3, 4, 5, 9 |
| 541 |
\CLinner=\fpeval{\paperwidth*\CLx*\CLxx}\p@% equation 2 |
| 542 |
\CLouter=\fpeval{\paperwidth*\CLxx}\p@% equation 3 |
| 543 |
\CLtop=\fpeval{\paperheight*\CLx*\CLxx}\p@% equation 4 |
| 544 |
\CLbottom=\fpeval{\paperheight*\CLxx}\p@% equation 5 |
| 545 |
\textwidth=\fpeval{\CLx*\paperwidth}\p@% equation 6 |
| 546 |
\textheight=\paperwidth% equation 7 |
| 547 |
\edef\CLcirclecenterX{\fpeval{\paperwidth/2}}% equation 8 |
| 548 |
\edef\CLcirclecenterY{\fpeval{\CLxx*\paperheight+\paperwidth/2}}% eq. 9 |
| 549 |
\let\CLcircleradius\CLcirclecenterX% equation 10 |
| 550 |
\edef\CLcirclediameter{\strip@pt\paperwidth}% |
| 551 |
\let\CLpageW\CLcirclediameter |
| 552 |
|
| 553 |
% \end{macrocode} |
| 554 |
% Then the text body height is proportional to the text body width trough |
| 555 |
% the above determined ratios. |
| 556 |
% We now set the other necessary page settings, even if by so doing, it |
| 557 |
% becomes impossible to modify them either in the preamble or after the |
| 558 |
% \cs{begin}\Marg{document} command. May be in the future this constraint |
| 559 |
% may be eliminated. |
| 560 |
% \begin{macrocode} |
| 561 |
\normalsize |
| 562 |
\headheight=\baselineskip |
| 563 |
\headsep=\baselineskip |
| 564 |
\footskip=2\baselineskip |
| 565 |
\marginparsep=0.1\CLouter\relax |
| 566 |
\marginparwidth=0.8\CLouter\relax |
| 567 |
\topmargin=\dimexpr\CLtop-\headsep-\headheight-1in\relax |
| 568 |
\oddsidemargin=\dimexpr\CLinner-1in \relax |
| 569 |
\evensidemargin=\dimexpr\CLouter-1in \relax |
| 570 |
|
| 571 |
% \end{macrocode} |
| 572 |
% |
| 573 |
% While \class{memoir} uses its computed results and applies them to all |
| 574 |
% pages; with the local calculations it is necessary to redesign the page |
| 575 |
% styles; we redefine also the |empty| and |plain| styles so as to have a |
| 576 |
% place holder in the otherwise empty headers, such that users can verify |
| 577 |
% the correct layout geometry by placing under the text being typeset, |
| 578 |
% a red drawing that shows the circle and the diagonal. Since the place |
| 579 |
% holder may contain some executable code, it is necessary to have handy |
| 580 |
% user macros to set it on or off. |
| 581 |
% |
| 582 |
% \begin{macrocode} |
| 583 |
\edef\CLdiagX{\strip@pt\paperwidth}% diagonal horizontal component |
| 584 |
\edef\CLdiagY{\strip@pt\paperheight}% diagonal vertical component |
| 585 |
\let\@CLdrawing\relax% initially drawings are turned off |
| 586 |
%Coordinates of the lower left page corner relative to the header origin |
| 587 |
\edef\CLlly{-\expandafter\strip@pt% both pages corner ordinate |
| 588 |
\dimexpr\paperheight-\CLtop+\headsep}% |
| 589 |
\edef\CLllLx{-\strip@pt\CLouter}% lower left left-page corner abscissa |
| 590 |
\edef\CLllRx{-\strip@pt\CLinner}% lower left right-page corner abscissa |
| 591 |
% \end{macrocode} |
| 592 |
% The user commands for turning on and off the canonical layout drawings |
| 593 |
% are the following; sometimes it might be necessary to delay them |
| 594 |
% to the start of a new page; this may me easily done by using the |
| 595 |
% \pack{afterpage} package and its command \cs{afterpage}. |
| 596 |
% There are two commands, one for starting to insert drawings |
| 597 |
% in consecutive pages, and another to stop this functionality. |
| 598 |
% \begin{macrocode} |
| 599 |
|
| 600 |
\newcommand*\CLstartdrawings{\let\@CLdrawing\CLdrawing} |
| 601 |
\newcommand*\CLstopdrawings{\let\@CLdrawing\relax} |
| 602 |
|
| 603 |
\newcommand*\CLdrawing{% |
| 604 |
\begin{picture}(0,0)\color{red}% |
| 605 |
\unitlength=\p@ |
| 606 |
\if@twoside |
| 607 |
\ifodd\value{page}% |
| 608 |
\put(\CLllRx,\CLlly){% right page: displaces the origin to the |
| 609 |
% lower left paper corner |
| 610 |
\put(\CLcirclecenterX,\CLcirclecenterY){\circle{\CLcirclediameter}} |
| 611 |
\put(\CLpageW,0){\line(-\CLdiagX,\CLdiagY){\CLpageW}} |
| 612 |
} |
| 613 |
\else |
| 614 |
\put(\CLllLx,\CLlly){% left page: displaces the origin to the |
| 615 |
% lower left paper corner |
| 616 |
\put(\CLcirclecenterX,\CLcirclecenterY){\circle{\CLcirclediameter}} |
| 617 |
\put(0,0){\line(\CLdiagX,\CLdiagY){\CLpageW}} |
| 618 |
} |
| 619 |
\fi |
| 620 |
\else |
| 621 |
\put(\CLllRx,\CLlly){% one side: displaces the origin to the |
| 622 |
% lower left paper corner |
| 623 |
\put(\CLcirclecenterX,\CLcirclecenterY){\circle{\CLcirclediameter}} |
| 624 |
\put(\CLcirclecenterX,\CLcirclecenterY){% |
| 625 |
\put(0,0){\line(\CLdiagX,\CLdiagY){\CLcircleradius}} |
| 626 |
\put(0,0){\line(-\CLdiagX,-\CLdiagY){\CLcircleradius}} |
| 627 |
} |
| 628 |
} |
| 629 |
\fi |
| 630 |
\end{picture} |
| 631 |
} |
| 632 |
% \end{macrocode} |
| 633 |
% Now we redefine the four standard page styles so as to set the place |
| 634 |
% holder in all the headers; when this place holder is activated by |
| 635 |
% \cs{CLstartdrawings}, it gets defined with an environment |picture| |
| 636 |
% code extended by the use of package \pack{pict2e}. The environment |
| 637 |
% |picture| initial command has zero dimensions, therefore it does not |
| 638 |
% occupy any space in the headers. Command \cs{CLstopdrawings} redefines |
| 639 |
% the place holder to \cs{relax} and stops all drawings relative |
| 640 |
% to the page design. |
| 641 |
% \begin{macrocode} |
| 642 |
\def\ps@empty{% |
| 643 |
\let\@mkboth\@gobbletwo |
| 644 |
\def\@oddhead{\makebox[\textwidth][l]{{\@CLdrawing}}}\let\@oddfoot\@empty |
| 645 |
\def\@evenheadhead{\makebox[\textwidth][l]{{\@CLdrawing}}} |
| 646 |
\let\@evenfoot\@empty} |
| 647 |
% \end{macrocode} |
| 648 |
% The above settings for an empty page may be useful to get the drawing |
| 649 |
% in a completely empty page, without any other object entering the page. |
| 650 |
% |
| 651 |
% The following redefinition of the |plain| page style is necessary in |
| 652 |
% order to get a chapter page overlaid on the red drawing. |
| 653 |
% \begin{macrocode} |
| 654 |
\def\ps@plain{\let\@mkboth\@gobbletwo |
| 655 |
\def\@oddhead{\makebox[\textwidth][l]{{\@CLdrawing}}} |
| 656 |
\def\@oddfoot{\reset@font\hfil\thepage\hfil} |
| 657 |
\def\@evenheadhead{\makebox[\textwidth][l]{{\@CLdrawing}}} |
| 658 |
\let\@evenfoot\@oddfoot} |
| 659 |
% \end{macrocode} |
| 660 |
% Th redefinition of the |headings| and |myhheadings| page styles are the |
| 661 |
% most useful ones because the typeset text is overlaid on the red drawing |
| 662 |
% and the user can see the effect of the canonical layout in the style of |
| 663 |
% a typeset page. |
| 664 |
% \begin{macrocode} |
| 665 |
\if@twoside |
| 666 |
\def\ps@headings{% |
| 667 |
\let\@oddfoot\@empty\let\@evenfoot\@empty |
| 668 |
\def\@evenhead{\@CLdrawing\thepage\hfil{\slshape\leftmark}}% |
| 669 |
\def\@oddhead{\@CLdrawing{\slshape\rightmark}\hfil\thepage}% |
| 670 |
\let\@mkboth\markboth |
| 671 |
\def\chaptermark##1{% |
| 672 |
\markboth {\MakeUppercase{% |
| 673 |
\ifnum \c@secnumdepth >\m@ne |
| 674 |
\if@mainmatter |
| 675 |
\@chapapp\ \thechapter. \ % |
| 676 |
\fi |
| 677 |
\fi |
| 678 |
##1}}{}}% |
| 679 |
\def\sectionmark##1{% |
| 680 |
\markright {\MakeUppercase{% |
| 681 |
\ifnum \c@secnumdepth >\z@ |
| 682 |
\thesection. \ % |
| 683 |
\fi |
| 684 |
##1}}}} |
| 685 |
\else |
| 686 |
\def\ps@headings{% |
| 687 |
\let\@oddfoot\@empty |
| 688 |
\def\@oddhead{\@CLdrawing{\slshape\rightmark}\hfil\thepage}% |
| 689 |
\let\@mkboth\markboth |
| 690 |
\def\chaptermark##1{% |
| 691 |
\markright {\MakeUppercase{% |
| 692 |
\ifnum \c@secnumdepth >\m@ne |
| 693 |
\if@mainmatter |
| 694 |
\@chapapp\ \thechapter. \ % |
| 695 |
\fi |
| 696 |
\fi |
| 697 |
##1}}}} |
| 698 |
\fi |
| 699 |
% \end{macrocode} |
| 700 |
% The |myheadings| page style is much simpler, at least this is the |
| 701 |
% definition based on the standard \LaTeX\ class \class{book} code: |
| 702 |
% \begin{macrocode} |
| 703 |
\def\ps@myheadings{% |
| 704 |
\let\@oddfoot\@empty\let\@evenfoot\@empty |
| 705 |
\def\@evenhead{\@CLdrawing\thepage\hfil{\slshape\leftmark}}% |
| 706 |
\def\@oddhead{\@CLdrawing{\slshape\rightmark}\hfil\thepage}% |
| 707 |
\let\@mkboth\@gobbletwo |
| 708 |
\let\chaptermark\@gobble |
| 709 |
\let\sectionmark\@gobble |
| 710 |
} |
| 711 |
|
| 712 |
% \end{macrocode} |
| 713 |
% |
| 714 |
% At this point we may close the argument of the \cs{AtEndPreamble} |
| 715 |
% command and the test on the use of the \class{memoir}~class. |
| 716 |
% \begin{macrocode} |
| 717 |
}}% |
| 718 |
% \end{macrocode} |
| 719 |
%\subsection{Service macros} |
| 720 |
% Just for testing the number of characters in a line the following macros |
| 721 |
% are provided. A couple of scratch dimension registers will be used |
| 722 |
% |dimen@| and |\abcwidth|; |\abcwidth| will hold the current lowercase |
| 723 |
% alphabet length, and |\dimen@| will hold several values in succession. |
| 724 |
% The scratch counters |\count254|, |\count252|, and |count250| will |
| 725 |
% receive the final result to be printed out. \eTeX\ arithmetics will be |
| 726 |
% used throughout, and we know this is possible, since we already tested |
| 727 |
% it at the very beginning. |
| 728 |
% |
| 729 |
% Another service macro for the user's sake is |\charactersperpage|; this |
| 730 |
% macro typesets the number of characters per line, the numbers of lines |
| 731 |
% per page, and eventually their product, a good estimate of the number of |
| 732 |
% characters per page. Many text editors have facilities for counting |
| 733 |
% a “compuscript” number o words and characters; with this further |
| 734 |
% information users may easily estimate the number of pages of their |
| 735 |
% document; of course they must make a certain allowance for the front |
| 736 |
% and back matter pages, so that they can evaluate the total |
| 737 |
% amount of signatures of the whole typeset document; of course, by |
| 738 |
% typesetting it with any engine based on \LaTeX\ they know exactly the |
| 739 |
% number of pages of the final document, but typographers like |
| 740 |
% to know a good estimate before the source \TeX\ files are finished. |
| 741 |
% \begin{macrocode} |
| 742 |
\newlength\abc@width |
| 743 |
\newcommand*\currentfontletters{% |
| 744 |
\settowidth\abc@width{abcdefghijklmnopqrstuvwxyz}\dimen0=26\p@ |
| 745 |
\dimen0=\dimexpr \textwidth * \dimen0 / \abc@width \relax |
| 746 |
\count254=\numexpr \dimen0 / \p@ \relax |
| 747 |
\par The number of characters in one text line with the current font is |
| 748 |
\the\count254.\par} |
| 749 |
|
| 750 |
\newcommand*\charactersperpage{% |
| 751 |
\settowidth\abc@width{abcdefghijklmnopqrstuvwxyz}\dimen0=26\p@ |
| 752 |
\dimen0=\dimexpr \textwidth * \dimen0 / \abc@width \relax |
| 753 |
\count254=\numexpr \dimen0 / \p@ \relax |
| 754 |
\count252=\numexpr \textheight / \baselineskip \relax |
| 755 |
\count250=\numexpr \count252 * \count254\relax |
| 756 |
\quote The number of characters in one text line with the current |
| 757 |
font is \the\count254;\\ |
| 758 |
this text block contains \the\count252\ lines;\\ |
| 759 |
a rough estimate of the number of characters per page is |
| 760 |
\the\count250.\par |
| 761 |
This might be used to estimate the total number of pages of |
| 762 |
a document. |
| 763 |
\endquote} |
| 764 |
% \end{macrocode} |
| 765 |
% |
| 766 |
%{\centering\color{red} \LARGE Happy \LaTeX{ing} \par} |
| 767 |
% \Finale |
| 768 |
%\iffalse |
| 769 |
%</package> |
| 770 |
%\fi |
| 771 |
% \endinput |
| 772 |
% |
| 773 |
%^^A%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 774 |
|