Quantcast
Channel: LuaLaTeX for dummies: basic directlua use - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

LuaLaTeX for dummies: basic directlua use

$
0
0

I'm trying to understand the basics of lua programming within LaTeX.

I have this simple function in a file called luatest.lua:

function fact (n)  if n == 0 then    return 1  else    return n * fact(n-1)  endend

Then I have an usual .tex file:

\documentclass{article}\directlua{dofile("luatest.lua")}\newcommand{\myluafact}[1]{\directlua{function fact(#1)}}  \begin{document}  test \myluafact{5}\end{document}

Which unfortunately does not compile. It seems to me that I'm missing some tex.sprint() somewhere, but where?


Viewing all articles
Browse latest Browse all 2

Trending Articles