ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* How to use tex.print in ctxlua
@ 2017-03-19 15:30 Otared Kavian
  2017-03-19 15:39 ` josephcanedo
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Otared Kavian @ 2017-03-19 15:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 857 bytes --]

Hi,

I would like to print in a text the values of a array computed in a  \startluacode …. \stopluacode combination.
How can I do it properly? Please have a look at the example below and its output, which is not satisfactory because the right parenthesis is separated from the number by a space. How can I suppress this unwanted space? 
For instance I get (1, 103 ) instead of (1, 103).

Thanks in advance for any help,
Best regards: OK

%%% begin ctxlua-print.tex
\starttext
\startluacode
	n = 6 ;
	vecteurX = {} ;
	for i = 1,n do
		vecteurX[i] = i ;
	end
	vecteurY = {} ;
	for i = 1,n do
		vecteurY[i] = 3*vecteurX[i] + 100 ;
	end
	for i = 1,n do
		context("(") 
		tex.print(vecteurX[i]) 
		context(", ") 
		tex.print(vecteurY[i])
		tex.print(")")
		context.par()
	end
\stopluacode
\stoptext
%%% begin ctxlua-print.tex


[-- Attachment #2: ctxlua-print.pdf --]
[-- Type: application/pdf, Size: 5947 bytes --]

[-- Attachment #3: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:30 How to use tex.print in ctxlua Otared Kavian
@ 2017-03-19 15:39 ` josephcanedo
  2017-03-19 15:51 ` Thomas A. Schmitz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 13+ messages in thread
From: josephcanedo @ 2017-03-19 15:39 UTC (permalink / raw)
  To: Otared Kavian, mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1155 bytes --]

Hi,

I think you can use tex.write() instead of tex.print() (pretty much the same as in lua io functions).
Hope this helps

Joseph

De : Otared Kavian
Envoyé le :dimanche 19 mars 2017 16:31
À : mailing list for ConTeXt users
Objet :[NTG-context] How to use tex.print in ctxlua

Hi,

I would like to print in a text the values of a array computed in a  \startluacode …. \stopluacode combination.
How can I do it properly? Please have a look at the example below and its output, which is not satisfactory because the right parenthesis is separated from the number by a space. How can I suppress this unwanted space? 
For instance I get (1, 103 ) instead of (1, 103).

Thanks in advance for any help,
Best regards: OK

%%% begin ctxlua-print.tex
\starttext
\startluacode
	n = 6 ;
	vecteurX = {} ;
	for i = 1,n do
		vecteurX[i] = i ;
	end
	vecteurY = {} ;
	for i = 1,n do
		vecteurY[i] = 3*vecteurX[i] + 100 ;
	end
	for i = 1,n do
		context("(") 
		tex.print(vecteurX[i]) 
		context(", ") 
		tex.print(vecteurY[i])
		tex.print(")")
		context.par()
	end
\stopluacode
\stoptext
%%% begin ctxlua-print.tex



[-- Attachment #1.2: Type: text/html, Size: 4479 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:30 How to use tex.print in ctxlua Otared Kavian
  2017-03-19 15:39 ` josephcanedo
