[NTG-context] error when using externalfigure
Hello, I have a big context source file which contains pictures from different sources. The problem is, that there are some pictures the context cannot process. It displays an error message and ends. I run the context from another script in batchmode. After finishing, the context creates a PDF file, which contains this problematic picture but the pdf is broken. It does not have numbers in the table of contents and it is not arranged by setup. Here is a minimal example: \starttext \externalfigure[ http://cdn-locations-images.tripomatic.com/img-poi1295-5ZTynx-s.jpg][width=26.5mm ] \stoptext When I run the context, it prints: ! Dimension too large. system tex error on line 1 in file a.tex: Dimension too large ... 1 \starttext 2 \externalfigure[ http://cdn-locations-images.tripomatic.com/img-poi1295-5ZTynx-s.jpg][width=26.5mm ] 3 \stoptext 4 \relocateexternalfigure ...d \foundexternalfigure \bgroup \box \foundexterna... l.1 \relocateexternalfigure \calculateexternalfigure ...ua {figures.include()} \ctxlua {figures.scale()}\... \dodoplaceexternalfigure ...[][#1][#2][#3][#4][#5] \dotagfigure \naturalvbox ... argument ...1295-5ZTynx-s.jpg][][width=26.5mm][] \fi \firstofoneargument #1-#1 Because I have several thousands pictures, it is impossible for me to correct them all. Is it somehow possible to run the context so that it ignores the problematic pictures? Thank you Pavel Dohnal ___ 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] print context version
Hi all, this is a very easy one, but I couldn't find information: for a document under version control, I would like to typeset the git revision and the context version used in a footer. For git, I have come up with \starttext git revision \ctxlua{context(os.resultof(git --no-pager log --pretty='\%h of \%aD' -1))} \stoptext But what is the easiest way to typeset the context version? There must be something easier than \ctxlua{context(os.resultof(context --version | grep current))}, right? All best 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 ___
Re: [NTG-context] print context version
On Mon, 26 Nov 2012, Thomas A. Schmitz wrote: Hi all, this is a very easy one, but I couldn't find information: for a document under version control, I would like to typeset the git revision and the context version used in a footer. For git, I have come up with \starttext git revision \ctxlua{context(os.resultof(git --no-pager log --pretty='\%h of \%aD' -1))} \stoptext But what is the easiest way to typeset the context version? There must be something easier than \ctxlua{context(os.resultof(context --version | grep current))}, right? \contextversion 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] mplib messages
On 11/12/2012 10:43 AM, Alan BRASLAU wrote: Hello, Were do MetaPost messages go using mplib? (/dev/null?) I see nothing on the console nor in the log file. Alan \starttext \startMPpage message a circle ; draw fullcircle scaled 2 cm ; \stopMPpage \stoptext \starttext \ctxlua{metapost.showlog = true} \startMPpage message(message: a circle) ; show(show: a circle) ; draw fullcircle scaled 2 cm ; \stopMPpage \stoptext - 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 ___
[NTG-context] \externalfigure and large-paged pdfs
Hi, Actually, this is a bug report. If you try to include a pdf with a large page size: \starttext \externalfigure[plankaart] \stoptext chances are that you get an error message like this: ! Dimension too large. recently read \hsize \setraggedness ...yphenpenalty \dimexpr 2.8\hsize /\dimexpr #1\relax \relax ... \raggedcenter ...spac_align_set_raggedness_middle \raggedstatus \plustwo \at... \next ...ght \pack_framed_do_setups \raggedcenter \vss \bgroup \localbegstru... \grph_include_finalize ...tedexternalfigureframed {\vfilll \box \foundextern... \grph_include_place ...ode \grph_include_finalize \fi \ctxlua {figures.pop()... ... l.2 \externalfigure[plankaart] It seems that \externalfigure forces execution of \raggedcenter, and if your PDF's page is large enough, that then fails. There is, in fact, a workaroud: \starttext {\setupalign[nothyphenated]\externalfigure[plankaart]} \stoptext but that looks totally bizarre. Hans, can you find a way to fix this properly? Best wishes, Taco ___ 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] \externalfigure and large-paged pdfs
On 11/8/2012 3:18 PM, Taco Hoekwater wrote: Hi, Actually, this is a bug report. If you try to include a pdf with a large page size: \starttext \externalfigure[plankaart] \stoptext chances are that you get an error message like this: ! Dimension too large. recently read \hsize \setraggedness ...yphenpenalty \dimexpr 2.8\hsize /\dimexpr #1\relax \relax ... \raggedcenter ...spac_align_set_raggedness_middle \raggedstatus \plustwo \at... \next ...ght \pack_framed_do_setups \raggedcenter \vss \bgroup \localbegstru... \grph_include_finalize ...tedexternalfigureframed {\vfilll \box \foundextern... \grph_include_place ...ode \grph_include_finalize \fi \ctxlua {figures.pop()... l.2 \externalfigure[plankaart] It seems that \externalfigure forces execution of \raggedcenter, and if your PDF's page is large enough, that then fails. There is, in fact, a workaroud: \starttext {\setupalign[nothyphenated]\externalfigure[plankaart]} \stoptext but that looks totally bizarre. Hans, can you find a way to fix this properly? what happens if you do \setupexternalfigures[align=] 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] \dorecurse within TABLE
On Fri, Oct 26, 2012 at 11:50 AM, Alan BRASLAU alan.bras...@cea.fr wrote: Does anyone have a solution to \dorecurse within TABLE? Alan Minimal example: \starttext \dorecurse{8}{\recurselevel\crlf} \bTABLE \dorecurse{8}{\bTR\bTD\recurselevel\eTD\eTR} \eTABLE \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 ___ table are strange, they can be parsed more than one time to achive the result If you use mkiv maybe the lua version is better \starttext \dorecurse{8}{\recurselevel\crlf} \startluacode global_cnt=0; \stopluacode \bTABLE %% ok, but why 17 ? \dorecurse{8}{\bTR\bTD\ctxlua{global_cnt=global_cnt+1;context(global_cnt-17)}:\recurselevel\eTD\eTR} \eTABLE %% straight \startluacode context.bTABLE() for i=1,8 do context.bTR() context.bTD() context(i) context.eTD() context.eTR() end context.eTABLE() \stopluacode \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 ___
Re: [NTG-context] using variable for subscript in math+lua
Hi Philipp, Thanks to you, Dalyoung and Hans for the nice example using luacode. I was wonedring how would you modify your code in order to be able to change the name of the matrix if necessary. For instance, how to modify your code in such a way that upon saying \ctxlua{document.print_matrix(b,3)} one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}. Thanks in advance: OK On 25 oct. 2012, at 03:02, Philipp Gesang philipp.ges...@alumni.uni-heidelberg.de wrote: ···date: 2012-10-25, Thursday···from: Jeong Dal··· Dear Hans, Lucas, Wolfgang, Aditya Now, I write a matrix using \startluacode by the helps of you. Also, I can do some operations in matrices which reduced my typing job. In this code, I have to give all the entries of a matrix as a table. It is good to use in many cases. I have one more question. If the given array is as the following and it works well. However, there might be a better way to do job using for iteration. I tired to use i, j in several ways but it doesn't work. Inside a string the variables are just bytes. To print to a string you can interpolate with string.format() [1]. [1] http://www.lua.org/manual/5.1/manual.html#pdf-string.format · \startluacode document = document or { } -- recommended: use namespace document.print_matrix = function (x, y) if not y then y = x end -- default to square context.startmatrix{left = \\left(\\,, right = \\,\\right)} local schema = a_{%d%d} -- %d: prints integer part for i=1, x do for j=1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end \stopluacode \starttext \startformula \ctxlua{document.print_matrix(3)} \stopformula \startformula \ctxlua{document.print_matrix(9,4)} \stopformula \startformula \ctxlua{document.print_matrix(9)} \stopformula \stoptext \endinput · Is there a way to do such a job using for iteration? Thank you for reading. Best regards, Dalyoung ___ 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 ___ -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments ___ 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 ___ ___ 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] using variable for subscript in math+lua
On 25-10-2012 20:02, Otared Kavian wrote: Hi Philipp, Thanks to you, Dalyoung and Hans for the nice example using luacode. I was wonedring how would you modify your code in order to be able to change the name of the matrix if necessary. For instance, how to modify your code in such a way that upon saying \ctxlua{document.print_matrix(b,3)} one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}. if the two of you can come up with some specs we can make a small module if needed 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] using variable for subscript in math+lua
On Thu, 25 Oct 2012 20:02:22 +0200, Otared Kavian ota...@gmail.com wrote: Hi Philipp, Thanks to you, Dalyoung and Hans for the nice example using luacode. I was wonedring how would you modify your code in order to be able to change the name of the matrix if necessary. For instance, how to modify your code in such a way that upon saying \ctxlua{document.print_matrix(b,3)} one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}. Thanks in advance: OK Something like this? · document.print_matrix = function (x, y, name) local name = name or a if not y then y = x end -- default to square context.startmatrix{left = \\left(\\,, right = \\,\\right)} local schema = name .. _{%d%d} -- %d: prints integer part for i=1, x do for j=1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end · Call with: \ctxlua{document.print_matrix(3, 3, b)} Best regards, Lukas ___ 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] using variable for subscript in math+lua
···date: 2012-10-25, Thursday···from: Otared Kavian··· Hi Philipp, Thanks to you, Dalyoung and Hans for the nice example using luacode. I was wonedring how would you modify your code in order to be able to change the name of the matrix if necessary. For instance, how to modify your code in such a way that upon saying \ctxlua{document.print_matrix(b,3)} one gets a 3x3 matrix whos coefficients are b_{11},…b_{33}. This may be overkill but you can just wrap the matrix command in some TeX macro: · % macros=mkvi \unprotect \startluacode local context = context commands.matrix_with_symbol = function (sym, x, y) if not y then y = x end -- default to square context.startmatrix{ left = \\left(\\,, right = \\,\\right) } local schema = sym .. _{%d%d} -- %d: prints integer part for i=1, x do for j=1, y do context.NC() context(schema, i, j) end context.NR() end context.stopmatrix() end \stopluacode \unexpanded\def\printsymbolmatrix{% \dotripleempty\print_symbol_matrix_indeed% } \def\print_symbol_matrix_indeed[#first][#second][#num]{% \bgroup \def\sym{a}%% set default symbol to print, could be done in Lua \def\y{nil}% \ifsecondargument \ifthirdargument \edef\sym{#first}% \edef\x{#second}% \edef\y{#num}% \else \doifnumberelse{#first}% {\edef \x{#first}\edef\y{#second}}% {\edef\sym{#first}\edef\x{#second}}% \fi \else \edef\x{#first}% \fi \ctxcommand{matrix_with_symbol(\!!bs\sym\!!es, \x, \y)}% \egroup% } \protect \starttext \startformula \printsymbolmatrix[3]%% symbol is “a”, matrix is square \stopformula \startformula \printsymbolmatrix[4][8]%% symbol is “a”, matrix is 4x8 \stopformula \startformula \printsymbolmatrix[b][8]%% symbol is “b”, matrix is square \stopformula \startformula \printsymbolmatrix[c][5][3]%% symbol is “c”, matrix is 5x3 \stopformula \stoptext \endinput · Now the symbol will default to “a” but you can specify another one. (Btw. I think the Lua part could be done as easily with dorecurse.) Regards Philipp Thanks in advance: OK On 25 oct. 2012, at 03:02, Philipp Gesang philipp.ges...@alumni.uni-heidelberg.de wrote: ···date: 2012-10-25, Thursday···from: Jeong Dal··· Dear Hans, Lucas, Wolfgang, Aditya Now, I write a matrix using \startluacode by the helps of you. Also, I can do some operations in matrices which reduced my typing job. In this code, I have to give all the entries of a matrix as a table. It is good to use in many cases. I have one more question. If the given array is as the following and it works well. However, there might be a better way to do job using for iteration. I tired to use i, j in several ways but it doesn't work. Inside a string the variables are just bytes. To print to a string you can interpolate with string.format() [1]. [1] http://www.lua.org/manual/5.1/manual.html#pdf-string.format · \startluacode document = document or { } -- recommended: use namespace document.print_matrix = function (x, y) if not y then y = x end -- default to square context.startmatrix{left = \\left(\\,, right = \\,\\right)} local schema = a_{%d%d} -- %d: prints integer part for i=1, x do for j=1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end \stopluacode \starttext \startformula \ctxlua{document.print_matrix(3)} \stopformula \startformula \ctxlua{document.print_matrix(9,4)} \stopformula \startformula \ctxlua{document.print_matrix(9)} \stopformula \stoptext \endinput · Is there a way to do such a job using for iteration? Thank you for reading. Best regards, Dalyoung ___ 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 ___ -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments ___ If your question is of interest to others as well, please
Re: [NTG-context] using variable for subscript in math+lua
···date: 2012-10-25, Thursday···from: Jeong Dal··· Dear Hans, Lucas, Wolfgang, Aditya Now, I write a matrix using \startluacode by the helps of you. Also, I can do some operations in matrices which reduced my typing job. In this code, I have to give all the entries of a matrix as a table. It is good to use in many cases. I have one more question. If the given array is as the following and it works well. However, there might be a better way to do job using for iteration. I tired to use i, j in several ways but it doesn't work. Inside a string the variables are just bytes. To print to a string you can interpolate with string.format() [1]. [1] http://www.lua.org/manual/5.1/manual.html#pdf-string.format · \startluacode document = document or { } -- recommended: use namespace document.print_matrix = function (x, y) if not y then y = x end -- default to square context.startmatrix{left = \\left(\\,, right = \\,\\right)} local schema = a_{%d%d} -- %d: prints integer part for i=1, x do for j=1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end \stopluacode \starttext \startformula \ctxlua{document.print_matrix(3)} \stopformula \startformula \ctxlua{document.print_matrix(9,4)} \stopformula \startformula \ctxlua{document.print_matrix(9)} \stopformula \stoptext \endinput · Is there a way to do such a job using for iteration? Thank you for reading. Best regards, Dalyoung ___ 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 ___ -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments pgpyR7Q10pCRx.pgp Description: PGP signature ___ 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] Referring to multiple elements
2012-09-28 Sietse Brouwer sbbrou...@gmail.com: Hi Sietse, \in{figure}[alpha,beta,gamma] This outputs “figure 1”. What I'd like to have is “figure 1-3”. The attached quasi-module seems to do it! On my computer, at least. (I call it 'quasi' because it is really nothing more than code in a file of its own.No configurability whatsoever, except to the extent that I tried to comment well, and split things up into functions.) I'd have written it so that it properly identifies runs like '1.2.1, 1.2.2, 1.2.3', too, but I can't find a function that will turn reference strings into such a prefixed strings. I hope it does what you want! Let me know if you want/need any alterations, or discover bugs. Thanks a lot for that. I'd adjust the interface, so that it matches the behaviour of \in: \def\inrange {\dodoublegroupempty\doinrange} \def\doinrange#left#right#dummy[#label] {\iffirstargument {#left }%% \fi \ctxlua{userdata.inwithranges(#label)}%% \ifsecondargument {#right}%% \fi} Then you can write: See \inrange{figures} [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h] See \inrange{figures}{TT} [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h] See \inrange [fig:a,fig:c,fig:d,fig:e,fig:g,fig:x,fig:h] Maybe worth mentioning: You need the additional module `showtable.lua` from http://article.gmane.org/gmane.comp.tex.context/78336 Marco ___ 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] Referring to multiple elements
Hi Marco, The heart of what you need is a lua function that will take an array of numbers, and return an array of consective-number runs, like so: fignumarray = {1, 2, 3,5, 6,8, 10, 11, 12} -- figruns = get_runs(fignumarray) -- returns a table structured like so: -- figruns[1].start = 1, figruns[1].stop = 3, -- figruns[2].start = 5, figruns[2].stop = 6, -- figruns[3].start = 8, figruns[3].stop = 8, -- figruns[4].start = 10, figruns[4].stop = 12 I've written one below, plus the scaffolding required to feed it the right input, and print its output to ConTeXt. Only two functions still need writing --- one to turn the context argument [fig:f1, fig:f2, fig:f4] into a lua array of strings, and one to turn each reference string into a figure number. But this should get you on your way. If you're not comfortable with programming LuaTeX, say so and I can fill in the two missing functions sometime this weekend. But they should be doable, really. (And, of course, you may be far more experienced in LuaTeX than I, I don't know.) Cheers, Sietse % should be below startluacode block, but clearer like so \def\inwithranges[#1]% {\ctxlua{u.inwithranges(#1)}} \startluacode u = userdata or { } function get_runs(a) runs = { } run_start = 1 while run_start = #a do run_stop = run_start while a[run_stop + 1] == a[run_stop] + 1 do run_stop = run_stop + 1 end print(a[run_start] .. - .. a[run_stop]) table.insert(runs, {[start] = a[run_start], [stop] = a[run_stop]}) run_start = run_stop + 1 end return runs end function u.inwithranges(ref_string) -- CTX... means I expect ConTeXt already has this function in a library somewhere local ref_array = CTXstring_to_array(refs_string) --FIXME local ref_numbers = { } for _, v in ipairs(ref_array) do ref_numbers[i] = CTXref_to_fignumber(array) --FIXME end ref_numbers.sort() runs = get_runs(ref_numbers) for i, run in ipairs(runs) do context.in( {run.start} ) context(-) context.in( {run.stop} ) if i #runs then context(',') end end end \stopluacode ___ 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] xml cross-references in lua?
On 09/11/2012 08:18 PM, Hans Hagen wrote: If the number of bib items is not that large hashing does not save much. (In x-xfdf.mkiv you can see another example). \starttext \startbuffer[demo] document bibitem xml:id=hagen2011 authorHans Hagen/author titleThe Meaning of Life Is 42/title journalThe Rhetoric of Mathematics/journal date2011/date /bibitem bibitem xml:id=hagen2012 authorHans Hagen/author titleThe New Meaning is Now 43/title journalHigh Energy Metaphysics/journal date2012/date /bibitem text pThis has been successfully proven in papers by bib ref=#hagen2011/ and bib ref=#hagen2012/./p /text /document \stopbuffer \startxmlsetups xml:define \xmlsetsetup{#1}{*}{xml:*} \stopxmlsetups \startxmlsetups xml:document \xmlall{#1}{/text} \stopxmlsetups \startxmlsetups xml:text \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:p \xmlflush{#1} \par \stopxmlsetups \startxmlsetups xml:bib \BibAuthor{#1}{\xmlatt{#1}{ref}} \stopxmlsetups \startxmlsetups xml:author [[\xmlflush{#1}]] \stopxmlsetups \def\BibAuthor#1#2{[1:\xmlfirst{whatever}{/document/bibitem[@xml:id==string.sub('#2',2)]/author}]} \xmlregistersetup{xml:define} \xmlprocessbuffer{whatever}{demo}{} \startluacode userdata = userdata or { } userdata.bibitems = { } \stopluacode \startxmlsetups xml:document \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:bibitem \ctxlua{userdata.bibitems[\letterhash\xmlatt{#1}{xml:id}] = #1} \stopxmlsetups \def\BibAuthor#1#2{[2:\xmlfirst{\cldcontext{userdata.bibitems['#2']}}{/author}]} \xmlprocessbuffer{whatever}{demo}{} \stoptext (I ran into a recently introduced side effect of an optimization so I'll generate you a new beta. Older versions should work anyway as no special trickery is used.) Hans Ah, wonderful, Hans, I can play with this! Thanks a lot for the swift reply and for the help, this will get me going! All best 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 ___
Re: [NTG-context] xml cross-references in lua?
On 11-9-2012 19:22, Thomas A. Schmitz wrote: Hi all, I have a question about xml processing and I think that what I want/need can best be achieved by using lua code, but so far, I'm not really sure how to proceed, so any help from one of the resident lua gurus would be welcome. So: the question. xml allows to provide elements with unique identifiers so that one can add cross-references within the document structure. Here is a sample xml file that shows what I mean: document bibitem xml:id=hagen2011 authorHans Hagen/author titleThe Meaning of Life Is 42/title journalThe Rhetoric of Mathematics/journal date2011/date /bibitem bibitem xml:id=hagen2012 authorHans Hagen/author titleThe New Meaning is Now 43/title journalHigh Energy Metaphysics/journal date2012/date /bibitem text pThis has been successfully proven in papers by bib ref=#hagen2011/ and bib ref=#hagen2012/./p /text /document [Note: the TEI guidelines add the hash character in the attribute value to such references, but after much googling, I'm still not sure if this is standard or necessary or bizarre.] So: at the point of the reference (which may be empty, like here, or contain text), I want to refer back to the bibitems. The typesetting engine should then be instructed to pick up the information, so that this is, e.g., typeset as This has been successfully proven in papers by Hans Hagen (2011) and Hans Hagen (2012). My idea: since the xml:id attributes must be unique across the document, it would be easiest to collect them into a lua table, with the xml:id as key, so their content could be accessed and typeset later. But unfortunately, I have no clue how to go about this... Could somebody provide a pointer? Thanks for your interest, if you've read this far! If the number of bib items is not that large hashing does not save much. (In x-xfdf.mkiv you can see another example). \starttext \startbuffer[demo] document bibitem xml:id=hagen2011 authorHans Hagen/author titleThe Meaning of Life Is 42/title journalThe Rhetoric of Mathematics/journal date2011/date /bibitem bibitem xml:id=hagen2012 authorHans Hagen/author titleThe New Meaning is Now 43/title journalHigh Energy Metaphysics/journal date2012/date /bibitem text pThis has been successfully proven in papers by bib ref=#hagen2011/ and bib ref=#hagen2012/./p /text /document \stopbuffer \startxmlsetups xml:define \xmlsetsetup{#1}{*}{xml:*} \stopxmlsetups \startxmlsetups xml:document \xmlall{#1}{/text} \stopxmlsetups \startxmlsetups xml:text \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:p \xmlflush{#1} \par \stopxmlsetups \startxmlsetups xml:bib \BibAuthor{#1}{\xmlatt{#1}{ref}} \stopxmlsetups \startxmlsetups xml:author [[\xmlflush{#1}]] \stopxmlsetups \def\BibAuthor#1#2{[1:\xmlfirst{whatever}{/document/bibitem[@xml:id==string.sub('#2',2)]/author}]} \xmlregistersetup{xml:define} \xmlprocessbuffer{whatever}{demo}{} \startluacode userdata = userdata or { } userdata.bibitems = { } \stopluacode \startxmlsetups xml:document \xmlflush{#1} \stopxmlsetups \startxmlsetups xml:bibitem \ctxlua{userdata.bibitems[\letterhash\xmlatt{#1}{xml:id}] = #1} \stopxmlsetups \def\BibAuthor#1#2{[2:\xmlfirst{\cldcontext{userdata.bibitems['#2']}}{/author}]} \xmlprocessbuffer{whatever}{demo}{} \stoptext (I ran into a recently introduced side effect of an optimization so I'll generate you a new beta. Older versions should work anyway as no special trickery is used.) 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] Lua conditionals fail inside \starttexdefinition
On 4-9-2012 20:44, Marco Patzer wrote: On 2012-09-04 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Why does adding semicolon not work? Do you have a example? \starttext \startluacode if true then; context(true) else; context(false) end \stopluacode \stoptext \ctxlua{context(tostring(some condition)} given that the condition returns true/false - 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] TeX expansion within lua
Am 04.09.2012 um 20:11 schrieb Marco Patzer home...@lavabit.com: On 2012-09-04 Wolfgang Schuster wolfgang.schus...@gmail.com wrote: Is there a good reason why you put \newdimen because dimen/count etc. registers should always be defined once. The definitions are not in a macro, they are defined at the top of the file. I messed around while creating a minimal example. However, the problem remains the same since the assignment does not happen within Lua. But, thanks for the hint. I am always happy for improvements and feedback about my code. What prevents you from setting the dimen value in Lua? \starttext \scratchdimen = 20pt \the\scratchdimen \ctxlua{tex.dimen.scratchdimen = 10pt} \the\scratchdimen \stoptext 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] built-in units command (mkiv) fails
Am 22.08.2012 um 21:54 schrieb Andreas Mang m...@imt.uni-luebeck.de: Hi there, Did / Do I miss something or is there a problem with the built-in \unit command? minimal example: start example \starttext 10 \unit{km/h} \stoptext stop example output: 10 kilometersolidushour ConTeXt: ver: 2012.08.16 22:20 MKIV fmt: 2012.8.22 phys-dim.mkiv %\ctxlua{ %languages.labels.define(setupprefixtext,prefixes)% %languages.labels.define(setupunittext,units)% %languages.labels.define(setupoperatortext,operators)% %languages.labels.define(setupsuffixtext,suffixes)% %} \ctxcommand{definelabels(prefix, prefixes )} \ctxcommand{definelabels(unit,units)} \ctxcommand{definelabels(operator,operators)} \ctxcommand{definelabels(suffix, suffixes )} 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] Creating TeX dimensions and counters registers directly in Lua
Am 22.08.2012 um 09:19 schrieb Jaroslav Hajtmar hajt...@gyza.cz: Hello all, Is it possible to create a new dimension ConTeXt register directly in Lua, or I have to first create the ConTeXt dimensional register and then to subsequently assign it a value? Here is example: \starttext \newdimen\mydimension \directlua{tex.setdimen(mydimension, 123)} \stoptext works fine, but all like: \starttext \directlua{tex.print([[\newdimen\myotherdimension]])} \directlua{tex.setdimen(myotherdimension, 123)} \directlua{tex.newdimen(myotherdimension)} etc... \stoptext fails. In addition, I am interested in whether directly in Lua to create a new counter as in the previous. \starttext \newcount\mycount \directlua{ tex.setcount(mycount,125) } again works, but anything like: \starttext \directlua{tex.print([[\newcount\myothercount]])} \directlua{tex.newcount(myothercount)} etc... \stoptext again fails... Is there any source or examples to study anything about it? AFAIK there is no tex.setdimen but what’s the problem to use Lua tables to save the values. \starttext \ctxlua{mydimension = number.topoints(1)} \ctxlua{context(mydimension)} \blank \ctxlua{myotherdimension = 123456} \ctxlua{context(number.tocentimeters(myotherdimension))} \stoptext 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] Creating TeX dimensions and counters registers directly in Lua
Thanks Wolfgang for the reply, but I must have misunderstood. My point is, that TeX registers was subsequently visible and usable in TeX (eg for width or height of boxes, etc.) Eg. for example, \the\mydimension can see that this does not occur! In addition, I solve the problem at LuaTEX, so ConTeXt converting functions do not work etc. .. Thanx Jaroslav Here is another example: \starttext \newdimen\mytexdimension \mytexdimension=100pt \ctxlua{myluadimension = number.topoints(1)} \ctxlua{context(myluadimension)} \the\mytexdimension \hbox to\mytexdimension{X} % FAILS %\the\myluadimension %\hbox to\myluadimension{X} \stoptext Dne 22.8.2012 9:43, Wolfgang Schuster napsal(a): \starttext \ctxlua{mydimension = number.topoints(1)} \ctxlua{context(mydimension)} \blank \ctxlua{myotherdimension = 123456} \ctxlua{context(number.tocentimeters(myotherdimension))} \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] Creating TeX dimensions and counters registers directly in Lua
On 22-8-2012 11:09, Jaroslav Hajtmar wrote: Thanks Wolfgang for the reply, but I must have misunderstood. My point is, that TeX registers was subsequently visible and usable in TeX (eg for width or height of boxes, etc.) Eg. for example, \the\mydimension can see that this does not occur! In addition, I solve the problem at LuaTEX, so ConTeXt converting functions do not work etc. .. Thanx Jaroslav Here is another example: \starttext \newdimen\mytexdimension \mytexdimension=100pt \ctxlua{myluadimension = number.topoints(1)} \ctxlua{context(myluadimension)} \the\mytexdimension \hbox to\mytexdimension{X} % FAILS %\the\myluadimension %\hbox to\myluadimension{X} Of course that fails: why should the globally defined lua variable myluadimension magically become a \dimen register at the tex end? And believe it or not, the context conversion function do work, else mkiv wouldn't work. \stoptext Here is the right code: \starttext \newdimen\mytexdimension \mytexdimension 100pt \ruledhbox to\mytexdimension{\the\mytexdimension} \ctxlua{document.myluadimension = 200pt} \ruledhbox to \cldcontext{document.myluadimension}{\cldcontext{document.myluadimension}} \ctxlua{tex.dimen.mytexdimension = 300pt} \ruledhbox to\mytexdimension{\the\mytexdimension} \stoptext - 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] Creating TeX dimensions and counters registers directly in Lua
On Wed, Aug 22 2012, Jaroslav Hajtmar wrote: \ctxlua{myluadimension = number.topoints(1)} \ctxlua{context(myluadimension)} \def\myluadimension{\ctxlua{context(myluadimension)}} ... \hbox to\myluadimension{X} -- Peter ___ 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] Ctx ... Lua
Hello, sometimes in this mail discussion I'm encountering a Ctx/Lua command which has been unknown for me or I would use other (known) commands to do the job. So - would it be possible to explain - what's the difference/advantage btw \directlua and \ctxlua - what \ctxcommand{} does - what \cldcontext{} does? TIA. Lukas ___ 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] Creating TeX dimensions and counters registers directly in Lua
Thank to Hans and Peter too. It works in context fine now. I would like realize this same in pure LuaTeX. I was primarily in the query for it to find Lua equivalent of TeX primitives \newdimen and \newcount (for direct creating new TeX registers) I could use something like \directlua{tex.newdimen.mydimen} that would create TeX register mydimen and then \directlua{tex.dimen.mydimen=200*2^16} which set value of register and that should be present in TeX for direct use such as \the\mydimen etc. I apologize for my naivete :-). Of course, I did not think that the global variable is magically changed the registry value, I just did not know how to implement it. Plus, I had in mind that ConTeXt conversion functions do not work in a clean LuaTEX (without reading about some library functions). One more thanx. Jaroslav Here is my pure luatex example. Is there any easy way? \newdimen\mytexdimension \mytexdimension 100pt mytexdimension: .\hbox to\mytexdimension{\the\mytexdimension}. \directlua{tex.myluadimension = 200pt} myluadimension: .\hbox to \directlua{tex.print(tex.myluadimension)}{\directlua{tex.print(tex.myluadimension)}}. \directlua{tex.dimen.mytexdimension = 300pt} mytexdimension: .\hbox to\mytexdimension{\the\mytexdimension}. \def\myluadimension{\directlua{tex.print(tex.myluadimension)}} myluadimension: .\hbox to\myluadimension{\myluadimension}. \bye Dne 22.8.2012 12:32, Hans Hagen napsal(a): On 22-8-2012 11:09, Jaroslav Hajtmar wrote: Thanks Wolfgang for the reply, but I must have misunderstood. My point is, that TeX registers was subsequently visible and usable in TeX (eg for width or height of boxes, etc.) Eg. for example, \the\mydimension can see that this does not occur! In addition, I solve the problem at LuaTEX, so ConTeXt converting functions do not work etc. .. Thanx Jaroslav Here is another example: \starttext \newdimen\mytexdimension \mytexdimension=100pt \ctxlua{myluadimension = number.topoints(1)} \ctxlua{context(myluadimension)} \the\mytexdimension \hbox to\mytexdimension{X} % FAILS %\the\myluadimension %\hbox to\myluadimension{X} Of course that fails: why should the globally defined lua variable myluadimension magically become a \dimen register at the tex end? And believe it or not, the context conversion function do work, else mkiv wouldn't work. \stoptext Here is the right code: \starttext \newdimen\mytexdimension \mytexdimension 100pt \ruledhbox to\mytexdimension{\the\mytexdimension} \ctxlua{document.myluadimension = 200pt} \ruledhbox to \cldcontext{document.myluadimension}{\cldcontext{document.myluadimension}} \ctxlua{tex.dimen.mytexdimension = 300pt} \ruledhbox to\mytexdimension{\the\mytexdimension} \stoptext - 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] Ctx ... Lua
Am 22.08.2012 um 13:15 schrieb Procházka Lukáš l...@pontex.cz: Hello, sometimes in this mail discussion I'm encountering a Ctx/Lua command which has been unknown for me or I would use other (known) commands to do the job. So - would it be possible to explain - what's the difference/advantage btw \directlua and \ctxlua No difference, just another name, there are even more synonyms. - what \ctxcommand{} does \ctxcommand{...} == \ctxlua{commands} - what \cldcontext{} does? \cldcontext{...} == \ctxlua{context(...)} There is also \cldcommand{...} which is a short form for \ctxlua{context} All these commands access functions in the “commands” or the “context” namespace. 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] Lua: document v. userdata
In a recent thread, Hans used the document namespace, where I (naively) expected userdata: On Aug 22, 2012, at 6:32 AM, Hans Hagen wrote: \ctxlua{document.myluadimension = 200pt} Is there a reason not to use userdata.myluadimension? Or is document.myluadimension safe, because myluadimension is almost certainly not an entry used by ConTeXt? Is using document.myluadimension better style here, in some sense? Somewhere I had gotten the idea that if a ConTeXt user wanted to store something in Lua, they ought to store it in the userdata namespace. Thanks, Michael This e-mail message (including any attachments) is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message (including any attachments) is strictly prohibited. If you have received this message in error, please contact the sender by reply e-mail message and destroy all copies of the original message (including attachments). ___ 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] Lua: document v. userdata
On 22-8-2012 14:55, Rogers, Michael K wrote: In a recent thread, Hans used the document namespace, where I (naively) expected userdata: On Aug 22, 2012, at 6:32 AM, Hans Hagen wrote: \ctxlua{document.myluadimension = 200pt} Is there a reason not to use userdata.myluadimension? Or is document.myluadimension safe, because myluadimension is almost certainly not an entry used by ConTeXt? Is using document.myluadimension better style here, in some sense? Somewhere I had gotten the idea that if a ConTeXt user wanted to store something in Lua, they ought to store it in the userdata namespace. Sure. Actually the document namespace has some functions so there is more danger in a clash there, so userdata is better. 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] Ctx ... Lua
On 22-8-2012 13:26, Wolfgang Schuster wrote: Am 22.08.2012 um 13:15 schrieb Procházka Lukáš l...@pontex.cz: Hello, sometimes in this mail discussion I'm encountering a Ctx/Lua command which has been unknown for me or I would use other (known) commands to do the job. So - would it be possible to explain - what's the difference/advantage btw \directlua and \ctxlua No difference, just another name, there are even more synonyms. The \ctxlua variant is somewhat more future proof. In the past \directlua had a mandate extra argument. Also, the \ctxlua macro can use a dedicated message namespace if needed and future versions might have more tracing. 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] test for (negative) number
On Mon, 20 Aug 2012 20:11:32 +0200, Sietse Brouwer sbbrou...@gmail.com wrote: Hi Peter, I recommend using the following handy little idiom: \ctxlua{commands.doifelse(-45 0)}{big}{small} % small It lets you do all sorts of things that are tricky in TeX: \ctxlua{ commands.doifelse( string.len( -45 ) 5 ) }{long}{short} Cheers, Sietse ... Has been wikified - http://wiki.contextgarden.net/Command/doif...; Lukas ___ 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] test for (negative) number
Am 21.08.2012 um 08:32 schrieb Procházka Lukáš l...@pontex.cz: On Mon, 20 Aug 2012 20:11:32 +0200, Sietse Brouwer sbbrou...@gmail.com wrote: Hi Peter, I recommend using the following handy little idiom: \ctxlua{commands.doifelse(-45 0)}{big}{small} % small It lets you do all sorts of things that are tricky in TeX: \ctxlua{ commands.doifelse( string.len( -45 ) 5 ) }{long}{short} Cheers, Sietse ... Has been wikified - http://wiki.contextgarden.net/Command/doif…; For functions in the commands namespace you can write e.g. \ctxcommand{doifelse(…)}{…}{…} instead of \ctxlua{commands.doifelse(…)}{…}{…}. 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] test for (negative) number
Thanks for all the answers so far. The 'doifelse' should do the trick. I was hoping for a system macro, but if there is none, I have to program it myself. :-) Peter Am 21.08.2012 08:56, schrieb Wolfgang Schuster: Am 21.08.2012 um 08:32 schrieb Procházka Lukáš l...@pontex.cz: On Mon, 20 Aug 2012 20:11:32 +0200, Sietse Brouwer sbbrou...@gmail.com wrote: Hi Peter, I recommend using the following handy little idiom: \ctxlua{commands.doifelse(-45 0)}{big}{small} % small It lets you do all sorts of things that are tricky in TeX: \ctxlua{ commands.doifelse( string.len( -45 ) 5 ) }{long}{short} Cheers, Sietse ... Has been wikified - http://wiki.contextgarden.net/Command/doif…; For functions in the commands namespace you can write e.g. \ctxcommand{doifelse(…)}{…}{…} instead of \ctxlua{commands.doifelse(…)}{…}{…}. 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 ___ ___ 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] test for (negative) number
... I also found another solution reposter before: \ctxlua{commands.testcase(condition)} { If true...} {If false} Note that both blocks (if-true and if-false) are mandatory. Considering Wolfgang's last answer, it would be better to write: \ctxcommand{testcase(condition)} { If true...} {If false} Lukas On Mon, 20 Aug 2012 20:11:32 +0200, Sietse Brouwer sbbrou...@gmail.com wrote: Hi Peter, I recommend using the following handy little idiom: \ctxlua{commands.doifelse(-45 0)}{big}{small} % small It lets you do all sorts of things that are tricky in TeX: \ctxlua{ commands.doifelse( string.len( -45 ) 5 ) }{long}{short} Cheers, Sietse ___ 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 ___ ___ 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] test for (negative) number
On 21-8-2012 17:13, Procházka Lukáš wrote: I also found another solution reposter before: \ctxlua{commands.testcase(condition)} { If true...} {If false} yes, but testcase is an unfortunate name and sort of obsolete (so best use doifelse) - 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] test for (negative) number
Hi Peter, I recommend using the following handy little idiom: \ctxlua{commands.doifelse(-45 0)}{big}{small} % small It lets you do all sorts of things that are tricky in TeX: \ctxlua{ commands.doifelse( string.len( -45 ) 5 ) }{long}{short} Cheers, Sietse ___ 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] Throwing an error on missing image with \externalfigure
On 17-8-2012 12:18, Peter Münster wrote: On Fri, Aug 17 2012, Tobias Mueller wrote: And I wouldn't want to embarras myself by having a document missing images. So a failure in the build process would help me a lot. Instead of calling context directly, you can make a script, that throws an error after grepping the log-file. or this: \externalfigure[rubish.pdf] \ifcase\figurestatus\relax \ctxlua{os.exit(999)} \fi - 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] \startcomponent, \startproduct... + automatic file name
On Thu, 09 Aug 2012 11:27:08 +0200, Hans Hagen pra...@wxs.nl wrote: in the current beta you can say \startcomponent * Hans Wikified at http://wiki.contextgarden.net/Command/startcomponent. This trick also works for startproject, startenvironment, and startproduct, I assume? And for the general case, what about `\ctxlua{commands.processedfile}`? That looks like it should print the current filename, as long as any inclusions use the ConTeXt commands and not \input. --Sietse On Thu, Aug 9, 2012 at 1:24 PM, Procházka Lukáš Ing. - Pontex s. r. o. l...@pontex.cz wrote: Great, thank you. Lukas On Thu, 09 Aug 2012 11:27:08 +0200, Hans Hagen pra...@wxs.nl wrote: in the current beta you can say \startcomponent * Hans -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 ___ 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 ___ ___ 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] \startcomponent, \startproduct... + automatic file name
Am 09.08.2012 um 15:08 schrieb Sietse Brouwer sbbrou...@gmail.com: On Thu, 09 Aug 2012 11:27:08 +0200, Hans Hagen pra...@wxs.nl wrote: in the current beta you can say \startcomponent * Hans Wikified at http://wiki.contextgarden.net/Command/startcomponent. This trick also works for startproject, startenvironment, and startproduct, I assume? And for the general case, what about `\ctxlua{commands.processedfile}`? That looks like it should print the current filename, as long as any inclusions use the ConTeXt commands and not \input. You can use \currentcomponent, \currentproduct and \currentproject to print the name of the file. 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] Strange bug with \ in footnotes
On 4-8-2012 20:59, Aditya Mahajan wrote: Hi Aditya, I usually use \ after abbreviations to avoid bad interword spaces. For example, Prof.\ ABC. However, when using this in footnotes, if there is a linebreak after the \, I get an error: ! Undefined control sequence. 1 \starttext 2 Someone\footnote{Prof.\ 3 ABC} 4 \stoptext 5 Ok, the next is only for those who want to spend some time on the internals ... \starttext \def\TestA#1% {\writestatus{Test A}{#1}% \ctxlua{str = #1 print(str) context(str) io.savedata(temp.tmp,str)}} \def\TestB#1% {\writestatus{Test B}{#1}% \ctxlua{str = \detokenize{#1} print(str) context(str) io.savedata(temp.tmp,str)}} \def\TestC#1% {\writestatus{Test C}{#1}% \edef\temp{#1}% \ctxlua{str = \detokenize\expandafter{\temp} print(str) context(str) io.savedata(temp.tmp,str)}% \typefile{temp.tmp}} \TestA{Test\ A} \TestB{Test\ B} \TestC{Test\ C} Test\ D \section{Test\ E} Test F\footnote{Note\ F} \stoptext I patched the helpers.title macro to deal with it but it's still something to look into as one might wonder why the newline end up there (Taco might know). (The 'context' function takes care of newlines so this is why it don't get noticed in other cases. Here a more low level sprint (catcodeid, str) was used. 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] Struggling with ConTeXt
On 02/08/2012 17:43, Aditya Mahajan wrote: On Thu, 2 Aug 2012, Olivier Binda wrote: 1) does lxml.att(#1,some tag) really work ? I don't know, but please provide a complete minimal example. \startxmlsetups xml:test \xmlsetsetup{maths}{c}{xml:*} \stopxmlsetups \xmlregistersetup{xml:test} \startxmlsetups xml:c \ctxlua{ title = test=..lxml.att(#1,title) context(title)}% \stopxmlsetups \starttext test : \xmlprocessdata {maths}{?xml version='1.0' standalone='yes?c title=My title/c} {} \stoptext \endinput Context gives the can't concatenate with a nil value Luatex error when processing this snipet...but if I ignore the error, the pdf output is okey ___ 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] Struggling with ConTeXt
On 3-8-2012 08:35, Olivier Binda wrote: On 02/08/2012 17:43, Aditya Mahajan wrote: On Thu, 2 Aug 2012, Olivier Binda wrote: 1) does lxml.att(#1,some tag) really work ? I don't know, but please provide a complete minimal example. \startxmlsetups xml:test \xmlsetsetup{maths}{c}{xml:*} \stopxmlsetups \xmlregistersetup{xml:test} \startxmlsetups xml:c \ctxlua{ title = test=..lxml.att(#1,title) context(title)}% \stopxmlsetups \starttext test : \xmlprocessdata {maths}{?xml version='1.0' standalone='yes?c title=My title/c} {} \stoptext \endinput Context gives the can't concatenate with a nil value Luatex error when processing this snipet...but if I ignore the error, the pdf output is okey the functions in the lxml namespace already print to context and return no value so you effectively appends nil which is invalid also, when used in a context run the default serializer is also piping to context so if you want otherwise you need to prefix with xml:// (which is an indication that in principle there can be many variants) here are some valid solutions (whatch the lxml.id): \startxmlsetups xml:test \xmlsetsetup{#1}{c}{xml:*} \stopxmlsetups \xmlregistersetup{xml:test} \startxmlsetups xml:c \ctxlua{title = test= .. xml.filter(lxml.id(#1),xml://./attribute(title)) context(title)} \par \ctxlua{context(test=) xml.filter(lxml.id(#1),./attribute(title))} \par \ctxlua{context(test=) lxml.att(#1,title)} \stopxmlsetups \starttext \xmlprocessdata {maths} {?xml version='1.0' standalone='yes?c title=My title/c} {} \stoptext You can wikify this ... 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 ___
[NTG-context] Struggling with ConTeXt
Hello I'm trying to port a big 300+ pages math course full of macros from plain XeTEX to ConTeXt mark IV (ubuntu 12.04+ stand alone beta) and I'm having some difficulties, could you please help ? My questions : 1) does lxml.att(#1,some tag) really work ? the next snipet doesn't work for me: \startluacode function set(node) p = lxml.att(node,p) -- or p = lxml.att(lxml.id(node),p) end \stopluacode \startxmlsetups xml:section \ctxlua{set(#1)} \stopxmlsetups it looks like it returns the p attribute of the node before #1 the following snipet works though (which is strange because I looked in the context source and it gives \def\xmlatt#1#2{\ctxlua{lxml.att(#1,#2)}}...) \startxmlsetups xml:section \ctxlua{p = \xmlatt{#1,p}} \stopxmlsetups 2) I'm trying to export to xml and have set \setupbackend[export=yes, xhtml=yes, css=mkiv-export.css] But a) my Metafun/Tikz pictures aren't exported to svg :/ b) the exported xml has namespaces problems (like error on line 63 at column 20: Namespace prefix m on math is not defined error on line 64 at column 22: Namespace prefix m on mrow is not defined) What am I doing wrong ? (I'm compiling with context mydoc.tex) Is there some \csname tex4ht\endcsname command or some other directive that I should use to get my xml export right ? Am I missing some namespace commands (there are lots of m:math and m:mrow mathml tags int the exported xml source, this smells like a tex4ht issue) 3) I have defined some framed text with metafun overlays (like in the Context manual) and I'm trying to type something like \inmargin{some label} \startMyFramedText...\stopMyFramedText Yet, the text in the margin is after the framed text :( (fiddling with the location setting (low, ..) doesn't allow me to have the in margin text right next the top of the framed text I somehow found a dirty workaround with typing a blank space \defineframedtext[Property][frame=off,background=OverlayProperty,before={}] and \inmargin{some label}\noindent\startMyFramedText...\stopMyFramedText but it's not really satisfying. (hate to lose vertical space with wandering blank spaces) Is there a better way ? 4) I'm trying to port the following TeX code to ConTeXt $$\eqalign{x=1\cr y=2\cr}\qquad \hbox{haha}$$ it looks like \startformula\startalign.. doesn't allow me to do that I somehow managed to have it by typing \startformula \vcenter{\starttabular[|rM|lM|] \NC x \NC =1\NC\NR \NC y \NC =2\NC\NR \stoptabular}\qquad\text{haha} \stopformula the pdf export is fine, but the xml export is awfull (because of \vcenter I guess) a) Is there a way to use tables inside math mode alongside other stuff (would be handy) ? b) what is the correct way to type the previous text, so the pdf and xml are fine in Context ? Best regards Olivier... really enjoying utf, xml, lua inside TeX as well as other nice ConTeXt features ___ 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] t-degrade.tex (solved)
Now I can downsample jpeg-files on the fly, see attached example file. But I need 2 patches: 1.) To get the width and the height into the name of the file, because when the figure dimensions change, there must be a new conversion: --8---cut here---start-8--- --- grph-inc.lua~ 2012-06-05 10:37:01.0 +0200 +++ grph-inc.lua2012-07-31 22:40:39.214426838 +0200 @@ -528,6 +528,9 @@ if resolution and resolution ~= then -- the order might change newbase = newbase .. _ .. resolution end +local width = figures.current().request.width +local height = figures.current().request.height +newbase = newbase .. _ .. width .. _ .. height -- -- see *, we had: -- --8---cut here---end---8--- 2.) To avoid crap in the width and height options: --8---cut here---start-8--- --- grph-inc.mkiv~ 2012-07-20 23:26:52.0 +0200 +++ grph-inc.mkiv 2012-08-01 00:02:23.851094854 +0200 @@ -293,6 +293,10 @@ % \the\t_grph_include_local_settings \dostarttagged\t!image\empty + \edef\current_width{\externalfigureparameter\c!width}% + \edef\current_height{\externalfigureparameter\c!height}% + \def\nocrap##1{\doifnotemptyvalue{##1}{% + \the\dimexpr\csname##1\endcsname\relax}}% \ctxlua{figures.push { name = \p_grph_include_name, label = \p_grph_include_label, @@ -312,8 +316,8 @@ resolution = \externalfigureparameter\c!resolution, color = \internalspotcolorparent{\externalfigureparameter\c!color}, % hack is needed [repeat] = \externalfigureparameter\c!repeat, -width = \externalfigureparameter\c!width, % can be crap -height = \externalfigureparameter\c!height, % can be crap +width = \nocrap{current_width}, % no more crap +height = \nocrap{current_height}, % no more crap } }% \ctxlua{figures.identify()}% % also mode: checkpresense only --8---cut here---end---8--- Hans, could you please patch the files? Cheers, -- Peter \startluacode local format = string.format -- figures.cachepaths.path = cache -- should be setup-option local function sample_down(oldname, newname, resolution) local request = figures.current().request local width = request.width:sub(1, -3) local height = request.height:sub(1, -3) if resolution == or (width == and height == ) then print(format(Nothing to do: %s, %s, %s, oldname, newname, resolution)) return end local inch = 72.27 local image = img.scan{filename = oldname} local xy = image.xsize / image.ysize if width == then width = height * xy end if height == then height = width / xy end local xsize = resolution * width / inch local ysize = resolution * height / inch if xsize image.xsize or ysize image.ysize then local s = format(gm convert -resize %dx%d %s %s, xsize, ysize, oldname, newname) print(Conversion: .. s) os.execute(s) else print(format(Nothing to do: %s, %s, %s, oldname, newname, resolution)) print(format(xsize = %d, ysize = %d, xsize, ysize)) end end figures.converters.jpg = figures.converters.jpg or {} figures.converters.jpg[lowres.jpg] = sample_down \stopluacode \starttext \setupexternalfigures[resolution=50, conversion=lowres.jpg] \externalfigure[hacker][width=0.5\textwidth] \setupexternalfigures[resolution=10] \externalfigure[hacker][width=0.5\textwidth] \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] Broken Nightly?
On 26-6-2012 06:36, Kip Warner wrote: On Tue, 2012-06-26 at 05:27 +0200, Wolfgang Schuster wrote: grph-epd.mkiv (untested): \startsetups system:graphics:epdf %\ctxlua{figures.mergegoodies(\@@efinteraction)}% \ctxlua{figures.mergegoodies(\externalfiguresparameter\c!interaction)}% \reference[\figurereference]{}% todo: dest area \stopsetups and \appendtoks \iflocation %\doif\figurefiletype{pdf}{\doifnot\@@efinteraction\v!none\grph_epdf_add_overlay}% \doif\figurefiletype{pdf}{\doifnot{\externalfiguresparameter\c!interaction}\v!none\grph_epdf_add_overlay}% \fi \to \externalfigurepostprocessors Hey Wolfgang. Thanks for your expeditious reply. I patched grph-epd.mkiv as directed and got the following error on the same file / line (Handbook.tex:42), ! Undefined control sequence. argument \@@efinteraction fixed in next beta - 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] Broken Nightly?
Am 26.06.2012 um 01:59 schrieb Kip Warner: Hey list, I'm using ConTeXt 2012.06.25 and I noticed a broken compilation of my book: grph-epd.mkiv (untested): \startsetups system:graphics:epdf %\ctxlua{figures.mergegoodies(\@@efinteraction)}% \ctxlua{figures.mergegoodies(\externalfiguresparameter\c!interaction)}% \reference[\figurereference]{}% todo: dest area \stopsetups and \appendtoks \iflocation %\doif\figurefiletype{pdf}{\doifnot\@@efinteraction\v!none\grph_epdf_add_overlay}% \doif\figurefiletype{pdf}{\doifnot{\externalfiguresparameter\c!interaction}\v!none\grph_epdf_add_overlay}% \fi \to \externalfigurepostprocessors 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] Broken Nightly?
On Tue, 2012-06-26 at 05:27 +0200, Wolfgang Schuster wrote: grph-epd.mkiv (untested): \startsetups system:graphics:epdf %\ctxlua{figures.mergegoodies(\@@efinteraction)}% \ctxlua{figures.mergegoodies(\externalfiguresparameter\c!interaction)}% \reference[\figurereference]{}% todo: dest area \stopsetups and \appendtoks \iflocation %\doif\figurefiletype{pdf}{\doifnot\@@efinteraction\v!none\grph_epdf_add_overlay}% \doif\figurefiletype{pdf}{\doifnot{\externalfiguresparameter\c!interaction}\v!none\grph_epdf_add_overlay}% \fi \to \externalfigurepostprocessors Hey Wolfgang. Thanks for your expeditious reply. I patched grph-epd.mkiv as directed and got the following error on the same file / line (Handbook.tex:42), ! Undefined control sequence. argument \@@efinteraction \doifnot #1#2-\edef \m_syst_string_one {#1 }\edef \m_syst_string_two {#2}\if... argument \doifnot \@@efinteraction \v!none \grph_epdf_add_overlay \firstofoneargument #1-#1 inserted text ...v!none \grph_epdf_add_overlay } \fi \grph_include_finalize ...nalfigurepostprocessors \edef \p_reset {\externalf... ... l.42 ...eativecommons.org/licenses/by-nc-sa/3.0/)] ? E You want to edit file Handbook.tex at line 42 -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com signature.asc Description: This is a digitally signed message part ___ 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] Testing the changing dimensions of boxes (in cycles) via Lua
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 ___
Re: [NTG-context] Testing the changing dimensions of boxes (in cycles) via Lua
Thanks very much to Luigi. Your solution really works. Can you please explain why you doing this? My point is that if I have the LUA code in a separate lua file (loaded with the Contex via \directlua{dofile(filename.lua)}) (for example as a separate Lua function), so I'm probably not so to do (how you did it in your example). Or perhaps in this case there is any way? Thanks Jaroslav Dne 15.6.2012 9:41, luigi scarso napsal(a): \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/216)..pt\\par) context(i..[[ width of box:]]..widthbox..pt : ..(tex.box[0].width/216)..pt\\par) context([[\box0\par]]) --[=[ end ]=] } } \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 ___
[NTG-context] Testing the changing dimensions of boxes (in cycles) via Lua
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 ___ 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] feature request for \getspr{}
On Fri, Jun 08 2012, Hans Hagen wrote: I've added moduledata.spreadsheets.settings.numberseparator but you have to test it after the next upload. Tested. Thanks! Just a minor comment: \setupspreadsheet[numberseparator=,] would be nicer than \ctxlua{moduledata.spreadsheets.settings.numberseparator = ,} -- Peter ___ 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] feature request for \getspr{}
On 8-6-2012 12:21, Peter Münster wrote: On Fri, Jun 08 2012, Hans Hagen wrote: I've added moduledata.spreadsheets.settings.numberseparator but you have to test it after the next upload. Tested. Thanks! Just a minor comment: \setupspreadsheet[numberseparator=,] would be nicer than \ctxlua{moduledata.spreadsheets.settings.numberseparator = ,} next beta \setupspreadsheet [test] [period={{\bf\middlered .}}, comma={{\bf\middlegreen ,}}, split=yes] \startspreadsheettable[test] \startrow \startcell 123456.78 \stopcell \startcell 1234567.89 \stopcell \startcell A[1] + B[1] \stopcell \stoprow \stopspreadsheettable - 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] indexing puzzle
Michael— Thank you so much for your very helpful response. 1. \unskip works well. 2. What I currently have is admittedly an ad hoc system for encoding my indices. As you note, the system works for page numbers 99 where line numbers 99. When line numbers 99, I adapt the sort key differently: thus, for Cleomedes, *Cael*. I have [CleomCael105001] for 1.5.1. This works (in MKII) but only because the number of entries is very small. 3. I like your MKII solution—it is much more general, works well on what I have, and is certainly less taxing to encode. Many thanks! The book that I trying to index right now is the last of my MKII projects. So I am also interested in, and very grateful, for your MKIV solution. All best, Alan On Thu, May 24, 2012 at 5:14 PM, Rogers, Michael K mrog...@emory.eduwrote: 1. For \ab you might want \def\ab{\unskip} since the space is not the same as the width of a digit. 2. Does your solution work with line numbers greater than 99? I tried to implement your idea and I got the order 25.7, 25.117, 25.37. Probably more than 99 lines never occurs on a page, so it's a non-issue. But Homer, for instance, is often referred to by Book.Line, and the lines go past 100. Again, perhaps a non-issue for you. 3. My own attempts: At first I though what a nice opportunity for me to learn a little more Lua, which it was. After, I read you wanted a MKII solution. Well, I'm embarrassed at how long I took to do the MKII, but I'm not good at controlling expansion. Anyway, it automatically generates sort keys for the pages by converting digits to letters and padding with initial a's, so that each page or line number is a fixed length (4 in this case, up to 1 pages/lines). For instance, 123.4--56 is mapped to abcdaaaeaafg MKII does not seem to sort digit-based keys reliably; MKIV does, and you can just pad out the digits with zeros. The complete sort key that worked was the catenation of the author, text, and locus key, which is similar to what you have. MKII: \defineregister[Passage][Passages] ... % interface to register -- \locuskey indirectly returns a key in \nextkey \def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}} \def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}} % Def. of \locuskey#1 %In: #1-p1[.l2[--l3]] Out: key stored in \nextkey ... (see attached file, if interested) MKIV: % interface to register -- expansion in MKIV must be different, because a direct approach works: \def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}} % Def. of \locuskey \startluacode userdata = userdata or { } function userdata.locuskey(x) context(string.gsub(x,(%d+),function (s) return string.format(%04d,tonumber(s)) end)) end \stopluacode \def\locuskey#1{\ctxlua{userdata.locuskey(#1)}} The Mark IV/Luatex one was much nicer, less frustrating to figure out. On May 24, 2012, at 7:06 AM, Alan Bowen wrote: For anyone interested in producing classical indices locorum, I have devised a way that seems to work, although it is not that elegant. The first step is to modify the sort keys by counting the number of digits in the page number: thus, [AuthorText01] for pages 1–9, [AuthorText02] for pages 10–99, and so on The next is to insert the command “ \ab” (note the space) when the line number is a single digit: thus 391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line} For \ab, I have: \newdimen\digitwidth \setbox0=\hbox{\tfx\char32} \digitwidth=\wd0 \def\ab{\tfx\kern-\digitwidth} The hitch here is that the font size is not context dependent. Alan On Tue, May 22, 2012 at 6:39 PM, Alan Bowen bowenala...@gmail.com wrote: I have been trying to index the passages cited in a book and would be grateful for some tactical advice. There are several works by a single author, and it is customary to cite each text by page and line number, as in 1253.12 (page 1253, line12), for example. I have a sort key for each work. But now I need a way to get the entry 1253.7 (page 1253, line 7) before the entry 1253.12 (page 1253, line 12). \[Passage[AuthorText]{Author+Text+1253.07}1253.7 or \[Passage[AuthorText]{Author+Text+1253.07}1253. 7 would work, but it is really better to have the index entry as “1253.7” rather than as “1253.07” or “1253. 7” I have experimented with different sort keys—e.g., AuthorText125307—and can generate an index with the 1235.7 and so on in the proper place and form, say, before 1253.12. But then the problem is that I also get entire sequences of entries out of order (485.19, 485.21 before 477.31, and so on). Very puzzling. (Restoring the sort key AuthorText removes the latter problems but then leaves 1253.7 in the wrong place.) If anyone has experience with this or just some ideas for a solution, their suggestions will be most welcome. I am using the MKII in the latest ConTeXt
Re: [NTG-context] indexing puzzle
Thanks, Alan. Actually, I now think MKIV works without any trickery. I was perhaps too eager to try a Lua solution. \Passage{Author+Text+Locus} seems to work fine in the beta today. Cheers, Michael On May 26, 2012, at 8:41 AM, Alan Bowen wrote: Michael— Thank you so much for your very helpful response. 1. \unskip works well. 2. What I currently have is admittedly an ad hoc system for encoding my indices. As you note, the system works for page numbers 99 where line numbers 99. When line numbers 99, I adapt the sort key differently: thus, for Cleomedes, Cael. I have [CleomCael105001] for 1.5.1. This works (in MKII) but only because the number of entries is very small. 3. I like your MKII solution—it is much more general, works well on what I have, and is certainly less taxing to encode. Many thanks! The book that I trying to index right now is the last of my MKII projects. So I am also interested in, and very grateful, for your MKIV solution. All best, Alan On Thu, May 24, 2012 at 5:14 PM, Rogers, Michael K mrog...@emory.edumailto:mrog...@emory.edu wrote: 1. For \ab you might want \def\ab{\unskip} since the space is not the same as the width of a digit. 2. Does your solution work with line numbers greater than 99? I tried to implement your idea and I got the order 25.7, 25.117, 25.37. Probably more than 99 lines never occurs on a page, so it's a non-issue. But Homer, for instance, is often referred to by Book.Line, and the lines go past 100. Again, perhaps a non-issue for you. 3. My own attempts: At first I though what a nice opportunity for me to learn a little more Lua, which it was. After, I read you wanted a MKII solution. Well, I'm embarrassed at how long I took to do the MKII, but I'm not good at controlling expansion. Anyway, it automatically generates sort keys for the pages by converting digits to letters and padding with initial a's, so that each page or line number is a fixed length (4 in this case, up to 1 pages/lines). For instance, 123.4--56 is mapped to abcdaaaeaafg MKII does not seem to sort digit-based keys reliably; MKIV does, and you can just pad out the digits with zeros. The complete sort key that worked was the catenation of the author, text, and locus key, which is similar to what you have. MKII: \defineregister[Passage][Passages] ... % interface to register -- \locuskey indirectly returns a key in \nextkey \def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}} \def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}} % Def. of \locuskey#1 %In: #1-p1[.l2[--l3]] Out: key stored in \nextkey ... (see attached file, if interested) MKIV: % interface to register -- expansion in MKIV must be different, because a direct approach works: \def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}} % Def. of \locuskey \startluacode userdata = userdata or { } function userdata.locuskey(x) context(string.gsub(x,(%d+),function (s) return string.format(%04d,tonumber(s)) end)) end \stopluacode \def\locuskey#1{\ctxlua{userdata.locuskey(#1)}} The Mark IV/Luatex one was much nicer, less frustrating to figure out. On May 24, 2012, at 7:06 AM, Alan Bowen wrote: For anyone interested in producing classical indices locorum, I have devised a way that seems to work, although it is not that elegant. The first step is to modify the sort keys by counting the number of digits in the page number: thus, [AuthorText01] for pages 1–9, [AuthorText02] for pages 10–99, and so on The next is to insert the command “ \ab” (note the space) when the line number is a single digit: thus 391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line} For \ab, I have: \newdimen\digitwidth \setbox0=\hbox{\tfx\char32} \digitwidth=\wd0 \def\ab{\tfx\kern-\digitwidth} The hitch here is that the font size is not context dependent. Alan On Tue, May 22, 2012 at 6:39 PM, Alan Bowen bowenala...@gmail.commailto:bowenala...@gmail.com wrote: I have been trying to index the passages cited in a book and would be grateful for some tactical advice. There are several works by a single author, and it is customary to cite each text by page and line number, as in 1253.12 (page 1253, line12), for example. I have a sort key for each work. But now I need a way to get the entry 1253.7 (page 1253, line 7) before the entry 1253.12 (page 1253, line 12). \[Passage[AuthorText]{Author+Text+1253.07}1253.7 or \[Passage[AuthorText]{Author+Text+1253.07}1253. 7 would work, but it is really better to have the index entry as “1253.7” rather than as “1253.07” or “1253. 7” I have experimented with different sort keys—e.g., AuthorText125307—and can generate an index with the 1235.7 and so on in the proper place and form, say, before 1253.12. But then the problem is that I also get entire sequences of entries out of order (485.19, 485.21 before 477.31, and so on). Very puzzling. (Restoring the sort key AuthorText
Re: [NTG-context] indexing puzzle
It does indeed! Excellent! A. On Sat, May 26, 2012 at 9:21 AM, Rogers, Michael K mrog...@emory.eduwrote: Thanks, Alan. Actually, I now think MKIV works without any trickery. I was perhaps too eager to try a Lua solution. \Passage{Author+Text+Locus} seems to work fine in the beta today. Cheers, Michael On May 26, 2012, at 8:41 AM, Alan Bowen wrote: Michael— Thank you so much for your very helpful response. 1. \unskip works well. 2. What I currently have is admittedly an ad hoc system for encoding my indices. As you note, the system works for page numbers 99 where line numbers 99. When line numbers 99, I adapt the sort key differently: thus, for Cleomedes, *Cael*. I have [CleomCael105001] for 1.5.1. This works (in MKII) but only because the number of entries is very small. 3. I like your MKII solution—it is much more general, works well on what I have, and is certainly less taxing to encode. Many thanks! The book that I trying to index right now is the last of my MKII projects. So I am also interested in, and very grateful, for your MKIV solution. All best, Alan On Thu, May 24, 2012 at 5:14 PM, Rogers, Michael K mrog...@emory.eduwrote: 1. For \ab you might want \def\ab{\unskip} since the space is not the same as the width of a digit. 2. Does your solution work with line numbers greater than 99? I tried to implement your idea and I got the order 25.7, 25.117, 25.37. Probably more than 99 lines never occurs on a page, so it's a non-issue. But Homer, for instance, is often referred to by Book.Line, and the lines go past 100. Again, perhaps a non-issue for you. 3. My own attempts: At first I though what a nice opportunity for me to learn a little more Lua, which it was. After, I read you wanted a MKII solution. Well, I'm embarrassed at how long I took to do the MKII, but I'm not good at controlling expansion. Anyway, it automatically generates sort keys for the pages by converting digits to letters and padding with initial a's, so that each page or line number is a fixed length (4 in this case, up to 1 pages/lines). For instance, 123.4--56 is mapped to abcdaaaeaafg MKII does not seem to sort digit-based keys reliably; MKIV does, and you can just pad out the digits with zeros. The complete sort key that worked was the catenation of the author, text, and locus key, which is similar to what you have. MKII: \defineregister[Passage][Passages] ... % interface to register -- \locuskey indirectly returns a key in \nextkey \def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}} \def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}} % Def. of \locuskey#1 %In: #1-p1[.l2[--l3]] Out: key stored in \nextkey ... (see attached file, if interested) MKIV: % interface to register -- expansion in MKIV must be different, because a direct approach works: \def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}} % Def. of \locuskey \startluacode userdata = userdata or { } function userdata.locuskey(x) context(string.gsub(x,(%d+),function (s) return string.format(%04d,tonumber(s)) end)) end \stopluacode \def\locuskey#1{\ctxlua{userdata.locuskey(#1)}} The Mark IV/Luatex one was much nicer, less frustrating to figure out. On May 24, 2012, at 7:06 AM, Alan Bowen wrote: For anyone interested in producing classical indices locorum, I have devised a way that seems to work, although it is not that elegant. The first step is to modify the sort keys by counting the number of digits in the page number: thus, [AuthorText01] for pages 1–9, [AuthorText02] for pages 10–99, and so on The next is to insert the command “ \ab” (note the space) when the line number is a single digit: thus 391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line} For \ab, I have: \newdimen\digitwidth \setbox0=\hbox{\tfx\char32} \digitwidth=\wd0 \def\ab{\tfx\kern-\digitwidth} The hitch here is that the font size is not context dependent. Alan On Tue, May 22, 2012 at 6:39 PM, Alan Bowen bowenala...@gmail.comwrote: I have been trying to index the passages cited in a book and would be grateful for some tactical advice. There are several works by a single author, and it is customary to cite each text by page and line number, as in 1253.12 (page 1253, line12), for example. I have a sort key for each work. But now I need a way to get the entry 1253.7 (page 1253, line 7) before the entry 1253.12 (page 1253, line 12). \[Passage[AuthorText]{Author+Text+1253.07}1253.7 or \[Passage[AuthorText]{Author+Text+1253.07}1253. 7 would work, but it is really better to have the index entry as “1253.7” rather than as “1253.07” or “1253. 7” I have experimented with different sort keys—e.g., AuthorText125307—and can generate an index with the 1235.7 and so on in the proper place and form, say, before 1253.12. But then the problem
Re: [NTG-context] Use figures without file extension
I don't know if this helps but the following tells what the type of the image file is. (In my case I copied a jpg to img1 and a png to img2, without extensions of course.) \startluacode userdata = userdata or { } function userdata.mytype(s) context(img.scan({filename=s}).imagetype) end \stopluacode \starttext img1 is \ctxlua{userdata.mytype(img1)}\par img2 is \ctxlua{userdata.mytype(img2)} \stoptext Michael This e-mail message (including any attachments) is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message (including any attachments) is strictly prohibited. If you have received this message in error, please contact the sender by reply e-mail message and destroy all copies of the original message (including attachments). ___ 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] indexing puzzle
1. For \ab you might want \def\ab{\unskip} since the space is not the same as the width of a digit. 2. Does your solution work with line numbers greater than 99? I tried to implement your idea and I got the order 25.7, 25.117, 25.37. Probably more than 99 lines never occurs on a page, so it's a non-issue. But Homer, for instance, is often referred to by Book.Line, and the lines go past 100. Again, perhaps a non-issue for you. 3. My own attempts: At first I though what a nice opportunity for me to learn a little more Lua, which it was. After, I read you wanted a MKII solution. Well, I'm embarrassed at how long I took to do the MKII, but I'm not good at controlling expansion. Anyway, it automatically generates sort keys for the pages by converting digits to letters and padding with initial a's, so that each page or line number is a fixed length (4 in this case, up to 1 pages/lines). For instance, 123.4--56 is mapped to abcdaaaeaafg MKII does not seem to sort digit-based keys reliably; MKIV does, and you can just pad out the digits with zeros. The complete sort key that worked was the catenation of the author, text, and locus key, which is similar to what you have. MKII: \defineregister[Passage][Passages] ... % interface to register -- \locuskey indirectly returns a key in \nextkey \def\MyPassage#1#2#3{\locuskey{#3}\expandoneargafter\doMyPassage{\nextkey}{#1}{#2}{#3}} \def\doMyPassage#1#2#3#4{\Passage[#2#3#1]{{#2}+{#3}+{#4}}} % Def. of \locuskey#1 %In: #1-p1[.l2[--l3]] Out: key stored in \nextkey ... (see attached file, if interested) MKIV: % interface to register -- expansion in MKIV must be different, because a direct approach works: \def\MyPassage#1#2#3{\Passage[#1#2\locuskey{#3}]{#1+#2+#3}} % Def. of \locuskey \startluacode userdata = userdata or { } function userdata.locuskey(x) context(string.gsub(x,(%d+),function (s) return string.format(%04d,tonumber(s)) end)) end \stopluacode \def\locuskey#1{\ctxlua{userdata.locuskey(#1)}} The Mark IV/Luatex one was much nicer, less frustrating to figure out. On May 24, 2012, at 7:06 AM, Alan Bowen wrote: For anyone interested in producing classical indices locorum, I have devised a way that seems to work, although it is not that elegant. The first step is to modify the sort keys by counting the number of digits in the page number: thus, [AuthorText01] for pages 1–9, [AuthorText02] for pages 10–99, and so on The next is to insert the command “ \ab” (note the space) when the line number is a single digit: thus 391. \ab{}2 but 391.12 in the entry specification {Author+Text+page.line} For \ab, I have: \newdimen\digitwidth \setbox0=\hbox{\tfx\char32} \digitwidth=\wd0 \def\ab{\tfx\kern-\digitwidth} The hitch here is that the font size is not context dependent. Alan On Tue, May 22, 2012 at 6:39 PM, Alan Bowen bowenala...@gmail.commailto:bowenala...@gmail.com wrote: I have been trying to index the passages cited in a book and would be grateful for some tactical advice. There are several works by a single author, and it is customary to cite each text by page and line number, as in 1253.12 (page 1253, line12), for example. I have a sort key for each work. But now I need a way to get the entry 1253.7 (page 1253, line 7) before the entry 1253.12 (page 1253, line 12). \[Passage[AuthorText]{Author+Text+1253.07}1253.7 or \[Passage[AuthorText]{Author+Text+1253.07}1253. 7 would work, but it is really better to have the index entry as “1253.7” rather than as “1253.07” or “1253. 7” I have experimented with different sort keys—e.g., AuthorText125307—and can generate an index with the 1235.7 and so on in the proper place and form, say, before 1253.12. But then the problem is that I also get entire sequences of entries out of order (485.19, 485.21 before 477.31, and so on). Very puzzling. (Restoring the sort key AuthorText removes the latter problems but then leaves 1253.7 in the wrong place.) If anyone has experience with this or just some ideas for a solution, their suggestions will be most welcome. I am using the MKII in the latest ConTeXt standalone. Alan This e-mail message (including any attachments) is for the sole use of the intended recipient(s) and may contain confidential and privileged information. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this message (including any attachments) is strictly prohibited. If you have received this message in error, please contact the sender by reply e-mail message and destroy all copies of the original message (including attachments). SortkeyMkII.tex Description: SortkeyMkII.tex ___ 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
Re: [NTG-context] Problem calling system
... Finally, I use the following to avoid ' in arguments and to keep to os.execute(): \bgroup \catcode`\%=11 \ctxlua{os.execute(([[echo lua -e print 'EXECUTE']]):gsub('(.-)', [[%1]]))} \egroup % Or: \startluacode os.execute(([[echo lua -e print 'EXECUTE']]):gsub('(.-)', [[%1]])) \stopluacode \starttext A \stoptext None of both solutions are pure as I'd imagine but they seem to work. Best regards, Lukas -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 ___ 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] Problem calling system
Hello, I slightly modified the example - my code now is: \ctxlua{os.execute([[echo lua -e print 'WWW']])} \starttext A \stoptext So now I'm able to diagnose what exactly is passed to the command line. I'm getting: ... languageslanguage en is active lua -e print WWW {c:/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map} ... So it can be seen that [surprisingly] character ' was substituted for - and IMHO this causes the problem. Could anyone explain why this substitution is performed and how to avoid it? Best regards, Lukas -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 t1.mkiv Description: Binary data ___ 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] Problem calling system
On 15-5-2012 09:05, Procházka Lukáš Ing. - Pontex s. r. o. wrote: Hello, I slightly modified the example - my code now is: \ctxlua{os.execute([[echo lua -e print 'WWW']])} \starttext A \stoptext So now I'm able to diagnose what exactly is passed to the command line. I'm getting: languages language en is active lua -e print WWW {c:/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map} So it can be seen that [surprisingly] character ' was substituted for - and IMHO this causes the problem. Could anyone explain why this substitution is performed and how to avoid it? probably some os.execute parsing ... does os.exec or os.spawn work ok? - 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] Problem calling system
probably some os.execute parsing ... Do you mean Lua itself does the parsing and substitution? I guessed [lua]tex core... When I try to call on the command line: C:\Lukas\ConTeXt\TestDDvlua Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio os.execute([[lua -e print 'WWW']]) WWW os.execute([[echo lua -e print 'WWW']]) lua -e print 'WWW' =os.exec nil =os.spawn nil - There is no '/ substitution in standalone Lua (?!). does os.exec or os.spawn work ok? Well, the 'os.exec' works, in condition that it is called with cmd /c: \ctxlua{os.execute([[echo lua -e print 'EXECUTE']])} \ctxlua{os.exec([[cmd.exe /c echo lua -e print 'EXEC']])} \ctxlua{os.spawn([[cmd.exe /c echo lua -e print 'SPAWN']])} \starttext A \stoptext Gives: ... languageslanguage en is active lua -e print EXECUTE lua -e print 'EXEC' system | total runtime: 0.609 Interesting that the string to be passed to 'os.exec' keeps ' whilst that to 'os.execute' doesn't. Why this happens? Anyhow, thanks for the idea with 'os.exec'. Best regards, Lukas -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 ___ 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] Problem calling system
On 14-5-2012 10:56, Procházka Lukáš Ing. - Pontex s. r. o. wrote: Hello, I'd need to call the OS, namely lua in it. I have the following code: \write18{lua -e require 'lfs'} \write18{lua -e require'lfs'} \starttext A \stoptext When calling directly from the command line lua -e require 'lfs' - there is no error. From within the Context code, I'm getting (see CmdLine.log): lua.exe: (command line):1: '=' expected near 'lfs' lua.exe: (command line):1: '=' expected near 'eof'... What could be the problem? My OS is WinXP 32b. And how about \ctxlua{os.execute(lua -e require 'lfs')} btw, if you run texlua you get lfs for free. 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] Problem calling system
\ctxlua{os.execute(lua -e require 'lfs')} ... Gives: ... fontslatin modern fonts are not preloaded languageslanguage en is active ! LuaTeX error main ctx instance:1: attempt to call global 'e' (a nil value) stack traceback: main ctx instance:1: in main chunk. system tex error on line 4 in file C:/Lukas/ConTeXt/TestDDv/t1.mkiv: LuaTeX error ... 1 %\write18{lua -e require 'lfs'} 2 % 3 4 \ctxlua{os.execute(lua -e require 'lfs')} 5 %\ctxlua{os.execute([[lua -e require 'lfs']])} 6 7 \starttext 8 A 9 \stoptext 10 l.4 \ctxlua{os.execute(lua -e require 'lfs')} ... If I try: \ctxlua{os.execute([[lua -e require 'lfs']])} I get error: ... languageslanguage en is active lua: (command line):1: '=' expected near 'lfs' {c:/ConTeXt/tex/texmf-context/fonts/map/pdftex/context/mkiv-base.map} ... (Like if ' were gobbled...) btw, if you run texlua you get lfs for free. OK, this is just a sample. I need to use another file, in fact. Lukas -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 t1.mkiv Description: Binary data ___ 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] Problem calling system
On 14-5-2012 12:23, Procházka Lukáš Ing. - Pontex s. r. o. wrote: \ctxlua{os.execute(lua -e require 'lfs')} \ctxlua{os.execute([[lua -e require 'lfs']])} - 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 ___
[NTG-context] Split \startalign content on more pages
\sbc{} is a command defined by me. \define[1]\sbc{\ctxlua{context(\%.2f, #1)}}% I'm writing a technical report and I use that command to substitute numbers to letters in formulas. ___ 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] Split \startalign content on more pages
On Sun, May 13, 2012 at 3:54 PM, elgo...@libero.it elgo...@libero.it wrote: \sbc{} is a command defined by me. \define[1]\sbc{\ctxlua{context(\%.2f, #1)}}% I'm writing a technical report and I use that command to substitute numbers to letters in formulas. ok, I'm using \def\sbc#1{#1} \let\sbd\sbc \let\sba\sbc but I've an error --- X is undefined . -- 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] Split \startalign content on more pages
On Sun, 13 May 2012, elgo...@libero.it wrote: \sbc{} is a command defined by me. \define[1]\sbc{\ctxlua{context(\%.2f, #1)}}% I'm writing a technical report and I use that command to substitute numbers to letters in formulas. Please create a complete working minimal example. 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 ___
[NTG-context] Split \startalign content on more pages
Sorry for having given you a non working example! Here you can find a working one. The comments at the end of each line are in italian. Changing the height of the frame you can move the \startalign content in the page. As you will see, the whole content flows from one page to the following, without splitting at the right line. Thank you very much for your help. %INIZIO PREAMBOLO \setuppapersize[A4, portrait] [A4]% layout di pagina su foglio A4 \setuplayout[width=middle]% disposizione del testo sulla pagina \setuppagenumbering[location={footer, middle}]% numero di pagina in basso al centro \setupbodyfont[11pt]% altezza carattere 11pt \setupcolors[state=start, rgb=yes]% per usare colori \setupcolor[rgb]% carico colori di default \setuptabulate[split=yes]% consente di spezzare le liste di tabualte su più pagine %\setupindenting[medium, yes]% indentazione prima linea di paragrafi \mainlanguage[it]% lingua principale del documento \usemodule[units]% per scrivere le unità di misura in maniera coerente sia in modalità testo che matematico %\usemodule[NTE]% per crare le tabelle complesse multipagina utilizzando l'ambiente TABLE % %--COMANDI DEFINITI DA UTENTE- % comando \sb \def\sb#1{\ctxlua{tex.print(#1)}}% definizione comando di sostituzione dei valori numerici a quelli letterali % comando \sba \def\sba#1{\ctxlua{tex.print(string.format(\%.0f, #1))}}% sostituisce numero a valori letterali scrivendolo senza cifre decimali % comando \sbb \define[1]\sbb{\ctxlua{context(\%.1f, #1)}}% sostituisce numero a valori letterali scrivendolo con 1 cifra decimale % comando \sbc \define[1]\sbc{\ctxlua{context(\%.2f, #1)}}% sostituisce numero a valori letterali scrivendolo con 2 cifre decimali % comando \sbd \define[1]\sbd{\ctxlua{context(\%.3f, #1)}}% sostituisce numero a valori letterali scrivendolo con 3 cifre decimali \definedescription[descr][style=packed,headstyle=bold,style=normal, location=hanging,width=broad,margin=1cm] %FINE PREAMBOLO \starttext Bla bla bla {\framed[height=15cm] Bla Bla} \startluacode e_yfi=5 R_fi=2000 r_fi=300 D_ifi=2500 P_dfi=0.6 f_dfi=200 e_dtryfi=1 -- spessore di tentativo in progetto in mm e_yfi=100 -- inizializzo il valore ey a 100 while math.abs(e_yfi-e_dtryfi)0.001 do e_dtryfi=e_yfi Y=math.min((e_dtryfi / R_fi), 0.04) Z=math.log10(1/Y) X=r_fi/D_ifi N=1.006-(1 / (6.2+(90*(Y^4 beta006=N*((-0.3635*(Z^3))+(2.2124*(Z^2))-(3.2937*Z)+1.8873) beta01=N*((-0.1833*(Z^3))+(1.0383*(Z^2))-(1.2943*Z)+0.837) beta02=math.max(0.95*(0.56-(1.94*Y)-(83.5*(Y^2))), 0.5) if X==0.06 then beta=beta006 elseif 0.06X and X0.1 then beta=25*(((0.1-X)*beta006)+((X-0.06)*beta01)) elseif X==0.1 then beta=beta01 elseif 0.1X and X0.2 then beta=10*(((0.2-X)*beta01)+((X-0.1)*beta02)) elseif X==0.2 then beta=beta02 else tex.print(\\red{ERRORE NELLA GEOMETRIA DEL FONDO INFERIORE}) end e_yfi=(beta*P_dfi*((0.75*R_fi)+(0.2*D_ifi)))/f_dfi end \stopluacode \setupformulas[align=right] \startformula \startalign[n=3, align={left, right, left}] \NC \text{dove} \quad \NC Y \NC = min \left({{e_{yfi}} \over {R_{fi}}}; 0.04 \right) = min \left({{\sbc{e_yfi}} \over {\sba{R_fi}}}; 0.04 \right)=\sbd{Y} \NR \NC \NC Z \NC = log_{10} \left({1 \over Y} \right) = log_{10} \left({1 \over \sbd{Y}} \right) = \sbc{Z} \NR \NC \NC X \NC = {{r_{fi}} \over {D_{ifi}}} = {{\sba{r_fi}} \over {\sba {D_ifi}}} = \sbd{X} \NR \NC \NC N \NC = 1.006 - {1 \over {6.2 + \left(90 \cdot Y \right)^4}} = 1.006 - {1 \over {6.2 + \left(90 \cdot \sbd{Y} \right)^4}} = \sbd{N} \NR \startluacode if X==0.06 then tex.print(\\NC \\NC \\beta_{0.06} \\NC = N \\cdot \\left(-0.3635 \\cdot Z^3 + 2.2124 \\cdot Z^2 - 3.2937 \\cdot Z + 1.8873 \\right) = \\NR) tex.print(\\NC \\NC \\NC = N \\cdot \\left(-0.3635 \\cdot \\sbc{Z}^3 + 2.2124 \\cdot \\sbc{Z}^2 - 3.2937 \\cdot \\sbc{Z} + 1.8873 \\right) = \\sbc {beta006} \\NR) tex.print(\\NC \\NC \\beta \\NC =\\beta_{0.06}=\\sbc{beta006} \\NR) elseif X0.06 and X0.1 then tex.print(\\NC \\NC \\beta_{0.06} \\NC = N \\cdot \\left(-0.3635 \\cdot Z^3 + 2.2124 \\cdot Z^2 - 3.2937 \\cdot Z + 1.8873 \\right) = \\NR) tex.print(\\NC \\NC \\NC = N \\cdot \\left(-0.3635 \\cdot \\sbc{Z}^3 + 2.2124 \\cdot \\sbc{Z}^2 - 3.2937 \\cdot \\sbc{Z} + 1.8873 \\right) = \\sbc {beta006} \\NR) tex.print(\\NC \\NC \\beta_{0.1} \\NC = N \\cdot \\left(-0.1833 \\cdot Z^3 + 1.0383 \\cdot Z^2 - 1.2943 \\cdot Z + 0.837 \\right) = \\NR) tex.print(\\NC \\NC \\NC = N \\cdot \\left(-0.1833 \\cdot \\sbc{Z}^3 + 1.0383 \\cdot \\sbc{Z}^2 - 1.2943 \\cdot \\sbc{Z} + 0.837 \\right
Re: [NTG-context] \systemparameter{n}
Am 06.05.2012 22:26, schrieb Hans Hagen: On 3-5-2012 19:01, Peter Rolf wrote: Hi, the system parameter 'n' is not properly set on the third run. % test.tex \starttext \ifnum\systemparameter{n}=1\relax \ctxlua{print(*** 1st run)}\fi \ifnum\systemparameter{n}=2\relax \ctxlua{print(*** 2nd run)}\fi \ifnum\systemparameter{n}=3\relax \ctxlua{print(*** 3rd run)}\fi \stoptext % A fresh run (three runs) gives *** 1st run *** 2nd run *** 2nd run from core-sys: \ifcase\directsystemparameter\c!n\relax %% 0 : unknown \or \setsystemmode\v!first % 1 : first run \or %% 2 : successive run \or \setsystemmode\v!first % 3 : first and only run \or \setsystemmode\v!last% 4 : (extra) last run \fi the run number is \systemparameter{m} Thanks Hans. No unwanted batch start in the third run anymore. :-) ___ 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] \systemparameter{n}
On 3-5-2012 19:01, Peter Rolf wrote: Hi, the system parameter 'n' is not properly set on the third run. % test.tex \starttext \ifnum\systemparameter{n}=1\relax \ctxlua{print(*** 1st run)}\fi \ifnum\systemparameter{n}=2\relax \ctxlua{print(*** 2nd run)}\fi \ifnum\systemparameter{n}=3\relax \ctxlua{print(*** 3rd run)}\fi \stoptext % A fresh run (three runs) gives *** 1st run *** 2nd run *** 2nd run from core-sys: \ifcase\directsystemparameter\c!n\relax %% 0 : unknown \or \setsystemmode\v!first % 1 : first run \or %% 2 : successive run \or \setsystemmode\v!first % 3 : first and only run \or \setsystemmode\v!last% 4 : (extra) last run \fi the run number is \systemparameter{m} 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] Font for MetaPost graphics
On 4-5-2012 13:09, Marco wrote: On 2012-05-04 Aditya Mahajanadit...@umich.edu wrote: On Fri, 4 May 2012, Mojca Miklavec wrote: But my guess is that the argument goes into the opposite way. I past (and still in MKII) one *had to* set up fonts twice - once for the main document and once for MetaPost since MetaPost did its own processing of labels and MetaPost didn't see the ConTeXt font setups. So it was difficult to convince MetaPost to use the same font. I agree, it's a big step forward towards usability and consistency to have MetaPost automatically inherit ConTeXts settings. However, it went out-of-control now. well, you still get text and not something random, so out-of-control is a bit too strong anyhow, we can do \newconditional\MPLIBtextgetdone \def\MPLIBsettext#1% #2% {\ifconditional\MPLIBtextgetdone \else \cldcontext{metapost.tex.get()}% \settrue\MPLIBtextgetdone % no \global needed \fi \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox} \def\MPLIBresettexts {\ctxlua{metapost.resettextexts()}%$ \setfalse\MPLIBtextgetdone} \starttext Serif \startMPcode draw textext(\ss Sans) ; \stopMPcode Serif \startMPenvironment \ss \stopMPenvironment \startMPcode draw textext(Sans) ; \stopMPcode Serif \stoptext A better alternative would to define \setupMPtext [ style=..., color=..., setups=..., ] that can be used to set the style for metapost text. this is ok for me, but then we mighe as well drop \startMPenviroment (and someone has to wikify that then) 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 ___
[NTG-context] Wiki - results differ?
Hello, Wiki and a file processed on a local computer give different results - - please compare http://wiki.contextgarden.net/Command/doif...; and the example attached: \starttext \ctxlua{test = true} Test is \ctxlua{commands.testcase(test)}{True}{False}. \ctxlua{test = false} Test is \ctxlua{commands.testcase(test)}{True}{False}. \stoptext The result should be: Test is True. Test is False. which works fine on my computer. But wiki shows (wrongly): Test is TrueFalse. Test is TrueFalse. although the same code is used in the example: context source=yes text=Gives: \starttext \ctxlua{test = true} Test is \ctxlua{commands.testcase(test)}{True}{False}. \ctxlua{test = false} Test is \ctxlua{commands.testcase(test)}{True}{False}. \stoptext /context Any idea why both results differ? And how to make wiki show the good result? Best regards, Lukas -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 t.log Description: Binary data t.mkiv Description: Binary data t.pdf Description: Adobe PDF document ___ 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] \systemparameter{n}
Hi, the system parameter 'n' is not properly set on the third run. % test.tex \starttext \ifnum\systemparameter{n}=1\relax \ctxlua{print(*** 1st run)}\fi \ifnum\systemparameter{n}=2\relax \ctxlua{print(*** 2nd run)}\fi \ifnum\systemparameter{n}=3\relax \ctxlua{print(*** 3rd run)}\fi \stoptext % A fresh run (three runs) gives *** 1st run *** 2nd run *** 2nd run Peter ___ 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] extracting word count from a *.words file
Hello all, Here is another question. Consider this test file: \starttext \setupspellchecking[state=start,method=2] \ctxlua{languages.words.threshold=3} \input knuth \stoptext Typesetting this file produces a word list 'test.words' which ends like this: [threshold]=1, [total]=122, [version]=1, } Is there a way to extract the value for [total] ('122' in this case) so that I can use that value somewhere else, e.g. in a project file where I want to present a word count. Thanks for a pointer! Jelle ___ 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] extracting word count from a *.words file
Hi again, On 2012-04-20 16:32, Jelle Huisman wrote: Hello all, Here is another question. Consider this test file: \starttext \setupspellchecking[state=start,method=2] \ctxlua{languages.words.threshold=3} \input knuth \stoptext Typesetting this file produces a word list 'test.words' which ends like this: [threshold]=1, [total]=122, [version]=1, } Is there a way to extract the value for [total] ('122' in this case) so that I can use that value somewhere else, e.g. in a project file where I want to present a word count. The “.words”-file is well formed Lua code, so you can just integrate it as a table: \define\wordcount{%%% Displays word count. This document consists of \startluacode local data = dofile\jobname.words %% Load data of _previous_ pass context(data.total) %% access the requested field \stopluacode \space words.% } \starttext \setupspellchecking[state=start,method=2] \ctxlua{languages.words.threshold=3} \input knuth \hairline \wordcount %% call to the macro \stoptext Thanks for a pointer! Thanks as well, btw, I didn’t know the word count facility yet! Philipp Jelle ___ 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 ___ -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments pgpjWSl4cFMhN.pgp Description: PGP signature ___ 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] extracting word count from a *.words file
On 2012-04-20 Jelle Huisman je...@jhnet.nl wrote: Is there a way to extract the value for [total] ('122' in this case) so that I can use that value somewhere else, e.g. in a project file where I want to present a word count. I used the word count some time ago. Here's the code I used. I have no idea what has changed since and if it still works. \startluacode userdata = userdata or { } function userdata.wordcount(listname) filename = file.addsuffix(tex.jobname,words) if lfs.isfile(filename) then local w = dofile(filename) if w then if type(w.categories[listname]) == table then context(w.categories[listname].total) else context(w.total) end context.par() end end end \stopluacode \def\wordcount{% \dosingleempty\dowordcount} \def\dowordcount[#1]{% \ctxlua{userdata.wordcount(#1)}} \starttext % Set up the word count \ctxlua{languages.words.threshold=2} \setupspellchecking [state=start, method=2] \setupspellchecking [list=foo] \startsection [title=Foo] Foo Bar \stopsection \setupspellchecking [list=lorem] \startsection [title=Lorem] Lorem ipsum dolor sit \stopsection \setupspellchecking [list=stop] \startsubject [title=Statistics] Words in Foo: \wordcount [foo] Words in Lorem: \wordcount [lorem] \stopsubject \stoptext Marco ___ 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] extracting word count from a *.words file
On 04/20/2012 04:53 PM, Philipp Gesang wrote: Hi again, On 2012-04-20 16:32, Jelle Huisman wrote: Hello all, Here is another question. Consider this test file: \starttext \setupspellchecking[state=start,method=2] \ctxlua{languages.words.threshold=3} \input knuth \stoptext Typesetting this file produces a word list 'test.words' which ends like this: [threshold]=1, [total]=122, [version]=1, } Is there a way to extract the value for [total] ('122' in this case) so that I can use that value somewhere else, e.g. in a project file where I want to present a word count. The “.words”-file is well formed Lua code, so you can just integrate it as a table: Thank you, Philip, this is a clean solution. Jelle ___ 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] Dump table of contents
On Mon, 2012-04-09 at 00:08 -0400, Aditya Mahajan wrote: \def\loaddatafile#1% {\ctxlua { job.initialize(#1.tuc,#1.tua) }}% \loaddatafile{full-book} %with the .tex extension \starttext \placelist[chapter] \stoptext Thanks Aditya, but I tried doing that. ConTeXt doesn't seem to emit an error, but neither does it a PDF. I've attached the output log. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com resolversresolving loading configuration file '/usr/share/texmf/web2c/contextcnf.lua' (Source/Makeup/Table_of_Contents_Standalone_Product.tex ConTeXt ver: 2012.04.07 14:42 MKIV fmt: 2012.4.8 int: english/english system cont-new.mkiv loaded (/usr/share/texmf/tex/context/base/cont-new.mkiv system beware: some patches loaded from cont-new.mkiv ) system Table_of_Contents_Standalone_Product.top loaded system options start used options used options % runtime options files (command line driven) used options \unprotect used options % feedback and basic job control used options % handy for special styles used options \startluacode used options document = document or { } used options document.arguments={ used options [environment]=Source/Environment.tex, used options } used options document.files={ used options Source/Makeup/Table_of_Contents_Standalone_Product.tex, used options } used options \stopluacode used options % process info used options \setupsystem[inputfile=Source/Makeup/Table_of_Contents_Standalone_Product.tex] used options \setupsystem[\c!n=1,\c!m=1] used options % modes used options % options (not that important) used options \startsetups *runtime:options used options \stopsetups used options % styles and modules used options \startsetups *runtime:modules used options \environment Source/Environment.tex used options \stopsetups used options % done used options \protect \endinput system options stop used options (Table_of_Contents_Standalone_Product.top) fontslatin modern fonts are not preloaded languageslanguage en is active (Source/Environment.tex resolversmodules loaded: 'units' (/usr/share/texmf/tex/context/base/m-units.mkiv+ /usr/share/texmf/tex/context/base/x-mathml.lua) resolversmodules loaded: 'simplefonts' (/usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.tex loading ConTeXt User Module / Simplefonts + /usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.lua) fontstypescripts unknown: library 'loc' {/usr/share/texmf/fonts/map/dvips/lm/lm-math.map}{/usr/share/texmf/fonts/map/dvips/lm/lm-rm.map}{/usr/share/texmf/fonts/map/pdftex/context/mkiv-base.map}) ) system files start used files used files 1: filename=Source/Makeup/Table_of_Contents_Standalone_Product.tex | foundname=Source/Makeup/Table_of_Contents_Standalone_Product.tex | usedmethod=direct used files 2: filename=cont-new.mkiv | filetype=tex | foundname=/usr/share/texmf/tex/context/base/cont-new.mkiv | usedmethod=database used files 3: filename=Table_of_Contents_Standalone_Product.top | foundname=Table_of_Contents_Standalone_Product.top | usedmethod=direct used files 4: filename=lang-us.lua | filetype=lua | foundname=/usr/share/texmf/tex/context/patterns/lang-us.lua | usedmethod=database used files 5: filename=Source/Environment.tex | foundname=Source/Environment.tex | usedmethod=direct used files 6: filename=m-units.mkiv | filetype=tex | foundname=/usr/share/texmf/tex/context/base/m-units.mkiv | usedmethod=database used files 7: filename=m-units.mkiv | filetype=tex | format=tex | foundname=/usr/share/texmf/tex/context/base/m-units.mkiv | usedmethod=database used files 8: filename=usr/share/texmf/tex/context/base/m-units.mkiv | foundname=/usr/share/texmf/tex/context/base/m-units.mkiv | usedmethod=qualified used files 9: filename=x-mathml.lua | filetype=tex | format=tex | foundname=/usr/share/texmf/tex/context/base/x-mathml.lua | usedmethod=database used files 10: filename=t-simplefonts.tex | filetype=tex | foundname=/usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.tex | usedmethod=database used files 11: filename=t-simplefonts.tex | filetype=tex | format=tex | foundname=/usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.tex | usedmethod=database used files 12: filename=usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.tex | foundname=/usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.tex | usedmethod=qualified used files 13: filename=t-simplefonts.lua | filetype=tex | format=tex | foundname=/usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.lua | usedmethod=database used files 14: filename=lm.lfg | filetype=tex | foundname=/usr
Re: [NTG-context] Dump table of contents
On Sun, 8 Apr 2012, Kip Warner wrote: On Mon, 2012-04-09 at 00:08 -0400, Aditya Mahajan wrote: \def\loaddatafile#1% {\ctxlua { job.initialize(#1.tuc,#1.tua) }}% \loaddatafile{full-book} %with the .tex extension Sorry, this should have read: WITHOUT the .tex extension \starttext \placelist[chapter] \stoptext 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] Dump table of contents
On Sun, 8 Apr 2012, Kip Warner wrote: Hey list, Is it possible to instruct ConTeXt to generate just the table of contents, skipping all other front matter, back matter, appendices, body matter, etc.? For example, only the following I'd like to see in the outputted PDF: % Contents at a glance... \title{Contents at a Glance} \placelist[chapter] % Complete table of contents... \title{Table of Contents} \placecontent Right now I am generating the full book, but then passing through pdftk manually to extract just the pages that fall within the aforementioned. I tried putting the aforementioned code in its own product file and then passing that through ConTeXt with the book's environment, but the problem is that the TOC now has nothing in it, of course. I don't know if there is proper interface to this, but you can just load the tuc file and reuse the labels. \def\loaddatafile#1% {\ctxlua { job.initialize(#1.tuc,#1.tua) }}% \loaddatafile{full-book} %with the .tex extension \starttext \placelist[chapter] \stoptext 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] Hooking \stoptext
... OK, your solution works - - But I'd need one which doesn't force user to hook manually; i.e. without: \let\Oldstoptext\stoptext \def\stoptext{% \startluacode context(END) \stopluacode \Oldstoptext } Hooking should be performed in a Lua function and should be invisible to the user. More complicated example: t-Hook4.mkiv \startluacode function foo() local stoptext_p = context.stoptext context.stoptext = function(...) context(END) stoptext_p(...) end end \stopluacode \starttext \input knuth \ctxlua{foo()} % This should cause END to appear at the end of the document \stoptext In this case, foo() is a function which does the hooking; and foo() may be placed in another file or Lua toolbox, so user is to call Lua's require 'my-Lua-toolbox-with-foo' foo(). So user is not forced to know how the function works; once he uses it, the text END will appear at the end of the document. - And this doesn't happen to me; and my goal is to make it work. Lukas On Wed, 07 Mar 2012 15:39:23 +0100, luigi scarso luigi.sca...@gmail.com wrote: 2012/3/7 Procházka Lukáš Ing. - Pontex s. r. o. l...@pontex.cz Hello, I'd need to to hook \stoptext by Lua - I'd need to write something right before the end of the text. At least \let\Oldstoptext\stoptext \def\stoptext{% \startluacode context(END) \stopluacode \Oldstoptext} \starttext \input knuth \stoptext % To be hooked by Lua But there are several \every* tokens list for this. -- Ing. Lukáš Procházka [mailto:l...@pontex.cz] Pontex s. r. o. [mailto:pon...@pontex.cz] [http://www.pontex.cz] Bezová 1658 147 14 Praha 4 Tel: +420 244 062 238 Fax: +420 244 461 038 t-Hook4.mkiv Description: Binary data t-Hook4.pdf Description: Adobe PDF document ___ 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] Hooking \stoptext
Am 07.03.2012 um 16:57 schrieb Procházka Lukáš Ing. - Pontex s. r. o.: ... Yes, that's it! Thanks a lot! You can also write your own stop/stop-commands for the document like \def\startmydocument {\starttext} \def\stopmydocument {\ctxlua{…}% \stoptext} and use them instead of \starttext and \stoptext. 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] Hooking \stoptext
Am 07.03.2012 um 18:37 schrieb Wolfgang Schuster: Am 07.03.2012 um 16:57 schrieb Procházka Lukáš Ing. - Pontex s. r. o.: ... Yes, that's it! Thanks a lot! You can also write your own stop/stop-commands for the document like \def\startmydocument {\starttext} \def\stopmydocument {\ctxlua{…}% \stoptext} and use them instead of \starttext and \stoptext. Or you use the predefined document environment which has before and after keys. \setupdocument[after={\blank\midaligned{\bf THE END}}] \startdocument \input knuth \stopdocument 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] Including command output
On Sun, 2012-03-04 at 23:20 -0500, Aditya Mahajan wrote: If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example: \def\BazaarRevision {\ctxlua{context.setevalue( BazaarRevision, os.resultofbzr revno | tr -d '\\n')}% \BazaarRevision} Hey Aditya. I tried the automagic method, but ConTeXt bails: ! TeX capacity exceeded, sorry [text input levels=127]. \BazaarRevision ...ltofbzr revno | tr -d '\\n')} \BazaarRevision l.4 } \BazaarRevision ...ltofbzr revno | tr -d '\\n')} \BazaarRevision l.4 } \BazaarRevision ...ltofbzr revno | tr -d '\\n')} \BazaarRevision l.4 } ... l.58 ! == Fatal error occurred, no output PDF file produced! mtx-context | fatal error: return code: 1 Based on what I saw from htop, it looks like it running the command into the ground over and over again which is the exact opposite of what we are trying to do. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com signature.asc Description: This is a digitally signed message part ___ 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] Including command output
On Mon, 5 Mar 2012, Kip Warner wrote: On Sun, 2012-03-04 at 23:20 -0500, Aditya Mahajan wrote: If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example: \def\BazaarRevision {\ctxlua{context.setevalue( BazaarRevision, os.resultofbzr revno | tr -d '\\n')}% \BazaarRevision} Hey Aditya. I tried the automagic method, but ConTeXt bails: ! TeX capacity exceeded, sorry [text input levels=127]. \BazaarRevision ...ltofbzr revno | tr -d '\\n')} \BazaarRevision l.4 } \BazaarRevision ...ltofbzr revno | tr -d '\\n')} \BazaarRevision l.4 } \BazaarRevision ...ltofbzr revno | tr -d '\\n')} \BazaarRevision l.4 } ... l.58 The attached file works at my end. Based on what I saw from htop, it looks like it running the command into the ground over and over again which is the exact opposite of what we are trying to do. No. It is defining \BazaarVersion once and then reusing the result. Add \loggingall to your file to see what is happening. Aditya test.tex Description: TeX document ___ 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] Including command output
On Mon, 2012-03-05 at 22:38 -0500, Aditya Mahajan wrote: Can you attach your complete log file? Attached. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com resolversresolving loading configuration file '/usr/share/texmf/web2c/contextcnf.lua' (Source/Handbook.tex ConTeXt ver: 2012.03.05 19:49 MKIV fmt: 2012.3.5 int: english/english system cont-new.mkiv loaded (/usr/share/texmf/tex/context/base/cont-new.mkiv system beware: some patches loaded from cont-new.mkiv ) system Handbook.top loaded system options start used options used options % runtime options files (command line driven) used options \unprotect used options % feedback and basic job control used options % handy for special styles used options \startluacode used options document = document or { } used options document.arguments={ used options [purgeresult]=true, used options [result]=Avaneya Project Crew Handbook.pdf, used options } used options document.files={ used options Source/Handbook.tex, used options } used options \stopluacode used options % process info used options \setupsystem[inputfile=Source/Handbook.tex] used options \setupsystem[file=Avaneya Project Crew Handbook.pdf] used options \setupsystem[\c!n=1,\c!m=1] used options % modes used options % options (not that important) used options \startsetups *runtime:options used options \stopsetups used options % styles and modules used options \startsetups *runtime:modules used options \stopsetups used options % done used options \protect \endinput system options stop used options (Handbook.top) fontslatin modern fonts are not preloaded languageslanguage en is active {/usr/share/texmf/fonts/map/pdftex/context/mkiv-base.map} fontspreloading latin modern fonts (second stage) fontstypescripts unknown: library 'loc' {/usr/share/texmf/fonts/map/dvips/lm/lm-math.map}{/usr/share/texmf/fonts/map/dvips/lm/lm-rm.map} fontsdefining forced type afm of stmary10 not found fontsdefining font with asked name 'stmary10' is not found using lookup 'file' fontsvirtual math loading font LMMath7-Regular subfont 9 with name stmary10.afm at 458752 is skipped, not found fontsdefining forced type afm of stmary10 not found fontsdefining font with asked name 'stmary10' is not found using lookup 'file' fontsvirtual math loading font LMMath9-Regular subfont 9 with name stmary10.afm at 589824 is skipped, not found fontsdefining forced type afm of stmary10 not found fontsdefining font with asked name 'stmary10' is not found using lookup 'file' fontsvirtual math loading font LMMath12-Regular subfont 9 with name stmary10.afm at 786432 is skipped, not found fontsfallback modern rm 12pt is loaded (Source/Environment.tex resolversmodules loaded: 'units' (/usr/share/texmf/tex/context/base/m-units.mkiv+ /usr/share/texmf/tex/context/base/x-mathml.lua) resolversmodules loaded: 'simplefonts' (/usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.tex loading ConTeXt User Module / Simplefonts + /usr/share/texmf/tex/context/third/simplefonts/t-simplefonts.lua) {vertical mode: \tracingstats} {\tracingpages} {\tracingoutput} {\tracinglostchars} {\tracingmacros} {\tracingparagraphs} {\tracingrestores} {\showboxbreadth} {\showboxdepth} {\tracinggroups} {\tracingifs} {\tracingscantokens} {\tracingnesting} {\tracingassigns} {into \tracingassigns=2} {\errorstopmode} {\tracingonline} {changing \tracingonline=1} {into \tracingonline=0} \BazaarRevision -\ctxlua {context.setevalue( BazaarRevision, os.resultofbzr revno | tr -d '\\n')}\BazaarRevision \ctxlua -\directlua \zerocount {\directlua} \setevalue #1-\expandafter \edef \csname #1\endcsname #1-BazaarRevision {\expandafter} {\csname} {\edef} {changing \BazaarRevision=macro:-\ctxlua {context.setevalue( B\ETC.} {into \BazaarRevision=macro:-178} \BazaarRevision -178 {the character 1} \everypar-\page_otr_command_synchronize_side_floats \checkindentation \showparagraphnumber \restoreinterlinepenalty \flushnotes \synchronizenotes \OTRSETshowstatus \flushpostponedbookmark \registerparoptions \flushpostponednodedata \typo_delimited_repeat \insertparagraphintro \dotagsetparcounter \page_otr_command_synchronize_side_floats -\page_sides_synchronize_floats \page_sides_synchronize_floats -\ifinner \else \page_sides_check_floats \fi {horizontal mode: \ifinner: (level 1) entered on line 49} {false} {\else: \ifinner (level 1) entered on line 49} \page_sides_check_floats -\page_sides_analyse_progress \ifdim \d_page_sides_progress \zeropoint \page_sides_check_floats_set \else \page_sides_check_floats_reset \fi \parskip \s_spac_whitespace_parskip
Re: [NTG-context] Including command output
On Mon, 5 Mar 2012, Kip Warner wrote: On Mon, 2012-03-05 at 22:50 -0500, Aditya Mahajan wrote: The error is not due to the macro \BazaarRevision. The log file shows that the group (for {\loggingall \BazaarRevison}) is closed properly; the error is displayed after that. So, something else in your setup is causing the error. It doesn't bail unless I replace the previous definition with yours. Here is an example of its usage from my source: \setupinteraction [state=start, color=colour_link, contrastcolor=colour_link, focus=standard, title=Some Book (Bzr r\BazaarRevision), author=Some Book (Bzr r\BazaarRevision)] Why don't you use the first version (\initializebazaarversion and \usebazaarversion)? \def\initializeBazaar {\ctxlua{context(\\global\\edef\\BazaarRevision{\%s}, os.resultofbzr revno | tr -d '\\n')}} \initializeBazaar \setupinteraction [state=start, color=colour_link, contrastcolor=colour_link, focus=standard, title=Some Book (Bzr r\BazaarRevision), author=Some Book (Bzr r\BazaarRevision)] \starttext Hello \BazaarRevision Bye \stoptext The rest of the book just has some \BazaarRevision scattered here and there, but I can't see anything unusual about their usage or context. It helps if you try to create a minimal example. 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] Including command output
On Tue, 2012-03-06 at 00:04 -0500, Aditya Mahajan wrote: Why don't you use the first version (\initializebazaarversion and \usebazaarversion)? \def\initializeBazaar {\ctxlua{context(\\global\\edef\\BazaarRevision{\%s}, os.resultofbzr revno | tr -d '\\n')}} \initializeBazaar Very good question. I suppose trying to get the automagic method to work doesn't matter since the above works fine. Thanks again Aditya. -- Kip Warner -- Software Engineer OpenPGP encrypted/signed mail preferred http://www.thevertigo.com signature.asc Description: This is a digitally signed message part ___ 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] Including command output
On Sun, 4 Mar 2012, Kip Warner wrote: Hey list, I'd like to include the output of a command. I am using the following to define the command, \def\BazaarRevision{\cldcontext{os.resultofbzr revno | tr -d '\\n'}} and the following to use the output of the command, \BazaarRevision A concern I have is whether this command is executed multiple times during the typesetting process when it need only be done once with the result cached. If this is indeed the case, Yes. does anyone have any suggestions? The cleaner way is to seperate the setup and use. For example: \def\initilizebazaar {\ctxlua{context.setevalue( usebazaarrevision, os.resultofbzr revno | tr -d '\\n')}} \appendtoks \initilizebazaar \to \everystarttext and then use can use \usebazaarrevision in the main text. If you want to use the automagic way, you can define \BazaarRevision to redefined \BazaarRevision, for example: \def\BazaarRevision {\ctxlua{context.setevalue( BazaarRevision, os.resultofbzr revno | tr -d '\\n')}% \BazaarRevision} 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] Getting changing/random graphics?
On 16-2-2012 07:43, Mari Voipio wrote: Hello all, I'm trying to do something that should be possible and I think variables is the answer, I just can't figure out how. I have a pile of photos (jpg) in a directory and the assumption is that they are all the same size and there's a spot for the photo on a layer at the top of the page. I already found out how I can get ConTeXt to draw the layer separately for each page (at http://wiki.contextgarden.net/layers#Use_dynamic_content), but I think I need a variables for dummies page... This time I'm not too picky, the images can be used randomly or in the order they are in the directory and then cycled, I'd just like to use more than one (and I'm so not doing every page by hand). So, if I have photo1.jpg photo2.jpg photo3.jpg photo4.jpg and \dorecurse{10}{insert random photo here}, how do I do it? More fancy ... \startluacode local files = { } function document.collectgraphics(pattern) files = table.merged(files,dir.glob(pattern)) files = table.unique(files) table.sort(files) logs.report(string.format(graphics: %s,table.concat(files, ))) end function document.choosegraphics() if #files 0 then context(table.remove(files, math.random(1,#files)) or dummy) else context(dummy) end end \stopluacode \def\CollectGraphics[#1]{\ctxlua{document.collectgraphics(#1)}} \def\ChooseGraphic {\ctxlua{document.choosegraphic()}} \CollectGraphics[*.png] \CollectGraphics[*.jpg] \starttext \dorecurse {10} { \expanded{\externalfigure[\ChooseGraphic][width=4cm]} } \stoptext - 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] Getting changing/random graphics?
On 16-2-2012 07:43, Mari Voipio wrote: I'm trying to do something that should be possible and I think variables is the answer, I just can't figure out how. attached .. (will be in test suite) 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 - % For Mari Voipio \startluacode local files = { } function document.collectgraphics(pattern) files = table.merged(files,dir.glob(pattern)) files = table.unique(files) table.sort(files) logs.report(string.format(graphics: %s,table.concat(files, ))) end function document.choosegraphic() if #files 0 then context(table.remove(files, math.random(1,#files)) or dummy) else context(dummy) end end \stopluacode \def\CollectGraphics[#1]{\ctxlua{document.collectgraphics(#1)}} \def\ChooseGraphic {\ctxlua{document.choosegraphic()}} \CollectGraphics[*.png] \CollectGraphics[*.jpg] \starttext \dorecurse {10} { \expanded{\externalfigure[\ChooseGraphic][width=4cm]} } \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 ___
[NTG-context] Problem with Lua processing UTF8 substrings
Hello ConTeXist, I want to use Lua to write characters (substrings) from a string, but I get an error message: ! String contains an invalid utf-8 sequence. I tried various Lua functions for working with UTF8 strings for example: string.subutf8(string, start[,end]) for i, char in str:nextutf8(orig_pos) string.lenutf8(string), but without success. Can you please someone help? Thanks Jaroslav Hajtmar Here is my minimal example: \def\mymacro#1{\ctxlua{for i=1, string.len('#1') do context(string.sub('#1',i,i).., ) end}} \starttext %\mymacro{šěřěžřýčřčžáýčý} % Here is a problem \mymacro{asdfghjklqwertt} % Here is all OK \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] Problem with Lua processing UTF8 substrings
On 2012-02-01 20:26, Jaroslav Hajtmar wrote: I want to use Lua to write characters (substrings) from a string, but I get an error message: ! String contains an invalid utf-8 sequence. Can you please someone help? Have you tried the unicode library? The standard string library operates on bytes, therefore extracting a single byte yields an incomplete multibyte char if the codepoint is beyond ascii. · \def\mymacro#1{% \startluacode local utf = unicode.utf8 local target = [==[\detokenize{#1}]==] for i=1, utf.len(target) do context(utf.sub(target,i,i).., ) end \stopluacode% } %% alternatively, use utfcharacters \define[1]\myothermacro{% \startluacode local result = { } for i in string.utfcharacters[==[\detokenize{#1}]==] do result[\letterhash result+1] = i end context(table.concat(result, , )) \stopluacode } \starttext \mymacro{šěřěžřýčřčžáýčý}\par \myothermacro{šěřěžřýčřčžáýčý} \stoptext · (Lazy people would just do a “local string = unicode.utf8” at the top of the file.) Regards Philipp Thanks Jaroslav Hajtmar Here is my minimal example: \def\mymacro#1{\ctxlua{for i=1, string.len('#1') do context(string.sub('#1',i,i).., ) end}} \starttext %\mymacro{šěřěžřýčřčžáýčý} % Here is a problem \mymacro{asdfghjklqwertt} % Here is all OK \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 ___ -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments pgpehNQA1ygvP.pgp Description: PGP signature ___ 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] What’s your favorite command?
On Mon, 30 Jan 2012, Marco wrote: On 2012-01-30 Wolfgang Schuster schuster.wolfg...@googlemail.com wrote: The ConTeXt package is huge and provides dozen of commands but I guess many have *one* favorite command (maybe also functionality). I was surprised by the unusual “Subject” line in my mail client. But I don't hesitate: My favourite command is \externalfigure [placeholder] because it produces very pretty colourful graphics (I'm bored to use the dutch cow or the wind mill every time). Example: \useMPlibrary [dum] \starttext \dorecurse{10}{ \startTEXpage \externalfigure [placeholder] \stopTEXpage} \stoptext You can also use my `\externalkitten` macro: http://randomdeterminism.wordpress.com/2011/05/07/images-for-documentation-examples/ \def\externalkitten[#1]% {\getparameters[kitten][width=10pt, height=10pt, #1] \externalfigure [\ctxlua{context(http://placekitten.com/g/\%0.0f/\%0.0f;, \withoutpt{\the\dimexpr\kittenwidth}, \withoutpt{\the\dimexpr\kittenheight})}] [#1, method=jpg]} \starttext \placefigure[left,none]{} {\externalkitten[width=0.5\textwidth, height=0.3\textheight]} \input knuth \stoptext 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 ___
[NTG-context] CLD: context.getvariable as Lua variable
Hello, I'm relatively quite new to TeX world. This is my first message to list. I hope you understand me, English isn't my mother language. I'm trying to use a variable set by \setvariable in Lua. I tried some combinations, based on manual but I couldn't succeed. The code below exemplifies what I wanted to do. \starttext \setvariable{namespace}{var}{Some context} \ctxlua{ local s = context.getvariable(namespace, var) if s == then ... else ... end } \stoptext I know that I can use some of \if* TeX commands, but coding in Lua is better to me. -- Wagner Macedo ___ 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] CLD: context.getvariable as Lua variable
Am 05.01.2012 um 15:49 schrieb Wagner Macedo: Hello, I'm relatively quite new to TeX world. This is my first message to list. I hope you understand me, English isn't my mother language. I'm trying to use a variable set by \setvariable in Lua. I tried some combinations, based on manual but I couldn't succeed. The code below exemplifies what I wanted to do. \starttext \setvariable{namespace}{var}{Some context} \ctxlua{ local s = context.getvariable(namespace, var) if s == then ... else ... end } \stoptext I know that I can use some of \if* TeX commands, but coding in Lua is better to me. What you’re trying is not possible but there are other ways to check the content of the variable in Lua. \startluacode userdata = userdata or { } function userdata.checkvariable(variable) if variable == then context(EMPTY) else context(NOT EMPTY) end end \stopluacode \setvariable{wagner}{name}{Wagner Macedo} \starttext \ctxlua{userdata.checkvariable(\getvariable{wagner}{name})} % This does only with \startlua or \ctxlua \startlua local name = \getvariable{wagner}{name} if name == then context(No Text) else name = Name: .. name context(name) end \stoplua \stoptext A different method is to save the \setvariables entries in a Lua table and check the entries of the table. \startluacode userdata= userdataor { } userdata.macedo = userdata.macedo or { } userdata.macedo.data = { } function userdata.macedo.savevariables(variables) userdata.macedo.data = variables end function userdata.macedo.checkvariables() local variables = userdata.macedo.data -- check for name if variables.name == then context(Name: No name set) context.par() else context(Name: ..variables.name) context.par() end -- check for address if variables.address == then context(Address: No address set) context.par() else context(Address: ..variables.address) context.par() end end \stopluacode \starttexdefinition SaveVariables \startlua userdata.macedo.savevariables{ name= \getvariable{macedo}{name}, address = \getvariable{macedo}{address}, } \stoplua \stoptexdefinition \setvariables[macedo][set=\SaveVariables] \starttext \setvariables[macedo][name=Wagner Macedo] \ctxlua{userdata.macedo.checkvariables()} \setvariables[macedo][address=Secret] \ctxlua{userdata.macedo.checkvariables()} \stoptext 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] CLD: context.getvariable as Lua variable
Firstly, thanks by answer. The second way is nice, but could be generic (e.g. save any variable in a namespace)? -- Wagner Macedo On 5 January 2012 13:04, Wolfgang Schuster schuster.wolfg...@googlemail.com wrote: Am 05.01.2012 um 15:49 schrieb Wagner Macedo: Hello, I'm relatively quite new to TeX world. This is my first message to list. I hope you understand me, English isn't my mother language. I'm trying to use a variable set by \setvariable in Lua. I tried some combinations, based on manual but I couldn't succeed. The code below exemplifies what I wanted to do. \starttext \setvariable{namespace}{var}{Some context} \ctxlua{ local s = context.getvariable(namespace, var) if s == then ... else ... end } \stoptext I know that I can use some of \if* TeX commands, but coding in Lua is better to me. What you’re trying is not possible but there are other ways to check the content of the variable in Lua. \startluacode userdata = userdata or { } function userdata.checkvariable(variable) if variable == then context(EMPTY) else context(NOT EMPTY) end end \stopluacode \setvariable{wagner}{name}{Wagner Macedo} \starttext \ctxlua{userdata.checkvariable(\getvariable{wagner}{name})} % This does only with \startlua or \ctxlua \startlua local name = \getvariable{wagner}{name} if name == then context(No Text) else name = Name: .. name context(name) end \stoplua \stoptext A different method is to save the \setvariables entries in a Lua table and check the entries of the table. \startluacode userdata= userdataor { } userdata.macedo = userdata.macedo or { } userdata.macedo.data = { } function userdata.macedo.savevariables(variables) userdata.macedo.data = variables end function userdata.macedo.checkvariables() local variables = userdata.macedo.data -- check for name if variables.name == then context(Name: No name set) context.par() else context(Name: ..variables.name) context.par() end -- check for address if variables.address == then context(Address: No address set) context.par() else context(Address: ..variables.address) context.par() end end \stopluacode \starttexdefinition SaveVariables \startlua userdata.macedo.savevariables{ name= \getvariable{macedo}{name}, address = \getvariable{macedo}{address}, } \stoplua \stoptexdefinition \setvariables[macedo][set=\SaveVariables] \starttext \setvariables[macedo][name=Wagner Macedo] \ctxlua{userdata.macedo.checkvariables()} \setvariables[macedo][address=Secret] \ctxlua{userdata.macedo.checkvariables()} \stoptext 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 ___ ___ 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] How to define a command...
Hi all, I need to define numerical coefficients (essentially at random) and then use them with commands, say like \CoeffAlpha, \CoeffBeta, and so on. More precisely, how can I define the command \RandomCoeff, so that \RandomCoeff{Beta}{1}{10} yields a command named \CoeffBeta, which is a random number chosen between 1 and 10? I tried to use the following approach, but could not make it work: %%% begin random-coeff.tex \setuprandomize[2012] % set a seed \ctxlua{CoeffAlpha = math.random(1,10) ;} \def\CoeffAlpha{\ctxlua{tex.print(CoeffAlpha)}} % \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... } \starttext \CoeffAlpha \RandomCoeff{Beta}{1}{10} \ctxlua{tex.print(a)} %\CoeffBeta \stoptext %%% end random-coeff.tex Thanks in advance for any suggestion or hint. Best regards: OK ___ 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] How to define a command...
Reccently I did something random in ctxlua. I post it in the hope it will be useful. Hans van der Meer \startluacode -- Define our namespace as hvdm hvdm = hvdm or {} -- Return random series of numbers 1..n depending on the number of arguments function hvdm.randomseries (n, straight) local done = {} for i = 1, n do done[i] = i end if straight == false then return table.concat(done,,) end local result = for i = n, 2, -1 do local r = math.random(i) result = result .. done[r] .. , table.remove(done,r) end result = result .. done[1] return result end \stopluacode \def\RandomSeed#1{\directlua{math.randomseed(#1)}} \def\RandomValue{\directlua{tex.print(math.random())}} \def\RandomRange#1{\directlua{tex.print(math.random(#1))}} \def\RandomSeries[#1]#2{\ctxlua{tex.print(hvdm.randomseries(#2,#1))}% On 5 jan. 2012, at 21:05, Otared Kavian wrote: Hi all, I need to define numerical coefficients (essentially at random) and then use them with commands, say like \CoeffAlpha, \CoeffBeta, and so on. More precisely, how can I define the command \RandomCoeff, so that \RandomCoeff{Beta}{1}{10} yields a command named \CoeffBeta, which is a random number chosen between 1 and 10? I tried to use the following approach, but could not make it work: %%% begin random-coeff.tex \setuprandomize[2012] % set a seed \ctxlua{CoeffAlpha = math.random(1,10) ;} \def\CoeffAlpha{\ctxlua{tex.print(CoeffAlpha)}} % \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... } \starttext \CoeffAlpha \RandomCoeff{Beta}{1}{10} \ctxlua{tex.print(a)} %\CoeffBeta \stoptext %%% end random-coeff.tex Thanks in advance for any suggestion or hint. Best regards: OK ___ 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 ___ ___ 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] How to define a command...
On Thu, Jan 05 2012, Otared Kavian wrote: \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} % \csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... \setuprandomize[2012] \define[3]\RandomCoeff{% \expandafter\def\csname Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} \starttext \RandomCoeff{Alpha}{1}{10} \RandomCoeff{Beta}{2}{20} \CoeffAlpha \CoeffBeta \stoptext -- Peter ___ 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] How to define a command...
Am 05.01.2012 um 21:17 schrieb Peter Münster: On Thu, Jan 05 2012, Otared Kavian wrote: \define[3]\RandomCoeff{% \ctxlua{a = math.random(#2,#3)} %\csname{Coeff#1}\endcsname{\ctxlua{tex.print(a)}} %% this line does not work as expected... \setuprandomize[2012] \define[3]\RandomCoeff{% \expandafter\def\csname Coeff#1\endcsname{\ctxlua{tex.print(math.random(#2,#3))}}} \setvalue{Coeff#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 ___