Re: [NTG-context] calculating with dimension unit
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 ___
Re: [NTG-context] calculating with dimension unit
Am 22.04.2013 um 01:13 schrieb Jan Heinen jahei...@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 ___
Re: [NTG-context] calculating with dimension unit
On 4/22/2013 8:48 AM, Wolfgang Schuster wrote: Am 22.04.2013 um 01:13 schrieb Jan Heinen jahei...@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 ___
Re: [NTG-context] calculating with dimension unit
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 ___
Re: [NTG-context] calculating with dimension unit
Am 22.04.2013 um 10:14 schrieb Hans Hagen pra...@wxs.nl: On 4/22/2013 8:48 AM, Wolfgang Schuster wrote: Am 22.04.2013 um 01:13 schrieb Jan Heinen jahei...@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 ___
Re: [NTG-context] calculating with dimension unit
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 ___
Re: [NTG-context] calculating with dimension unit
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 ___
Re: [NTG-context] calculating with dimension unit
On 2013-04-22, at 6:43 AM, Wolfgang Schuster schuster.wolfg...@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 ___
Re: [NTG-context] calculating with dimension unit
On Mon, Apr 22, 2013 at 1:31 PM, Jan Heinen jahei...@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 ___
Re: [NTG-context] calculating with dimension unit
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 ___
Re: [NTG-context] calculating with dimension unit
Am 22.04.2013 um 23:28 schrieb Jan Heinen jahei...@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 ___
[NTG-context] calculating with dimension unit
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 ___
Re: [NTG-context] calculating with dimension unit
\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 ___