Was kann ich mit dem Programm „LuaTeX“ anfangen?0
Im letzten Artikel habe ich dir gezeigt, wie du LuaTeX kompilieren kannst. Nur was fangen wir mit dem Ergebnis an? Es ist eine harmlose Datei namens „luatex“. Ein kleiner Blick auf die Hilfeseite verrät uns schon das Wichtigste:
/tmp/luatex/trunk/build/texk/web2c$ ./luatex --help Usage: luatex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS] or: luatex --lua=FILE [OPTION]... \FIRST-LINE or: luatex --lua=FILE [OPTION]... &FMT ARGS Run LuaTeX on TEXNAME, usually creating TEXNAME.pdf. Any remaining COMMANDS are processed as luatex input, after TEXNAME is read. Alternatively, if the first non-option argument begins with a backslash, luatex interprets all non-option arguments as an input line. Alternatively, if the first non-option argument begins with a &, the next word is taken as the FMT to read, overriding all else. Any remaining arguments are processed as above. If no arguments or options are specified, prompt for input. --lua=FILE the lua initialization file --nosocket disable the luasocket (network) library --safer disable easily exploitable lua commands --fmt=FORMAT load the format file FORMAT --ini be initex, for dumping formats --help display this help and exit --version output version information and exit Alternate behaviour models can be obtained by special switches --luaonly run a lua file, then exit --luaconly byte-compile a lua file, then exit Email bug reports to dev-luatex@ntg.nl.Auf den ersten Blick sieht es genau so aus, wie ein PDFTeX-Binary. Doch die letzten beiden Optionen verraten, dass in dem Programm noch viel mehr steckt: ein Lua-Interpreter. Ruft man LuaTeX mit dem Parameter
--luaonly auf, so erhält man einen normalen Lua-Interpreter. Fast normal, denn er ist gegenüber einem Standardinterpreter erweitert. So sind die Bibliotheken luazip, luafilesystem, lzlib, md5, luasocket und lpeg fest eingebunden. Das heißt, du kannst diese Fähigkeiten direkt nutzen. Beispiele dafür werde ich in anderen Beiträgen noch detailliert geben. Aber nicht nur das, im TeX-Modus verhält LuaTeX sich so ähnlich wie PDFTeX, aber du kannst mit einem einfachen Kommando direkt in den LuaTeX Interpreter springen:
Hallo Welt! Du benutzt \directlua{ tex.sprint(os.type) }, oder?
ergibt bei mir „Hallo Welt! Du benutzt unix, oder?“. In dem Beispiel siehst du schon, wie mit \directlua{...} in den Lua Modus geschaltet wird. Dort stehen dir dann alle Möglichkeiten von Lua zur Verfügung.

Kommentar schreiben