From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/71975 Path: news.gmane.org!not-for-mail From: "Thomas A. Schmitz" Newsgroups: gmane.comp.tex.context Subject: Re: xml and lua again Date: Fri, 28 Oct 2011 08:55:18 +0200 Message-ID: <4EAA51D6.3050909@uni-bonn.de> References: <4EA2F34E.6080202@uni-bonn.de> <4EA53B44.1040105@wxs.nl> <4EA55792.9090408@uni-bonn.de> <4EA5598A.4060109@wxs.nl> <4EA599BE.2050304@uni-bonn.de> <4EA5B2F2.2050700@wxs.nl> <4EA684D9.2040702@uni-bonn.de> <4EA68CB4.30809@wxs.nl> <4EA68F04.4090706@uni-bonn.de> <4EA9231F.6080001@uni-bonn.de> <4EA93348.6030308@uni-bonn.de> <4EA93AE0.2000805@wxs.nl> <4EAA4A61.4090707@uni-bonn.de> <83BD5F74-4BB7-41D2-9C1E-F5F31084E6AC@gundla.ch> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1319784941 24609 80.91.229.12 (28 Oct 2011 06:55:41 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 28 Oct 2011 06:55:41 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Fri Oct 28 08:55:37 2011 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RJgLo-00069c-EX for gctc-ntg-context-518@m.gmane.org; Fri, 28 Oct 2011 08:55:36 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id CC666CB0A6; Fri, 28 Oct 2011 08:55:35 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ycNflCxmsa1v; Fri, 28 Oct 2011 08:55:33 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 1C497CB0A2; Fri, 28 Oct 2011 08:55:33 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 5C4E0CB0A2 for ; Fri, 28 Oct 2011 08:55:32 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PHU42HhBk5fe for ; Fri, 28 Oct 2011 08:55:20 +0200 (CEST) Original-Received: from filter4-nij.mf.surf.net (filter4-nij.mf.surf.net [195.169.124.155]) by balder.ntg.nl (Postfix) with ESMTP id 4C50FCB09E for ; Fri, 28 Oct 2011 08:55:20 +0200 (CEST) Original-Received: from uni-bonn.de (mail.uni-bonn.de [131.220.15.113]) by filter4-nij.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p9S6tJbT008817 for ; Fri, 28 Oct 2011 08:55:19 +0200 Original-Received: from [87.178.37.233] (account tschmit1@uni-bonn.de HELO [192.168.0.3]) by fe2.uni-bonn.de (CommuniGate Pro SMTP 5.2.12) with ESMTPSA id 2508573 for ntg-context@ntg.nl; Fri, 28 Oct 2011 08:55:18 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15 In-Reply-To: <83BD5F74-4BB7-41D2-9C1E-F5F31084E6AC@gundla.ch> X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=131.220.15.113; country=DE; region=07; city=Bonn; latitude=50.7333; longitude=7.1000; http://maps.google.com/maps?q=50.7333,7.1000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 04FO6Tj94 - eb5a4e3678a0 - 20111028 X-Scanned-By: CanIt (www . roaringpenguin . com) on 195.169.124.155 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:71975 Archived-At: On 10/28/11 08:44, Patrick Gundlach wrote: > > >>>>> >>>>> 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 > Luigi, Patrick, thanks for your explanations! The point of my question was: can I feed the content of tex.dimen["textwidth"] directly back to TeX, and the answer to this appears to be "no"; you need to add some unit to it (otherwise, you get an error message). Which was a bit confusing to me at first, because the name tex.dimen implies that it holds a "real" dimension, like \newdim does. Thomas ___________________________________________________________________________________ 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 ___________________________________________________________________________________