@ 2017-03-19 15:51 ` Thomas A. Schmitz
  2017-03-19 16:39   ` Otared Kavian
  2017-03-19 17:28   ` Hans Hagen
  2017-03-19 15:56 ` Pablo Rodriguez
  2017-03-19 16:37 ` Aditya Mahajan
  3 siblings, 2 replies; 13+ messages in thread
From: Thomas A. Schmitz @ 2017-03-19 15:51 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 19.03.2017 16:30, Otared Kavian wrote:
> I would like to print in a text the values of a array computed in a  \startluacode …. \stopluacode combination.
> How can I do it properly? Please have a look at the example below and its output, which is not satisfactory because the right parenthesis is separated from the number by a space. How can I suppress this unwanted space?
> For instance I get (1, 103 ) instead of (1, 103).

Otared,

is there a reason why you don't use context(vecteurY[i]) and 
context(vecteurX[i])? This gets rid of the spurious space for me (and 
makes your code more consistent). But I assume you must have tried it 
because you use the "context" command in other places of your lua code.

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:30 How to use tex.print in ctxlua Otared Kavian
  2017-03-19 15:39 ` josephcanedo
  2017-03-19 15:51 ` Thomas A. Schmitz
@ 2017-03-19 15:56 ` Pablo Rodriguez
  2017-03-19 16:42   ` Otared Kavian
  2017-03-19 16:53   ` Thomas A. Schmitz
  2017-03-19 16:37 ` Aditya Mahajan
  3 siblings, 2 replies; 13+ messages in thread
From: Pablo Rodriguez @ 2017-03-19 15:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 03/19/2017 04:30 PM, Otared Kavian wrote:
> Hi,
> 
> I would like to print in a text the values of a array computed in a
> \startluacode …. \stopluacode combination.
> How can I do it properly? Please have a look at the example below
> and its output, which is not satisfactory because the right parenthesis is
> separated from the number by a space. How can I suppress this unwanted
> space?
> For instance I get (1, 103 ) instead of (1, 103).

Hi Otared,

is there any reason not to use the following instead of your way below?

  for i = 1,n do
    tex.print("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
  end

> 	for i = 1,n do
> 		context("(") 
> 		tex.print(vecteurX[i]) 
> 		context(", ") 
> 		tex.print(vecteurY[i])
> 		tex.print(")")
> 		context.par()
> 	end

I think this is shorter and clearer (to me, at least).

Just in case it helps,

Pablo
-- 
http://www.ousia.tk
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:30 How to use tex.print in ctxlua Otared Kavian
                   ` (2 preceding siblings ...)
  2017-03-19 15:56 ` Pablo Rodriguez
@ 2017-03-19 16:37 ` Aditya Mahajan
  2017-03-19 16:46   ` Otared Kavian
  3 siblings, 1 reply; 13+ messages in thread
From: Aditya Mahajan @ 2017-03-19 16:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 512 bytes --]

On Sun, 19 Mar 2017, Otared Kavian wrote:

> Hi,
>
> I would like to print in a text the values of a array computed in a  \startluacode …. \stopluacode combination.
> How can I do it properly? Please have a look at the example below and its output, which is not satisfactory because the right parenthesis is separated from the number by a space. How can I suppress this unwanted space?
> For instance I get (1, 103 ) instead of (1, 103).

use context(....) to print instead of tex.print(...).

Aditya

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:51 ` Thomas A. Schmitz
@ 2017-03-19 16:39   ` Otared Kavian
  2017-03-19 17:28   ` Hans Hagen
  1 sibling, 0 replies; 13+ messages in thread
From: Otared Kavian @ 2017-03-19 16:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Thomas,

Thanks for your answer.
Indeed I did not know that I could use directly 
	context(vecteurY[i])
Now this solves my problem!

Best regards: OK

> On 19 Mar 2017, at 16:51, Thomas A. Schmitz <thomas.schmitz@uni-bonn.de> wrote:
> 
> On 19.03.2017 16:30, Otared Kavian wrote:
>> I would like to print in a text the values of a array computed in a  \startluacode …. \stopluacode combination.
>> How can I do it properly? Please have a look at the example below and its output, which is not satisfactory because the right parenthesis is separated from the number by a space. How can I suppress this unwanted space?
>> For instance I get (1, 103 ) instead of (1, 103).
> 
> Otared,
> 
> is there a reason why you don't use context(vecteurY[i]) and context(vecteurX[i])? This gets rid of the spurious space for me (and makes your code more consistent). But I assume you must have tried it because you use the "context" command in other places of your lua code.
> 
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:56 ` Pablo Rodriguez
@ 2017-03-19 16:42   ` Otared Kavian
  2017-03-19 16:53   ` Thomas A. Schmitz
  1 sibling, 0 replies; 13+ messages in thread
From: Otared Kavian @ 2017-03-19 16:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Pablo,

Thanks for your answer: actually I did not know that it is possible to concatenate so easily in lua… Your solution is indeed simpler than what I did and solves also the problem of the spurious space before the closing parenthesis.

Best regards: OK

> On 19 Mar 2017, at 16:56, Pablo Rodriguez <oinos@gmx.es> wrote:
> 
> On 03/19/2017 04:30 PM, Otared Kavian wrote:
>> Hi,
>> 
>> I would like to print in a text the values of a array computed in a
>> \startluacode …. \stopluacode combination.
>> How can I do it properly? Please have a look at the example below
>> and its output, which is not satisfactory because the right parenthesis is
>> separated from the number by a space. How can I suppress this unwanted
>> space?
>> For instance I get (1, 103 ) instead of (1, 103).
> 
> Hi Otared,
> 
> is there any reason not to use the following instead of your way below?
> 
>  for i = 1,n do
>    tex.print("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
>  end
> 
>> 	for i = 1,n do
>> 		context("(") 
>> 		tex.print(vecteurX[i]) 
>> 		context(", ") 
>> 		tex.print(vecteurY[i])
>> 		tex.print(")")
>> 		context.par()
>> 	end
> 
> I think this is shorter and clearer (to me, at least).
> 
> Just in case it helps,
> 
> Pablo
> -- 
> http://www.ousia.tk
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 16:37 ` Aditya Mahajan
@ 2017-03-19 16:46   ` Otared Kavian
  2017-03-19 16:56     ` Wolfgang Schuster
  0 siblings, 1 reply; 13+ messages in thread
