# [NTG-context] typearea

Peter Münster ntg-context@ntg.nl
Sun, 11 Jan 2004 22:02:47 +0100 (CET)

On Tue, 6 Jan 2004, Henning Hraban Ramm wrote:

> Am Dienstag, 06.01.04, um 08:21 Uhr (Europe/Zurich) schrieb Peter
> Münster:
> > Ok, I'm going to try it, perhaps it'll be my first ConTeXt module ;)
>
> It shouldn't be a module, but an environment.

All right. Here is my first try, where you can see, that I've still a
problem to be solved, so I would be lucky about any help:

% this environment works a little bit like \usepackage[DIVcalc]{typearea}
% in LaTeX as explained in detail in scrguien.pdf (KOMA-Script documentation)
\startenvironment e-test
\def\BCOR{3mm}% eventual binding correction
\setbox\scratchbox\hbox{\dorecurse{26}{\character\recurselevel}}
\newdimen\PageWidth
\PageWidth=\paperwidth
\doifmode{BCOR}{\PageWidth=\dimexpr(\PageWidth-\BCOR)}

%%%%%% Here is the problem: dividing one length by another. %%%%%%
% the following is not working for 2 reasons:
% * there is still the "pt" behind the numbers
% * one cannot divide by a real number, only integer
%\edef\Ratio{\the\numexpr(\the\paperheight / \the\PageWidth)}
\edef\Ratio{1.5}% to make the rest work...
\newdimen\Width
\newdimen\Height
\newdimen\Back
\Width=\dimexpr(2.5\wd\scratchbox)
\Height=\dimexpr(\Ratio\Width)
\edef\Top{\the\dimexpr((\paperheight - \Height) / 3 - \headerheight)}
\doifmodeelse{oneside}{%
\Back=\dimexpr((\PageWidth - \Width) / 2)
}{%
\Back=\dimexpr((\PageWidth - \Width) / 3)
\setuppagenumbering[alternative=doublesided]}
\doifmode{BCOR}{\Back=\dimexpr(\Back + \BCOR)}