[NTG-context] Re: calculate ...

2025-03-04 Thread Thomas Meyer

Hello Ric, Wolfgang and Hans,

that was very enlightening. Thank you very much for your explanations, 
advice and tips.


Greetings
Thomas

Am 03.03.25 um 16:27 schrieb Wolfgang Schuster:

Am 03.03.2025 um 15:46 schrieb Rik Kabel:


On 2025-03-03 08:43, Thomas Meyer wrote:



You mean that:
% Set the textarea width to 2.6 alphabets.
\setbox\scratchbox\hbox{\dorecurse{26}{\character\recurselevel}}
\newdimen\Width \Width=\dimexpr(2.6\wd\scratchbox)
That's something I don't understand! What is a 2.6 alphabet? What 
means "scratchbox", "2.6\wd" ... ?


This is straight TeX (not the higher-level nicety of ConTeXt). What 
it does is create a throw-away box (a scratchbox) and sets in it 
horizontally one lower case alphabet of the current body font. It 
creates that alphabet by setting \character{1}\character{2}... 
\character{26} using a loop. It then measures the width of the box 
holding the 26 characters (\wd\scratchbox) and multiplies that by 
2.6, depositing the result in \Width.


A more ConTeXt-y way to do this might be:

    \def\Alphabet{abcdefghijklmnopqrstuvwxyz}
    \setupbodyfont[libertinus,12pt]
    \setwidthof\Alphabet\to\AlphabetWidth

and then use width=2.6\AlphabetWidth in your layout


You can also use the avarage character width of the main language but 
at the moment it's limited to the four languages shown in the example.


