>>>> 
>>>> context.blackrule{ width = number.topoints(tex.dimen["textwidth"]/2) }
>> 
>> 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 :)

tex.dimen holds a number, that is the size in points, multiplied by 65536/1pt, 
so for example 3pt becomes

3pt * 65536
-----------  = 3 * 65536 = 196608
      1pt


This number is also known "sp". So if you store the number 3*65536 in 
tex.dimen[...], you can say:

my width is \directlua{ tex.dimen[...] / 2}sp (results to "my width is 
196608sp", which you can use as an argument to whatever needs a length)

or

my width is \directlua{  number_to_points(tex.dimen[...]) } where 
number_to_points is something like

number_to_points = function (amount_in_sp) 
  in_pt = tostring(amount_in_sp / 65536) 
  return in_pt .. "pt"
end

which gives "3pt". 

Patrick

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to