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

learn more… | top users | synonyms

6
votes
1answer
71 views

Is it possible, in LuaTeX, to replace text from the input buffer but only inside math mode?

I am trying to create a Lua script that lets me replace all instances of -> inside my equations with \rightarrow. I found this answer that suggests a hack involving a process_input_buffer callback: ...
4
votes
3answers
124 views

Problem printing LaTeX from lua in lualatex

I am having difficulty printing LaTeX from a lua function in a LaTeX document processed with lualatex (version 0.70.2). I have a sample that works (if I remove all newlines from the code) and a case ...
2
votes
0answers
91 views

pgfplotstable: typset csv with 2 or more header lines (eg. name, unit, comment)

I am exporting from Origin and get a Data.csv like this: Short_Name1; Short_Name2 Long_Name1; Long_Name2 Unit1; Unit2 Comment1; Comment2 1,1; 2,0 3,5; 4,3 When I try to ...
3
votes
0answers
122 views

How to add/check missing punctuation marks (itemize/enumerate) automatically?

(An experiment) I'd like to present you one of the possible tasks (to be automated) I solve in my daily work: adding missing punctuation marks in the itemize and enumerate environments. I polish ...
3
votes
0answers
92 views

luatodonotes and tikz externalization won't mix

Consider the following code: documentclass[11pt]{report} \usepackage{pgfplots} \usepgfplotslibrary{external} \tikzexternalize %\usepackage{luatodonotes} \begin{document} \begin{tikzpicture} ...
6
votes
1answer
203 views

How to get vector graphics from Concorde program?

Back in around 2009/2010, my former colleague Libor Sarga (a beginner in TeX at that time), asked me if I could help him to get a vector form of his results obtained from Concorde. He was writing a ...
5
votes
1answer
140 views

LuaTeX: How to handle a Lua function that prints TeX macros

Let's say that I have a Lua function that prints TeX macros: How can those macros be executed during compilation with LuaLaTeX? In the following example, I defined a LaTeX macro that should print a ...
3
votes
1answer
453 views

LuaTeX - unexpected symbol near '>'

I wrote my first Lua code and it works as expected when running through lua.exe. But when I try to include the lua file or its complete source code I always get the error ! LuaTeX error mr.lua:11: ...
2
votes
1answer
545 views

Install make4ht with MiKTeX

I am trying to install make4ht on a system running MiKTex. The recommended instructions ...
7
votes
2answers
334 views

Lua code with Tikz

Is there a reason why the code below leads to the error: ! Illegal unit of measure (pt inserted). <to be read again> e l.16 ...t [domain=-.1:.1,samples = 100] (\x,{G(\x)}) ...
3
votes
1answer
139 views

Write/Read values of the LaTeX commands (like \title, \ author etc) in file using Lua

This problem relate with other my question here . I found a solution with pdfpages package thanks to TX.SX: \documentclass[]{scrbook} \usepackage{authblk} \usepackage{pdfpages} ...
6
votes
1answer
164 views

Convert all all-caps words to small caps

I'd like to turn all all-uppercase words, acronyms etc. into small caps, preferably automatically on the fly and without changing the source files. The ideal solution would also allow me to block some ...
16
votes
0answers
210 views

What is “the” LUA root for context packages?

As package author, I want to write a LUA module which can be found by both lualatex and context. The lualatex prototype works reasonably and I am convinced that this will also be true if I release ...
28
votes
1answer
616 views

Best Practices for Lua Modules

In the Lua world Lua Modules are installed using LuaRocks. With LuaTeX these modules are normally installed in the scripts folder (under MikTeX windows). What tools are available for downloading and ...
8
votes
1answer
198 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 ...
15
votes
0answers
87 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 ...
10
votes
1answer
404 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 ...
18
votes
1answer
514 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 * ...
37
votes
1answer
537 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 ...
42
votes
5answers
3k 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
196 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
62 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
103 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
117 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 ...
9
votes
2answers
338 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
101 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
130 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 ...
24
votes
0answers
529 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
800 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 ...
4
votes
2answers
300 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
239 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
174 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
140 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, ...
14
votes
1answer
315 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
319 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
224 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
461 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 ...
14
votes
3answers
7k 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 ...
18
votes
4answers
950 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
981 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
3k 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
420 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 ...
11
votes
3answers
2k 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
457 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
434 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
501 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 ...
8
votes
2answers
1k 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
447 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 ...
8
votes
3answers
661 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
616 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 ...