Dear Dalyoung,

I am not sure what the issue is; but as a workaround it seems that using \ctxlua works:

___________________________________________________
\starttext

\startluacode
  function makeHead(a)
    local n = #a
   
    context.HL()
    for i = 1, n  do
      context.NC() context(a[i])
    end
    context.NC()context.AR()
    context.HL()
  end
\stopluacode

\starttabulate[|mcw(1cm)|mcw(1cm)|mcw(1cm)|mcw(1cm)|]
    \ctxlua{local a = {"x","y","z","(x\\to y)"}; makeHead(a)}
\stoptabulate

\stoptext
___________________________________________________

Cheers,
Florent

Le ven. 3 janv. 2025 à 15:58, Jeong Dal via ntg-context <ntg-context@ntg.nl> a écrit :
Dear all,

I got the error "You can't use '\prevdepth' in restricted horizontal mode” when I compile the following code.

If I remove “\starttabulete…  \stoptabulate”, then no errors, but the out put is not the form of table.

How can I fix this error?

Thank you.

Best regards,

Dalyoung

\starttext

\startluacode
function makeHead(a)
local n = #a
context.HL()
for i = 1, n do
context.NC() context(a[i])
end
context.NC()context.AR()
context.HL()
end
\stopluacode

%\starttabulate[|mcw(1cm)|mcw(1cm)|mcw(1cm)|mcw(1cm)|]
\startluacode
local a = {"x","y","z","(x\\to y)"}
makeHead(a)
\stopluacode
%\stoptabulate

\stoptext


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________