* [NTG-context] Different behavior of \clf_lastypos vs \clf_lastxpos
@ 2023-09-17 1:26 Aditya Mahajan
2023-09-17 7:04 ` [NTG-context] " Max Chernoff
2023-09-17 7:05 ` Hans Hagen
0 siblings, 2 replies; 4+ messages in thread
From: Aditya Mahajan @ 2023-09-17 1:26 UTC (permalink / raw)
To: mailing list for ConTeXt users
[-- Attachment #1: Type: text/plain, Size: 549 bytes --]
Hi,
I am trying to debug an unexpected behavior with tikz reported on tex.se: https://tex.stackexchange.com/q/696136/323
The attached file shows what is going wrong (without using tikz). For some reason, there is an extra \relax written to file after `\the\numexp\clf_lastypos\relax` (there is no such relax after `\the\numexpr\clf_lastxpos\relax`). The test.pgf file is:
\macro {A}{23930350}{43358454.0\relax }
\macro {B}{39564274.0\relax }{14083538}
Any ideas on why is the extra \relax written after lastypos and how to fix that?
Aditya
[-- Attachment #2: Type: application/x-tex, Size: 699 bytes --]
[-- Attachment #3: Type: text/plain, Size: 495 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* [NTG-context] Re: Different behavior of \clf_lastypos vs \clf_lastxpos
2023-09-17 1:26 [NTG-context] Different behavior of \clf_lastypos vs \clf_lastxpos Aditya Mahajan
@ 2023-09-17 7:04 ` Max Chernoff
2023-09-17 7:18 ` Hans Hagen
2023-09-17 7:05 ` Hans Hagen
1 sibling, 1 reply; 4+ messages in thread
From: Max Chernoff @ 2023-09-17 7:04 UTC (permalink / raw)
To: ntg-context
Hi Aditya,
> For some reason, there is an extra \relax written to file after
> `\the\numexp\clf_lastypos\relax` (there is no such relax after
> `\the\numexpr\clf_lastxpos\relax`). The test.pgf file is:
>
> \macro {A}{23930350}{43358454.0\relax } \macro {B}{39564274.0\relax
> }{14083538}
>
> Any ideas on why is the extra \relax written after lastypos and how to
> fix that?
\numexpr stops at the first non-expandable or non-digit token. If
\clf_last[xy]pos expands to an integer, then that's the \relax, but if
it expands to a float, then that's the decimal point.
With Lua, adding, subtracting, or multiplying two integers will give you
an integer, but dividing gives you a float. So somewhere in the backend,
the vertical position is probably divided but the horizontal position is
only added or subtracted.
To fix this, change lines 2344--2345 of anch-pos.lmt from
implement { name = "lastxpos", actions = function() context(jobpositions.lastx) end }
implement { name = "lastypos", actions = function() context(jobpositions.lasty) end }
to
implement { name = "lastxpos", actions = function() context("%.0f", jobpositions.lastx) end }
implement { name = "lastypos", actions = function() context("%.0f", jobpositions.lasty) end }
Thanks,
-- Max
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* [NTG-context] Re: Different behavior of \clf_lastypos vs \clf_lastxpos
2023-09-17 1:26 [NTG-context] Different behavior of \clf_lastypos vs \clf_lastxpos Aditya Mahajan
2023-09-17 7:04 ` [NTG-context] " Max Chernoff
@ 2023-09-17 7:05 ` Hans Hagen
1 sibling, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2023-09-17 7:05 UTC (permalink / raw)
To: Aditya Mahajan, mailing list for ConTeXt users
On 9/17/2023 3:26 AM, Aditya Mahajan wrote:
> Hi,
>
> I am trying to debug an unexpected behavior with tikz reported on tex.se: https://tex.stackexchange.com/q/696136/323
>
> The attached file shows what is going wrong (without using tikz). For some reason, there is an extra \relax written to file after `\the\numexp\clf_lastypos\relax` (there is no such relax after `\the\numexpr\clf_lastxpos\relax`). The test.pgf file is:
>
> \macro {A}{23930350}{43358454.0\relax }
> \macro {B}{39564274.0\relax }{14083538}
>
> Any ideas on why is the extra \relax written after lastypos and how to fix that?
i'll round the values
wrt relaxes, these can creep in as side effect of tex pushing back
looked-ahead and not used tokens (there are wasy around this but it's
not relevant here)
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 : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
* [NTG-context] Re: Different behavior of \clf_lastypos vs \clf_lastxpos
2023-09-17 7:04 ` [NTG-context] " Max Chernoff
@ 2023-09-17 7:18 ` Hans Hagen
0 siblings, 0 replies; 4+ messages in thread
From: Hans Hagen @ 2023-09-17 7:18 UTC (permalink / raw)
To: ntg-context
On 9/17/2023 9:04 AM, Max Chernoff wrote:
> Hi Aditya,
>
>> For some reason, there is an extra \relax written to file after
>> `\the\numexp\clf_lastypos\relax` (there is no such relax after
>> `\the\numexpr\clf_lastxpos\relax`). The test.pgf file is:
>>
>> \macro {A}{23930350}{43358454.0\relax } \macro {B}{39564274.0\relax
>> }{14083538}
>>
>> Any ideas on why is the extra \relax written after lastypos and how to
>> fix that?
>
> \numexpr stops at the first non-expandable or non-digit token. If
> \clf_last[xy]pos expands to an integer, then that's the \relax, but if
> it expands to a float, then that's the decimal point.
>
> With Lua, adding, subtracting, or multiplying two integers will give you
> an integer, but dividing gives you a float. So somewhere in the backend,
> the vertical position is probably divided but the horizontal position is
> only added or subtracted.
>
> To fix this, change lines 2344--2345 of anch-pos.lmt from
>
> implement { name = "lastxpos", actions = function() context(jobpositions.lastx) end }
> implement { name = "lastypos", actions = function() context(jobpositions.lasty) end }
>
> to
>
> implement { name = "lastxpos", actions = function() context("%.0f", jobpositions.lastx) end }
> implement { name = "lastypos", actions = function() context("%.0f", jobpositions.lasty) end }
it's better to do some rounding earlier on
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 : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-09-17 7:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-17 1:26 [NTG-context] Different behavior of \clf_lastypos vs \clf_lastxpos Aditya Mahajan
2023-09-17 7:04 ` [NTG-context] " Max Chernoff
2023-09-17 7:18 ` Hans Hagen
2023-09-17 7:05 ` Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox