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

learn more… | top users | synonyms

2
votes
1answer
31 views

tex4ebook and 4ht files

I am using MiKTeX on windows and calling tex4ebook.lua as a parameter to lualatex to make epub3. Can somebody explain in simple terms what the .4ht files in the tex4ebook directory are used for ...
2
votes
1answer
54 views

Execute luacode after \end{document} to rename pdf file after creation

I'm using toggle switches to create different outputs with a single tex-file. However my output PDF is always named after the producing tex-file e.g. luaexample.tex produces luaexample.pdf. Along ...
5
votes
2answers
193 views

why luacode environments do not ignore lua comment — lines?

I do understand (a little) the difference between luacode and luacode* But I almost fell of my seat when something I wrote inside a commented line caused lualatex to scream at me. I changed luacode* ...
3
votes
2answers
73 views

why lua multiline string [[ ]] does not work going from LUA to Latex?

lua supports multiline strings. I need to send such string from LUA back to Latex. I first verified the code works using lua standalone engine but lualatex does not like something. Here is the ...
1
vote
1answer
36 views

another luacode new line question, how to generate new line without making everything string

I wanted to print something from luacode, and have it show up on its own line in Latex, not on the same line. The question here, which is similar, but uses strings, but I am not printing strings from ...
13
votes
3answers
233 views

Accessing TeX token or exporting filtered plain text

(updated according to gained information) In the context of keyword extraction from arbitrary (La)TeX documents and simple manipulations with them (automated annotation), I would like to be able to ...
2
votes
1answer
67 views

Implementing \luaescapestring in plain e-TeX

I'm trying to implement \luaescapestring in plain e-TeX. My solution needs to be fully expandable, so that \immediate\write\luascript{ local file = "\luaescapestring{\something}" } works. The ...
3
votes
1answer
116 views

How to use LaTeX commands in a luacode* environment?

How can one access LaTeX commands in the starred version of luacode environment? I am basically interested in using \ifdefined code below. For example, this works: \documentclass{article} \...
2
votes
1answer
92 views

Compilation time speed up for this pgfplots figure possible?

I already experienced in this question that the right choice of assignments for the coordinate values and meta values from a table could increase the compilation speed of pgfplots due to the lua ...
3
votes
1answer
71 views

How to determine the lua version in texlive 2015

I look for the lua interpreter version in luatex in texlive 2015 ?
3
votes
1answer
49 views

Help integrating some LUA code into a Luatex document?

Consider the following MWE: \documentclass[12pt,a4paper]{amsart} \usepackage{fontspec} \usepackage{luacode} \begin{document} ABC \begin{luacode} tex.sprint(os.date("compiled on --- %A at %X " )...
0
votes
1answer
69 views

Run pdflatex.exe from LuaLaTeX document

My document-combiner combine pdf-files via package pdfpages using command \includepdf. But before including, a source tex compiling by pdflatex.exe to produce the pdf. But now I have a little ...
4
votes
1answer
72 views

Is there a way to step through LuaLaTeX macros using a remote debugger?

Writing LaTeX macros has always been difficult, and it seems like writing a major package can only be accomplished by a Real Programmer. Fortunately, LuaTeX is on its way, and writing Lua macros is ...
2
votes
1answer
73 views

LuaLaTeX output from tex.print not interpreted

This is a follow-up from my previous answer to Automated Creation of Questions and Solutions for a Worksheet/Exam. I realised, that the macros I created like this \ewcommand{\currentI}{\directlua{tex....
4
votes
1answer
49 views

LuaLatTeX inefficiency in transliteration from cyrillic of acute accented vowels

Transliteration from cyrillic to latin characters can be done in LuaLaTeX with the help of directlua as shown by @DavidCarlisle: Create a mapping for transliteration from cyrillic to latin in LuaLaTeX ...
4
votes
1answer
78 views

Lua to Tex : content and variable content different?

Here is something bizarre ! (I mean I don't understand). I enter a content, let's say "Something" in the (global) variable context. In line 2 of the following code, as one may anticipate, we have the ...
1
vote
1answer
43 views

How to redefine a command to keep track of page assignments w/o exceeding TeX capacity

Seemed straight-forward enough (and I've changed it per Christian's suggestion of using \edef instead and added some status code): \documentclass{memoir} \newcommand{\tabloidpagecount}{} \newcommand{...
3
votes
1answer
149 views

Using LuaLaTeX to calculate lengths in cm to be used in TikZ drawing

What I am trying to accomplish is the calculation of a length in cm, which I need for a TikZ drawing. The calculation itself is not trivial (cubic root, which I turned into math.log and math.exp), ...
1
vote
1answer
42 views

How to insert output of Lua script verbatim at location with LuaLaTeX?

I'm using TikZ' graph layout engine, and I'm very confused as to why \graph {1, 2, 3, 2--3}; draws the desired graph, while \graph {\directlua{dofile("foo.lua")}}; does not when foo.lua just ...
3
votes
1answer
192 views

Symbol not found error when using Lua C .so module with LuaLaTeX

I am trying to get a basic Lua C .so module working with LuaLaTeX. I am able to run the library using my local Lua interpreter just fine (lua test.lua). But when I try to load it inside LuaLaTeX, I ...
5
votes
1answer
43 views

How to get a customized number of decimal places in tex.sprint / directlua / qrCode?

The number of decimal places is "9" in the following example: string.format("\%0.9f", X). How can one achieve the replacement of the fixed "9" decimal places with "NumberOfDecimalPlaces" (in ...
7
votes
1answer
104 views

LuaTeX gets stuck when “.” is added to pattern-expression

today on SE I got inspired to try LuaTeX. I'm facing a problem where the compilation process stalls at some point if I add a single "." to a pattern matching expression. In short, this works: line =...
6
votes
1answer
110 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: ...
5
votes
3answers
235 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
162 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 ...
5
votes
0answers
243 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
149 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
436 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 ...
6
votes
1answer
257 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
692 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
877 views

Install make4ht with MiKTeX

I am trying to install make4ht on a system running MiKTex. The recommended instructions https://d800fotos.wordpress.com/2015/01/19/create-e-books-from-latex-tex-files-ebook-aus-latex-tex-dateien-...
8
votes
2answers
537 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)}) \documentclass[...
3
votes
1answer
210 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} \newcommand{\...
6
votes
1answer
261 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 ...
25
votes
0answers
382 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
866 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
349 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 ...
21
votes
0answers
154 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 adjust_head....
12
votes
1answer
725 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 %\newcommand*{\mycommand}{\...
20
votes
1answer
786 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 * ...
38
votes
1answer
601 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 ...
43
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
250 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
69 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
115 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
131 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 ...
10
votes
2answers
563 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
143 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
232 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 ...
33
votes
0answers
779 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} \directlua{...