Lua is a powerful, fast, lightweight, embeddable scripting language.

learn more… | top users | synonyms

2
votes
0answers
26 views

LuaLaTeX error - file ended while scanning use of \luacode@grab@lines (?) [closed]

Even the reduced-to-the-absolute-minimum-file: \documentclass{scrreprt} \usepackage{luacode} \begin{document} \begin{luacode*} tex.sprint(1) \end{luacode*} \end{document} yields the error: ! ...
10
votes
2answers
177 views

Lua syntax for the listings package

I'm preparing some slides with Beamer and I've just discovered that the listings package, which otherwise does exactly what I want, is missing the syntax for the Lua language. How can I configure ...
3
votes
2answers
85 views

Accessing MySQL or SQLite from Lua(La)TeX

I thought it would be possible to access MySQL or SQLite from Lua(La)TeX, but couldn't google up anything on the topic. Please give me pointers to: Snippets / Examples / Documentation on that, if ...
4
votes
2answers
158 views

Bouncing ball over time

I have this clumsy code to plot the height of a bouncing ball over time. Is there a possibility for optimization? Perhaps writing the functions directly with the tikz math library? Also at the moment ...
0
votes
0answers
98 views

Execute lua file out of a pdf, lua doesn´t execute “io.open” command

I would like to run program out of the compiled pdf via link. \documentclass[12pt]{article} \usepackage[colorlinks, linkcolor = black, citecolor = black, filecolor = black, urlcolor = ...
2
votes
1answer
97 views

How to let Lua see the contents of a variable rather than just the variable name in ConTeXt?

I have some Lua code which searches for "①" and "②" within some text and prints only the text displayed between: \startluacode userdata = userdata or {} function userdata.printbetween(str, ...
12
votes
1answer
186 views

How can I dump Lua code to a format file?

From this format: %% testformat.ini \input plain \directlua {tex.enableprimitives('', tex.extraprimitives())} \directlua { testFunction = function () tex.print("This was print by Lua's ...
6
votes
2answers
263 views

More than one width of a glyph in LaTeX or LuaLatex

I don't know where I can ask about it. I have font with 2 or 3 versions of letter 'a'. How I can put this information to LuaLaTeX, LaTeX etc.? When the paragraph are breaking/making LaTeX made ...
7
votes
1answer
172 views

Strange interaction between fontspec, lua and pgfplots

While trying to combine some Lua code with plots written in pgfplots something went completely wrong. I have no idea what causes the problem, as the error message is a bit opaque to me. Here is the ...
24
votes
1answer
393 views

Bad interaction between fontspec and some lua code that performs string-related search and replace operations

Update 2013/05/28: The selnolig package is now on the CTAN. Comments and critiques always welcome! If you wish to contact me about any aspects of the package, please use the email address that's given ...
12
votes
2answers
3k views

How to properly install and use a new font with LuaLaTeX?

I have problems trying to get new fonts to work when compiling with LuaLaTeX. I'm working on Mac and use TexShop (with the MacTeX package). It goes like this: I downloaded for example the Cardo ...
14
votes
4answers
636 views

How to read a file with luatex

I tried to read a file with lua and set the content as normal text in my document, but I didn't worked it out. Here my code: \documentclass{scrartcl} \usepackage{luatextra} \usepackage{filecontents} ...
8
votes
1answer
683 views

Speeding up latex/lua/tikz

I have a rather large LaTeX document in that it generates a lot of LaTeX code using lua (small .tex file on disk but large amount of generated LaTeX code). It is very slow to compile and takes about 1 ...
7
votes
1answer
816 views

Search & Replace Script for TeXworks

Does anyone have an example for a search & replace lua script that I can use with TeXworks. I have a rather large document here (about 3'000 pages DIN A5) which I need to update continously. To ...
5
votes
1answer
317 views

Hacking Animate

While babysitting my kids yesterday I played little bit with one of my favorite LaTeX package PSTricks. Naturally I started toying with something more "advanced" so a toyed a bit with animations. On ...
10
votes
3answers
1k views

Matrix multiplication (and other operations) macro using lua module

I am hoping to be able to create a macro to multiply matrices using a lua module. The module is here: https://raw.github.com/davidm/lua-matrix/master/lua/matrix.lua As suggested to me in a previous ...
4
votes
2answers
283 views

Why does \luaexec work but the luacode environment doesn't?

The following code can be compiled by lualatex (Version beta-0.70.1-2011061410 (rev 4277)) correctly. But if I use \begin{luacode} ... \end{luacode} environment to replace the \luaexec{...} command, ...
7
votes
1answer
221 views

Pass parameter to texlua script

Calling texlua file.lua on the command line runs the file through a Lua interpreter. Is it possible to give arguments to the script? For instance, in -- file.lua io.write(3.4 + 5.6) io.write("\n") ...
1
vote
0answers
343 views

Debugging Lua in LuaLatex with LDT [closed]

LDT is an IDE for lua based on eclipse. It is quite nice and the best free lua debugger I've seen(I've just stumbled upon it the last 2 days or so). It took me a bit to get setup properly but because ...
7
votes
2answers
598 views

How to check if a value is not equal using TeX conditionals?

I have a value defined in a macro, e.g.: \mymacro{apple} I need to check if a value does not equal a string, e.g.: IF #1 NOT EQUAL TO "apple" THEN PRINT "It is not a apple, it is #1." FI I ...
11
votes
3answers
314 views

In which order is Lua Code in LuaTeX being processed

Can someone help me understand the order in which LuaTeX documents are being processed? From what I've understood, the order is the following: the code is being read, top to bottom when the ...
6
votes
3answers
428 views

How to do a 'printline' in LuaTeX

I have just started exploring the world of LuaTeX and wanted to write a piece of code, that prints a name to a new line in the document. \directlua{ for i=1,3,1 do tex.print("FOO") end } which ...
4
votes
1answer
380 views

How to use string.find from Lua in ConTeXt?

I am trying to make some conditionals with Lua, which check if some text is found within a string. Unfortunately, when I compile it, I get: ! LuaTeX error <main ctx instance>:4: bad argument #1 ...
5
votes
0answers
305 views

Lua techniques and libraries for LuaTeX [closed]

With LuaTeX, it is possible to use many libraries and functions that can simplify various aspects of Lua programming. As Lua as language is quite new for the majority of TeX users, I think it would be ...
13
votes
1answer
236 views

Lua function to see if a macro is defined or not

I need to determine if a TeX macro is already defined or not via a Lua function. Any ideas? function IsTeXMacroDefined(macroname) if defined(macroname) then return true end return false end
7
votes
2answers
390 views

How to display special symbols in ConTeXt which are processed by Lua?

I have a ConTeXt document containing many special characters. I have followed the instructions at Which symbols need to be escaped in ConTeXt? to ensure they can all display properly in the document, ...
0
votes
2answers
550 views

Print large macro block from Lua to TeX

I have a rather large block of TeX macro code that is no problem to do in TeX but I'd like to create the macro in Lua instead The macro contains various TeX macro characters (\, %, [, ]) How can I ...
3
votes
1answer
174 views

LPeg self-referential pattern

I am trying to create a self-referential pattern in lua/lpeg local group = lpeg.P(sep1 * (1 - sep2)^0 * group^0 * sep2) notice that group refers to itself. This is not possible since group is ...
-1
votes
1answer
161 views

LPeg alternative match? [closed]

Looking over the LPeg docs I do not see a way to have alternatives(OR) http://www.inf.puc-rio.br/~roberto/lpeg e.g., a | b will match a or b. Am I missing something?
22
votes
5answers
2k views

Reading data from a relational database into a LaTeX table

I'm using Tex Live 2009 on Debian squeeze. I can upgrade if I really, really have to, but I'd rather not. i was wondering if it would be possible to do the following. Given some data in a ...
7
votes
3answers
732 views

What is the correct way to delineate directories in Lua?

I have been experimenting with some Lua code to list directories and provide them to the TeX engine. I have been using the Lua File System (lfs) module. The first part list the current directory ...
4
votes
2answers
422 views

Using macro variables with Lua in ConTeXt

I need to make some macros in ConTeXt. I have tried to use Lua code, but I do not understand how to mix ConTeXt source and Lua source together. Here is an example: \define[3]\textmacro{ \startlua ...
23
votes
7answers
2k views

What are the advantages of Lua over other scripting languages for a TeX implementation?

The question is inspired by Martin Schröder's answer to I am new to TeX. Should I use LaTeX, XeLaTeX, …? as well as my two previous questions on this forum: Automatic document update Generate LaTeX ...
1
vote
0answers
75 views

Sorting tlpdb.tlu output [closed]

I get an output from tlpdb.tlu, which is unsorted. When I now use table.sort the output as a pdf is still unsorted. tlpdb = read_tlpdb( kpse.var_value("SELFAUTOPARENT") ) table.sort(tlpdb) Do I ...
6
votes
1answer
386 views

LuaTeX with unicode-math, how to get the font id of current math font

How can I query informations about the current math font? I tried the following in a document using unicode-math and Cambria Math font \documentclass{article} \usepackage{unicode-math} ...
18
votes
2answers
741 views

LuaJIT and LuaTeX

Is it possible to change the Lua engine in LuaTeX to LuaJIT? Will it be as simple as replacing the Lua5.1 source code in the LuaTeX tarball with the LuaJIT source, or does it require (drastic) ...
4
votes
1answer
87 views

Find node above and under

Using a post_linebreak_filter callback, is it possible to access the nodes positioned above and under a given node?
9
votes
1answer
222 views

Convert color name to pdfliteral code

How can I convert a color name (such as used with the xcolor package) to a pdfliteral code, like q 1 0 0 rg (for red)?
2
votes
1answer
369 views

Using pdfliteral to highlight text

Using pdfliteral, one can color text like the following: w1_prev = node.new("whatsit","pdf_literal") w1_prev.data = "q 1 0 0 rg" w1_prev.mode = 1 w2_prev = ...
6
votes
2answers
102 views

Problems with insert_before and post_linebreak_filter

I'm coding an algorithm to detect and highlight homeoarchies. Here my current almost working (but compiling at least) code: \documentclass{article} \usepackage[french]{babel} \usepackage{kpfonts} ...
2
votes
1answer
95 views

post_linebreak_filter and glyph analysis

When calling a function with a post_linebreak_filter callback, the nodelist only contains nodes of type 0 (hlist), 10 (glue) and 12 (penalty), whereas when using a pre_linebreak_filter callback, type ...
8
votes
1answer
214 views

Testing for TeX boolean in Lua code

How can I test for a TeX boolean in Lua? This kind of code doesn't work: \newif\if@mypkg@someif \begin{luacode} -- some lua code \if@mypkg@someif -- some more lua code \else ...
4
votes
2answers
724 views

How can one get a list of the available functions in Lua(La)TeX

Is there a list or method to determine a list of the lua functions available/installed? Sofar I could only find the lua source files. Maybe I should write something that search through all the ...
3
votes
1answer
632 views

Passing two or more dimensional arrays to lua

I can write: \def\myarray{{Nrs,1,2,3}} then I can call lua: \luadirect{myfunc(\myarray)} and access the values in the array/table. How would one do it for multidimensional ones? I initially ...
3
votes
1answer
138 views

ConTeXt's user namespace seems somewhat empty

With ConTeXt ver: 2010.05.24 13:05 MKIV fmt: 2010.12.18 int: english/english the ConTeXt code \starttext \message{one} \directlua{print(1)} \message{two} \usercode{print(2)} ...
15
votes
1answer
1k views

Installing Lua Modules for use in LuaLaTeX

I've done all of the searching that I can, and I think I've read the right answer, but am too dumb to know that I read it. I can't seem to figure out the magic tricks to get Lua modules, installed by ...
6
votes
2answers
275 views

How to register a callback in ConTeXt

In ConTeXt mkiv, how do I register a callback? callback.register() does nothing (and IIRC most callbacks are frozen anyway) and somewhere I found tasks.appendaction, but this gives me an error that ...
9
votes
2answers
444 views

percent signs in luacode* environment (LuaLaTeX)

Can someone explain what happens here: \documentclass{article} \usepackage{luacode} \begin{document} \begin{luacode*} tex.print("xx\%a","yy\\%b","zz\\\%c") \end{luacode*} \end{document} The ...