[NTG-context] typearea

Peter Münster ntg-context@ntg.nl
Wed, 14 Jan 2004 19:33:51 +0100 (CET)


On Sun, 11 Jan 2004, Peter Münster wrote:

> %%%%%% Here is the problem: dividing one length by another. %%%%%%

Hello,
I've found a solution. Here is now the full environment:

% 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)}
\unprotect
\begingroup
  \catcode`P=12
  \catcode`T=12
  \lowercase{\def\x@x{%
    \def\rem@pt##1.##2PT{##1.##2}%
    \def\rem@@pt##1.##2PT{##1}}}
\expandafter\endgroup\x@x
\def\strip@Pt{\expandafter\rem@pt\the}
\def\strip@PT{\expandafter\rem@@pt\the}
\edef\Ratio{\strip@Pt\dimexpr(10\paperheight/\strip@PT\dimexpr(10\PageWidth))}
\protect
\newdimen\Width
\newdimen\Height
\newdimen\Back
\Width=\dimexpr(2.5\wd\scratchbox)
\Height=\dimexpr(\Ratio\Width)
\headerheight=2.75\baselineskip
\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)}
\Height=\dimexpr(\Height + \headerheight + \footerheight)
\setuplayout[header=\the\headerheight,height=\the\Height,
  width=\the\Width,topspace=\Top,backspace=\the\Back]
\stopenvironment

Cheers, Peter

-- 
http://pmrb.free.fr/contact/
------------------------------------
Film Search site: http://f-s.sf.net/