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

learn more… | top users | synonyms

7
votes
1answer
70 views

PDF for the hypergeometric distribution

I wish to plot the p.d.f. for the hypergeometric distribution, and I have been using lua combined with pgfplots. However I get an error when I use the density function with the formula for the ...
8
votes
0answers
35 views

How to use luatex's node.hpack so that marks, inserts and vadjusts migrate out?

TeX's hpack routine packages an hlist into a box. While doing that it looks at a global pointer adjust_tail and if that is not "null" it migrates some nodes to a separate list starting at ...
8
votes
1answer
135 views

LuaLaTeX for dummies: how to add LaTeX macros into \directlua?

How to make the following code to compile? \documentclass{article} \newcommand*{\mycommand}{\directlua{for i = 1, 10 do tex.sprint(i\hskip1cm) end}} %does not work ...
16
votes
1answer
267 views

LuaLaTeX for dummies: basic directlua use

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 * ...
35
votes
1answer
451 views

Replacement(s) for TeX's paragraph builder using LuaTeX

The LuaTeX engine provides a callback that allows you to replace the built-in paragraph builder by your own algorithm. My question is twofold: does there exist a lua implementation that fully (or ...
39
votes
5answers
2k views

Practical use of Lua

Although I always use LuaLaTeX to compile my documents, I don't really use Lua that often. Sometimes I even forget about it. In my last document I used it to write a random word generator, which ...
8
votes
2answers
103 views

Escape a string printed from Lua using ConTeXt

This seems to have come up a couple times, but I cannot glean an answer to the generic question of how one might protect an arbitrary string in Lua to ensure its characters are printed. In other ...
2
votes
0answers
42 views

Using Lua in listed elements (List of Figures, List of Tables, List of Content)

I am not sure if I use the wrong approach or if this is an issue in LuaLaTex in general. I tried to integrate some internationalization (I18n) to our documentation framework using Lua. Long story, ...
1
vote
0answers
89 views

Why lua and not python? [duplicate]

I mean instead of lualatex. I came across the python package, so I am not asking about python support. What was so special about lua that people spent so much time on that instead of doing something ...
1
vote
1answer
69 views

references to floats without ever using figure numbers (possbily using lua or python)

Stephen Wolfram's 'A New Kind of Science' states in its colophon that it has 973 illustrations spread out over 1280 pages. Remarkably, he accomplishes this without ever using figure numbers. No figure ...
8
votes
2answers
126 views

How to manipulate a multi-line string in luatex?

I want to write a Lua function that processes some multi-line string. Thus, I created a new file test.lua which contains userdata = userdata or {} function userdata.surroundwithdashes(str) str = ...
2
votes
0answers
66 views

How to parse BIB file to a known TeX structure?

I'm becoming a TeXist by profession these days. This is the first real challenge from my new employer: I was asked if I could take a look at this problem and improve the current state, if it's ...
3
votes
0answers
68 views

How to get and process bitmap graphics at a pixel level on-the-fly?

We are trying to solve How to get intersection point(s) of two glyphs? and there are some interesting subtasks. In word cloud algorithms they are converting glyphs (a vector form) to a raster form and ...
19
votes
0answers
373 views

wxLua in LuaLaTeX

I have some problems using wxLua in LuaLateX. This works: lua simpleui.lua (print instead of tex.print) But if i try this: lualatex wx.tex it doesn't work. \documentclass{article} ...
11
votes
2answers
377 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
156 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 ...
5
votes
2answers
202 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
126 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
115 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, ...
13
votes
1answer
227 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
277 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
201 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
422 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 ...
13
votes
3answers
4k 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 ...
17
votes
4answers
741 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} ...
9
votes
1answer
822 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
2k 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
369 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
339 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
284 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
405 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
755 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
362 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
535 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
434 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
327 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
274 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
422 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, ...
1
vote
2answers
593 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
192 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
168 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?
23
votes
5answers
3k 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
910 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
488 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 ...
32
votes
7answers
3k 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
77 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 ...
7
votes
1answer
452 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
858 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) ...
5
votes
1answer
96 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?