ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <j.hagen@xs4all.nl>
To: ntg-context@ntg.nl
Subject: [NTG-context] Re: Different behavior of \clf_lastypos vs \clf_lastxpos
Date: Sun, 17 Sep 2023 09:18:06 +0200	[thread overview]
Message-ID: <48092628-1f58-dee4-9643-baadf63ada23@xs4all.nl> (raw)
In-Reply-To: <947cf5e7a0e99d13535f7d839a8b3204e6038d61.camel@telus.net>

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
___________________________________________________________________________________

  reply	other threads:[~2023-09-17  7:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-17  1:26 [NTG-context] " Aditya Mahajan
2023-09-17  7:04 ` [NTG-context] " Max Chernoff
2023-09-17  7:18   ` Hans Hagen [this message]
2023-09-17  7:05 ` Hans Hagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48092628-1f58-dee4-9643-baadf63ada23@xs4all.nl \
    --to=j.hagen@xs4all.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).