From: Otared Kavian @ 2017-03-19 16:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Aditya,

Thanks, as Thomas, Pablo and you mentioned the right way is to use context() instead of tex.print()
Actually I just saw that one can also concatenate with context() as in:

	context("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")

which is equivalent to
	tex.print("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")

Best regards: OK

> On 19 Mar 2017, at 17:37, Aditya Mahajan <adityam@umich.edu> wrote:
> 
> On Sun, 19 Mar 2017, Otared Kavian wrote:
> 
>> Hi,
>> 
>> I would like to print in a text the values of a array computed in a  \startluacode …. \stopluacode combination.
>> How can I do it properly? Please have a look at the example below and its output, which is not satisfactory because the right parenthesis is separated from the number by a space. How can I suppress this unwanted space?
>> For instance I get (1, 103 ) instead of (1, 103).
> 
> use context(....) to print instead of tex.print(...).
> 
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:56 ` Pablo Rodriguez
  2017-03-19 16:42   ` Otared Kavian
@ 2017-03-19 16:53   ` Thomas A. Schmitz
  1 sibling, 0 replies; 13+ messages in thread
From: Thomas A. Schmitz @ 2017-03-19 16:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 19.03.2017 16:56, Pablo Rodriguez wrote:
> is there any reason not to use the following instead of your way below?
>
>   for i = 1,n do
>     tex.print("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
>   end

I don't think that this is a good approach. Refer to chapter 11.6 of 
"Programming in Lua" to see why string concatenation is computationally 
expensive. (It wouldn't matter in this simple case, but it's not a good 
habit to develop.)

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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 16:46   ` Otared Kavian
@ 2017-03-19 16:56     ` Wolfgang Schuster
  2017-03-19 17:17       ` Otared Kavian
  2017-03-19 17:26       ` Hans Hagen
  0 siblings, 2 replies; 13+ messages in thread
From: Wolfgang Schuster @ 2017-03-19 16:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 742 bytes --]


> Otared Kavian <mailto:otared@gmail.com>
> 19. März 2017 um 17:46via Postbox 
> <https://www.postbox-inc.com/?utm_source=email&utm_medium=sumlink&utm_campaign=reach>
> Hi Aditya,
>
> Thanks, as Thomas, Pablo and you mentioned the right way is to use 
> context() instead of tex.print()
> Actually I just saw that one can also concatenate with context() as in:
>
> context("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
>
> which is equivalent to
> tex.print("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
You can use the string.formatters function for this.

\starttext

\startluacode

local string_a = "12"
local string_b = "23"

context(string.formatters["(%s,%s)"](string_a,string_b))

\stopluacode

\stoptext

Wolfgang

[-- Attachment #1.2: Type: text/html, Size: 1896 bytes --]

[-- Attachment #2: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 16:56     ` Wolfgang Schuster
@ 2017-03-19 17:17       ` Otared Kavian
  2017-03-19 17:26       ` Hans Hagen
  1 sibling, 0 replies; 13+ messages in thread
From: Otared Kavian @ 2017-03-19 17:17 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Wolfgang,

Thanks for letting me know the command string.formatters[….]. It allows to avoid the concatenation, which is to avoid as Thomas points out.

