* calculating with dimension unit
@ 2013-04-21 23:13 Jan Heinen
2013-04-21 23:59 ` luigi scarso
` (2 more replies)
0 siblings, 3 replies; 13+ messages in thread
From: Jan Heinen @ 2013-04-21 23:13 UTC (permalink / raw)
To: ntg-context
In a book I produced with ConTeXt last year, I did a lot of
calculation to be able to change the layout dynamicaly.
With the actual version of ConTeXt I can't compile the book.
I have tried a lot of things today ... without success.
I hope my minimal-example helps you to understand, what I
want to do - and what I am doing wrong:
\starttext
\setupexternalfigures[location={local,global,default}]
\defineexpandable\ColumnA {30mm}
\defineexpandable\ColumnB {40mm}
\defineexpandable\ColumnABi {\dimexpr(\ColumnA + \ColumnB)}
\defineexpandable\ColumnABii {\ctxlua{context(\ColumnA +
\ColumnB)}}
\newdimen\ColumnABiii \ColumnABiii = \dimexpr(\ColumnA +
\ColumnB)
A \ColumnA% ok
B \ColumnB% ok
% I sadly get only errors when I delete the comments:
%ColumnABi: \ColumnABi
%ColumnABii: \ColumnABii
%ColumnABiii: \ColumnABiii
%\externalfigure[cow][width=\ColumnABiii]
~
\page
\stoptext
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-21 23:13 calculating with dimension unit Jan Heinen
@ 2013-04-21 23:59 ` luigi scarso
2013-04-22 6:48 ` Wolfgang Schuster
2013-04-22 8:23 ` Hans Hagen
2 siblings, 0 replies; 13+ messages in thread
From: luigi scarso @ 2013-04-21 23:59 UTC (permalink / raw)
To: mailing list for ConTeXt users
\starttext
\setupexternalfigures[location={local,global,default}]
\defineexpandable\ColumnA {30mm}
\defineexpandable\ColumnB {40mm}
\defineexpandable\ColumnABi {\the\dimexpr(\ColumnA + \ColumnB)}
\defineexpandable\ColumnABii {\ctxlua{context([==[\ColumnA + \ColumnB]==])}}
\newdimen\ColumnABiii \ColumnABiii=\dimexpr(\ColumnA + \ColumnB)
A \ColumnA% ok
B \ColumnB% ok
ColumnABi: \ColumnABi
ColumnABii: \ColumnABii
ColumnABiii: \the\ColumnABiii
\externalfigure[cow][width=\ColumnABiii]
~
\page
\stoptext
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-21 23:13 calculating with dimension unit Jan Heinen
2013-04-21 23:59 ` luigi scarso
@ 2013-04-22 6:48 ` Wolfgang Schuster
2013-04-22 8:14 ` Hans Hagen
2013-04-22 8:23 ` Hans Hagen
2 siblings, 1 reply; 13+ messages in thread
From: Wolfgang Schuster @ 2013-04-22 6:48 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 22.04.2013 um 01:13 schrieb Jan Heinen <JaHeinen@gmx.de>:
> In a book I produced with ConTeXt last year, I did a lot of calculation to be able to change the layout dynamicaly.
>
> With the actual version of ConTeXt I can't compile the book. I have tried a lot of things today ... without success.
> I hope my minimal-example helps you to understand, what I want to do - and what I am doing wrong:
>
>
> \starttext
> \setupexternalfigures[location={local,global,default}]
>
> \defineexpandable\ColumnA {30mm}
> \defineexpandable\ColumnB {40mm}
> \defineexpandable\ColumnABi {\dimexpr(\ColumnA + \ColumnB)}
> \defineexpandable\ColumnABii {\ctxlua{context(\ColumnA + \ColumnB)}}
> \newdimen\ColumnABiii \ColumnABiii = \dimexpr(\ColumnA + \ColumnB)
\definemeasure[ColumnA][30mm]
\definemeasure[ColumnB][40mm]
\definemeasure[ColumnBi][\the\dimexpr(\measure{ColumnA}+\measure{ColumnB})]
> A \ColumnA% ok
>
> B \ColumnB% ok
>
> % I sadly get only errors when I delete the comments:
> %ColumnABi: \ColumnABi
A \measure{ColumnA}
B \measure{ColumnB}
C \measure{ColumnBi}
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-22 6:48 ` Wolfgang Schuster
@ 2013-04-22 8:14 ` Hans Hagen
2013-04-22 10:43 ` Wolfgang Schuster
0 siblings, 1 reply; 13+ messages in thread
From: Hans Hagen @ 2013-04-22 8:14 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 4/22/2013 8:48 AM, Wolfgang Schuster wrote:
>
> Am 22.04.2013 um 01:13 schrieb Jan Heinen <JaHeinen@gmx.de>:
>
>> In a book I produced with ConTeXt last year, I did a lot of calculation to be able to change the layout dynamicaly.
>>
>> With the actual version of ConTeXt I can't compile the book. I have tried a lot of things today ... without success.
>> I hope my minimal-example helps you to understand, what I want to do - and what I am doing wrong:
>>
>>
>> \starttext
>> \setupexternalfigures[location={local,global,default}]
>>
>> \defineexpandable\ColumnA {30mm}
>> \defineexpandable\ColumnB {40mm}
>> \defineexpandable\ColumnABi {\dimexpr(\ColumnA + \ColumnB)}
>> \defineexpandable\ColumnABii {\ctxlua{context(\ColumnA + \ColumnB)}}
>> \newdimen\ColumnABiii \ColumnABiii = \dimexpr(\ColumnA + \ColumnB)
>
> \definemeasure[ColumnA][30mm]
> \definemeasure[ColumnB][40mm]
> \definemeasure[ColumnBi][\the\dimexpr(\measure{ColumnA}+\measure{ColumnB})]
FYI: \the\dimexpr... will look ahead till there's something
nonexpandable, and contrary to what one expects
\dimexpr(...)
will not stop at the ) so, although with measures it normally goes okay,
personally I always use \relax as terminator; the \relax will be eaten
up so there is no interference but it guarantees to stop scanning.
(I've been wondering if we should make measured \the\dimexpr..\relax
internally which can save dimexpr at the user end.)
>> A \ColumnA% ok
>>
>> B \ColumnB% ok
>>
>> % I sadly get only errors when I delete the comments:
>> %ColumnABi: \ColumnABi
>
>
> A \measure{ColumnA}
>
> B \measure{ColumnB}
>
> C \measure{ColumnBi}
>
> Wolfgang
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________
>
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-21 23:13 calculating with dimension unit Jan Heinen
2013-04-21 23:59 ` luigi scarso
2013-04-22 6:48 ` Wolfgang Schuster
@ 2013-04-22 8:23 ` Hans Hagen
2 siblings, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2013-04-22 8:23 UTC (permalink / raw)
To: mailing list for ConTeXt users; +Cc: Jan Heinen
On 4/22/2013 1:13 AM, Jan Heinen wrote:
> %\externalfigure[cow][width=\ColumnABiii]
Already for quite a while some commands that take a dimension as well as
a keyword need a verbose dimension (so \the\ColumnABiii in your case)
because it's handled at the lua end (where at this moment we cannot deal
with it otherwise).
Hans
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
| www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-22 8:14 ` Hans Hagen
@ 2013-04-22 10:43 ` Wolfgang Schuster
2013-04-22 14:00 ` Aditya Mahajan
0 siblings, 1 reply; 13+ messages in thread
From: Wolfgang Schuster @ 2013-04-22 10:43 UTC (permalink / raw)
To: Hans Hagen; +Cc: mailing list for ConTeXt users
Am 22.04.2013 um 10:14 schrieb Hans Hagen <pragma@wxs.nl>:
> On 4/22/2013 8:48 AM, Wolfgang Schuster wrote:
>>
>> Am 22.04.2013 um 01:13 schrieb Jan Heinen <JaHeinen@gmx.de>:
>>
>>> In a book I produced with ConTeXt last year, I did a lot of calculation to be able to change the layout dynamicaly.
>>>
>>> With the actual version of ConTeXt I can't compile the book. I have tried a lot of things today ... without success.
>>> I hope my minimal-example helps you to understand, what I want to do - and what I am doing wrong:
>>>
>>>
>>> \starttext
>>> \setupexternalfigures[location={local,global,default}]
>>>
>>> \defineexpandable\ColumnA {30mm}
>>> \defineexpandable\ColumnB {40mm}
>>> \defineexpandable\ColumnABi {\dimexpr(\ColumnA + \ColumnB)}
>>> \defineexpandable\ColumnABii {\ctxlua{context(\ColumnA + \ColumnB)}}
>>> \newdimen\ColumnABiii \ColumnABiii = \dimexpr(\ColumnA + \ColumnB)
>>
>> \definemeasure[ColumnA][30mm]
>> \definemeasure[ColumnB][40mm]
>> \definemeasure[ColumnBi][\the\dimexpr(\measure{ColumnA}+\measure{ColumnB})]
>
> FYI: \the\dimexpr... will look ahead till there's something nonexpandable, and contrary to what one expects
>
> \dimexpr(...)
>
> will not stop at the ) so, although with measures it normally goes okay, personally I always use \relax as terminator; the \relax will be eaten up so there is no interference but it guarantees to stop scanning.
AFAIR the etex already mentions it.
> (I've been wondering if we should make measured \the\dimexpr..\relax internally which can save dimexpr at the user end.)
+1
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-22 10:43 ` Wolfgang Schuster
@ 2013-04-22 14:00 ` Aditya Mahajan
0 siblings, 0 replies; 13+ messages in thread
From: Aditya Mahajan @ 2013-04-22 14:00 UTC (permalink / raw)
To: mailing list for ConTeXt users
On 2013-04-22, at 6:43 AM, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:
>
>> (I've been wondering if we should make measured \the\dimexpr..\relax internally which can save dimexpr at the user end.)
>
> +1
+1 from me as well. Having to use \dimexpr...\relax in definemeasure ISS bit awkward.
Aditya
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
@ 2013-04-23 18:18 Jan Heinen
0 siblings, 0 replies; 13+ messages in thread
From: Jan Heinen @ 2013-04-23 18:18 UTC (permalink / raw)
To: ntg-context
Ok, I now put the \ctxlua into an other chapter:
http://wiki.contextgarden.net/Calculating_with_dimension_units
Can you say something to the missing points there? "Wich
meethod?", "\the" and "Expanding
If you don't know how to edit the context-wiki, please write
your information here in the mailinglist - then I will put
it into the wiki.
Regards
Jannis
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-22 21:28 Jan Heinen
@ 2013-04-22 21:34 ` Wolfgang Schuster
0 siblings, 0 replies; 13+ messages in thread
From: Wolfgang Schuster @ 2013-04-22 21:34 UTC (permalink / raw)
To: mailing list for ConTeXt users
Am 22.04.2013 um 23:28 schrieb Jan Heinen <JaHeinen@gmx.de>:
> Thank you all!!!!!!
>
> My book from last year (15.000 lines text + context-code and 1.500 lines macro-code now was compiled without no further problems!
>
> I only had to change all
> \define\variable ...
>
> to
> \defineexpandable\variable ...
>
>
> I think, now I understand a little bit more about ConTeXt and try again to give a little bit back to the community.
> I have started a new article on the context-wiki:
>
> http://wiki.contextgarden.net/Calculating_with_dimension_units
>
> Hopefully the more sophisticated ConTeXter help a little bit to improve the article. Please have a look what is wrong and what I have forgotten (or don't know).
The Lua version can be removed because the line
\defineexpandable\ColumnABii {\ctxlua{context([==[\ColumnA + \ColumnB]==])}}
is only a complicated form to write
\defineexpandable\ColumnABii {30mm + 40mm}
What does happen is that context replaces \ColumnA with 30mm and \ColumnB with 40mm but nothing is calculate because the argument is a simple text string.
Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
@ 2013-04-22 21:28 Jan Heinen
2013-04-22 21:34 ` Wolfgang Schuster
0 siblings, 1 reply; 13+ messages in thread
From: Jan Heinen @ 2013-04-22 21:28 UTC (permalink / raw)
To: ntg-context
Thank you all!!!!!!
My book from last year (15.000 lines text + context-code and
1.500 lines macro-code now was compiled without no further
problems!
I only had to change all
\define\variable ...
to
\defineexpandable\variable ...
I think, now I understand a little bit more about ConTeXt
and try again to give a little bit back to the community.
I have started a new article on the context-wiki:
http://wiki.contextgarden.net/Calculating_with_dimension_units
Hopefully the more sophisticated ConTeXter help a little bit
to improve the article. Please have a look what is wrong and
what I have forgotten (or don't know).
Regards
Janis
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-22 11:31 Jan Heinen
2013-04-22 13:58 ` Aditya Mahajan
@ 2013-04-22 14:51 ` luigi scarso
1 sibling, 0 replies; 13+ messages in thread
From: luigi scarso @ 2013-04-22 14:51 UTC (permalink / raw)
To: mailing list for ConTeXt users
On Mon, Apr 22, 2013 at 1:31 PM, Jan Heinen <JaHeinen@gmx.de> wrote:
> Hello,
>
> thanks for the helpfull tipps. Only one wasn't working:
>
>
> \defineexpandable\ColumnABii {\ctxlua{context([==[\ColumnA +
> \ColumnB]==])}}
>
> ColumnABii: \ColumnABii
>
> The result is: ColumnABii: 30mm+ 40mm
> And it should be ColumnABii: 70mm
ColumnABii: \the\dimexpr \ColumnABii\relax
>
> And in the other cases I get back: 199.16928pt instead of 70mm but this
> seems to be the same.
TeX internally uses scaled points (1pt = 2^16 scaled point)
and prints values in american point (1pt = 1/72.27 inch 1inch =2.54cm)
--
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
2013-04-22 11:31 Jan Heinen
@ 2013-04-22 13:58 ` Aditya Mahajan
2013-04-22 14:51 ` luigi scarso
1 sibling, 0 replies; 13+ messages in thread
From: Aditya Mahajan @ 2013-04-22 13:58 UTC (permalink / raw)
To: mailing list for ConTeXt users
>
> I think this calculating with dimension is not very well documented in the context-wiki.
> Thus I would like to write a small article about "Calculating with dimension units" in the wiki.contextgarden.net to help others a bit.
> Or is there already an article somewhere?
Such an article will be very useful. Currently the information is scattered in plain tex manuals, etex manual, context manuals, and context source code documentation. Having it in one place will make it more easily accessible.
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: calculating with dimension unit
@ 2013-04-22 11:31 Jan Heinen
2013-04-22 13:58 ` Aditya Mahajan
2013-04-22 14:51 ` luigi scarso
0 siblings, 2 replies; 13+ messages in thread
From: Jan Heinen @ 2013-04-22 11:31 UTC (permalink / raw)
To: ntg-context
Hello,
thanks for the helpfull tipps. Only one wasn't working:
\defineexpandable\ColumnABii {\ctxlua{context([==[\ColumnA
+ \ColumnB]==])}}
ColumnABii: \ColumnABii
The result is: ColumnABii: 30mm+ 40mm
And it should be ColumnABii: 70mm
And in the other cases I get back: 199.16928pt instead of
70mm but this seems to be the same.
I think this calculating with dimension is not very well
documented in the context-wiki.
Thus I would like to write a small article about
"Calculating with dimension units" in the
wiki.contextgarden.net to help others a bit.
Or is there already an article somewhere?
Regards
Jannis
___________________________________________________________________________________
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2013-04-23 18:18 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21 23:13 calculating with dimension unit Jan Heinen
2013-04-21 23:59 ` luigi scarso
2013-04-22 6:48 ` Wolfgang Schuster
2013-04-22 8:14 ` Hans Hagen
2013-04-22 10:43 ` Wolfgang Schuster
2013-04-22 14:00 ` Aditya Mahajan
2013-04-22 8:23 ` Hans Hagen
2013-04-22 11:31 Jan Heinen
2013-04-22 13:58 ` Aditya Mahajan
2013-04-22 14:51 ` luigi scarso
2013-04-22 21:28 Jan Heinen
2013-04-22 21:34 ` Wolfgang Schuster
2013-04-23 18:18 Jan Heinen
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).