On Thu, Jun 14, 2012 at 10:17 PM, Jaroslav Hajtmar <hajt...@gyza.cz> wrote: > Hello ConTeXist and Lua experts. > > In a my Lua project I need to determine the changing dimensions of the TeX > \vbox through Lua. > In ConTeXt cycle, it works fine, but in the Lua cycle does not change the > dimensions of the box. > What am I doing wrong? > > Thank you. > > Jaroslav Hajtmar > > Here is my minimal example: > -------------------------------------------------------------------- > \newdimen\lsize > > \def\contentofvbox{\input ward } > > \def\setmybox{\setbox0=\vbox{\hsize=\lsize \contentofvbox}} > > \starttext > > Height of box via ConTeXt (works fine): > > \setmybox > > \lsize=5cm > \dorecurse{3}{% > \lsize=\dimexpr(\lsize+7mm) > \setmybox > height of box: \the\ht0\par > width of box: \the\wd0\par > \box0\par > } > > \page > > ... and Height of box via Lua (do not working): > > \setmybox > > \ctxlua{ > tex.dimen.lsize=5*72.27*65536/25.4 > > for i=1, 3 do > tex.dimen.lsize=tex.dimen.lsize+7*72.27*65536/25.4 > context([[\setmybox]]) > local heightbox=tex.box[0].height > local widthbox=tex.box[0].width > heightbox=(heightbox*2.84527559067*25.4)/(72.27*65536) > widthbox=(widthbox*2.84527559067*25.4)/(72.27*65536) > context([[height of box:]]..heightbox.."pt\\par") > context([[width of box:]]..widthbox.."pt\\par") > context([[\box0\par]]) > end > } > > > > \stoptext
Try this one: \def\setmybox{\setbox0=\vbox{\hsize=\lsize\input knuth \par}} \newdimen\lsize \lsize=5cm \starttext Height of box via ConTeXt (works fine): \setmybox \lsize=5cm \dorecurse{3}{% \lsize=\dimexpr(\lsize+7mm) \setmybox height of box: \the\ht0\par width of box: \the\wd0\par \box0\par } \page ... and Height of box via Lua (does it work ?): \setmybox \ctxlua{tex.dimen.lsize=5*72.27*65536/25.4;i=0} \dorecurse{3}{% \ctxlua{ --[=[ for i=1, 3 do ]=] i=i+1 tex.dimen.lsize=tex.dimen.lsize+7*72.27*65536/25.4 context([[\setmybox]]) } \ctxlua{ local heightbox=tex.box[0].height local widthbox=tex.box[0].width heightbox=(heightbox*2.84527559067*25.4)/(72.27*65536) widthbox=(widthbox*2.84527559067*25.4)/(72.27*65536) context(i..[[ height of box:]]..heightbox.."pt : "..(tex.box[0].height/2^16).."pt\\par") context(i..[[ width of box:]]..widthbox.."pt : "..(tex.box[0].width/2^16).."pt\\par") context([[\box0\par]]) --[=[ end ]=] } } \stoptext -- luigi ___________________________________________________________________________________ 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 ___________________________________________________________________________________