On 2025-03-02 11:38, Thomas Meyer wrote:
> Hi Rik and autumnus, > > Sorry for my late reply, but thank you very much for your > suggestions on this topic. Your calculations are very complicated I > think. However, the type area is not the end of the story. > Unfortunately, the line length remains the same with your > suggestions, even if the font size is reduced. For good readability, > however, the number of characters in the line should remain more or > less constant and not increase. In any case, that's what I've read. > I have therefore orientated myself on this: https:// > wiki.contextgarden.net/Introduction/From_LaTeX_to_ConTeXt/KOMA- > scrartcl_Type_Area > > It looks like this for me now: > > \definebodyfontenvironment[12pt][interlinespace=15pt] > \setupbodyfont[libertinus, 12pt] > > \setuppagenumbering[location={footer,middle}, > alternative=doublesided] > > \setupindenting[yes, small, next] > > %\enablemode[BCOR] % Set binding correction value . > \doifmodeelse{BCOR}{\def\bindingcorr{5mm}}{\def\bindingcorr{0pt}} > > % Set visible page width. \newdimen\PageWidth > \PageWidth=\dimexpr(\paperwidth-\bindingcorr) > > % Determine the paper aspect ratio. \edef\Ratio{0.618} > %Golden Ratio > > % Set the textarea height proportional to the width. > \newdimen\Height \Height=41\baselineskip % constant > number of lines (41) \newdimen\Width \Width=\dimexpr(\Ratio\Height) > > % Set the margin/gutter widths to be equal on a full spread. % > \newdimen\Back \Back=\dimexpr(((\PageWidth - \Width) / 2) + > \bindingcorr) > > \enablemode[oneside] \newdimen\Back \doifmodeelse{oneside} > {\Back=\dimexpr(((\PageWidth - \Width) / 2) + \bindingcorr)} > {\Back=\dimexpr(((\PageWidth - \Width) / 3) + \bindingcorr)} > > > % Set the top and bottom margins in a 1:2 ratio, ignoring headers. > \edef\Top{\the\dimexpr((\paperheight - \Height) / 3 - 3\lineheight)} > > % Redefine \Height to include header and footer space. > \Height=\dimexpr(\Height + 8\lineheight) > > % Set up the page layout using the calculated parameters. > \setuplayout[ backspace=\the\Back, height=\the\Height, > width=\the\Width, header=2.5\lineheight, > headerdistance=0.5\lineheight, footer=4.5\lineheight, > footerdistance=0.5\lineheight, bottom=2\lineheight, > bottomdistance=0.5\lineheight, margindistance=0.2\lineheight, > topspace=\Top, grid=on, ] > > \starttext > > \showgrid > > \input knuth > > \input tufte > > \input knuth > > \input tufte > > \showlayout[1, pt, mm] > > \stoptext > > If I am wrong, please correct me. > > Greetings Thomas

You are correct that these are two different approaches. The version I showed  calculates fixed top and side margins based on page size and computes a type area of specific proportions after that. The user is still responsible for determining an appropriate font size and leading, and the line count follows from that. Your solution starts with a font size, leading and line count, then computes text height, and lastly text width, splitting the remaining space among the margins.


I think that there are a couple of problems with the code as shown.

Other than that, it does a fine job. Perhaps best practice calls for \relax at the end of some of the \dimexprs, but that isn't necessary in this case.

--
Rik