Hello, I'm trying to include a gcd function using lua in a sty file.
Here is the code of euclide.sty :

   \RequirePackage{ifluatex,luacode,luatextra}
   \ifluatex
        \begin{luacode}
            function euclide(a,b)
                if a < b then a,b = b,a end
                r = a-math.floor(a/b)*b
                if r == 0 then tex.print(b)    else euclide(b,r) end
            end
        \end{luacode}
        \newcommand{\euclide}[2]{\luaexec{euclide(#1,#2)}}
   \fi

Here is the texfile code :

   \documentclass[10pt,oneside]{article}
   \usepackage{euclide}

   \begin{document}
   \euclide{435}{630}
   \end{document}

The lualatex compilation give me errors :

   Runaway argument?
   ! File ended while scanning use of \luacode@grab@lines.
   <inserted text>
   \par
   l.4

   I suspect you have forgotten a `}', causing me
   to read past where you wanted me to stop.
   I'll try to recover; but if the error is serious,
   you'd better type `E' or `X' now and fix your file.


   ! LaTeX Error: Missing \begin{document}.

Can somebody tell me what's wrong in my code ?
Thanks, MB.

Reply via email to