From: Taco Hoekwater <taco@bittext.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Getting dimensions in Lua
Date: Mon, 18 Jan 2021 11:02:09 +0100 [thread overview]
Message-ID: <4CA9C67C-AD39-4329-A0C0-375BFFD06D7A@bittext.nl> (raw)
In-Reply-To: <61e180c9-cdee-8020-ce19-0b6a752db3df@xs4all.nl>
> On 18 Jan 2021, at 10:45, Hans Hagen <j.hagen@xs4all.nl> wrote:
>
> On 1/18/2021 1:58 AM, Jairo A. del Rio wrote:
>> Hi, list.
>> I want to get some dimensions in Lua. See, for instance
>> \starttext
>> \the\dimexpr\availablehsize\relax %say, 426pt
>> \stoptext
>> Is there an equivalent in ConTeXt for Lua, i.e. without passing values from TeX or, at least, using only Lua commands? Thank you in advance.
> tex being tex, there is always a way ...
There is also this option:
% function returns scaled points
\startluacode
function availablehsize()
local l = tex.dimen.hsize - tex.skip.leftskip.width - tex.skip.rightskip.width
if tex.count.hangafter<0 then
local h = tex.dimen.hangindent
if h>0 then l = l - h else l = l + h end
end
return l
end
\stopluacode
But I suspect that there are multiple cases where this does not work
(like when used in horizontal mode, for example if the par setting changes
before the \par is seen, or when there is data in the local par node)
Best wishes,
Taco
—
Taco Hoekwater E: taco@bittext.nl
genderfluid (all pronouns)
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2021-01-18 10:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 0:58 Jairo A. del Rio
2021-01-18 9:45 ` Hans Hagen
2021-01-18 10:02 ` Taco Hoekwater [this message]
2021-01-18 10:10 ` Jairo A. del Rio
2021-01-18 10:12 ` Jairo A. del Rio
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=4CA9C67C-AD39-4329-A0C0-375BFFD06D7A@bittext.nl \
--to=taco@bittext.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).