Changes

Jump to navigation Jump to search
m
Improve minor errors in code
-- Print a countdown '10, 8, ..., 0!'
-- `..` is Lua for string concatenation
-- Look! we can use # and $ with impunity!
for i = 10, 2, -2 do
context(i .. ", ")
end
context("0!")  -- \\par is equivalent to a blank line in the input -- (Notice the escaped backslash: TeX won't mind the above comment.) context.par() 
-- Look! we can use # and $ with impunity!
context("Unless we print them, then we must \\#\\$\\& print the escape themcharacters, too.")
\stopluacode
</texcode>
<texcode>
\startluacode
name = "Jane"date = "today"context("Hello %s, how are you %s?", "Jane"name, "today"date)-- becomes Becomes 'Hello Jane, how are youtoday?'
\stopluacode
</texcode>
[[Category:LuaTeX]]
[[Category:Programming]]
/texcode>
 
=== Namespaces ===
 
It is a good habit to put your custom-defined functions in their own namespace. The traditional namespace for this is

Navigation menu