* problems with \hbox inside lua @ 2010-12-23 12:57 Mojca Miklavec 2010-12-23 13:03 ` luigi scarso 2010-12-23 13:09 ` Peter Münster 0 siblings, 2 replies; 9+ messages in thread From: Mojca Miklavec @ 2010-12-23 12:57 UTC (permalink / raw) To: mailing list for ConTeXt users Dear list, I cannot figure out what I am doing wrong here. If I remove \hbox, it works fine, but I would like to draw a table. \starttext \startluacode function draw_table(unicode_start,n_columns) for i=0,0xF do tex.print('\\dontleavehmode\\definedfont[Serif at 20pt]\\kern0pt') for j=0,n_columns do --tex.print('\\hbox{ \\char %d }', unicode_start+i*16+j) tex.print('\\hbox to 1.5em{\\hss %s \\hss}', unicode.utf8.char(unicode_start+i*16+j)) end tex.print('\\crlf') end end draw_table(0x00C0,4) \stopluacode \stoptext Any hints welcome. Thanks, Mojca ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 12:57 problems with \hbox inside lua Mojca Miklavec @ 2010-12-23 13:03 ` luigi scarso 2010-12-23 13:09 ` Peter Münster 1 sibling, 0 replies; 9+ messages in thread From: luigi scarso @ 2010-12-23 13:03 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Dec 23, 2010 at 1:57 PM, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote: > Dear list, > > I cannot figure out what I am doing wrong here. If I remove \hbox, it > works fine, but I would like to draw a table. > > \starttext > \startluacode > function draw_table(unicode_start,n_columns) > for i=0,0xF do > tex.print('\\dontleavehmode\\definedfont[Serif at 20pt]\\kern0pt') > for j=0,n_columns do > --tex.print('\\hbox{ \\char %d }', unicode_start+i*16+j) > tex.print('\\hbox to 1.5em{\\hss %s \\hss}', > unicode.utf8.char(unicode_start+i*16+j)) > end > tex.print('\\crlf') > end > end > > draw_table(0x00C0,4) > \stopluacode > \stoptext > > Any hints welcome. I don't know but for the moment this works \starttext \startluacode function draw_table(unicode_start,n_columns) for i=0,0xF do tex.print('\\dontleavehmode\\definedfont[Serif at 20pt]\\kern0pt') for j=0,n_columns do local d = string.format( "\\hbox to 1.5em{\\hss \%s \\hss}",unicode.utf8.char(unicode_start+i*16+j)) tex.print(d) end tex.print('\\crlf') end end draw_table(0x00C0,4) \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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 12:57 problems with \hbox inside lua Mojca Miklavec 2010-12-23 13:03 ` luigi scarso @ 2010-12-23 13:09 ` Peter Münster 2010-12-23 13:36 ` luigi scarso 1 sibling, 1 reply; 9+ messages in thread From: Peter Münster @ 2010-12-23 13:09 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Dec 23 2010, Mojca Miklavec wrote: > tex.print('\\hbox to 1.5em{\\hss %s \\hss}', tex.print() does not handle the %s. context() does. So just replace tex.print() by context(). Peter -- Contact information: http://pmrb.free.fr/contact/ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 13:09 ` Peter Münster @ 2010-12-23 13:36 ` luigi scarso 2010-12-23 14:52 ` Hans Hagen 0 siblings, 1 reply; 9+ messages in thread From: luigi scarso @ 2010-12-23 13:36 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Dec 23, 2010 at 2:09 PM, Peter Münster <pmlists@free.fr> wrote: > On Thu, Dec 23 2010, Mojca Miklavec wrote: > >> tex.print('\\hbox to 1.5em{\\hss %s \\hss}', > > tex.print() does not handle the %s. context() does. > > So just replace tex.print() by context(). Right, this also works \starttext \startluacode function draw_table(unicode_start,n_columns) for i=0,0xF do tex.print('\\dontleavehmode\\definedfont[Serif at 20pt]\\kern0pt') for j=0,n_columns do context('\\hbox to 1.5em{\\hss %s \\hss}',unicode.utf8.char(unicode_start+i*16+j)) end tex.print('\\crlf') end end draw_table(0x00C0,4) \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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 13:36 ` luigi scarso @ 2010-12-23 14:52 ` Hans Hagen 2010-12-23 17:06 ` Mojca Miklavec 0 siblings, 1 reply; 9+ messages in thread From: Hans Hagen @ 2010-12-23 14:52 UTC (permalink / raw) To: mailing list for ConTeXt users On 23-12-2010 2:36, luigi scarso wrote: > On Thu, Dec 23, 2010 at 2:09 PM, Peter Münster<pmlists@free.fr> wrote: >> On Thu, Dec 23 2010, Mojca Miklavec wrote: >> >>> tex.print('\\hbox to 1.5em{\\hss %s \\hss}', >> >> tex.print() does not handle the %s. context() does. >> >> So just replace tex.print() by context(). > Right, this also works > > \starttext > \startluacode > function draw_table(unicode_start,n_columns) > for i=0,0xF do > tex.print('\\dontleavehmode\\definedfont[Serif at 20pt]\\kern0pt') > for j=0,n_columns do > context('\\hbox to 1.5em{\\hss %s > \\hss}',unicode.utf8.char(unicode_start+i*16+j)) > end > tex.print('\\crlf') > end > end > > draw_table(0x00C0,4) > \stopluacode > \stoptext without backslashes: function draw_table(unicode_start,n_columns) context.start() context.definedfont{"Serif at 20pt"} for i=0,0xF do context.dontleavehmode() for j=0,n_columns do -- context('\\hbox to 1.5em{\\hss %s\\hss}',unicode.utf8.char(unicode_start+i*16+j)) context.hbox(false,"to 1.5em") context.bgroup() context.hss() context(unicode.utf8.char(unicode_start+i*16+j)) context.hss() context.egroup() end context.crlf() end context.stop() end cleaner: function draw_table(unicode_start,n_columns) context.start() context.definedfont { "Serif at 20pt" } context.starttabulate { string.format("*{%s}{|w(1.5em)}|",n_columns+1) } for i=0,0xF do context.NC() for j=0,n_columns do context(unicode.utf8.char(unicode_start+i*16+j)) context.NC() end context.NR() end context.stoptabulate() context.stop() end Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 14:52 ` Hans Hagen @ 2010-12-23 17:06 ` Mojca Miklavec 2010-12-23 17:10 ` Mojca Miklavec 2010-12-23 19:01 ` luigi scarso 0 siblings, 2 replies; 9+ messages in thread From: Mojca Miklavec @ 2010-12-23 17:06 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Dec 23, 2010 at 15:52, Hans Hagen wrote: > > cleaner: > > function draw_table(unicode_start,n_columns) > context.start() > context.definedfont { "Serif at 20pt" } > context.starttabulate { string.format("*{%s}{|w(1.5em)}|",n_columns+1) } Great, thanks! (I wanted to create a proper table at some point, but didn't take time to think about how to create an arbitrary number of columns.) But then I have another question: how can I use \HL and \VL? The following code doesn't create any line at all: function draw_table(unicode_start,n_columns) context.bgroup() context.definedfont { "Serif at 20pt" } context.starttable { string.format("*{%s}{|w(1.2em)}|", n_columns) } for i=0,0xF do context.VL() for j=0,n_columns-1 do context(unicode.utf8.char(unicode_start+i+16*j)) context.VL() end context.NR() context.HL() end context.stoptable() context.egroup() end Mojca PS: I still don't know the reason why my example fails, but I will ignore that for a moment since this does the job as well. ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 17:06 ` Mojca Miklavec @ 2010-12-23 17:10 ` Mojca Miklavec 2010-12-23 19:01 ` luigi scarso 1 sibling, 0 replies; 9+ messages in thread From: Mojca Miklavec @ 2010-12-23 17:10 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Dec 23, 2010 at 18:06, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote: > > But then I have another question: how can I use \HL and \VL? The > following code doesn't create any line at all: I'm sorry. I was compiling the wrong file. Mojca ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 17:06 ` Mojca Miklavec 2010-12-23 17:10 ` Mojca Miklavec @ 2010-12-23 19:01 ` luigi scarso 2010-12-23 20:14 ` Peter Münster 1 sibling, 1 reply; 9+ messages in thread From: luigi scarso @ 2010-12-23 19:01 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Dec 23, 2010 at 6:06 PM, Mojca Miklavec <mojca.miklavec.lists@gmail.com> wrote: > PS: I still don't know the reason why my example fails catcode , I suppose -- luigi ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: problems with \hbox inside lua 2010-12-23 19:01 ` luigi scarso @ 2010-12-23 20:14 ` Peter Münster 0 siblings, 0 replies; 9+ messages in thread From: Peter Münster @ 2010-12-23 20:14 UTC (permalink / raw) To: mailing list for ConTeXt users On Thu, Dec 23 2010, luigi scarso wrote: > > PS: I still don't know the reason why my example fails > catcode , I suppose Indeed. The %-sign starts a comment in TeX. \starttext \startluacode tex.print("\\hbox{ %s }", "a string") \stopluacode \stoptext is nearly the same as \starttext \hbox{ %s } a string \stoptext In both cases, the error message is: ! Missing } inserted. Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/ ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-12-23 20:14 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-12-23 12:57 problems with \hbox inside lua Mojca Miklavec 2010-12-23 13:03 ` luigi scarso 2010-12-23 13:09 ` Peter Münster 2010-12-23 13:36 ` luigi scarso 2010-12-23 14:52 ` Hans Hagen 2010-12-23 17:06 ` Mojca Miklavec 2010-12-23 17:10 ` Mojca Miklavec 2010-12-23 19:01 ` luigi scarso 2010-12-23 20:14 ` Peter Münster
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).