Now that I have solved the issue with the spurious space, I have one more question: how could one print the values (vecteuX[i],vecteurY[i]) in a tabulated environment so that when for instance one has 15 such values, one gets 3 lines with 5 values on each line?

Best regards: OK

> On 19 Mar 2017, at 17:56, Wolfgang Schuster <schuster.wolfgang@gmail.com> wrote:
> 
> 
>> Otared Kavian 19. März 2017 um 17:46 via Postbox
>> Hi Aditya,
>> 
>> Thanks, as Thomas, Pablo and you mentioned the right way is to use context() instead of tex.print()
>> Actually I just saw that one can also concatenate with context() as in:
>> 
>> context("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
>> 
>> which is equivalent to
>> tex.print("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
> You can use the string.formatters function for this.
> 
> \starttext
> 
> \startluacode
> 
> local string_a = "12"
> local string_b = "23"
> 
> context(string.formatters["(%s,%s)"](string_a,string_b))
> 
> \stopluacode
> 
> \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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 16:56     ` Wolfgang Schuster
  2017-03-19 17:17       ` Otared Kavian
@ 2017-03-19 17:26       ` Hans Hagen
  1 sibling, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2017-03-19 17:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 3/19/2017 5:56 PM, Wolfgang Schuster wrote:
>
>> Otared Kavian <mailto:otared@gmail.com>
>> 19. März 2017 um 17:46via Postbox
>> <https://www.postbox-inc.com/?utm_source=email&utm_medium=sumlink&utm_campaign=reach>
>> Hi Aditya,
>>
>> Thanks, as Thomas, Pablo and you mentioned the right way is to use
>> context() instead of tex.print()
>> Actually I just saw that one can also concatenate with context() as in:
>>
>> context("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
>>
>> which is equivalent to
>> tex.print("(" .. vecteurX[i] .. ", " .. vecteurY[i] .. ")\\par")
> You can use the string.formatters function for this.
>
> \starttext
>
> \startluacode
>
> local string_a = "12"
> local string_b = "23"
>
> context(string.formatters["(%s,%s)"](string_a,string_b))
>
> \stopluacode
>
> \stoptext

\starttext

\startluacode

local string_a = "12"
local string_b = "23"

context("(%s,%s)",string_a,string_b)

context.formatted.bold("(%s,%s)",string_a,string_b)

\stopluacode

\stoptext


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: How to use tex.print in ctxlua
  2017-03-19 15:51 ` Thomas A. Schmitz
  2017-03-19 16:39   ` Otared Kavian
@ 2017-03-19 17:28   ` Hans Hagen
  1 sibling, 0 replies; 13+ messages in thread
From: Hans Hagen @ 2017-03-19 17:28 UTC (permalink / raw)
  To: ntg-context

On 3/19/2017 4:51 PM, Thomas A. Schmitz wrote:
> On 19.03.2017 16:30, Otared Kavian wrote:
>> I would like to print in a text the values of a array computed in a
>> \startluacode …. \stopluacode combination.
>> How can I do it properly? Please have a look at the example below and
>> its output, which is not satisfactory because the right parenthesis is
>> separated from the number by a space. How can I suppress this unwanted
>> space?
>> For instance I get (1, 103 ) instead of (1, 103).
>
> Otared,
>
> is there a reason why you don't use context(vecteurY[i]) and
> context(vecteurX[i])? This gets rid of the spurious space for me (and
> makes your code more consistent). But I assume you must have tried it
> because you use the "context" command in other places of your lua code.

always try to use the context command because it deals with catcodes and 
is more robust than a tex.(s)print

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | 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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2017-03-19 17:28 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-19 15:30 How to use tex.print in ctxlua Otared Kavian
2017-03-19 15:39 ` josephcanedo
2017-03-19 15:51 ` Thomas A. Schmitz
2017-03-19 16:39   ` Otared Kavian
2017-03-19 17:28   ` Hans Hagen
2017-03-19 15:56 ` Pablo Rodriguez
2017-03-19 16:42   ` Otared Kavian
2017-03-19 16:53   ` Thomas A. Schmitz
2017-03-19 16:37 ` Aditya Mahajan
2017-03-19 16:46   ` Otared Kavian
2017-03-19 16:56     ` Wolfgang Schuster
2017-03-19 17:17       ` Otared Kavian
2017-03-19 17:26       ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).