* [NTG-context] dimension * counter
@ 2025-09-15 13:09 Henning Hraban Ramm
2025-09-15 16:47 ` [NTG-context] " Wolfgang Schuster
0 siblings, 1 reply; 3+ messages in thread
From: Henning Hraban Ramm @ 2025-09-15 13:09 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi again,
I’d like to calculate the thickness of the current document.
This doesn’t work (“Argument of \lastcounter has an extra }”):
\definemeasure[paperthickness][.1mm]
\expanded{\definemeasure[bookthickness][\measured{paperthickness}*\lastcounter[userpage]/2]}
It works with e.g. "50\measured{paperthickness}", but multiplication of
a dimension/measure with a counter seems to be a problem.
Hraban
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* [NTG-context] Re: dimension * counter
2025-09-15 13:09 [NTG-context] dimension * counter Henning Hraban Ramm
@ 2025-09-15 16:47 ` Wolfgang Schuster
2025-09-15 17:37 ` Henning Hraban Ramm
0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Schuster @ 2025-09-15 16:47 UTC (permalink / raw)
To: ntg-context
Am 15.09.2025 um 15:09 schrieb Henning Hraban Ramm:
> Hi again,
> I’d like to calculate the thickness of the current document.
>
> This doesn’t work (“Argument of \lastcounter has an extra }”):
>
> \definemeasure[paperthickness][.1mm]
> \expanded{\definemeasure[bookthickness][\measured{paperthickness}
> *\lastcounter[userpage]/2]}
>
>
> It works with e.g. "50\measured{paperthickness}", but multiplication of
> a dimension/measure with a counter seems to be a problem.
You're using the wrong counter command.
\starttext
\definemeasure[paperthickness][.1mm]
\the\dimexpression{\measured{paperthickness}*\lastcountervalue[userpage]/2}
\the\dimexpression{\measured{paperthickness}*\lastuserpage/2}
\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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
* [NTG-context] Re: dimension * counter
2025-09-15 16:47 ` [NTG-context] " Wolfgang Schuster
@ 2025-09-15 17:37 ` Henning Hraban Ramm
0 siblings, 0 replies; 3+ messages in thread
From: Henning Hraban Ramm @ 2025-09-15 17:37 UTC (permalink / raw)
To: ntg-context
Am 15.09.25 um 18:47 schrieb Wolfgang Schuster:
> Am 15.09.2025 um 15:09 schrieb Henning Hraban Ramm:
>> Hi again,
>> I’d like to calculate the thickness of the current document.
>>
>> This doesn’t work (“Argument of \lastcounter has an extra }”):
>>
>> \definemeasure[paperthickness][.1mm]
>> \expanded{\definemeasure[bookthickness][\measured{paperthickness}
>> *\lastcounter[userpage]/2]}
>>
>>
>> It works with e.g. "50\measured{paperthickness}", but multiplication
>> of a dimension/measure with a counter seems to be a problem.
>
>
> You're using the wrong counter command.
>
> \starttext
>
> \definemeasure[paperthickness][.1mm]
>
> \the\dimexpression{\measured{paperthickness}*\lastcountervalue[userpage]/2}
>
> \the\dimexpression{\measured{paperthickness}*\lastuserpage/2}
>
> \stoptext
Thank you!
Now I can print on the front edge of a book/magazine. ✌️😁
Hraban
\setuppapersize[A5][A5,oversized]
\setupbodyfont[heros,12pt]
\definelayer[Cut][x=0mm,y=0mm,height=1ph,width=1pw,repeat=yes]
\definemeasure[paperthickness][.1mm]
\expanded{\definemeasure[bulkthickness][\measured{paperthickness}*\lastuserpage/2]}
\def\Edgetext{\scale[height=\measure{bulkthickness}]{\definedfont[SansBold*default]context
group journal}}
\setwidthof{\Edgetext}\to\EdgetextWidth
\def\Clipping{\clip[
width=2mm,height=1ph,
% -20 is an estimated correction
hoffset=\dimexpr\measure{paperthickness}*(\userpage-20)\relax,
]{\rotate[rotation=90]{\Edgetext}}}
\startsetups[CutSetupL]
\resetlayer[Cut]
\setlayer[Cut][
x=\dimexpr -1mm\relax,
y=\dimexpr (1ph - \EdgetextWidth)/2\relax,
]{\mirror{\Clipping}}
\stopsetups
\startsetups[CutSetupR]
\resetlayer[Cut]
\setlayer[Cut][
x=\dimexpr 1pw - 1mm\relax,
y=\dimexpr (1ph - \EdgetextWidth)/2\relax,
]{\Clipping}
\stopsetups
\setupbackgrounds[leftpage][background=Cut,state=repeat,setups=CutSetupL]
\setupbackgrounds[rightpage][background=Cut,state=repeat,setups=CutSetupR]
\showframe
\setuplayout[
location=middle,
marking=on,
]
\setuppagenumbering[alternative=doublesided]
\starttext
\measure{bulkthickness}
\dorecurse{100}{
empty page
\userpage/\lastuserpage
\page
}
\stoptext
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-15 17:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-15 13:09 [NTG-context] dimension * counter Henning Hraban Ramm
2025-09-15 16:47 ` [NTG-context] " Wolfgang Schuster
2025-09-15 17:37 ` Henning Hraban Ramm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).