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 : ntg-context@ntg.nl /
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 : ntg-context@ntg.nl /
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
___________________________________________________________________________________