\startsetups[averagecharwidth]
  \page
  \mainlanguage[#1]
  \setuplayout[width=70\averagecharwidth]
  \starttabulate
  \NC Language  \EQ \currentmainlanguage    \NC\NR
  \NC Textwidth \EQ \PtToCm{\the\textwidth} \NC\NR
  \stoptabulate
  \samplefile{lorem}
\stopsetups

\showframe[text][text]

\starttext
\setupwithargument{averagecharwidth}{en}
\setupwithargument{averagecharwidth}{nl}
\setupwithargument{averagecharwidth}{de}
\setupwithargument{averagecharwidth}{pt}
\stoptext

Wolfgang

___ 

If your question is of interest to others as well, please add an entry 
to the Wiki!


maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net 
(mirror)

archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___ 

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-03-03 Thread Wolfgang Schuster

Am 03.03.2025 um 15:46 schrieb Rik Kabel:


On 2025-03-03 08:43, Thomas Meyer wrote:



You mean that:
% Set the textarea width to 2.6 alphabets.
\setbox\scratchbox\hbox{\dorecurse{26}{\character\recurselevel}}
\newdimen\Width \Width=\dimexpr(2.6\wd\scratchbox)
That's something I don't understand! What is a 2.6 alphabet? What 
means "scratchbox", "2.6\wd" ... ?


This is straight TeX (not the higher-level nicety of ConTeXt). What it 
does is create a throw-away box (a scratchbox) and sets in it 
horizontally one lower case alphabet of the current body font. It 
creates that alphabet by setting \character{1}\character{2}... 
\character{26} using a loop. It then measures the width of the box 
holding the 26 characters (\wd\scratchbox) and multiplies that by 2.6, 
depositing the result in \Width.


A more ConTeXt-y way to do this might be:

\def\Alphabet{abcdefghijklmnopqrstuvwxyz}
\setupbodyfont[libertinus,12pt]
\setwidthof\Alphabet\to\AlphabetWidth

and then use width=2.6\AlphabetWidth in your layout


You can also use the avarage character width of the main language but at 
the moment it's limited to the four languages shown in the example.


\startsetups[averagecharwidth]
  \page
  \mainlanguage[#1]
  \setuplayout[width=70\averagecharwidth]
  \starttabulate
  \NC Language  \EQ \currentmainlanguage\NC\NR
  \NC Textwidth \EQ \PtToCm{\the\textwidth} \NC\NR
  \stoptabulate
  \samplefile{lorem}
\stopsetups

\showframe[text][text]

\starttext
\setupwithargument{averagecharwidth}{en}
\setupwithargument{averagecharwidth}{nl}
\setupwithargument{averagecharwidth}{de}
\setupwithargument{averagecharwidth}{pt}
\stoptext

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-03-03 Thread Hans Hagen

On 3/3/2025 4:13 PM, Wolfgang Schuster wrote:

Am 03.03.2025 um 04:22 schrieb Rik Kabel:


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.


You can also use braces to limit the argument for \dimexpr. Hans added 
this feature at the begin of the year to Luametatex.


\starttext
\the\dimexpr{2pt+3pt}
\stoptext


best use \dimexpression which is also a bit more flexible

Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
   tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-03-03 Thread Wolfgang Schuster

Am 03.03.2025 um 04:22 schrieb Rik Kabel:


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.


You can also use braces to limit the argument for \dimexpr. Hans added 
this feature at the begin of the year to Luametatex.


\starttext
\the\dimexpr{2pt+3pt}
\stoptext

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-03-03 Thread Rik Kabel


On 2025-03-03 08:43, Thomas Meyer wrote:



You mean that:
% Set the textarea width to 2.6 alphabets.
\setbox\scratchbox\hbox{\dorecurse{26}{\character\recurselevel}}
\newdimen\Width \Width=\dimexpr(2.6\wd\scratchbox)
That's something I don't understand! What is a 2.6 alphabet? What 
means "scratchbox", "2.6\wd" ... ?


This is straight TeX (not the higher-level nicety of ConTeXt). What it 
does is create a throw-away box (a scratchbox) and sets in it 
horizontally one lower case alphabet of the current body font. It 
creates that alphabet by setting 
\character{1}\character{2}...\character{26} using a loop. It then 
measures the width of the box holding the 26 characters (\wd\scratchbox) 
and multiplies that by 2.6, depositing the result in \Width.


A more ConTeXt-y way to do this might be:

   \def\Alphabet{abcdefghijklmnopqrstuvwxyz}
   \setupbodyfont[libertinus,12pt]
   \setwidthof\Alphabet\to\AlphabetWidth

and then use width=2.6\AlphabetWidth in your layout

--
Rik
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-03-03 Thread Thomas Meyer



Am 03.03.25 um 04:22 schrieb Rik Kabel:


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.

  *  It conflates paper size and page size -- try adding
\setuppapersize[A5][A3] and you will see what I mean.


How can I change that?


  *  I do not see where your solution adapts the width to the alphabet
width -- the referenced wiki page does;


You mean that:

% Set the textarea width to 2.6 alphabets.
\setbox\scratchbox\hbox{\dorecurse{26}{\character\recurselevel}}
\newdimen\Width \Width=\dimexpr(2.6\wd\scratchbox)

That's something I don't understand! What is a 2.6 alphabet? What means 
"scratchbox", "2.6\wd" ... ?



  * your version uses \baselineskip an an indirect stand-in. (Also,
the comment is now misleading: Width is set proportionate to the
determined height, not height proportionate to a determined width.)


Forget the comment. It is copied.


  * As far as characters per line, there are so many variables --
serif or sans, large or small x-height, ... but for single column
texts with book faces 50 to 70 characters width is typical, 40 to
50 for two-column setting. You pick your authority and make your
choice --

I think a regular font is just right for continuous text. (Here 68 
characters per line)


  *  Binding correction is a press-time issue. Page layout should not
deal with it -- it is handled during imposition after the paper
weight and binding methods are settled. Two different trades. (If
you need a quickie leaflet printed on standard untrimmed paper
perhaps you might want to look at it, but not beyond that.) As
long as you don't use BCOR mode, however, this is irrelevant to
your layout, and I would remove all references to it.
  * Is this for a one-sided or two-sided document? You have
\setuppagenumbering configured for two-sided, but calculate
margins based on a mode suggesting a one-sided document.


[NTG-context] Re: calculate ...

2025-03-02 Thread Rik Kabel


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.

  *  It conflates paper size and page size -- try adding
   \setuppapersize[A5][A3] and you will see what I mean.
  *  I do not see where your solution adapts the width to the alphabet
   width -- the referenced wiki page does; your version uses
   \baselineskip an an indirect stand-in. (Also, the comment is now
   misleading: Width is set proportionate to the determined height, not
   height proportionate to a determined width.) As far as characters
   per line, there are so many variables -- serif or sans, large or
   small x-height, ... but for single column texts with book faces 50
   to 70 characters width is typical, 40 to 50 for two-column setting.
   You pick your authority and make your choice --
  *  Binding correction is a press-time issue. Page layout should not
   deal with it -- it is handled during imposition after the paper
   weight and binding methods are settled. Two different trades. (If
   you need a quickie leaflet printed on standard untrimmed paper
   perhaps you might want to look at it, but not beyond that.) As long
   as you don't use BCOR mode, however, this is irrelevant to your
   layout, and I would remove all references to it.
 * Is this for a one-sided or two-sided document? You have
   \setuppagenumbering configured for two-sided, but calculate margins
   based on a mode suggesting a one-sided document.

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

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive 

[NTG-context] Re: calculate ...

2025-03-02 Thread Thomas Meyer

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



Am 24.02.25 um 19:33 schrieb Rik Kabel:



On 2025-02-24 04:19, Thomas Meyer wrote:

Hello Hraban,

thanks for your tip.
Hopefully I'll find time to have a look at it after that busy weekend.

Regards
Thomas

Am 22.02.25 um 19:11 schrieb Henning Hraban Ramm:

Am 22.02.25 um 18:36 schrieb Thomas Meyer:

Thank you Wolfgang,

I guess I'm thinking too complicated. Ultimately, this should 
result in a type area according to the golden ratio.
(textheight = 660 pt = 1.618 * textwidth or something similar, 
depending on the font size or interlinespace)




To simplify your code, you can replace many of these measures with 
units, e.g. th, tw; see also lowlevel-registers.pdf


Perhaps this can help. It works for me. It lays out his page 155 (1st 
edition paperback) bottom page, which has a 1.7 ratio type area on a 
1.5 ratio page.


\doifmodeelse{frame}{\def\Paper{letter}}{\def\Paper{octavo}}
  \definepapersize [octavo]
   [width=6in,%   152.4mm, 433.62pt, 432bp
    height=9in]%  228.6mm, 650..43pt, 648bp
  \setuppapersize[octavo][\Paper]
  \setuplayout   [
%Bringhurst example on p155
%
% P = 1.5 (h=9", w=6") (648bp × 432bp) (54pc × 36pc)
% T = 1.7 (d=6.8", m=4") (491.44pt × 289.08pt) (489.6bp × 288bp)
(40.8pc × 24pc)
%     (exclusive of running heads and folios)
% s = t = w/9 = 0.667" backspace and top margin
% e = 2s = 1.333" foredge
% ( f = h - t - d = 9" - 0.667" - 6.8" = 1.533"
%   but must allow for footer/footerdistance in that )
%  36 lines @ 13.5pt = 486pt, 36 lines @ 13.45bp  = 484.2bp
  %
  % Bringhurst calculations for 24pica width   char/line
  %    libertinus alphabet width 10pt:   122pt   66
  %    libertinus alphabet width 10.5pt: 128pt   63
  %    libertinus alphabet width 11pt:   134pt   61
  %    libertinus alphabet width 12pt:   146pt   56
% backspace =
leftedge+leftedgedistance+leftmarginwidth+leftmargindistance
% cutspace  = right...
% s = w/9 = leftmarginwidth+leftmargindistance = 0.667" = 48bp
% t = s = topspace + header+headerdistance
% header+headerdistance = 27bp
% topspace = 48bp - 27bp = 21bp
% e = 2×s = rightmarginwidth+rightmargindistance = 1.333" = 96bp
  vz=2,
  location=middle,
  backspace=pw / 9,
  cutspace=\backspace * 2,
  width=\backspace * 6,
  h

[NTG-context] Re: calculate ...

2025-02-24 Thread Rik Kabel


On 2025-02-24 04:19, Thomas Meyer wrote:

Hello Hraban,

thanks for your tip.
Hopefully I'll find time to have a look at it after that busy weekend.

Regards
Thomas

Am 22.02.25 um 19:11 schrieb Henning Hraban Ramm:

Am 22.02.25 um 18:36 schrieb Thomas Meyer:

Thank you Wolfgang,

I guess I'm thinking too complicated. Ultimately, this should result 
in a type area according to the golden ratio.
(textheight = 660 pt = 1.618 * textwidth or something similar, 
depending on the font size or interlinespace)




To simplify your code, you can replace many of these measures with 
units, e.g. th, tw; see also lowlevel-registers.pdf


Perhaps this can help. It works for me. It lays out his page 155 (1st 
edition paperback) bottom page, which has a 1.7 ratio type area on a 1.5 
ratio page.


   \doifmodeelse{frame}{\def\Paper{letter}}{\def\Paper{octavo}}
  \definepapersize [octavo]
   [width=6in,%   152.4mm, 433.62pt, 432bp
    height=9in]%  228.6mm, 650..43pt, 648bp
  \setuppapersize[octavo][\Paper]
  \setuplayout   [
   %Bringhurst example on p155
   %
   % P = 1.5 (h=9", w=6") (648bp × 432bp) (54pc × 36pc)
   % T = 1.7 (d=6.8", m=4") (491.44pt × 289.08pt) (489.6bp × 288bp)
   (40.8pc × 24pc)
   %     (exclusive of running heads and folios)
   % s = t = w/9 = 0.667" backspace and top margin
   % e = 2s = 1.333" foredge
   % ( f = h - t - d = 9" - 0.667" - 6.8" = 1.533"
   %   but must allow for footer/footerdistance in that )
   %  36 lines @ 13.5pt = 486pt, 36 lines @ 13.45bp  = 484.2bp
  %
  % Bringhurst calculations for 24pica width   char/line
  %    libertinus alphabet width 10pt:   122pt   66
  %    libertinus alphabet width 10.5pt: 128pt   63
  %    libertinus alphabet width 11pt:   134pt   61
  %    libertinus alphabet width 12pt:   146pt   56
   % backspace =
   leftedge+leftedgedistance+leftmarginwidth+leftmargindistance
   % cutspace  = right...
   % s = w/9 = leftmarginwidth+leftmargindistance = 0.667" = 48bp
   % t = s = topspace + header+headerdistance
   % header+headerdistance = 27bp
   % topspace = 48bp - 27bp = 21bp
   % e = 2×s = rightmarginwidth+rightmargindistance = 1.333" = 96bp
  vz=2,
  location=middle,
  backspace=pw / 9,
  cutspace=\backspace * 2,
  width=\backspace * 6,
  height=(\backspace * 6 * 1.7) + (4 * \lineheight),
  topspace=\backspace - 2 * \lineheight,
  headerdistance=\lineheight, header=\lineheight,
  footerdistance=\lineheight, footer=\lineheight,
  leftmargindistance=8bp, rightmargindistance=8bp,
  leftmargin=\backspace - \leftmargindistance,
  rightmargin=\cutspace - \rightmargindistance,
 ]

--
Rik
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-02-24 Thread autumnus
I have defined the following layout in my own module, which may have some 
inspiration for your needs.


% must load font first, then can get real text fontsize(1em)
% Only care about the width of each row, the height of each column and the 
width of the side note. 
% Others are cut according to the ratio of 1:√2 (only rough)

 
% If the layout is not set in the module, \c_textcount \c_heightcount 
\c_margincount must be set in advance.

\unprotect
\newcount\c_textcount \c_textcount=40\relax % Modify to the required 
number of words per line
\newcount\c_heightcount \c_heightcount=45\relax %Modify to the required 
number of lines in the text
\newcount\c_margincount\c_margincount=10\relax % Modify to the number of 
words required for each line in the side note area
\newdimen\d_textfontsize\d_textfontsize=\fontdimen6\font\relax
\newdimen\d_marginwidth   
\d_marginwidth=\dimexpr\fontdimen6\font*\c_margincount\relax
\newdimen\d_textlineheight\d_textlineheight=
 \dimexpr\baselineskip*\c_heightcount-\baselineskip+
 \ifdim\topskip<\ht\strutbox\topskip\else\ht\strutbox\fi\relax
\protect

\startluacode
  local todimen
  local pw = tex.getdimen("paperwidth")
  local ph = tex.getdimen("paperheight")
  local pr = pw / ph
  local tc = tex.getcount("c_textcount")
  local hc = tex.getcount("c_heightcount")
  local mc = tex.getcount("c_margincount")
  local bs = tex.getdimen("d_textfontsize")
  local hh = tex.getdimen("d_textlineheight")
  local mw = tex.getdimen("d_marginwidth")
  local twr = tc * bs -- The number of words per line is necessary to set.

  ifhc == 0 then  -- If the page height is not set
thr = twr / pr
  else
thr = hh
  end

  local Rm  = (pw - twr) / (1 + pr)   -- right total
  local Rmr = Rm * pr / (2 + pr + 1/pr)   -- edge distance
  local Rml = Rmr / pr-- margin distance
  local Lm  = pw - Rm - twr   -- left total

  ifmc == 0 then
Rmm = Rm -Rml -Rmr   -- margin text width
  else
Rmm = mw
Rmr = (Rm - Rmm) / (1 + pr)
Rml = Rm - Rmm - Rmr
  end

  local He = (ph - thr) / (1 + pr)  -- top total
  local Fo = ph - He - thr  -- bot total
  local Het = He * pr / (2 + pr + 1/pr) -- top distance
  local Heb = Het / pr  -- header distance
  local Hem = He - Het - Heb-- header height
  local Fob = Fo * pr / (2 + pr + 1/pr)
  local Fot = Fob / pr
  local Fom = Fo - Fot -Fob

  textwidth  = tostring(twr/65536) .. "pt"
  textheight = ph - Het - Fob-- textheight 是 Page - Top - Tail
  textheight = tostring(textheight/65536) .. "pt"

  backspace   = tostring(Lm/65536) .. "pt"
  rightmargin = tostring(Rmm/65536) .. "pt"
  rightmargindistance = tostring(Rml/65536) .. "pt"
  rightedgedistance   = tostring(Rmr/65536) .. "pt"
  topdistance = tostring(Het/65536) .. "pt"
  header  = tostring(Hem/65536) .. "pt"
  headerdistance  = tostring(Heb/65536) .. "pt"
  footer  = tostring(Fom/65536) .. "pt"
  footerdistance  = tostring(Fot/65536) .. "pt"
  botdistance = tostring(Fob/65536) .. "pt"

  -- context(ph/65536)context.par()
  -- context("he  ")context(He/65536)context.par()
  -- context("het ")context(Het/65536)context.par()
  -- context("hem ")context(Hem/65536)context.par()
  -- context("heb ")context(Heb/65536)context.par()
  -- context("fo  ")context(Fo/65536)context.par()
  -- context("fot ")context(Fot/65536)context.par()
  -- context("fom ")context(Fom/65536)context.par()
  -- context("fob ")context(Fob/65536)context.par()
  -- context(thr/65536)context.par()
  -- context(textheight)context.par()

context.definelayout(
  { "hermes" },
  {
width=textwidth,
backspace=backspace,
rightmargin=rightmargin,
rightmargindistance=rightmargindistance,
rightedgedistance=rightedgedistance,
topspace=topdistance,
header=header,
headerdistance=headerdistance,
footer=footer,
footerdistance=footerdistance,
bottomspace=botdistance,
height=textheight,
  }
)
\stopluacode
%%%

Then you can set it to \setuplayout[hermes],
If the current layout does not meet the requirements,
it can also be modified later.

autumnus
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-02-24 Thread Thomas Meyer

Hello Hraban,

thanks for your tip.
Hopefully I'll find time to have a look at it after that busy weekend.

Regards
Thomas

Am 22.02.25 um 19:11 schrieb Henning Hraban Ramm:

Am 22.02.25 um 18:36 schrieb Thomas Meyer:

Thank you Wolfgang,

I guess I'm thinking too complicated. Ultimately, this should result 
in a type area according to the golden ratio.
(textheight = 660 pt = 1.618 * textwidth or something similar, 
depending on the font size or interlinespace)




To simplify your code, you can replace many of these measures with 
units, e.g. th, tw; see also lowlevel-registers.pdf


Hraban
___ 

If your question is of interest to others as well, please add an entry 
to the Wiki!


maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net 
(mirror)

archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___ 

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-02-22 Thread Henning Hraban Ramm

Am 22.02.25 um 18:36 schrieb Thomas Meyer:

Thank you Wolfgang,

I guess I'm thinking too complicated. Ultimately, this should result in 
a type area according to the golden ratio.
(textheight = 660 pt = 1.618 * textwidth or something similar, depending 
on the font size or interlinespace)




To simplify your code, you can replace many of these measures with 
units, e.g. th, tw; see also lowlevel-registers.pdf


Hraban
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-02-22 Thread Thomas Meyer

Thank you Wolfgang,

I guess I'm thinking too complicated. Ultimately, this should result in 
a type area according to the golden ratio.
(textheight = 660 pt = 1.618 * textwidth or something similar, depending 
on the font size or interlinespace)


Greetings
Thomas

Am 22.02.25 um 13:43 schrieb Wolfgang Schuster:

Am 22.02.2025 um 13:02 schrieb Thomas Meyer:

Hi folks,

is it possible to calculate with interlinespace and lines?

For example:
interlinespace = 15pt
lines = 44

Something like that -> textheight = interlinespace * lines = 660 pt

How can I do it and were can I find information about this?



Can you provide more information because the layout already take the 
number of lines and the line height into account when it calculates 
the text height.


\showgrid

\setuplayout[lines=20]

\starttext

\page[dummy]

\page

\setuplayout[lines=30]

\page[dummy]

\page

\setupinterlinespace[line=4ex]
\setuplayout[lines=20]

\page[dummy]

\stoptext

Wolfgang

___ 

If your question is of interest to others as well, please add an entry 
to the Wiki!


maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net 
(mirror)

archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___ 

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___


[NTG-context] Re: calculate ...

2025-02-22 Thread Wolfgang Schuster

Am 22.02.2025 um 13:02 schrieb Thomas Meyer:

Hi folks,

is it possible to calculate with interlinespace and lines?

For example:
interlinespace = 15pt
lines = 44

Something like that -> textheight = interlinespace * lines = 660 pt

How can I do it and were can I find information about this?



Can you provide more information because the layout already take the 
number of lines and the line height into account when it calculates the 
text height.


\showgrid

\setuplayout[lines=20]

\starttext

\page[dummy]

\page

\setuplayout[lines=30]

\page[dummy]

\page

\setupinterlinespace[line=4ex]
\setuplayout[lines=20]

\page[dummy]

\stoptext

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___