On Fri, Oct 28, 2011 at 8:23 AM, Thomas A. Schmitz
On 10/27/11 13:05, Hans Hagen wrote:
With “tex.dimen[…]” you get the value in scaled points but util-dim.lua provides some functions to convert the value in points, centimeter etc.
\starttext \startluacode context.blackrule{ width = number.topoints(tex.dimen["textwidth"]/2) } \stopluacode \stoptext
Thank you Wolfgang, that's exactly what I was looking for!
or just tex.dimen["textwidth"]/2 .. "sp"
Wait, just so I understand: your solution would imply that tex.dimen["textwidth"] holds a number, not a dimension, right? (Because you simply concatenate it with a dimension unit). Which makes sense when I think of it because lua has no concept of dimensions, only of strings, functions, tables, numbers... Whereas the Wolfgang implies that the result is already in sp. So who's right? both -- where is the problem ? tex.dimen["textwidth"]/2 .. "sp" gives "xyzsp"
number.topoints(tex.dimen["textwidth"]/2) gives "XYZ.ABSpt" TeX reads "xyzsp" and drops sp or TeX reads "XYZ.ABC.pt" and convert to "xyzsp" and drops sp The problem is that tex.dimen["textwidth"]/2 gives a number, while TeX wants a dimension there PS both numbers are signed ( and maybe with spaces here and there, I don't remember) -- luigi